@seafile/sdoc-editor 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/api/seafile-api.js +20 -0
  2. package/dist/context.js +14 -0
  3. package/dist/editor/sdoc-editor.js +3 -0
  4. package/dist/editor/wiki-editor.js +4 -1
  5. package/dist/extension/commons/insert-element-dialog/index.js +26 -13
  6. package/dist/extension/constants/element-type.js +2 -1
  7. package/dist/extension/constants/font.js +1 -2
  8. package/dist/extension/constants/index.js +8 -0
  9. package/dist/extension/constants/menus-config.js +8 -3
  10. package/dist/extension/plugins/code-block/plugin.js +9 -0
  11. package/dist/extension/plugins/file-view/helpers.js +77 -0
  12. package/dist/extension/plugins/file-view/index.js +17 -0
  13. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/constants.js +16 -0
  14. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/index.css +96 -0
  15. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/index.js +156 -0
  16. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/lib.png +0 -0
  17. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/option.css +49 -0
  18. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/option.js +53 -0
  19. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/select-option-group.css +37 -0
  20. package/dist/extension/plugins/file-view/insert-view-dialog/dropdown-select/select-option-group.js +241 -0
  21. package/dist/extension/plugins/file-view/insert-view-dialog/index.js +232 -0
  22. package/dist/extension/plugins/file-view/insert-view-dialog/modal-portal.js +41 -0
  23. package/dist/extension/plugins/file-view/plugin.js +71 -0
  24. package/dist/extension/plugins/file-view/render-elem/index.css +53 -0
  25. package/dist/extension/plugins/file-view/render-elem/index.js +103 -0
  26. package/dist/extension/plugins/html/plugin.js +2 -3
  27. package/dist/extension/plugins/image/use-copy-image.js +2 -2
  28. package/dist/extension/plugins/index.js +9 -2
  29. package/dist/extension/plugins/list/plugin/index.js +2 -1
  30. package/dist/extension/plugins/list/transforms/normalize-list-item.js +1 -1
  31. package/dist/extension/plugins/quick-insert/render-elem.js +1 -0
  32. package/dist/extension/render/custom-element.js +6 -0
  33. package/dist/extension/toolbar/insert-element-toolbar/index.js +16 -1
  34. package/dist/extension/toolbar/side-toolbar/index.js +36 -12
  35. package/dist/extension/toolbar/side-toolbar/insert-block-menu.js +16 -2
  36. package/dist/node-id/index.js +3 -0
  37. package/package.json +2 -2
@@ -328,6 +328,7 @@ var SideToolbar = function SideToolbar() {
328
328
  }
329
329
  var _getNodeEntry3 = (0, _helpers2.getNodeEntry)(editor, targetElement),
330
330
  _getNodeEntry4 = (0, _slicedToArray2["default"])(_getNodeEntry3, 2),
331
+ targetNode = _getNodeEntry4[0],
331
332
  targetPath = _getNodeEntry4[1];
332
333
  // Drag multiple list_items nodes
333
334
  if (draggedSourcePaths.current) {
@@ -394,7 +395,7 @@ var SideToolbar = function SideToolbar() {
394
395
  }
395
396
 
396
397
  // Dragging into a list is not supported
397
- if ([_constants2.CODE_BLOCK, _constants2.TABLE, _constants2.BLOCKQUOTE, _constants2.CHECK_LIST_ITEM].includes(sourceNode.type) && (0, _helpers2.isList)(editor, targetPath)) {
398
+ if ([_constants2.CALL_OUT, _constants2.TABLE, _constants2.BLOCKQUOTE, _constants2.CHECK_LIST_ITEM].includes(sourceNode.type) && (0, _helpers2.isList)(editor, targetPath)) {
398
399
  return;
399
400
  }
400
401
 
@@ -409,8 +410,19 @@ var SideToolbar = function SideToolbar() {
409
410
  return;
410
411
  }
411
412
 
413
+ // Drag out codeblock from list into non-list nodes
414
+ if ((0, _helpers2.isList)(editor, sourcePath) && sourceNode.type === _constants2.CODE_BLOCK && !(0, _helpers2.isList)(editor, targetPath)) {
415
+ var codeblockPath = (0, _core.findPath)(editor, sourceNode);
416
+ var toPath = _slate.Path.next(targetPath);
417
+ _slate.Transforms.moveNodes(editor, {
418
+ at: codeblockPath,
419
+ to: toPath
420
+ });
421
+ return;
422
+ }
423
+
412
424
  // Drag list
413
- if ((0, _helpers2.isList)(editor, sourcePath)) {
425
+ if ((0, _helpers2.isList)(editor, sourcePath) && sourceNode !== _constants2.CODE_BLOCK) {
414
426
  // ordinary list items
415
427
  if (!(0, _helpers2.isBlockquote)(editor, [sourcePath[0]])) {
416
428
  // Drag ordinary list items to places other than list and quoteBlock
@@ -498,39 +510,51 @@ var SideToolbar = function SideToolbar() {
498
510
 
499
511
  // Handling drag situations including non-multi_column or non-list item dragged from multiColumn
500
512
  if (!isInMultiColumn || isInMultiColumn && ![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(currentSourceNode.type)) {
513
+ // Special situation: drag codeblock into list nodes
514
+ if ((0, _helpers2.isList)(editor, targetPath) && [_constants2.CODE_BLOCK].includes(sourceNode.type)) {
515
+ var childrenPath = (0, _core.findPath)(editor, targetNode);
516
+ var _codeblockPath = (0, _core.findPath)(editor, sourceNode);
517
+ var _toPath = _slate.Path.next(childrenPath);
518
+ _slate.Transforms.moveNodes(editor, {
519
+ at: _codeblockPath,
520
+ to: _toPath
521
+ });
522
+ return;
523
+ }
524
+
501
525
  // Drag backward
502
526
  if (_slate.Path.isAfter(targetPath, sourcePath)) {
503
- var toPath = targetPath.slice(0);
527
+ var _toPath2 = targetPath.slice(0);
504
528
 
505
529
  // Drag elements outside the quoteBlock into the quoteBlock
506
530
  if (!(0, _helpers2.isBlockquote)(editor, [sourcePath[0]]) && (0, _helpers2.isBlockquote)(editor, [targetPath[0]]) && targetPath.length > 1) {
507
- toPath = _slate.Path.next(targetPath);
531
+ _toPath2 = _slate.Path.next(targetPath);
508
532
  }
509
533
 
510
- // Drag into list
511
- if ((0, _helpers2.isList)(editor, targetPath)) {
512
- toPath = _slate.Path.next(targetPath);
534
+ // Drag non-codeblock into list
535
+ if ((0, _helpers2.isList)(editor, targetPath) && ![_constants2.CODE_BLOCK].includes(currentSourceNode.type)) {
536
+ _toPath2 = _slate.Path.next(targetPath);
513
537
  }
514
538
  _slate.Transforms.moveNodes(editor, {
515
539
  at: sourcePath,
516
- to: toPath
540
+ to: _toPath2
517
541
  });
518
542
  }
519
543
 
520
544
  // Drag forward
521
545
  if (_slate.Path.isBefore(targetPath, sourcePath)) {
522
- var _toPath = _slate.Path.next(targetPath);
546
+ var _toPath3 = _slate.Path.next(targetPath);
523
547
  _slate.Transforms.moveNodes(editor, {
524
548
  at: sourcePath,
525
- to: _toPath
549
+ to: _toPath3
526
550
  });
527
551
  }
528
552
  }
529
553
  var selectedSourcePath = sourcePath;
530
554
  // Handling drag forward situation for multi_column update
531
555
  if (_slate.Path.isBefore(targetPath, sourcePath)) {
532
- var targetNode = _slate.Editor.node(editor, [targetPath[0]])[0];
533
- if (![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(targetNode.type)) {
556
+ var _targetNode = _slate.Editor.node(editor, [targetPath[0]])[0];
557
+ if (![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(_targetNode.type)) {
534
558
  selectedSourcePath[0] += 1;
535
559
  }
536
560
  }
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
10
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _reactI18next = require("react-i18next");
13
13
  var _reactstrap = require("reactstrap");
@@ -142,7 +142,21 @@ var InsertBlockMenu = function InsertBlockMenu(_ref) {
142
142
  var newInsertPosition = slateNode.type === _constants2.ELEMENT_TYPE.LIST_ITEM ? _constants2.INSERT_POSITION.AFTER : insertPosition;
143
143
  (0, _helper2.insertMultiColumn)(editor, editor.selection, newInsertPosition, type);
144
144
  }, [editor, insertPosition, slateNode]);
145
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, [_constants2.SIDE_INSERT_MENUS_CONFIG[_constants2.ELEMENT_TYPE.PARAGRAPH]].concat((0, _toConsumableArray2["default"])(_constants2.SIDE_INSERT_MENUS_CONFIG[_constants2.ELEMENT_TYPE.HEADER])).map(function (item) {
145
+ var insertFileView = (0, _react.useCallback)(function () {
146
+ var eventBus = _eventBus["default"].getInstance();
147
+ eventBus.dispatch(_constants.INTERNAL_EVENT.INSERT_ELEMENT, {
148
+ type: _constants2.ELEMENT_TYPE.FILE_VIEW,
149
+ insertPosition: insertPosition,
150
+ slateNode: slateNode
151
+ });
152
+ // eslint-disable-next-line react-hooks/exhaustive-deps
153
+ }, [insertPosition]);
154
+ console.log(editor.editorType);
155
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, editor.editorType === _constants.WIKI_EDITOR && /*#__PURE__*/_react["default"].createElement(_dropdownMenuItem["default"], {
156
+ isHidden: !insertMenuSearchMap[_constants2.ELEMENT_TYPE.FILE_VIEW],
157
+ menuConfig: (0, _objectSpread2["default"])({}, _constants2.SIDE_INSERT_MENUS_CONFIG[_constants2.ELEMENT_TYPE.FILE_VIEW]),
158
+ onClick: insertFileView
159
+ }), [_constants2.SIDE_INSERT_MENUS_CONFIG[_constants2.ELEMENT_TYPE.PARAGRAPH]].concat((0, _toConsumableArray2["default"])(_constants2.SIDE_INSERT_MENUS_CONFIG[_constants2.ELEMENT_TYPE.HEADER])).map(function (item) {
146
160
  return /*#__PURE__*/_react["default"].createElement(_dropdownMenuItem["default"], {
147
161
  isHidden: !insertMenuSearchMap[item.type],
148
162
  disabled: isNodeEmpty && item.type === _constants2.PARAGRAPH,
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -7,6 +8,7 @@ exports["default"] = void 0;
7
8
  var _slate = require("@seafile/slate");
8
9
  var _constants = require("../extension/constants");
9
10
  var _documentUtils = require("../utils/document-utils");
11
+ var _localStorageUtils = _interopRequireDefault(require("../utils/local-storage-utils"));
10
12
  var _helpers = require("./helpers");
11
13
  var withNodeId = function withNodeId(editor) {
12
14
  var apply = editor.apply,
@@ -65,6 +67,7 @@ var withNodeId = function withNodeId(editor) {
65
67
  var cleaned = (0, _helpers.removeCommentMarks)(parsed);
66
68
  var newData = (0, _helpers.replacePastedDataId)(cleaned);
67
69
  var normalizeNewData = (0, _documentUtils.normalizeCopyNodes)(newEditor, newData);
70
+ _localStorageUtils["default"].setItem(_constants.RECENT_COPY_CONTENT, normalizeNewData);
68
71
  newEditor.insertFragment(normalizeNewData);
69
72
  return newEditor;
70
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "f4690d913506d3dd6108d97248323e1b9b06ee32"
74
+ "gitHead": "0a7ebc1042c83af89889893429b3b1a6b1a13431"
75
75
  }