diff --git a/packages/client/src/components/tiptap/extensions/documents/reference/index.tsx b/packages/client/src/components/tiptap/extensions/documents/reference/index.tsx index a73f64fe..549369a9 100644 --- a/packages/client/src/components/tiptap/extensions/documents/reference/index.tsx +++ b/packages/client/src/components/tiptap/extensions/documents/reference/index.tsx @@ -1,24 +1,13 @@ -import { - Node, - Command, - mergeAttributes, - textInputRule, - textblockTypeInputRule, - wrappingInputRule, -} from '@tiptap/core'; +import { Node, Command, mergeAttributes, wrappingInputRule } from '@tiptap/core'; import { NodeViewWrapper, NodeViewContent, ReactNodeViewRenderer } from '@tiptap/react'; import { useRouter } from 'next/router'; import Link from 'next/link'; -import { Space, Select, Popover, Tag, Input, Typography } from '@douyinfe/semi-ui'; +import { Select } from '@douyinfe/semi-ui'; import { useWikiTocs } from 'data/wiki'; -import { useDocumentDetail } from 'data/document'; import { DataRender } from 'components/data-render'; -import { Empty } from 'components/empty'; import { IconDocument } from 'components/icons'; import styles from './index.module.scss'; -const { Text } = Typography; - declare module '@tiptap/core' { interface Commands { documentReference: { @@ -92,34 +81,36 @@ const Render = ({ editor, node, updateAttributes }) => { const { wikiId, documentId, title } = node.attrs; const { data: tocs, loading, error } = useWikiTocs(isShare ? null : wikiIdFromUrl); + const selectDoc = (str) => { + const [wikiId, documentId, title] = str.split('/'); + updateAttributes({ wikiId, documentId, title }); + }; + return (
{isEditable && ( - selectDoc(v)} + {...(wikiId && documentId ? { value: `${wikiId}/${documentId}/${title}` } : {})} > - {toc.title} - - ))} - + {(tocs || []).map((toc) => ( + + {toc.title} + + ))} + + )} + /> )} - { > - {title} + {title || '请选择文档'}
- {/*
- 子文档 - { - if (!documents || !documents.length) { - return ; - } - return ( -
- {documents.map((doc) => { - return ( - - - - {doc.title} - - - ); - })} -
- ); - }} - /> -
*/}
); diff --git a/packages/client/src/data/wiki.tsx b/packages/client/src/data/wiki.tsx index 0c321afc..19b8fbec 100644 --- a/packages/client/src/data/wiki.tsx +++ b/packages/client/src/data/wiki.tsx @@ -95,7 +95,7 @@ export const useWikiHomeDoc = (wikiId) => { export const useWikiTocs = (wikiId) => { const { data, error, mutate } = useSWR>( `/wiki/tocs/${wikiId}`, - (url) => HttpClient.get(url) + (url) => (wikiId ? HttpClient.get(url) : null) ); const loading = !data && !error;