@seafile/sdoc-editor 1.0.102 → 1.0.103
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/comment/components/comment-editor.js +3 -3
- package/dist/basic-sdk/editor/sdoc-comment-editor.js +4 -4
- package/dist/basic-sdk/editor/sdoc-editor.js +7 -7
- package/dist/basic-sdk/editor/wiki-editor.js +7 -7
- package/dist/basic-sdk/utils/diff.js +8 -8
- package/dist/basic-sdk/views/published-revision-diff-viewer.js +1 -1
- package/dist/basic-sdk/views/revision-diff-viewer.js +1 -1
- package/dist/basic-sdk/views/sdoc-diff-viewer.js +1 -1
- package/dist/basic-sdk/views/sdoc-viewer.js +1 -1
- package/dist/basic-sdk/views/sdoc-wiki-viewer.js +1 -0
- package/dist/hooks/use-document.js +0 -7
- package/dist/pages/simple-viewer.js +0 -6
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
|
@@ -50,12 +50,12 @@ const CommentEditor = _ref => {
|
|
|
50
50
|
const userInfo = _context.default.getUserInfo();
|
|
51
51
|
const document = (0, _react.useMemo)(() => {
|
|
52
52
|
const cursor = {};
|
|
53
|
-
let
|
|
54
|
-
|
|
53
|
+
let elements = null;
|
|
54
|
+
elements = [(0, _core.generateEmptyElement)(_constants.PARAGRAPH, {
|
|
55
55
|
placeholder
|
|
56
56
|
})];
|
|
57
57
|
return {
|
|
58
|
-
|
|
58
|
+
elements,
|
|
59
59
|
cursor
|
|
60
60
|
};
|
|
61
61
|
}, [placeholder]);
|
|
@@ -33,7 +33,7 @@ const SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
33
33
|
submitBtnText,
|
|
34
34
|
onCancel
|
|
35
35
|
} = _ref;
|
|
36
|
-
const [slateValue, setSlateValue] = (0, _react.useState)(document.
|
|
36
|
+
const [slateValue, setSlateValue] = (0, _react.useState)(document.elements);
|
|
37
37
|
const commentEditorContainerRef = (0, _react.useRef)(null);
|
|
38
38
|
const validEditor = (0, _react.useMemo)(() => {
|
|
39
39
|
if (propsEditor) return propsEditor;
|
|
@@ -85,8 +85,8 @@ const SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
85
85
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
86
86
|
setSlateValue: document => {
|
|
87
87
|
// Force update of editor's child elements
|
|
88
|
-
validEditor.children = document.
|
|
89
|
-
setSlateValue([...document.
|
|
88
|
+
validEditor.children = document.elements;
|
|
89
|
+
setSlateValue([...document.elements]);
|
|
90
90
|
},
|
|
91
91
|
updateDocumentVersion: document => {
|
|
92
92
|
validEditor.updateDocumentVersion(document);
|
|
@@ -95,7 +95,7 @@ const SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
95
95
|
getSlateValue: () => {
|
|
96
96
|
return (0, _deepCopy.default)({
|
|
97
97
|
...document,
|
|
98
|
-
|
|
98
|
+
elements: slateValue
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -51,13 +51,13 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
51
51
|
|
|
52
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
53
|
}, []);
|
|
54
|
-
const [slateValue, setSlateValue] = (0, _react.useState)(document.
|
|
54
|
+
const [slateValue, setSlateValue] = (0, _react.useState)(document.elements);
|
|
55
55
|
|
|
56
56
|
// Fix: The editor's children are not updated when the document is updated in revision
|
|
57
|
-
// In revision mode, the document is updated, but the editor's children are not updated,as onValueChange override the new document.
|
|
57
|
+
// In revision mode, the document is updated, but the editor's children are not updated,as onValueChange override the new document.elements. This unexpected action cause the editor to display the old content
|
|
58
58
|
(0, _react.useEffect)(() => {
|
|
59
|
-
setSlateValue(document.
|
|
60
|
-
}, [document.
|
|
59
|
+
setSlateValue(document.elements);
|
|
60
|
+
}, [document.elements]);
|
|
61
61
|
(0, _react.useEffect)(() => {
|
|
62
62
|
validEditor.readonly = false;
|
|
63
63
|
return () => {
|
|
@@ -111,8 +111,8 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
111
111
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
112
112
|
setSlateValue: document => {
|
|
113
113
|
// Force update of editor's child elements
|
|
114
|
-
validEditor.children = document.
|
|
115
|
-
setSlateValue([...document.
|
|
114
|
+
validEditor.children = document.elements;
|
|
115
|
+
setSlateValue([...document.elements]);
|
|
116
116
|
},
|
|
117
117
|
updateDocumentVersion: document => {
|
|
118
118
|
validEditor.updateDocumentVersion(document);
|
|
@@ -121,7 +121,7 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
121
121
|
getSlateValue: () => {
|
|
122
122
|
return (0, _deepCopy.default)({
|
|
123
123
|
...document,
|
|
124
|
-
|
|
124
|
+
elements: slateValue
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -52,13 +52,13 @@ const WikiEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
52
52
|
|
|
53
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
54
|
}, []);
|
|
55
|
-
const [slateValue, setSlateValue] = (0, _react.useState)(document.
|
|
55
|
+
const [slateValue, setSlateValue] = (0, _react.useState)(document.elements);
|
|
56
56
|
|
|
57
57
|
// Fix: The editor's children are not updated when the document is updated in revision
|
|
58
|
-
// In revision mode, the document is updated, but the editor's children are not updated,as onValueChange override the new document.
|
|
58
|
+
// In revision mode, the document is updated, but the editor's children are not updated,as onValueChange override the new document.elements. This unexpected action cause the editor to display the old content
|
|
59
59
|
(0, _react.useEffect)(() => {
|
|
60
|
-
setSlateValue(document.
|
|
61
|
-
}, [document.
|
|
60
|
+
setSlateValue(document.elements);
|
|
61
|
+
}, [document.elements]);
|
|
62
62
|
(0, _react.useEffect)(() => {
|
|
63
63
|
validEditor.readonly = false;
|
|
64
64
|
return () => {
|
|
@@ -117,8 +117,8 @@ const WikiEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
117
117
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
118
118
|
setSlateValue: document => {
|
|
119
119
|
// Force update of editor's child elements
|
|
120
|
-
validEditor.children = document.
|
|
121
|
-
setSlateValue([...document.
|
|
120
|
+
validEditor.children = document.elements;
|
|
121
|
+
setSlateValue([...document.elements]);
|
|
122
122
|
},
|
|
123
123
|
updateDocumentVersion: document => {
|
|
124
124
|
validEditor.updateDocumentVersion(document);
|
|
@@ -127,7 +127,7 @@ const WikiEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
127
127
|
getSlateValue: () => {
|
|
128
128
|
return (0, _deepCopy.default)({
|
|
129
129
|
...document,
|
|
130
|
-
|
|
130
|
+
elements: slateValue
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -333,36 +333,36 @@ const getElementDiffValue = (currentContent, oldContent) => {
|
|
|
333
333
|
*/
|
|
334
334
|
const getDiff = function () {
|
|
335
335
|
let currentValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
336
|
-
|
|
336
|
+
elements: []
|
|
337
337
|
};
|
|
338
338
|
let oldValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
339
|
-
|
|
339
|
+
elements: []
|
|
340
340
|
};
|
|
341
341
|
if (!currentValue && !oldValue) return {
|
|
342
342
|
value: [],
|
|
343
343
|
changes: []
|
|
344
344
|
};
|
|
345
345
|
if (!currentValue && oldValue) return {
|
|
346
|
-
value: (0, _documentUtils.normalizeChildren)(oldValue.
|
|
346
|
+
value: (0, _documentUtils.normalizeChildren)(oldValue.elements),
|
|
347
347
|
changes: []
|
|
348
348
|
};
|
|
349
349
|
if (currentValue && !oldValue) return {
|
|
350
|
-
value: (0, _documentUtils.normalizeChildren)(currentValue.
|
|
350
|
+
value: (0, _documentUtils.normalizeChildren)(currentValue.elements),
|
|
351
351
|
changes: []
|
|
352
352
|
};
|
|
353
353
|
const {
|
|
354
354
|
version: currentVersion,
|
|
355
|
-
|
|
355
|
+
elements: currentContent
|
|
356
356
|
} = {
|
|
357
357
|
...currentValue,
|
|
358
|
-
|
|
358
|
+
elements: (0, _documentUtils.normalizeChildren)(currentValue.elements)
|
|
359
359
|
};
|
|
360
360
|
const {
|
|
361
361
|
version: oldVersion,
|
|
362
|
-
|
|
362
|
+
elements: oldContent
|
|
363
363
|
} = {
|
|
364
364
|
...oldValue,
|
|
365
|
-
|
|
365
|
+
elements: (0, _documentUtils.normalizeChildren)(oldValue.elements)
|
|
366
366
|
};
|
|
367
367
|
if (currentVersion === oldVersion) return {
|
|
368
368
|
value: currentContent,
|
|
@@ -53,7 +53,7 @@ const PublishedRevisionDiffViewer = _ref => {
|
|
|
53
53
|
return /*#__PURE__*/_react.default.createElement(_loading.default, null);
|
|
54
54
|
}
|
|
55
55
|
const document = {
|
|
56
|
-
|
|
56
|
+
elements: isShowChanges && (diff === null || diff === void 0 ? void 0 : diff.value) || revisionContent.elements
|
|
57
57
|
};
|
|
58
58
|
return /*#__PURE__*/_react.default.createElement(_sdocViewer.default, {
|
|
59
59
|
document: document,
|
|
@@ -51,7 +51,7 @@ const RevisionDiffViewer = _ref => {
|
|
|
51
51
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_sdocViewer.default, {
|
|
52
52
|
editor: editor,
|
|
53
53
|
document: {
|
|
54
|
-
|
|
54
|
+
elements: diff.value
|
|
55
55
|
},
|
|
56
56
|
showToolbar: true,
|
|
57
57
|
showOutline: true,
|
|
@@ -25,7 +25,7 @@ const SDocViewer = _ref => {
|
|
|
25
25
|
plugins = []
|
|
26
26
|
} = _ref;
|
|
27
27
|
const validEditor = editor || (0, _nodeId.default)((0, _extension.createDefaultEditor)());
|
|
28
|
-
const slateValue = (document || (0, _utils.generateDefaultDocContent)()).
|
|
28
|
+
const slateValue = (document || (0, _utils.generateDefaultDocContent)()).elements;
|
|
29
29
|
const Provider = showComment ? _hooks.CollaboratorsProvider : _react.Fragment;
|
|
30
30
|
return /*#__PURE__*/_react.default.createElement(Provider, null, /*#__PURE__*/_react.default.createElement(_hooks.PluginsProvider, {
|
|
31
31
|
plugins: plugins,
|
|
@@ -16,6 +16,7 @@ var _useColorContext = require("../hooks/use-color-context");
|
|
|
16
16
|
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
17
17
|
var _wikiOutline = _interopRequireDefault(require("../wiki-outline"));
|
|
18
18
|
require("../assets/css/sdoc-wiki-viewer.css");
|
|
19
|
+
// maybe can be deleted in the future
|
|
19
20
|
const SDocMdViewer = _ref => {
|
|
20
21
|
let {
|
|
21
22
|
editor,
|
|
@@ -22,13 +22,6 @@ const useDocument = () => {
|
|
|
22
22
|
return new Promise((resolve, reject) => {
|
|
23
23
|
_context.default.getFileContent().then(res => {
|
|
24
24
|
let result = res.data;
|
|
25
|
-
if (result && !result.children) {
|
|
26
|
-
result = {
|
|
27
|
-
version: 0,
|
|
28
|
-
children: result.content,
|
|
29
|
-
cursors: result.cursors || {}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
25
|
resolve(result);
|
|
33
26
|
}).catch(error => {
|
|
34
27
|
// eslint-disable-next-line
|
|
@@ -30,12 +30,6 @@ class SimpleViewer extends _react.default.Component {
|
|
|
30
30
|
try {
|
|
31
31
|
const contentRes = await _context.default.getFileContent();
|
|
32
32
|
let result = contentRes.data || (0, _utils.generateDefaultDocContent)();
|
|
33
|
-
if (result && !result.children) {
|
|
34
|
-
result = {
|
|
35
|
-
version: 0,
|
|
36
|
-
children: result.content
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
33
|
this.setState({
|
|
40
34
|
isContextInit: true,
|
|
41
35
|
document: result
|
package/dist/utils/index.js
CHANGED