@seafile/sdoc-editor 0.1.154-beta → 0.1.154

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.
Files changed (30) hide show
  1. package/dist/api/sdoc-server-api.js +0 -10
  2. package/dist/api/seafile-api.js +9 -17
  3. package/dist/basic-sdk/constants/index.js +1 -25
  4. package/dist/basic-sdk/editor.js +105 -0
  5. package/dist/basic-sdk/extension/constants/element-type.js +1 -6
  6. package/dist/basic-sdk/extension/core/transforms/replace-node-children.js +0 -26
  7. package/dist/basic-sdk/extension/render/render-element.js +1 -247
  8. package/dist/basic-sdk/{editor/slate-editor.js → slate-editor.js} +16 -21
  9. package/dist/basic-sdk/socket/helpers.js +0 -2
  10. package/dist/basic-sdk/socket/socket-client.js +0 -45
  11. package/dist/basic-sdk/socket/socket-manager.js +2 -28
  12. package/dist/basic-sdk/socket/with-socket-io.js +12 -35
  13. package/dist/basic-sdk/utils/diff.js +3 -4
  14. package/dist/basic-sdk/views/diff-viewer.js +1 -3
  15. package/dist/basic-sdk/views/viewer.js +12 -9
  16. package/dist/components/doc-operations/index.js +2 -4
  17. package/dist/components/doc-operations/revision-operations/index.js +2 -5
  18. package/dist/components/doc-operations/revision-operations/publish-button.js +13 -6
  19. package/dist/constants/index.js +2 -23
  20. package/dist/context.js +9 -34
  21. package/dist/pages/simple-editor.js +83 -250
  22. package/package.json +1 -1
  23. package/public/locales/en/sdoc-editor.json +1 -11
  24. package/public/locales/zh_CN/sdoc-editor.json +1 -10
  25. package/dist/basic-sdk/editor/common-editor.js +0 -50
  26. package/dist/basic-sdk/editor/index.css +0 -29
  27. package/dist/basic-sdk/editor/index.js +0 -129
  28. package/dist/basic-sdk/utils/rebase.js +0 -228
  29. package/dist/components/tip-dialog/index.js +0 -48
  30. package/dist/components/tip-dialog/tip-content.js +0 -47
@@ -58,16 +58,6 @@ var SDocServerApi = /*#__PURE__*/function () {
58
58
  }
59
59
  });
60
60
  }
61
-
62
- // saveDocContentByRebase(content) {
63
- // const { server, docUuid, accessToken } = this;
64
- // const url = `${server}/api/v1/docs/${docUuid}/rebase/`;
65
-
66
- // const formData = new FormData();
67
- // formData.append('doc_content', JSON.stringify(content));
68
-
69
- // return axios.post(url, formData, {headers: {Authorization: `Token ${accessToken}`}});
70
- // }
71
61
  }, {
72
62
  key: "getCollaborators",
73
63
  value: function getCollaborators() {
@@ -46,6 +46,12 @@ var SeafileAPI = /*#__PURE__*/function () {
46
46
  var url = '/api/v2.1/seadoc/download-image/' + docUuid + '/' + encodeURIComponent(imageName);
47
47
  return this.req.get(url);
48
48
  }
49
+ }, {
50
+ key: "sdocPublishRevision",
51
+ value: function sdocPublishRevision(docUuid) {
52
+ var url = '/api/v2.1/seadoc/publish-revision/' + docUuid + '/';
53
+ return this.req.post(url);
54
+ }
49
55
  }, {
50
56
  key: "startRevise",
51
57
  value: function startRevise(repoID, fileUuid, path) {
@@ -57,9 +63,9 @@ var SeafileAPI = /*#__PURE__*/function () {
57
63
  return this._sendPostRequest(url, form);
58
64
  }
59
65
  }, {
60
- key: "getSeadocOriginFileDownloadLink",
61
- value: function getSeadocOriginFileDownloadLink(docUuid) {
62
- var url = '/api/v2.1/seadoc/origin-file-download-link/' + docUuid + '/';
66
+ key: "getSeadocRevisionDownloadLinks",
67
+ value: function getSeadocRevisionDownloadLinks(docUuid) {
68
+ var url = '/api/v2.1/seadoc/revision/download-links/' + docUuid + '/';
63
69
  return this.req.get(url);
64
70
  }
65
71
  }, {
@@ -75,20 +81,6 @@ var SeafileAPI = /*#__PURE__*/function () {
75
81
  var url = 'api/v2.1/seadoc/revisions/' + docUuid + '/?page=' + page + '&per_page=' + perPage;
76
82
  return this.req.get(url);
77
83
  }
78
- }, {
79
- key: "updateSdocRevision",
80
- value: function updateSdocRevision(docUuid) {
81
- var url = 'api/v2.1/seadoc/revision/' + docUuid + '/';
82
- return this.req.put(url);
83
- }
84
- }, {
85
- key: "getFileHistoryVersion",
86
- value: function getFileHistoryVersion(docUuid, fileVersion, docPath) {
87
- var url = 'api/v2.1/seadoc/history-content/' + docUuid + '/?p=' + encodeURIComponent(docPath) + '&file_version=' + fileVersion;
88
- return this.req.get(url);
89
- }
90
-
91
- // local files
92
84
  }, {
93
85
  key: "getSdocFiles",
94
86
  value: function getSdocFiles(docUuid, p, type) {
@@ -6,28 +6,4 @@ export var INTERNAL_EVENT = {
6
6
  INSERT_ELEMENT: 'insert_element',
7
7
  OUTLINE_STATE_CHANGED: 'outline_state_changed'
8
8
  };
9
- export var PAGE_EDIT_AREA_WIDTH = 672; // 672 = 794 - 2[borderLeft + borderRight] - 120[paddingLeft + paddingRight]
10
-
11
- export var MODIFY_TYPE = {
12
- ADD: 'add',
13
- DELETE: 'delete',
14
- MODIFY: 'modify',
15
- CHILDREN_MODIFY: 'children_modify'
16
- };
17
- export var REBASE_TYPE = {
18
- MODIFY_MODIFY: 'modify_modify',
19
- DELETE_MODIFY: 'delete_modify',
20
- MODIFY_DELETE: 'modify_delete',
21
- CHILDREN_MODIFY: 'children_modify'
22
- };
23
- export var REBASE_MARK_KEY = {
24
- ORIGIN: 'origin',
25
- REBASE_TYPE: 'rebase_type',
26
- MODIFY_TYPE: 'modify_type',
27
- OLD_ELEMENT: 'old_element'
28
- };
29
- export var REBASE_ORIGIN = {
30
- OTHER: 'other',
31
- MY: 'my'
32
- };
33
- export var REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
9
+ export var PAGE_EDIT_AREA_WIDTH = 672; // 672 = 794 - 2[borderLeft + borderRight] - 120[paddingLeft + paddingRight]
@@ -0,0 +1,105 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useEffect, useMemo, useState, forwardRef, useImperativeHandle } from 'react';
3
+ import { Editor } from '@seafile/slate';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { createDefaultEditor } from './extension';
6
+ import { focusEditor } from './extension/core';
7
+ import { withSocketIO } from './socket';
8
+ import withNodeId from './node-id';
9
+ import { PAGE_EDIT_AREA_WIDTH } from './constants';
10
+ import context from '../context';
11
+ import { EditorContainer, EditorContent } from './layout';
12
+ import SlateEditor from './slate-editor';
13
+ import InsertElementDialog from './extension/commons/insert-element-dialog';
14
+ var SDocEditor = forwardRef(function (_ref, ref) {
15
+ var document = _ref.document,
16
+ config = _ref.config;
17
+ var _useTranslation = useTranslation(),
18
+ t = _useTranslation.t;
19
+
20
+ // init editor
21
+ var editor = useMemo(function () {
22
+ var defaultEditor = createDefaultEditor();
23
+ var newEditor = withNodeId(withSocketIO(defaultEditor, {
24
+ document: document,
25
+ config: config
26
+ }));
27
+ var cursors = document.cursors;
28
+ newEditor.cursors = cursors || {};
29
+ newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
30
+ newEditor.readonly = false;
31
+ return newEditor;
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ }, []);
34
+ var _useState = useState(document.children),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ slateValue = _useState2[0],
37
+ setSlateValue = _useState2[1];
38
+
39
+ // The parent component can call the method of this component through ref
40
+ useImperativeHandle(ref, function () {
41
+ return {
42
+ // get latest value
43
+ getValue: function getValue() {
44
+ return slateValue;
45
+ }
46
+ };
47
+ }, [slateValue]);
48
+
49
+ // useMount: init socket connection
50
+ useEffect(function () {
51
+ editor.openConnection();
52
+ return function () {
53
+ editor.closeConnection();
54
+ };
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }, []);
57
+
58
+ // useMount: focus editor
59
+ useEffect(function () {
60
+ var timer = setTimeout(function () {
61
+ var _editor$children = _slicedToArray(editor.children, 1),
62
+ firstNode = _editor$children[0];
63
+ if (firstNode) {
64
+ var _firstNode$children = _slicedToArray(firstNode.children, 1),
65
+ firstNodeFirstChild = _firstNode$children[0];
66
+ if (firstNodeFirstChild) {
67
+ var endOfFirstNode = Editor.end(editor, [0, 0]);
68
+ var range = {
69
+ anchor: endOfFirstNode,
70
+ focus: endOfFirstNode
71
+ };
72
+ focusEditor(editor, range);
73
+ }
74
+ }
75
+ }, 300);
76
+ return function () {
77
+ clearTimeout(timer);
78
+ };
79
+ // eslint-disable-next-line react-hooks/exhaustive-deps
80
+ }, []);
81
+
82
+ // useMount: reset title
83
+ useEffect(function () {
84
+ var isSdocRevision = context.getSetting('isSdocRevision');
85
+ var originFilename = context.getSetting('originFilename');
86
+ if (isSdocRevision) {
87
+ window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
88
+ }
89
+
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, []);
92
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
93
+ editor: editor
94
+ }, /*#__PURE__*/React.createElement(EditorContent, {
95
+ docValue: slateValue,
96
+ showOutline: true
97
+ }, /*#__PURE__*/React.createElement(SlateEditor, {
98
+ editor: editor,
99
+ slateValue: slateValue,
100
+ setSlateValue: setSlateValue
101
+ }))), /*#__PURE__*/React.createElement(InsertElementDialog, {
102
+ editor: editor
103
+ }));
104
+ });
105
+ export default SDocEditor;
@@ -22,9 +22,4 @@ export var TABLE_CELL = 'table-cell';
22
22
  export var LINK = 'link';
23
23
  export var SDOC_LINK = 'sdoc-link';
24
24
  export var FILE_LINK = 'file_link';
25
- export var IMAGE = 'image';
26
-
27
- // font
28
- export var FONT_SIZE = 'font-size';
29
- export var FONT_SIZE_INCREASE = 'font-size-increase';
30
- export var FONT_SIZE_REDUCE = 'font-size-reduce';
25
+ export var IMAGE = 'image';
@@ -12,30 +12,4 @@ export var replaceNodeChildren = function replaceNodeChildren(editor, _ref) {
12
12
  at: at.concat([0])
13
13
  }));
14
14
  });
15
- };
16
- export var replaceNode = function replaceNode(editor) {
17
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
18
- at = _ref2.at,
19
- nodes = _ref2.nodes,
20
- insertOptions = _ref2.insertOptions,
21
- removeOptions = _ref2.removeOptions;
22
- Editor.withoutNormalizing(editor, function () {
23
- Transforms.removeNodes(editor, _objectSpread({
24
- at: at
25
- }, removeOptions));
26
- Transforms.insertNodes(editor, nodes, _objectSpread(_objectSpread({}, insertOptions), {}, {
27
- at: at
28
- }));
29
- });
30
- };
31
- export var deleteNodeMark = function deleteNodeMark(editor, path, element) {
32
- var marks = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
33
- var newElement = _objectSpread({}, element);
34
- marks.forEach(function (markItem) {
35
- newElement[markItem] && delete newElement[markItem];
36
- });
37
- replaceNode(editor, {
38
- at: path,
39
- nodes: newElement
40
- });
41
15
  };
@@ -1,16 +1,10 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
2
  import React, { useCallback } from 'react';
5
3
  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
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';
10
5
  import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin } from '../plugins';
11
6
  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, generateEmptyElement, deleteNodeMark } from '../../extension/core';
7
+ import { INTERNAL_EVENT } from '../../constants';
14
8
  var CustomElement = function CustomElement(props) {
15
9
  var editor = useSlateStatic();
16
10
  var element = props.element,
@@ -152,246 +146,6 @@ var CustomElement = function CustomElement(props) {
152
146
  }
153
147
  };
154
148
  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
-
203
- // const addDeletedElement = useCallback((element) => {
204
- // const path = findPath(editor, element);
205
- // deleteNodeMark(editor, path, element, REBASE_MARKS);
206
-
207
- // if (element.type !== ELEMENT_TYPE.LIST_ITEM) {
208
- // const emptyNode = generateEmptyElement(ELEMENT_TYPE.PARAGRAPH);
209
- // Transforms.insertNodes(editor, emptyNode, { at: [ path[0] ] });
210
- // } else {
211
- // const emptyNode = generateEmptyElement(ELEMENT_TYPE.LIST_ITEM);
212
- // emptyNode.children[0] = generateEmptyElement(ELEMENT_TYPE.LIST_LIC);
213
- // const parentPath = path.slice(0, -1);
214
- // const parentNode = getNode(editor, parentPath);
215
- // const newChildren = [ ...parentNode.children ];
216
- // const index = path[path.length - 1];
217
- // newChildren.splice(index, 0, emptyNode);
218
- // replaceNode(editor, { at: parentPath, nodes: { ...parentNode, children: newChildren} });
219
- // }
220
-
221
- // if (element.type === ELEMENT_TYPE.LIST_ITEM) {
222
- // updateParentNodeByPath(path);
223
- // }
224
-
225
- // // eslint-disable-next-line react-hooks/exhaustive-deps
226
- // }, [ editor]);
227
-
228
- var useMasterChanges = useCallback(function (element) {
229
- var path = findPath(editor, element);
230
- deleteNodeMark(editor, path, element[REBASE_MARK_KEY.OLD_ELEMENT], REBASE_MARKS);
231
- var nextElementPath = _toConsumableArray(path);
232
- nextElementPath[path.length - 1] = path[path.length - 1] + 1;
233
- Transforms.removeNodes(editor, {
234
- at: nextElementPath
235
- });
236
- if (element.type === ELEMENT_TYPE.LIST_ITEM) {
237
- updateParentNodeByPath(path);
238
- }
239
-
240
- // eslint-disable-next-line react-hooks/exhaustive-deps
241
- }, [editor]);
242
- var useCurrentChanges = useCallback(function (element) {
243
- var path = findPath(editor, element);
244
- var currentElementPath = _toConsumableArray(path);
245
- currentElementPath[path.length - 1] = path[path.length - 1] + 1;
246
- var currentElement = getNode(editor, currentElementPath);
247
- var newCurrentElement = deepCopy(currentElement);
248
- deleteNodeMark(editor, currentElementPath, newCurrentElement, REBASE_MARKS);
249
- Transforms.removeNodes(editor, {
250
- at: path
251
- });
252
- if (element.type === ELEMENT_TYPE.LIST_ITEM) {
253
- updateParentNodeByPath(path);
254
- }
255
-
256
- // eslint-disable-next-line react-hooks/exhaustive-deps
257
- }, [editor]);
258
- var useBothChanges = useCallback(function (element) {
259
- // delete element marks
260
- var path = findPath(editor, element);
261
- deleteNodeMark(editor, path, element, REBASE_MARKS);
262
-
263
- // delete next element marks
264
- var nextElementPath = [].concat(_toConsumableArray(path.slice(0, -1)), [path[path.length - 1] + 1]);
265
- var nextElement = getNode(editor, nextElementPath);
266
- deleteNodeMark(editor, nextElementPath, nextElement, REBASE_MARKS);
267
- if (element.type === ELEMENT_TYPE.LIST_ITEM) {
268
- updateParentNodeByPath(path);
269
- }
270
-
271
- // eslint-disable-next-line react-hooks/exhaustive-deps
272
- }, [editor]);
273
- var element = props.element;
274
- var rebaseType = element[REBASE_MARK_KEY.REBASE_TYPE];
275
- if (!rebaseType) {
276
- return /*#__PURE__*/React.createElement(CustomElement, props);
277
- }
278
- if (rebaseType === REBASE_TYPE.MODIFY_DELETE) {
279
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
280
- className: "w-100 d-flex sdoc-rebase-btn-group",
281
- contentEditable: false
282
- }, /*#__PURE__*/React.createElement("div", {
283
- className: "sdoc-rebase-btn",
284
- onClick: function onClick() {
285
- return deleteMark(element);
286
- }
287
- }, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
288
- className: "mr-2 ml-2"
289
- }, '|'), /*#__PURE__*/React.createElement("div", {
290
- className: "sdoc-rebase-btn",
291
- onClick: function onClick() {
292
- return deleteElement(element);
293
- }
294
- }, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
295
- className: "mr-2 ml-2"
296
- }, '|'), /*#__PURE__*/React.createElement("div", {
297
- className: "sdoc-rebase-btn",
298
- onClick: function onClick() {
299
- return deleteMark(element);
300
- }
301
- }, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
302
- className: "w-100 sdoc-rebase-current-changes-start",
303
- contentEditable: false
304
- }, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
305
- className: "w-100 sdoc-rebase-incoming-changes",
306
- contentEditable: false
307
- }, /*#__PURE__*/React.createElement(CustomElement, props)), /*#__PURE__*/React.createElement("div", {
308
- className: "w-100",
309
- contentEditable: false
310
- }, '======='), /*#__PURE__*/React.createElement("div", {
311
- className: "w-100 sdoc-rebase-incoming-changes-end",
312
- contentEditable: false
313
- }, '>>>>>>>'));
314
- }
315
- if (rebaseType === REBASE_TYPE.DELETE_MODIFY) {
316
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
317
- className: "w-100 d-flex sdoc-rebase-btn-group",
318
- contentEditable: false
319
- }, /*#__PURE__*/React.createElement("div", {
320
- className: "sdoc-rebase-btn",
321
- onClick: function onClick() {
322
- return deleteElement(element);
323
- }
324
- }, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
325
- className: "mr-2 ml-2"
326
- }, '|'), /*#__PURE__*/React.createElement("div", {
327
- className: "sdoc-rebase-btn",
328
- onClick: function onClick() {
329
- return deleteMark(element);
330
- }
331
- }, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
332
- className: "mr-2 ml-2"
333
- }, '|'), /*#__PURE__*/React.createElement("div", {
334
- className: "sdoc-rebase-btn",
335
- onClick: function onClick() {
336
- return deleteMark(element);
337
- }
338
- }, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
339
- className: "w-100 sdoc-rebase-current-changes-start",
340
- contentEditable: false
341
- }, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
342
- className: "w-100",
343
- contentEditable: false
344
- }, '======='), /*#__PURE__*/React.createElement("div", {
345
- className: "w-100 sdoc-rebase-incoming-changes",
346
- contentEditable: false
347
- }, /*#__PURE__*/React.createElement(CustomElement, props)), /*#__PURE__*/React.createElement("div", {
348
- className: "w-100 sdoc-rebase-incoming-changes-end",
349
- contentEditable: false
350
- }, '>>>>>>>'));
351
- }
352
- if (rebaseType === REBASE_TYPE.MODIFY_MODIFY) {
353
- if (element[REBASE_MARK_KEY.ORIGIN] === REBASE_ORIGIN.OTHER) {
354
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
355
- className: "w-100 d-flex sdoc-rebase-btn-group",
356
- contentEditable: false
357
- }, /*#__PURE__*/React.createElement("div", {
358
- className: "sdoc-rebase-btn",
359
- onClick: function onClick() {
360
- return useMasterChanges(element);
361
- }
362
- }, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
363
- className: "mr-2 ml-2"
364
- }, '|'), /*#__PURE__*/React.createElement("div", {
365
- className: "sdoc-rebase-btn",
366
- onClick: function onClick() {
367
- return useCurrentChanges(element);
368
- }
369
- }, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
370
- className: "mr-2 ml-2"
371
- }, '|'), /*#__PURE__*/React.createElement("div", {
372
- className: "sdoc-rebase-btn",
373
- onClick: function onClick() {
374
- return useBothChanges(element);
375
- }
376
- }, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
377
- className: "w-100 sdoc-rebase-current-changes-start",
378
- contentEditable: false
379
- }, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
380
- className: "w-100 sdoc-rebase-current-changes",
381
- contentEditable: false
382
- }, /*#__PURE__*/React.createElement(CustomElement, props)));
383
- }
384
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
385
- className: "w-100",
386
- contentEditable: false
387
- }, '======='), /*#__PURE__*/React.createElement("div", {
388
- className: "w-100 sdoc-rebase-incoming-changes",
389
- contentEditable: false
390
- }, /*#__PURE__*/React.createElement(CustomElement, props)), /*#__PURE__*/React.createElement("div", {
391
- className: "w-100 sdoc-rebase-incoming-changes-end",
392
- contentEditable: false
393
- }, '>>>>>>>'));
394
- }
395
149
  return /*#__PURE__*/React.createElement(CustomElement, props);
396
150
 
397
151
  // const { element } = props;
@@ -1,24 +1,22 @@
1
1
  import React, { useCallback, useMemo, Fragment } from 'react';
2
2
  import { Editable, ReactEditor, Slate } from '@seafile/slate-react';
3
- import { renderLeaf, renderElement, ContextToolbar, SideToolbar } from '../extension';
4
- import { getAboveBlockNode, getNextNode, getPrevNode, isSelectionAtBlockEnd, isSelectionAtBlockStart } from '../extension/core';
5
- import EventProxy from '../utils/event-handler';
6
- import { useCursors } from '../cursor/use-cursors';
7
- import { INTERNAL_EVENT } from '../constants';
8
- import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
9
- import CommentContextProvider from '../comment/comment-context-provider';
10
- import CommentWrapper from '../comment';
11
- import { usePipDecorate } from '../decorates';
12
- import { getCursorPosition, getDomHeight, getDomMarginTop } from '../utils/dom-utils';
13
- import EventBus from '../utils/event-bus';
14
- import { ArticleContainer } from '../layout';
15
- import { useScrollContext } from '../hooks/use-scroll-context';
3
+ import { renderLeaf, renderElement, ContextToolbar, SideToolbar } from './extension';
4
+ import { getAboveBlockNode, getNextNode, getPrevNode, isSelectionAtBlockEnd, isSelectionAtBlockStart } from './extension/core';
5
+ import EventProxy from './utils/event-handler';
6
+ import { useCursors } from './cursor/use-cursors';
7
+ import { INTERNAL_EVENT } from './constants';
8
+ import { SetNodeToDecorations } from './highlight-decorate/setNodeToDecorations';
9
+ import CommentContextProvider from './comment/comment-context-provider';
10
+ import CommentWrapper from './comment';
11
+ import { usePipDecorate } from './decorates';
12
+ import { getCursorPosition, getDomHeight, getDomMarginTop } from './utils/dom-utils';
13
+ import EventBus from './utils/event-bus';
14
+ import { ArticleContainer } from './layout';
15
+ import { useScrollContext } from './hooks/use-scroll-context';
16
16
  var SlateEditor = function SlateEditor(_ref) {
17
17
  var editor = _ref.editor,
18
18
  setSlateValue = _ref.setSlateValue,
19
- slateValue = _ref.slateValue,
20
- customRenderElement = _ref.renderElement,
21
- isShowComment = _ref.isShowComment;
19
+ slateValue = _ref.slateValue;
22
20
  var _useCursors = useCursors(editor),
23
21
  cursors = _useCursors.cursors;
24
22
  var decorate = usePipDecorate(editor);
@@ -140,15 +138,12 @@ var SlateEditor = function SlateEditor(_ref) {
140
138
  editor: editor
141
139
  }, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ContextToolbar, null), /*#__PURE__*/React.createElement(SetNodeToDecorations, null), /*#__PURE__*/React.createElement(Editable, {
142
140
  cursors: cursors,
143
- renderElement: customRenderElement || renderElement,
141
+ renderElement: renderElement,
144
142
  renderLeaf: renderLeaf,
145
143
  onKeyDown: onKeyDown,
146
144
  onMouseDown: onMouseDown,
147
145
  decorate: decorate,
148
146
  onCut: eventProxy.onCut
149
- })), /*#__PURE__*/React.createElement(SideToolbar, null), isShowComment && /*#__PURE__*/React.createElement(CommentContextProvider, null, /*#__PURE__*/React.createElement(CommentWrapper, null))));
150
- };
151
- SlateEditor.defaultProps = {
152
- isShowComment: true
147
+ })), /*#__PURE__*/React.createElement(SideToolbar, null), /*#__PURE__*/React.createElement(CommentContextProvider, null, /*#__PURE__*/React.createElement(CommentWrapper, null))));
153
148
  };
154
149
  export default SlateEditor;
@@ -4,7 +4,6 @@ import { Editor, Operation } from '@seafile/slate';
4
4
  import { getNode } from '../extension/core';
5
5
  import * as OPERATION from '../node-id/constants';
6
6
  import { setCursor } from '../cursor/helper';
7
- import { MODE } from '../../constants';
8
7
  export var getNodePathById = function getNodePathById(rootNode, nodeId) {
9
8
  var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
10
9
  if (rootNode.id === nodeId) return path;
@@ -253,7 +252,6 @@ export var reExecRevertOperationList = function reExecRevertOperationList(editor
253
252
  }
254
253
  };
255
254
  export var syncRemoteOperations = function syncRemoteOperations(editor, remoteOperations) {
256
- if (editor.mode !== MODE.EDITOR) return;
257
255
  if (remoteOperations.length === 0) return;
258
256
  Editor.withoutNormalizing(editor, function () {
259
257
  for (var i = 0; i < remoteOperations.length; i++) {
@@ -119,45 +119,6 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
119
119
  this.disconnectWithServer = function () {
120
120
  _this.socket.disconnect();
121
121
  };
122
- this.sendPublishDocument = function (originDocUuid, originDocName, isNeedUpdateOriginDoc, callback) {
123
- _this.socket.emit('publish-document', _this.getParams({
124
- origin_doc_uuid: originDocUuid,
125
- origin_doc_name: originDocName,
126
- update_origin_doc: isNeedUpdateOriginDoc
127
- }), function (success) {
128
- callback && callback(success);
129
- });
130
- };
131
- this.receivePublishDocument = function () {
132
- var socketManager = SocketManager.getInstance();
133
- socketManager.receivePublishDocument();
134
- };
135
- this.receivePublishDocumentError = function () {
136
- var socketManager = SocketManager.getInstance();
137
- socketManager.receivePublishDocumentError();
138
- };
139
- this.sendReplaceDocument = function (document, callback) {
140
- _this.socket.emit('replace-document', _this.getParams({
141
- document: document
142
- }), function (result) {
143
- callback && callback(result);
144
- });
145
- };
146
- this.receiveDocumentReplaced = function () {
147
- var socketManager = SocketManager.getInstance();
148
- socketManager.receiveDocumentReplaced();
149
- };
150
- this.receiveDocumentReplacedError = function () {
151
- var socketManager = SocketManager.getInstance();
152
- socketManager.receiveDocumentReplacedError();
153
- };
154
- this.sendSaveDocument = function (callback) {
155
- _this.socket.emit('save-document', _this.getParams({
156
- document: document
157
- }), function (saveFlag) {
158
- callback && callback(saveFlag);
159
- });
160
- };
161
122
  this.config = config;
162
123
  this.isReconnect = false;
163
124
  this.socket = io(config.sdocServer, {
@@ -172,12 +133,6 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
172
133
  this.socket.on('join-room', this.onJoinRoom);
173
134
  this.socket.on('leave-room', this.onLeaveRoom);
174
135
  this.socket.on('update-document', this.onReceiveRemoteOperations);
175
-
176
- // doc-replaced
177
- this.socket.on('doc-replaced', this.receiveDocumentReplaced);
178
- this.socket.on('doc-replaced-error', this.receiveDocumentReplacedError);
179
- this.socket.on('publish-document', this.receivePublishDocument);
180
- this.socket.on('publish-document-error', this.receivePublishDocumentError);
181
136
  this.socket.on('update-cursor', this.receiveCursorLocation);
182
137
  this.socket.io.on('reconnect', this.onReconnect);
183
138
  this.socket.io.on('reconnect_attempt', this.onReconnectAttempt);