mirror of https://github.com/fantasticit/think.git
feat: improve read document speed
This commit is contained in:
parent
98faa451b5
commit
4b2722757d
|
@ -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}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -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={
|
||||||
|
initialContent ? (
|
||||||
|
<ReaderEditor content={initialContent} />
|
||||||
|
) : (
|
||||||
<div style={{ width: 174, margin: 'auto' }}>
|
<div style={{ width: 174, margin: 'auto' }}>
|
||||||
<Spin tip="正在为您加载编辑器中...">
|
<Spin tip="正在为您加载编辑器中...">
|
||||||
{/* FIXME: semi-design 的问题,不加 div,文字会换行! */}
|
{/* FIXME: semi-design 的问题,不加 div,文字会换行! */}
|
||||||
<div></div>
|
<div></div>
|
||||||
</Spin>
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
error={error}
|
error={error}
|
||||||
errorContent={(error) => (
|
errorContent={(error) => (
|
||||||
|
|
|
@ -28,6 +28,12 @@ export interface ICollaborationEditorProps {
|
||||||
*/
|
*/
|
||||||
user: ILoginUser | null;
|
user: ILoginUser | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始内容
|
||||||
|
* websocket 连接比较耗时,可以先用初始内容展现
|
||||||
|
*/
|
||||||
|
initialContent?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文档标题变动
|
* 文档标题变动
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue