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} user={user}
id={documentId} id={documentId}
type="document" type="document"
initialContent={document.content}
renderInEditorPortal={renderAuthor} renderInEditorPortal={renderAuthor}
onAwarenessUpdate={triggerJoinUser} onAwarenessUpdate={triggerJoinUser}
/> />

View File

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

View File

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