@seafile/sdoc-editor 0.1.0 → 0.1.2

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 (149) hide show
  1. package/dist/{new-editors/editor.js → editor.js} +38 -17
  2. package/dist/index.js +2 -36
  3. package/dist/slate-extension/core/transforms/move-children.js +1 -1
  4. package/dist/slate-extension/plugins/blockquote/helpers.js +3 -3
  5. package/dist/slate-extension/plugins/index.js +3 -2
  6. package/dist/slate-extension/plugins/list/transforms/normalize-list-item.js +2 -2
  7. package/dist/slate-extension/plugins/list/transforms/toggle-list.js +6 -8
  8. package/dist/slate-extension/plugins/socket/index.js +6 -0
  9. package/dist/slate-extension/plugins/socket/plugin.js +23 -0
  10. package/dist/slate-extension/socket/socket-client.js +94 -0
  11. package/dist/slate-extension/socket/socket-manager.js +63 -0
  12. package/dist/slate-extension/toolbar/index.js +1 -1
  13. package/dist/utils/event-bus.js +39 -0
  14. package/package.json +5 -25
  15. package/dist/assets/css/comment-dialog.css +0 -50
  16. package/dist/assets/css/diff-viewer.css +0 -105
  17. package/dist/assets/css/formula.css +0 -19
  18. package/dist/assets/css/history-viewer.css +0 -104
  19. package/dist/assets/css/image.css +0 -134
  20. package/dist/assets/css/issue-card.css +0 -43
  21. package/dist/assets/css/keyboard-shortcuts.css +0 -58
  22. package/dist/assets/css/link.css +0 -7
  23. package/dist/assets/css/markdown-editor.css +0 -12
  24. package/dist/assets/css/markdown-viewer.css +0 -69
  25. package/dist/assets/css/navbar-imgbutton.css +0 -83
  26. package/dist/assets/css/outline.css +0 -29
  27. package/dist/assets/css/table.css +0 -57
  28. package/dist/assets/css/textlink-hovermenu.css +0 -47
  29. package/dist/assets/css/topbar.css +0 -350
  30. package/dist/assets/css/tree-view.css +0 -67
  31. package/dist/assets/css/user-help.css +0 -84
  32. package/dist/assets/editor/plain-editor.css +0 -30
  33. package/dist/assets/editor/seatable-editor.css +0 -77
  34. package/dist/assets/editor/simple-editor.css +0 -77
  35. package/dist/components/click-outside.js +0 -46
  36. package/dist/components/context-menu.js +0 -97
  37. package/dist/components/dialogs/add-formula-dialog.js +0 -116
  38. package/dist/components/dialogs/add-image-dialog.js +0 -69
  39. package/dist/components/dialogs/add-link-dialog.js +0 -133
  40. package/dist/components/dialogs/comment-dialog.js +0 -97
  41. package/dist/components/dialogs/shortcut-dialog.js +0 -131
  42. package/dist/components/error-boundary.js +0 -28
  43. package/dist/components/load-script/index.js +0 -69
  44. package/dist/components/loading.js +0 -25
  45. package/dist/components/markdown-lint.js +0 -72
  46. package/dist/components/menu/index.js +0 -4
  47. package/dist/components/menu/item.js +0 -49
  48. package/dist/components/menu/menu.js +0 -38
  49. package/dist/components/menu/style.css +0 -42
  50. package/dist/components/modal-portal.js +0 -38
  51. package/dist/components/outline/index.js +0 -92
  52. package/dist/components/outline/outline-item.js +0 -58
  53. package/dist/components/select/_option.js +0 -44
  54. package/dist/components/select/field-setting.js +0 -106
  55. package/dist/components/select/index.js +0 -149
  56. package/dist/components/select/style.css +0 -144
  57. package/dist/components/svg-icons/check-mark-icon.js +0 -14
  58. package/dist/components/svg-icons/column-icon.js +0 -17
  59. package/dist/components/svg-icons/text-icon.js +0 -34
  60. package/dist/components/text-link-hover-menu/index.js +0 -123
  61. package/dist/components/toast/alert.js +0 -138
  62. package/dist/components/toast/index.js +0 -3
  63. package/dist/components/toast/toast.js +0 -159
  64. package/dist/components/toast/toastManager.js +0 -139
  65. package/dist/components/toast/toaster.js +0 -65
  66. package/dist/components/toolbar/header-list.js +0 -114
  67. package/dist/components/toolbar/help-group.js +0 -33
  68. package/dist/components/toolbar/index.js +0 -4
  69. package/dist/components/toolbar/insert-image.js +0 -106
  70. package/dist/components/toolbar/insert-table.js +0 -136
  71. package/dist/components/toolbar/table-group.js +0 -74
  72. package/dist/components/toolbar/toolbar.js +0 -317
  73. package/dist/components/toolbar/widgets/button-group.js +0 -24
  74. package/dist/components/toolbar/widgets/button-item.js +0 -129
  75. package/dist/components/toolbar/widgets/drop-list.js +0 -88
  76. package/dist/components/user-help/index.js +0 -179
  77. package/dist/config-0.js +0 -15
  78. package/dist/config.js +0 -16
  79. package/dist/constants/cell-types.js +0 -29
  80. package/dist/constants/column.js +0 -4
  81. package/dist/containers/code-highlight-package.js +0 -14
  82. package/dist/containers/controller/block-element-controller.js +0 -375
  83. package/dist/containers/controller/index.js +0 -5
  84. package/dist/containers/controller/inline-element-controller.js +0 -134
  85. package/dist/containers/controller/normalize-controller.js +0 -95
  86. package/dist/containers/controller/shortcut-controller.js +0 -385
  87. package/dist/containers/controller/void-element-controller.js +0 -9
  88. package/dist/containers/custom/custom.js +0 -18
  89. package/dist/containers/custom/get-event-transfer.js +0 -33
  90. package/dist/containers/custom/getNodesByTypeAtRange.js +0 -57
  91. package/dist/containers/custom/insertNodes.js +0 -120
  92. package/dist/containers/custom/is-empty-paragraph.js +0 -9
  93. package/dist/containers/custom/set-event-transfer.js +0 -30
  94. package/dist/containers/custom/split-nodes-at-point.js +0 -136
  95. package/dist/containers/custom/unwrap-node-by-type-at-range.js +0 -70
  96. package/dist/containers/editor-context.js +0 -85
  97. package/dist/containers/editor-utils/block-element-utils/blockquote-utils.js +0 -80
  98. package/dist/containers/editor-utils/block-element-utils/code-utils.js +0 -145
  99. package/dist/containers/editor-utils/block-element-utils/formula-utils.js +0 -51
  100. package/dist/containers/editor-utils/block-element-utils/index.js +0 -31
  101. package/dist/containers/editor-utils/block-element-utils/list-utils.js +0 -395
  102. package/dist/containers/editor-utils/block-element-utils/table-utils.js +0 -412
  103. package/dist/containers/editor-utils/clear-format-utils.js +0 -84
  104. package/dist/containers/editor-utils/common-editor-utils.js +0 -492
  105. package/dist/containers/editor-utils/inline-element-utils/index.js +0 -95
  106. package/dist/containers/editor-utils/mark-utils.js +0 -20
  107. package/dist/containers/editor-utils/range-utils.js +0 -7
  108. package/dist/containers/editor-utils/selection-utils.js +0 -30
  109. package/dist/containers/editor-utils/text-utils.js +0 -117
  110. package/dist/containers/editor-widgets/check-list-item.js +0 -53
  111. package/dist/containers/editor-widgets/code-block.js +0 -128
  112. package/dist/containers/editor-widgets/column.js +0 -100
  113. package/dist/containers/editor-widgets/formula.js +0 -67
  114. package/dist/containers/editor-widgets/image.js +0 -237
  115. package/dist/containers/editor-widgets/link.js +0 -9
  116. package/dist/containers/editor-widgets/table.js +0 -144
  117. package/dist/containers/element-model/blockquote.js +0 -13
  118. package/dist/containers/element-model/column.js +0 -19
  119. package/dist/containers/element-model/image.js +0 -16
  120. package/dist/containers/element-model/link.js +0 -16
  121. package/dist/containers/element-model/table.js +0 -57
  122. package/dist/containers/element-model/text.js +0 -10
  123. package/dist/containers/render-utils/common-utils.js +0 -80
  124. package/dist/containers/render-utils/editor-utils.js +0 -133
  125. package/dist/containers/render-utils/viewer-utils.js +0 -198
  126. package/dist/containers/viewer-widgets/viewer-formula/index.js +0 -54
  127. package/dist/containers/viewer-widgets/viewer-image/index.js +0 -70
  128. package/dist/containers/viewer-widgets/viewer-image/viewer-image.css +0 -3
  129. package/dist/editors/index.js +0 -78
  130. package/dist/editors/markdown-editor.js +0 -280
  131. package/dist/editors/plain-markdown-editor.js +0 -285
  132. package/dist/editors/seatable-editor.js +0 -210
  133. package/dist/editors/simple-editor.js +0 -200
  134. package/dist/utils/deserialize-html.js +0 -260
  135. package/dist/utils/diff/compare-strings.js +0 -35
  136. package/dist/utils/diff/diff.js +0 -769
  137. package/dist/utils/diff/index.js +0 -2
  138. package/dist/utils/seafile-markdown2html.js +0 -52
  139. package/dist/utils/slate2markdown/deserialize.js +0 -588
  140. package/dist/utils/slate2markdown/index.js +0 -3
  141. package/dist/utils/slate2markdown/serialize.js +0 -366
  142. package/dist/utils/utils.js +0 -69
  143. package/dist/viewer/diff-viewer.js +0 -85
  144. package/dist/viewer/index.js +0 -4
  145. package/dist/viewer/markdown-viewer.js +0 -121
  146. package/dist/viewer/seatable-viewer.js +0 -63
  147. package/dist/viewer/slate-viewer.js +0 -71
  148. /package/dist/assets/css/{new-editor-toolbar.css → sdoc-editor-toolbar.css} +0 -0
  149. /package/dist/assets/css/{new-editor.css → sdoc-editor.css} +0 -0
@@ -1,492 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import { Range, Editor, Node, Path } from 'slate';
5
- import isHotKey from 'is-hotkey';
6
- import { SfEditor } from '../custom/custom';
7
- import setEventTransfer from '../custom/set-event-transfer';
8
- import MarkUtils from './mark-utils';
9
- import BlockElementUtils from './block-element-utils';
10
- import InlineElementUtils from './inline-element-utils';
11
- import ListUtils from '../editor-utils/block-element-utils/list-utils';
12
- import TableUtils from '../editor-utils/block-element-utils/table-utils';
13
- import CodeUtils from '../editor-utils/block-element-utils/code-utils';
14
- import FormulaUtils from '../editor-utils/block-element-utils/formula-utils';
15
- import BlockquoteUtils from '../editor-utils/block-element-utils/blockquote-utils';
16
- var EditorUtils = /*#__PURE__*/function () {
17
- function EditorUtils(_editor) {
18
- var _this = this;
19
- _classCallCheck(this, EditorUtils);
20
- this.onKeyDown = function (event) {
21
- if (event.nativeEvent.keyCode === 13) {
22
- event.preventDefault();
23
- if (isHotKey('shift+enter', event)) {
24
- if (_this.listUtils.isInlist()) {
25
- _this.editor.exec({
26
- type: 'split_list_item'
27
- });
28
- }
29
- } else if (isHotKey('mod+enter', event)) {
30
- if (_this.codeUtils.isInCodeBlock()) {
31
- _this.editor.exec({
32
- type: 'exit_code_block'
33
- });
34
- }
35
- if (_this.tableUtils.isInTable()) {
36
- _this.editor.exec({
37
- type: 'exit_table'
38
- });
39
- }
40
- } else {
41
- _this.editor.exec({
42
- type: 'insert_break'
43
- });
44
- }
45
- }
46
- if (isHotKey('shift+tab', event)) {
47
- event.preventDefault();
48
- if (_this.listUtils.isInlist()) {
49
- var _Editor$nodes = Editor.nodes(_this.editor, {
50
- match: [{
51
- type: 'unordered_list'
52
- }, {
53
- type: 'ordered_list'
54
- }],
55
- at: _this.editor.selection,
56
- mode: 'highest'
57
- }),
58
- _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
59
- listNode = _Editor$nodes2[0];
60
- if (!listNode) return;
61
- var type = listNode[0].type;
62
- _this.editor.exec({
63
- type: "unwrap_".concat(type)
64
- });
65
- }
66
- if (_this.tableUtils.isInTable()) {
67
- _this.editor.exec({
68
- type: 'focus_previous_table_cell'
69
- });
70
- }
71
- }
72
- if (isHotKey('mod+s', event)) {
73
- event.preventDefault();
74
- _this.editor.onSave && _this.editor.onSave();
75
- }
76
- if (isHotKey('tab', event) && Range.isCollapsed(_this.editor.selection)) {
77
- event.preventDefault();
78
- if (_this.codeUtils.isInCodeBlock()) {
79
- _this.editor.exec({
80
- type: 'increase_code_block_indent'
81
- });
82
- }
83
- if (_this.listUtils.isInlist()) {
84
- _this.editor.exec({
85
- type: 'increase_list_item_depth'
86
- });
87
- }
88
- if (_this.tableUtils.isInTable()) {
89
- _this.editor.exec({
90
- type: 'focus_next_table_cell'
91
- });
92
- }
93
- }
94
- if (isHotKey('mod+b', event)) {
95
- event.preventDefault();
96
- if (!_this.codeUtils.isInCodeBlock()) {
97
- _this.editor.exec({
98
- type: 'format_text',
99
- properties: {
100
- BOLD: true
101
- }
102
- });
103
- }
104
- }
105
- if (isHotKey('mod+i', event)) {
106
- event.preventDefault();
107
- if (!_this.codeUtils.isInCodeBlock()) {
108
- _this.editor.exec({
109
- type: 'format_text',
110
- properties: {
111
- ITALIC: true
112
- }
113
- });
114
- }
115
- }
116
- if (isHotKey('mod+/', event)) {
117
- event.preventDefault();
118
- if (!_this.codeUtils.isInCodeBlock()) {
119
- _this.editor.exec({
120
- type: 'format_text',
121
- properties: {
122
- CODE: true
123
- }
124
- });
125
- }
126
- }
127
- if (isHotKey('mod+4', {
128
- byKey: true
129
- })(event)) {
130
- event.preventDefault();
131
- var toolbarRef = window.abcdef_editorToolbar;
132
- toolbarRef.onToggleFormulaDialog();
133
- return;
134
- }
135
-
136
- // compate chrome: in chrome press backspace would not exec delete_backward command
137
- if (isHotKey('backspace', event)) {
138
- var voidNode = SfEditor.match(_this.editor, _this.editor.selection, 'void');
139
- if (voidNode && (voidNode[0].type === 'image' || voidNode[0].type === 'formula')) {
140
- event.preventDefault();
141
- _this.editor.exec({
142
- type: 'delete_backward',
143
- unit: 'character'
144
- });
145
- return;
146
- }
147
- }
148
- if (isHotKey('mod+a', event)) {
149
- if (_this.codeUtils.isInCodeBlock()) {
150
- var anchorPoint = _this.editor.selection.anchor;
151
- var focusPoint = _this.editor.selection.focus;
152
- var anchorCodeBlock = Editor.match(_this.editor, anchorPoint, {
153
- type: 'code_block'
154
- });
155
- var focusCodeBlock = Editor.match(_this.editor, focusPoint, {
156
- type: 'code_block'
157
- });
158
- if (anchorCodeBlock && focusCodeBlock && Path.equals(focusCodeBlock[1], anchorCodeBlock[1])) {
159
- event.preventDefault();
160
- Editor.select(_this.editor, focusCodeBlock[1]);
161
- return;
162
- }
163
- }
164
- }
165
- };
166
- this.onCut = function (event, editor) {
167
- var image = SfEditor.match(_this.editor, _this.editor.selection, {
168
- type: 'image'
169
- });
170
- if (image) {
171
- // write the image element to clipboard
172
- setEventTransfer(event, 'fragment', [{
173
- type: 'paragraph',
174
- children: [image[0]]
175
- }]);
176
- // remove the image element when cut an image due to slate did not has the action when cut a image
177
- _this.editor.exec({
178
- type: 'delete_backward',
179
- unit: 'character'
180
- });
181
- return;
182
- }
183
- };
184
- this.onCopy = function (event, editor) {
185
- event.stopPropagation();
186
- event.nativeEvent.stopImmediatePropagation();
187
- if (_this.tableUtils.isInTable()) {
188
- event.preventDefault();
189
- var table = _this.tableUtils.getSelectedTableCells();
190
- if (table) {
191
- setEventTransfer(event, 'fragment', table);
192
- return;
193
- }
194
- }
195
- if (editor.selection && !Range.isCollapsed(editor.selection)) {
196
- // get block deepest block node.
197
- // for example: code line in a code block, paragraph in a list
198
- var blockList = Editor.nodes(editor, {
199
- at: editor.selection,
200
- match: 'block'
201
- });
202
- if (blockList) {
203
- var nodeList = Array.from(blockList);
204
- /**
205
- * if only one block element selected, write the selected content as paragraph or text to clipboard
206
- * instead of use slate default behavior which write the outest element to clipboard
207
- */
208
- if (nodeList.length === 1) {
209
- event.preventDefault();
210
- var _nodeList$ = _slicedToArray(nodeList[0], 2),
211
- node = _nodeList$[0],
212
- path = _nodeList$[1];
213
- path = path.slice(1);
214
- if (node && node.type === 'paragraph') {
215
- // get selected paragraph node in selection and write to clipboard
216
- var fragment = Node.fragment(editor, editor.selection);
217
- var selectedNode = Node.get(fragment[0], Array(path.length).fill(0));
218
- setEventTransfer(event, 'fragment', [selectedNode]);
219
- } else {
220
- setEventTransfer(event, 'text', SfEditor.text(editor, editor.selection));
221
- }
222
- return;
223
- }
224
- }
225
- }
226
- };
227
- this.clickMark = function (type) {
228
- _this.markUtils.setMark(type);
229
- };
230
- this.clickHeader = function (type) {
231
- _this.editor.exec({
232
- type: 'set_header',
233
- headerType: type
234
- });
235
- };
236
- this.clickBlock = function (type) {
237
- if (type === 'blockquote') {
238
- if (_this.blockquoteUtils.isInBlockquote()) {
239
- _this.editor.exec({
240
- type: 'unwrap_blockquote'
241
- });
242
- } else {
243
- _this.editor.exec({
244
- type: 'set_blockquote'
245
- });
246
- }
247
- }
248
- if (type === 'code_block') {
249
- if (_this.codeUtils.isInCodeBlock()) {
250
- _this.editor.exec({
251
- type: 'unwrap_code_block'
252
- });
253
- } else {
254
- _this.editor.exec({
255
- type: 'set_code_block'
256
- });
257
- }
258
- }
259
- if (type === 'ordered_list' || type === 'unordered_list') {
260
- if (_this.listUtils.isInlist()) {
261
- var items = _this.listUtils.getCurrentListItem();
262
- var item = items[0];
263
- var currentList = Node.parent(_this.editor, item[1]);
264
- if (currentList.type === type) {
265
- if (typeof item[0].data.checked === 'boolean') {
266
- _this.editor.exec({
267
- type: 'unwrap_check_list_item'
268
- });
269
- return;
270
- }
271
- _this.editor.exec({
272
- type: "unwrap_".concat(currentList.type)
273
- });
274
- } else {
275
- var currentListPath = Path.parent(item[1]);
276
- var listAncesstor = Node.get(_this.editor, Path.parent(currentListPath));
277
- // modify the sublist to different types
278
- if (listAncesstor.type && listAncesstor.type.includes('list')) {
279
- _this.editor.exec({
280
- type: 'modify_sublist_type',
281
- target_list_type: type
282
- });
283
- return;
284
- }
285
- _this.editor.exec({
286
- type: "unwrap_".concat(currentList.type)
287
- });
288
- _this.editor.exec({
289
- type: "set_".concat(type)
290
- });
291
- }
292
- } else {
293
- _this.editor.exec({
294
- type: "set_".concat(type)
295
- });
296
- }
297
- }
298
- };
299
- this.clearFormat = function () {
300
- _this.editor.exec({
301
- type: 'clear_format'
302
- });
303
- };
304
- this.unwrapLink = function () {
305
- _this.inlineElementUtils.unwrapLink();
306
- };
307
- this.isLinkActive = function () {
308
- return _this.inlineElementUtils.isLinkActive();
309
- };
310
- this.getLinkText = function (linkNode) {
311
- return _this.inlineElementUtils.getLinkText(linkNode);
312
- };
313
- this.insertLink = function (elementData) {
314
- return _this.inlineElementUtils.insertLink(elementData);
315
- };
316
- this.setLink = function (elementData) {
317
- return _this.inlineElementUtils.setLink(elementData);
318
- };
319
- this.getSelectedText = function () {
320
- var selection = window.getSelection();
321
- var range = selection.getRangeAt(0);
322
- return range.toString();
323
- };
324
- this.getCurrentLinkNode = function () {
325
- return _this.inlineElementUtils.getCurrentLinkNode();
326
- };
327
- this.clickCheckItem = function () {
328
- if (_this.listUtils.isInlist()) {
329
- var items = _this.listUtils.getCurrentListItem();
330
- var item = items[0];
331
- if (typeof item[0].data.checked === 'boolean') {
332
- _this.editor.exec({
333
- type: 'unwrap_check_list_item'
334
- });
335
- return;
336
- }
337
- }
338
- _this.editor.exec({
339
- type: 'wrap_check_list_item'
340
- });
341
- };
342
- this.addTable = function (rowCount, columnCount) {
343
- _this.editor.exec({
344
- type: 'insert_table',
345
- data: {
346
- rowCount: rowCount,
347
- columnCount: columnCount
348
- }
349
- });
350
- };
351
- this.addFormula = function (data) {
352
- _this.editor.exec({
353
- type: 'insert_formula',
354
- data: data
355
- });
356
- };
357
- this.setFormula = function (data) {
358
- _this.editor.exec({
359
- type: 'set_formula',
360
- data: data
361
- });
362
- };
363
- this.addCustomColumn = function () {
364
- _this.editor.exec({
365
- type: 'insert_seatable_column'
366
- });
367
- };
368
- this.insertImage = function (data) {
369
- _this.inlineElementUtils.insertImage(data);
370
- };
371
- this.removeTable = function () {
372
- _this.editor.exec({
373
- type: 'remove_table'
374
- });
375
- };
376
- this.insertColumn = function () {
377
- _this.editor.exec({
378
- type: 'insert_column'
379
- });
380
- };
381
- this.removeColumn = function () {
382
- _this.editor.exec({
383
- type: 'remove_column'
384
- });
385
- };
386
- this.insertRow = function () {
387
- _this.editor.exec({
388
- type: 'insert_row'
389
- });
390
- };
391
- this.removeRow = function () {
392
- _this.editor.exec({
393
- type: 'remove_row'
394
- });
395
- };
396
- this.setAlign = function (align) {
397
- _this.editor.exec({
398
- type: 'set_table_cell_align',
399
- align: align
400
- });
401
- };
402
- this.adjustImageSize = function (options) {
403
- return _this.inlineElementUtils.adjustImageSize(options);
404
- };
405
- this.editor = _editor;
406
- this.markUtils = new MarkUtils(_editor);
407
- this.blockElementUtils = new BlockElementUtils(_editor);
408
- this.inlineElementUtils = new InlineElementUtils(_editor);
409
- this.listUtils = new ListUtils(_editor);
410
- this.tableUtils = new TableUtils(_editor);
411
- this.codeUtils = new CodeUtils(_editor);
412
- this.blockquoteUtils = new BlockquoteUtils(_editor);
413
- this.formulaUtils = new FormulaUtils(_editor);
414
- this.onSave = _editor.onSave;
415
- }
416
- _createClass(EditorUtils, [{
417
- key: "getToolbarStatus",
418
- value:
419
- // set is Active of each button
420
- function getToolbarStatus() {
421
- var selection = this.editor.selection;
422
- var toolbarStatus = {
423
- headerType: 'paragraph'
424
- };
425
- if (!selection) return toolbarStatus;
426
- var activeHeader = this.blockElementUtils.getActiveHeader([{
427
- type: 'paragraph'
428
- }, {
429
- type: 'header_one'
430
- }, {
431
- type: 'header_two'
432
- }, {
433
- type: 'header_three'
434
- }, {
435
- type: 'header_four'
436
- }, {
437
- type: 'header_five'
438
- }, {
439
- type: 'header_six'
440
- }]);
441
- var isLinkActive = this.isLinkActive();
442
- var isBlockquoteActive = this.blockquoteUtils.isInBlockquote();
443
- var isCodeActive = this.codeUtils.isInCodeBlock();
444
- var isTableActive = this.tableUtils.isInTable();
445
- var block = activeHeader[0];
446
- var activeMarks = this.markUtils.getActiveMarks();
447
- var isCheckListActive = false;
448
- var isOrderedListActive = false;
449
- var isUnorderedListActive = false;
450
- var isSelectedInList = this.listUtils.isInlist();
451
- if (isSelectedInList) {
452
- var items = this.listUtils.getCurrentListItem();
453
- var item = items[0];
454
- if (item[0].data && typeof item[0].data.checked === 'boolean') {
455
- isCheckListActive = true;
456
- isUnorderedListActive = false;
457
- } else {
458
- var currentList = Node.parent(this.editor, item[1]);
459
- var listType = currentList.type;
460
- if (listType === 'unordered_list') {
461
- isUnorderedListActive = true;
462
- } else {
463
- isOrderedListActive = true;
464
- }
465
- }
466
- }
467
- toolbarStatus = {
468
- headerType: block.type,
469
- isBoldActive: activeMarks.BOLD,
470
- isItalicActive: activeMarks.ITALIC,
471
- isInlineCodeActive: activeMarks.CODE,
472
- isLinkActive: isLinkActive,
473
- isBlockquoteActive: isBlockquoteActive,
474
- isOrderedListActive: isOrderedListActive,
475
- isUnorderedListActive: isUnorderedListActive,
476
- isCheckListActive: isCheckListActive,
477
- isCodeActive: isCodeActive,
478
- isTableActive: isTableActive
479
- };
480
- var isFormulaActive = false;
481
- if (window.canInsertFormula) {
482
- isFormulaActive = this.formulaUtils.isFormulaActive();
483
- toolbarStatus.isFormulaActive = isFormulaActive;
484
- }
485
- var isActiveColumn = this.inlineElementUtils.isColumnActive();
486
- toolbarStatus.isColumnActive = isActiveColumn;
487
- return toolbarStatus;
488
- }
489
- }]);
490
- return EditorUtils;
491
- }();
492
- export { EditorUtils };
@@ -1,95 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import { Editor } from 'slate';
5
- var InlineElementUtils = /*#__PURE__*/function () {
6
- function InlineElementUtils(editor) {
7
- var _this = this;
8
- _classCallCheck(this, InlineElementUtils);
9
- this.isLinkActive = function () {
10
- var _Editor$nodes = Editor.nodes(_this.editor, {
11
- match: {
12
- type: 'link'
13
- }
14
- }),
15
- _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
16
- link = _Editor$nodes2[0];
17
- return !!link;
18
- };
19
- this.getLinkText = function (linkNode) {
20
- var linkText = '';
21
- linkNode.children.forEach(function (textNode) {
22
- linkText += textNode.text;
23
- });
24
- return linkText;
25
- };
26
- this.getCurrentLinkNode = function () {
27
- var _Editor$nodes3 = Editor.nodes(_this.editor, {
28
- match: {
29
- type: 'link'
30
- }
31
- }),
32
- _Editor$nodes4 = _slicedToArray(_Editor$nodes3, 1),
33
- link = _Editor$nodes4[0];
34
- if (link) {
35
- return link[0];
36
- }
37
- return null;
38
- };
39
- this.unwrapLink = function () {
40
- _this.editor.exec({
41
- type: 'unwrap_link'
42
- });
43
- };
44
- this.insertLink = function (elementData) {
45
- _this.editor.exec({
46
- type: 'insert_link_at_selection',
47
- elementData: elementData
48
- });
49
- };
50
- this.setLink = function (elementData) {
51
- _this.editor.exec({
52
- type: 'set_link',
53
- elementData: elementData
54
- });
55
- };
56
- this.insertImage = function (data) {
57
- _this.editor.exec({
58
- type: 'insert_image_at_selection',
59
- data: {
60
- src: data.url
61
- },
62
- at: data.selection
63
- });
64
- };
65
- this.isColumnActive = function () {
66
- var _Editor$nodes5 = Editor.nodes(_this.editor, {
67
- match: {
68
- type: 'column'
69
- }
70
- }),
71
- _Editor$nodes6 = _slicedToArray(_Editor$nodes5, 1),
72
- column = _Editor$nodes6[0];
73
- return !!column;
74
- };
75
- this.setSeatableColumn = function (data) {
76
- _this.editor.exec({
77
- type: 'set_seatable_column',
78
- data: data
79
- });
80
- };
81
- this.editor = editor;
82
- }
83
- _createClass(InlineElementUtils, [{
84
- key: "adjustImageSize",
85
- value: function adjustImageSize(options) {
86
- var data = Object.assign({}, {}, options);
87
- this.editor.exec({
88
- type: 'set_image',
89
- data: data
90
- });
91
- }
92
- }]);
93
- return InlineElementUtils;
94
- }();
95
- export default InlineElementUtils;
@@ -1,20 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
- import { Editor } from 'slate';
5
- var MarkUtils = /*#__PURE__*/_createClass(function MarkUtils(editor) {
6
- var _this = this;
7
- _classCallCheck(this, MarkUtils);
8
- this.getActiveMarks = function () {
9
- var marks = Editor.marks(_this.editor);
10
- return marks;
11
- };
12
- this.setMark = function (type) {
13
- _this.editor.exec({
14
- type: 'format_text',
15
- properties: _defineProperty({}, type, true)
16
- });
17
- };
18
- this.editor = editor;
19
- });
20
- export default MarkUtils;
@@ -1,7 +0,0 @@
1
- import { Range } from 'slate';
2
- var isRangeCollapsed = function isRangeCollapsed(range) {
3
- if (range) {
4
- return Range.isCollapsed(range);
5
- }
6
- };
7
- export { isRangeCollapsed };
@@ -1,30 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { Editor, Range } from 'slate';
3
-
4
- /** Triple-click can set the selection focus point to
5
- * the start of the following block node.
6
- * Use this function to reset the selection focus point to the end of the previous block node
7
- * */
8
- export var normailizeSelection = function normailizeSelection(editor) {
9
- var selection = editor.selection;
10
- if (!selection) return false;
11
- var anchor = selection.anchor,
12
- focus = selection.focus;
13
- if (Range.isCollapsed(selection)) return;
14
- if (focus.offset !== 0) return;
15
- var _Editor$nodes = Editor.nodes(editor, {
16
- match: 'block',
17
- at: focus
18
- }),
19
- _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
20
- node = _Editor$nodes2[0];
21
- if (!node) return;
22
- if (Editor.isStart(editor, focus, node[1])) {
23
- var newFocusNode = Editor.before(editor, focus);
24
- var newSelection = {
25
- anchor: anchor,
26
- focus: newFocusNode
27
- };
28
- Editor.select(editor, newSelection);
29
- }
30
- };