@seafile/sdoc-editor 1.0.221 → 1.0.223

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 (36) hide show
  1. package/dist/basic-sdk/assets/css/dropdown-menu.css +14 -1
  2. package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +0 -23
  3. package/dist/basic-sdk/extension/commons/search-list/index.css +28 -0
  4. package/dist/basic-sdk/extension/commons/search-list/index.js +150 -0
  5. package/dist/basic-sdk/extension/constants/index.js +2 -6
  6. package/dist/basic-sdk/extension/constants/menus-config.js +15 -0
  7. package/dist/basic-sdk/extension/plugins/image/helpers.js +9 -21
  8. package/dist/basic-sdk/extension/plugins/image/image-loader/index.css +37 -0
  9. package/dist/basic-sdk/extension/plugins/image/image-loader/index.js +23 -0
  10. package/dist/basic-sdk/extension/plugins/image/render-elem.js +24 -76
  11. package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +80 -0
  12. package/dist/basic-sdk/extension/plugins/multi-column/constants/index.js +1 -1
  13. package/dist/basic-sdk/extension/plugins/multi-column/helper.js +24 -7
  14. package/dist/basic-sdk/extension/plugins/multi-column/render/index.css +1 -3
  15. package/dist/basic-sdk/extension/plugins/multi-column/render/index.js +7 -2
  16. package/dist/basic-sdk/extension/plugins/multi-column/resize-handlers/index.js +2 -2
  17. package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-item.js +36 -0
  18. package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.css +4 -2
  19. package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.js +8 -13
  20. package/dist/basic-sdk/extension/plugins/seatable-column/menu/index.js +5 -9
  21. package/dist/basic-sdk/extension/plugins/seatable-column/render-elem.js +36 -7
  22. package/dist/basic-sdk/extension/plugins/seatable-tables/menu/index.js +3 -6
  23. package/dist/basic-sdk/extension/plugins/seatable-tables/menu/seatable-list.js +35 -2
  24. package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.css +19 -4
  25. package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.js +39 -9
  26. package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/seatable-table.js +2 -1
  27. package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/hide-column-popover.js +2 -4
  28. package/dist/basic-sdk/extension/plugins/table/helpers.js +1 -0
  29. package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +4 -0
  30. package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +7 -0
  31. package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +51 -1
  32. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +116 -20
  33. package/dist/basic-sdk/utils/full-width-mode.js +1 -1
  34. package/package.json +2 -2
  35. package/public/locales/en/sdoc-editor.json +2 -1
  36. package/public/locales/zh_CN/sdoc-editor.json +2 -1
@@ -138,6 +138,12 @@ const QuickInsertBlockMenu = _ref => {
138
138
  });
139
139
  return !!callout;
140
140
  }, [editor]);
141
+ const isDisableTable = (0, _react.useMemo)(() => {
142
+ const callout = (0, _core.getAboveBlockNode)(editor, {
143
+ match: n => [_constants.ELEMENT_TYPE.ORDERED_LIST, _constants.ELEMENT_TYPE.UNORDERED_LIST, _constants.ELEMENT_TYPE.CHECK_LIST_ITEM, _constants.ELEMENT_TYPE.MULTI_COLUMN].includes(n.type)
144
+ });
145
+ return !!callout;
146
+ }, [editor]);
141
147
  const createMultiColumn = (0, _react.useCallback)(type => {
142
148
  callback && callback();
143
149
  const newInsertPosition = slateNode.type === _constants.ELEMENT_TYPE.LIST_ITEM ? _constants.INSERT_POSITION.AFTER : insertPosition;
@@ -168,6 +174,7 @@ const QuickInsertBlockMenu = _ref => {
168
174
  // eslint-disable-next-line react/jsx-indent
169
175
  _react.default.createElement(_dropdownMenuItem.default, {
170
176
  isHidden: !quickInsertMenuSearchMap[_constants.TABLE],
177
+ disabled: isDisableTable,
171
178
  key: "sdoc-insert-menu-table",
172
179
  menuConfig: {
173
180
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.TABLE]
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isInMultiColumnNode = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
7
+ exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItemFromMultiColumn = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isInMultiColumnNode = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNodeFromMultiColumn = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
8
8
  var _slate = require("@seafile/slate");
9
9
  var _slugid = _interopRequireDefault(require("slugid"));
10
10
  var _slateReact = require("@seafile/slate-react");
@@ -20,6 +20,7 @@ var _helpers2 = require("../../plugins/check-list/helpers");
20
20
  var _constants3 = require("../../../constants");
21
21
  var _helpers3 = require("../../../node-id/helpers");
22
22
  var _documentUtils = require("../../../utils/document-utils");
23
+ var _helper2 = require("../../plugins/multi-column/helper");
23
24
  const onSetNodeType = (editor, element, type) => {
24
25
  if (!type) return;
25
26
  if (type === _constants.CALL_OUT) {
@@ -53,6 +54,32 @@ const onSetNodeType = (editor, element, type) => {
53
54
  });
54
55
  return;
55
56
  }
57
+
58
+ // Transform to multi_column and put content into first column
59
+ if (_constants.MULTI_COLUMN_TYPE.includes(type)) {
60
+ const path = (0, _core.findPath)(editor, element);
61
+ const multiColumnNode = (0, _helper2.generateEmptyMultiColumn)(editor, type);
62
+ _slate.Transforms.insertNodes(editor, multiColumnNode, {
63
+ at: [path[0] + 1]
64
+ });
65
+ const nodeIndex = path[0];
66
+ const highestNode = editor.children[nodeIndex];
67
+ if (path.length > 1 && [_constants.BLOCKQUOTE, _constants.ORDERED_LIST, _constants.UNORDERED_LIST, _constants.CODE_BLOCK].includes(highestNode.type)) {
68
+ _slate.Transforms.moveNodes(editor, {
69
+ at: [path[0]],
70
+ to: [path[0] + 1, 0, 0]
71
+ });
72
+ } else {
73
+ _slate.Transforms.moveNodes(editor, {
74
+ at: path,
75
+ to: [path[0] + 1, 0, 0]
76
+ });
77
+ }
78
+ _slate.Transforms.removeNodes(editor, {
79
+ at: [path[0], 0, 1]
80
+ });
81
+ return;
82
+ }
56
83
  _slate.Transforms.setNodes(editor, {
57
84
  type: type
58
85
  });
@@ -220,6 +247,25 @@ const getListNode = (editor, path) => {
220
247
  return listNode;
221
248
  };
222
249
  exports.getListNode = getListNode;
250
+ const getListNodeFromMultiColumn = (editor, path) => {
251
+ let listType = _slate.Editor.node(editor, path.slice(0, 3))[0].type;
252
+ const listItem = _slate.Editor.node(editor, path)[0];
253
+ const listNode = (0, _model.generateEmptyList)(listType);
254
+ listNode.children[0] = listItem;
255
+ return listNode;
256
+ };
257
+ exports.getListNodeFromMultiColumn = getListNodeFromMultiColumn;
258
+ const onWrapListItemFromMultiColumn = (editor, targetPath, sourcePath) => {
259
+ const nextPath = _slate.Path.next(targetPath);
260
+ const listNode = getListNodeFromMultiColumn(editor, sourcePath.slice(0, 4));
261
+ _slate.Transforms.removeNodes(editor, {
262
+ at: sourcePath.slice(0, 4)
263
+ });
264
+ _slate.Transforms.insertNodes(editor, listNode, {
265
+ at: nextPath
266
+ });
267
+ };
268
+ exports.onWrapListItemFromMultiColumn = onWrapListItemFromMultiColumn;
223
269
  const onWrapListItem = (editor, targetPath, sourcePath) => {
224
270
  const nextPath = _slate.Path.next(targetPath);
225
271
  const listNode = getListNode(editor, sourcePath);
@@ -274,6 +320,10 @@ const getTransformMenusConfig = (editor, slateNode) => {
274
320
  if (highestNode.type === _constants.BLOCKQUOTE) {
275
321
  newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => item.type !== _constants.CALL_OUT);
276
322
  }
323
+ // Element in Multi_column can not be converted to multi_column type
324
+ if (highestNode.type === _constants.MULTI_COLUMN) {
325
+ newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => !_constants.MULTI_COLUMN_TYPE.includes(item.type));
326
+ }
277
327
  }
278
328
 
279
329
  // headers can't be nested by quote block
@@ -20,6 +20,7 @@ var _constants = require("../../../constants");
20
20
  var _constants2 = require("../../constants");
21
21
  var _helper = require("../../plugins/callout/helper");
22
22
  var _event = require("./event");
23
+ var _helper2 = require("../../plugins/multi-column/helper");
23
24
  require("./index.css");
24
25
  let sourceElement = null;
25
26
  let targetElement = null;
@@ -88,6 +89,9 @@ const SideToolbar = () => {
88
89
  let dom = e.target;
89
90
  while (((_dom = dom) === null || _dom === void 0 ? void 0 : (_dom$dataset = _dom.dataset) === null || _dom$dataset === void 0 ? void 0 : _dom$dataset.root) !== 'true') {
90
91
  var _dom, _dom$dataset;
92
+ if (dom.className === 'column') {
93
+ return;
94
+ }
91
95
  if (!dom.parentNode) return;
92
96
  dom = dom.parentNode;
93
97
  }
@@ -106,6 +110,20 @@ const SideToolbar = () => {
106
110
  } = document.querySelector('.sdoc-editor-container').getBoundingClientRect();
107
111
  left = editorLeft - containerLeft - 40;
108
112
  }
113
+ const path = (0, _core.findPath)(editor, node);
114
+ // Add side-tool-bar for paragraphs in multi_column
115
+ if (path.length > 2 && (0, _helpers.isInMultiColumnNode)(editor, node)) {
116
+ let domLeft;
117
+ domLeft = document.querySelector(`[data-id="${dom.dataset.id}"]`) && document.querySelector(`[data-id="${dom.dataset.id}"]`).getBoundingClientRect().left;
118
+ const parentNode = _slate.Editor.node(editor, path.slice(0, 3))[0];
119
+ if ([_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST, _constants2.BLOCKQUOTE].includes(parentNode.type)) {
120
+ domLeft = document.querySelector(`[data-id="${parentNode.id}"]`) && document.querySelector(`[data-id="${parentNode.id}"]`).getBoundingClientRect().left;
121
+ }
122
+ const {
123
+ left: containerLeft
124
+ } = document.querySelector('.sdoc-editor__article').getBoundingClientRect();
125
+ left = domLeft - containerLeft - 41;
126
+ }
109
127
  setTimeout(() => {
110
128
  // wait animation
111
129
  setSidePosition({
@@ -247,6 +265,7 @@ const SideToolbar = () => {
247
265
  leaveElement.classList.remove('sdoc-draging');
248
266
  }, []);
249
267
  const drop = (0, _react.useCallback)(event => {
268
+ var _parentNode$children$;
250
269
  targetElement = event.currentTarget;
251
270
  targetElement.classList.remove('sdoc-draging');
252
271
  const dragTypes = event.dataTransfer.types;
@@ -326,11 +345,17 @@ const SideToolbar = () => {
326
345
  return;
327
346
  }
328
347
 
329
- // Drag into callout is not supported
348
+ // Dragging into callout is not supported
330
349
  if ([_constants2.CALL_OUT, _constants2.CODE_BLOCK, _constants2.TABLE].includes(sourceNode.type) && (0, _helper.getCalloutEntry)(editor, targetPath)) {
331
350
  return;
332
351
  }
333
352
 
353
+ // Dragging multi_column's child into multi_column is not supported
354
+ const isInMultiColumn = (0, _helpers.isInMultiColumnNode)(editor, sourceNode);
355
+ if (isInMultiColumn && (0, _helpers.isMultiColumn)(editor, [targetPath[0]])) {
356
+ return;
357
+ }
358
+
334
359
  // Drag list
335
360
  if ((0, _helpers.isList)(editor, sourcePath)) {
336
361
  // ordinary list items
@@ -380,32 +405,103 @@ const SideToolbar = () => {
380
405
  }
381
406
  }
382
407
 
383
- // Drag backward
384
- if (_slate.Path.isAfter(targetPath, sourcePath)) {
385
- let toPath = targetPath.slice(0);
408
+ // Dragging element from multi_column to other nodes
409
+ const currentSourceNode = _slate.Editor.node(editor, sourcePath.slice(0, 3))[0];
410
+ if (isInMultiColumn && sourceNode.type === _constants2.PARAGRAPH) {
411
+ // Dragging list
412
+ if ([_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(currentSourceNode.type)) {
413
+ // Drag ordinary list items to places other than list and quoteBlock
414
+ if (!(0, _helpers.isList)(editor, targetPath) && !(0, _helpers.isBlockquote)(editor, [targetPath[0]])) {
415
+ (0, _helpers.onWrapListItemFromMultiColumn)(editor, targetPath, sourcePath);
416
+ }
417
+
418
+ // Drag ordinary list items to list
419
+ if ((0, _helpers.isList)(editor, targetPath)) {
420
+ _slate.Transforms.moveNodes(editor, {
421
+ at: sourcePath.slice(0, 4),
422
+ to: _slate.Path.next(targetPath)
423
+ });
424
+ }
386
425
 
387
- // Drag elements outside the quoteBlock into the quoteBlock
388
- if (!(0, _helpers.isBlockquote)(editor, [sourcePath[0]]) && (0, _helpers.isBlockquote)(editor, [targetPath[0]]) && targetPath.length > 1) {
389
- toPath = _slate.Path.next(targetPath);
426
+ // Drag ordinary list items into the quoteBlock
427
+ if ((0, _helpers.isBlockquote)(editor, [targetPath[0]])) {
428
+ // Drag and drop ordinary list items onto the list within the quoteBlock
429
+ if ((0, _helpers.isList)(editor, targetPath)) {
430
+ _slate.Transforms.moveNodes(editor, {
431
+ at: sourcePath.slice(0, 4),
432
+ to: _slate.Path.next(targetPath)
433
+ });
434
+ } else {
435
+ (0, _helpers.onWrapListItemFromMultiColumn)(editor, targetPath, sourcePath);
436
+ }
437
+ }
390
438
  }
391
439
 
392
- // Drag into list
393
- if ((0, _helpers.isList)(editor, targetPath)) {
394
- toPath = _slate.Path.next(targetPath);
440
+ // Dragging quoteBlock's children element from multi_column is not supported
441
+ if (currentSourceNode.type === _constants2.BLOCKQUOTE) {
442
+ return;
395
443
  }
396
- _slate.Transforms.moveNodes(editor, {
397
- at: sourcePath,
398
- to: toPath
399
- });
400
444
  }
401
445
 
402
- // Drag forward
446
+ // Handling drag situations including non-multi_column or non-list item dragged from multiColumn
447
+ if (!isInMultiColumn || isInMultiColumn && ![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(currentSourceNode.type)) {
448
+ // Drag backward
449
+ if (_slate.Path.isAfter(targetPath, sourcePath)) {
450
+ let toPath = targetPath.slice(0);
451
+
452
+ // Drag elements outside the quoteBlock into the quoteBlock
453
+ if (!(0, _helpers.isBlockquote)(editor, [sourcePath[0]]) && (0, _helpers.isBlockquote)(editor, [targetPath[0]]) && targetPath.length > 1) {
454
+ toPath = _slate.Path.next(targetPath);
455
+ }
456
+
457
+ // Drag into list
458
+ if ((0, _helpers.isList)(editor, targetPath)) {
459
+ toPath = _slate.Path.next(targetPath);
460
+ }
461
+ _slate.Transforms.moveNodes(editor, {
462
+ at: sourcePath,
463
+ to: toPath
464
+ });
465
+ }
466
+
467
+ // Drag forward
468
+ if (_slate.Path.isBefore(targetPath, sourcePath)) {
469
+ const toPath = _slate.Path.next(targetPath);
470
+ _slate.Transforms.moveNodes(editor, {
471
+ at: sourcePath,
472
+ to: toPath
473
+ });
474
+ }
475
+ }
476
+ let selectedSourcePath = sourcePath;
477
+ // Handling drag forward situation for multi_column update
403
478
  if (_slate.Path.isBefore(targetPath, sourcePath)) {
404
- const toPath = _slate.Path.next(targetPath);
405
- _slate.Transforms.moveNodes(editor, {
406
- at: sourcePath,
407
- to: toPath
408
- });
479
+ const targetNode = _slate.Editor.node(editor, [targetPath[0]])[0];
480
+ if (![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(targetNode.type)) {
481
+ selectedSourcePath[0] += 1;
482
+ }
483
+ }
484
+
485
+ // Dragging childNodes from multi_column
486
+ const nodeIndex = selectedSourcePath[0];
487
+ const highestNode = editor.children[nodeIndex];
488
+ const [parentNode] = _slate.Editor.parent(editor, selectedSourcePath.slice(0, 3));
489
+ if (selectedSourcePath.length > 1 && highestNode.type === _constants2.MULTI_COLUMN && !((_parentNode$children$ = parentNode.children[0]) !== null && _parentNode$children$ !== void 0 && _parentNode$children$.type)) {
490
+ if (highestNode.children.length <= 2) {
491
+ _slate.Transforms.removeNodes(editor, {
492
+ at: selectedSourcePath.slice(0, 2)
493
+ });
494
+ _slate.Transforms.unwrapNodes(editor, {
495
+ at: [selectedSourcePath[0]]
496
+ });
497
+ } else {
498
+ const topNodesColumnAttribute = highestNode.column;
499
+ _slate.Transforms.removeNodes(editor, {
500
+ at: selectedSourcePath.slice(0, 2)
501
+ });
502
+ const isDragged = true;
503
+ (0, _helper2.updateColumnWidthOnDeletion)(editor, selectedSourcePath, topNodesColumnAttribute, 'deleteBackward', isDragged);
504
+ }
409
505
  }
410
506
 
411
507
  // reset
@@ -17,7 +17,7 @@ const getStyleByFullWidthMode = (scrollRef, editor) => {
17
17
  containerStyle['minWidth'] = _constants.ARTICLE_FULL_MIN_WIDTH;
18
18
 
19
19
  // Has outline
20
- if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
20
+ if (isShowOutline && (editor === null || editor === void 0 ? void 0 : editor.editorType) !== _constants.WIKI_EDITOR) {
21
21
  containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
22
22
  const adjustWidth = ` - ${_constants.LEFT_OUTLINE_WIDTH - 50}px`; // One side is 50
23
23
  containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.221",
3
+ "version": "1.0.223",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,7 @@
11
11
  "@seafile/slate-history": "0.86.2",
12
12
  "@seafile/slate-hyperscript": "0.81.7",
13
13
  "@seafile/slate-react": "0.92.7",
14
- "axios": "^1.7.4",
14
+ "axios": "^1.8.2",
15
15
  "classnames": "2.3.2",
16
16
  "copy-to-clipboard": "^3.3.3",
17
17
  "dayjs": "1.10.7",
@@ -613,5 +613,6 @@
613
613
  "Support_Youtube_Tencent_Bilibili_and_more": "Support Youtube, Tencent, Bilibili and more",
614
614
  "Image_cannot_be_copied_Please_download_the_source_image": "Image cannot be copied. Please download the source image,",
615
615
  "And_select_insert_-_image_to_upload": "and select 「insert」 - 「image」 to upload.",
616
- "Image_copy_error": "Image copy error"
616
+ "Image_copy_error": "Image copy error",
617
+ "Image_is_uploading": "Image is uploading..."
617
618
  }
@@ -613,5 +613,6 @@
613
613
  "Support_Youtube_Tencent_Bilibili_and_more": "支持Youtube,腾讯视频,B站及其他平台",
614
614
  "Image_cannot_be_copied_Please_download_the_source_image": "此照片不支持复制,请下载原图",
615
615
  "And_select_insert_-_image_to_upload": "后点击工具栏「插入」- 「照片」上传",
616
- "Image_copy_error": "图片复制错误"
616
+ "Image_copy_error": "图片复制错误",
617
+ "Image_is_uploading": "图片正在上传..."
617
618
  }