@seafile/sdoc-editor 1.0.126 → 1.0.128
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/assets/css/dropdown-menu.css +10 -0
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +2 -2
- package/dist/basic-sdk/comment/components/global-comment/global-comment-editor.js +2 -1
- package/dist/basic-sdk/comment/components/global-comment/index.css +5 -1
- package/dist/basic-sdk/comment/components/global-comment/index.js +36 -26
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +3 -2
- package/dist/basic-sdk/extension/constants/index.js +6 -0
- package/dist/basic-sdk/extension/constants/menus-config.js +10 -6
- package/dist/basic-sdk/extension/plugins/html/plugin.js +0 -36
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +1 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +2 -2
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +1 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +67 -25
- package/package.json +1 -1
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
align-items: center;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
.sdoc-dropdown-menu .sdoc-dropdown-menu-item-title {
|
|
32
|
+
color: #666666;
|
|
33
|
+
padding: 3px 12px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sdoc-dropdown-menu .sdoc-dropdown-menu-item-title:hover {
|
|
37
|
+
background-color: unset !important;
|
|
38
|
+
cursor: initial !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
.sdoc-dropdown-menu .sdoc-dropdown-menu-item-no-results {
|
|
32
42
|
height: 30px;
|
|
33
43
|
width: 100%;
|
|
@@ -27,7 +27,7 @@ const CommentItemWrapper = _ref => {
|
|
|
27
27
|
isActive,
|
|
28
28
|
comment,
|
|
29
29
|
isGlobalComment,
|
|
30
|
-
|
|
30
|
+
commentDetailRef,
|
|
31
31
|
updateScrollPosition,
|
|
32
32
|
hiddenComment,
|
|
33
33
|
setCurrentCommentGroup,
|
|
@@ -197,7 +197,7 @@ const CommentItemWrapper = _ref => {
|
|
|
197
197
|
replies.push(reply);
|
|
198
198
|
insertReply(comment.id, replies);
|
|
199
199
|
}, [comment.id, comment.resolved, insertReply]);
|
|
200
|
-
(0, _react.useImperativeHandle)(
|
|
200
|
+
(0, _react.useImperativeHandle)(commentDetailRef, () => ({
|
|
201
201
|
insertContent
|
|
202
202
|
}));
|
|
203
203
|
const deleteReply = (0, _react.useCallback)(async replyId => {
|
|
@@ -12,6 +12,7 @@ const GlobalCommentEditor = _ref => {
|
|
|
12
12
|
let {
|
|
13
13
|
isScrollDisplayed,
|
|
14
14
|
globalCommentContent,
|
|
15
|
+
type,
|
|
15
16
|
insertDocComment,
|
|
16
17
|
hiddenCommentEditor,
|
|
17
18
|
updateGlobalCommentContent
|
|
@@ -23,7 +24,7 @@ const GlobalCommentEditor = _ref => {
|
|
|
23
24
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
24
25
|
className: "comment-ui-container active"
|
|
25
26
|
}, /*#__PURE__*/_react.default.createElement(_commentEditor.default, {
|
|
26
|
-
type:
|
|
27
|
+
type: type,
|
|
27
28
|
className: "sdoc-doc-comment-editor",
|
|
28
29
|
globalCommentContent: globalCommentContent,
|
|
29
30
|
hiddenUserInfo: true,
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
display: flex;
|
|
118
118
|
flex-direction: column;
|
|
119
119
|
padding-top: 0px;
|
|
120
|
-
margin-bottom:
|
|
120
|
+
margin-bottom: 16px;
|
|
121
121
|
overflow: auto;
|
|
122
122
|
border-bottom: 1px solid #e1e2e5;
|
|
123
123
|
}
|
|
@@ -194,6 +194,10 @@
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/* custom */
|
|
197
|
+
.sdoc-comment-drawer .sdoc-comment-list-container {
|
|
198
|
+
margin-top: 0px;
|
|
199
|
+
}
|
|
200
|
+
|
|
197
201
|
.sdoc-comment-drawer .sdoc-comment-list-container .comment-ui-container {
|
|
198
202
|
background-color: #FFF;
|
|
199
203
|
margin-bottom: 0px;
|
|
@@ -28,8 +28,8 @@ const GlobalComment = _ref => {
|
|
|
28
28
|
deleteUnseenNotifications,
|
|
29
29
|
t
|
|
30
30
|
} = _ref;
|
|
31
|
-
const commentRef = (0, _react.useRef)(null);
|
|
32
31
|
const contentRef = (0, _react.useRef)(null);
|
|
32
|
+
const commentDetailRef = (0, _react.useRef)(null);
|
|
33
33
|
const {
|
|
34
34
|
closePlugin
|
|
35
35
|
} = (0, _hooks.usePlugins)();
|
|
@@ -49,13 +49,20 @@ const GlobalComment = _ref => {
|
|
|
49
49
|
const isShowScroll = contentContainer.scrollHeight > contentContainer.clientHeight;
|
|
50
50
|
setIsScrollDisplayed(isShowScroll);
|
|
51
51
|
}, []);
|
|
52
|
+
const onCommentsPanelBodyScroll = (0, _react.useCallback)(position => {
|
|
53
|
+
var _contentRef$current, _contentRef$current2;
|
|
54
|
+
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.scrollTo({
|
|
55
|
+
top: position === 'top' ? 0 : (_contentRef$current2 = contentRef.current) === null || _contentRef$current2 === void 0 ? void 0 : _contentRef$current2.scrollHeight,
|
|
56
|
+
behavior: 'smooth'
|
|
57
|
+
});
|
|
58
|
+
}, [contentRef]);
|
|
52
59
|
(0, _react.useEffect)(() => {
|
|
53
60
|
detectScroll();
|
|
54
61
|
}, [commentList, detectScroll]);
|
|
55
62
|
const updateScrollPosition = (0, _react.useCallback)(() => {
|
|
56
|
-
var _contentRef$
|
|
63
|
+
var _contentRef$current3;
|
|
57
64
|
const resolvedDom = document.querySelector('.sdoc-resolved');
|
|
58
|
-
(_contentRef$
|
|
65
|
+
(_contentRef$current3 = contentRef.current) === null || _contentRef$current3 === void 0 ? void 0 : _contentRef$current3.scrollTo({
|
|
59
66
|
top: resolvedDom.offsetTop,
|
|
60
67
|
behavior: 'smooth'
|
|
61
68
|
});
|
|
@@ -81,29 +88,32 @@ const GlobalComment = _ref => {
|
|
|
81
88
|
});
|
|
82
89
|
}, [dispatch]);
|
|
83
90
|
const insertDocComment = (0, _react.useCallback)(commentDetail => {
|
|
84
|
-
var
|
|
91
|
+
var _commentDetailRef$cur;
|
|
85
92
|
// Reply to a comment
|
|
86
|
-
if (activeCommentGroup && (
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
if (activeCommentGroup && (_commentDetailRef$cur = commentDetailRef.current) !== null && _commentDetailRef$cur !== void 0 && _commentDetailRef$cur.insertContent) {
|
|
94
|
+
commentDetailRef.current.insertContent(commentDetail);
|
|
95
|
+
} else {
|
|
96
|
+
// Insert global comment
|
|
97
|
+
const user = _context.default.getUserInfo();
|
|
98
|
+
const elementId = _constants.DOC_COMMENT_ELEMENT_ID;
|
|
99
|
+
const time = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
|
|
100
|
+
const comment = {
|
|
101
|
+
comment: commentDetail,
|
|
102
|
+
detail: {
|
|
103
|
+
element_id: elementId,
|
|
104
|
+
comment: commentDetail
|
|
105
|
+
},
|
|
106
|
+
author: user.username,
|
|
107
|
+
updated_at: time
|
|
108
|
+
};
|
|
109
|
+
insertComment(elementId, comment);
|
|
110
|
+
detectScroll();
|
|
89
111
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const comment = {
|
|
96
|
-
comment: commentDetail,
|
|
97
|
-
detail: {
|
|
98
|
-
element_id: elementId,
|
|
99
|
-
comment: commentDetail
|
|
100
|
-
},
|
|
101
|
-
author: user.username,
|
|
102
|
-
updated_at: time
|
|
103
|
-
};
|
|
104
|
-
insertComment(elementId, comment);
|
|
105
|
-
detectScroll();
|
|
106
|
-
}, [activeCommentGroup, detectScroll, insertComment]);
|
|
112
|
+
// After the comment is inserted, scroll to the bottom
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
onCommentsPanelBodyScroll('bottom');
|
|
115
|
+
}, 500);
|
|
116
|
+
}, [activeCommentGroup, detectScroll, insertComment, onCommentsPanelBodyScroll]);
|
|
107
117
|
const hiddenCommentEditor = (0, _react.useCallback)(() => {
|
|
108
118
|
setShowEditor(false);
|
|
109
119
|
}, []);
|
|
@@ -130,7 +140,6 @@ const GlobalComment = _ref => {
|
|
|
130
140
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
131
141
|
className: "sdoc-comment-drawer"
|
|
132
142
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
133
|
-
ref: commentRef,
|
|
134
143
|
className: "comments-panel-wrapper"
|
|
135
144
|
}, /*#__PURE__*/_react.default.createElement(_globalCommentHeader.default, {
|
|
136
145
|
toggle: closePlugin,
|
|
@@ -168,7 +177,7 @@ const GlobalComment = _ref => {
|
|
|
168
177
|
editor: editor,
|
|
169
178
|
element: getNodeByElementId(activeCommentGroup.detail.element_id),
|
|
170
179
|
container: "global-comment-list-container",
|
|
171
|
-
|
|
180
|
+
commentDetailRef: commentDetailRef,
|
|
172
181
|
comment: activeCommentGroup,
|
|
173
182
|
isGlobalComment: true,
|
|
174
183
|
isActive: true,
|
|
@@ -189,6 +198,7 @@ const GlobalComment = _ref => {
|
|
|
189
198
|
}), showEditor && /*#__PURE__*/_react.default.createElement(_globalCommentEditor.default, {
|
|
190
199
|
globalCommentContent: globalCommentContent,
|
|
191
200
|
isScrollDisplayed: isScrollDisplayed,
|
|
201
|
+
type: activeCommentGroup ? 'replay' : 'comment',
|
|
192
202
|
hiddenCommentEditor: hiddenCommentEditor,
|
|
193
203
|
insertDocComment: insertDocComment,
|
|
194
204
|
updateGlobalCommentContent: content => {
|
|
@@ -43,9 +43,10 @@ exports.initElementCommentsMap = initElementCommentsMap;
|
|
|
43
43
|
const initCommentList = comments => {
|
|
44
44
|
// format comments
|
|
45
45
|
const formatComments = formatCommentsData(comments);
|
|
46
|
+
return formatComments;
|
|
46
47
|
|
|
47
48
|
// sort comments by update time
|
|
48
|
-
return sortCommentList(formatComments);
|
|
49
|
+
// return sortCommentList(formatComments);
|
|
49
50
|
};
|
|
50
51
|
exports.initCommentList = initCommentList;
|
|
51
52
|
const sortCommentList = commentList => {
|
|
@@ -125,7 +126,7 @@ const commentReducer = (state, action) => {
|
|
|
125
126
|
element_comments_map[element_id] = [];
|
|
126
127
|
}
|
|
127
128
|
element_comments_map[element_id] = [...element_comments_map[element_id], comment];
|
|
128
|
-
const commentList = [(0, _deepCopy.default)(comment)
|
|
129
|
+
const commentList = [...comment_list, (0, _deepCopy.default)(comment)];
|
|
129
130
|
return {
|
|
130
131
|
...state,
|
|
131
132
|
element_comments_map: {
|
|
@@ -331,6 +331,12 @@ Object.defineProperty(exports, "SIDE_INSERT_MENUS_SEARCH_MAP", {
|
|
|
331
331
|
return _menusConfig.SIDE_INSERT_MENUS_SEARCH_MAP;
|
|
332
332
|
}
|
|
333
333
|
});
|
|
334
|
+
Object.defineProperty(exports, "SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP", {
|
|
335
|
+
enumerable: true,
|
|
336
|
+
get: function () {
|
|
337
|
+
return _menusConfig.SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
334
340
|
Object.defineProperty(exports, "SIDE_TRANSFORM_MENUS_CONFIG", {
|
|
335
341
|
enumerable: true,
|
|
336
342
|
get: function () {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNDO = exports.TEXT_STYLE_MORE = exports.TEXT_STYLE_MAP = exports.TEXT_STYLE = exports.TEXT_ALIGN = exports.SIDE_TRANSFORM_MENUS_SEARCH_MAP = exports.SIDE_TRANSFORM_MENUS_CONFIG = exports.SIDE_INSERT_MENUS_SEARCH_MAP = exports.SIDE_INSERT_MENUS_CONFIG = exports.SEARCH_REPLACE = exports.REMOVE_TABLE = exports.REDO = exports.MENUS_CONFIG_MAP = exports.ITALIC = exports.COMBINE_CELL = exports.CLEAR_FORMAT = exports.BOLD = void 0;
|
|
6
|
+
exports.UNDO = exports.TEXT_STYLE_MORE = exports.TEXT_STYLE_MAP = exports.TEXT_STYLE = exports.TEXT_ALIGN = exports.SIDE_TRANSFORM_MENUS_SEARCH_MAP = exports.SIDE_TRANSFORM_MENUS_CONFIG = exports.SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP = exports.SIDE_INSERT_MENUS_SEARCH_MAP = exports.SIDE_INSERT_MENUS_CONFIG = exports.SEARCH_REPLACE = exports.REMOVE_TABLE = exports.REDO = exports.MENUS_CONFIG_MAP = exports.ITALIC = exports.COMBINE_CELL = exports.CLEAR_FORMAT = exports.BOLD = void 0;
|
|
7
7
|
var _color = require("./color");
|
|
8
8
|
var _elementType = require("./element-type");
|
|
9
9
|
const UNDO = exports.UNDO = 'undo';
|
|
@@ -297,11 +297,7 @@ const SIDE_TRANSFORM_MENUS_SEARCH_MAP = exports.SIDE_TRANSFORM_MENUS_SEARCH_MAP
|
|
|
297
297
|
[_elementType.ORDERED_LIST]: 'Ordered_list',
|
|
298
298
|
[_elementType.CHECK_LIST_ITEM]: 'Check_list',
|
|
299
299
|
[_elementType.BLOCKQUOTE]: 'Quote',
|
|
300
|
-
[_elementType.CALL_OUT]: 'Callout'
|
|
301
|
-
'COPY_LINK_OF_SECTION': 'Copy_link_of_section',
|
|
302
|
-
'COPY': 'Copy',
|
|
303
|
-
'CUT': 'Cut',
|
|
304
|
-
'DELETE': 'Delete'
|
|
300
|
+
[_elementType.CALL_OUT]: 'Callout'
|
|
305
301
|
};
|
|
306
302
|
|
|
307
303
|
// Side insert menu config
|
|
@@ -403,4 +399,12 @@ const SIDE_INSERT_MENUS_SEARCH_MAP = exports.SIDE_INSERT_MENUS_SEARCH_MAP = {
|
|
|
403
399
|
[_elementType.HEADER4]: 'Header_four',
|
|
404
400
|
[_elementType.COLUMN]: 'SeaTable_column',
|
|
405
401
|
[_elementType.SEATABLE_TABLE]: 'SeaTable_table'
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// Other operations menu config
|
|
405
|
+
const SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP = exports.SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP = {
|
|
406
|
+
'COPY_LINK_OF_SECTION': 'Copy_link_of_section',
|
|
407
|
+
'COPY': 'Copy',
|
|
408
|
+
'CUT': 'Cut',
|
|
409
|
+
'DELETE': 'Delete'
|
|
406
410
|
};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
9
|
-
var _slate = require("@seafile/slate");
|
|
10
9
|
var _helper = require("./helper");
|
|
11
10
|
var _core = require("../../core");
|
|
12
11
|
var _constants = require("../../constants");
|
|
@@ -43,41 +42,6 @@ const withHtml = editor => {
|
|
|
43
42
|
editor.insertFragment(content);
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
// Paste AI code as code blcok type
|
|
48
|
-
if (data.types[0].includes('text/plain') && data.types.length === 1) {
|
|
49
|
-
const pastedCode = data.getData('text/plain') || '';
|
|
50
|
-
if (pastedCode && pastedCode.trim() !== '') {
|
|
51
|
-
const fragmentData = {
|
|
52
|
-
id: _slugid.default.nice(),
|
|
53
|
-
language: 'plaintext',
|
|
54
|
-
type: _constants.CODE_BLOCK,
|
|
55
|
-
children: pastedCode.split('\n').map(text => ({
|
|
56
|
-
id: _slugid.default.nice(),
|
|
57
|
-
type: _constants.CODE_LINE,
|
|
58
|
-
children: [{
|
|
59
|
-
id: _slugid.default.nice(),
|
|
60
|
-
text: text
|
|
61
|
-
}]
|
|
62
|
-
}))
|
|
63
|
-
};
|
|
64
|
-
const string = _slate.Editor.string(newEditor, newEditor.selection.focus.path);
|
|
65
|
-
if (string.length === 0) {
|
|
66
|
-
_slate.Transforms.insertNodes(newEditor, fragmentData, {
|
|
67
|
-
at: newEditor.selection.focus.path
|
|
68
|
-
});
|
|
69
|
-
const paragraph = (0, _core.generateEmptyElement)(_constants.PARAGRAPH);
|
|
70
|
-
_slate.Transforms.insertNodes(newEditor, paragraph, {
|
|
71
|
-
at: [newEditor.selection.focus.path[0] + 1]
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
_slate.Transforms.insertNodes(newEditor, fragmentData, {
|
|
75
|
-
at: newEditor.selection
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
45
|
insertData(data);
|
|
82
46
|
}
|
|
83
47
|
};
|
|
@@ -38,7 +38,7 @@ const Paragraph = _ref => {
|
|
|
38
38
|
const node = editor.children[1];
|
|
39
39
|
isShowPlaceHolder = _slate.Node.string(element) === '' && (node === null || node === void 0 ? void 0 : node.id) === (element === null || element === void 0 ? void 0 : element.id) && !isComposing;
|
|
40
40
|
}
|
|
41
|
-
if (isSelected && _slate.Range.isCollapsed(editor.selection) && (0, _helper.isEmptyNode)(element) && _slateReact.ReactEditor.findPath(editor, element).length === 1 && !isComposing) {
|
|
41
|
+
if (!isCommentEditor && isSelected && _slate.Range.isCollapsed(editor.selection) && (0, _helper.isEmptyNode)(element) && _slateReact.ReactEditor.findPath(editor, element).length === 1 && !isComposing) {
|
|
42
42
|
isShowPlaceHolder = true;
|
|
43
43
|
}
|
|
44
44
|
const style = {
|
|
@@ -262,12 +262,12 @@ const getSearchedOperations = (sourceMenuSearchMap, isNodeEmpty, event, t) => {
|
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
if (!isNodeEmpty) {
|
|
265
|
-
menuSearchMap['
|
|
265
|
+
menuSearchMap['searching'] = true; // Used to identify the search for Transform menu list
|
|
266
266
|
}
|
|
267
267
|
} else {
|
|
268
268
|
menuSearchMap = sourceMenuSearchMap;
|
|
269
269
|
if (!isNodeEmpty) {
|
|
270
|
-
menuSearchMap['
|
|
270
|
+
menuSearchMap['searching'] = false;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
return menuSearchMap;
|
|
@@ -168,7 +168,7 @@ const InsertBlockMenu = _ref => {
|
|
|
168
168
|
editor: editor,
|
|
169
169
|
readonly: editor.readonly,
|
|
170
170
|
insertPosition: insertPosition
|
|
171
|
-
}), Object.keys(insertMenuSearchMap).length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
171
|
+
}), isNodeEmpty && Object.keys(insertMenuSearchMap).length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
172
172
|
className: "sdoc-dropdown-menu-item-no-results"
|
|
173
173
|
}, t('No_results')));
|
|
174
174
|
};
|
|
@@ -34,6 +34,8 @@ const SideMenu = (_ref, ref) => {
|
|
|
34
34
|
const [menuStyle, setMenuStyle] = (0, _react.useState)('');
|
|
35
35
|
const [insertMenuSearchMap, setInsertMenuSearchMap] = (0, _react.useState)();
|
|
36
36
|
const [transformMenuSearchMap, setTransformMenuSearchMap] = (0, _react.useState)(_constants.SIDE_TRANSFORM_MENUS_SEARCH_MAP);
|
|
37
|
+
const [insertBelowMenuSearchMap, setInsertBelowMenuSearchMap] = (0, _react.useState)(_constants.SIDE_INSERT_MENUS_SEARCH_MAP);
|
|
38
|
+
const [otherOperatonsMenuSearchMap, setOtherOperatonsMenuSearchMap] = (0, _react.useState)(_constants.SIDE_OTHER_OPERATIONS_MENUS_SEARCH_MAP);
|
|
37
39
|
const editor = (0, _slateReact.useSlateStatic)();
|
|
38
40
|
(0, _react.useEffect)(() => {
|
|
39
41
|
const eventBus = _eventBus.default.getInstance();
|
|
@@ -65,7 +67,7 @@ const SideMenu = (_ref, ref) => {
|
|
|
65
67
|
});
|
|
66
68
|
onReset();
|
|
67
69
|
}, [onReset, slateNode.id, t]);
|
|
68
|
-
(0, _react.
|
|
70
|
+
const onUpdateMenuLocation = (0, _react.useCallback)(() => {
|
|
69
71
|
let top = menuPosition.top;
|
|
70
72
|
if (sideMenuRef.current) {
|
|
71
73
|
const overflowY = menuPosition.top + sideMenuRef.current.offsetHeight - document.body.clientHeight;
|
|
@@ -74,6 +76,9 @@ const SideMenu = (_ref, ref) => {
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
setMenuStyle(`top: ${top}px; left: ${menuPosition.left}px`);
|
|
79
|
+
}, [menuPosition.left, menuPosition.top]);
|
|
80
|
+
(0, _react.useEffect)(() => {
|
|
81
|
+
onUpdateMenuLocation();
|
|
77
82
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
83
|
}, [menuPosition, sideMenuRef.current]);
|
|
79
84
|
(0, _react.useImperativeHandle)(ref, () => {
|
|
@@ -93,11 +98,22 @@ const SideMenu = (_ref, ref) => {
|
|
|
93
98
|
setInsertMenuSearchMap(newMenuSearchMap);
|
|
94
99
|
}
|
|
95
100
|
if (!isNodeEmpty) {
|
|
96
|
-
const
|
|
97
|
-
|
|
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);
|
|
104
|
+
setTransformMenuSearchMap(newTransformMenuSearchMap);
|
|
105
|
+
setInsertBelowMenuSearchMap(newInsertBelowMenuSearchMap);
|
|
106
|
+
setOtherOperatonsMenuSearchMap(newOtherOperationsMenuSearchMap);
|
|
107
|
+
queueMicrotask(() => {
|
|
108
|
+
var _sideMenuRef$current;
|
|
109
|
+
// Search content exceeds original height, The original container height is 249
|
|
110
|
+
if (((_sideMenuRef$current = sideMenuRef.current) === null || _sideMenuRef$current === void 0 ? void 0 : _sideMenuRef$current.offsetHeight) > 249) {
|
|
111
|
+
onUpdateMenuLocation();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
98
114
|
}
|
|
99
115
|
}
|
|
100
|
-
}, [t,
|
|
116
|
+
}, [isNodeEmpty, t, onUpdateMenuLocation]);
|
|
101
117
|
const onCompositionStart = (0, _react.useCallback)(() => {
|
|
102
118
|
sideMenuRef.current.isInputtingChinese = true;
|
|
103
119
|
}, []);
|
|
@@ -105,13 +121,21 @@ const SideMenu = (_ref, ref) => {
|
|
|
105
121
|
sideMenuRef.current.isInputtingChinese = false;
|
|
106
122
|
onChange(e);
|
|
107
123
|
}, [onChange]);
|
|
124
|
+
const isDisplayCategoryTitle = (0, _react.useCallback)((sourceMap, targetMap) => {
|
|
125
|
+
const keys = Object.keys(sourceMap);
|
|
126
|
+
if (keys.length > 1) {
|
|
127
|
+
const index = keys.findIndex(key => key !== 'searching' && sourceMap[key] === targetMap[key]);
|
|
128
|
+
return index !== -1 ? true : false;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}, []);
|
|
108
132
|
return /*#__PURE__*/_react.default.createElement(_commons.ElementPopover, {
|
|
109
133
|
className: "sdoc-side-menu-popover",
|
|
110
134
|
style: menuStyle
|
|
111
135
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
112
136
|
className: "sdoc-side-menu sdoc-dropdown-menu",
|
|
113
137
|
ref: sideMenuRef
|
|
114
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
138
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
115
139
|
className: "sdoc-side-menu-search-wrapper"
|
|
116
140
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
117
141
|
autoFocus: true,
|
|
@@ -119,7 +143,23 @@ const SideMenu = (_ref, ref) => {
|
|
|
119
143
|
onChange: onChange,
|
|
120
144
|
onCompositionStart: onCompositionStart,
|
|
121
145
|
onCompositionEnd: onCompositionEnd
|
|
122
|
-
})),
|
|
146
|
+
})), isNodeEmpty && /*#__PURE__*/_react.default.createElement(_insertBlockMenu.default, {
|
|
147
|
+
isNodeEmpty: isNodeEmpty,
|
|
148
|
+
slateNode: slateNode,
|
|
149
|
+
insertMenuSearchMap: insertMenuSearchMap
|
|
150
|
+
}), !isNodeEmpty && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, transformMenuSearchMap['searching'] && isDisplayCategoryTitle(transformMenuSearchMap, insertBelowMenuSearchMap) && /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
151
|
+
menuConfig: {
|
|
152
|
+
text: 'Transform_to'
|
|
153
|
+
},
|
|
154
|
+
className: "pr-2 sdoc-dropdown-menu-item-title"
|
|
155
|
+
}), transformMenuSearchMap['searching'] && (0, _helpers.getTransformMenusConfig)(editor, slateNode).map(item => {
|
|
156
|
+
return /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
157
|
+
isHidden: !transformMenuSearchMap[item.type],
|
|
158
|
+
key: item.id,
|
|
159
|
+
menuConfig: item,
|
|
160
|
+
onClick: () => onSetType(item.type)
|
|
161
|
+
});
|
|
162
|
+
}), !transformMenuSearchMap['searching'] && !(0, _helpers.isNotSupportTransform)(slateNode) && /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
123
163
|
menuConfig: {
|
|
124
164
|
id: 'sdoc-side-menu-item-transform',
|
|
125
165
|
text: 'Transform_to',
|
|
@@ -133,31 +173,29 @@ const SideMenu = (_ref, ref) => {
|
|
|
133
173
|
slateNode: slateNode,
|
|
134
174
|
editor: editor,
|
|
135
175
|
onSetType: onSetType
|
|
136
|
-
}))
|
|
137
|
-
|
|
176
|
+
})), insertBelowMenuSearchMap['searching'] && isDisplayCategoryTitle(insertBelowMenuSearchMap, transformMenuSearchMap) && /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
177
|
+
menuConfig: {
|
|
178
|
+
text: 'Insert_below'
|
|
179
|
+
},
|
|
180
|
+
className: "pr-2 sdoc-dropdown-menu-item-title"
|
|
181
|
+
}), insertBelowMenuSearchMap['searching'] && /*#__PURE__*/_react.default.createElement(_insertBlockMenu.default, {
|
|
182
|
+
insertPosition: _constants.INSERT_POSITION.AFTER,
|
|
138
183
|
slateNode: slateNode,
|
|
139
|
-
insertMenuSearchMap:
|
|
140
|
-
}),
|
|
184
|
+
insertMenuSearchMap: insertBelowMenuSearchMap
|
|
185
|
+
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
141
186
|
menuConfig: {
|
|
142
187
|
id: 'sdoc-side-menu-item-insert-below',
|
|
143
188
|
text: 'Insert_below',
|
|
144
189
|
iconClass: 'sdocfont sdoc-insert'
|
|
145
190
|
},
|
|
146
191
|
className: "pr-2 sdoc-dropdown-menu-item-relative",
|
|
147
|
-
isHidden:
|
|
192
|
+
isHidden: insertBelowMenuSearchMap['searching']
|
|
148
193
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
149
194
|
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
150
195
|
}), /*#__PURE__*/_react.default.createElement(_insertBelowMenu.default, {
|
|
151
196
|
target: "sdoc-side-menu-item-insert-below",
|
|
152
197
|
slateNode: slateNode
|
|
153
|
-
})),
|
|
154
|
-
return /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
155
|
-
isHidden: !transformMenuSearchMap[item.type],
|
|
156
|
-
key: item.id,
|
|
157
|
-
menuConfig: item,
|
|
158
|
-
onClick: () => onSetType(item.type)
|
|
159
|
-
});
|
|
160
|
-
}), !transformMenuSearchMap['searchingForTransformMenu'] && /*#__PURE__*/_react.default.createElement("div", {
|
|
198
|
+
})), !insertBelowMenuSearchMap['searching'] && /*#__PURE__*/_react.default.createElement("div", {
|
|
161
199
|
className: "sdoc-dropdown-menu-divider"
|
|
162
200
|
}), [_constants.HEADER1, _constants.HEADER2, _constants.HEADER3].includes(slateNode === null || slateNode === void 0 ? void 0 : slateNode.type) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
163
201
|
menuConfig: {
|
|
@@ -165,8 +203,8 @@ const SideMenu = (_ref, ref) => {
|
|
|
165
203
|
iconClass: 'sdocfont sdoc-link'
|
|
166
204
|
},
|
|
167
205
|
onClick: onCopyHeaderLink,
|
|
168
|
-
isHidden: !
|
|
169
|
-
}), !
|
|
206
|
+
isHidden: !otherOperatonsMenuSearchMap['COPY_LINK_OF_SECTION']
|
|
207
|
+
}), !otherOperatonsMenuSearchMap['searching'] && /*#__PURE__*/_react.default.createElement("div", {
|
|
170
208
|
className: "sdoc-dropdown-menu-divider"
|
|
171
209
|
})), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
172
210
|
menuConfig: {
|
|
@@ -174,22 +212,26 @@ const SideMenu = (_ref, ref) => {
|
|
|
174
212
|
iconClass: 'sdocfont sdoc-copy'
|
|
175
213
|
},
|
|
176
214
|
onClick: onCopy,
|
|
177
|
-
isHidden: !
|
|
215
|
+
isHidden: !otherOperatonsMenuSearchMap['COPY']
|
|
178
216
|
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
179
217
|
menuConfig: {
|
|
180
218
|
text: 'Cut',
|
|
181
219
|
iconClass: 'sdocfont sdoc-cut'
|
|
182
220
|
},
|
|
183
221
|
onClick: onCut,
|
|
184
|
-
isHidden: !
|
|
222
|
+
isHidden: !otherOperatonsMenuSearchMap['CUT']
|
|
185
223
|
}), /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
186
224
|
menuConfig: {
|
|
187
225
|
text: 'Delete',
|
|
188
226
|
iconClass: 'sdocfont sdoc-delete'
|
|
189
227
|
},
|
|
190
228
|
onClick: onDelete,
|
|
191
|
-
isHidden: !
|
|
192
|
-
}), transformMenuSearchMap['
|
|
229
|
+
isHidden: !otherOperatonsMenuSearchMap['DELETE']
|
|
230
|
+
}), transformMenuSearchMap['searching'] && Object.keys({
|
|
231
|
+
...transformMenuSearchMap,
|
|
232
|
+
...insertBelowMenuSearchMap,
|
|
233
|
+
...otherOperatonsMenuSearchMap
|
|
234
|
+
}).length === 1 && /*#__PURE__*/_react.default.createElement("div", {
|
|
193
235
|
className: "sdoc-dropdown-menu-item-no-results"
|
|
194
236
|
}, t('No_results')))));
|
|
195
237
|
};
|