This commit is contained in:
@@ -33,6 +33,6 @@ class WikiAssetsController < ApplicationController
|
|||||||
page.update!(next_asset_no: no + 1)
|
page.update!(next_asset_no: no + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: asset
|
render json: asset.as_json(methods: [:url])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,4 +7,8 @@ class WikiAsset < ApplicationRecord
|
|||||||
has_one_attached :file
|
has_one_attached :file
|
||||||
|
|
||||||
validates :file, presence: true
|
validates :file, presence: true
|
||||||
|
|
||||||
|
def url
|
||||||
|
Rails.application.routes.url_helpers.rails_blob_url(file, only_path: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,18 +1,6 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
|
||||||
import { useMemo } from 'react'
|
|
||||||
import ReactMarkdown from 'react-markdown'
|
|
||||||
import remarkGFM from 'remark-gfm'
|
|
||||||
|
|
||||||
import PrefetchLink from '@/components/PrefetchLink'
|
|
||||||
import WikiMarkdown from '@/components/WikiMarkdown'
|
import WikiMarkdown from '@/components/WikiMarkdown'
|
||||||
import SectionTitle from '@/components/common/SectionTitle'
|
|
||||||
import SubsectionTitle from '@/components/common/SubsectionTitle'
|
|
||||||
import { wikiKeys } from '@/lib/queryKeys'
|
|
||||||
import remarkWikiAutoLink from '@/lib/remark-wiki-autolink'
|
|
||||||
import { fetchWikiPages } from '@/lib/wiki'
|
|
||||||
|
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import type { Components } from 'react-markdown'
|
|
||||||
|
|
||||||
type Props = { title: string
|
type Props = { title: string
|
||||||
body?: string }
|
body?: string }
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import MarkdownIt from 'markdown-it'
|
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import MdEditor from 'react-markdown-editor-lite'
|
import MdEditor from 'react-markdown-editor-lite'
|
||||||
|
|
||||||
|
import WikiMarkdown from '@/components/WikiMarkdown'
|
||||||
import Label from '@/components/common/Label'
|
import Label from '@/components/common/Label'
|
||||||
|
import { apiPost } from '@/lib/api'
|
||||||
|
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
|
|
||||||
const mdParser = new MarkdownIt
|
import type { WikiAsset } from '@/types'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
title: string
|
||||||
@@ -60,7 +61,7 @@ export default (({ title: initTitle, body: initBody, onSubmit, id }: Props) => {
|
|||||||
<MdEditor
|
<MdEditor
|
||||||
value={body}
|
value={body}
|
||||||
style={{ height: '500px' }}
|
style={{ height: '500px' }}
|
||||||
renderHTML={text => mdParser.render (text)}
|
renderHTML={text => <WikiMarkdown body={text} preview/>}
|
||||||
onChange={({ text }) => setBody (text)}
|
onChange={({ text }) => setBody (text)}
|
||||||
onImageUpload={handleImageUpload}/>
|
onImageUpload={handleImageUpload}/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -149,6 +149,11 @@ export type User = {
|
|||||||
|
|
||||||
export type ViewFlagBehavior = typeof ViewFlagBehavior[keyof typeof ViewFlagBehavior]
|
export type ViewFlagBehavior = typeof ViewFlagBehavior[keyof typeof ViewFlagBehavior]
|
||||||
|
|
||||||
|
export type WikiAsset = {
|
||||||
|
wikiPageId: number
|
||||||
|
no: number
|
||||||
|
url: string }
|
||||||
|
|
||||||
export type WikiPage = {
|
export type WikiPage = {
|
||||||
id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
|
|||||||
Reference in New Issue
Block a user