@seafile/sdoc-editor 1.0.173 → 1.0.175
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 +13 -0
- package/dist/basic-sdk/assets/css/layout.css +2 -1
- package/dist/basic-sdk/assets/css/sdoc-viewer.css +2 -1
- package/dist/basic-sdk/comment/components/comment-editor.js +0 -11
- package/dist/basic-sdk/comment/components/comment-list.css +9 -5
- package/dist/basic-sdk/comment/components/comment-list.js +1 -1
- package/dist/basic-sdk/comment/components/editor-comment.js +0 -12
- package/dist/basic-sdk/comment/components/global-comment/index.css +1 -0
- package/dist/basic-sdk/comment/provider/comment-context-provider.js +9 -4
- package/dist/basic-sdk/constants/index.js +4 -4
- package/dist/basic-sdk/editor/editable-article.js +13 -0
- package/dist/basic-sdk/extension/constants/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/quick-insert/plugin/index.js +6 -1
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +0 -1
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +43 -45
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +91 -6
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +142 -1
- package/dist/basic-sdk/utils/default-mode.js +1 -9
- package/dist/basic-sdk/utils/full-width-mode.js +2 -9
- package/dist/components/doc-info/index.js +4 -3
- package/dist/components/doc-operations/index.js +5 -1
- package/dist/components/doc-operations/more-operations.js +34 -3
- package/dist/pages/simple-editor.js +1 -0
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +4 -1
- package/public/locales/de/sdoc-editor.json +4 -1
- package/public/locales/en/sdoc-editor.json +4 -1
- package/public/locales/es/sdoc-editor.json +4 -1
- package/public/locales/es_AR/sdoc-editor.json +4 -1
- package/public/locales/es_MX/sdoc-editor.json +4 -1
- package/public/locales/fr/sdoc-editor.json +4 -1
- package/public/locales/it/sdoc-editor.json +4 -1
- package/public/locales/ru/sdoc-editor.json +5 -2
- package/public/locales/zh_CN/sdoc-editor.json +4 -1
|
@@ -112,3 +112,16 @@
|
|
|
112
112
|
.sdoc-sub-dropdown-menu .sdoc-insert-element-table-size-wrapper {
|
|
113
113
|
left: 227px !important;
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
.mobile-login .sdoc-dropdown-menu {
|
|
117
|
+
padding: 0 !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.mobile-login .sdoc-dropdown-menu .sdoc-dropdown-menu-item {
|
|
121
|
+
padding: 16px !important;
|
|
122
|
+
height: 47px !important;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.mobile-login .sdoc-dropdown-menu .sdoc-operator-folder-divider {
|
|
126
|
+
margin: 0 !important;
|
|
127
|
+
}
|
|
@@ -74,17 +74,6 @@ const CommentEditor = _ref => {
|
|
|
74
74
|
newEditor.editorType = _constants2.COMMENT_EDITOR;
|
|
75
75
|
return newEditor;
|
|
76
76
|
}, [document]);
|
|
77
|
-
|
|
78
|
-
// onMount: set scrollLeft
|
|
79
|
-
(0, _react.useEffect)(() => {
|
|
80
|
-
if (!commentWrapperRef.current) return;
|
|
81
|
-
(commentRef === null || commentRef === void 0 ? void 0 : commentRef.current) && commentRef.current.scrollIntoView({
|
|
82
|
-
behavior: 'smooth',
|
|
83
|
-
block: 'nearest'
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
|
-
}, []);
|
|
88
77
|
const updateValue = (0, _react.useCallback)(value => {
|
|
89
78
|
if (!value || value.trim() === '') return;
|
|
90
79
|
if (!content) return insertContent(value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.sdoc-comment-list-container {
|
|
2
2
|
position: absolute;
|
|
3
3
|
margin-top: 5px;
|
|
4
|
-
|
|
4
|
+
right: 0;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.sdoc-comment-list-container .article.sdoc-comment-editor {
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdoc-comment-list-container .comment-ui-container {
|
|
12
|
-
background-color:
|
|
12
|
+
background-color: rgba(255, 255, 255, .99);
|
|
13
13
|
margin-bottom: 0px;
|
|
14
|
-
box-shadow:
|
|
14
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 4px 8px 3px rgba(0, 0, 0, .15);
|
|
15
15
|
padding: 16px;
|
|
16
|
-
border-radius:
|
|
16
|
+
border-radius: 5px;
|
|
17
17
|
cursor: pointer;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
padding-bottom: 0px;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
.sdoc-comment-list-container-popover .comment-item-list {
|
|
77
|
+
max-height: 280px;
|
|
78
|
+
}
|
|
79
|
+
|
|
76
80
|
.sdoc-comment-list-container .comment-item {
|
|
77
81
|
position: relative;
|
|
78
82
|
padding: 0px;
|
|
@@ -268,7 +272,7 @@
|
|
|
268
272
|
width: 100%;
|
|
269
273
|
padding: 8px;
|
|
270
274
|
padding-bottom: 0;
|
|
271
|
-
min-height:
|
|
275
|
+
min-height: 60px;
|
|
272
276
|
max-height: 130px;
|
|
273
277
|
box-shadow: none;
|
|
274
278
|
overflow-y: auto;
|
|
@@ -74,7 +74,7 @@ const CommentList = _ref => {
|
|
|
74
74
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
75
75
|
ref: commentRef,
|
|
76
76
|
id: "sdoc-comment-list-container",
|
|
77
|
-
className: "sdoc-comment-list-container",
|
|
77
|
+
className: "sdoc-comment-list-container sdoc-comment-list-container-popover",
|
|
78
78
|
style: {
|
|
79
79
|
top: position.y,
|
|
80
80
|
width: '300px'
|
|
@@ -14,12 +14,9 @@ var _commentList = _interopRequireDefault(require("./comment-list"));
|
|
|
14
14
|
var _useSelectionElement = require("../../hooks/use-selection-element");
|
|
15
15
|
var _useCommentContext = require("../hooks/comment-hooks/use-comment-context");
|
|
16
16
|
var _elementsCommentCount = _interopRequireDefault(require("./elements-comment-count"));
|
|
17
|
-
var _eventBus = _interopRequireDefault(require("../../../basic-sdk/utils/event-bus"));
|
|
18
|
-
var _localStorageUtils = _interopRequireDefault(require("../../../utils/local-storage-utils"));
|
|
19
17
|
var _index = require("../utils/index");
|
|
20
18
|
var _constants = require("../../extension/constants");
|
|
21
19
|
var _constants2 = require("../../constants");
|
|
22
|
-
var _constants3 = require("../../../basic-sdk/constants");
|
|
23
20
|
const EditorComment = _ref => {
|
|
24
21
|
let {
|
|
25
22
|
deleteUnseenNotifications,
|
|
@@ -68,15 +65,6 @@ const EditorComment = _ref => {
|
|
|
68
65
|
}
|
|
69
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
67
|
}, [element_comments_map]);
|
|
71
|
-
(0, _react.useEffect)(() => {
|
|
72
|
-
const settings = _localStorageUtils.default.getItem(_constants3.SDOC_STORAGE) || {};
|
|
73
|
-
_localStorageUtils.default.setItem(_constants3.SDOC_STORAGE, {
|
|
74
|
-
...settings,
|
|
75
|
-
isShowComments
|
|
76
|
-
});
|
|
77
|
-
const eventBus = _eventBus.default.getInstance();
|
|
78
|
-
eventBus.dispatch(_constants3.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
79
|
-
}, [isShowComments]);
|
|
80
68
|
(0, _react.useEffect)(() => {
|
|
81
69
|
// Close when the currently selected element changes
|
|
82
70
|
if (isShowComments) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
@@ -9,6 +10,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
10
|
var _commentReducer = require("../reducer/comment-reducer");
|
|
10
11
|
var _useCommentMount = require("../hooks/comment-hooks/use-comment-mount");
|
|
11
12
|
var _useCommentContext = require("../hooks/comment-hooks/use-comment-context");
|
|
13
|
+
var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
|
|
14
|
+
var _constants = require("../../constants");
|
|
12
15
|
const CommentContextProvider = _ref => {
|
|
13
16
|
let {
|
|
14
17
|
children,
|
|
@@ -17,11 +20,13 @@ const CommentContextProvider = _ref => {
|
|
|
17
20
|
const [commentsInfo, dispatch] = (0, _react.useReducer)(_commentReducer.commentReducer, _commentReducer.initCommentsInfo);
|
|
18
21
|
(0, _useCommentMount.useCommentsMount)(dispatch);
|
|
19
22
|
(0, _react.useEffect)(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
if (Object.keys(commentsInfo.element_comments_map).length) {
|
|
24
|
+
editor.element_comments_map = commentsInfo.element_comments_map;
|
|
25
|
+
const eventBus = _eventBus.default.getInstance();
|
|
26
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.RELOAD_COMMENT);
|
|
27
|
+
}
|
|
23
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
-
}, [commentsInfo]);
|
|
29
|
+
}, [commentsInfo.element_comments_map]);
|
|
25
30
|
return /*#__PURE__*/_react.default.createElement(_useCommentContext.CommentContext.Provider, {
|
|
26
31
|
value: {
|
|
27
32
|
commentsInfo,
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "PLUGIN_DISPLAY_TYPE", {
|
|
|
17
17
|
return _plugin.PLUGIN_DISPLAY_TYPE;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
exports.Z_INDEX = exports.WIKI_OUTLINE = exports.WIKI_EDITOR = exports.SDOC_STORAGE = exports.
|
|
20
|
+
exports.Z_INDEX = exports.WIKI_OUTLINE = exports.WIKI_EDITOR = exports.SDOC_STORAGE = exports.REVISION_DIFF_VALUE = exports.REVISION_DIFF_KEY = exports.REBASE_TYPES = exports.REBASE_TYPE = exports.REBASE_ORIGIN = exports.REBASE_MARK_KEY = exports.REBASE_MARKS = void 0;
|
|
21
21
|
var Z_INDEX = _interopRequireWildcard(require("./z-index"));
|
|
22
22
|
exports.Z_INDEX = Z_INDEX;
|
|
23
23
|
var _plugin = require("./plugin");
|
|
@@ -47,7 +47,8 @@ const INTERNAL_EVENT = exports.INTERNAL_EVENT = {
|
|
|
47
47
|
COMMENT_EDITOR_POST_COMMENT: 'comment_editor_post_comment',
|
|
48
48
|
CLOSE_FILE_INSET_DIALOG: 'close_file_insert_dialog',
|
|
49
49
|
RESIZE_ARTICLE: 'resize_article',
|
|
50
|
-
ON_VIDEO_FILES_UPLOADED: 'on_video_files_uploaded'
|
|
50
|
+
ON_VIDEO_FILES_UPLOADED: 'on_video_files_uploaded',
|
|
51
|
+
RELOAD_COMMENT: 'reload_comment'
|
|
51
52
|
};
|
|
52
53
|
const REVISION_DIFF_KEY = exports.REVISION_DIFF_KEY = 'diff';
|
|
53
54
|
const REVISION_DIFF_VALUE = exports.REVISION_DIFF_VALUE = '1';
|
|
@@ -89,9 +90,8 @@ const DIFF_VIEWER = exports.DIFF_VIEWER = 'diff_viewer';
|
|
|
89
90
|
const FULL_WIDTH_MODE = exports.FULL_WIDTH_MODE = 'full-width-mode';
|
|
90
91
|
const SDOC_STORAGE = exports.SDOC_STORAGE = 'sdoc';
|
|
91
92
|
|
|
92
|
-
// left outline
|
|
93
|
+
// left outline
|
|
93
94
|
const LEFT_OUTLINE_WIDTH = exports.LEFT_OUTLINE_WIDTH = 280;
|
|
94
|
-
const RIGHT_COMMENT_WIDTH = exports.RIGHT_COMMENT_WIDTH = 314;
|
|
95
95
|
|
|
96
96
|
// Default mode width
|
|
97
97
|
const ARTICLE_DEFAULT_WIDTH = exports.ARTICLE_DEFAULT_WIDTH = '794px';
|
|
@@ -24,6 +24,7 @@ var _useScrollContext = require("../hooks/use-scroll-context");
|
|
|
24
24
|
var _highlight = require("../highlight");
|
|
25
25
|
var _constants2 = require("../extension/constants");
|
|
26
26
|
var _helpers = require("../extension/plugins/table/helpers");
|
|
27
|
+
var _useForceUpdate = _interopRequireDefault(require("../../basic-sdk/hooks/use-force-update"));
|
|
27
28
|
const EditableArticle = _ref => {
|
|
28
29
|
let {
|
|
29
30
|
showComment,
|
|
@@ -35,6 +36,7 @@ const EditableArticle = _ref => {
|
|
|
35
36
|
cursors
|
|
36
37
|
} = (0, _useCursors.useCursors)(editor);
|
|
37
38
|
const decorate = (0, _decorates.usePipDecorate)(editor);
|
|
39
|
+
const forceUpdate = (0, _useForceUpdate.default)();
|
|
38
40
|
|
|
39
41
|
// init eventHandler
|
|
40
42
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -51,6 +53,17 @@ const EditableArticle = _ref => {
|
|
|
51
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
54
|
}, []);
|
|
53
55
|
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
56
|
+
const onReloadComment = () => {
|
|
57
|
+
forceUpdate();
|
|
58
|
+
};
|
|
59
|
+
(0, _react.useEffect)(() => {
|
|
60
|
+
const eventBus = _eventBus.default.getInstance();
|
|
61
|
+
const unsubscribeReloadComment = eventBus.subscribe(_constants.INTERNAL_EVENT.RELOAD_COMMENT, onReloadComment);
|
|
62
|
+
return () => {
|
|
63
|
+
unsubscribeReloadComment();
|
|
64
|
+
};
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, []);
|
|
54
67
|
const onKeyDown = (0, _react.useCallback)(event => {
|
|
55
68
|
const {
|
|
56
69
|
scrollTop,
|
|
@@ -528,7 +528,7 @@ const FILE_TYPE = exports.FILE_TYPE = {
|
|
|
528
528
|
[_elementType.FILE_LINK]: 'file',
|
|
529
529
|
[_elementType.SDOC_LINK]: 'sdoc'
|
|
530
530
|
};
|
|
531
|
-
const SUPPORTED_SIDE_OPERATION_TYPE = exports.SUPPORTED_SIDE_OPERATION_TYPE = [_elementType.PARAGRAPH, _elementType.SUBTITLE, _elementType.HEADER1, _elementType.HEADER2, _elementType.HEADER3, _elementType.HEADER4, _elementType.HEADER5, _elementType.HEADER6, _elementType.CHECK_LIST_ITEM, _elementType.CODE_BLOCK, _elementType.TABLE, _elementType.BLOCKQUOTE, _elementType.CALL_OUT, _elementType.IMAGE_BLOCK, _elementType.VIDEO, _elementType.SEATABLE_TABLE];
|
|
531
|
+
const SUPPORTED_SIDE_OPERATION_TYPE = exports.SUPPORTED_SIDE_OPERATION_TYPE = [_elementType.PARAGRAPH, _elementType.SUBTITLE, _elementType.HEADER1, _elementType.HEADER2, _elementType.HEADER3, _elementType.HEADER4, _elementType.HEADER5, _elementType.HEADER6, _elementType.CHECK_LIST_ITEM, _elementType.CODE_BLOCK, _elementType.TABLE, _elementType.BLOCKQUOTE, _elementType.CALL_OUT, _elementType.IMAGE_BLOCK, _elementType.VIDEO, _elementType.SEATABLE_TABLE, _elementType.MULTI_COLUMN];
|
|
532
532
|
const MOUSE_ENTER_EVENT_DISABLED_MAP = exports.MOUSE_ENTER_EVENT_DISABLED_MAP = {
|
|
533
533
|
[_elementType.PARAGRAPH]: [_elementType.CALL_OUT],
|
|
534
534
|
[_elementType.TITLE]: [_elementType.CALL_OUT],
|
|
@@ -19,6 +19,7 @@ const withQuickInsert = editor => {
|
|
|
19
19
|
deleteForward
|
|
20
20
|
} = editor;
|
|
21
21
|
const newEditor = editor;
|
|
22
|
+
newEditor.isSlashKey = false;
|
|
22
23
|
newEditor.insertText = text => {
|
|
23
24
|
if (!editor.selection) return insertText(text);
|
|
24
25
|
const [blockNode] = (0, _core.getTopLevelBlockNode)(editor);
|
|
@@ -40,7 +41,10 @@ const withQuickInsert = editor => {
|
|
|
40
41
|
return insertText(text);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
|
|
45
|
+
// Set isSlashKey to compatible with ’Sou gou‘ Chinese Input Method
|
|
46
|
+
if (text === '/' || text === '、' && newEditor.isSlashKey) {
|
|
47
|
+
newEditor.isSlashKey = false;
|
|
44
48
|
// Avoid triggering quick insert when the cursor is in the quick insert
|
|
45
49
|
const isInQuickInsert = (0, _helper.getQuickInsertEntity)(editor);
|
|
46
50
|
if (isInQuickInsert) return insertText(text);
|
|
@@ -106,6 +110,7 @@ const withQuickInsert = editor => {
|
|
|
106
110
|
return deleteForward(unit);
|
|
107
111
|
};
|
|
108
112
|
newEditor.onHotKeyDown = event => {
|
|
113
|
+
newEditor.isSlashKey = event.code === 'Slash';
|
|
109
114
|
const quickInsertEntry = (0, _helper.getQuickInsertEntity)(editor);
|
|
110
115
|
if (quickInsertEntry) {
|
|
111
116
|
const [quickInsertNode, quickInsertPath] = quickInsertEntry;
|
|
@@ -148,7 +148,6 @@ const TableCell = _ref => {
|
|
|
148
148
|
eventBus.dispatch(_constants2.INTERNAL_EVENT.TABLE_SHOW_DRAG_HANDLER, cellInfo);
|
|
149
149
|
}, [cellIndex, cellPath, editor, eventBus, rowIndex, selectedRange, tableEntry, tableId]);
|
|
150
150
|
const handleDrop = (0, _react.useCallback)(event => {
|
|
151
|
-
event.stopPropagation();
|
|
152
151
|
event.preventDefault();
|
|
153
152
|
if (!canDrop.current) return;
|
|
154
153
|
const {
|
|
@@ -146,6 +146,49 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
146
146
|
}, [callback, editor, insertPosition, slateNode]);
|
|
147
147
|
const dropDownItems = (0, _react.useMemo)(() => {
|
|
148
148
|
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
|
+
}),
|
|
149
192
|
[_constants.IMAGE]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
150
193
|
isHidden: !quickInsertMenuSearchMap[_constants.IMAGE],
|
|
151
194
|
disabled: isDisableImage,
|
|
@@ -216,53 +259,8 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
216
259
|
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CALL_OUT]
|
|
217
260
|
},
|
|
218
261
|
onClick: () => onInsertCallout(_constants.PARAGRAPH)
|
|
219
|
-
}),
|
|
220
|
-
[_constants.UNORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
221
|
-
isHidden: !quickInsertMenuSearchMap[_constants.UNORDERED_LIST],
|
|
222
|
-
key: "sdoc-insert-menu-unorder-list",
|
|
223
|
-
menuConfig: {
|
|
224
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.UNORDERED_LIST]
|
|
225
|
-
},
|
|
226
|
-
onClick: () => {
|
|
227
|
-
onInsertList(_constants.ELEMENT_TYPE.UNORDERED_LIST);
|
|
228
|
-
}
|
|
229
|
-
}),
|
|
230
|
-
[_constants.ORDERED_LIST]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
231
|
-
isHidden: !quickInsertMenuSearchMap[_constants.ORDERED_LIST],
|
|
232
|
-
key: "sdoc-insert-menu-order-list",
|
|
233
|
-
menuConfig: {
|
|
234
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.ORDERED_LIST]
|
|
235
|
-
},
|
|
236
|
-
onClick: () => {
|
|
237
|
-
onInsertList(_constants.ELEMENT_TYPE.ORDERED_LIST);
|
|
238
|
-
}
|
|
239
|
-
}),
|
|
240
|
-
[_constants.CHECK_LIST_ITEM]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
241
|
-
isHidden: !quickInsertMenuSearchMap[_constants.CHECK_LIST_ITEM],
|
|
242
|
-
key: "sdoc-insert-menu-check-list",
|
|
243
|
-
menuConfig: {
|
|
244
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.CHECK_LIST_ITEM]
|
|
245
|
-
},
|
|
246
|
-
onClick: onInsertCheckList
|
|
247
|
-
}),
|
|
248
|
-
[_constants.PARAGRAPH]: /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
249
|
-
isHidden: !quickInsertMenuSearchMap[_constants.PARAGRAPH],
|
|
250
|
-
disabled: isEmptyNode,
|
|
251
|
-
key: "sdoc-insert-menu-paragraph",
|
|
252
|
-
menuConfig: {
|
|
253
|
-
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.PARAGRAPH]
|
|
254
|
-
},
|
|
255
|
-
onClick: () => onInsert(_constants.ELEMENT_TYPE.PARAGRAPH)
|
|
256
262
|
})
|
|
257
263
|
};
|
|
258
|
-
_constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.HEADER].forEach(item => {
|
|
259
|
-
items[item.id.toLowerCase()] = /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
260
|
-
isHidden: !quickInsertMenuSearchMap[item.type],
|
|
261
|
-
key: item.id,
|
|
262
|
-
menuConfig: item,
|
|
263
|
-
onClick: () => onInsert(item.type)
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
264
|
_constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.MULTI_COLUMN].forEach(item => {
|
|
267
265
|
items[item.id.toLowerCase()] = /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
268
266
|
isHidden: !quickInsertMenuSearchMap[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.setSelection = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.isVoidNode = exports.isNotSupportTransform = exports.isList = exports.isBlockquote = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNode = void 0;
|
|
7
|
+
exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
|
|
8
8
|
var _slate = require("@seafile/slate");
|
|
9
9
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
@@ -18,6 +18,8 @@ var _constants2 = require("../../plugins/table/constants");
|
|
|
18
18
|
var _helper = require("../../plugins/callout/helper");
|
|
19
19
|
var _helpers2 = require("../../plugins/check-list/helpers");
|
|
20
20
|
var _constants3 = require("../../../constants");
|
|
21
|
+
var _helpers3 = require("../../../node-id/helpers");
|
|
22
|
+
var _documentUtils = require("../../../utils/document-utils");
|
|
21
23
|
const onSetNodeType = (editor, element, type) => {
|
|
22
24
|
if (!type) return;
|
|
23
25
|
if (type === _constants.CALL_OUT) {
|
|
@@ -176,16 +178,25 @@ const isBlockquote = (editor, path) => {
|
|
|
176
178
|
return false;
|
|
177
179
|
};
|
|
178
180
|
exports.isBlockquote = isBlockquote;
|
|
179
|
-
const
|
|
181
|
+
const isMultiColumn = (editor, path) => {
|
|
180
182
|
var _nodeEntry$2;
|
|
183
|
+
const nodeEntry = _slate.Editor.node(editor, path);
|
|
184
|
+
if (nodeEntry && ((_nodeEntry$2 = nodeEntry[0]) === null || _nodeEntry$2 === void 0 ? void 0 : _nodeEntry$2.type) === _constants.MULTI_COLUMN) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
};
|
|
189
|
+
exports.isMultiColumn = isMultiColumn;
|
|
190
|
+
const isList = (editor, path) => {
|
|
191
|
+
var _nodeEntry$3;
|
|
181
192
|
const nodeEntry = _slate.Editor.node(editor, [path[0]]);
|
|
182
|
-
if (nodeEntry && [_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes((_nodeEntry$
|
|
193
|
+
if (nodeEntry && [_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes((_nodeEntry$3 = nodeEntry[0]) === null || _nodeEntry$3 === void 0 ? void 0 : _nodeEntry$3.type)) {
|
|
183
194
|
return true;
|
|
184
195
|
}
|
|
185
196
|
if (path.length > 1 && isBlockquote(editor, [path[0]])) {
|
|
186
|
-
var _nodeEntry$
|
|
197
|
+
var _nodeEntry$4;
|
|
187
198
|
const nodeEntry = _slate.Editor.node(editor, [path[0], path[1]]);
|
|
188
|
-
if ([_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes((_nodeEntry$
|
|
199
|
+
if ([_constants.ORDERED_LIST, _constants.UNORDERED_LIST].includes((_nodeEntry$4 = nodeEntry[0]) === null || _nodeEntry$4 === void 0 ? void 0 : _nodeEntry$4.type)) {
|
|
189
200
|
return true;
|
|
190
201
|
}
|
|
191
202
|
}
|
|
@@ -215,6 +226,35 @@ const onWrapListItem = (editor, targetPath, sourcePath) => {
|
|
|
215
226
|
return;
|
|
216
227
|
};
|
|
217
228
|
exports.onWrapListItem = onWrapListItem;
|
|
229
|
+
const insertEmptyListNodeAtTarget = (editor, targetPath, listType) => {
|
|
230
|
+
const currentTargetPath = _slate.Path.next(targetPath);
|
|
231
|
+
const emptyListNode = (0, _model.generateEmptyList)(listType);
|
|
232
|
+
emptyListNode.children[0] = (0, _model.generateListItem)();
|
|
233
|
+
_slate.Transforms.insertNodes(editor, emptyListNode, {
|
|
234
|
+
at: currentTargetPath
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
exports.insertEmptyListNodeAtTarget = insertEmptyListNodeAtTarget;
|
|
238
|
+
const onWrapMultiListItem = (editor, currentTargetPath, sourceNodes) => {
|
|
239
|
+
sourceNodes && sourceNodes.slice().reverse().forEach(nodes => {
|
|
240
|
+
_slate.Transforms.insertNodes(editor, nodes[0], {
|
|
241
|
+
at: currentTargetPath
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
exports.onWrapMultiListItem = onWrapMultiListItem;
|
|
246
|
+
const onWrapMultiListItemToNonListTypeTarget = (editor, targetPath, sourceNodes, listType) => {
|
|
247
|
+
insertEmptyListNodeAtTarget(editor, targetPath, listType);
|
|
248
|
+
let currentTargetPath = _slate.Path.next(targetPath);
|
|
249
|
+
currentTargetPath.splice(currentTargetPath.length, 0, 0);
|
|
250
|
+
const emptyListPath = [...currentTargetPath];
|
|
251
|
+
currentTargetPath = _slate.Path.next(currentTargetPath);
|
|
252
|
+
onWrapMultiListItem(editor, currentTargetPath, sourceNodes);
|
|
253
|
+
_slate.Transforms.removeNodes(editor, {
|
|
254
|
+
at: emptyListPath
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
exports.onWrapMultiListItemToNonListTypeTarget = onWrapMultiListItemToNonListTypeTarget;
|
|
218
258
|
const getTransformMenusConfig = (editor, slateNode) => {
|
|
219
259
|
let newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG;
|
|
220
260
|
if (_constants.LIST_ITEM_CORRELATION_TYPE.includes(slateNode.type)) {
|
|
@@ -274,4 +314,49 @@ const getSearchedOperations = (sourceMenuSearchMap, isNodeEmpty, event, t, edito
|
|
|
274
314
|
}
|
|
275
315
|
return menuSearchMap;
|
|
276
316
|
};
|
|
277
|
-
exports.getSearchedOperations = getSearchedOperations;
|
|
317
|
+
exports.getSearchedOperations = getSearchedOperations;
|
|
318
|
+
const createDragPreviewContainer = () => {
|
|
319
|
+
const previewContainer = document.createElement('div');
|
|
320
|
+
previewContainer.style.position = 'absolute';
|
|
321
|
+
previewContainer.style.width = '654px';
|
|
322
|
+
previewContainer.style.pointerEvents = 'none';
|
|
323
|
+
previewContainer.style.background = 'rgba(255, 255, 255, 0.9)';
|
|
324
|
+
previewContainer.style.padding = '3px 0px';
|
|
325
|
+
previewContainer.style.zIndex = '103';
|
|
326
|
+
document.body.appendChild(previewContainer);
|
|
327
|
+
return previewContainer;
|
|
328
|
+
};
|
|
329
|
+
exports.createDragPreviewContainer = createDragPreviewContainer;
|
|
330
|
+
const deleteNodesFromBack = (editor, sortedPaths) => {
|
|
331
|
+
sortedPaths.slice().reverse().forEach(path => {
|
|
332
|
+
_slate.Transforms.removeNodes(editor, {
|
|
333
|
+
at: path
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
exports.deleteNodesFromBack = deleteNodesFromBack;
|
|
338
|
+
const isListItem = editor => {
|
|
339
|
+
if (!editor.selection) return false;
|
|
340
|
+
const anchorPath = editor.selection.anchor.path;
|
|
341
|
+
const focusPath = editor.selection.focus.path;
|
|
342
|
+
if (isMultiColumn(editor, [anchorPath[0]])) return false;
|
|
343
|
+
const start = Math.min(anchorPath[0], focusPath[0]);
|
|
344
|
+
const end = Math.max(anchorPath[0], focusPath[0]);
|
|
345
|
+
let isListItem = true;
|
|
346
|
+
for (let i = start; i <= end; i++) {
|
|
347
|
+
const topNode = (0, _core.getNode)(editor, [i]);
|
|
348
|
+
if ((topNode === null || topNode === void 0 ? void 0 : topNode.type) !== _constants.ORDERED_LIST && (topNode === null || topNode === void 0 ? void 0 : topNode.type) !== _constants.UNORDERED_LIST) {
|
|
349
|
+
return isListItem = false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return isListItem;
|
|
353
|
+
};
|
|
354
|
+
exports.isListItem = isListItem;
|
|
355
|
+
const normalizeCopyData = (editor, fragment) => {
|
|
356
|
+
const decoded = decodeURIComponent(window.atob(fragment));
|
|
357
|
+
const parsed = JSON.parse(decoded);
|
|
358
|
+
const newData = (0, _helpers3.replacePastedDataId)(parsed);
|
|
359
|
+
const normalizeNewData = (0, _documentUtils.normalizeCopyNodes)(editor, newData);
|
|
360
|
+
return normalizeNewData;
|
|
361
|
+
};
|
|
362
|
+
exports.normalizeCopyData = normalizeCopyData;
|
|
@@ -34,6 +34,10 @@ const SideToolbar = () => {
|
|
|
34
34
|
const [isEnterMoreVertical, setIsEnterMoreVertical] = (0, _react.useState)(false);
|
|
35
35
|
const [isMoving, setIsMoving] = (0, _react.useState)(false);
|
|
36
36
|
const sideMenuRef = (0, _react.useRef)();
|
|
37
|
+
const draggedSourcePaths = (0, _react.useRef)(null);
|
|
38
|
+
const selectedNodesRef = (0, _react.useRef)(null);
|
|
39
|
+
const showSelectedNodesRef = (0, _react.useRef)(null);
|
|
40
|
+
const draggedPreviewContainer = (0, _react.useRef)(null);
|
|
37
41
|
const onReset = (0, _react.useCallback)(() => {
|
|
38
42
|
setShowSideMenu(false);
|
|
39
43
|
setMenuPosition({});
|
|
@@ -110,6 +114,65 @@ const SideToolbar = () => {
|
|
|
110
114
|
|
|
111
115
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
116
|
}, [editor, isShowSideMenu, scrollRef, sidePosition.top]);
|
|
117
|
+
const onMouseDown = (0, _react.useCallback)(e => {
|
|
118
|
+
const domSelection = window.getSelection();
|
|
119
|
+
if (domSelection.type !== 'Range' || !editor.selection || _slate.Path.equals(editor.selection.focus.path, editor.selection.anchor.path)) {
|
|
120
|
+
draggedPreviewContainer.current = null;
|
|
121
|
+
selectedNodesRef.current = null;
|
|
122
|
+
showSelectedNodesRef.current = null;
|
|
123
|
+
draggedSourcePaths.current = null;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// Bond when selecting more than more list_items nodes
|
|
127
|
+
const dom = e.target;
|
|
128
|
+
const domTop = dom.getBoundingClientRect().top;
|
|
129
|
+
if ((0, _helpers.isListItem)(editor)) {
|
|
130
|
+
const {
|
|
131
|
+
anchor,
|
|
132
|
+
focus
|
|
133
|
+
} = editor.selection;
|
|
134
|
+
// Return if selecting only one line list_item
|
|
135
|
+
if (_slate.Path.equals(anchor.path.slice(0, -1), focus.path.slice(0, -1))) return;
|
|
136
|
+
const startPath = (_slate.Path.compare(anchor.path, focus.path) < 0 ? anchor.path : focus.path).slice(0, -2);
|
|
137
|
+
// Remove unselected parent level list node when selecting child level list_item nodes
|
|
138
|
+
const selectedDraggedPreviewNodes = Array.from(_slate.Editor.nodes(editor, {
|
|
139
|
+
match: node => node.type === _constants2.LIST_ITEM,
|
|
140
|
+
at: editor.selection
|
|
141
|
+
})).filter(_ref => {
|
|
142
|
+
let [, path] = _ref;
|
|
143
|
+
return !_slate.Path.isAncestor(path, startPath);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Remove their all children level list_items when selecting parent level list nodes
|
|
147
|
+
let selectedNodes = [];
|
|
148
|
+
let lastAncestorPath = null;
|
|
149
|
+
for (const [node, path] of selectedDraggedPreviewNodes) {
|
|
150
|
+
if (lastAncestorPath && _slate.Path.isAncestor(lastAncestorPath, path)) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
selectedNodes.push([node, path]);
|
|
154
|
+
lastAncestorPath = path;
|
|
155
|
+
}
|
|
156
|
+
const topValues = selectedDraggedPreviewNodes.map(_ref2 => {
|
|
157
|
+
let [node] = _ref2;
|
|
158
|
+
const domNode = _slateReact.ReactEditor.toDOMNode(editor, node);
|
|
159
|
+
const rect = domNode.getBoundingClientRect();
|
|
160
|
+
return rect.top;
|
|
161
|
+
});
|
|
162
|
+
const rangeStart = Math.min(...topValues) - 15;
|
|
163
|
+
const rangeEnd = Math.max(...topValues) + 15;
|
|
164
|
+
// Active only when the sideTool bar references to the selectedNodes
|
|
165
|
+
if (selectedDraggedPreviewNodes.length > 1 && rangeStart < domTop && domTop < rangeEnd) {
|
|
166
|
+
showSelectedNodesRef.current = selectedDraggedPreviewNodes;
|
|
167
|
+
selectedNodesRef.current = selectedNodes;
|
|
168
|
+
} else {
|
|
169
|
+
draggedPreviewContainer.current = null;
|
|
170
|
+
selectedNodesRef.current = null;
|
|
171
|
+
showSelectedNodesRef.current = null;
|
|
172
|
+
draggedSourcePaths.current = null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, [editor]);
|
|
113
176
|
const onShowSideMenuToggle = (0, _react.useCallback)(() => {
|
|
114
177
|
(0, _helpers.setSelection)(editor, slateNode);
|
|
115
178
|
const {
|
|
@@ -123,6 +186,32 @@ const SideToolbar = () => {
|
|
|
123
186
|
});
|
|
124
187
|
}, [editor, isShowSideMenu, slateNode]);
|
|
125
188
|
const dragStart = (0, _react.useCallback)(event => {
|
|
189
|
+
// Create the preview container when dragging more than one listNodes
|
|
190
|
+
const noDrag = _slate.Path.equals(editor.selection.focus.path, editor.selection.anchor.path);
|
|
191
|
+
if (showSelectedNodesRef.current && showSelectedNodesRef.current.length > 1 && !noDrag) {
|
|
192
|
+
if (!draggedPreviewContainer.current) {
|
|
193
|
+
draggedPreviewContainer.current = (0, _helpers.createDragPreviewContainer)();
|
|
194
|
+
}
|
|
195
|
+
draggedPreviewContainer.current.innerHTML = '';
|
|
196
|
+
showSelectedNodesRef.current.forEach(_ref3 => {
|
|
197
|
+
let [node, path] = _ref3;
|
|
198
|
+
const nodeElement = _slateReact.ReactEditor.toDOMNode(editor, node.children[0]);
|
|
199
|
+
const clonedNode = nodeElement.cloneNode(true);
|
|
200
|
+
draggedPreviewContainer.current.appendChild(clonedNode);
|
|
201
|
+
});
|
|
202
|
+
event.dataTransfer.setDragImage(draggedPreviewContainer.current, 0, 0);
|
|
203
|
+
draggedSourcePaths.current = showSelectedNodesRef.current.map(_ref4 => {
|
|
204
|
+
let [, path] = _ref4;
|
|
205
|
+
return path;
|
|
206
|
+
});
|
|
207
|
+
setTimeout(() => {
|
|
208
|
+
if (draggedPreviewContainer.current) {
|
|
209
|
+
draggedPreviewContainer.current.innerHTML = '';
|
|
210
|
+
draggedPreviewContainer.current = null;
|
|
211
|
+
}
|
|
212
|
+
}, 0);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
126
215
|
sourceElement = _slateReact.ReactEditor.toDOMNode(editor, slateNode);
|
|
127
216
|
const path = _slateReact.ReactEditor.findPath(editor, slateNode);
|
|
128
217
|
|
|
@@ -155,9 +244,60 @@ const SideToolbar = () => {
|
|
|
155
244
|
(0, _helpers2.insertImageFiles)(event.dataTransfer.files, editor, targetPath);
|
|
156
245
|
return;
|
|
157
246
|
}
|
|
158
|
-
const [sourceNode, sourcePath] = (0, _helpers.getNodeEntry)(editor, sourceElement);
|
|
159
247
|
const [, targetPath] = (0, _helpers.getNodeEntry)(editor, targetElement);
|
|
248
|
+
// Drag multiple list_items nodes
|
|
249
|
+
if (draggedSourcePaths.current) {
|
|
250
|
+
try {
|
|
251
|
+
// Return if dragging items into themselves
|
|
252
|
+
if (draggedSourcePaths.current.some(arr => JSON.stringify(arr) === JSON.stringify(targetPath))) return;
|
|
253
|
+
const sortedPaths = [...draggedSourcePaths.current].sort(_slate.Path.compare);
|
|
254
|
+
let currentTargetPath = _slate.Path.next(targetPath);
|
|
255
|
+
const currentNode = _slate.Node.get(editor, targetPath);
|
|
256
|
+
const parentNode = _slate.Node.parent(editor, targetPath);
|
|
257
|
+
const topNode = _slate.Node.get(editor, [targetPath[0]]);
|
|
258
|
+
|
|
259
|
+
// Drag into list nods within blockquote, callout or multi_column block node
|
|
260
|
+
if (topNode.type === _constants2.CALL_OUT && parentNode.type === _constants2.LIST_ITEM || topNode.type === _constants2.MULTI_COLUMN && parentNode.type === _constants2.LIST_ITEM) {
|
|
261
|
+
currentTargetPath = _slate.Path.next(targetPath.slice(0, -1));
|
|
262
|
+
(0, _helpers.onWrapMultiListItem)(editor, currentTargetPath, selectedNodesRef.current);
|
|
263
|
+
(0, _helpers.deleteNodesFromBack)(editor, sortedPaths);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (topNode.type === _constants2.BLOCKQUOTE && currentNode.type === _constants2.LIST_ITEM) {
|
|
267
|
+
(0, _helpers.onWrapMultiListItem)(editor, currentTargetPath, selectedNodesRef.current);
|
|
268
|
+
(0, _helpers.deleteNodesFromBack)(editor, sortedPaths);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
160
271
|
|
|
272
|
+
// Drag into other element nodes rather than blockquote, callout or multi_column block node
|
|
273
|
+
if (_slate.Path.isAfter(targetPath, sortedPaths[0])) {
|
|
274
|
+
if (currentNode.type === _constants2.LIST_ITEM) {
|
|
275
|
+
(0, _helpers.onWrapMultiListItem)(editor, currentTargetPath, selectedNodesRef.current);
|
|
276
|
+
} else {
|
|
277
|
+
const listType = _slate.Editor.node(editor, [sortedPaths[0][0]])[0].type;
|
|
278
|
+
(0, _helpers.onWrapMultiListItemToNonListTypeTarget)(editor, targetPath, selectedNodesRef.current, listType);
|
|
279
|
+
}
|
|
280
|
+
(0, _helpers.deleteNodesFromBack)(editor, sortedPaths);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (_slate.Path.isBefore(targetPath, sortedPaths[0])) {
|
|
284
|
+
const listType = _slate.Editor.node(editor, [sortedPaths[0][0]])[0].type;
|
|
285
|
+
(0, _helpers.deleteNodesFromBack)(editor, sortedPaths);
|
|
286
|
+
if (currentNode.type === _constants2.LIST_ITEM) {
|
|
287
|
+
(0, _helpers.onWrapMultiListItem)(editor, currentTargetPath, selectedNodesRef.current);
|
|
288
|
+
} else {
|
|
289
|
+
(0, _helpers.onWrapMultiListItemToNonListTypeTarget)(editor, targetPath, selectedNodesRef.current, listType);
|
|
290
|
+
}
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
} finally {
|
|
294
|
+
selectedNodesRef.current = null;
|
|
295
|
+
draggedSourcePaths.current = null;
|
|
296
|
+
showSelectedNodesRef.current = null;
|
|
297
|
+
draggedPreviewContainer.current = null;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const [sourceNode, sourcePath] = (0, _helpers.getNodeEntry)(editor, sourceElement);
|
|
161
301
|
// Dragging into a quoteBlock is not supported
|
|
162
302
|
if ([_constants2.CODE_BLOCK, _constants2.TABLE, _constants2.BLOCKQUOTE].includes(sourceNode.type) && (0, _helpers.isBlockquote)(editor, [targetPath[0]]) && targetPath.length > 1) {
|
|
163
303
|
return;
|
|
@@ -279,6 +419,7 @@ const SideToolbar = () => {
|
|
|
279
419
|
style: sidePosition
|
|
280
420
|
}, slateNode && /*#__PURE__*/_react.default.createElement("div", {
|
|
281
421
|
ref: menuRef,
|
|
422
|
+
onMouseDown: onMouseDown,
|
|
282
423
|
draggable: true,
|
|
283
424
|
onDragStart: dragStart,
|
|
284
425
|
className: "sdoc-side-op-icon",
|
|
@@ -10,8 +10,7 @@ var _constants = require("../constants");
|
|
|
10
10
|
const getStyleByDefaultMode = (scrollRef, editor) => {
|
|
11
11
|
const sdocStorage = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
12
12
|
const {
|
|
13
|
-
outlineOpen: isShowOutline
|
|
14
|
-
isShowComments
|
|
13
|
+
outlineOpen: isShowOutline
|
|
15
14
|
} = sdocStorage;
|
|
16
15
|
const containerStyle = {
|
|
17
16
|
width: _constants.ARTICLE_DEFAULT_WIDTH
|
|
@@ -20,13 +19,6 @@ const getStyleByDefaultMode = (scrollRef, editor) => {
|
|
|
20
19
|
// Has outline
|
|
21
20
|
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
|
|
22
21
|
const rect = scrollRef.current.getBoundingClientRect();
|
|
23
|
-
if (isShowComments) {
|
|
24
|
-
const outlineRightWidth = Number(_constants.ARTICLE_DEFAULT_WIDTH.slice(0, 3)) + _constants.RIGHT_COMMENT_WIDTH;
|
|
25
|
-
if (rect.width - outlineRightWidth < 280) {
|
|
26
|
-
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
27
|
-
return containerStyle;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
22
|
if ((rect.width - Number(_constants.ARTICLE_DEFAULT_WIDTH.slice(0, 3))) / 2 < 280) {
|
|
31
23
|
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
32
24
|
}
|
|
@@ -10,8 +10,7 @@ var _constants = require("../constants");
|
|
|
10
10
|
const getStyleByFullWidthMode = (scrollRef, editor) => {
|
|
11
11
|
const sdocStorage = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
12
12
|
const {
|
|
13
|
-
outlineOpen: isShowOutline
|
|
14
|
-
isShowComments: isHasComments
|
|
13
|
+
outlineOpen: isShowOutline
|
|
15
14
|
} = sdocStorage;
|
|
16
15
|
let containerStyle = {};
|
|
17
16
|
containerStyle['width'] = _constants.ARTICLE_FULL_WIDTH;
|
|
@@ -23,19 +22,13 @@ const getStyleByFullWidthMode = (scrollRef, editor) => {
|
|
|
23
22
|
const adjustWidth = ` - ${_constants.LEFT_OUTLINE_WIDTH - 50}px`; // One side is 50
|
|
24
23
|
containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
|
|
25
24
|
}
|
|
26
|
-
// Has comments right list
|
|
27
|
-
if (isHasComments) {
|
|
28
|
-
containerStyle['marginRight'] = `${_constants.RIGHT_COMMENT_WIDTH}px`;
|
|
29
|
-
const adjustWidth = ` - ${_constants.RIGHT_COMMENT_WIDTH - 50}px`; // One side is 50
|
|
30
|
-
containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
|
|
31
|
-
}
|
|
32
25
|
return containerStyle;
|
|
33
26
|
};
|
|
34
27
|
exports.getStyleByFullWidthMode = getStyleByFullWidthMode;
|
|
35
28
|
const getContentStyleByFullModeStyle = () => {
|
|
36
29
|
if (_localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE)) {
|
|
37
30
|
return {
|
|
38
|
-
'minWidth': `${Number(_constants.ARTICLE_FULL_MIN_WIDTH.slice(0, -2))
|
|
31
|
+
'minWidth': `${Number(_constants.ARTICLE_FULL_MIN_WIDTH.slice(0, -2))}px`
|
|
39
32
|
};
|
|
40
33
|
}
|
|
41
34
|
return {};
|
|
@@ -32,7 +32,8 @@ const DocInfo = _ref => {
|
|
|
32
32
|
const {
|
|
33
33
|
isShowInternalLink,
|
|
34
34
|
isStarIconShown,
|
|
35
|
-
isFreezed
|
|
35
|
+
isFreezed,
|
|
36
|
+
mobileLogin
|
|
36
37
|
} = _context.default.getSettings();
|
|
37
38
|
const onInternalLinkClick = (0, _react.useCallback)(() => {
|
|
38
39
|
const eventBus = _basicSdk.EventBus.getInstance();
|
|
@@ -52,12 +53,12 @@ const DocInfo = _ref => {
|
|
|
52
53
|
const originFileURL = _context.default.getSetting('originFileURL');
|
|
53
54
|
window.open(originFileURL, '_blank');
|
|
54
55
|
}, []);
|
|
55
|
-
const docInfo = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDraft && /*#__PURE__*/_react.default.createElement(_draftDropdown.default, null), isStarIconShown && /*#__PURE__*/_react.default.createElement("button", {
|
|
56
|
+
const docInfo = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDraft && /*#__PURE__*/_react.default.createElement(_draftDropdown.default, null), isStarIconShown && !mobileLogin && /*#__PURE__*/_react.default.createElement("button", {
|
|
56
57
|
className: `doc-icon sdocfont ${isStarred ? 'sdoc-starred' : 'sdoc-unstarred'} border-0 p-0 bg-transparent`,
|
|
57
58
|
title: isStarred ? t('Starred') : t('Unstarred'),
|
|
58
59
|
"aria-label": isStarred ? t('Unstar') : t('Star'),
|
|
59
60
|
onClick: toggleStar
|
|
60
|
-
}), isShowInternalLink && /*#__PURE__*/_react.default.createElement("span", {
|
|
61
|
+
}), isShowInternalLink && !mobileLogin && /*#__PURE__*/_react.default.createElement("span", {
|
|
61
62
|
className: "doc-icon"
|
|
62
63
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
63
64
|
className: "internal-link sdocfont sdoc-link",
|
|
@@ -18,6 +18,7 @@ require("./style.css");
|
|
|
18
18
|
const DocOperations = _ref => {
|
|
19
19
|
let {
|
|
20
20
|
isShowChanges,
|
|
21
|
+
isStarred,
|
|
21
22
|
isPublished = false,
|
|
22
23
|
changes,
|
|
23
24
|
handleViewChangesToggle,
|
|
@@ -25,10 +26,13 @@ const DocOperations = _ref => {
|
|
|
25
26
|
handleRevisionPublished
|
|
26
27
|
} = _ref;
|
|
27
28
|
const isSdocRevision = _context.default.getSetting('isSdocRevision');
|
|
29
|
+
const mobileLogin = _context.default.getSetting('mobileLogin');
|
|
28
30
|
if (_utils.isMobile) {
|
|
29
31
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
32
|
className: "doc-ops"
|
|
31
|
-
}, !isSdocRevision && /*#__PURE__*/_react.default.createElement(_shareOperation.default, null), !isSdocRevision && /*#__PURE__*/_react.default.createElement(_moreOperations.default,
|
|
33
|
+
}, !isSdocRevision && !mobileLogin && /*#__PURE__*/_react.default.createElement(_shareOperation.default, null), !isSdocRevision && /*#__PURE__*/_react.default.createElement(_moreOperations.default, {
|
|
34
|
+
isStarred: isStarred
|
|
35
|
+
}));
|
|
32
36
|
}
|
|
33
37
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
34
38
|
className: "doc-ops"
|
|
@@ -20,6 +20,7 @@ var _constants = require("../../constants");
|
|
|
20
20
|
var _constants2 = require("../../basic-sdk/constants");
|
|
21
21
|
const MoreOperations = _ref => {
|
|
22
22
|
let {
|
|
23
|
+
isStarred,
|
|
23
24
|
t
|
|
24
25
|
} = _ref;
|
|
25
26
|
const [isDropdownOpen, setIsDropdownOpen] = (0, _react.useState)(false);
|
|
@@ -30,6 +31,7 @@ const MoreOperations = _ref => {
|
|
|
30
31
|
const docPerm = _context.default.getSetting('docPerm');
|
|
31
32
|
const historyURL = _context.default.getSetting('historyURL');
|
|
32
33
|
const isSdocRevision = _context.default.getSetting('isSdocRevision');
|
|
34
|
+
const mobileLogin = _context.default.getSetting('mobileLogin');
|
|
33
35
|
const cssUrls = _context.default.getPrintCss();
|
|
34
36
|
(0, _react.useEffect)(() => {
|
|
35
37
|
const eventBus = _basicSdk.EventBus.getInstance();
|
|
@@ -83,8 +85,26 @@ const MoreOperations = _ref => {
|
|
|
83
85
|
eventBus.dispatch(_constants2.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
84
86
|
setIsFullWidthMode(newMode);
|
|
85
87
|
}, [isFullWidthMode]);
|
|
88
|
+
const toggleStar = (0, _react.useCallback)(() => {
|
|
89
|
+
const eventBus = _basicSdk.EventBus.getInstance();
|
|
90
|
+
eventBus.dispatch(_constants.EXTERNAL_EVENT.TOGGLE_STAR);
|
|
91
|
+
}, []);
|
|
92
|
+
const onShareToggle = (0, _react.useCallback)(() => {
|
|
93
|
+
const eventBus = _basicSdk.EventBus.getInstance();
|
|
94
|
+
eventBus.dispatch(_constants.EXTERNAL_EVENT.SHARE_SDOC);
|
|
95
|
+
}, []);
|
|
96
|
+
const onInternalLinkClick = (0, _react.useCallback)(() => {
|
|
97
|
+
const eventBus = _basicSdk.EventBus.getInstance();
|
|
98
|
+
if (isSdocRevision) {
|
|
99
|
+
eventBus.dispatch(_constants.EXTERNAL_EVENT.INTERNAL_LINK_CLICK, {
|
|
100
|
+
internalLink: window.location.href
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
eventBus.dispatch(_constants.EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
|
|
105
|
+
}, [isSdocRevision]);
|
|
86
106
|
return /*#__PURE__*/_react.default.createElement(_reactstrap.Dropdown, {
|
|
87
|
-
className:
|
|
107
|
+
className: `sdoc-operator-folder ${mobileLogin ? 'mobile-login' : ''}`,
|
|
88
108
|
isOpen: isDropdownOpen,
|
|
89
109
|
toggle: event => toggleDropdown(event, isDropdownOpen)
|
|
90
110
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownToggle, {
|
|
@@ -95,7 +115,18 @@ const MoreOperations = _ref => {
|
|
|
95
115
|
})), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownMenu, {
|
|
96
116
|
className: "sdoc-dropdown-menu",
|
|
97
117
|
right: true
|
|
98
|
-
}, /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
118
|
+
}, mobileLogin && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
119
|
+
className: "sdoc-dropdown-menu-item",
|
|
120
|
+
onClick: toggleStar
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, isStarred ? t('Collected') : t('Collect'))), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
122
|
+
className: "sdoc-dropdown-menu-item",
|
|
123
|
+
onClick: onShareToggle
|
|
124
|
+
}, t('Share_1')), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
125
|
+
className: "sdoc-dropdown-menu-item",
|
|
126
|
+
onClick: onInternalLinkClick
|
|
127
|
+
}, t('Internal_link')), /*#__PURE__*/_react.default.createElement("div", {
|
|
128
|
+
className: "sdoc-operator-folder-divider"
|
|
129
|
+
})), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
99
130
|
className: "sdoc-dropdown-menu-item",
|
|
100
131
|
onClick: handlePrint
|
|
101
132
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -111,7 +142,7 @@ const MoreOperations = _ref => {
|
|
|
111
142
|
}, t('Freeze_document')), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
112
143
|
className: "sdoc-dropdown-menu-item",
|
|
113
144
|
onClick: handleClickHistory
|
|
114
|
-
}, t('Document_history')), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
145
|
+
}, t('Document_history')), !_utils.isMobile && /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
115
146
|
id: "sdoc-full-width-mode-wrapper",
|
|
116
147
|
className: "sdoc-dropdown-menu-item"
|
|
117
148
|
}, /*#__PURE__*/_react.default.createElement(_DTableSwitch2.default, {
|
package/package.json
CHANGED
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Sdílet",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Freigeben",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Share",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Compartir",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Compartir",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Compartir",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Partager",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -578,5 +578,8 @@
|
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Token expired. Please refresh the page.",
|
|
579
579
|
"Link_to_page": "Link to page",
|
|
580
580
|
"No_page_results": "No page results",
|
|
581
|
-
"Page": "Page"
|
|
581
|
+
"Page": "Page",
|
|
582
|
+
"Share_1": "Condividi",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|
|
@@ -577,6 +577,9 @@
|
|
|
577
577
|
"The_current_version_does_not_support_>5MB_video_file": "Текущая_версия_не_поддерживает_видео_файл_>5_МБ",
|
|
578
578
|
"Token_expired_Please_refresh_the_page": "Срок действия токена истек. Обновите страницу.",
|
|
579
579
|
"Link_to_page": "Ссылка на страницу",
|
|
580
|
-
"No_page_results": "
|
|
581
|
-
"Page": "
|
|
580
|
+
"No_page_results": "Нет результатов на странице",
|
|
581
|
+
"Page": "Страница",
|
|
582
|
+
"Share_1": "Общий доступ",
|
|
583
|
+
"Collect": "Collect",
|
|
584
|
+
"Collected": "Collected"
|
|
582
585
|
}
|