@seafile/sdoc-editor 2.0.32 → 2.0.34

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.
@@ -3,12 +3,13 @@
3
3
  width: 100%;
4
4
  height: 100%;
5
5
  display: flex;
6
- flex-direction: column;
6
+ flex-direction: row;
7
7
  align-items: center;
8
8
  justify-content: center;
9
- top: 0;
9
+ bottom: 0;
10
10
  left: 0;
11
- background-color: 'rgba(0, 0, 0, 0.5)'
11
+ background-color: rgba(0, 0, 0, 0.5);
12
+ min-height: 28px;
12
13
  }
13
14
 
14
15
  @keyframes spin {
@@ -33,5 +34,7 @@
33
34
  }
34
35
 
35
36
  .sdoc-image-process-container .copyright {
36
- margin-top: 4px;
37
+ margin-left: 15px;
38
+ display: inline-block;
39
+ white-space: nowrap;
37
40
  }
@@ -209,8 +209,8 @@ const Image = _ref => {
209
209
  }
210
210
  }, [data, editor]);
211
211
  const onImageLoaded = (0, _react.useCallback)(() => {
212
- if ((0, _helpers.isImagUrlIsFromCopy)(data.src)) {
213
- setCopyImageLoading(true);
212
+ if (!(0, _helpers.isImagUrlIsFromCopy)(data.src)) {
213
+ setCopyImageLoading(false);
214
214
  }
215
215
  }, [data.src, setCopyImageLoading]);
216
216
  const onImageLoadError = (0, _react.useCallback)(() => {
@@ -35,7 +35,7 @@ const useImageUpload = _ref => {
35
35
  const {
36
36
  is_copy_error = false
37
37
  } = data;
38
- const [isLoading, setIsLoading] = (0, _react.useState)(false);
38
+ const [isLoading, setIsLoading] = (0, _react.useState)(true);
39
39
  const [isCopyError, setIsCopyError] = (0, _react.useState)(is_copy_error);
40
40
  (0, _react.useEffect)(() => {
41
41
  const {
@@ -21,16 +21,82 @@ var _constants3 = require("../../../constants");
21
21
  var _helpers3 = require("../../../node-id/helpers");
22
22
  var _documentUtils = require("../../../utils/document-utils");
23
23
  var _helper2 = require("../../plugins/multi-column/helper");
24
+ var _helpers4 = require("../../plugins/blockquote/helpers");
25
+ var _helpers5 = require("../../plugins/header/helpers");
24
26
  const onSetNodeType = (editor, element, type) => {
27
+ const {
28
+ selection
29
+ } = editor;
25
30
  if (!type) return;
26
31
  if (type === _constants.CALL_OUT) {
32
+ if (_constants.IMAGE_BLOCK === element.type) {
33
+ _slate.Transforms.setNodes(editor, {
34
+ type: _constants.PARAGRAPH
35
+ });
36
+ }
27
37
  (0, _helper.wrapCallout)(editor);
28
38
  return;
29
39
  }
30
40
  if ([_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes(type)) {
41
+ if ([_constants.IMAGE_BLOCK].includes(element.type)) return;
31
42
  (0, _transforms.toggleList)(editor, type);
43
+ const path = (0, _core.findPath)(editor, element);
44
+ const [targetNode] = _slate.Editor.node(editor, [path[0]]) || [];
45
+ if ([_constants.MULTI_COLUMN, _constants.BLOCKQUOTE].includes(targetNode.type)) {
46
+ if (targetNode.type === _constants.BLOCKQUOTE) {
47
+ (0, _helpers4.setBlockQuoteType)(editor, true);
48
+ } else {
49
+ const currentNodeInColumn = (0, _core.getNode)(editor, selection.anchor.path.slice(0, 3));
50
+ if ([_constants.BLOCKQUOTE].includes(currentNodeInColumn.type)) {
51
+ (0, _helpers4.setBlockQuoteType)(editor, true);
52
+ }
53
+ }
54
+ }
32
55
  return;
33
56
  }
57
+ if ([_constants.PARAGRAPH, ..._constants.HEADERS].includes(type)) {
58
+ var _getTopLevelBlockNode;
59
+ // Transform list-item, blockquote, callout to paragraph or header
60
+ const topNodeType = (_getTopLevelBlockNode = (0, _core.getTopLevelBlockNode)(editor)[0]) === null || _getTopLevelBlockNode === void 0 ? void 0 : _getTopLevelBlockNode.type;
61
+ if (topNodeType === _constants.MULTI_COLUMN) {
62
+ const currentNodeInColumn = (0, _core.getNode)(editor, selection.anchor.path.slice(0, 3));
63
+ // Callout, List-item, Blockquote in multi_column
64
+ if ([_constants.CALL_OUT].includes(currentNodeInColumn.type)) {
65
+ (0, _helper.unwrapCallout)(editor);
66
+ }
67
+ if ([_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes(currentNodeInColumn.type)) {
68
+ (0, _transforms.toggleList)(editor, currentNodeInColumn.type);
69
+ if ([..._constants.HEADERS].includes(type)) {
70
+ (0, _helpers5.setHeaderType)(editor, type);
71
+ }
72
+ }
73
+ if ([_constants.BLOCKQUOTE].includes(currentNodeInColumn.type)) {
74
+ if ([..._constants.HEADERS].includes(type)) {
75
+ (0, _helpers5.setHeaderType)(editor, type);
76
+ }
77
+ (0, _helpers4.setBlockQuoteType)(editor, true);
78
+ }
79
+ return;
80
+ } else {
81
+ // List-item, blockquote, callout is top node
82
+ if ([_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes(topNodeType)) {
83
+ (0, _transforms.toggleList)(editor, topNodeType);
84
+ if ([..._constants.HEADERS].includes(type)) {
85
+ (0, _helpers5.setHeaderType)(editor, type);
86
+ }
87
+ }
88
+ if ([_constants.BLOCKQUOTE].includes(topNodeType)) {
89
+ if ([..._constants.HEADERS].includes(type)) {
90
+ (0, _helpers5.setHeaderType)(editor, type);
91
+ }
92
+ (0, _helpers4.setBlockQuoteType)(editor, true);
93
+ }
94
+ if ([_constants.CALL_OUT].includes(topNodeType)) {
95
+ (0, _helper.unwrapCallout)(editor);
96
+ }
97
+ return;
98
+ }
99
+ }
34
100
  if (type === _constants.CHECK_LIST_ITEM) {
35
101
  const path = (0, _core.findPath)(editor, element);
36
102
  const [targetNode, targetPath] = _slate.Editor.node(editor, [path[0]]) || [];
@@ -42,8 +108,31 @@ const onSetNodeType = (editor, element, type) => {
42
108
  _slate.Transforms.setNodes(editor, {
43
109
  type: newType
44
110
  });
111
+ if ([_constants.MULTI_COLUMN, _constants.BLOCKQUOTE].includes(targetNode.type)) {
112
+ if (targetNode.type === _constants.BLOCKQUOTE) {
113
+ (0, _helpers4.setBlockQuoteType)(editor, true);
114
+ } else {
115
+ const currentNodeInColumn = (0, _core.getNode)(editor, selection.anchor.path.slice(0, 3));
116
+ if ([_constants.BLOCKQUOTE].includes(currentNodeInColumn.type)) {
117
+ (0, _helpers4.setBlockQuoteType)(editor, true);
118
+ }
119
+ }
120
+ }
45
121
  return;
46
122
  }
123
+ if (type === _constants.BLOCKQUOTE && !_constants.LIST_ITEM_CORRELATION_TYPE.includes(element.type)) {
124
+ if (element.type === _constants.BLOCKQUOTE) return;
125
+ const isBlockQuoteParent = (0, _core.getAboveNode)(editor, {
126
+ match: {
127
+ type: _constants.BLOCKQUOTE
128
+ }
129
+ });
130
+ if (isBlockQuoteParent) return;
131
+ if (!isBlockQuoteParent && ![_constants.BLOCKQUOTE].includes(element.type)) {
132
+ (0, _helpers4.setBlockQuoteType)(editor, false);
133
+ return;
134
+ }
135
+ }
47
136
  if (type === _constants.BLOCKQUOTE && _constants.LIST_ITEM_CORRELATION_TYPE.includes(element.type)) {
48
137
  _slate.Transforms.wrapNodes(editor, {
49
138
  id: _slugid.default.nice(),
@@ -167,7 +256,7 @@ const isVoidNode = node => {
167
256
  };
168
257
  exports.isVoidNode = isVoidNode;
169
258
  const isNotSupportTransform = node => {
170
- if (node.type && [_constants.CODE_BLOCK, _constants.TABLE, _constants.CALL_OUT, _constants.VIDEO, _constants.SEATABLE_TABLE].includes(node.type)) {
259
+ if (node.type && [_constants.CODE_BLOCK, _constants.TABLE, _constants.VIDEO, _constants.SEATABLE_TABLE, _constants.SEATABLE_ROW].includes(node.type)) {
171
260
  return true;
172
261
  }
173
262
  return false;
@@ -313,6 +402,9 @@ const onWrapMultiListItemToNonListTypeTarget = (editor, targetPath, sourceNodes,
313
402
  exports.onWrapMultiListItemToNonListTypeTarget = onWrapMultiListItemToNonListTypeTarget;
314
403
  const getTransformMenusConfig = (editor, slateNode) => {
315
404
  let newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG;
405
+ if ([_constants.CALL_OUT].includes(slateNode.type)) {
406
+ return newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => [_constants.PARAGRAPH].includes(item.type));
407
+ }
316
408
  if (_constants.LIST_ITEM_CORRELATION_TYPE.includes(slateNode.type)) {
317
409
  newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => _constants.LIST_ITEM_SUPPORTED_TRANSFORMATION.includes(item.type));
318
410
  }
@@ -330,6 +422,11 @@ const getTransformMenusConfig = (editor, slateNode) => {
330
422
  }
331
423
  }
332
424
 
425
+ // Image-block can't be nested by ordered-list, ordered-list and check-list
426
+ if (_constants.IMAGE_BLOCK.includes(highestNode.type)) {
427
+ newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => ![_constants.ORDERED_LIST, _constants.UNORDERED_LIST, _constants.CHECK_LIST_ITEM].includes(item.type));
428
+ }
429
+
333
430
  // headers can't be nested by quote block
334
431
  if (_constants.HEADERS.includes(highestNode.type)) {
335
432
  newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => item.type !== _constants.BLOCKQUOTE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "2.0.32",
3
+ "version": "2.0.34",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",