@seafile/sdoc-editor 0.1.0 → 0.1.1

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 (144) hide show
  1. package/dist/{new-editors/editor.js → editor.js} +23 -17
  2. package/dist/index.js +2 -36
  3. package/dist/slate-extension/plugins/index.js +3 -2
  4. package/dist/slate-extension/plugins/socket/index.js +6 -0
  5. package/dist/slate-extension/plugins/socket/plugin.js +17 -0
  6. package/dist/slate-extension/socket/socket-client.js +84 -0
  7. package/dist/slate-extension/socket/socket-manager.js +61 -0
  8. package/dist/slate-extension/toolbar/index.js +1 -1
  9. package/package.json +3 -23
  10. package/dist/assets/css/comment-dialog.css +0 -50
  11. package/dist/assets/css/diff-viewer.css +0 -105
  12. package/dist/assets/css/formula.css +0 -19
  13. package/dist/assets/css/history-viewer.css +0 -104
  14. package/dist/assets/css/image.css +0 -134
  15. package/dist/assets/css/issue-card.css +0 -43
  16. package/dist/assets/css/keyboard-shortcuts.css +0 -58
  17. package/dist/assets/css/link.css +0 -7
  18. package/dist/assets/css/markdown-editor.css +0 -12
  19. package/dist/assets/css/markdown-viewer.css +0 -69
  20. package/dist/assets/css/navbar-imgbutton.css +0 -83
  21. package/dist/assets/css/outline.css +0 -29
  22. package/dist/assets/css/table.css +0 -57
  23. package/dist/assets/css/textlink-hovermenu.css +0 -47
  24. package/dist/assets/css/topbar.css +0 -350
  25. package/dist/assets/css/tree-view.css +0 -67
  26. package/dist/assets/css/user-help.css +0 -84
  27. package/dist/assets/editor/plain-editor.css +0 -30
  28. package/dist/assets/editor/seatable-editor.css +0 -77
  29. package/dist/assets/editor/simple-editor.css +0 -77
  30. package/dist/components/click-outside.js +0 -46
  31. package/dist/components/context-menu.js +0 -97
  32. package/dist/components/dialogs/add-formula-dialog.js +0 -116
  33. package/dist/components/dialogs/add-image-dialog.js +0 -69
  34. package/dist/components/dialogs/add-link-dialog.js +0 -133
  35. package/dist/components/dialogs/comment-dialog.js +0 -97
  36. package/dist/components/dialogs/shortcut-dialog.js +0 -131
  37. package/dist/components/error-boundary.js +0 -28
  38. package/dist/components/load-script/index.js +0 -69
  39. package/dist/components/loading.js +0 -25
  40. package/dist/components/markdown-lint.js +0 -72
  41. package/dist/components/menu/index.js +0 -4
  42. package/dist/components/menu/item.js +0 -49
  43. package/dist/components/menu/menu.js +0 -38
  44. package/dist/components/menu/style.css +0 -42
  45. package/dist/components/modal-portal.js +0 -38
  46. package/dist/components/outline/index.js +0 -92
  47. package/dist/components/outline/outline-item.js +0 -58
  48. package/dist/components/select/_option.js +0 -44
  49. package/dist/components/select/field-setting.js +0 -106
  50. package/dist/components/select/index.js +0 -149
  51. package/dist/components/select/style.css +0 -144
  52. package/dist/components/svg-icons/check-mark-icon.js +0 -14
  53. package/dist/components/svg-icons/column-icon.js +0 -17
  54. package/dist/components/svg-icons/text-icon.js +0 -34
  55. package/dist/components/text-link-hover-menu/index.js +0 -123
  56. package/dist/components/toast/alert.js +0 -138
  57. package/dist/components/toast/index.js +0 -3
  58. package/dist/components/toast/toast.js +0 -159
  59. package/dist/components/toast/toastManager.js +0 -139
  60. package/dist/components/toast/toaster.js +0 -65
  61. package/dist/components/toolbar/header-list.js +0 -114
  62. package/dist/components/toolbar/help-group.js +0 -33
  63. package/dist/components/toolbar/index.js +0 -4
  64. package/dist/components/toolbar/insert-image.js +0 -106
  65. package/dist/components/toolbar/insert-table.js +0 -136
  66. package/dist/components/toolbar/table-group.js +0 -74
  67. package/dist/components/toolbar/toolbar.js +0 -317
  68. package/dist/components/toolbar/widgets/button-group.js +0 -24
  69. package/dist/components/toolbar/widgets/button-item.js +0 -129
  70. package/dist/components/toolbar/widgets/drop-list.js +0 -88
  71. package/dist/components/user-help/index.js +0 -179
  72. package/dist/config-0.js +0 -15
  73. package/dist/config.js +0 -16
  74. package/dist/constants/cell-types.js +0 -29
  75. package/dist/constants/column.js +0 -4
  76. package/dist/containers/code-highlight-package.js +0 -14
  77. package/dist/containers/controller/block-element-controller.js +0 -375
  78. package/dist/containers/controller/index.js +0 -5
  79. package/dist/containers/controller/inline-element-controller.js +0 -134
  80. package/dist/containers/controller/normalize-controller.js +0 -95
  81. package/dist/containers/controller/shortcut-controller.js +0 -385
  82. package/dist/containers/controller/void-element-controller.js +0 -9
  83. package/dist/containers/custom/custom.js +0 -18
  84. package/dist/containers/custom/get-event-transfer.js +0 -33
  85. package/dist/containers/custom/getNodesByTypeAtRange.js +0 -57
  86. package/dist/containers/custom/insertNodes.js +0 -120
  87. package/dist/containers/custom/is-empty-paragraph.js +0 -9
  88. package/dist/containers/custom/set-event-transfer.js +0 -30
  89. package/dist/containers/custom/split-nodes-at-point.js +0 -136
  90. package/dist/containers/custom/unwrap-node-by-type-at-range.js +0 -70
  91. package/dist/containers/editor-context.js +0 -85
  92. package/dist/containers/editor-utils/block-element-utils/blockquote-utils.js +0 -80
  93. package/dist/containers/editor-utils/block-element-utils/code-utils.js +0 -145
  94. package/dist/containers/editor-utils/block-element-utils/formula-utils.js +0 -51
  95. package/dist/containers/editor-utils/block-element-utils/index.js +0 -31
  96. package/dist/containers/editor-utils/block-element-utils/list-utils.js +0 -395
  97. package/dist/containers/editor-utils/block-element-utils/table-utils.js +0 -412
  98. package/dist/containers/editor-utils/clear-format-utils.js +0 -84
  99. package/dist/containers/editor-utils/common-editor-utils.js +0 -492
  100. package/dist/containers/editor-utils/inline-element-utils/index.js +0 -95
  101. package/dist/containers/editor-utils/mark-utils.js +0 -20
  102. package/dist/containers/editor-utils/range-utils.js +0 -7
  103. package/dist/containers/editor-utils/selection-utils.js +0 -30
  104. package/dist/containers/editor-utils/text-utils.js +0 -117
  105. package/dist/containers/editor-widgets/check-list-item.js +0 -53
  106. package/dist/containers/editor-widgets/code-block.js +0 -128
  107. package/dist/containers/editor-widgets/column.js +0 -100
  108. package/dist/containers/editor-widgets/formula.js +0 -67
  109. package/dist/containers/editor-widgets/image.js +0 -237
  110. package/dist/containers/editor-widgets/link.js +0 -9
  111. package/dist/containers/editor-widgets/table.js +0 -144
  112. package/dist/containers/element-model/blockquote.js +0 -13
  113. package/dist/containers/element-model/column.js +0 -19
  114. package/dist/containers/element-model/image.js +0 -16
  115. package/dist/containers/element-model/link.js +0 -16
  116. package/dist/containers/element-model/table.js +0 -57
  117. package/dist/containers/element-model/text.js +0 -10
  118. package/dist/containers/render-utils/common-utils.js +0 -80
  119. package/dist/containers/render-utils/editor-utils.js +0 -133
  120. package/dist/containers/render-utils/viewer-utils.js +0 -198
  121. package/dist/containers/viewer-widgets/viewer-formula/index.js +0 -54
  122. package/dist/containers/viewer-widgets/viewer-image/index.js +0 -70
  123. package/dist/containers/viewer-widgets/viewer-image/viewer-image.css +0 -3
  124. package/dist/editors/index.js +0 -78
  125. package/dist/editors/markdown-editor.js +0 -280
  126. package/dist/editors/plain-markdown-editor.js +0 -285
  127. package/dist/editors/seatable-editor.js +0 -210
  128. package/dist/editors/simple-editor.js +0 -200
  129. package/dist/utils/deserialize-html.js +0 -260
  130. package/dist/utils/diff/compare-strings.js +0 -35
  131. package/dist/utils/diff/diff.js +0 -769
  132. package/dist/utils/diff/index.js +0 -2
  133. package/dist/utils/seafile-markdown2html.js +0 -52
  134. package/dist/utils/slate2markdown/deserialize.js +0 -588
  135. package/dist/utils/slate2markdown/index.js +0 -3
  136. package/dist/utils/slate2markdown/serialize.js +0 -366
  137. package/dist/utils/utils.js +0 -69
  138. package/dist/viewer/diff-viewer.js +0 -85
  139. package/dist/viewer/index.js +0 -4
  140. package/dist/viewer/markdown-viewer.js +0 -121
  141. package/dist/viewer/seatable-viewer.js +0 -63
  142. package/dist/viewer/slate-viewer.js +0 -71
  143. /package/dist/assets/css/{new-editor-toolbar.css → sdoc-editor-toolbar.css} +0 -0
  144. /package/dist/assets/css/{new-editor.css → sdoc-editor.css} +0 -0
@@ -1,395 +0,0 @@
1
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
- import { Node, Range, Path, Editor } from 'slate';
7
- import { SfEditor } from '../../custom/custom';
8
- import getEventTransfer from '../../custom/get-event-transfer';
9
- import { htmlDeserializer } from '../../../utils/deserialize-html';
10
- import { normailizeSelection } from '../selection-utils';
11
- var LitsUtils = /*#__PURE__*/_createClass(function LitsUtils(editor) {
12
- var _this = this;
13
- _classCallCheck(this, LitsUtils);
14
- this.unwrapList = function () {
15
- // defer normalization util the unwrap operartions completed
16
- SfEditor.withoutNormalizing(_this.editor, function () {
17
- normailizeSelection(_this.editor);
18
- // selected list item
19
- var selectedListItem = _this.getCurrentListItem();
20
- // first selected item path and node
21
- var firstSelectedItem = selectedListItem[0];
22
- var firstSelectedItemPath = firstSelectedItem[1];
23
- // get selected list and the path of the list
24
- var selectedListPath = firstSelectedItemPath.slice(0, firstSelectedItemPath.length - 1);
25
- var selectedList = Node.get(_this.editor, selectedListPath);
26
- // get the node and path of parent of selected list
27
- var listParent = Node.parent(_this.editor, selectedListPath);
28
- var listParentPath = selectedListPath.slice(0, selectedListPath.length - 1);
29
-
30
- // unwrap list of selected list item
31
- // if the type of parent of selected list is a list and it should be a list item
32
- if (listParent.type && listParent.type.includes('list')) {
33
- // get the path of parent of listParent
34
- var ancesstorPath = listParentPath.slice(0, listParentPath.length - 1);
35
- var lastSelectedListItem = selectedListItem.slice(-1)[0];
36
- var lastSelectedListItemPath = lastSelectedListItem[1];
37
- var lastSelectedListItemIndex = lastSelectedListItemPath.slice(-1)[0];
38
- var unSelectedListItem = selectedList.children.slice(selectedListItem.slice(-1)[0][1].slice(-1)[0] + 1);
39
-
40
- // insert a new list to the last selected list item
41
- if (!(lastSelectedListItemIndex === selectedList.children.length - 1)) {
42
- SfEditor.insertNodes(_this.editor, {
43
- type: selectedList.type,
44
- children: []
45
- }, {
46
- at: [].concat(_toConsumableArray(lastSelectedListItemPath), [lastSelectedListItem[0].children.length])
47
- });
48
- }
49
-
50
- // move the unselected list item to the new created list
51
- unSelectedListItem.forEach(function (item, index) {
52
- SfEditor.moveNodes(_this.editor, {
53
- at: [].concat(_toConsumableArray(lastSelectedListItemPath.slice(0, -1)), [lastSelectedListItemIndex + 1]),
54
- to: [].concat(_toConsumableArray(lastSelectedListItemPath), [lastSelectedListItem[0].children.length, index])
55
- });
56
- });
57
- var currentItemPath = firstSelectedItemPath;
58
- var startIndexOfItemInNewList = listParentPath[listParentPath.length - 1] + 1;
59
-
60
- // move item to outer list by path
61
- selectedListItem.forEach(function (item, index) {
62
- var itemTargetPath = [].concat(_toConsumableArray(ancesstorPath), [index + startIndexOfItemInNewList]);
63
- SfEditor.moveNodes(_this.editor, {
64
- at: currentItemPath,
65
- to: itemTargetPath
66
- });
67
- });
68
- var currentList = Node.get(_this.editor, selectedListPath);
69
- // delete empty list
70
- if (!currentList.children[0] || currentList.children[0].type !== 'list_item') {
71
- SfEditor.removeNodes(_this.editor, {
72
- at: selectedListPath
73
- });
74
- }
75
- } else {
76
- // unwrap list item if the selected list is the outest of the root
77
- var firstListItemIndex = firstSelectedItem[1].slice(-1)[0];
78
- var restCount = 0;
79
- selectedListItem.forEach(function (item) {
80
- SfEditor.unwrapNodesByTypeAtRange(_this.editor, {
81
- match: {
82
- type: 'list_item'
83
- },
84
- mode: 'highest',
85
- at: [].concat(_toConsumableArray(selectedListPath), [firstListItemIndex + restCount])
86
- });
87
- restCount += item[0].children.length;
88
- });
89
- var startItemRange = Editor.range(_this.editor, [].concat(_toConsumableArray(selectedListPath), [firstListItemIndex]));
90
- var endItemRange = Editor.range(_this.editor, [].concat(_toConsumableArray(selectedListPath), [firstListItemIndex + restCount - 1]));
91
- SfEditor.unwrapNodesByTypeAtRange(_this.editor, {
92
- match: [{
93
- type: selectedList.type
94
- }],
95
- split: true,
96
- mode: 'highest',
97
- at: {
98
- anchor: startItemRange.anchor,
99
- focus: endItemRange.focus
100
- }
101
- });
102
- }
103
- });
104
- };
105
- this.wrapList = function (type) {
106
- normailizeSelection(_this.editor);
107
- var selection = _this.editor.selection;
108
- var focusPath = selection.focus.path;
109
- var anchorPath = selection.anchor.path;
110
- if (Path.equals(focusPath, anchorPath)) {
111
- var _SfEditor$match = SfEditor.match(_this.editor, _this.editor.selection, 'block'),
112
- _SfEditor$match2 = _slicedToArray(_SfEditor$match, 2),
113
- block = _SfEditor$match2[0],
114
- path = _SfEditor$match2[1];
115
- Editor.withoutNormalizing(_this.editor, function (editor) {
116
- SfEditor.wrapNodes(_this.editor, {
117
- type: 'list_item',
118
- children: [block],
119
- data: {}
120
- }, {
121
- at: path
122
- });
123
- SfEditor.wrapNodes(_this.editor, {
124
- type: type,
125
- children: []
126
- }, {
127
- split: false,
128
- at: path
129
- });
130
- });
131
- return;
132
- }
133
- var commonPath = Path.common(focusPath, anchorPath);
134
- var commonAncestor = Node.get(_this.editor, commonPath);
135
- var startIndex = anchorPath[commonPath.length];
136
- var endIndex = focusPath[commonPath.length];
137
- // get hightest selected commonAncestor block items
138
- var selectedBlock = commonAncestor.children.slice(startIndex, endIndex + 1);
139
- Editor.withoutNormalizing(_this.editor, function (editor) {
140
- selectedBlock.forEach(function (blockItem, index) {
141
- // wrap block into list
142
- if (!blockItem.type.includes('list')) {
143
- SfEditor.wrapNodes(_this.editor, {
144
- type: 'list_item',
145
- children: [blockItem],
146
- data: {}
147
- }, {
148
- at: [].concat(_toConsumableArray(commonPath), [startIndex + index])
149
- });
150
- SfEditor.wrapNodes(_this.editor, {
151
- type: type,
152
- children: []
153
- }, {
154
- split: false,
155
- at: [].concat(_toConsumableArray(commonPath), [startIndex + index])
156
- });
157
- }
158
- });
159
- });
160
- };
161
- // unwrap list wrap list
162
- this.getCurrentListItem = function () {
163
- var selection = _this.editor.selection;
164
- if (!selection) {
165
- return [];
166
- }
167
- if (Range.isCollapsed(selection)) {
168
- // get the nearest ancesstor of block, judge if the ancesstor is list item to compat the possibility that
169
- // a code block or blockquote in a list item
170
- var block = SfEditor.match(_this.editor, _this.editor.selection, 'block');
171
- var blockPath = block[1];
172
- var blockParent = Node.parent(_this.editor, blockPath);
173
- if (blockParent.type && blockParent.type.indexOf('list') < 0) {
174
- return [];
175
- }
176
- var listItemNodes = SfEditor.nodes(_this.editor, {
177
- match: {
178
- type: 'list_item'
179
- }
180
- });
181
- var listItemNode;
182
- var _iterator = _createForOfIteratorHelper(listItemNodes),
183
- _step;
184
- try {
185
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
186
- var item = _step.value;
187
- listItemNode = item;
188
- }
189
- } catch (err) {
190
- _iterator.e(err);
191
- } finally {
192
- _iterator.f();
193
- }
194
- if (listItemNode) {
195
- return [listItemNode];
196
- }
197
- return [];
198
- }
199
- var focusPath = selection.focus.path;
200
- var anchorPath = selection.anchor.path;
201
- var _SfEditor$nodes = SfEditor.nodes(_this.editor, {
202
- match: 'block',
203
- at: anchorPath
204
- }),
205
- _SfEditor$nodes2 = _slicedToArray(_SfEditor$nodes, 1),
206
- startItem = _SfEditor$nodes2[0];
207
- var _SfEditor$nodes3 = SfEditor.nodes(_this.editor, {
208
- match: 'block',
209
- at: focusPath
210
- }),
211
- _SfEditor$nodes4 = _slicedToArray(_SfEditor$nodes3, 1),
212
- endItem = _SfEditor$nodes4[0];
213
- var _startItem = _slicedToArray(startItem, 2),
214
- startPath = _startItem[1];
215
- var _endItem = _slicedToArray(endItem, 2),
216
- endPath = _endItem[1];
217
- if (Path.equals(startPath, endPath)) {
218
- var _blockParent = Node.parent(_this.editor, startPath);
219
- if (!_blockParent.type || _blockParent.type.indexOf('list') < 0) {
220
- return [];
221
- }
222
- return [[_blockParent, startPath.slice(0, -1)]];
223
- }
224
- var commonPath = Path.common(focusPath, anchorPath);
225
- var commonAncestor = Node.get(_this.editor, commonPath);
226
- var nodeType = commonAncestor.type;
227
- if (nodeType === 'ordered_list' || nodeType === 'unordered_list') {
228
- var startIndex = anchorPath.slice(commonPath.length)[0];
229
- var endIndex = focusPath.slice(commonPath.length)[0];
230
- var selectedListItem = [];
231
- for (var index = startIndex; index <= endIndex; index++) {
232
- selectedListItem.push([commonAncestor.children[index], [].concat(_toConsumableArray(commonPath), [index])]);
233
- }
234
- return selectedListItem;
235
- } else if (nodeType === 'list_item') {
236
- return [[commonAncestor, commonPath]];
237
- }
238
- return [];
239
- };
240
- this.increaseListDepth = function () {
241
- var listNodes = SfEditor.nodes(_this.editor, {
242
- match: {
243
- type: 'list_item'
244
- }
245
- });
246
- var node;
247
-
248
- //get the nearest list_item of current selection
249
- var _iterator2 = _createForOfIteratorHelper(listNodes),
250
- _step2;
251
- try {
252
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
253
- var item = _step2.value;
254
- node = item;
255
- }
256
-
257
- // if current list item is the first child of the list return
258
- } catch (err) {
259
- _iterator2.e(err);
260
- } finally {
261
- _iterator2.f();
262
- }
263
- var listItemPath = _toConsumableArray(node[1]);
264
- if (listItemPath[listItemPath.length - 1] === 0) return;
265
- var listNode = Node.parent(_this.editor, listItemPath);
266
- var listItemIndex = listItemPath.pop();
267
- var listNodePath = listItemPath;
268
- var previousListItem = listNode.children[listItemIndex - 1];
269
- var previousListItemPath = [].concat(_toConsumableArray(listNodePath), [listItemIndex - 1]);
270
- var lastIndex = previousListItem.children.length;
271
- var newListPath = [].concat(_toConsumableArray(previousListItemPath), [lastIndex]);
272
- // Deferring normalization list untils after operations completes.
273
- SfEditor.withoutNormalizing(_this.editor, function () {
274
- SfEditor.insertNodes(_this.editor, {
275
- type: listNode.type,
276
- children: []
277
- }, {
278
- at: newListPath,
279
- split: true
280
- });
281
- var newListItemPath = [].concat(_toConsumableArray(newListPath), [0]);
282
- SfEditor.moveNodes(_this.editor, {
283
- at: node[1],
284
- to: newListItemPath
285
- });
286
- });
287
- };
288
- this.isInlist = function () {
289
- var node = _this.getCurrentListItem();
290
- if (node.length > 0) return true;
291
- return false;
292
- };
293
- /**
294
- * When copying a sublist, the list item in the list returned by slate contains only one sublis,
295
- * pasting the list item directly into the list will produce an incorrect list structure,
296
- * the list item that contains only one list need to flatten
297
- * Input: {type: 'list', children: [{type: 'list_item', children: [{type: 'list', children[{type: 'list_item'}, ...]}]}]}
298
- * Output: [{type: 'list_item'},....]
299
- */
300
- this.getNormalizedListItems = function (list) {
301
- var listItems = [];
302
- list.children.forEach(function (listItem) {
303
- var children = listItem.children || [];
304
- var child = children[0];
305
- if (child && child.type.includes('_list') && children.length === 1) {
306
- listItems.push.apply(listItems, _toConsumableArray(_this.getNormalizedListItems(child)));
307
- } else {
308
- listItems.push(listItem);
309
- }
310
- });
311
- return listItems;
312
- };
313
- this.pasteContentInList = function (command) {
314
- var data = command.data;
315
- var _getEventTransfer = getEventTransfer(data),
316
- fragment = _getEventTransfer.fragment,
317
- text = _getEventTransfer.text,
318
- type = _getEventTransfer.type,
319
- html = _getEventTransfer.html;
320
- if (type === 'text' && !fragment) {
321
- var newText = text.replace(/\r\n|\n/g, ' ');
322
- SfEditor.insertText(_this.editor, newText);
323
- return;
324
- }
325
- if (type === 'html') {
326
- fragment = htmlDeserializer(html);
327
- }
328
-
329
- // insert fragment
330
- if (text.length > 0) {
331
- var newtext = text.replace(/\r\n|\n/g, ' ');
332
- var firstBlock = fragment[0];
333
- var firstBlockType = firstBlock.type;
334
- var currentItem = _this.getCurrentListItem();
335
- var currentItemPath = currentItem[0][1];
336
- var currentItemIndex = currentItemPath[currentItemPath.length - 1];
337
- var listPath = currentItemPath.slice(0, currentItemPath.length - 1);
338
- if (firstBlockType === 'ordered_list' || firstBlockType === 'unordered_list') {
339
- var listItems = _this.getNormalizedListItems(firstBlock);
340
- listItems.forEach(function (listItem, index) {
341
- var itemChildren = listItem.children;
342
- if (itemChildren[0].type.includes('list')) {
343
- SfEditor.insertNodes(_this.editor, [itemChildren[0]]);
344
- } else {
345
- SfEditor.insertFragment(_this.editor, [itemChildren[0]]);
346
- }
347
- if (itemChildren.length > 1) {
348
- var currentListItem = Node.get(_this.editor, [].concat(_toConsumableArray(listPath), [currentItemIndex + index]));
349
- SfEditor.insertNodes(_this.editor, itemChildren.slice(1), {
350
- at: [].concat(_toConsumableArray(listPath), [currentItemIndex + index, currentListItem.children.length])
351
- });
352
- }
353
- if (index < listItems.length - 1) {
354
- SfEditor.insertNodes(_this.editor, {
355
- type: 'list_item',
356
- data: {},
357
- children: [{
358
- type: 'paragraph',
359
- children: [{
360
- text: ''
361
- }]
362
- }]
363
- }, {
364
- at: [].concat(_toConsumableArray(listPath), [currentItemIndex + index + 1])
365
- });
366
- SfEditor.select(_this.editor, [].concat(_toConsumableArray(listPath), [currentItemIndex + index + 1]));
367
- }
368
- });
369
- if (fragment.length > 1) {
370
- var outestListItem = SfEditor.match(_this.editor, _this.editor.selection, {
371
- type: 'list_item'
372
- });
373
- var outestListItemPath = outestListItem[1];
374
- var outestListPath = outestListItemPath.slice(0, outestListItemPath.length - 1);
375
- var outestListIndex = outestListPath[outestListPath.length - 1];
376
- var nextBlockPath = [].concat(_toConsumableArray(outestListPath.slice(0, outestListPath.length - 1)), [outestListIndex + 1]);
377
- SfEditor.insertNodes(_this.editor, fragment.slice(1), {
378
- at: nextBlockPath
379
- });
380
- }
381
- } else {
382
- if (fragment.length === 1 && fragment[0].type === 'paragraph') {
383
- SfEditor.insertFragment(_this.editor, fragment);
384
- return;
385
- }
386
- // insert text directly when the first block is not a list
387
- SfEditor.insertText(_this.editor, newtext);
388
- }
389
- } else {
390
- SfEditor.insertFragment(_this.editor, fragment);
391
- }
392
- };
393
- this.editor = editor;
394
- });
395
- export default LitsUtils;