このコミットが含まれているのは:
@@ -36,12 +36,10 @@ const mdComponents = { h1: ({ children }) => <SectionTitle>{children}</SectionT
|
||||
export default (({ title, body }: Props) => {
|
||||
const [pageNames, setPageNames] = useState<string[]> ([])
|
||||
|
||||
const remarkPlugins = useMemo (() => [remarkWikiAutoLink (pageNames)], [pageNames])
|
||||
const remarkPlugins = useMemo (
|
||||
() => [() => remarkWikiAutoLink (pageNames), remarkGFM], [pageNames])
|
||||
|
||||
useEffect (() => {
|
||||
if (!(body))
|
||||
return
|
||||
|
||||
void (async () => {
|
||||
try
|
||||
{
|
||||
@@ -54,7 +52,7 @@ export default (({ title, body }: Props) => {
|
||||
setPageNames ([])
|
||||
}
|
||||
}) ()
|
||||
}, [body])
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<ReactMarkdown components={mdComponents} remarkPlugins={remarkPlugins}>
|
||||
|
||||
@@ -4,7 +4,7 @@ const escapeForRegExp = (s: string) => s.replace (/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
|
||||
|
||||
export default (pageNames: string[], basePath = '/wiki'): ((tree: Root) => void) => {
|
||||
const names = pageNames.sort ((a, b) => b.length - a.length)
|
||||
const names = [...pageNames].sort ((a, b) => b.length - a.length)
|
||||
|
||||
if (names.length === 0)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ export default (pageNames: string[], basePath = '/wiki'): ((tree: Root) => void)
|
||||
if (start > last)
|
||||
parts.push ({ type: 'text', value: value.slice (last, start) })
|
||||
|
||||
const name = m[0]
|
||||
const name = m[1]
|
||||
parts.push ({ type: 'link',
|
||||
url: `${ basePath }/${ encodeURIComponent (name) }`,
|
||||
title: null,
|
||||
|
||||
@@ -36,6 +36,7 @@ export default () => {
|
||||
if (/^\d+$/.test (title))
|
||||
{
|
||||
void (async () => {
|
||||
setWikiPage (undefined)
|
||||
try
|
||||
{
|
||||
const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`)
|
||||
@@ -52,6 +53,7 @@ export default () => {
|
||||
}
|
||||
|
||||
void (async () => {
|
||||
setWikiPage (undefined)
|
||||
try
|
||||
{
|
||||
const res = await axios.get (
|
||||
|
||||
@@ -12,6 +12,8 @@ import Forbidden from '@/pages/Forbidden'
|
||||
|
||||
import 'react-markdown-editor-lite/lib/index.css'
|
||||
|
||||
import type { FC } from 'react'
|
||||
|
||||
import type { User, WikiPage } from '@/types'
|
||||
|
||||
const mdParser = new MarkdownIt
|
||||
@@ -19,7 +21,7 @@ const mdParser = new MarkdownIt
|
||||
type Props = { user: User | null }
|
||||
|
||||
|
||||
export default ({ user }: Props) => {
|
||||
export default (({ user }: Props) => {
|
||||
if (!(['admin', 'member'].some (r => user?.role === r)))
|
||||
return <Forbidden/>
|
||||
|
||||
@@ -93,9 +95,9 @@ export default ({ user }: Props) => {
|
||||
{/* 送信 */}
|
||||
<button onClick={handleSubmit}
|
||||
className="px-4 py-2 bg-blue-600 text-white rounded disabled:bg-gray-400">
|
||||
追加
|
||||
編輯
|
||||
</button>
|
||||
</>)}
|
||||
</div>
|
||||
</MainArea>)
|
||||
}
|
||||
}) satisfies FC<Props>
|
||||
|
||||
新しい課題から参照
ユーザをブロックする