@seafile/seafile-editor 0.3.129 → 0.3.131

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 (35) hide show
  1. package/dist/components/context-menu.js +1 -1
  2. package/dist/components/dialogs/add-formula-dialog.js +12 -11
  3. package/dist/components/dialogs/add-image-dialog.js +2 -2
  4. package/dist/components/dialogs/add-link-dialog.js +10 -9
  5. package/dist/components/outline/index.js +2 -2
  6. package/dist/components/toolbar/insert-image.js +2 -2
  7. package/dist/components/toolbar/insert-table.js +0 -1
  8. package/dist/components/toolbar/toolbar.js +82 -44
  9. package/dist/containers/controller/block-element-controller.js +3 -3
  10. package/dist/containers/controller/index.js +5 -0
  11. package/dist/containers/controller/inline-element-controller.js +3 -3
  12. package/dist/containers/controller/normalize-controller.js +1 -2
  13. package/dist/containers/{editor-builder.js → editor-context.js} +6 -26
  14. package/dist/containers/editor-utils/common-editor-utils.js +244 -58
  15. package/dist/containers/editor-widgets/column.js +2 -2
  16. package/dist/containers/editor-widgets/formula.js +2 -2
  17. package/dist/containers/editor-widgets/image.js +4 -4
  18. package/dist/editors/markdown-editor.js +8 -9
  19. package/dist/editors/seatable-editor.js +18 -15
  20. package/dist/editors/simple-editor.js +17 -14
  21. package/dist/index.js +3 -3
  22. package/dist/utils/deserialize-html.js +1 -1
  23. package/dist/utils/seafile-markdown2html.js +6 -12
  24. package/dist/utils/slate2markdown/deserialize.js +15 -7
  25. package/dist/utils/slate2markdown/serialize.js +13 -9
  26. package/dist/viewer/slate-viewer.js +6 -6
  27. package/package.json +14 -63
  28. package/dist/containers/editor-plugin.js +0 -228
  29. package/dist/lib/slate-hyperscript/creators.js +0 -243
  30. package/dist/lib/slate-hyperscript/hyperscript.js +0 -78
  31. package/dist/lib/slate-hyperscript/index.js +0 -3
  32. package/dist/lib/slate-hyperscript/tokens.js +0 -99
  33. package/dist/lib/unified/index.js +0 -398
  34. package/dist/lib/vfile/core.js +0 -154
  35. package/dist/lib/vfile/index.js +0 -42
@@ -33,10 +33,10 @@ var ContextMenu = /*#__PURE__*/function (_React$Component) {
33
33
  }
34
34
  });
35
35
  };
36
- _this.tableUtils = props.tableUtils;
37
36
  _this.state = {
38
37
  contextStyle: {}
39
38
  };
39
+ _this.tableUtils = props.tableUtils;
40
40
  return _this;
41
41
  }
42
42
  _createClass(ContextMenu, [{
@@ -6,7 +6,7 @@ import React, { Fragment } from 'react';
6
6
  import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
7
7
  import { withTranslation } from 'react-i18next';
8
8
  import { Editor } from 'slate';
9
- import EditorBuilder from '../../containers/editor-builder';
9
+ import EditorContext from '../../containers/editor-context';
10
10
  var AddFormulaDialog = /*#__PURE__*/function (_React$PureComponent) {
11
11
  _inherits(AddFormulaDialog, _React$PureComponent);
12
12
  var _super = _createSuper(AddFormulaDialog);
@@ -15,7 +15,7 @@ var AddFormulaDialog = /*#__PURE__*/function (_React$PureComponent) {
15
15
  _classCallCheck(this, AddFormulaDialog);
16
16
  _this = _super.call(this, props);
17
17
  _this.setInitialValue = function () {
18
- var editor = EditorBuilder.getEditor();
18
+ var editor = EditorContext.getEditor();
19
19
  var nodes = Editor.match(editor, editor.selection, {
20
20
  type: 'formula'
21
21
  });
@@ -47,35 +47,35 @@ var AddFormulaDialog = /*#__PURE__*/function (_React$PureComponent) {
47
47
  at: _this.formulaNode[1]
48
48
  });
49
49
  } else {
50
- _this.editorUtils.onAddFormula({
50
+ _this.editorUtils.addFormula({
51
51
  formula: formula,
52
52
  at: _this.editorSelection
53
53
  });
54
54
  }
55
55
  _this.props.toggleFormulaDialog();
56
56
  };
57
- _this.editorUtils = EditorBuilder.getEditorUtils();
58
57
  _this.state = {
59
58
  formula: ''
60
59
  };
61
60
  _this.formulaNode = null;
62
61
  _this.editorSelection = null;
62
+ _this.editorUtils = EditorContext.getEditorUtils();
63
63
  return _this;
64
64
  }
65
65
  _createClass(AddFormulaDialog, [{
66
+ key: "componentWillMount",
67
+ value: function componentWillMount() {
68
+ this.setInitialValue();
69
+ }
70
+ }, {
66
71
  key: "componentDidMount",
67
72
  value: function componentDidMount() {
68
- var editor = EditorBuilder.getEditor();
73
+ var editor = EditorContext.getEditor();
69
74
  this.editorSelection = editor.selection;
70
75
  if (this.formulaNode) {
71
76
  this.renderFormula(this.state.formula);
72
77
  }
73
78
  }
74
- }, {
75
- key: "componentWillMount",
76
- value: function componentWillMount() {
77
- this.setInitialValue();
78
- }
79
79
  }, {
80
80
  key: "render",
81
81
  value: function render() {
@@ -83,7 +83,8 @@ var AddFormulaDialog = /*#__PURE__*/function (_React$PureComponent) {
83
83
  return /*#__PURE__*/React.createElement(Modal, {
84
84
  isOpen: true,
85
85
  toggle: this.props.toggleFormulaDialog,
86
- className: this.props.className
86
+ className: this.props.className,
87
+ returnFocusAfterClose: false
87
88
  }, /*#__PURE__*/React.createElement(ModalHeader, {
88
89
  toggle: this.props.toggleFormulaDialog
89
90
  }, this.props.t('insert_formula')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -5,7 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Form, FormGroup, Label, Input } from 'reactstrap';
7
7
  import { withTranslation } from 'react-i18next';
8
- import EditorBuilder from '../../containers/editor-builder';
8
+ import EditorContext from '../../containers/editor-context';
9
9
  var AddImageDialog = /*#__PURE__*/function (_React$PureComponent) {
10
10
  _inherits(AddImageDialog, _React$PureComponent);
11
11
  var _super = _createSuper(AddImageDialog);
@@ -34,7 +34,7 @@ var AddImageDialog = /*#__PURE__*/function (_React$PureComponent) {
34
34
  _createClass(AddImageDialog, [{
35
35
  key: "componentDidMount",
36
36
  value: function componentDidMount() {
37
- var editor = EditorBuilder.getEditor();
37
+ var editor = EditorContext.getEditor();
38
38
  this.editorSelection = editor.selection;
39
39
  }
40
40
  }, {
@@ -5,7 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React, { Fragment } from 'react';
6
6
  import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
7
7
  import { withTranslation } from 'react-i18next';
8
- import EditorBuilder from '../../containers/editor-builder';
8
+ import EditorContext from '../../containers/editor-context';
9
9
  var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
10
10
  _inherits(AddLinkDialog, _React$PureComponent);
11
11
  var _super = _createSuper(AddLinkDialog);
@@ -61,7 +61,7 @@ var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
61
61
  _this.handleSubmit(e);
62
62
  }
63
63
  };
64
- _this.editorUtils = EditorBuilder.getEditorUtils();
64
+ _this.editorUtils = EditorContext.getEditorUtils();
65
65
  _this.isLinkActive = _this.editorUtils.isLinkActive();
66
66
  _this.editorSelection = null;
67
67
  _this.state = {
@@ -71,16 +71,16 @@ var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
71
71
  return _this;
72
72
  }
73
73
  _createClass(AddLinkDialog, [{
74
- key: "componentDidMount",
75
- value: function componentDidMount() {
76
- var editor = EditorBuilder.getEditor();
77
- this.editorSelection = editor.selection;
78
- }
79
- }, {
80
74
  key: "componentWillMount",
81
75
  value: function componentWillMount() {
82
76
  this.setInitialValue();
83
77
  }
78
+ }, {
79
+ key: "componentDidMount",
80
+ value: function componentDidMount() {
81
+ var editor = EditorContext.getEditor();
82
+ this.editorSelection = editor.selection;
83
+ }
84
84
  }, {
85
85
  key: "render",
86
86
  value: function render() {
@@ -89,7 +89,8 @@ var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
89
89
  autoFocus: false,
90
90
  toggle: this.props.toggleLinkDialog,
91
91
  className: this.props.className,
92
- zIndex: 1071
92
+ zIndex: 1071,
93
+ returnFocusAfterClose: false
93
94
  }, /*#__PURE__*/React.createElement(ModalHeader, {
94
95
  toggle: this.props.toggleLinkDialog
95
96
  }, this.props.t('insert_link')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import { withTranslation } from 'react-i18next';
7
- import EditorBuilder from '../../containers/editor-builder';
7
+ import EditorContext from '../../containers/editor-context';
8
8
  import OutlineItem from './outline-item';
9
9
  import '../../assets/css/outline.css';
10
10
  var OutlineView = /*#__PURE__*/function (_React$PureComponent) {
@@ -20,7 +20,7 @@ var OutlineView = /*#__PURE__*/function (_React$PureComponent) {
20
20
  _this.props.scrollToNode(node);
21
21
  return;
22
22
  }
23
- var editorRef = EditorBuilder.getEditorRef();
23
+ var editorRef = EditorContext.getEditorRef();
24
24
  editorRef.scrollToNode(node);
25
25
  };
26
26
  _this.getHeaderList = function (document) {
@@ -5,7 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Tooltip, Label, Input } from 'reactstrap';
7
7
  import { withTranslation } from 'react-i18next';
8
- import EditorBuilder from '../../containers/editor-builder';
8
+ import EditorContext from '../../containers/editor-context';
9
9
  var InsertImage = /*#__PURE__*/function (_React$Component) {
10
10
  _inherits(InsertImage, _React$Component);
11
11
  var _super = _createSuper(InsertImage);
@@ -37,7 +37,7 @@ var InsertImage = /*#__PURE__*/function (_React$Component) {
37
37
  });
38
38
  };
39
39
  _this.uploadLocalImage = function (event) {
40
- var editor = EditorBuilder.getEditor();
40
+ var editor = EditorContext.getEditor();
41
41
  if (editor.editorApi.uploadLocalImage) {
42
42
  editor.editorApi.uploadLocalImage(event.target.files[0]).then(function (res) {
43
43
  _this.props.onInsertImage({
@@ -13,7 +13,6 @@ var InsertTable = /*#__PURE__*/function (_Component) {
13
13
  _classCallCheck(this, InsertTable);
14
14
  _this = _super.call(this, props);
15
15
  _this.toggleCard = function (event) {
16
- console.log('aaaa');
17
16
  if (event) {
18
17
  event.stopPropagation();
19
18
  event.nativeEvent.stopImmediatePropagation();
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React, { Fragment } from 'react';
7
7
  import { withTranslation } from 'react-i18next';
8
- import EditorBuilder from '../../containers/editor-builder';
8
+ import EditorContext from '../../containers/editor-context';
9
9
  import ButtonItem from './widgets/button-item';
10
10
  import ButtonGroup from './widgets/button-group';
11
11
  import HeaderList from './header-list';
@@ -24,10 +24,65 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
24
24
  var _this;
25
25
  _classCallCheck(this, Toolbar);
26
26
  _this = _super.call(this, props);
27
- _this.onToggleLinkDialog = function () {
28
- _this.setState({
29
- isShowLinkDialog: !_this.state.isShowLinkDialog
30
- });
27
+ _this.onClickHeader = function (event, type) {
28
+ event.preventDefault();
29
+ _this.editorUtils.clickHeader(type);
30
+ };
31
+ _this.onClickMark = function (type) {
32
+ return function (event) {
33
+ event.preventDefault();
34
+ _this.editorUtils.clickMark(type);
35
+ };
36
+ };
37
+ _this.onClickBlock = function (type) {
38
+ return function (event) {
39
+ event.preventDefault();
40
+ _this.editorUtils.clickBlock(type);
41
+ };
42
+ };
43
+ _this.onClearFormat = function (event) {
44
+ event.preventDefault();
45
+ _this.editorUtils.clearFormat();
46
+ };
47
+ _this.onClickCheckItem = function (event) {
48
+ event.preventDefault();
49
+ _this.editorUtils.clickCheckItem();
50
+ };
51
+ _this.onAddTable = function (event, rowCount, columnCount) {
52
+ event.preventDefault();
53
+ _this.editorUtils.addTable(rowCount, columnCount);
54
+ };
55
+ _this.onInsertImage = function (data) {
56
+ _this.editorUtils.insertImage(data);
57
+ };
58
+ _this.onAddCustomColumn = function (event) {
59
+ event.preventDefault();
60
+ event.nativeEvent.stopImmediatePropagation();
61
+ _this.editorUtils.addCustomColumn();
62
+ };
63
+ _this.onRemoveTable = function (event) {
64
+ event.preventDefault();
65
+ _this.editorUtils.removeTable();
66
+ };
67
+ _this.onInsertColumn = function (event) {
68
+ event.preventDefault();
69
+ _this.editorUtils.insertColumn();
70
+ };
71
+ _this.onRemoveColumn = function (event) {
72
+ event.preventDefault();
73
+ _this.editorUtils.removeColumn();
74
+ };
75
+ _this.onInsertRow = function (event) {
76
+ event.preventDefault();
77
+ _this.editorUtils.insertRow();
78
+ };
79
+ _this.onRemoveRow = function (event) {
80
+ event.preventDefault();
81
+ _this.editorUtils.removeRow();
82
+ };
83
+ _this.onSetAlign = function (event, align) {
84
+ event.preventDefault();
85
+ _this.editorUtils.setAlign(align);
31
86
  };
32
87
  _this.onToggleLink = function (event) {
33
88
  event.preventDefault();
@@ -60,14 +115,13 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
60
115
  isShowImageDialog: false,
61
116
  isShowFormulaDialog: false
62
117
  };
63
- _this.editorUtils = EditorBuilder.getEditorUtils();
118
+ _this.editorUtils = EditorContext.getEditorUtils();
64
119
  window.abcdef_editorToolbar = _assertThisInitialized(_this);
65
120
  return _this;
66
121
  }
67
122
  _createClass(Toolbar, [{
68
123
  key: "render",
69
124
  value: function render() {
70
- var _this2 = this;
71
125
  var _this$props = this.props,
72
126
  hasSidePanel = _this$props.hasSidePanel,
73
127
  isShowSidePanel = _this$props.isShowSidePanel,
@@ -102,7 +156,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
102
156
  }, /*#__PURE__*/React.createElement(HeaderList, {
103
157
  disabled: isFormulaActive || isCodeActive || isColumnActive || isTableActive,
104
158
  headerType: toolbarStatus.headerType,
105
- onClickHeader: this.editorUtils.onClickHeader
159
+ onClickHeader: this.onClickHeader
106
160
  })), /*#__PURE__*/React.createElement(ButtonGroup, {
107
161
  className: 'editor-btn-group'
108
162
  }, /*#__PURE__*/React.createElement(ButtonItem, {
@@ -112,9 +166,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
112
166
  id: 'ITALICButton',
113
167
  icon: 'iconfont icon-italic',
114
168
  isActive: isItalicActive,
115
- onMouseDown: function onMouseDown(event) {
116
- return _this2.editorUtils.onClickMark(event, 'ITALIC');
117
- }
169
+ onMouseDown: this.onClickMark('ITALIC')
118
170
  }), /*#__PURE__*/React.createElement(ButtonItem, {
119
171
  disabled: isFormulaActive || isCodeActive || isColumnActive,
120
172
  isRichEditor: true,
@@ -122,9 +174,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
122
174
  id: 'BOLDButton',
123
175
  icon: 'iconfont icon-bold',
124
176
  isActive: isBoldActive,
125
- onMouseDown: function onMouseDown(event) {
126
- return _this2.editorUtils.onClickMark(event, 'BOLD');
127
- }
177
+ onMouseDown: this.onClickMark('BOLD')
128
178
  }), /*#__PURE__*/React.createElement(ButtonItem, {
129
179
  disabled: isFormulaActive || isCodeActive || isColumnActive,
130
180
  isRichEditor: true,
@@ -132,9 +182,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
132
182
  id: 'CODEButton',
133
183
  icon: 'iconfont icon-code',
134
184
  isActive: isInlineCodeActive,
135
- onMouseDown: function onMouseDown(event) {
136
- return _this2.editorUtils.onClickMark(event, 'CODE');
137
- }
185
+ onMouseDown: this.onClickMark('CODE')
138
186
  }), /*#__PURE__*/React.createElement(ButtonItem, {
139
187
  disabled: isFormulaActive || isCodeActive || isColumnActive,
140
188
  isRichEditor: true,
@@ -152,9 +200,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
152
200
  id: 'block-quoteButton',
153
201
  icon: 'iconfont icon-quote-left',
154
202
  isActive: isBlockquoteActive,
155
- onMouseDown: function onMouseDown(event) {
156
- return _this2.editorUtils.onClickBlock(event, 'blockquote');
157
- }
203
+ onMouseDown: this.onClickBlock('blockquote')
158
204
  }), /*#__PURE__*/React.createElement(ButtonItem, {
159
205
  disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
160
206
  isRichEditor: true,
@@ -162,9 +208,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
162
208
  id: 'ordered_listButton',
163
209
  icon: 'iconfont icon-list-ol',
164
210
  isActive: isOrderedListActive,
165
- onMouseDown: function onMouseDown(event) {
166
- return _this2.editorUtils.onClickBlock(event, 'ordered_list');
167
- }
211
+ onMouseDown: this.onClickBlock('ordered_list')
168
212
  }), /*#__PURE__*/React.createElement(ButtonItem, {
169
213
  disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
170
214
  isRichEditor: true,
@@ -172,9 +216,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
172
216
  id: 'unordered_listButton',
173
217
  icon: 'iconfont icon-list-ul',
174
218
  isActive: isUnorderedListActive,
175
- onMouseDown: function onMouseDown(event) {
176
- return _this2.editorUtils.onClickBlock(event, 'unordered_list');
177
- }
219
+ onMouseDown: this.onClickBlock('unordered_list')
178
220
  }), !canInsertColumn && /*#__PURE__*/React.createElement(ButtonItem, {
179
221
  disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
180
222
  isRichEditor: true,
@@ -182,7 +224,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
182
224
  id: 'checkListItemButton',
183
225
  icon: 'iconfont icon-check-square',
184
226
  isActive: isCheckListActive,
185
- onMouseDown: this.editorUtils.onToggleCheckItem
227
+ onMouseDown: this.onClickCheckItem
186
228
  })), /*#__PURE__*/React.createElement(ButtonGroup, {
187
229
  className: 'editor-btn-group'
188
230
  }, /*#__PURE__*/React.createElement(ButtonItem, {
@@ -191,17 +233,15 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
191
233
  text: t('code_block'),
192
234
  id: 'codeButton',
193
235
  icon: 'iconfont icon-code-block',
194
- onMouseDown: function onMouseDown(event) {
195
- return _this2.editorUtils.onClickBlock(event, 'code_block');
196
- },
197
- isActive: isCodeActive
236
+ isActive: isCodeActive,
237
+ onMouseDown: this.onClickBlock('code_block')
198
238
  }), /*#__PURE__*/React.createElement(InsertTable, {
199
239
  disabled: isFormulaActive || isCodeActive || isTableActive || isColumnActive,
200
240
  isRichEditor: true,
201
241
  text: t('insert_table'),
202
242
  id: 'tableButton',
203
243
  icon: 'iconfont icon-table',
204
- onAddTable: this.editorUtils.onAddTable
244
+ onAddTable: this.onAddTable
205
245
  }), window.canInsertFormula && /*#__PURE__*/React.createElement(ButtonItem, {
206
246
  disabled: isFormulaActive || isCodeActive || isTableActive || isColumnActive || isHeadActive || isListActive,
207
247
  isRichEditor: true,
@@ -214,8 +254,8 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
214
254
  text: 'insert_image',
215
255
  id: 'insertImageButton',
216
256
  insertRepoFile: this.props.insertRepoFile,
217
- onInsertImage: this.editorUtils.insertImage,
218
257
  toolbarStatus: this.props.toolbarStatus,
258
+ onInsertImage: this.onInsertImage,
219
259
  onToggleImageDialog: this.onToggleImageDialog
220
260
  }), canInsertColumn && /*#__PURE__*/React.createElement(ButtonItem, {
221
261
  disabled: isFormulaActive || isTableActive || isHeadActive,
@@ -223,18 +263,16 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
223
263
  text: t('Insert_column'),
224
264
  id: 'insertColumn',
225
265
  className: "svg-button",
226
- onMouseDown: function onMouseDown(event) {
227
- return _this2.editorUtils.onToggleAddColumn(event);
228
- },
266
+ onMouseDown: this.onAddCustomColumn,
229
267
  isActive: isCodeActive,
230
268
  image: ColumnIcon
231
269
  })), isTableActive && /*#__PURE__*/React.createElement(TableGroup, {
232
- onRemoveTable: this.editorUtils.onRemoveTable,
233
- onInsertColumn: this.editorUtils.onInsertColumn,
234
- onRemoveColumn: this.editorUtils.onRemoveColumn,
235
- onInsertRow: this.editorUtils.onInsertRow,
236
- onRemoveRow: this.editorUtils.onRemoveRow,
237
- onSetAlign: this.editorUtils.onSetAlign
270
+ onRemoveTable: this.onRemoveTable,
271
+ onInsertColumn: this.onInsertColumn,
272
+ onRemoveColumn: this.onRemoveColumn,
273
+ onInsertRow: this.onInsertRow,
274
+ onRemoveRow: this.onRemoveRow,
275
+ onSetAlign: this.onSetAlign
238
276
  }), /*#__PURE__*/React.createElement(ButtonGroup, {
239
277
  className: 'editor-btn-group'
240
278
  }, /*#__PURE__*/React.createElement(ButtonItem, {
@@ -243,7 +281,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
243
281
  text: t('Clear_format'),
244
282
  id: 'clearButton',
245
283
  icon: 'iconfont icon-clear-format',
246
- onMouseDown: this.editorUtils.clearFormat
284
+ onMouseDown: this.onClearFormat
247
285
  }))), hasSidePanel && /*#__PURE__*/React.createElement("div", {
248
286
  className: "button-container"
249
287
  }, !this.props.isShowSidePanel && /*#__PURE__*/React.createElement(ButtonGroup, {
@@ -269,7 +307,7 @@ var Toolbar = /*#__PURE__*/function (_React$Component) {
269
307
  }), isShowFormulaDialog && /*#__PURE__*/React.createElement(AddFormulaDialog, {
270
308
  toggleFormulaDialog: this.onToggleFormulaDialog
271
309
  }), isShowImageDialog && /*#__PURE__*/React.createElement(AddImageDialog, {
272
- insertImage: this.editorUtils.insertImage,
310
+ insertImage: this.onInsertImage,
273
311
  onToggleImageDialog: this.onToggleImageDialog
274
312
  }));
275
313
  }
@@ -14,7 +14,7 @@ import { htmlDeserializer } from '../../utils/deserialize-html';
14
14
  import generateLinkElement from '../element-model/link';
15
15
  import generateImageElement from '../element-model/image';
16
16
  import { SfEditor } from '../custom/custom';
17
- import EditorBuilder from '../editor-builder';
17
+ import EditorContext from '../editor-context';
18
18
  var withBlock = function withBlock(editor) {
19
19
  var exec = editor.exec;
20
20
  var listUtils = new ListUtils(editor);
@@ -53,8 +53,8 @@ var withBlock = function withBlock(editor) {
53
53
  Editor.insertNodes(editor, img);
54
54
  return;
55
55
  }
56
- var _EditorBuilder$getEdi = EditorBuilder.getEditor(),
57
- editorApi = _EditorBuilder$getEdi.editorApi;
56
+ var _EditorContext$getEdi = EditorContext.getEditor(),
57
+ editorApi = _EditorContext$getEdi.editorApi;
58
58
  if (editorApi.isInternalFileLink(text)) {
59
59
  var index = text.lastIndexOf('/');
60
60
  if (index > 0) {
@@ -0,0 +1,5 @@
1
+ import withBlock from "./block-element-controller";
2
+ import withVoid from "./void-element-controller";
3
+ import withMarkdownShortcut from "./shortcut-controller";
4
+ import withInline from "./inline-element-controller";
5
+ export { withBlock, withInline, withMarkdownShortcut, withVoid };
@@ -3,7 +3,7 @@ import { Editor, Range } from 'slate';
3
3
  import generateLinkElement from '../element-model/link';
4
4
  import generateImageElement from '../element-model/image';
5
5
  import generateColumn from '../element-model/column';
6
- import EditorBuilder from '../editor-builder';
6
+ import EditorContext from '../editor-context';
7
7
  var withInline = function withInline(editor) {
8
8
  var exec = editor.exec,
9
9
  isInline = editor.isInline;
@@ -93,8 +93,8 @@ var withInline = function withInline(editor) {
93
93
  });
94
94
  break;
95
95
  case 'insert_data':
96
- var _EditorBuilder$getEdi = EditorBuilder.getEditor(),
97
- editorApi = _EditorBuilder$getEdi.editorApi;
96
+ var _EditorContext$getEdi = EditorContext.getEditor(),
97
+ editorApi = _EditorContext$getEdi.editorApi;
98
98
  if (data.types.includes('Files') && data.files[0].type.includes('image') && editorApi.uploadLocalImage) {
99
99
  editorApi.uploadLocalImage(command.data.files[0]).then(function (res) {
100
100
  var img = generateImageElement({
@@ -1,5 +1,4 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _readOnlyError from "@babel/runtime/helpers/esm/readOnlyError";
3
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
3
  import { SfEditor } from '../custom/custom';
5
4
  import { Node, Text, Path } from 'slate';
@@ -31,7 +30,7 @@ var normalizeNode = function normalizeNode(editor) {
31
30
  SfEditor.mergeNodes(editor, {
32
31
  at: path
33
32
  });
34
- currentNodeIndex - 1, _readOnlyError("currentNodeIndex");
33
+ currentNodeIndex = currentNodeIndex - 1;
35
34
  }
36
35
  var parentNode = Node.parent(editor, path);
37
36
  var nextIndex = currentNodeIndex + 1;
@@ -10,17 +10,14 @@ import withMarkdownShortcut from './controller/shortcut-controller';
10
10
  import normalizeNode from './controller/normalize-controller';
11
11
  import { EditorUtils } from './editor-utils/common-editor-utils';
12
12
  import TableUtils from './editor-utils/block-element-utils/table-utils';
13
- import Plugin from './editor-plugin';
14
- var EditorBuilder = /*#__PURE__*/function () {
15
- function EditorBuilder() {
16
- _classCallCheck(this, EditorBuilder);
13
+ var EditorContext = /*#__PURE__*/function () {
14
+ function EditorContext() {
15
+ _classCallCheck(this, EditorContext);
17
16
  this.editor = null;
18
- this.slateEditor = null;
19
- this.plugin = null;
20
17
  this.tableUtils = null;
21
18
  this.editorUtils = null;
22
19
  }
23
- _createClass(EditorBuilder, null, [{
20
+ _createClass(EditorContext, null, [{
24
21
  key: "getEditor",
25
22
  value: function getEditor(options) {
26
23
  if (this.editor && options) {
@@ -47,19 +44,10 @@ var EditorBuilder = /*#__PURE__*/function () {
47
44
  }
48
45
  return this.editor;
49
46
  }
50
- }, {
51
- key: "getSlateEditor",
52
- value: function getSlateEditor() {
53
- if (this.slateEditor) return this.slateEditor;
54
- this.slateEditor = withInline(withVoid(withReact(createEditor())));
55
- return this.slateEditor;
56
- }
57
47
  }, {
58
48
  key: "resetEditor",
59
49
  value: function resetEditor() {
60
50
  this.editor = null;
61
- this.slateEditor = null;
62
- this.plugin = null;
63
51
  this.editorUtils = null;
64
52
  this.tableUtils = null;
65
53
  }
@@ -91,15 +79,7 @@ var EditorBuilder = /*#__PURE__*/function () {
91
79
  this.tableUtils = new TableUtils(this.editor);
92
80
  return this.tableUtils;
93
81
  }
94
- }, {
95
- key: "getPlugin",
96
- value: function getPlugin() {
97
- if (this.plugin) return this.plugin;
98
- if (!this.editor) this.getEditor();
99
- this.plugin = new Plugin(this.editor);
100
- return this.plugin;
101
- }
102
82
  }]);
103
- return EditorBuilder;
83
+ return EditorContext;
104
84
  }();
105
- export default EditorBuilder;
85
+ export default EditorContext;