diff --git a/packages/client/src/components/document/reader/author.tsx b/packages/client/src/components/document/reader/author.tsx new file mode 100644 index 0000000..c48c598 --- /dev/null +++ b/packages/client/src/components/document/reader/author.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { Space, Avatar } from '@douyinfe/semi-ui'; +import { LocaleTime } from 'components/locale-time'; +import { IconUser } from '@douyinfe/semi-icons'; +import { IDocument } from '@think/domains'; + +interface IProps { + document: IDocument; +} + +export const Author: React.FC = ({ document }) => { + return ( +
+ + + + +
+

+ 创建者: + {document.createUser && document.createUser.name} +

+

+ 最近更新日期: + + {' ⦁ '}阅读量: + {document.views} +

+
+
+
+ ); +}; diff --git a/packages/client/src/components/document/reader/index.tsx b/packages/client/src/components/document/reader/index.tsx index 977282a..eaca35c 100644 --- a/packages/client/src/components/document/reader/index.tsx +++ b/packages/client/src/components/document/reader/index.tsx @@ -2,21 +2,8 @@ import Router from 'next/router'; import React, { useCallback, useMemo, useState } from 'react'; import { createPortal } from 'react-dom'; import cls from 'classnames'; -import { - Layout, - Nav, - Space, - Avatar, - Button, - Typography, - Skeleton, - Tooltip, - Popover, - BackTop, - Spin, -} from '@douyinfe/semi-ui'; -import { LocaleTime } from 'components/locale-time'; -import { IconUser, IconEdit, IconArticle } from '@douyinfe/semi-icons'; +import { Layout, Nav, Space, Button, Typography, Skeleton, Tooltip, Popover, BackTop, Spin } from '@douyinfe/semi-ui'; +import { IconEdit, IconArticle } from '@douyinfe/semi-icons'; import { Seo } from 'components/seo'; import { DataRender } from 'components/data-render'; import { DocumentShare } from 'components/document/share'; @@ -31,6 +18,7 @@ import { useUser } from 'data/user'; import { useDocumentDetail } from 'data/document'; import { triggerJoinUser } from 'event'; import { CollaborationEditor } from 'tiptap/editor'; +import { Author } from './author'; import styles from './index.module.scss'; const { Header } = Layout; @@ -70,37 +58,7 @@ export const DocumentReader: React.FC = ({ documentId }) => { const target = element && element.querySelector('.ProseMirror .title'); if (target) { - return createPortal( -
- - - - -
-

- 创建者: - {document.createUser && document.createUser.name} -

-

- 最近更新日期: - - {' ⦁ '}阅读量: - {document.views} -

-
-
-
, - target - ); + return createPortal(, target); } return null; diff --git a/packages/client/src/components/document/reader/public/index.tsx b/packages/client/src/components/document/reader/public/index.tsx index cea85f9..a955944 100644 --- a/packages/client/src/components/document/reader/public/index.tsx +++ b/packages/client/src/components/document/reader/public/index.tsx @@ -1,4 +1,5 @@ import React, { useMemo, useRef, useCallback } from 'react'; +import { createPortal } from 'react-dom'; import cls from 'classnames'; import { Layout, @@ -26,6 +27,7 @@ import { useDocumentStyle } from 'hooks/use-document-style'; import { usePublicDocument } from 'data/document'; import { DocumentSkeleton } from 'tiptap/components/skeleton'; import { CollaborationEditor } from 'tiptap/editor'; +import { Author } from '../author'; import styles from './index.module.scss'; const { Header, Content } = Layout; @@ -44,6 +46,21 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = return width === 'standardWidth' ? styles.isStandardWidth : styles.isFullWidth; }, [width]); + const renderAuthor = useCallback( + (element) => { + if (!document) return null; + + const target = element && element.querySelector('.ProseMirror .title'); + + if (target) { + return createPortal(, target); + } + + return null; + }, + [data] + ); + const handleOk = useCallback(() => { $form.current.validate().then((values) => { query(values.password); @@ -121,7 +138,7 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = }} loadingContent={
- 1 +
} normalContent={() => { @@ -132,7 +149,14 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = style={{ fontSize }} > - + document.querySelector('#js-share-document-editor-container').parentNode} />