@seafile/sdoc-editor 1.0.155 → 1.0.156

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.
@@ -337,6 +337,12 @@ Object.defineProperty(exports, "SDOC_LINK", {
337
337
  return _elementType.SDOC_LINK;
338
338
  }
339
339
  });
340
+ Object.defineProperty(exports, "SEATABLE_COLUMN", {
341
+ enumerable: true,
342
+ get: function () {
343
+ return _elementType.SEATABLE_COLUMN;
344
+ }
345
+ });
340
346
  Object.defineProperty(exports, "SEATABLE_TABLE", {
341
347
  enumerable: true,
342
348
  get: function () {
@@ -414,12 +414,10 @@ const SIDE_INSERT_MENUS_SEARCH_MAP = exports.SIDE_INSERT_MENUS_SEARCH_MAP = {
414
414
  [_elementType.IMAGE]: 'Image',
415
415
  [_elementType.VIDEO]: 'Video',
416
416
  [_elementType.TABLE]: 'Table',
417
- [_elementType.MULTI_COLUMN]: 'Multi_column',
418
417
  [_elementType.COLUMN]: 'Column',
419
418
  [_elementType.TWO_COLUMN]: 'Two_column',
420
419
  [_elementType.THREE_COLUMN]: 'Three_column',
421
420
  [_elementType.FOUR_COLUMN]: 'Four_column',
422
- [_elementType.FIVE_COLUMN]: 'Five_column',
423
421
  [_elementType.LINK]: 'Link',
424
422
  [_elementType.CODE_BLOCK]: 'Code_block',
425
423
  [_elementType.CALL_OUT]: 'Callout',
@@ -31,9 +31,10 @@ const RenderQuickInsert = (_ref, editor, readonly) => {
31
31
  const scrollRef = (0, _useScrollContext.useScrollContext)();
32
32
  const insertElmRef = (0, _react.useRef)(null);
33
33
  const aboveBlockNode = (0, _core.getAboveBlockNode)(editor);
34
- const searchText = _slate.Node.string(element);
35
34
  const isEmptyNode = (0, _helpers.isVoidNode)(aboveBlockNode === null || aboveBlockNode === void 0 ? void 0 : aboveBlockNode[0]);
36
35
  const handleClick = (0, _react.useCallback)(e => {
36
+ // Click the search input
37
+ if (sideMenuRef.current.contains(e.target) && e.target.tagName === 'INPUT') return;
37
38
  if (!insertElmRef.current.contains(e.target)) {
38
39
  (0, _helper.transformToText)(editor, element);
39
40
  }
@@ -88,7 +89,6 @@ const RenderQuickInsert = (_ref, editor, readonly) => {
88
89
  isEmptyNode: isEmptyNode,
89
90
  insertPosition: isEmptyNode ? _constants.INSERT_POSITION.CURRENT : _constants.INSERT_POSITION.AFTER,
90
91
  slateNode: aboveBlockNode === null || aboveBlockNode === void 0 ? void 0 : aboveBlockNode[0],
91
- searchText: searchText,
92
92
  callback: handleInsertBlock
93
93
  })))));
94
94
  };
@@ -3,31 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SHORT_INSERT_ELEMENT_USER_INPUT_MAP = exports.SELECTED_ITEM_CLASS_NAME = void 0;
7
- var _constants = require("../../constants");
8
- const SELECTED_ITEM_CLASS_NAME = exports.SELECTED_ITEM_CLASS_NAME = 'sdoc-dropdown-item-selected';
9
- const SHORT_INSERT_ELEMENT_USER_INPUT_MAP = exports.SHORT_INSERT_ELEMENT_USER_INPUT_MAP = {
10
- [_constants.IMAGE]: 'image',
11
- [_constants.TABLE]: 'table',
12
- [_constants.LINK]: 'link',
13
- [_constants.CODE_BLOCK]: 'code block',
14
- [_constants.CALL_OUT]: 'callout',
15
- [_constants.UNORDERED_LIST]: 'unorder list',
16
- [_constants.ORDERED_LIST]: 'order list',
17
- [_constants.CHECK_LIST_ITEM]: 'check list',
18
- [_constants.PARAGRAPH]: 'paragraph',
19
- [_constants.HEADER1]: 'header 1',
20
- [_constants.HEADER2]: 'header 2',
21
- [_constants.HEADER3]: 'header 3',
22
- [_constants.HEADER4]: 'header 4',
23
- [_constants.HEADER5]: 'header 5',
24
- [_constants.HEADER6]: 'header 6',
25
- [_constants.BLOCKQUOTE]: 'quote',
26
- [_constants.MULTI_COLUMN]: 'multi_column',
27
- [_constants.COLUMN]: 'column',
28
- [_constants.TWO_COLUMN]: 'two_column',
29
- [_constants.THREE_COLUMN]: 'three_column',
30
- [_constants.FOUR_COLUMN]: 'four_column',
31
- [_constants.FIVE_COLUMN]: 'five_column',
32
- [_constants.VIDEO]: 'video'
33
- };
6
+ exports.SELECTED_ITEM_CLASS_NAME = void 0;
7
+ const SELECTED_ITEM_CLASS_NAME = exports.SELECTED_ITEM_CLASS_NAME = 'sdoc-dropdown-item-selected';
@@ -9,6 +9,8 @@ exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _slateReact = require("@seafile/slate-react");
11
11
  var _slate = require("@seafile/slate");
12
+ var _reactI18next = require("react-i18next");
13
+ var _reactstrap = require("reactstrap");
12
14
  var _helpers = require("../side-toolbar/helpers");
13
15
  var _helpers2 = require("../../plugins/table/helpers");
14
16
  var _tableSizePopover = _interopRequireDefault(require("../../plugins/table/popover/table-size-popover"));
@@ -30,14 +32,14 @@ const QuickInsertBlockMenu = _ref => {
30
32
  let {
31
33
  insertPosition,
32
34
  slateNode,
33
- searchText,
34
35
  callback,
35
- isEmptyNode
36
+ isEmptyNode,
37
+ t
36
38
  } = _ref;
37
39
  const editor = (0, _slateReact.useSlateStatic)();
38
- const [currentSelectIndex, setCurrentSelectIndex] = (0, _react.useState)(0);
39
- const renderItemListRef = (0, _react.useRef)([]);
40
40
  const downDownWrapperRef = (0, _react.useRef)(null);
41
+ const [currentSelectIndex, setCurrentSelectIndex] = (0, _react.useState)(0);
42
+ const [quickInsertMenuSearchMap, setQuickInsertMenuSearchMap] = (0, _react.useState)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP);
41
43
  const onInsertImageToggle = (0, _react.useCallback)(() => {
42
44
  callback && callback();
43
45
  const eventBus = _eventBus.default.getInstance();
@@ -145,6 +147,7 @@ const QuickInsertBlockMenu = _ref => {
145
147
  const dropDownItems = (0, _react.useMemo)(() => {
146
148
  let items = {
147
149
  [_constants.IMAGE]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
150
+ isHidden: !quickInsertMenuSearchMap[_constants.IMAGE],
148
151
  disabled: isDisableImage,
149
152
  key: "sdoc-insert-menu-image",
150
153
  menuConfig: {
@@ -153,6 +156,7 @@ const QuickInsertBlockMenu = _ref => {
153
156
  onClick: onInsertImageToggle
154
157
  }),
155
158
  [_constants.VIDEO]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
159
+ isHidden: !quickInsertMenuSearchMap[_constants.VIDEO],
156
160
  disabled: isDisableVideo,
157
161
  key: "sdoc-insert-menu-video",
158
162
  menuConfig: {
@@ -164,6 +168,7 @@ const QuickInsertBlockMenu = _ref => {
164
168
  /*#__PURE__*/
165
169
  // eslint-disable-next-line react/jsx-indent
166
170
  _react.default.createElement(_dropdownMenuItem.default, {
171
+ isHidden: !quickInsertMenuSearchMap[_constants.TABLE],
167
172
  key: "sdoc-insert-menu-tabe",
168
173
  menuConfig: {
169
174
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.TABLE]
@@ -180,6 +185,7 @@ const QuickInsertBlockMenu = _ref => {
180
185
  createTable: createTable
181
186
  })),
182
187
  [_constants.LINK]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
188
+ isHidden: !quickInsertMenuSearchMap[_constants.LINK],
183
189
  key: "sdoc-insert-menu-link",
184
190
  menuConfig: {
185
191
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.LINK]
@@ -187,6 +193,7 @@ const QuickInsertBlockMenu = _ref => {
187
193
  onClick: openLinkDialog
188
194
  }),
189
195
  [_constants.BLOCKQUOTE]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
196
+ isHidden: !quickInsertMenuSearchMap[_constants.BLOCKQUOTE],
190
197
  key: "sdoc-insert-menu-blockquote",
191
198
  menuConfig: {
192
199
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.BLOCKQUOTE]
@@ -194,6 +201,7 @@ const QuickInsertBlockMenu = _ref => {
194
201
  onClick: onInsertBlockQuote
195
202
  }),
196
203
  [_constants.CODE_BLOCK]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
204
+ isHidden: !quickInsertMenuSearchMap[_constants.CODE_BLOCK],
197
205
  key: "sdoc-insert-menu-code-block",
198
206
  menuConfig: {
199
207
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CODE_BLOCK]
@@ -201,6 +209,7 @@ const QuickInsertBlockMenu = _ref => {
201
209
  onClick: onInsertCodeBlock
202
210
  }),
203
211
  [_constants.CALL_OUT]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
212
+ isHidden: !quickInsertMenuSearchMap[_constants.CALL_OUT],
204
213
  disabled: isDisableCallout,
205
214
  key: "sdoc-insert-menu-callout",
206
215
  menuConfig: {
@@ -209,6 +218,7 @@ const QuickInsertBlockMenu = _ref => {
209
218
  onClick: () => onInsertCallout(_constants.PARAGRAPH)
210
219
  }),
211
220
  [_constants.UNORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
221
+ isHidden: !quickInsertMenuSearchMap[_constants.UNORDERED_LIST],
212
222
  key: "sdoc-insert-menu-unorder-list",
213
223
  menuConfig: {
214
224
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.UNORDERED_LIST]
@@ -218,6 +228,7 @@ const QuickInsertBlockMenu = _ref => {
218
228
  }
219
229
  }),
220
230
  [_constants.ORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
231
+ isHidden: !quickInsertMenuSearchMap[_constants.ORDERED_LIST],
221
232
  key: "sdoc-insert-menu-order-list",
222
233
  menuConfig: {
223
234
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.ORDERED_LIST]
@@ -227,6 +238,7 @@ const QuickInsertBlockMenu = _ref => {
227
238
  }
228
239
  }),
229
240
  [_constants.CHECK_LIST_ITEM]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
241
+ isHidden: !quickInsertMenuSearchMap[_constants.CHECK_LIST_ITEM],
230
242
  key: "sdoc-insert-menu-check-list",
231
243
  menuConfig: {
232
244
  ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM]
@@ -234,6 +246,7 @@ const QuickInsertBlockMenu = _ref => {
234
246
  onClick: onInsertCheckList
235
247
  }),
236
248
  [_constants.PARAGRAPH]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
249
+ isHidden: !quickInsertMenuSearchMap[_constants.PARAGRAPH],
237
250
  disabled: isEmptyNode,
238
251
  key: "sdoc-insert-menu-paragraph",
239
252
  menuConfig: {
@@ -244,6 +257,7 @@ const QuickInsertBlockMenu = _ref => {
244
257
  };
245
258
  _constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.HEADER].forEach(item => {
246
259
  items[item.id.toLowerCase()] = /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
260
+ isHidden: !quickInsertMenuSearchMap[item.type],
247
261
  key: item.id,
248
262
  menuConfig: item,
249
263
  onClick: () => onInsert(item.type)
@@ -251,6 +265,7 @@ const QuickInsertBlockMenu = _ref => {
251
265
  });
252
266
  _constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.MULTI_COLUMN].forEach(item => {
253
267
  items[item.id.toLowerCase()] = /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
268
+ isHidden: !quickInsertMenuSearchMap[item.type],
254
269
  className: "sdoc-insert-menu-multi-column",
255
270
  key: item.id,
256
271
  menuConfig: item,
@@ -258,7 +273,7 @@ const QuickInsertBlockMenu = _ref => {
258
273
  });
259
274
  });
260
275
  return items;
261
- }, [isDisableImage, isDisableVideo, onInsertImageToggle, editor, createTable, openLinkDialog, onInsertBlockQuote, onInsertCodeBlock, isDisableCallout, onInsertCheckList, isEmptyNode, onInsertCallout, onInsertList, onInsert, createMultiColumn]);
276
+ }, [isDisableImage, onInsertImageToggle, isDisableVideo, onInsertVideoToggle, editor, createTable, openLinkDialog, onInsertBlockQuote, onInsertCodeBlock, isDisableCallout, onInsertCheckList, isEmptyNode, onInsertCallout, onInsertList, onInsert, createMultiColumn, quickInsertMenuSearchMap]);
262
277
  const getSelectItemDom = selectIndex => {
263
278
  const dropDownItemWrapper = downDownWrapperRef.current;
264
279
  const currentSelectItem = dropDownItemWrapper.children[selectIndex];
@@ -321,35 +336,38 @@ const QuickInsertBlockMenu = _ref => {
321
336
  currentSelectItem.classList.add(_const.SELECTED_ITEM_CLASS_NAME);
322
337
  }
323
338
  }, [clearSelectStyle, currentSelectIndex, dropDownItems]);
324
- if (searchText) {
325
- const renderList = [];
326
- for (const key in dropDownItems) {
327
- if (Object.hasOwnProperty.call(dropDownItems, key)) {
328
- const inputText = _const.SHORT_INSERT_ELEMENT_USER_INPUT_MAP[key];
329
- if (inputText.toLowerCase().indexOf(searchText.toLowerCase()) !== -1) {
330
- renderList.push(dropDownItems[key]);
331
- }
332
- }
339
+ const onChange = (0, _react.useCallback)(e => {
340
+ if (!downDownWrapperRef.current.isInputtingChinese) {
341
+ const newMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP, true, e, t, editor);
342
+ setQuickInsertMenuSearchMap(newMenuSearchMap);
333
343
  }
334
- if (!renderList.length) {
335
- renderList.push( /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
336
- key: "sdoc-insert-menu-no-result",
337
- menuConfig: {
338
- text: 'Search_not_found'
339
- }
340
- }));
341
- }
342
- renderItemListRef.current = renderList;
343
- } else {
344
- // setRenderItemList(dropDownItems);
345
- renderItemListRef.current = Object.values(dropDownItems);
346
- }
344
+ }, [editor, t]);
345
+ const onCompositionStart = (0, _react.useCallback)(() => {
346
+ downDownWrapperRef.current.isInputtingChinese = true;
347
+ }, []);
348
+ const onCompositionEnd = (0, _react.useCallback)(e => {
349
+ downDownWrapperRef.current.isInputtingChinese = false;
350
+ onChange(e);
351
+ }, [onChange]);
347
352
  return /*#__PURE__*/_react.default.createElement("div", {
348
353
  className: "sdoc-insert-element-toolbar",
349
354
  ref: downDownWrapperRef
350
- }, renderItemListRef.current);
355
+ }, /*#__PURE__*/_react.default.createElement("div", {
356
+ className: "sdoc-side-menu-search-wrapper"
357
+ }, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
358
+ placeholder: t('Search_action'),
359
+ onChange: onChange,
360
+ onCompositionStart: onCompositionStart,
361
+ onCompositionEnd: onCompositionEnd
362
+ })), /*#__PURE__*/_react.default.createElement("div", {
363
+ className: "sdoc-insert-element-content-wrapper"
364
+ }, Object.keys(dropDownItems).map(key => {
365
+ return dropDownItems[key];
366
+ }), Object.keys(quickInsertMenuSearchMap).length === 0 && /*#__PURE__*/_react.default.createElement("div", {
367
+ className: "sdoc-dropdown-menu-item-no-results"
368
+ }, t('No_results'))));
351
369
  };
352
370
  QuickInsertBlockMenu.defaultProps = {
353
371
  insertPosition: _constants.INSERT_POSITION.CURRENT
354
372
  };
355
- var _default = exports.default = QuickInsertBlockMenu;
373
+ var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(QuickInsertBlockMenu);
@@ -1,3 +1,8 @@
1
1
  .sdoc-insert-element-toolbar .sdoc-dropdown-menu-item.sdoc-dropdown-item-selected {
2
2
  background-color: #e3e3e3;
3
3
  }
4
+
5
+ .sdoc-insert-element-toolbar .sdoc-insert-element-content-wrapper {
6
+ max-height: 278px;
7
+ overflow-y: auto;
8
+ }
@@ -248,7 +248,7 @@ const getTransformMenusConfig = (editor, slateNode) => {
248
248
  return newSideMenusConfig;
249
249
  };
250
250
  exports.getTransformMenusConfig = getTransformMenusConfig;
251
- const getSearchedOperations = (sourceMenuSearchMap, isNodeEmpty, event, t) => {
251
+ const getSearchedOperations = (sourceMenuSearchMap, isNodeEmpty, event, t, editor) => {
252
252
  let menuSearchMap = {};
253
253
  if (event.target.value.trim()) {
254
254
  Object.keys(sourceMenuSearchMap).forEach(key => {
@@ -256,6 +256,10 @@ const getSearchedOperations = (sourceMenuSearchMap, isNodeEmpty, event, t) => {
256
256
  const sourceStr = t(value).toUpperCase();
257
257
  const targetStr = event.target.value.trim().toUpperCase();
258
258
  if (sourceStr.includes(targetStr)) {
259
+ // Only the documentation plugin has this operation
260
+ if ([_constants.SEATABLE_COLUMN, _constants.SEATABLE_TABLE].includes(key) && editor.editorType !== _constants3.DOCUMENT_PLUGIN_EDITOR) {
261
+ return;
262
+ }
259
263
  menuSearchMap[key] = value;
260
264
  }
261
265
  });
@@ -183,6 +183,7 @@ const InsertBlockMenu = _ref => {
183
183
  });
184
184
  }), _constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.MULTI_COLUMN].map(item => {
185
185
  return /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
186
+ isHidden: !insertMenuSearchMap[item.type],
186
187
  key: item.id,
187
188
  menuConfig: item,
188
189
  onClick: () => createMultiColumn(item.type)
@@ -94,13 +94,13 @@ const SideMenu = (_ref, ref) => {
94
94
  const onChange = (0, _react.useCallback)(e => {
95
95
  if (!sideMenuRef.current.isInputtingChinese) {
96
96
  if (isNodeEmpty) {
97
- const newMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP, isNodeEmpty, e, t);
97
+ const newMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP, isNodeEmpty, e, t, editor);
98
98
  setInsertMenuSearchMap(newMenuSearchMap);
99
99
  }
100
100
  if (!isNodeEmpty) {
101
- const newTransformMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_TRANSFORM_MENUS_SEARCH_MAP, isNodeEmpty, e, t);
102
- const newInsertBelowMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP, isNodeEmpty, e, t);
103
- const newOtherOperationsMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP, isNodeEmpty, e, t);
101
+ const newTransformMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_TRANSFORM_MENUS_SEARCH_MAP, isNodeEmpty, e, t, editor);
102
+ const newInsertBelowMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP, isNodeEmpty, e, t, editor);
103
+ const newOtherOperationsMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP, isNodeEmpty, e, t, editor);
104
104
  setTransformMenuSearchMap(newTransformMenuSearchMap);
105
105
  setInsertBelowMenuSearchMap(newInsertBelowMenuSearchMap);
106
106
  setOtherOperatonsMenuSearchMap(newOtherOperationsMenuSearchMap);
@@ -113,7 +113,7 @@ const SideMenu = (_ref, ref) => {
113
113
  });
114
114
  }
115
115
  }
116
- }, [isNodeEmpty, t, onUpdateMenuLocation]);
116
+ }, [isNodeEmpty, t, onUpdateMenuLocation, editor]);
117
117
  const onCompositionStart = (0, _react.useCallback)(() => {
118
118
  sideMenuRef.current.isInputtingChinese = true;
119
119
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.155",
3
+ "version": "1.0.156",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",