@seafile/sdoc-editor 0.1.80 → 0.1.81

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 (37) hide show
  1. package/dist/api/seafile-api.js +6 -0
  2. package/dist/basic-sdk/assets/css/dropdown-menu.css +23 -0
  3. package/dist/basic-sdk/comment/comment-item.js +1 -3
  4. package/dist/basic-sdk/comment/style.css +13 -6
  5. package/dist/basic-sdk/editor.js +5 -2
  6. package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +28 -8
  7. package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +2 -3
  8. package/dist/basic-sdk/extension/plugins/header/menu/index.js +9 -9
  9. package/dist/basic-sdk/extension/plugins/header/menu/style.css +0 -17
  10. package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -5
  11. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +1 -4
  12. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +0 -4
  13. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +14 -14
  14. package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +2 -2
  15. package/dist/basic-sdk/extension/plugins/text-align/menu/style.css +0 -12
  16. package/dist/basic-sdk/socket/socket-manager.js +3 -0
  17. package/dist/basic-sdk/socket/with-socket-io.js +2 -2
  18. package/dist/basic-sdk/views/viewer.js +1 -0
  19. package/dist/components/doc-info/index.js +9 -4
  20. package/dist/components/doc-operations/index.js +10 -3
  21. package/dist/components/doc-operations/revision-operations/index.js +16 -0
  22. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.css +58 -0
  23. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +56 -0
  24. package/dist/components/doc-operations/revision-operations/publish-button.js +28 -0
  25. package/dist/components/doc-operations/{revision-operations.js → revision-operations/revision-operations.js} +3 -3
  26. package/dist/components/doc-operations/revision-operations/view-changes/index.css +3 -0
  27. package/dist/components/doc-operations/revision-operations/view-changes/index.js +26 -0
  28. package/dist/components/switch/index.css +14 -0
  29. package/dist/components/switch/index.js +28 -0
  30. package/dist/components/tip-message/index.js +4 -1
  31. package/dist/context.js +6 -0
  32. package/dist/pages/simple-editor.js +132 -116
  33. package/dist/pages/simple-viewer.js +5 -3
  34. package/package.json +1 -1
  35. package/public/locales/en/sdoc-editor.json +3 -1
  36. package/public/locales/zh-CN/sdoc-editor.json +4 -2
  37. package/public/media/sdoc-editor-font.css +6 -6
@@ -62,6 +62,12 @@ var SeafileAPI = /*#__PURE__*/function () {
62
62
  form.append('file_uuid', fileUuid);
63
63
  return this._sendPostRequest(url, form);
64
64
  }
65
+ }, {
66
+ key: "getSeadocRevisionDownloadLinks",
67
+ value: function getSeadocRevisionDownloadLinks(docUuid) {
68
+ var url = '/api/v2.1/seadoc/revision/download-links/' + docUuid + '/';
69
+ return this.req.get(url);
70
+ }
65
71
  }]);
66
72
  return SeafileAPI;
67
73
  }();
@@ -0,0 +1,23 @@
1
+ .sdoc-dropdown-menu {
2
+ padding: 8px 0;
3
+ }
4
+
5
+ .sdoc-dropdown-menu .sdoc-dropdown-menu-divider {
6
+ width: 100%;
7
+ height: 0;
8
+ margin: 0.5rem 0;
9
+ overflow: hidden;
10
+ border-top: 1px solid #e9ecef;
11
+ }
12
+
13
+ .sdoc-dropdown-menu .sdoc-dropdown-menu-item {
14
+ cursor: pointer;
15
+ height: 28px;
16
+ width: 100%;
17
+ padding: 4px 24px;
18
+ user-select: none;
19
+ }
20
+
21
+ .sdoc-dropdown-menu .sdoc-dropdown-menu-item:hover {
22
+ background-color: rgb(245, 245, 245);
23
+ }
@@ -79,9 +79,7 @@ var CommentItem = function CommentItem(_ref) {
79
79
  placement: "bottom-end",
80
80
  hideArrow: true
81
81
  }, /*#__PURE__*/React.createElement(PopoverBody, {
82
- style: {
83
- padding: '5px'
84
- }
82
+ className: "sdoc-comment-menu"
85
83
  }, /*#__PURE__*/React.createElement("div", {
86
84
  className: "sdoc-popover-menu"
87
85
  }, /*#__PURE__*/React.createElement("div", {
@@ -100,25 +100,32 @@
100
100
  cursor: pointer;
101
101
  }
102
102
 
103
+ .sdoc-comment-menu {
104
+ padding: 0;
105
+ border-radius: 2px;
106
+ }
107
+
103
108
  .sdoc-popover-menu {
104
109
  background: rgb(255, 255, 255);
105
110
  width: 130px;
111
+ padding: 8px 0;
106
112
  height: auto;
107
113
  }
108
114
 
109
115
  .sdoc-popover-menu__item {
110
- padding: 0 10px;
111
- height: 32px;
112
- line-height: 32px;
116
+ padding: 4px 24px;
117
+ height: 28px;
118
+ vertical-align: middle;
113
119
  font-size: 14px;
114
- border-radius: 5px;
115
- color: #0f141a;
116
120
  background-color: transparent;
117
121
  cursor: default;
122
+ color: #202428;
123
+ background-color: #fff;
118
124
  }
119
125
 
120
126
  .sdoc-popover-menu__item:hover {
121
- background-color: rgba(6, 15, 26, 0.05);
127
+ background-color: #20a0ff;
128
+ color: #fff;
122
129
  }
123
130
 
124
131
  .sdoc-comment-container .comment-list-container .comment-editor-wrapper {
@@ -9,7 +9,7 @@ import SDocOutline from './outline';
9
9
  import EventProxy from './utils/event-handler';
10
10
  import { useCursors } from './cursor/use-cursors';
11
11
  import EventBus from './utils/event-bus';
12
- import { EXTERNAL_EVENT } from '../constants';
12
+ import { EXTERNAL_EVENT, PAGE_EDIT_AREA_WIDTH } from '../constants';
13
13
  import { isAllInTable } from './extension/plugins/table/helpers';
14
14
  import { SetNodeToDecorations } from './highlight-decorate/setNodeToDecorations';
15
15
  import { ScrollContext } from './hooks/use-scroll-context';
@@ -19,6 +19,7 @@ import { usePipDecorate } from './decorates';
19
19
  import { getCursorPosition, getDomHeight, getDomMarginTop } from './utils/dom-utils';
20
20
  import './assets/css/layout.css';
21
21
  import './assets/css/sdoc-editor-plugins.css';
22
+ import './assets/css/dropdown-menu.css';
22
23
  var SDocEditor = function SDocEditor(_ref) {
23
24
  var document = _ref.document,
24
25
  config = _ref.config;
@@ -30,6 +31,7 @@ var SDocEditor = function SDocEditor(_ref) {
30
31
  }));
31
32
  var cursors = document.cursors;
32
33
  newEditor.cursors = cursors || {};
34
+ newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
33
35
  return newEditor;
34
36
  // eslint-disable-next-line react-hooks/exhaustive-deps
35
37
  }, []);
@@ -61,7 +63,6 @@ var SDocEditor = function SDocEditor(_ref) {
61
63
  // useMount: init socket connection
62
64
  useEffect(function () {
63
65
  editor.openConnection();
64
- editor.width = articleRef.current.children[0].clientWidth;
65
66
  return function () {
66
67
  editor.closeConnection();
67
68
  };
@@ -71,6 +72,8 @@ var SDocEditor = function SDocEditor(_ref) {
71
72
  // useMount: focus editor
72
73
  useEffect(function () {
73
74
  var timer = setTimeout(function () {
75
+ // real width
76
+ editor.width = articleRef.current.children[0].clientWidth;
74
77
  focusEditor(editor);
75
78
  }, 300);
76
79
  return function () {
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { Editor, Transforms } from '@seafile/slate';
3
- import { BLOCKQUOTE } from '../../constants';
2
+ import { Editor, Transforms, Element } from '@seafile/slate';
3
+ import slugid from 'slugid';
4
+ import { BLOCKQUOTE, CHECK_LIST_ITEM, IMAGE, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
4
5
  import { focusEditor, getNodeType } from '../../core';
5
6
  export var isMenuDisabled = function isMenuDisabled(editor) {
6
7
  if (editor.selection == null) return true;
@@ -11,6 +12,11 @@ export var isMenuDisabled = function isMenuDisabled(editor) {
11
12
  // Only available for p and blockquote
12
13
  if (type === 'paragraph') return true;
13
14
  if (type === 'blockquote') return true;
15
+ if (type === UNORDERED_LIST) return true;
16
+ if (type === ORDERED_LIST) return true;
17
+ if (type === CHECK_LIST_ITEM) return true;
18
+ if (type && type.startWith && type.startWith('header')) return true;
19
+ if (type === IMAGE) return true;
14
20
  return false;
15
21
  },
16
22
  universal: true,
@@ -40,11 +46,25 @@ export var getBlockQuoteType = function getBlockQuoteType(editor) {
40
46
  n = _match[0];
41
47
  return getNodeType(n);
42
48
  };
43
- export var setBlockQuoteType = function setBlockQuoteType(editor, type) {
44
- Transforms.setNodes(editor, {
45
- type: type
46
- }, {
47
- mode: 'highest'
48
- });
49
+ export var setBlockQuoteType = function setBlockQuoteType(editor, active) {
50
+ if (!active) {
51
+ var blockquoteNode = {
52
+ id: slugid.nice(),
53
+ type: BLOCKQUOTE
54
+ };
55
+ Transforms.wrapNodes(editor, blockquoteNode, {
56
+ mode: 'highest',
57
+ match: function match(n) {
58
+ return Element.isElement(n) && Editor.isBlock(editor, n);
59
+ }
60
+ });
61
+ } else {
62
+ Transforms.unwrapNodes(editor, {
63
+ mode: 'highest',
64
+ match: function match(n) {
65
+ return Element.isElement(n) && Editor.isBlock(editor, n);
66
+ }
67
+ });
68
+ }
49
69
  focusEditor(editor);
50
70
  };
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React from 'react';
7
- import { BLOCKQUOTE, MENUS_CONFIG_MAP, PARAGRAPH } from '../../../constants';
7
+ import { BLOCKQUOTE, MENUS_CONFIG_MAP } from '../../../constants';
8
8
  import { MenuItem } from '../../../menu';
9
9
  import { getBlockQuoteType, isMenuDisabled, setBlockQuoteType } from '../helpers';
10
10
  var QuoteMenu = /*#__PURE__*/function (_React$Component) {
@@ -28,8 +28,7 @@ var QuoteMenu = /*#__PURE__*/function (_React$Component) {
28
28
  _this.onMouseDown = function (e) {
29
29
  var editor = _this.props.editor;
30
30
  var active = _this.isActive(editor);
31
- var newType = active ? PARAGRAPH : BLOCKQUOTE;
32
- setBlockQuoteType(editor, newType);
31
+ setBlockQuoteType(editor, active);
33
32
  };
34
33
  return _this;
35
34
  }
@@ -92,29 +92,29 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
92
92
  }, t(HEADER_TITLE_MAP[headerType])), !disabled && /*#__PURE__*/React.createElement("span", {
93
93
  className: headerIconClass
94
94
  })), isShowHeaderPopover && /*#__PURE__*/React.createElement("div", {
95
- className: "header-popover"
95
+ className: "header-popover sdoc-dropdown-menu"
96
96
  }, /*#__PURE__*/React.createElement("div", {
97
- className: "header-menu-item",
97
+ className: "sdoc-dropdown-menu-item",
98
98
  onClick: this.onMouseDown(PARAGRAPH)
99
99
  }, t(HEADER_TITLE_MAP.paragraph)), /*#__PURE__*/React.createElement("div", {
100
- className: "header-divider"
100
+ className: "sdoc-dropdown-menu-divider"
101
101
  }), /*#__PURE__*/React.createElement("div", {
102
- className: "header-menu-item",
102
+ className: "sdoc-dropdown-menu-item",
103
103
  onClick: this.onMouseDown(HEADER1)
104
104
  }, t(HEADER_TITLE_MAP.header1)), /*#__PURE__*/React.createElement("div", {
105
- className: "header-menu-item",
105
+ className: "sdoc-dropdown-menu-item",
106
106
  onClick: this.onMouseDown(HEADER2)
107
107
  }, t(HEADER_TITLE_MAP.header2)), /*#__PURE__*/React.createElement("div", {
108
- className: "header-menu-item",
108
+ className: "sdoc-dropdown-menu-item",
109
109
  onClick: this.onMouseDown(HEADER3)
110
110
  }, t(HEADER_TITLE_MAP.header3)), /*#__PURE__*/React.createElement("div", {
111
- className: "header-menu-item",
111
+ className: "sdoc-dropdown-menu-item",
112
112
  onClick: this.onMouseDown(HEADER4)
113
113
  }, t(HEADER_TITLE_MAP.header4)), /*#__PURE__*/React.createElement("div", {
114
- className: "header-menu-item",
114
+ className: "sdoc-dropdown-menu-item",
115
115
  onClick: this.onMouseDown(HEADER5)
116
116
  }, t(HEADER_TITLE_MAP.header5)), /*#__PURE__*/React.createElement("div", {
117
- className: "header-menu-item",
117
+ className: "sdoc-dropdown-menu-item",
118
118
  onClick: this.onMouseDown(HEADER6)
119
119
  }, t(HEADER_TITLE_MAP.header6))));
120
120
  }
@@ -50,20 +50,3 @@
50
50
  align-items: flex-start;
51
51
  z-index: 10;
52
52
  }
53
-
54
- .header-menu .header-popover .header-divider {
55
- width: 100%;
56
- border-top: 1px solid #e5e5e5;
57
- }
58
-
59
- .header-menu .header-popover .header-menu-item {
60
- cursor: pointer;
61
- height: 30px;
62
- width: 100%;
63
- padding: 4px 24px;
64
- user-select: none;
65
- }
66
-
67
- .header-menu .header-popover .header-menu-item:hover {
68
- background-color: rgb(245, 245, 245);
69
- }
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import urlJoin from 'url-join';
4
4
  import { Editor, Range, Transforms } from '@seafile/slate';
5
- import { BLOCKQUOTE, CODE_BLOCK, IMAGE, ORDERED_LIST, UNORDERED_LIST, ELEMENT_TYPE } from '../../constants';
5
+ import { CODE_BLOCK, IMAGE, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
6
6
  import { generateEmptyElement, getNodeType, isTextNode, getParentNode } from '../../core';
7
7
  import context from '../../../../context';
8
8
  export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor) {
@@ -16,14 +16,10 @@ export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor
16
16
  var parentNode = getParentNode(editor.children, n.id);
17
17
  type = getNodeType(parentNode);
18
18
  }
19
- if (type === ELEMENT_TYPE.TABLE) return true;
20
- if (type === ELEMENT_TYPE.TABLE_ROW) return true;
21
- if (type === ELEMENT_TYPE.TABLE_CELL) return true;
22
19
  if (type === CODE_BLOCK) return true;
23
20
  if (type === ORDERED_LIST) return true;
24
21
  if (type === UNORDERED_LIST) return true;
25
22
  if (type.startsWith('header')) return true;
26
- if (type === BLOCKQUOTE) return true;
27
23
  if (Editor.isVoid(editor, n)) return true;
28
24
  return false;
29
25
  },
@@ -21,9 +21,6 @@ var CommonMenu = /*#__PURE__*/function (_Component) {
21
21
  itemClass = "rich-icon-btn d-flex ".concat(disabled ? 'rich-icon-btn-disabled' : 'rich-icon-btn-hover');
22
22
  return itemClass + ' ' + className;
23
23
  };
24
- _this.hidePopover = function () {
25
- _this.ref && _this.ref.toggle && _this.ref.toggle();
26
- };
27
24
  _this.setRef = function (ref) {
28
25
  _this.ref = ref;
29
26
  if (!_this.ref) return;
@@ -65,7 +62,7 @@ var CommonMenu = /*#__PURE__*/function (_Component) {
65
62
  hideArrow: true,
66
63
  ref: this.setRef
67
64
  }, /*#__PURE__*/React.createElement("div", {
68
- className: "sdoc-common-menu-popover-container"
65
+ className: "sdoc-dropdown-menu"
69
66
  }, children)));
70
67
  }
71
68
  }]);
@@ -1,7 +1,3 @@
1
- .sdoc-common-menu-popover .sdoc-common-menu-popover-container {
2
- padding: 8px 0;
3
- }
4
-
5
1
  .sdoc-table-menu-group .sdoc-drop-down,
6
2
  .sdoc-table-menu-group .sdoc-caret-up {
7
3
  transform: scale(.8);
@@ -59,18 +59,18 @@ var ActiveTableMenu = /*#__PURE__*/function (_Component) {
59
59
  ref: function ref(_ref) {
60
60
  return _this.textAlignRef = _ref;
61
61
  }
62
- }, /*#__PURE__*/React.createElement("button", {
63
- className: "dropdown-item",
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: "sdoc-dropdown-menu-item",
64
64
  onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'left')
65
65
  }, /*#__PURE__*/React.createElement("i", {
66
66
  className: "sdocfont sdoc-align-left mr-2"
67
- }), t('Left')), /*#__PURE__*/React.createElement("button", {
68
- className: "dropdown-item",
67
+ }), t('Left')), /*#__PURE__*/React.createElement("div", {
68
+ className: "sdoc-dropdown-menu-item",
69
69
  onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'center')
70
70
  }, /*#__PURE__*/React.createElement("i", {
71
71
  className: "sdocfont sdoc-align-center mr-2"
72
- }), t('Center')), /*#__PURE__*/React.createElement("button", {
73
- className: "dropdown-item",
72
+ }), t('Center')), /*#__PURE__*/React.createElement("div", {
73
+ className: "sdoc-dropdown-menu-item",
74
74
  onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'right')
75
75
  }, /*#__PURE__*/React.createElement("i", {
76
76
  className: "sdocfont sdoc-align-right mr-2"
@@ -84,11 +84,11 @@ var ActiveTableMenu = /*#__PURE__*/function (_Component) {
84
84
  ref: function ref(_ref2) {
85
85
  return _this.tableColumnRef = _ref2;
86
86
  }
87
- }, /*#__PURE__*/React.createElement("button", {
88
- className: "dropdown-item",
87
+ }, /*#__PURE__*/React.createElement("div", {
88
+ className: "sdoc-dropdown-menu-item",
89
89
  onClick: _this.insertTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.COLUMN)
90
- }, t('Insert_column')), /*#__PURE__*/React.createElement("button", {
91
- className: "dropdown-item",
90
+ }, t('Insert_column')), /*#__PURE__*/React.createElement("div", {
91
+ className: "sdoc-dropdown-menu-item",
92
92
  onClick: _this.removeTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.COLUMN)
93
93
  }, t('Remove_column')));
94
94
  };
@@ -100,11 +100,11 @@ var ActiveTableMenu = /*#__PURE__*/function (_Component) {
100
100
  ref: function ref(_ref3) {
101
101
  return _this.tableRowRef = _ref3;
102
102
  }
103
- }, /*#__PURE__*/React.createElement("button", {
104
- className: "dropdown-item",
103
+ }, /*#__PURE__*/React.createElement("div", {
104
+ className: "sdoc-dropdown-menu-item",
105
105
  onClick: _this.insertTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.ROW)
106
- }, t('Insert_row')), /*#__PURE__*/React.createElement("button", {
107
- className: "dropdown-item",
106
+ }, t('Insert_row')), /*#__PURE__*/React.createElement("div", {
107
+ className: "sdoc-dropdown-menu-item",
108
108
  onClick: _this.removeTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.ROW)
109
109
  }, t('Remove_row')));
110
110
  };
@@ -89,11 +89,11 @@ var TextAlignMenu = /*#__PURE__*/function (_React$Component) {
89
89
  }), !disabled && /*#__PURE__*/React.createElement("span", {
90
90
  className: caretIconClass
91
91
  })), isDropdownMenuOpen && /*#__PURE__*/React.createElement("div", {
92
- className: "align-popover"
92
+ className: "align-popover sdoc-dropdown-menu"
93
93
  }, MENUS_CONFIG_MAP[TEXT_ALIGN].map(function (item, index) {
94
94
  return /*#__PURE__*/React.createElement("span", {
95
95
  key: index,
96
- className: "align-menu-item ".concat(item.iconClass),
96
+ className: "sdoc-dropdown-menu-item ".concat(item.iconClass),
97
97
  onClick: _this2.setType.bind(_this2, item.type)
98
98
  });
99
99
  })));
@@ -51,15 +51,3 @@
51
51
  align-items: flex-start;
52
52
  z-index: 10;
53
53
  }
54
-
55
- .align-menu .align-popover .align-menu-item {
56
- cursor: pointer;
57
- height: 30px;
58
- width: 100%;
59
- padding: 4px 24px;
60
- user-select: none;
61
- }
62
-
63
- .align-menu .align-popover .align-menu-item:hover {
64
- background-color: rgb(245, 245, 245);
65
- }
@@ -210,4 +210,7 @@ SocketManager.getInstance = function (editor, document, socketConfig) {
210
210
  SocketManager.instance = new SocketManager(editor, document, socketConfig);
211
211
  return SocketManager.instance;
212
212
  };
213
+ SocketManager.destroy = function () {
214
+ SocketManager.instance = null;
215
+ };
213
216
  export default SocketManager;
@@ -1,4 +1,3 @@
1
- var _this = this;
2
1
  import { generateCursorData } from '../cursor/helper';
3
2
  import EventBus from '../utils/event-bus';
4
3
  import SocketManager from './socket-manager';
@@ -16,7 +15,8 @@ var withSocketIO = function withSocketIO(editor, options) {
16
15
  socketManager = SocketManager.getInstance(newEditor, document, config);
17
16
  };
18
17
  newEditor.closeConnection = function () {
19
- socketManager && _this.socketManager.closeConnection();
18
+ socketManager && socketManager.closeSocketConnect();
19
+ SocketManager.destroy();
20
20
  };
21
21
  newEditor.onChange = function () {
22
22
  var operations = newEditor.operations;
@@ -8,6 +8,7 @@ import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations
8
8
  import { usePipDecorate } from '../decorates';
9
9
  import '../assets/css/layout.css';
10
10
  import '../assets/css/sdoc-editor-plugins.css';
11
+ import '../assets/css/dropdown-menu.css';
11
12
  var SDocViewer = function SDocViewer(_ref) {
12
13
  var document = _ref.document,
13
14
  customRenderLeaf = _ref.renderLeaf,
@@ -7,7 +7,8 @@ import { EXTERNAL_EVENT } from '../../constants';
7
7
  import { DateUtils } from '../../utils';
8
8
  var DocInfo = function DocInfo(_ref) {
9
9
  var t = _ref.t,
10
- isStarred = _ref.isStarred;
10
+ isStarred = _ref.isStarred,
11
+ isEditMode = _ref.isEditMode;
11
12
  var onInternalLinkClick = useCallback(function () {
12
13
  var eventBus = EventBus.getInstance();
13
14
  eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
@@ -32,7 +33,9 @@ var DocInfo = function DocInfo(_ref) {
32
33
  className: "internal-link sdocfont sdoc-link",
33
34
  title: t('Internal_link'),
34
35
  onClick: onInternalLinkClick
35
- })), /*#__PURE__*/React.createElement(TipMessage, null));
36
+ })), /*#__PURE__*/React.createElement(TipMessage, {
37
+ isEditMode: isEditMode
38
+ }));
36
39
  if (!isSdocRevision) {
37
40
  return /*#__PURE__*/React.createElement("div", {
38
41
  className: "doc-info"
@@ -43,12 +46,14 @@ var DocInfo = function DocInfo(_ref) {
43
46
  var revisionCreatedAt = context.getSetting('revisionCreatedAt');
44
47
  var oldDocName = context.getSetting('originFilename');
45
48
  return /*#__PURE__*/React.createElement("div", {
46
- className: "doc-info d-flex flex-column"
49
+ className: "doc-info d-flex flex-column align-items-start"
47
50
  }, /*#__PURE__*/React.createElement("div", {
48
51
  className: "doc-name-container d-flex align-items-center justify-content-start w-100"
49
52
  }, /*#__PURE__*/React.createElement("div", {
50
53
  className: "doc-name"
51
- }, oldDocName), docInfo), /*#__PURE__*/React.createElement("div", {
54
+ }, oldDocName), /*#__PURE__*/React.createElement(TipMessage, {
55
+ isEditMode: isEditMode
56
+ })), /*#__PURE__*/React.createElement("div", {
52
57
  className: "doc-state"
53
58
  }, /*#__PURE__*/React.createElement("span", {
54
59
  className: "mr-2"
@@ -4,14 +4,21 @@ import RevisionOperations from './revision-operations';
4
4
  import HistoryOperation from './history-operation';
5
5
  import CollaboratorsOperation from './collaborators-operation';
6
6
  import MoreOperations from './more-operations';
7
+ import context from '../../context';
7
8
  import './style.css';
8
- var DocOperations = function DocOperations() {
9
+ var DocOperations = function DocOperations(_ref) {
10
+ var isShowChanges = _ref.isShowChanges,
11
+ toggleViewChanges = _ref.toggleViewChanges;
12
+ var isSdocRevision = context.getSetting('isSdocRevision');
9
13
  return /*#__PURE__*/React.createElement("div", {
10
14
  className: "doc-ops"
11
- }, /*#__PURE__*/React.createElement(RevisionOperations, null), /*#__PURE__*/React.createElement("span", {
15
+ }, /*#__PURE__*/React.createElement(RevisionOperations, {
16
+ isShowChanges: isShowChanges,
17
+ toggleViewChanges: toggleViewChanges
18
+ }), !isSdocRevision && /*#__PURE__*/React.createElement("span", {
12
19
  className: "op-item"
13
20
  }, /*#__PURE__*/React.createElement("i", {
14
21
  className: "sdocfont sdoc-share"
15
- })), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), /*#__PURE__*/React.createElement(MoreOperations, null));
22
+ })), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
16
23
  };
17
24
  export default withTranslation('sdoc-editor')(DocOperations);
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import context from '../../../context';
3
+ import PublishRevision from './publish-button';
4
+ import ViewChanges from './view-changes';
5
+ import MoreRevisionOperations from './more-revision-operations';
6
+ var RevisionOperations = function RevisionOperations(_ref) {
7
+ var isShowChanges = _ref.isShowChanges,
8
+ toggleViewChanges = _ref.toggleViewChanges;
9
+ var isSdocRevision = context.getSetting('isSdocRevision');
10
+ var isPublished = context.getSetting('isPublished');
11
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !isSdocRevision && /*#__PURE__*/React.createElement(MoreRevisionOperations, null), isSdocRevision && /*#__PURE__*/React.createElement(ViewChanges, {
12
+ isShowChanges: isShowChanges,
13
+ toggleViewChanges: toggleViewChanges
14
+ }), isSdocRevision && !isPublished && /*#__PURE__*/React.createElement(PublishRevision, null));
15
+ };
16
+ export default RevisionOperations;
@@ -0,0 +1,58 @@
1
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle {
2
+ width: 66px;
3
+ height: 30px;
4
+ border-radius: 15px;
5
+ background-color: #F0F0F0;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ color: #666;
10
+ }
11
+
12
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle:hover {
13
+ cursor: pointer;
14
+ color: #333;
15
+ }
16
+
17
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle .sdoc-revise {
18
+ margin-right: 10px;
19
+ }
20
+
21
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle .sdocfont {
22
+ font-size: 14px;
23
+ }
24
+
25
+ .sdoc-more-revision-operations-dropdown .dropdown-item {
26
+ padding: 12px;
27
+ min-height: 32px;
28
+ }
29
+
30
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operation {
31
+ width: 373px;
32
+ display: flex;
33
+ flex-direction: column;
34
+ align-items: flex-start;
35
+ }
36
+
37
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operation-title .sdocfont {
38
+ font-size: 14px;
39
+ margin-right: 6px;
40
+ }
41
+
42
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operation-title-name {
43
+ color: #212529;
44
+ font-size: 14px;
45
+ }
46
+
47
+ .sdoc-more-revision-operations-dropdown .sdoc-more-revision-operation-describe {
48
+ padding-left: 20px;
49
+ color: #999;
50
+ font-size: 13px;
51
+ width: 100%;
52
+ white-space: break-spaces;
53
+ }
54
+
55
+ .sdoc-more-revision-operations-dropdown .dropdown-item:hover .sdoc-more-revision-operation-title-name,
56
+ .sdoc-more-revision-operations-dropdown .dropdown-item:hover .sdoc-more-revision-operation-describe {
57
+ color: #fff;
58
+ }
@@ -0,0 +1,56 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback, useState } from 'react';
3
+ import { withTranslation } from 'react-i18next';
4
+ import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
5
+ import context from '../../../../context';
6
+ import toaster from '../../../toast';
7
+ import './index.css';
8
+ var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
9
+ var t = _ref.t;
10
+ var repoID = context.getSetting('repoID');
11
+ var siteRoot = context.getSetting('siteRoot');
12
+ var _useState = useState(false),
13
+ _useState2 = _slicedToArray(_useState, 2),
14
+ isDropdownOpen = _useState2[0],
15
+ setIsDropdownOpen = _useState2[1];
16
+ var toggleDropdown = useCallback(function (isDropdownOpen) {
17
+ setIsDropdownOpen(!isDropdownOpen);
18
+ }, []);
19
+ var startRevise = useCallback(function () {
20
+ context.startRevise().then(function (res) {
21
+ window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/file").concat(res.data.file_path);
22
+ }).catch(function (error) {
23
+ toaster.danger(t('Error'));
24
+ });
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ }, []);
27
+ return /*#__PURE__*/React.createElement(Dropdown, {
28
+ isOpen: isDropdownOpen,
29
+ toggle: function toggle() {
30
+ return toggleDropdown(isDropdownOpen);
31
+ },
32
+ className: "sdoc-more-revision-operations-dropdown"
33
+ }, /*#__PURE__*/React.createElement(DropdownToggle, {
34
+ className: "ml-4 sdoc-more-revision-operations-toggle",
35
+ tag: "div"
36
+ }, /*#__PURE__*/React.createElement("i", {
37
+ className: "sdocfont sdoc-revise"
38
+ }), /*#__PURE__*/React.createElement("span", {
39
+ className: "sdocfont sdoc-".concat(isDropdownOpen ? 'caret-up' : 'drop-down')
40
+ })), /*#__PURE__*/React.createElement(DropdownMenu, {
41
+ right: true
42
+ }, /*#__PURE__*/React.createElement(DropdownItem, {
43
+ onClick: startRevise
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ className: "sdoc-more-revision-operation"
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ className: "sdoc-more-revision-operation-title"
48
+ }, /*#__PURE__*/React.createElement("i", {
49
+ className: "sdocfont sdoc-revise"
50
+ }), /*#__PURE__*/React.createElement("span", {
51
+ className: "sdoc-more-revision-operation-title-name"
52
+ }, t('Revise'))), /*#__PURE__*/React.createElement("div", {
53
+ className: "sdoc-more-revision-operation-describe"
54
+ }, t('Start_revise_tip'))))));
55
+ };
56
+ export default withTranslation('sdoc-editor')(MoreRevisionOperations);
@@ -0,0 +1,28 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Button } from 'reactstrap';
3
+ import { withTranslation } from 'react-i18next';
4
+ import context from '../../../context';
5
+ import toaster from '../../../components/toast';
6
+ var PublishRevision = function PublishRevision(_ref) {
7
+ var t = _ref.t;
8
+ var repoID = context.getSetting('repoID');
9
+ var siteRoot = context.getSetting('siteRoot');
10
+ var publish = useCallback(function (event) {
11
+ event.stopPropagation();
12
+ event.nativeEvent.stopImmediatePropagation();
13
+ context.publishSdocRevision().then(function (res) {
14
+ var origin_file_path = res.data.origin_file_path;
15
+ window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/file/").concat(origin_file_path);
16
+ }).catch(function (error) {
17
+ toaster.danger(t('Error'));
18
+ });
19
+
20
+ // eslint-disable-next-line react-hooks/exhaustive-deps
21
+ }, []);
22
+ return /*#__PURE__*/React.createElement(Button, {
23
+ color: "success",
24
+ onClick: publish,
25
+ className: "ml-4"
26
+ }, t('Publish'));
27
+ };
28
+ export default withTranslation('sdoc-editor')(PublishRevision);
@@ -1,8 +1,8 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { Button } from 'reactstrap';
3
3
  import { withTranslation } from 'react-i18next';
4
- import context from '../../context';
5
- import toaster from '../../components/toast';
4
+ import context from '../../../context';
5
+ import toaster from '../../toast';
6
6
  var RevisionOperations = function RevisionOperations(_ref) {
7
7
  var t = _ref.t;
8
8
  var isSdocRevision = context.getSetting('isSdocRevision');
@@ -48,7 +48,7 @@ var RevisionOperations = function RevisionOperations(_ref) {
48
48
  // eslint-disable-next-line react-hooks/exhaustive-deps
49
49
  }, []);
50
50
  if (!isSdocRevision) return startReviseBtn();
51
- return /*#__PURE__*/React.createElement(React.Fragment, null, startReviseBtn('mr-4'), !isPublished && revisionURL && /*#__PURE__*/React.createElement(Button, {
51
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !isPublished && revisionURL && /*#__PURE__*/React.createElement(Button, {
52
52
  color: "success",
53
53
  className: "mr-4",
54
54
  onClick: viewChanges
@@ -0,0 +1,3 @@
1
+ .sdoc-toggle-revision-changes .custom-switch {
2
+ padding-left: 0;
3
+ }
@@ -0,0 +1,26 @@
1
+ import React, { useCallback } from 'react';
2
+ import { withTranslation } from 'react-i18next';
3
+ import { UncontrolledTooltip } from 'reactstrap';
4
+ import Switch from '../../../switch';
5
+ import './index.css';
6
+ var ViewChanges = function ViewChanges(_ref) {
7
+ var isShowChanges = _ref.isShowChanges,
8
+ t = _ref.t,
9
+ toggleViewChanges = _ref.toggleViewChanges;
10
+ var onToggleViewCHanges = useCallback(function () {
11
+ toggleViewChanges(!isShowChanges);
12
+
13
+ // eslint-disable-next-line react-hooks/exhaustive-deps
14
+ }, [isShowChanges]);
15
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
16
+ id: "sdoc-toggle-revision-changes-container",
17
+ className: "h-100 ml-4 d-flex align-items-center "
18
+ }, /*#__PURE__*/React.createElement(Switch, {
19
+ checked: isShowChanges,
20
+ onChange: onToggleViewCHanges,
21
+ className: "sdoc-toggle-revision-changes d-flex align-items-center"
22
+ })), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
23
+ target: "sdoc-toggle-revision-changes-container"
24
+ }, t('View_changes')));
25
+ };
26
+ export default withTranslation('sdoc-editor')(ViewChanges);
@@ -0,0 +1,14 @@
1
+ .seadoc-switch.small .custom-switch-indicator {
2
+ width: 22px;
3
+ height: 12px;
4
+ border-radius: 6px;
5
+ }
6
+
7
+ .seadoc-switch.small .custom-switch-indicator:before {
8
+ height: 8px;
9
+ width: 8px;
10
+ }
11
+
12
+ .seadoc-switch.small .custom-switch-input:checked~.custom-switch-indicator:before {
13
+ left: 12px;
14
+ }
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import './index.css';
4
+ function Switch(props) {
5
+ var onChange = props.onChange,
6
+ checked = props.checked,
7
+ placeholder = props.placeholder,
8
+ disabled = props.disabled,
9
+ className = props.className,
10
+ size = props.size;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: classnames('seadoc-switch position-relative', className, size)
13
+ }, /*#__PURE__*/React.createElement("label", {
14
+ className: "custom-switch"
15
+ }, /*#__PURE__*/React.createElement("input", {
16
+ className: "custom-switch-input",
17
+ type: "checkbox",
18
+ checked: checked,
19
+ onChange: onChange,
20
+ name: "custom-switch-checkbox",
21
+ disabled: disabled
22
+ }), placeholder && /*#__PURE__*/React.createElement("span", {
23
+ className: "custom-switch-description text-truncate"
24
+ }, placeholder), /*#__PURE__*/React.createElement("span", {
25
+ className: "custom-switch-indicator"
26
+ })));
27
+ }
28
+ export default Switch;
@@ -23,7 +23,10 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
23
23
  });
24
24
  };
25
25
  _this.onDisconnect = function () {
26
- var t = _this.props.t;
26
+ var _this$props = _this.props,
27
+ t = _this$props.t,
28
+ isEditMode = _this$props.isEditMode;
29
+ if (!isEditMode) return;
27
30
  var message = t('Server_is_not_connected_Operation_will_be_sent_to_server_later');
28
31
  toaster.warning(message, {
29
32
  hasCloseButton: true,
package/dist/context.js CHANGED
@@ -139,6 +139,12 @@ var Context = /*#__PURE__*/function () {
139
139
  var docUuid = this.getSetting('docUuid');
140
140
  return this.api.sdocPublishRevision(docUuid);
141
141
  }
142
+ }, {
143
+ key: "getSeadocRevisionDownloadLinks",
144
+ value: function getSeadocRevisionDownloadLinks() {
145
+ var docUuid = this.getSetting('docUuid');
146
+ return this.api.getSeadocRevisionDownloadLinks(docUuid);
147
+ }
142
148
  }]);
143
149
  return Context;
144
150
  }();
@@ -1,10 +1,6 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
7
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback, useEffect, useState } from 'react';
3
+ import { withTranslation } from 'react-i18next';
8
4
  import { SDocEditor } from '../basic-sdk';
9
5
  import Loading from '../components/loading';
10
6
  import DocInfo from '../components/doc-info';
@@ -12,116 +8,136 @@ import DocOperations from '../components/doc-operations';
12
8
  import Layout, { Header, Content } from '../layout';
13
9
  import { generateDefaultDocContent } from '../utils';
14
10
  import context from '../context';
11
+ import DiffViewer from './diff-viewer';
15
12
  import '../assets/css/simple-editor.css';
16
- var SimpleEditor = /*#__PURE__*/function (_React$Component) {
17
- _inherits(SimpleEditor, _React$Component);
18
- var _super = _createSuper(SimpleEditor);
19
- function SimpleEditor(props) {
20
- var _this;
21
- _classCallCheck(this, SimpleEditor);
22
- _this = _super.call(this, props);
23
- _this.onValueChanged = function (value) {
24
- _this.isValueChanged = true;
25
- _this.value = value;
26
- };
27
- _this.onSave = function () {
28
- if (_this.isValueChanged) {
29
- _this.isValueChanged = false;
30
- var content = {
31
- version: _this.state.document.version,
32
- children: _this.value
13
+ var SimpleEditor = function SimpleEditor(_ref) {
14
+ var isStarred = _ref.isStarred,
15
+ t = _ref.t;
16
+ var _useState = useState(true),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ isFirstLoad = _useState2[0],
19
+ setFirstLoad = _useState2[1];
20
+ var _useState3 = useState(false),
21
+ _useState4 = _slicedToArray(_useState3, 2),
22
+ isContextInit = _useState4[0],
23
+ setContextInit = _useState4[1];
24
+ var _useState5 = useState(''),
25
+ _useState6 = _slicedToArray(_useState5, 2),
26
+ errorMessage = _useState6[0],
27
+ setErrorMessage = _useState6[1];
28
+ var _useState7 = useState(false),
29
+ _useState8 = _slicedToArray(_useState7, 2),
30
+ isShowChanges = _useState8[0],
31
+ setShowChanges = _useState8[1];
32
+ var _useState9 = useState(null),
33
+ _useState10 = _slicedToArray(_useState9, 2),
34
+ document = _useState10[0],
35
+ setDocument = _useState10[1];
36
+ var _useState11 = useState(null),
37
+ _useState12 = _slicedToArray(_useState11, 2),
38
+ currentContent = _useState12[0],
39
+ setCurrentContent = _useState12[1];
40
+ var _useState13 = useState(null),
41
+ _useState14 = _slicedToArray(_useState13, 2),
42
+ lastContent = _useState14[0],
43
+ setLastContent = _useState14[1];
44
+ useEffect(function () {
45
+ context.initApi();
46
+ initDocumentData(true);
47
+
48
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
+ }, []);
50
+ var initDocumentData = useCallback(function (isFirstLoad) {
51
+ setShowChanges(false);
52
+ context.getFileContent().then(function (res) {
53
+ var result = res.data || generateDefaultDocContent();
54
+ if (result && !result.children) {
55
+ result = {
56
+ version: 0,
57
+ children: result.content,
58
+ cursors: result.cursors || {}
33
59
  };
34
- context.saveContent(JSON.stringify(content)).then(function (res) {
35
- // eslint-disable-next-line
36
- console.log('saved success');
37
- });
38
- }
39
- };
40
- _this.state = {
41
- isContextInit: false,
42
- errorMessage: null,
43
- document: null,
44
- isSaved: false,
45
- isSaving: false
46
- };
47
- _this.saveTimer = null;
48
- return _this;
49
- }
50
- _createClass(SimpleEditor, [{
51
- key: "componentDidMount",
52
- value: function () {
53
- var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
54
- var contentRes, result;
55
- return _regeneratorRuntime().wrap(function _callee$(_context) {
56
- while (1) switch (_context.prev = _context.next) {
57
- case 0:
58
- context.initApi();
59
- _context.prev = 1;
60
- _context.next = 4;
61
- return context.getFileContent();
62
- case 4:
63
- contentRes = _context.sent;
64
- result = contentRes.data || generateDefaultDocContent();
65
- if (result && !result.children) {
66
- result = {
67
- version: 0,
68
- children: result.content,
69
- cursors: result.cursors || {}
70
- };
71
- }
72
- this.setState({
73
- isContextInit: true,
74
- document: result
75
- });
76
- _context.next = 14;
77
- break;
78
- case 10:
79
- _context.prev = 10;
80
- _context.t0 = _context["catch"](1);
81
- // eslint-disable-next-line
82
- console.log(_context.t0);
83
- this.setState({
84
- isContextInit: true,
85
- errorMessage: 'load doc content error',
86
- document: null
87
- });
88
- case 14:
89
- case "end":
90
- return _context.stop();
91
- }
92
- }, _callee, this, [[1, 10]]);
93
- }));
94
- function componentDidMount() {
95
- return _componentDidMount.apply(this, arguments);
96
- }
97
- return componentDidMount;
98
- }()
99
- }, {
100
- key: "render",
101
- value: function render() {
102
- var _this$state = this.state,
103
- isContextInit = _this$state.isContextInit,
104
- errorMessage = _this$state.errorMessage,
105
- document = _this$state.document;
106
- if (!isContextInit) {
107
- return /*#__PURE__*/React.createElement(Loading, null);
108
60
  }
109
- if (errorMessage) {
110
- return /*#__PURE__*/React.createElement("div", {
111
- className: "d-flex justify-content-center"
112
- }, errorMessage);
113
- }
114
- var isOpenSocket = context.getSetting('isOpenSocket');
115
- return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
116
- isStarred: this.props.isStarred
117
- }), /*#__PURE__*/React.createElement(DocOperations, null)), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocEditor, {
118
- config: context.getEditorConfig(),
119
- document: document,
120
- isOpenSocket: isOpenSocket,
121
- onValueChanged: this.onValueChanged
122
- })));
61
+ setDocument(result);
62
+ setContextInit(true);
63
+ isFirstLoad && setFirstLoad(false);
64
+ }).catch(function (error) {
65
+ // eslint-disable-next-line
66
+ console.log(error);
67
+ setErrorMessage('Load_doc_content_error');
68
+ setDocument(null);
69
+ setContextInit(true);
70
+ isFirstLoad && setFirstLoad(false);
71
+ });
72
+
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, []);
75
+ var initChangesData = useCallback(function () {
76
+ setShowChanges(true);
77
+ context.getSeadocRevisionDownloadLinks().then(function (res) {
78
+ var _res$data = res.data,
79
+ fileDownloadLink = _res$data.file_download_link,
80
+ originFileDownloadLink = _res$data.origin_file_download_link;
81
+ fetch(fileDownloadLink).then(function (res) {
82
+ return res.json();
83
+ }).then(function (revisionContent) {
84
+ fetch(originFileDownloadLink).then(function (res) {
85
+ return res.json();
86
+ }).then(function (originContent) {
87
+ setCurrentContent(revisionContent);
88
+ setLastContent(originContent);
89
+ setErrorMessage(null);
90
+ setContextInit(true);
91
+ }).catch(function (error) {
92
+ setErrorMessage('Load_doc_content_error');
93
+ setContextInit(true);
94
+ });
95
+ }).catch(function (error) {
96
+ setErrorMessage('Load_doc_content_error');
97
+ setContextInit(true);
98
+ });
99
+ }).catch(function (error) {
100
+ setErrorMessage('Load_doc_content_error');
101
+ setContextInit(true);
102
+ });
103
+
104
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
+ }, []);
106
+ var toggleViewChanges = useCallback(function (isShowChanges) {
107
+ setContextInit(false);
108
+ if (isShowChanges) {
109
+ initChangesData();
110
+ return;
123
111
  }
124
- }]);
125
- return SimpleEditor;
126
- }(React.Component);
127
- export default SimpleEditor;
112
+ initDocumentData(false);
113
+
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ }, []);
116
+ if (isFirstLoad && !isContextInit) {
117
+ return /*#__PURE__*/React.createElement(Loading, null);
118
+ }
119
+ if (isFirstLoad && errorMessage) {
120
+ return /*#__PURE__*/React.createElement("div", {
121
+ className: "d-flex justify-content-center"
122
+ }, t(errorMessage));
123
+ }
124
+ return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
125
+ isStarred: isStarred,
126
+ isEditMode: !isShowChanges
127
+ }), /*#__PURE__*/React.createElement(DocOperations, {
128
+ isShowChanges: isShowChanges,
129
+ toggleViewChanges: toggleViewChanges
130
+ })), /*#__PURE__*/React.createElement(Content, null, !isContextInit && /*#__PURE__*/React.createElement("div", {
131
+ className: "w-100 h-100 d-flex align-items-center justify-content-center"
132
+ }, /*#__PURE__*/React.createElement(Loading, null)), !isContextInit && errorMessage && /*#__PURE__*/React.createElement("div", {
133
+ className: "w-100 h-100 d-flex justify-content-center align-items-center"
134
+ }, t(errorMessage)), isContextInit && /*#__PURE__*/React.createElement(React.Fragment, null, isShowChanges ? /*#__PURE__*/React.createElement(DiffViewer, {
135
+ currentContent: currentContent,
136
+ lastContent: lastContent
137
+ }) : /*#__PURE__*/React.createElement(SDocEditor, {
138
+ config: context.getEditorConfig(),
139
+ document: document,
140
+ isOpenSocket: context.getSetting('isOpenSocket')
141
+ }))));
142
+ };
143
+ export default withTranslation('sdoc-editor')(SimpleEditor);
@@ -5,6 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
7
7
  import React from 'react';
8
+ import { withTranslation } from 'react-i18next';
8
9
  import { SDocViewer } from '../basic-sdk';
9
10
  import context from '../context';
10
11
  import Loading from '../components/loading';
@@ -63,7 +64,7 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
63
64
  console.log(_context.t0);
64
65
  this.setState({
65
66
  isContextInit: true,
66
- errorMessage: 'load doc content error',
67
+ errorMessage: 'Load_doc_content_error',
67
68
  document: null
68
69
  });
69
70
  case 14:
@@ -84,13 +85,14 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
84
85
  isContextInit = _this$state.isContextInit,
85
86
  errorMessage = _this$state.errorMessage,
86
87
  document = _this$state.document;
88
+ var t = this.props.t;
87
89
  if (!isContextInit) {
88
90
  return /*#__PURE__*/React.createElement(Loading, null);
89
91
  }
90
92
  if (errorMessage) {
91
93
  return /*#__PURE__*/React.createElement("div", {
92
94
  className: "d-flex justify-content-center"
93
- }, errorMessage);
95
+ }, t(errorMessage));
94
96
  }
95
97
  var docName = context.getSetting('docName');
96
98
  return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement("div", null, docName)), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocViewer, {
@@ -101,4 +103,4 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
101
103
  }]);
102
104
  return SimpleViewer;
103
105
  }(React.Component);
104
- export default SimpleViewer;
106
+ export default withTranslation('sdoc-editor')(SimpleViewer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.80",
3
+ "version": "0.1.81",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -258,5 +258,7 @@
258
258
  "Revision": "Revision",
259
259
  "Error": "Error",
260
260
  "Start_revise": "Start revise",
261
- "Failed_to_execute_operation_on_server": "Failed to execute operation on server"
261
+ "Failed_to_execute_operation_on_server": "Failed to execute operation on server",
262
+ "Start_revise_tip": "Create a temporary document and modify on it, merge it back after reviewing changes",
263
+ "Load_doc_content_error": "Load doc content error"
262
264
  }
@@ -255,8 +255,10 @@
255
255
  "Are_you_sure_to_delete_this_comment": "你确定要删除这个评论吗?",
256
256
  "Confirm": "确定",
257
257
  "View_changes": "查看改动",
258
- "Revision": "修订",
258
+ "Revision": "修订稿",
259
259
  "Error": "错误",
260
260
  "Start_revise": "开始修订",
261
- "Failed_to_execute_operation_on_server": "无法在服务器上执行操作"
261
+ "Failed_to_execute_operation_on_server": "无法在服务器上执行操作",
262
+ "Start_revise_tip": "创建一个临时文档并对其进行修订,检查更改后将其合并回来",
263
+ "Load_doc_content_error": "加载文档内容错误"
262
264
  }
@@ -1,11 +1,11 @@
1
1
  @font-face {
2
2
  font-family: "sdocfont"; /* Project id 4097705 */
3
- src: url('./sdoc-editor-font/iconfont.eot?t=1689301494065'); /* IE9 */
4
- src: url('./sdoc-editor-font/iconfont.eot?t=1689301494065#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
- url('./sdoc-editor-font/iconfont.woff2?t=1689301494065') format('woff2'),
6
- url('./sdoc-editor-font/iconfont.woff?t=1689301494065') format('woff'),
7
- url('./sdoc-editor-font/iconfont.ttf?t=1689301494065') format('truetype'),
8
- url('./sdoc-editor-font/iconfont.svg?t=1689301494065#sdocfont') format('svg');
3
+ src: url('./sdoc-editor-font/iconfont.eot?t=1689461796012'); /* IE9 */
4
+ src: url('./sdoc-editor-font/iconfont.eot?t=1689461796012#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
+ url('./sdoc-editor-font/iconfont.woff2?t=1689461796012') format('woff2'),
6
+ url('./sdoc-editor-font/iconfont.woff?t=1689461796012') format('woff'),
7
+ url('iconfont.ttf?t=1689461796012') format('truetype'),
8
+ url('./sdoc-editor-font/iconfont.svg?t=1689461796012#sdocfont') format('svg');
9
9
  }
10
10
 
11
11
  .sdocfont {