feat: improve read document speed

This commit is contained in:
fantasticit 2022-05-24 17:53:42 +08:00
parent 98faa451b5
commit 4b2722757d
3 changed files with 19 additions and 6 deletions

View File

@ -154,6 +154,7 @@ export const DocumentReader: React.FC<IProps> = ({ documentId }) => {
user={user}
id={documentId}
type="document"
initialContent={document.content}
renderInEditorPortal={renderAuthor}
onAwarenessUpdate={triggerJoinUser}
/>

View File

@ -8,6 +8,7 @@ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, use
import { IndexeddbPersistence } from 'tiptap/core/y-indexeddb';
import { Editor } from '../../react';
import { ReaderEditor } from '../reader';
import { EditorInstance } from './editor';
import styles from './index.module.scss';
import { ICollaborationEditorProps, ProviderStatus } from './type';
@ -26,6 +27,7 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
onTitleUpdate,
user,
menubar,
initialContent,
renderInEditorPortal,
onAwarenessUpdate,
} = props;
@ -98,12 +100,16 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
<DataRender
loading={loading}
loadingContent={
initialContent ? (
<ReaderEditor content={initialContent} />
) : (
<div style={{ width: 174, margin: 'auto' }}>
<Spin tip="正在为您加载编辑器中...">
{/* FIXME: semi-design 的问题,不加 div文字会换行! */}
<div></div>
</Spin>
</div>
)
}
error={error}
errorContent={(error) => (

View File

@ -28,6 +28,12 @@ export interface ICollaborationEditorProps {
*/
user: ILoginUser | null;
/**
*
* websocket
*/
initialContent?: string;
/**
*
*/