@seafile/sdoc-editor 0.1.170 → 0.1.172-beta
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/{highlight-decorate → decorate/highlight-decorate}/index.js +4 -2
- package/dist/basic-sdk/{highlight-decorate → decorate/highlight-decorate}/setNodeToDecorations.js +3 -3
- package/dist/basic-sdk/{decorates → decorate}/index.js +4 -2
- package/dist/basic-sdk/decorate/rebase-decorate/index.js +29 -0
- package/dist/basic-sdk/decorate/rebase-decorate/rebase-delete-modify-decorate.js +64 -0
- package/dist/basic-sdk/decorate/rebase-decorate/rebase-modify-delete-decorate.js +64 -0
- package/dist/basic-sdk/decorate/rebase-decorate/rebase-modify-modify-decorate.js +97 -0
- package/dist/basic-sdk/editor/editable-article.js +1 -2
- package/dist/basic-sdk/editor/sdoc-editor.js +72 -8
- package/dist/basic-sdk/extension/core/transforms/index.js +2 -1
- package/dist/basic-sdk/extension/core/transforms/update-parent-node.js +25 -0
- package/dist/basic-sdk/extension/render/custom-render-element.js +148 -0
- package/dist/basic-sdk/extension/render/render-element.js +9 -365
- package/dist/basic-sdk/index.js +1 -1
- package/dist/basic-sdk/socket/socket-manager.js +7 -1
- package/dist/basic-sdk/views/readonly-article.js +1 -2
- package/package.json +1 -1
- package/dist/basic-sdk/editor/index.js +0 -84
- /package/dist/basic-sdk/{editor → decorate/rebase-decorate}/index.css +0 -0
- /package/dist/basic-sdk/extension/core/transforms/{replace-node-children.js → replace-node.js} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { Element } from '@seafile/slate';
|
|
3
|
-
import { CODE_LINE } from '
|
|
3
|
+
import { CODE_LINE } from '../../extension/constants';
|
|
4
|
+
import { SetNodeToDecorations } from './setNodeToDecorations';
|
|
4
5
|
export var highlightDecorate = function highlightDecorate(editor) {
|
|
5
6
|
return function (_ref) {
|
|
6
7
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -14,4 +15,5 @@ export var highlightDecorate = function highlightDecorate(editor) {
|
|
|
14
15
|
}
|
|
15
16
|
return ranges;
|
|
16
17
|
};
|
|
17
|
-
};
|
|
18
|
+
};
|
|
19
|
+
export { SetNodeToDecorations };
|
package/dist/basic-sdk/{highlight-decorate → decorate/highlight-decorate}/setNodeToDecorations.js
RENAMED
|
@@ -4,9 +4,9 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
4
4
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
5
5
|
import { Node, Element, Editor } from '@seafile/slate';
|
|
6
6
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
7
|
-
import Prism, { normalizeTokens, normalizeTokensByLanguageType } from '
|
|
8
|
-
import { CODE_BLOCK } from '
|
|
9
|
-
import { getValidLang } from '
|
|
7
|
+
import Prism, { normalizeTokens, normalizeTokensByLanguageType } from '../../extension/plugins/code-block/prismjs';
|
|
8
|
+
import { CODE_BLOCK } from '../../extension/constants';
|
|
9
|
+
import { getValidLang } from '../../extension/plugins/code-block/helpers';
|
|
10
10
|
var mergeMaps = function mergeMaps() {
|
|
11
11
|
var map = new Map();
|
|
12
12
|
for (var _len = arguments.length, maps = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import { commentDecorate } from '../comment/comment-decorate';
|
|
3
|
-
import { highlightDecorate } from '
|
|
3
|
+
import { highlightDecorate, SetNodeToDecorations } from './highlight-decorate';
|
|
4
4
|
import useSelectionUpdate from '../hooks/use-selection-update';
|
|
5
|
+
import RebaseDecorate from './rebase-decorate';
|
|
5
6
|
var pluginDecorates = [highlightDecorate, commentDecorate];
|
|
6
7
|
export var usePipDecorate = function usePipDecorate(editor) {
|
|
7
8
|
useSelectionUpdate();
|
|
@@ -18,4 +19,5 @@ export var usePipDecorate = function usePipDecorate(editor) {
|
|
|
18
19
|
});
|
|
19
20
|
return ranges;
|
|
20
21
|
};
|
|
21
|
-
};
|
|
22
|
+
};
|
|
23
|
+
export { SetNodeToDecorations, RebaseDecorate };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RebaseModifyDeleteDecorate from './rebase-modify-delete-decorate';
|
|
3
|
+
import RebaseModifyModifyDecorate from './rebase-modify-modify-decorate';
|
|
4
|
+
import RebaseDeleteModifyDecorate from './rebase-delete-modify-decorate';
|
|
5
|
+
import { REBASE_MARK_KEY, REBASE_TYPE } from '../../constants';
|
|
6
|
+
import './index.css';
|
|
7
|
+
var RebaseDecorate = function RebaseDecorate(_ref) {
|
|
8
|
+
var element = _ref.element,
|
|
9
|
+
children = _ref.children;
|
|
10
|
+
var rebaseType = element[REBASE_MARK_KEY.REBASE_TYPE];
|
|
11
|
+
if (!rebaseType) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
12
|
+
if (rebaseType === REBASE_TYPE.MODIFY_DELETE) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(RebaseModifyDeleteDecorate, {
|
|
14
|
+
element: element
|
|
15
|
+
}, children);
|
|
16
|
+
}
|
|
17
|
+
if (rebaseType === REBASE_TYPE.DELETE_MODIFY) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(RebaseDeleteModifyDecorate, {
|
|
19
|
+
element: element
|
|
20
|
+
}, children);
|
|
21
|
+
}
|
|
22
|
+
if (rebaseType === REBASE_TYPE.MODIFY_MODIFY) {
|
|
23
|
+
return /*#__PURE__*/React.createElement(RebaseModifyModifyDecorate, {
|
|
24
|
+
element: element
|
|
25
|
+
}, children);
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
28
|
+
};
|
|
29
|
+
export default RebaseDecorate;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Transforms } from '@seafile/slate';
|
|
4
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
5
|
+
import { ELEMENT_TYPE } from '../../extension/constants';
|
|
6
|
+
import { REBASE_MARKS } from '../../constants';
|
|
7
|
+
import { findPath, deleteNodeMark, updateRebaseParentNodeByPath } from '../../extension/core';
|
|
8
|
+
var RebaseDeleteModifyDecorate = function RebaseDeleteModifyDecorate(_ref) {
|
|
9
|
+
var element = _ref.element,
|
|
10
|
+
children = _ref.children;
|
|
11
|
+
var _useTranslation = useTranslation(),
|
|
12
|
+
t = _useTranslation.t;
|
|
13
|
+
var editor = useSlateStatic();
|
|
14
|
+
var deleteElement = useCallback(function () {
|
|
15
|
+
var path = findPath(editor, element);
|
|
16
|
+
Transforms.removeNodes(editor, {
|
|
17
|
+
at: path
|
|
18
|
+
});
|
|
19
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
20
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [editor, element]);
|
|
25
|
+
var deleteMark = useCallback(function () {
|
|
26
|
+
var path = findPath(editor, element);
|
|
27
|
+
deleteNodeMark(editor, path, element, REBASE_MARKS);
|
|
28
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
29
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [editor, element]);
|
|
34
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
36
|
+
contentEditable: false
|
|
37
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "sdoc-rebase-btn",
|
|
39
|
+
onClick: deleteElement
|
|
40
|
+
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: "mr-2 ml-2"
|
|
42
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "sdoc-rebase-btn",
|
|
44
|
+
onClick: deleteMark
|
|
45
|
+
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "mr-2 ml-2"
|
|
47
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "sdoc-rebase-btn",
|
|
49
|
+
onClick: deleteMark
|
|
50
|
+
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "w-100 sdoc-rebase-current-changes-start",
|
|
52
|
+
contentEditable: false
|
|
53
|
+
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "w-100",
|
|
55
|
+
contentEditable: false
|
|
56
|
+
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "w-100 sdoc-rebase-incoming-changes",
|
|
58
|
+
contentEditable: false
|
|
59
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
61
|
+
contentEditable: false
|
|
62
|
+
}, '>>>>>>>'));
|
|
63
|
+
};
|
|
64
|
+
export default RebaseDeleteModifyDecorate;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Transforms } from '@seafile/slate';
|
|
4
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
5
|
+
import { ELEMENT_TYPE } from '../../extension/constants';
|
|
6
|
+
import { REBASE_MARKS } from '../../constants';
|
|
7
|
+
import { findPath, deleteNodeMark, updateRebaseParentNodeByPath } from '../../extension/core';
|
|
8
|
+
var RebaseModifyDeleteDecorate = function RebaseModifyDeleteDecorate(_ref) {
|
|
9
|
+
var element = _ref.element,
|
|
10
|
+
children = _ref.children;
|
|
11
|
+
var _useTranslation = useTranslation(),
|
|
12
|
+
t = _useTranslation.t;
|
|
13
|
+
var editor = useSlateStatic();
|
|
14
|
+
var deleteElement = useCallback(function () {
|
|
15
|
+
var path = findPath(editor, element);
|
|
16
|
+
Transforms.removeNodes(editor, {
|
|
17
|
+
at: path
|
|
18
|
+
});
|
|
19
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
20
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [editor, element]);
|
|
25
|
+
var deleteMark = useCallback(function () {
|
|
26
|
+
var path = findPath(editor, element);
|
|
27
|
+
deleteNodeMark(editor, path, element, REBASE_MARKS);
|
|
28
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
29
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [editor, element]);
|
|
34
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
36
|
+
contentEditable: false
|
|
37
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "sdoc-rebase-btn",
|
|
39
|
+
onClick: deleteMark
|
|
40
|
+
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: "mr-2 ml-2"
|
|
42
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "sdoc-rebase-btn",
|
|
44
|
+
onClick: deleteElement
|
|
45
|
+
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "mr-2 ml-2"
|
|
47
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "sdoc-rebase-btn",
|
|
49
|
+
onClick: deleteMark
|
|
50
|
+
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "w-100 sdoc-rebase-current-changes-start",
|
|
52
|
+
contentEditable: false
|
|
53
|
+
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "w-100 sdoc-rebase-incoming-changes",
|
|
55
|
+
contentEditable: false
|
|
56
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "w-100",
|
|
58
|
+
contentEditable: false
|
|
59
|
+
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
61
|
+
contentEditable: false
|
|
62
|
+
}, '>>>>>>>'));
|
|
63
|
+
};
|
|
64
|
+
export default RebaseModifyDeleteDecorate;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import deepCopy from 'deep-copy';
|
|
5
|
+
import { Transforms } from '@seafile/slate';
|
|
6
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
7
|
+
import { ELEMENT_TYPE } from '../../extension/constants';
|
|
8
|
+
import { REBASE_MARKS, REBASE_MARK_KEY, REBASE_ORIGIN } from '../../constants';
|
|
9
|
+
import { findPath, getNode, deleteNodeMark, updateRebaseParentNodeByPath } from '../../extension/core';
|
|
10
|
+
var RebaseModifyModifyDecorate = function RebaseModifyModifyDecorate(_ref) {
|
|
11
|
+
var element = _ref.element,
|
|
12
|
+
children = _ref.children;
|
|
13
|
+
var _useTranslation = useTranslation(),
|
|
14
|
+
t = _useTranslation.t;
|
|
15
|
+
var editor = useSlateStatic();
|
|
16
|
+
var useMasterChanges = useCallback(function () {
|
|
17
|
+
var path = findPath(editor, element);
|
|
18
|
+
deleteNodeMark(editor, path, element[REBASE_MARK_KEY.OLD_ELEMENT], REBASE_MARKS);
|
|
19
|
+
var nextElementPath = _toConsumableArray(path);
|
|
20
|
+
nextElementPath[path.length - 1] = path[path.length - 1] + 1;
|
|
21
|
+
Transforms.removeNodes(editor, {
|
|
22
|
+
at: nextElementPath
|
|
23
|
+
});
|
|
24
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
25
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
}, [editor, element]);
|
|
30
|
+
var useCurrentChanges = useCallback(function () {
|
|
31
|
+
var path = findPath(editor, element);
|
|
32
|
+
var currentElementPath = _toConsumableArray(path);
|
|
33
|
+
currentElementPath[path.length - 1] = path[path.length - 1] + 1;
|
|
34
|
+
var currentElement = getNode(editor, currentElementPath);
|
|
35
|
+
var newCurrentElement = deepCopy(currentElement);
|
|
36
|
+
deleteNodeMark(editor, currentElementPath, newCurrentElement, REBASE_MARKS);
|
|
37
|
+
Transforms.removeNodes(editor, {
|
|
38
|
+
at: path
|
|
39
|
+
});
|
|
40
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
41
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
}, [editor, element]);
|
|
46
|
+
var useBothChanges = useCallback(function () {
|
|
47
|
+
// delete element marks
|
|
48
|
+
var path = findPath(editor, element);
|
|
49
|
+
deleteNodeMark(editor, path, element, REBASE_MARKS);
|
|
50
|
+
|
|
51
|
+
// delete next element marks
|
|
52
|
+
var nextElementPath = [].concat(_toConsumableArray(path.slice(0, -1)), [path[path.length - 1] + 1]);
|
|
53
|
+
var nextElement = getNode(editor, nextElementPath);
|
|
54
|
+
deleteNodeMark(editor, nextElementPath, nextElement, REBASE_MARKS);
|
|
55
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
56
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}, [editor, element]);
|
|
61
|
+
if (element[REBASE_MARK_KEY.ORIGIN] === REBASE_ORIGIN.OTHER) {
|
|
62
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
64
|
+
contentEditable: false
|
|
65
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "sdoc-rebase-btn",
|
|
67
|
+
onClick: useMasterChanges
|
|
68
|
+
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: "mr-2 ml-2"
|
|
70
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "sdoc-rebase-btn",
|
|
72
|
+
onClick: useCurrentChanges
|
|
73
|
+
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
className: "mr-2 ml-2"
|
|
75
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "sdoc-rebase-btn",
|
|
77
|
+
onClick: useBothChanges
|
|
78
|
+
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: "w-100 sdoc-rebase-current-changes-start",
|
|
80
|
+
contentEditable: false
|
|
81
|
+
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "w-100 sdoc-rebase-current-changes",
|
|
83
|
+
contentEditable: false
|
|
84
|
+
}, children));
|
|
85
|
+
}
|
|
86
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: "w-100",
|
|
88
|
+
contentEditable: false
|
|
89
|
+
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: "w-100 sdoc-rebase-incoming-changes",
|
|
91
|
+
contentEditable: false
|
|
92
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
94
|
+
contentEditable: false
|
|
95
|
+
}, '>>>>>>>'));
|
|
96
|
+
};
|
|
97
|
+
export default RebaseModifyModifyDecorate;
|
|
@@ -5,10 +5,9 @@ import { getAboveBlockNode, getNextNode, getPrevNode, isSelectionAtBlockEnd, isS
|
|
|
5
5
|
import EventProxy from '../utils/event-handler';
|
|
6
6
|
import { useCursors } from '../cursor/use-cursors';
|
|
7
7
|
import { INTERNAL_EVENT } from '../constants';
|
|
8
|
-
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
9
8
|
import CommentContextProvider from '../comment/comment-context-provider';
|
|
10
9
|
import CommentWrapper from '../comment';
|
|
11
|
-
import { usePipDecorate } from '../
|
|
10
|
+
import { usePipDecorate, SetNodeToDecorations } from '../decorate';
|
|
12
11
|
import { getCursorPosition, getDomHeight, getDomMarginTop } from '../utils/dom-utils';
|
|
13
12
|
import EventBus from '../utils/event-bus';
|
|
14
13
|
import { ArticleContainer } from '../layout';
|
|
@@ -1,16 +1,53 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
4
|
+
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo } from 'react';
|
|
3
5
|
import { Editor } from '@seafile/slate';
|
|
6
|
+
import deepCopy from 'deep-copy';
|
|
7
|
+
import context from '../../context';
|
|
8
|
+
import CommonLoading from '../../components/common-loading';
|
|
9
|
+
import { PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
10
|
+
import { createDefaultEditor } from '../extension';
|
|
11
|
+
import withNodeId from '../node-id';
|
|
12
|
+
import { withSocketIO } from '../socket';
|
|
4
13
|
import { focusEditor } from '../extension/core';
|
|
5
|
-
import { EditorContainer, EditorContent } from '../layout';
|
|
6
14
|
import InsertElementDialog from '../extension/commons/insert-element-dialog';
|
|
15
|
+
import { EditorContainer, EditorContent } from '../layout';
|
|
7
16
|
import EditableArticle from './editable-article';
|
|
8
17
|
import { ColorProvider } from '../hooks/use-color-context';
|
|
9
18
|
import { HeaderToolbar } from '../extension';
|
|
10
|
-
var SdocEditor = function
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
var SdocEditor = forwardRef(function (_ref, ref) {
|
|
20
|
+
var document = _ref.document,
|
|
21
|
+
isReloading = _ref.isReloading;
|
|
22
|
+
var editor = useMemo(function () {
|
|
23
|
+
var defaultEditor = createDefaultEditor();
|
|
24
|
+
var editorConfig = context.getEditorConfig();
|
|
25
|
+
var newEditor = withNodeId(withSocketIO(defaultEditor, {
|
|
26
|
+
document: document,
|
|
27
|
+
config: editorConfig
|
|
28
|
+
}));
|
|
29
|
+
var cursors = document.cursors;
|
|
30
|
+
newEditor.cursors = cursors || {};
|
|
31
|
+
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
32
|
+
return newEditor;
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, []);
|
|
36
|
+
var _useState = useState(document.children),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
slateValue = _useState2[0],
|
|
39
|
+
_setSlateValue = _useState2[1];
|
|
40
|
+
|
|
41
|
+
// useMount: init socket connection
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
editor.openConnection();
|
|
44
|
+
return function () {
|
|
45
|
+
editor.closeConnection();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
14
51
|
// useMount: focus editor
|
|
15
52
|
useEffect(function () {
|
|
16
53
|
var timer = setTimeout(function () {
|
|
@@ -34,6 +71,33 @@ var SdocEditor = function SdocEditor(_ref) {
|
|
|
34
71
|
};
|
|
35
72
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
73
|
}, []);
|
|
74
|
+
|
|
75
|
+
// The parent component can call the method of this component through ref
|
|
76
|
+
useImperativeHandle(ref, function () {
|
|
77
|
+
return {
|
|
78
|
+
setSlateValue: function setSlateValue(document) {
|
|
79
|
+
// Force update of editor's child elements
|
|
80
|
+
editor.children = document.children;
|
|
81
|
+
_setSlateValue(_toConsumableArray(document.children));
|
|
82
|
+
},
|
|
83
|
+
updateDocumentVersion: function updateDocumentVersion(document) {
|
|
84
|
+
editor.updateDocumentVersion(document);
|
|
85
|
+
},
|
|
86
|
+
// get value
|
|
87
|
+
getSlateValue: function getSlateValue() {
|
|
88
|
+
return deepCopy(_objectSpread(_objectSpread({}, document), {}, {
|
|
89
|
+
children: slateValue
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
};
|
|
95
|
+
}, [document, editor, slateValue]);
|
|
96
|
+
if (isReloading) {
|
|
97
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: "h-100 w-100 d-flex align-items-center justify-content-center"
|
|
99
|
+
}, /*#__PURE__*/React.createElement(CommonLoading, null));
|
|
100
|
+
}
|
|
37
101
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
|
|
38
102
|
editor: editor
|
|
39
103
|
}, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(HeaderToolbar, {
|
|
@@ -44,9 +108,9 @@ var SdocEditor = function SdocEditor(_ref) {
|
|
|
44
108
|
}, /*#__PURE__*/React.createElement(EditableArticle, {
|
|
45
109
|
editor: editor,
|
|
46
110
|
slateValue: slateValue,
|
|
47
|
-
updateSlateValue:
|
|
111
|
+
updateSlateValue: _setSlateValue
|
|
48
112
|
})))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
49
113
|
editor: editor
|
|
50
114
|
}));
|
|
51
|
-
};
|
|
115
|
+
});
|
|
52
116
|
export default SdocEditor;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { REBASE_MARK_KEY } from '../../../constants';
|
|
3
|
+
import { getNode } from '../queries';
|
|
4
|
+
import { replaceNode } from './replace-node';
|
|
5
|
+
export var updateRebaseParentNodeByPath = function updateRebaseParentNodeByPath(editor, path) {
|
|
6
|
+
var parentPath = path.slice(0, -1);
|
|
7
|
+
var parentNode = getNode(editor, parentPath);
|
|
8
|
+
if (parentNode.children.filter(function (item) {
|
|
9
|
+
return item[REBASE_MARK_KEY.REBASE_TYPE];
|
|
10
|
+
}).length !== 0) return;
|
|
11
|
+
var newParentElement = _objectSpread({}, parentNode);
|
|
12
|
+
newParentElement[REBASE_MARK_KEY.REBASE_TYPE] && delete newParentElement[REBASE_MARK_KEY.REBASE_TYPE];
|
|
13
|
+
newParentElement[REBASE_MARK_KEY.OLD_ELEMENT] && delete newParentElement[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
14
|
+
newParentElement[REBASE_MARK_KEY.ORIGIN] && delete newParentElement[REBASE_MARK_KEY.ORIGIN];
|
|
15
|
+
newParentElement['children'] = newParentElement['children'].map(function (item) {
|
|
16
|
+
item[REBASE_MARK_KEY.REBASE_TYPE] && delete item[REBASE_MARK_KEY.REBASE_TYPE];
|
|
17
|
+
item[REBASE_MARK_KEY.OLD_ELEMENT] && delete item[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
18
|
+
item[REBASE_MARK_KEY.ORIGIN] && delete item[REBASE_MARK_KEY.ORIGIN];
|
|
19
|
+
return item;
|
|
20
|
+
});
|
|
21
|
+
replaceNode(editor, {
|
|
22
|
+
at: parentPath,
|
|
23
|
+
nodes: newParentElement
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
4
|
+
import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, LIST_LIC, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK, FILE_LINK, TITLE, SUBTITLE } from '../constants';
|
|
5
|
+
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin } from '../plugins';
|
|
6
|
+
import EventBus from '../../utils/event-bus';
|
|
7
|
+
import { INTERNAL_EVENT } from '../../constants';
|
|
8
|
+
var CustomRenderElement = function CustomRenderElement(props) {
|
|
9
|
+
var editor = useSlateStatic();
|
|
10
|
+
var element = props.element,
|
|
11
|
+
attributes = props.attributes;
|
|
12
|
+
var onMouseEnter = useCallback(function (event) {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
var eventBus = EventBus.getInstance();
|
|
15
|
+
eventBus.dispatch(INTERNAL_EVENT.ON_MOUSE_ENTER_BLOCK, event);
|
|
16
|
+
}, []);
|
|
17
|
+
switch (element.type) {
|
|
18
|
+
case PARAGRAPH:
|
|
19
|
+
{
|
|
20
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
21
|
+
var _ParagraphPlugin$rend = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
22
|
+
renderParagraph = _ParagraphPlugin$rend[0];
|
|
23
|
+
return renderParagraph(props);
|
|
24
|
+
}
|
|
25
|
+
case TITLE:
|
|
26
|
+
{
|
|
27
|
+
var _HeaderPlugin$renderE = _slicedToArray(HeaderPlugin.renderElements, 1),
|
|
28
|
+
renderTitle = _HeaderPlugin$renderE[0];
|
|
29
|
+
return renderTitle(props, editor);
|
|
30
|
+
}
|
|
31
|
+
case SUBTITLE:
|
|
32
|
+
{
|
|
33
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
34
|
+
var _HeaderPlugin$renderE2 = _slicedToArray(HeaderPlugin.renderElements, 2),
|
|
35
|
+
renderSubtitle = _HeaderPlugin$renderE2[1];
|
|
36
|
+
return renderSubtitle(props, editor);
|
|
37
|
+
}
|
|
38
|
+
case HEADER1:
|
|
39
|
+
case HEADER2:
|
|
40
|
+
case HEADER3:
|
|
41
|
+
case HEADER4:
|
|
42
|
+
case HEADER5:
|
|
43
|
+
case HEADER6:
|
|
44
|
+
{
|
|
45
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
46
|
+
var _HeaderPlugin$renderE3 = _slicedToArray(HeaderPlugin.renderElements, 3),
|
|
47
|
+
renderHeader = _HeaderPlugin$renderE3[2];
|
|
48
|
+
return renderHeader(props, editor);
|
|
49
|
+
}
|
|
50
|
+
case LINK:
|
|
51
|
+
{
|
|
52
|
+
var _LinkPlugin$renderEle = _slicedToArray(LinkPlugin.renderElements, 1),
|
|
53
|
+
renderLink = _LinkPlugin$renderEle[0];
|
|
54
|
+
return renderLink(props, editor);
|
|
55
|
+
}
|
|
56
|
+
case BLOCKQUOTE:
|
|
57
|
+
{
|
|
58
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
59
|
+
var _BlockquotePlugin$ren = _slicedToArray(BlockquotePlugin.renderElements, 1),
|
|
60
|
+
renderBlockquote = _BlockquotePlugin$ren[0];
|
|
61
|
+
return renderBlockquote(props, editor);
|
|
62
|
+
}
|
|
63
|
+
case ORDERED_LIST:
|
|
64
|
+
case UNORDERED_LIST:
|
|
65
|
+
{
|
|
66
|
+
var _ListPlugin$renderEle = _slicedToArray(ListPlugin.renderElements, 1),
|
|
67
|
+
renderList = _ListPlugin$renderEle[0];
|
|
68
|
+
return renderList(props, editor);
|
|
69
|
+
}
|
|
70
|
+
case LIST_ITEM:
|
|
71
|
+
{
|
|
72
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
73
|
+
var _ListPlugin$renderEle2 = _slicedToArray(ListPlugin.renderElements, 2),
|
|
74
|
+
renderListItem = _ListPlugin$renderEle2[1];
|
|
75
|
+
return renderListItem(props, editor);
|
|
76
|
+
}
|
|
77
|
+
case LIST_LIC:
|
|
78
|
+
{
|
|
79
|
+
var _ListPlugin$renderEle3 = _slicedToArray(ListPlugin.renderElements, 3),
|
|
80
|
+
renderListLic = _ListPlugin$renderEle3[2];
|
|
81
|
+
return renderListLic(props, editor);
|
|
82
|
+
}
|
|
83
|
+
case CHECK_LIST_ITEM:
|
|
84
|
+
{
|
|
85
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
86
|
+
var _CheckListPlugin$rend = _slicedToArray(CheckListPlugin.renderElements, 1),
|
|
87
|
+
renderCheckListItem = _CheckListPlugin$rend[0];
|
|
88
|
+
return renderCheckListItem(props, editor);
|
|
89
|
+
}
|
|
90
|
+
case CODE_BLOCK:
|
|
91
|
+
{
|
|
92
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
93
|
+
var _CodeBlockPlugin$rend = _slicedToArray(CodeBlockPlugin.renderElements, 1),
|
|
94
|
+
renderCodeBlock = _CodeBlockPlugin$rend[0];
|
|
95
|
+
return renderCodeBlock(props, editor);
|
|
96
|
+
}
|
|
97
|
+
case CODE_LINE:
|
|
98
|
+
{
|
|
99
|
+
var _CodeBlockPlugin$rend2 = _slicedToArray(CodeBlockPlugin.renderElements, 2),
|
|
100
|
+
renderCodeLine = _CodeBlockPlugin$rend2[1];
|
|
101
|
+
return renderCodeLine(props, editor);
|
|
102
|
+
}
|
|
103
|
+
case IMAGE:
|
|
104
|
+
{
|
|
105
|
+
var _ImagePlugin$renderEl = _slicedToArray(ImagePlugin.renderElements, 1),
|
|
106
|
+
renderImage = _ImagePlugin$renderEl[0];
|
|
107
|
+
return renderImage(props, editor);
|
|
108
|
+
}
|
|
109
|
+
case ELEMENT_TYPE.TABLE:
|
|
110
|
+
{
|
|
111
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
112
|
+
var _TablePlugin$renderEl = _slicedToArray(TablePlugin.renderElements, 1),
|
|
113
|
+
renderTable = _TablePlugin$renderEl[0];
|
|
114
|
+
return renderTable(props, editor);
|
|
115
|
+
}
|
|
116
|
+
case ELEMENT_TYPE.TABLE_ROW:
|
|
117
|
+
{
|
|
118
|
+
var _TablePlugin$renderEl2 = _slicedToArray(TablePlugin.renderElements, 2),
|
|
119
|
+
renderTableRow = _TablePlugin$renderEl2[1];
|
|
120
|
+
return renderTableRow(props, editor);
|
|
121
|
+
}
|
|
122
|
+
case ELEMENT_TYPE.TABLE_CELL:
|
|
123
|
+
{
|
|
124
|
+
var _TablePlugin$renderEl3 = _slicedToArray(TablePlugin.renderElements, 3),
|
|
125
|
+
renderTableCell = _TablePlugin$renderEl3[2];
|
|
126
|
+
return renderTableCell(props, editor);
|
|
127
|
+
}
|
|
128
|
+
case SDOC_LINK:
|
|
129
|
+
{
|
|
130
|
+
var _SdocLinkPlugin$rende = _slicedToArray(SdocLinkPlugin.renderElements, 1),
|
|
131
|
+
renderSdocLink = _SdocLinkPlugin$rende[0];
|
|
132
|
+
return renderSdocLink(props, editor);
|
|
133
|
+
}
|
|
134
|
+
case FILE_LINK:
|
|
135
|
+
{
|
|
136
|
+
var _FileLinkPlugin$rende = _slicedToArray(FileLinkPlugin.renderElements, 1),
|
|
137
|
+
renderFileLink = _FileLinkPlugin$rende[0];
|
|
138
|
+
return renderFileLink(props, editor);
|
|
139
|
+
}
|
|
140
|
+
default:
|
|
141
|
+
{
|
|
142
|
+
var _ParagraphPlugin$rend2 = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
143
|
+
_renderParagraph = _ParagraphPlugin$rend2[0];
|
|
144
|
+
return _renderParagraph(props);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
export default CustomRenderElement;
|
|
@@ -1,372 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useSlateStatic } from '@seafile/slate-react';
|
|
6
|
-
import { Transforms } from '@seafile/slate';
|
|
7
|
-
import deepCopy from 'deep-copy';
|
|
8
|
-
import { useTranslation } from 'react-i18next';
|
|
9
|
-
import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, LIST_LIC, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK, FILE_LINK, TITLE, SUBTITLE } from '../constants';
|
|
10
|
-
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin } from '../plugins';
|
|
11
|
-
import EventBus from '../../utils/event-bus';
|
|
12
|
-
import { INTERNAL_EVENT, REBASE_TYPE, REBASE_MARKS, REBASE_MARK_KEY, REBASE_ORIGIN } from '../../constants';
|
|
13
|
-
import { findPath, getNode, replaceNode, deleteNodeMark } from '../../extension/core';
|
|
14
|
-
var CustomElement = function CustomElement(props) {
|
|
15
|
-
var editor = useSlateStatic();
|
|
16
|
-
var element = props.element,
|
|
17
|
-
attributes = props.attributes;
|
|
18
|
-
var onMouseEnter = useCallback(function (event) {
|
|
19
|
-
event.stopPropagation();
|
|
20
|
-
var eventBus = EventBus.getInstance();
|
|
21
|
-
eventBus.dispatch(INTERNAL_EVENT.ON_MOUSE_ENTER_BLOCK, event);
|
|
22
|
-
}, []);
|
|
23
|
-
switch (element.type) {
|
|
24
|
-
case PARAGRAPH:
|
|
25
|
-
{
|
|
26
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
27
|
-
var _ParagraphPlugin$rend = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
28
|
-
renderParagraph = _ParagraphPlugin$rend[0];
|
|
29
|
-
return renderParagraph(props);
|
|
30
|
-
}
|
|
31
|
-
case TITLE:
|
|
32
|
-
{
|
|
33
|
-
var _HeaderPlugin$renderE = _slicedToArray(HeaderPlugin.renderElements, 1),
|
|
34
|
-
renderTitle = _HeaderPlugin$renderE[0];
|
|
35
|
-
return renderTitle(props, editor);
|
|
36
|
-
}
|
|
37
|
-
case SUBTITLE:
|
|
38
|
-
{
|
|
39
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
40
|
-
var _HeaderPlugin$renderE2 = _slicedToArray(HeaderPlugin.renderElements, 2),
|
|
41
|
-
renderSubtitle = _HeaderPlugin$renderE2[1];
|
|
42
|
-
return renderSubtitle(props, editor);
|
|
43
|
-
}
|
|
44
|
-
case HEADER1:
|
|
45
|
-
case HEADER2:
|
|
46
|
-
case HEADER3:
|
|
47
|
-
case HEADER4:
|
|
48
|
-
case HEADER5:
|
|
49
|
-
case HEADER6:
|
|
50
|
-
{
|
|
51
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
52
|
-
var _HeaderPlugin$renderE3 = _slicedToArray(HeaderPlugin.renderElements, 3),
|
|
53
|
-
renderHeader = _HeaderPlugin$renderE3[2];
|
|
54
|
-
return renderHeader(props, editor);
|
|
55
|
-
}
|
|
56
|
-
case LINK:
|
|
57
|
-
{
|
|
58
|
-
var _LinkPlugin$renderEle = _slicedToArray(LinkPlugin.renderElements, 1),
|
|
59
|
-
renderLink = _LinkPlugin$renderEle[0];
|
|
60
|
-
return renderLink(props, editor);
|
|
61
|
-
}
|
|
62
|
-
case BLOCKQUOTE:
|
|
63
|
-
{
|
|
64
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
65
|
-
var _BlockquotePlugin$ren = _slicedToArray(BlockquotePlugin.renderElements, 1),
|
|
66
|
-
renderBlockquote = _BlockquotePlugin$ren[0];
|
|
67
|
-
return renderBlockquote(props, editor);
|
|
68
|
-
}
|
|
69
|
-
case ORDERED_LIST:
|
|
70
|
-
case UNORDERED_LIST:
|
|
71
|
-
{
|
|
72
|
-
var _ListPlugin$renderEle = _slicedToArray(ListPlugin.renderElements, 1),
|
|
73
|
-
renderList = _ListPlugin$renderEle[0];
|
|
74
|
-
return renderList(props, editor);
|
|
75
|
-
}
|
|
76
|
-
case LIST_ITEM:
|
|
77
|
-
{
|
|
78
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
79
|
-
var _ListPlugin$renderEle2 = _slicedToArray(ListPlugin.renderElements, 2),
|
|
80
|
-
renderListItem = _ListPlugin$renderEle2[1];
|
|
81
|
-
return renderListItem(props, editor);
|
|
82
|
-
}
|
|
83
|
-
case LIST_LIC:
|
|
84
|
-
{
|
|
85
|
-
var _ListPlugin$renderEle3 = _slicedToArray(ListPlugin.renderElements, 3),
|
|
86
|
-
renderListLic = _ListPlugin$renderEle3[2];
|
|
87
|
-
return renderListLic(props, editor);
|
|
88
|
-
}
|
|
89
|
-
case CHECK_LIST_ITEM:
|
|
90
|
-
{
|
|
91
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
92
|
-
var _CheckListPlugin$rend = _slicedToArray(CheckListPlugin.renderElements, 1),
|
|
93
|
-
renderCheckListItem = _CheckListPlugin$rend[0];
|
|
94
|
-
return renderCheckListItem(props, editor);
|
|
95
|
-
}
|
|
96
|
-
case CODE_BLOCK:
|
|
97
|
-
{
|
|
98
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
99
|
-
var _CodeBlockPlugin$rend = _slicedToArray(CodeBlockPlugin.renderElements, 1),
|
|
100
|
-
renderCodeBlock = _CodeBlockPlugin$rend[0];
|
|
101
|
-
return renderCodeBlock(props, editor);
|
|
102
|
-
}
|
|
103
|
-
case CODE_LINE:
|
|
104
|
-
{
|
|
105
|
-
var _CodeBlockPlugin$rend2 = _slicedToArray(CodeBlockPlugin.renderElements, 2),
|
|
106
|
-
renderCodeLine = _CodeBlockPlugin$rend2[1];
|
|
107
|
-
return renderCodeLine(props, editor);
|
|
108
|
-
}
|
|
109
|
-
case IMAGE:
|
|
110
|
-
{
|
|
111
|
-
var _ImagePlugin$renderEl = _slicedToArray(ImagePlugin.renderElements, 1),
|
|
112
|
-
renderImage = _ImagePlugin$renderEl[0];
|
|
113
|
-
return renderImage(props, editor);
|
|
114
|
-
}
|
|
115
|
-
case ELEMENT_TYPE.TABLE:
|
|
116
|
-
{
|
|
117
|
-
attributes['onMouseEnter'] = onMouseEnter;
|
|
118
|
-
var _TablePlugin$renderEl = _slicedToArray(TablePlugin.renderElements, 1),
|
|
119
|
-
renderTable = _TablePlugin$renderEl[0];
|
|
120
|
-
return renderTable(props, editor);
|
|
121
|
-
}
|
|
122
|
-
case ELEMENT_TYPE.TABLE_ROW:
|
|
123
|
-
{
|
|
124
|
-
var _TablePlugin$renderEl2 = _slicedToArray(TablePlugin.renderElements, 2),
|
|
125
|
-
renderTableRow = _TablePlugin$renderEl2[1];
|
|
126
|
-
return renderTableRow(props, editor);
|
|
127
|
-
}
|
|
128
|
-
case ELEMENT_TYPE.TABLE_CELL:
|
|
129
|
-
{
|
|
130
|
-
var _TablePlugin$renderEl3 = _slicedToArray(TablePlugin.renderElements, 3),
|
|
131
|
-
renderTableCell = _TablePlugin$renderEl3[2];
|
|
132
|
-
return renderTableCell(props, editor);
|
|
133
|
-
}
|
|
134
|
-
case SDOC_LINK:
|
|
135
|
-
{
|
|
136
|
-
var _SdocLinkPlugin$rende = _slicedToArray(SdocLinkPlugin.renderElements, 1),
|
|
137
|
-
renderSdocLink = _SdocLinkPlugin$rende[0];
|
|
138
|
-
return renderSdocLink(props, editor);
|
|
139
|
-
}
|
|
140
|
-
case FILE_LINK:
|
|
141
|
-
{
|
|
142
|
-
var _FileLinkPlugin$rende = _slicedToArray(FileLinkPlugin.renderElements, 1),
|
|
143
|
-
renderFileLink = _FileLinkPlugin$rende[0];
|
|
144
|
-
return renderFileLink(props, editor);
|
|
145
|
-
}
|
|
146
|
-
default:
|
|
147
|
-
{
|
|
148
|
-
var _ParagraphPlugin$rend2 = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
149
|
-
_renderParagraph = _ParagraphPlugin$rend2[0];
|
|
150
|
-
return _renderParagraph(props);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { REBASE_MARK_KEY } from '../../constants';
|
|
3
|
+
import { RebaseDecorate } from '../../decorate';
|
|
4
|
+
import CustomRenderElement from './custom-render-element';
|
|
154
5
|
var RenderElement = function RenderElement(props) {
|
|
155
|
-
var editor = useSlateStatic();
|
|
156
|
-
var _useTranslation = useTranslation(),
|
|
157
|
-
t = _useTranslation.t;
|
|
158
|
-
var updateParentNodeByPath = useCallback(function (path) {
|
|
159
|
-
var parentPath = path.slice(0, -1);
|
|
160
|
-
var parentNode = getNode(editor, parentPath);
|
|
161
|
-
if (parentNode.children.filter(function (item) {
|
|
162
|
-
return item[REBASE_MARK_KEY.REBASE_TYPE];
|
|
163
|
-
}).length === 0) {
|
|
164
|
-
var newParentElement = _objectSpread({}, parentNode);
|
|
165
|
-
newParentElement[REBASE_MARK_KEY.REBASE_TYPE] && delete newParentElement[REBASE_MARK_KEY.REBASE_TYPE];
|
|
166
|
-
newParentElement[REBASE_MARK_KEY.OLD_ELEMENT] && delete newParentElement[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
167
|
-
newParentElement[REBASE_MARK_KEY.ORIGIN] && delete newParentElement[REBASE_MARK_KEY.ORIGIN];
|
|
168
|
-
newParentElement['children'] = newParentElement['children'].map(function (item) {
|
|
169
|
-
item[REBASE_MARK_KEY.REBASE_TYPE] && delete item[REBASE_MARK_KEY.REBASE_TYPE];
|
|
170
|
-
item[REBASE_MARK_KEY.OLD_ELEMENT] && delete item[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
171
|
-
item[REBASE_MARK_KEY.ORIGIN] && delete item[REBASE_MARK_KEY.ORIGIN];
|
|
172
|
-
return item;
|
|
173
|
-
});
|
|
174
|
-
replaceNode(editor, {
|
|
175
|
-
at: parentPath,
|
|
176
|
-
nodes: newParentElement
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
181
|
-
}, [editor]);
|
|
182
|
-
var deleteElement = useCallback(function (element) {
|
|
183
|
-
var path = findPath(editor, element);
|
|
184
|
-
Transforms.removeNodes(editor, {
|
|
185
|
-
at: path
|
|
186
|
-
});
|
|
187
|
-
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
188
|
-
updateParentNodeByPath(path);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
192
|
-
}, [editor]);
|
|
193
|
-
var deleteMark = useCallback(function (element) {
|
|
194
|
-
var path = findPath(editor, element);
|
|
195
|
-
deleteNodeMark(editor, path, element, REBASE_MARKS);
|
|
196
|
-
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
197
|
-
updateParentNodeByPath(path);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
201
|
-
}, [editor]);
|
|
202
|
-
var useMasterChanges = useCallback(function (element) {
|
|
203
|
-
var path = findPath(editor, element);
|
|
204
|
-
deleteNodeMark(editor, path, element[REBASE_MARK_KEY.OLD_ELEMENT], REBASE_MARKS);
|
|
205
|
-
var nextElementPath = _toConsumableArray(path);
|
|
206
|
-
nextElementPath[path.length - 1] = path[path.length - 1] + 1;
|
|
207
|
-
Transforms.removeNodes(editor, {
|
|
208
|
-
at: nextElementPath
|
|
209
|
-
});
|
|
210
|
-
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
211
|
-
updateParentNodeByPath(path);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
215
|
-
}, [editor]);
|
|
216
|
-
var useCurrentChanges = useCallback(function (element) {
|
|
217
|
-
var path = findPath(editor, element);
|
|
218
|
-
var currentElementPath = _toConsumableArray(path);
|
|
219
|
-
currentElementPath[path.length - 1] = path[path.length - 1] + 1;
|
|
220
|
-
var currentElement = getNode(editor, currentElementPath);
|
|
221
|
-
var newCurrentElement = deepCopy(currentElement);
|
|
222
|
-
deleteNodeMark(editor, currentElementPath, newCurrentElement, REBASE_MARKS);
|
|
223
|
-
Transforms.removeNodes(editor, {
|
|
224
|
-
at: path
|
|
225
|
-
});
|
|
226
|
-
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
227
|
-
updateParentNodeByPath(path);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
231
|
-
}, [editor]);
|
|
232
|
-
var useBothChanges = useCallback(function (element) {
|
|
233
|
-
// delete element marks
|
|
234
|
-
var path = findPath(editor, element);
|
|
235
|
-
deleteNodeMark(editor, path, element, REBASE_MARKS);
|
|
236
|
-
|
|
237
|
-
// delete next element marks
|
|
238
|
-
var nextElementPath = [].concat(_toConsumableArray(path.slice(0, -1)), [path[path.length - 1] + 1]);
|
|
239
|
-
var nextElement = getNode(editor, nextElementPath);
|
|
240
|
-
deleteNodeMark(editor, nextElementPath, nextElement, REBASE_MARKS);
|
|
241
|
-
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
242
|
-
updateParentNodeByPath(path);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
246
|
-
}, [editor]);
|
|
247
6
|
var element = props.element;
|
|
248
7
|
var rebaseType = element[REBASE_MARK_KEY.REBASE_TYPE];
|
|
249
|
-
if (
|
|
250
|
-
return /*#__PURE__*/React.createElement(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
254
|
-
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
255
|
-
contentEditable: false
|
|
256
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
257
|
-
className: "sdoc-rebase-btn",
|
|
258
|
-
onClick: function onClick() {
|
|
259
|
-
return deleteMark(element);
|
|
260
|
-
}
|
|
261
|
-
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
262
|
-
className: "mr-2 ml-2"
|
|
263
|
-
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
264
|
-
className: "sdoc-rebase-btn",
|
|
265
|
-
onClick: function onClick() {
|
|
266
|
-
return deleteElement(element);
|
|
267
|
-
}
|
|
268
|
-
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
269
|
-
className: "mr-2 ml-2"
|
|
270
|
-
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
271
|
-
className: "sdoc-rebase-btn",
|
|
272
|
-
onClick: function onClick() {
|
|
273
|
-
return deleteMark(element);
|
|
274
|
-
}
|
|
275
|
-
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
276
|
-
className: "w-100 sdoc-rebase-current-changes-start",
|
|
277
|
-
contentEditable: false
|
|
278
|
-
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
279
|
-
className: "w-100 sdoc-rebase-incoming-changes",
|
|
280
|
-
contentEditable: false
|
|
281
|
-
}, /*#__PURE__*/React.createElement(CustomElement, props)), /*#__PURE__*/React.createElement("div", {
|
|
282
|
-
className: "w-100",
|
|
283
|
-
contentEditable: false
|
|
284
|
-
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
285
|
-
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
286
|
-
contentEditable: false
|
|
287
|
-
}, '>>>>>>>'));
|
|
288
|
-
}
|
|
289
|
-
if (rebaseType === REBASE_TYPE.DELETE_MODIFY) {
|
|
290
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
291
|
-
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
292
|
-
contentEditable: false
|
|
293
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
294
|
-
className: "sdoc-rebase-btn",
|
|
295
|
-
onClick: function onClick() {
|
|
296
|
-
return deleteElement(element);
|
|
297
|
-
}
|
|
298
|
-
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
299
|
-
className: "mr-2 ml-2"
|
|
300
|
-
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
301
|
-
className: "sdoc-rebase-btn",
|
|
302
|
-
onClick: function onClick() {
|
|
303
|
-
return deleteMark(element);
|
|
304
|
-
}
|
|
305
|
-
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
306
|
-
className: "mr-2 ml-2"
|
|
307
|
-
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
308
|
-
className: "sdoc-rebase-btn",
|
|
309
|
-
onClick: function onClick() {
|
|
310
|
-
return deleteMark(element);
|
|
311
|
-
}
|
|
312
|
-
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
313
|
-
className: "w-100 sdoc-rebase-current-changes-start",
|
|
314
|
-
contentEditable: false
|
|
315
|
-
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
316
|
-
className: "w-100",
|
|
317
|
-
contentEditable: false
|
|
318
|
-
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
319
|
-
className: "w-100 sdoc-rebase-incoming-changes",
|
|
320
|
-
contentEditable: false
|
|
321
|
-
}, /*#__PURE__*/React.createElement(CustomElement, props)), /*#__PURE__*/React.createElement("div", {
|
|
322
|
-
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
323
|
-
contentEditable: false
|
|
324
|
-
}, '>>>>>>>'));
|
|
325
|
-
}
|
|
326
|
-
if (rebaseType === REBASE_TYPE.MODIFY_MODIFY) {
|
|
327
|
-
if (element[REBASE_MARK_KEY.ORIGIN] === REBASE_ORIGIN.OTHER) {
|
|
328
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
329
|
-
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
330
|
-
contentEditable: false
|
|
331
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
332
|
-
className: "sdoc-rebase-btn",
|
|
333
|
-
onClick: function onClick() {
|
|
334
|
-
return useMasterChanges(element);
|
|
335
|
-
}
|
|
336
|
-
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
337
|
-
className: "mr-2 ml-2"
|
|
338
|
-
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
339
|
-
className: "sdoc-rebase-btn",
|
|
340
|
-
onClick: function onClick() {
|
|
341
|
-
return useCurrentChanges(element);
|
|
342
|
-
}
|
|
343
|
-
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
344
|
-
className: "mr-2 ml-2"
|
|
345
|
-
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
346
|
-
className: "sdoc-rebase-btn",
|
|
347
|
-
onClick: function onClick() {
|
|
348
|
-
return useBothChanges(element);
|
|
349
|
-
}
|
|
350
|
-
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
351
|
-
className: "w-100 sdoc-rebase-current-changes-start",
|
|
352
|
-
contentEditable: false
|
|
353
|
-
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
354
|
-
className: "w-100 sdoc-rebase-current-changes",
|
|
355
|
-
contentEditable: false
|
|
356
|
-
}, /*#__PURE__*/React.createElement(CustomElement, props)));
|
|
357
|
-
}
|
|
358
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
359
|
-
className: "w-100",
|
|
360
|
-
contentEditable: false
|
|
361
|
-
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
362
|
-
className: "w-100 sdoc-rebase-incoming-changes",
|
|
363
|
-
contentEditable: false
|
|
364
|
-
}, /*#__PURE__*/React.createElement(CustomElement, props)), /*#__PURE__*/React.createElement("div", {
|
|
365
|
-
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
366
|
-
contentEditable: false
|
|
367
|
-
}, '>>>>>>>'));
|
|
8
|
+
if (rebaseType) {
|
|
9
|
+
return /*#__PURE__*/React.createElement(RebaseDecorate, {
|
|
10
|
+
element: element
|
|
11
|
+
}, /*#__PURE__*/React.createElement(CustomRenderElement, props));
|
|
368
12
|
}
|
|
369
|
-
return /*#__PURE__*/React.createElement(
|
|
13
|
+
return /*#__PURE__*/React.createElement(CustomRenderElement, props);
|
|
370
14
|
|
|
371
15
|
// const { element } = props;
|
|
372
16
|
// const editor = useSlateStatic();
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -50,7 +50,11 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
|
|
|
50
50
|
};
|
|
51
51
|
this.onReceiveLocalOperations = function (operations) {
|
|
52
52
|
_this.pendingOperationList.push(operations);
|
|
53
|
-
|
|
53
|
+
var lastOpBeginTime = new Date().getTime();
|
|
54
|
+
_this.pendingOperationBeginTimeList.push(lastOpBeginTime);
|
|
55
|
+
var firstOpBeginTime = _this.pendingOperationBeginTimeList[0];
|
|
56
|
+
var isExceedExecuteTime = (lastOpBeginTime - firstOpBeginTime) / 1000 > 30 ? true : false;
|
|
57
|
+
if (isExceedExecuteTime || _this.pendingOperationList.length > 50) {
|
|
54
58
|
_this.dispatchConnectState('pending_operations_exceed_limit');
|
|
55
59
|
}
|
|
56
60
|
_this.sendOperations();
|
|
@@ -83,6 +87,7 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
|
|
|
83
87
|
_this.dispatchConnectState('saved', lastSavedAt);
|
|
84
88
|
|
|
85
89
|
// send next operations
|
|
90
|
+
_this.pendingOperationBeginTimeList.shift(); // remove current operation's begin time
|
|
86
91
|
_this._sendingOperations = null;
|
|
87
92
|
_this.sendNextOperations();
|
|
88
93
|
return;
|
|
@@ -317,6 +322,7 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
|
|
|
317
322
|
this.document = _document;
|
|
318
323
|
this.socketClient = new SocketClient(config);
|
|
319
324
|
this.pendingOperationList = []; // Two-dimensional arrays: [operations, operations, ...]
|
|
325
|
+
this.pendingOperationBeginTimeList = [];
|
|
320
326
|
this.remoteOperationsList = []; // Same with pending operations
|
|
321
327
|
this.revertOperationList = [];
|
|
322
328
|
this.eventBus = EventBus.getInstance();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import { Editable, Slate } from '@seafile/slate-react';
|
|
3
3
|
import { ArticleContainer } from '../layout';
|
|
4
|
-
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
5
4
|
import { renderElement, renderLeaf } from '../extension';
|
|
6
|
-
import { usePipDecorate } from '../
|
|
5
|
+
import { usePipDecorate, SetNodeToDecorations } from '../decorate';
|
|
7
6
|
export default function ReadOnlyArticle(_ref) {
|
|
8
7
|
var editor = _ref.editor,
|
|
9
8
|
slateValue = _ref.slateValue;
|
package/package.json
CHANGED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import React, { useMemo, useEffect, useState, useCallback, useImperativeHandle, forwardRef } from 'react';
|
|
5
|
-
import deepCopy from 'deep-copy';
|
|
6
|
-
import context from '../../context';
|
|
7
|
-
import CommonLoading from '../../components/common-loading';
|
|
8
|
-
import { PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
9
|
-
import { createDefaultEditor } from '../extension';
|
|
10
|
-
import withNodeId from '../node-id';
|
|
11
|
-
import { withSocketIO } from '../socket';
|
|
12
|
-
import SDocEditor from './sdoc-editor';
|
|
13
|
-
import './index.css';
|
|
14
|
-
var Editor = forwardRef(function (_ref, ref) {
|
|
15
|
-
var document = _ref.document,
|
|
16
|
-
_ref$isReloading = _ref.isReloading,
|
|
17
|
-
isReloading = _ref$isReloading === void 0 ? false : _ref$isReloading;
|
|
18
|
-
var editor = useMemo(function () {
|
|
19
|
-
var defaultEditor = createDefaultEditor();
|
|
20
|
-
var editorConfig = context.getEditorConfig();
|
|
21
|
-
var newEditor = withNodeId(withSocketIO(defaultEditor, {
|
|
22
|
-
document: document,
|
|
23
|
-
config: editorConfig
|
|
24
|
-
}));
|
|
25
|
-
var cursors = document.cursors;
|
|
26
|
-
newEditor.cursors = cursors || {};
|
|
27
|
-
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
28
|
-
return newEditor;
|
|
29
|
-
|
|
30
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
-
}, []);
|
|
32
|
-
var _useState = useState(document.children),
|
|
33
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
-
slateValue = _useState2[0],
|
|
35
|
-
_setSlateValue = _useState2[1];
|
|
36
|
-
|
|
37
|
-
// useMount: init socket connection
|
|
38
|
-
useEffect(function () {
|
|
39
|
-
editor.openConnection();
|
|
40
|
-
return function () {
|
|
41
|
-
editor.closeConnection();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
}, []);
|
|
46
|
-
var updateSlateValue = useCallback(function (value) {
|
|
47
|
-
_setSlateValue(value);
|
|
48
|
-
|
|
49
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
-
}, []);
|
|
51
|
-
|
|
52
|
-
// The parent component can call the method of this component through ref
|
|
53
|
-
useImperativeHandle(ref, function () {
|
|
54
|
-
return {
|
|
55
|
-
setSlateValue: function setSlateValue(document) {
|
|
56
|
-
// Force update of editor's child elements
|
|
57
|
-
editor.children = document.children;
|
|
58
|
-
_setSlateValue(_toConsumableArray(document.children));
|
|
59
|
-
},
|
|
60
|
-
updateDocumentVersion: function updateDocumentVersion(document) {
|
|
61
|
-
editor.updateDocumentVersion(document);
|
|
62
|
-
},
|
|
63
|
-
// get value
|
|
64
|
-
getSlateValue: function getSlateValue() {
|
|
65
|
-
return deepCopy(_objectSpread(_objectSpread({}, document), {}, {
|
|
66
|
-
children: slateValue
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
|
-
};
|
|
72
|
-
}, [document, editor, slateValue]);
|
|
73
|
-
if (isReloading) {
|
|
74
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
-
className: "h-100 w-100 d-flex align-items-center justify-content-center"
|
|
76
|
-
}, /*#__PURE__*/React.createElement(CommonLoading, null));
|
|
77
|
-
}
|
|
78
|
-
return /*#__PURE__*/React.createElement(SDocEditor, {
|
|
79
|
-
slateValue: slateValue,
|
|
80
|
-
editor: editor,
|
|
81
|
-
updateSlateValue: updateSlateValue
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
export default Editor;
|
|
File without changes
|
/package/dist/basic-sdk/extension/core/transforms/{replace-node-children.js → replace-node.js}
RENAMED
|
File without changes
|