@seafile/sdoc-editor 1.0.175 → 1.0.176-beta
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.
- package/dist/basic-sdk/extension/commons/wiki-file-insert-dialog/index.js +2 -2
- package/dist/basic-sdk/extension/constants/index.js +6 -0
- package/dist/basic-sdk/extension/constants/menus-config.js +23 -1
- package/dist/basic-sdk/extension/plugins/quick-insert/render-elem.js +6 -2
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +7 -1
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +147 -5
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.css +4 -0
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.js +94 -4
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/sample-table.js +12 -3
- package/dist/basic-sdk/extension/plugins/text-style/menu/comemnt-editor-menu.js +7 -11
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +3 -16
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +108 -78
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +31 -31
- package/dist/basic-sdk/extension/utils/index.js +29 -2
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +4 -0
- package/dist/components/doc-operations/revision-operations/revisions/index.js +13 -0
- package/dist/constants/index.js +3 -1
- package/dist/utils/index.js +13 -2
- package/package.json +1 -1
- package/public/media/sdoc-editor-font/iconfont.css +542 -0
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +16 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +38 -6
|
@@ -25,8 +25,8 @@ var _helper = require("../../plugins/callout/helper");
|
|
|
25
25
|
var _keyCodes = _interopRequireDefault(require("../../../../constants/key-codes"));
|
|
26
26
|
var _const = require("./const");
|
|
27
27
|
var _core = require("../../core");
|
|
28
|
-
var _helpers5 = require("../../plugins/blockquote/helpers");
|
|
29
28
|
var _helper2 = require("../../plugins/multi-column/helper");
|
|
29
|
+
var _utils = require("../../utils");
|
|
30
30
|
require("./style.css");
|
|
31
31
|
const QuickInsertBlockMenu = _ref => {
|
|
32
32
|
let {
|
|
@@ -34,12 +34,15 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
34
34
|
slateNode,
|
|
35
35
|
callback,
|
|
36
36
|
isEmptyNode,
|
|
37
|
+
handleClosePopover,
|
|
37
38
|
t
|
|
38
39
|
} = _ref;
|
|
39
40
|
const editor = (0, _slateReact.useSlateStatic)();
|
|
41
|
+
const tableSizeRef = (0, _react.useRef)(null);
|
|
42
|
+
const inputWrapperRef = (0, _react.useRef)(null);
|
|
40
43
|
const downDownWrapperRef = (0, _react.useRef)(null);
|
|
41
|
-
const [currentSelectIndex, setCurrentSelectIndex] = (0, _react.useState)(
|
|
42
|
-
const [quickInsertMenuSearchMap, setQuickInsertMenuSearchMap] = (0, _react.useState)(_constants.
|
|
44
|
+
const [currentSelectIndex, setCurrentSelectIndex] = (0, _react.useState)(-1); // -1 is input focus position
|
|
45
|
+
const [quickInsertMenuSearchMap, setQuickInsertMenuSearchMap] = (0, _react.useState)(_constants.SIDE_QUICK_INSERT_MENUS_SEARCH_MAP);
|
|
43
46
|
const onInsertImageToggle = (0, _react.useCallback)(() => {
|
|
44
47
|
callback && callback();
|
|
45
48
|
const eventBus = _eventBus.default.getInstance();
|
|
@@ -135,10 +138,6 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
135
138
|
});
|
|
136
139
|
return !!callout;
|
|
137
140
|
}, [editor]);
|
|
138
|
-
const onInsertBlockQuote = (0, _react.useCallback)(() => {
|
|
139
|
-
callback && callback();
|
|
140
|
-
(0, _helpers5.insertBlockQuote)(editor, false);
|
|
141
|
-
}, [callback, editor]);
|
|
142
141
|
const createMultiColumn = (0, _react.useCallback)(type => {
|
|
143
142
|
callback && callback();
|
|
144
143
|
const newInsertPosition = slateNode.type === _constants.ELEMENT_TYPE.LIST_ITEM ? _constants.INSERT_POSITION.AFTER : insertPosition;
|
|
@@ -146,49 +145,6 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
146
145
|
}, [callback, editor, insertPosition, slateNode]);
|
|
147
146
|
const dropDownItems = (0, _react.useMemo)(() => {
|
|
148
147
|
let items = {
|
|
149
|
-
[_constants.PARAGRAPH]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
150
|
-
isHidden: !quickInsertMenuSearchMap[_constants.PARAGRAPH],
|
|
151
|
-
disabled: isEmptyNode,
|
|
152
|
-
key: "sdoc-insert-menu-paragraph",
|
|
153
|
-
menuConfig: {
|
|
154
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.PARAGRAPH]
|
|
155
|
-
},
|
|
156
|
-
onClick: () => onInsert(_constants.ELEMENT_TYPE.PARAGRAPH)
|
|
157
|
-
}),
|
|
158
|
-
[_constants.ELEMENT_TYPE.HEADER]: _constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.HEADER].map(item => /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
159
|
-
isHidden: !quickInsertMenuSearchMap[item.type],
|
|
160
|
-
key: item.id,
|
|
161
|
-
menuConfig: item,
|
|
162
|
-
onClick: () => onInsert(item.type)
|
|
163
|
-
})),
|
|
164
|
-
[_constants.UNORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
165
|
-
isHidden: !quickInsertMenuSearchMap[_constants.UNORDERED_LIST],
|
|
166
|
-
key: "sdoc-insert-menu-unorder-list",
|
|
167
|
-
menuConfig: {
|
|
168
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.UNORDERED_LIST]
|
|
169
|
-
},
|
|
170
|
-
onClick: () => {
|
|
171
|
-
onInsertList(_constants.ELEMENT_TYPE.UNORDERED_LIST);
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
[_constants.ORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
175
|
-
isHidden: !quickInsertMenuSearchMap[_constants.ORDERED_LIST],
|
|
176
|
-
key: "sdoc-insert-menu-order-list",
|
|
177
|
-
menuConfig: {
|
|
178
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.ORDERED_LIST]
|
|
179
|
-
},
|
|
180
|
-
onClick: () => {
|
|
181
|
-
onInsertList(_constants.ELEMENT_TYPE.ORDERED_LIST);
|
|
182
|
-
}
|
|
183
|
-
}),
|
|
184
|
-
[_constants.CHECK_LIST_ITEM]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
185
|
-
isHidden: !quickInsertMenuSearchMap[_constants.CHECK_LIST_ITEM],
|
|
186
|
-
key: "sdoc-insert-menu-check-list",
|
|
187
|
-
menuConfig: {
|
|
188
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM]
|
|
189
|
-
},
|
|
190
|
-
onClick: onInsertCheckList
|
|
191
|
-
}),
|
|
192
148
|
[_constants.IMAGE]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
193
149
|
isHidden: !quickInsertMenuSearchMap[_constants.IMAGE],
|
|
194
150
|
disabled: isDisableImage,
|
|
@@ -220,12 +176,15 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
220
176
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
221
177
|
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
222
178
|
}), /*#__PURE__*/_react.default.createElement(_tableSizePopover.default, {
|
|
179
|
+
tableSizeRef: tableSizeRef,
|
|
223
180
|
editor: editor,
|
|
224
181
|
target: "sdoc-side-menu-item-table",
|
|
225
182
|
trigger: "hover",
|
|
226
183
|
placement: "left-start",
|
|
227
184
|
popperClassName: "sdoc-side-menu-table-size sdoc-insert-element-table-size-wrapper",
|
|
228
|
-
createTable: createTable
|
|
185
|
+
createTable: createTable,
|
|
186
|
+
callback: callback,
|
|
187
|
+
handleClosePopover: handleClosePopover
|
|
229
188
|
})),
|
|
230
189
|
[_constants.LINK]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
231
190
|
isHidden: !quickInsertMenuSearchMap[_constants.LINK],
|
|
@@ -235,14 +194,6 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
235
194
|
},
|
|
236
195
|
onClick: openLinkDialog
|
|
237
196
|
}),
|
|
238
|
-
[_constants.BLOCKQUOTE]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
239
|
-
isHidden: !quickInsertMenuSearchMap[_constants.BLOCKQUOTE],
|
|
240
|
-
key: "sdoc-insert-menu-blockquote",
|
|
241
|
-
menuConfig: {
|
|
242
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.BLOCKQUOTE]
|
|
243
|
-
},
|
|
244
|
-
onClick: onInsertBlockQuote
|
|
245
|
-
}),
|
|
246
197
|
[_constants.CODE_BLOCK]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
247
198
|
isHidden: !quickInsertMenuSearchMap[_constants.CODE_BLOCK],
|
|
248
199
|
key: "sdoc-insert-menu-code-block",
|
|
@@ -259,8 +210,53 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
259
210
|
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CALL_OUT]
|
|
260
211
|
},
|
|
261
212
|
onClick: () => onInsertCallout(_constants.PARAGRAPH)
|
|
213
|
+
}),
|
|
214
|
+
[_constants.UNORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
215
|
+
isHidden: !quickInsertMenuSearchMap[_constants.UNORDERED_LIST],
|
|
216
|
+
key: "sdoc-insert-menu-unorder-list",
|
|
217
|
+
menuConfig: {
|
|
218
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.UNORDERED_LIST]
|
|
219
|
+
},
|
|
220
|
+
onClick: () => {
|
|
221
|
+
onInsertList(_constants.ELEMENT_TYPE.UNORDERED_LIST);
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
[_constants.ORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
225
|
+
isHidden: !quickInsertMenuSearchMap[_constants.ORDERED_LIST],
|
|
226
|
+
key: "sdoc-insert-menu-order-list",
|
|
227
|
+
menuConfig: {
|
|
228
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.ORDERED_LIST]
|
|
229
|
+
},
|
|
230
|
+
onClick: () => {
|
|
231
|
+
onInsertList(_constants.ELEMENT_TYPE.ORDERED_LIST);
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
[_constants.CHECK_LIST_ITEM]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
235
|
+
isHidden: !quickInsertMenuSearchMap[_constants.CHECK_LIST_ITEM],
|
|
236
|
+
key: "sdoc-insert-menu-check-list",
|
|
237
|
+
menuConfig: {
|
|
238
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM]
|
|
239
|
+
},
|
|
240
|
+
onClick: onInsertCheckList
|
|
241
|
+
}),
|
|
242
|
+
[_constants.PARAGRAPH]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
243
|
+
isHidden: !quickInsertMenuSearchMap[_constants.PARAGRAPH],
|
|
244
|
+
disabled: isEmptyNode,
|
|
245
|
+
key: "sdoc-insert-menu-paragraph",
|
|
246
|
+
menuConfig: {
|
|
247
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.PARAGRAPH]
|
|
248
|
+
},
|
|
249
|
+
onClick: () => onInsert(_constants.ELEMENT_TYPE.PARAGRAPH)
|
|
262
250
|
})
|
|
263
251
|
};
|
|
252
|
+
_constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.HEADER].forEach(item => {
|
|
253
|
+
items[item.id.toLowerCase()] = /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
254
|
+
isHidden: !quickInsertMenuSearchMap[item.type],
|
|
255
|
+
key: item.id,
|
|
256
|
+
menuConfig: item,
|
|
257
|
+
onClick: () => onInsert(item.type)
|
|
258
|
+
});
|
|
259
|
+
});
|
|
264
260
|
_constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.MULTI_COLUMN].forEach(item => {
|
|
265
261
|
items[item.id.toLowerCase()] = /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
266
262
|
isHidden: !quickInsertMenuSearchMap[item.type],
|
|
@@ -274,19 +270,33 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
274
270
|
delete items[_constants.VIDEO];
|
|
275
271
|
}
|
|
276
272
|
return items;
|
|
277
|
-
}, [isDisableImage, onInsertImageToggle, isDisableVideo, onInsertVideoToggle, editor, createTable,
|
|
273
|
+
}, [quickInsertMenuSearchMap, isDisableImage, onInsertImageToggle, isDisableVideo, onInsertVideoToggle, editor, createTable, callback, handleClosePopover, openLinkDialog, onInsertCodeBlock, isDisableCallout, onInsertCheckList, isEmptyNode, onInsertCallout, onInsertList, onInsert, createMultiColumn]);
|
|
278
274
|
const getSelectItemDom = selectIndex => {
|
|
279
275
|
const dropDownItemWrapper = downDownWrapperRef.current;
|
|
280
|
-
const
|
|
276
|
+
const searchedDropDownItemWrapper = [];
|
|
277
|
+
Array.from(dropDownItemWrapper.children).forEach(item => {
|
|
278
|
+
if (!Array.from(item.classList).includes('sdoc-dropdown-menu-item-hidden')) {
|
|
279
|
+
searchedDropDownItemWrapper.push(item);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
const currentSelectItem = searchedDropDownItemWrapper[selectIndex];
|
|
281
283
|
return currentSelectItem;
|
|
282
284
|
};
|
|
283
285
|
const handleKeyDown = (0, _react.useCallback)(e => {
|
|
286
|
+
if (document.getElementsByClassName('sdoc-selected-table-size-popover')[0]) {
|
|
287
|
+
tableSizeRef.current.handleTableSizeKeyDown(e);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
284
290
|
const {
|
|
285
291
|
UpArrow,
|
|
286
292
|
DownArrow,
|
|
287
|
-
Enter
|
|
293
|
+
Enter,
|
|
294
|
+
Esc
|
|
288
295
|
} = _keyCodes.default;
|
|
289
|
-
const renderItems =
|
|
296
|
+
const renderItems = [];
|
|
297
|
+
Reflect.ownKeys(dropDownItems).forEach(key => {
|
|
298
|
+
if (quickInsertMenuSearchMap[key]) renderItems.push(key);
|
|
299
|
+
});
|
|
290
300
|
const {
|
|
291
301
|
keyCode
|
|
292
302
|
} = e;
|
|
@@ -294,52 +304,71 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
294
304
|
e.preventDefault();
|
|
295
305
|
const currentSelectItem = getSelectItemDom(currentSelectIndex);
|
|
296
306
|
if (currentSelectItem) currentSelectItem.classList.remove(_const.SELECTED_ITEM_CLASS_NAME);
|
|
297
|
-
if (currentSelectIndex >
|
|
307
|
+
if (currentSelectIndex > -1) {
|
|
298
308
|
setCurrentSelectIndex(currentSelectIndex - 1);
|
|
299
|
-
} else {
|
|
300
|
-
setCurrentSelectIndex(renderItems.length - 1);
|
|
301
309
|
}
|
|
302
310
|
}
|
|
303
311
|
if (keyCode === DownArrow) {
|
|
304
312
|
e.preventDefault();
|
|
313
|
+
if (currentSelectIndex === renderItems.length - 1) return;
|
|
305
314
|
const currentSelectItem = getSelectItemDom(currentSelectIndex);
|
|
306
315
|
if (currentSelectItem) currentSelectItem.classList.remove(_const.SELECTED_ITEM_CLASS_NAME);
|
|
307
316
|
if (currentSelectIndex < renderItems.length - 1) {
|
|
308
317
|
setCurrentSelectIndex(currentSelectIndex + 1);
|
|
309
|
-
} else {
|
|
310
|
-
setCurrentSelectIndex(0);
|
|
311
318
|
}
|
|
312
319
|
}
|
|
313
320
|
if (keyCode === Enter) {
|
|
314
321
|
e.preventDefault();
|
|
315
322
|
const item = renderItems[currentSelectIndex];
|
|
323
|
+
if (item === _constants.TABLE) {
|
|
324
|
+
tableSizeRef.current.uncontrolledPopoverRef.current.toggle();
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
316
327
|
const {
|
|
317
328
|
disabled,
|
|
318
329
|
onClick
|
|
319
330
|
} = dropDownItems[item].props;
|
|
320
331
|
!disabled && onClick();
|
|
321
332
|
}
|
|
322
|
-
|
|
333
|
+
if (keyCode === Esc) {
|
|
334
|
+
e.preventDefault();
|
|
335
|
+
handleClosePopover();
|
|
336
|
+
}
|
|
337
|
+
}, [currentSelectIndex, dropDownItems, handleClosePopover, quickInsertMenuSearchMap]);
|
|
323
338
|
(0, _react.useEffect)(() => {
|
|
324
339
|
document.addEventListener('keydown', handleKeyDown);
|
|
325
340
|
return () => {
|
|
326
341
|
document.removeEventListener('keydown', handleKeyDown);
|
|
327
342
|
};
|
|
343
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
328
344
|
}, [handleKeyDown]);
|
|
329
345
|
const clearSelectStyle = (0, _react.useCallback)(() => {
|
|
330
346
|
const domList = Array.from(downDownWrapperRef.current.children);
|
|
331
347
|
domList.forEach(dom => dom.classList.remove(_const.SELECTED_ITEM_CLASS_NAME));
|
|
332
348
|
}, []);
|
|
349
|
+
const onHandleInputFocus = (0, _react.useCallback)(isFocus => {
|
|
350
|
+
if (inputWrapperRef.current) {
|
|
351
|
+
queueMicrotask(() => {
|
|
352
|
+
isFocus ? inputWrapperRef.current.focus() : inputWrapperRef.current.blur();
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}, []);
|
|
333
356
|
(0, _react.useEffect)(() => {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
357
|
+
if (currentSelectIndex === -1) {
|
|
358
|
+
onHandleInputFocus(true);
|
|
359
|
+
} else {
|
|
360
|
+
onHandleInputFocus(false);
|
|
361
|
+
clearSelectStyle();
|
|
362
|
+
const currentSelectItem = getSelectItemDom(currentSelectIndex);
|
|
363
|
+
if (currentSelectItem) {
|
|
364
|
+
(0, _utils.onHandleOverflowScroll)(currentSelectItem, downDownWrapperRef);
|
|
365
|
+
currentSelectItem.classList.add(_const.SELECTED_ITEM_CLASS_NAME);
|
|
366
|
+
}
|
|
338
367
|
}
|
|
339
|
-
}, [clearSelectStyle, currentSelectIndex,
|
|
368
|
+
}, [clearSelectStyle, currentSelectIndex, downDownWrapperRef, onHandleInputFocus]);
|
|
340
369
|
const onChange = (0, _react.useCallback)(e => {
|
|
341
370
|
if (!downDownWrapperRef.current.isInputtingChinese) {
|
|
342
|
-
const newMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.
|
|
371
|
+
const newMenuSearchMap = (0, _helpers.getSearchedOperations)(_constants.SIDE_QUICK_INSERT_MENUS_SEARCH_MAP, true, e, t, editor);
|
|
343
372
|
setQuickInsertMenuSearchMap(newMenuSearchMap);
|
|
344
373
|
}
|
|
345
374
|
}, [editor, t]);
|
|
@@ -351,17 +380,18 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
351
380
|
onChange(e);
|
|
352
381
|
}, [onChange]);
|
|
353
382
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
354
|
-
className: "sdoc-insert-element-toolbar"
|
|
355
|
-
ref: downDownWrapperRef
|
|
383
|
+
className: "sdoc-insert-element-toolbar"
|
|
356
384
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
357
385
|
className: "sdoc-side-menu-search-wrapper"
|
|
358
386
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
387
|
+
innerRef: inputWrapperRef,
|
|
359
388
|
placeholder: t('Search_action'),
|
|
360
389
|
onChange: onChange,
|
|
361
390
|
onCompositionStart: onCompositionStart,
|
|
362
391
|
onCompositionEnd: onCompositionEnd
|
|
363
392
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
364
|
-
className: "sdoc-insert-element-content-wrapper"
|
|
393
|
+
className: "sdoc-insert-element-content-wrapper",
|
|
394
|
+
ref: downDownWrapperRef
|
|
365
395
|
}, Object.keys(dropDownItems).map(key => {
|
|
366
396
|
return dropDownItems[key];
|
|
367
397
|
}), Object.keys(quickInsertMenuSearchMap).length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -106,7 +106,37 @@ const InsertBlockMenu = _ref => {
|
|
|
106
106
|
const newInsertPosition = slateNode.type === _constants.ELEMENT_TYPE.LIST_ITEM ? _constants.INSERT_POSITION.AFTER : insertPosition;
|
|
107
107
|
(0, _helper2.insertMultiColumn)(editor, editor.selection, newInsertPosition, type);
|
|
108
108
|
}, [editor, insertPosition, slateNode]);
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, [_constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.PARAGRAPH], ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.HEADER]].map(item => {
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
111
|
+
isHidden: !insertMenuSearchMap[item.type],
|
|
112
|
+
disabled: isNodeEmpty && item.type === _constants.PARAGRAPH,
|
|
113
|
+
key: item.id,
|
|
114
|
+
menuConfig: item,
|
|
115
|
+
onClick: () => onInsert(item.type)
|
|
116
|
+
});
|
|
117
|
+
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
118
|
+
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.UNORDERED_LIST],
|
|
119
|
+
menuConfig: {
|
|
120
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.UNORDERED_LIST]
|
|
121
|
+
},
|
|
122
|
+
onClick: () => {
|
|
123
|
+
onInsertList(_constants.ELEMENT_TYPE.UNORDERED_LIST);
|
|
124
|
+
}
|
|
125
|
+
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
126
|
+
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.ORDERED_LIST],
|
|
127
|
+
menuConfig: {
|
|
128
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.ORDERED_LIST]
|
|
129
|
+
},
|
|
130
|
+
onClick: () => {
|
|
131
|
+
onInsertList(_constants.ELEMENT_TYPE.ORDERED_LIST);
|
|
132
|
+
}
|
|
133
|
+
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
134
|
+
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM],
|
|
135
|
+
menuConfig: {
|
|
136
|
+
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM]
|
|
137
|
+
},
|
|
138
|
+
onClick: onInsertCheckList
|
|
139
|
+
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
110
140
|
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.IMAGE],
|
|
111
141
|
menuConfig: {
|
|
112
142
|
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.IMAGE]
|
|
@@ -151,36 +181,6 @@ const InsertBlockMenu = _ref => {
|
|
|
151
181
|
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CALL_OUT]
|
|
152
182
|
},
|
|
153
183
|
onClick: () => onInsertCallout(_constants.PARAGRAPH)
|
|
154
|
-
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
155
|
-
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.UNORDERED_LIST],
|
|
156
|
-
menuConfig: {
|
|
157
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.UNORDERED_LIST]
|
|
158
|
-
},
|
|
159
|
-
onClick: () => {
|
|
160
|
-
onInsertList(_constants.ELEMENT_TYPE.UNORDERED_LIST);
|
|
161
|
-
}
|
|
162
|
-
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
163
|
-
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.ORDERED_LIST],
|
|
164
|
-
menuConfig: {
|
|
165
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.ORDERED_LIST]
|
|
166
|
-
},
|
|
167
|
-
onClick: () => {
|
|
168
|
-
onInsertList(_constants.ELEMENT_TYPE.ORDERED_LIST);
|
|
169
|
-
}
|
|
170
|
-
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
171
|
-
isHidden: !insertMenuSearchMap[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM],
|
|
172
|
-
menuConfig: {
|
|
173
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM]
|
|
174
|
-
},
|
|
175
|
-
onClick: onInsertCheckList
|
|
176
|
-
}), [_constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.PARAGRAPH], ..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.HEADER]].map(item => {
|
|
177
|
-
return /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
178
|
-
isHidden: !insertMenuSearchMap[item.type],
|
|
179
|
-
disabled: isNodeEmpty && item.type === _constants.PARAGRAPH,
|
|
180
|
-
key: item.id,
|
|
181
|
-
menuConfig: item,
|
|
182
|
-
onClick: () => onInsert(item.type)
|
|
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
186
|
isHidden: !insertMenuSearchMap[item.type],
|
|
@@ -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.isSameDomain = exports.isOverflowPortByDirection = exports.isImage = exports.IMAGE_TYPES = void 0;
|
|
7
|
+
exports.onHandleOverflowScroll = exports.isSameDomain = exports.isOverflowPortByDirection = exports.isImage = exports.IMAGE_TYPES = void 0;
|
|
8
8
|
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
9
9
|
const IMAGE_TYPES = exports.IMAGE_TYPES = ['png', 'jpg', 'gif'];
|
|
10
10
|
const isImage = url => {
|
|
@@ -41,4 +41,31 @@ const isOverflowPortByDirection = (element, direction) => {
|
|
|
41
41
|
return right >= viewWidth;
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
exports.isOverflowPortByDirection = isOverflowPortByDirection;
|
|
44
|
+
exports.isOverflowPortByDirection = isOverflowPortByDirection;
|
|
45
|
+
const onHandleOverflowScroll = (currentSelectItem, downDownWrapperRef) => {
|
|
46
|
+
const {
|
|
47
|
+
bottom: curBottom,
|
|
48
|
+
top: curTop
|
|
49
|
+
} = currentSelectItem.getBoundingClientRect();
|
|
50
|
+
const {
|
|
51
|
+
bottom: containerBottom
|
|
52
|
+
} = downDownWrapperRef.current.parentNode.getBoundingClientRect();
|
|
53
|
+
const {
|
|
54
|
+
top: containerTop
|
|
55
|
+
} = downDownWrapperRef.current.getBoundingClientRect();
|
|
56
|
+
if (curBottom > containerBottom) {
|
|
57
|
+
const scrollTop = downDownWrapperRef.current.scrollTop + 100;
|
|
58
|
+
downDownWrapperRef.current.scrollTo({
|
|
59
|
+
top: scrollTop,
|
|
60
|
+
behavior: 'smooth'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (curTop < containerTop) {
|
|
64
|
+
const scrollTop = downDownWrapperRef.current.scrollTop - 100;
|
|
65
|
+
downDownWrapperRef.current.scrollTo({
|
|
66
|
+
top: scrollTop,
|
|
67
|
+
behavior: 'smooth'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.onHandleOverflowScroll = onHandleOverflowScroll;
|
package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js
CHANGED
|
@@ -11,11 +11,14 @@ var _reactI18next = require("react-i18next");
|
|
|
11
11
|
var _reactstrap = require("reactstrap");
|
|
12
12
|
var _context = _interopRequireDefault(require("../../../../context"));
|
|
13
13
|
var _toast = _interopRequireDefault(require("../../../toast"));
|
|
14
|
+
var _basicSdk = require("../../../../basic-sdk");
|
|
15
|
+
var _constants = require("../../../../constants");
|
|
14
16
|
require("./index.css");
|
|
15
17
|
const MoreRevisionOperations = _ref => {
|
|
16
18
|
let {
|
|
17
19
|
t
|
|
18
20
|
} = _ref;
|
|
21
|
+
const eventBus = _basicSdk.EventBus.getInstance();
|
|
19
22
|
const [isDropdownOpen, setIsDropdownOpen] = (0, _react.useState)(false);
|
|
20
23
|
const toggleDropdown = (0, _react.useCallback)(isDropdownOpen => {
|
|
21
24
|
setIsDropdownOpen(!isDropdownOpen);
|
|
@@ -26,6 +29,7 @@ const MoreRevisionOperations = _ref => {
|
|
|
26
29
|
const siteRoot = _context.default.getSetting('siteRoot');
|
|
27
30
|
const revisionURL = `${siteRoot}lib/${repoID}/revisions/${res.data.revision_id}/`;
|
|
28
31
|
window.open(revisionURL, '_blank');
|
|
32
|
+
eventBus.dispatch(_constants.EXTERNAL_EVENT.NEW_REVISION);
|
|
29
33
|
}).catch(error => {
|
|
30
34
|
_toast.default.danger(t('Error'));
|
|
31
35
|
});
|
|
@@ -12,13 +12,19 @@ var _context = _interopRequireDefault(require("../../../../context"));
|
|
|
12
12
|
var _revisionsDialog = _interopRequireDefault(require("./revisions-dialog"));
|
|
13
13
|
var _utils = require("../../../../utils");
|
|
14
14
|
var _toast = _interopRequireDefault(require("../../../toast"));
|
|
15
|
+
var _basicSdk = require("../../../../basic-sdk");
|
|
16
|
+
var _constants = require("../../../../constants");
|
|
15
17
|
require("./index.css");
|
|
16
18
|
const Revisions = () => {
|
|
19
|
+
const eventBus = _basicSdk.EventBus.getInstance();
|
|
17
20
|
const {
|
|
18
21
|
t
|
|
19
22
|
} = (0, _reactI18next.useTranslation)();
|
|
20
23
|
const [revisionsCount, setRevisionsCount] = (0, _react.useState)(0);
|
|
21
24
|
const [isShowRevisions, setShowRevisions] = (0, _react.useState)(false);
|
|
25
|
+
const autoIncrementRevisionsCount = (0, _react.useCallback)(() => {
|
|
26
|
+
setShowRevisions(revisionsCount + 1);
|
|
27
|
+
}, [revisionsCount]);
|
|
22
28
|
|
|
23
29
|
// did mount
|
|
24
30
|
(0, _react.useEffect)(() => {
|
|
@@ -32,6 +38,13 @@ const Revisions = () => {
|
|
|
32
38
|
|
|
33
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
40
|
}, []);
|
|
41
|
+
(0, _react.useEffect)(() => {
|
|
42
|
+
const autoIncrementRevisionSubscribe = eventBus.subscribe(_constants.EXTERNAL_EVENT.NEW_REVISION, autoIncrementRevisionsCount);
|
|
43
|
+
return () => {
|
|
44
|
+
autoIncrementRevisionSubscribe();
|
|
45
|
+
};
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
}, [autoIncrementRevisionsCount]);
|
|
35
48
|
const showRevisions = (0, _react.useCallback)(() => {
|
|
36
49
|
setShowRevisions(true);
|
|
37
50
|
}, []);
|
package/dist/constants/index.js
CHANGED
|
@@ -40,7 +40,9 @@ const EXTERNAL_EVENT = exports.EXTERNAL_EVENT = {
|
|
|
40
40
|
INSERT_LINK: 'insert_link',
|
|
41
41
|
// document
|
|
42
42
|
COLLABORATORS_UPDATED: 'collaborators_updated',
|
|
43
|
-
IMAGE_COLUMN_TOGGLE: 'Image_column_toggle'
|
|
43
|
+
IMAGE_COLUMN_TOGGLE: 'Image_column_toggle',
|
|
44
|
+
// revise
|
|
45
|
+
NEW_REVISION: 'new_revision'
|
|
44
46
|
};
|
|
45
47
|
const TIP_TYPE = exports.TIP_TYPE = {
|
|
46
48
|
DELETE_NO_CHANGES_REVISION: 'delete_no_changes_revision',
|
package/dist/utils/index.js
CHANGED
|
@@ -25,7 +25,7 @@ Object.defineProperty(exports, "getEventTransfer", {
|
|
|
25
25
|
return _getEventTransfer.default;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
exports.resetWebTitle = exports.isMobile = exports.isMac = exports.isEnglish = exports.getSelectionCoords = exports.getMaximumCapacity = exports.getImageFileNameWithTimestamp = void 0;
|
|
28
|
+
exports.resetWebTitle = exports.isMobile = exports.isMac = exports.isEnglish = exports.getSelectionCoords = exports.getMaximumCapacity = exports.getLocalStorageFiles = exports.getImageFileNameWithTimestamp = void 0;
|
|
29
29
|
var _dateUtils = _interopRequireDefault(require("./date-utils"));
|
|
30
30
|
var _localStorageUtils = _interopRequireDefault(require("./local-storage-utils"));
|
|
31
31
|
var _context = _interopRequireDefault(require("../context"));
|
|
@@ -170,4 +170,15 @@ const getMaximumCapacity = files => {
|
|
|
170
170
|
});
|
|
171
171
|
return newFiles;
|
|
172
172
|
};
|
|
173
|
-
exports.getMaximumCapacity = getMaximumCapacity;
|
|
173
|
+
exports.getMaximumCapacity = getMaximumCapacity;
|
|
174
|
+
const getLocalStorageFiles = files => {
|
|
175
|
+
const wikiRepoId = window.wiki.config.wikiId;
|
|
176
|
+
const newFiles = [];
|
|
177
|
+
files.forEach(item => {
|
|
178
|
+
if ((item === null || item === void 0 ? void 0 : item.wikiRepoId) === wikiRepoId) {
|
|
179
|
+
newFiles.push(item);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return newFiles;
|
|
183
|
+
};
|
|
184
|
+
exports.getLocalStorageFiles = getLocalStorageFiles;
|