@seafile/sdoc-editor 0.1.136 → 0.1.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import React, { useEffect, useMemo, useState, forwardRef, useImperativeHandle } from 'react';
|
|
3
3
|
import { Editor } from '@seafile/slate';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import
|
|
5
|
+
import { createDefaultEditor } from './extension';
|
|
6
6
|
import { focusEditor } from './extension/core';
|
|
7
7
|
import { withSocketIO } from './socket';
|
|
8
8
|
import withNodeId from './node-id';
|
|
@@ -18,6 +18,7 @@ var SDocEditor = forwardRef(function (_ref, ref) {
|
|
|
18
18
|
|
|
19
19
|
// init editor
|
|
20
20
|
var editor = useMemo(function () {
|
|
21
|
+
var defaultEditor = createDefaultEditor();
|
|
21
22
|
var newEditor = withNodeId(withSocketIO(defaultEditor, {
|
|
22
23
|
document: document,
|
|
23
24
|
config: config
|
|
@@ -25,6 +26,7 @@ var SDocEditor = forwardRef(function (_ref, ref) {
|
|
|
25
26
|
var cursors = document.cursors;
|
|
26
27
|
newEditor.cursors = cursors || {};
|
|
27
28
|
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
29
|
+
newEditor.readonly = false;
|
|
28
30
|
return newEditor;
|
|
29
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
32
|
}, []);
|
|
@@ -13,5 +13,15 @@ var defaultEditor = Plugins === null || Plugins === void 0 ? void 0 : Plugins.re
|
|
|
13
13
|
}
|
|
14
14
|
return editor;
|
|
15
15
|
}, baseEditor);
|
|
16
|
+
export var createDefaultEditor = function createDefaultEditor() {
|
|
17
|
+
var defaultEditor = Plugins === null || Plugins === void 0 ? void 0 : Plugins.reduce(function (editor, pluginItem) {
|
|
18
|
+
var withPlugin = pluginItem.editorPlugin;
|
|
19
|
+
if (withPlugin) {
|
|
20
|
+
return withPlugin(editor);
|
|
21
|
+
}
|
|
22
|
+
return editor;
|
|
23
|
+
}, withHistory(withReact(createEditor())));
|
|
24
|
+
return defaultEditor;
|
|
25
|
+
};
|
|
16
26
|
export default defaultEditor;
|
|
17
27
|
export { renderLeaf, renderElement, Toolbar, ContextToolbar, SideToolbar };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { Fragment,
|
|
2
|
-
import classnames from 'classnames';
|
|
1
|
+
import React, { Fragment, useMemo } from 'react';
|
|
3
2
|
import { Editable, Slate } from '@seafile/slate-react';
|
|
4
|
-
import
|
|
3
|
+
import { renderLeaf as _renderLeaf, renderElement as _renderElement, createDefaultEditor } from '../extension';
|
|
5
4
|
import withNodeId from '../node-id';
|
|
6
5
|
import { generateDefaultDocContent } from '../../utils';
|
|
7
6
|
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
@@ -14,7 +13,10 @@ var SDocViewer = function SDocViewer(_ref) {
|
|
|
14
13
|
customRenderElement = _ref.renderElement,
|
|
15
14
|
showToolbar = _ref.showToolbar,
|
|
16
15
|
showOutline = _ref.showOutline;
|
|
17
|
-
var editor =
|
|
16
|
+
var editor = useMemo(function () {
|
|
17
|
+
var defaultEditor = createDefaultEditor();
|
|
18
|
+
return withNodeId(defaultEditor);
|
|
19
|
+
}, []);
|
|
18
20
|
editor.readonly = true;
|
|
19
21
|
var slateValue = (document || generateDefaultDocContent()).children;
|
|
20
22
|
var decorate = usePipDecorate(editor);
|