@seafile/sdoc-editor 0.5.63 → 0.5.65
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/sdoc-editor-plugins.css +2 -1
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +15 -2
- package/dist/basic-sdk/comment/components/global-comment/index.js +2 -1
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +8 -5
- package/dist/basic-sdk/extension/plugins/quick-insert/render-elem.js +4 -1
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +5 -3
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +3 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +1 -0
- package/package.json +2 -2
|
@@ -56,13 +56,14 @@
|
|
|
56
56
|
.sdoc-editor-container .article .sdoc-image-wrapper {
|
|
57
57
|
position: relative;
|
|
58
58
|
display: inline-block;
|
|
59
|
-
padding: 6px 1px 6px 1px;
|
|
60
59
|
margin: 0 0.15em;
|
|
60
|
+
caret-color: transparent;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
.sdoc-editor-container .article .sdoc-image-inner {
|
|
64
64
|
position: relative;
|
|
65
65
|
display: inline-block;
|
|
66
|
+
margin: 0 3px;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
.sdoc-editor-container .article .sdoc-image-content {
|
|
@@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { Node } from '@seafile/slate';
|
|
6
|
+
import { ReactEditor } from '@seafile/slate-react';
|
|
6
7
|
import context from '../../../context';
|
|
7
8
|
import { useCommentContext } from '../hooks/comment-hooks/use-comment-context';
|
|
8
9
|
import CommentItemContent from './comment-item-content';
|
|
@@ -19,12 +20,14 @@ const CommentItemWrapper = _ref => {
|
|
|
19
20
|
comment,
|
|
20
21
|
onCommentClick,
|
|
21
22
|
updateScrollPosition,
|
|
22
|
-
hiddenComment
|
|
23
|
+
hiddenComment,
|
|
24
|
+
editor
|
|
23
25
|
} = _ref;
|
|
24
26
|
const listRef = useRef(null);
|
|
25
27
|
const {
|
|
26
28
|
dispatch
|
|
27
29
|
} = useCommentContext();
|
|
30
|
+
const scrollRef = useRef(document.querySelector('.sdoc-scroll-container'));
|
|
28
31
|
const commentOpToolsId = "commentOpTools_".concat(comment.id);
|
|
29
32
|
const deleteComment = useCallback(async commentId => {
|
|
30
33
|
await context.deleteComment(commentId);
|
|
@@ -234,12 +237,22 @@ const CommentItemWrapper = _ref => {
|
|
|
234
237
|
'd-flex flex-column pt-0': element
|
|
235
238
|
});
|
|
236
239
|
const tip = comment.resolved ? 'Reopen_discussion' : 'Enter_reply_Enter_for_new_line_Shift_Enter_to_send';
|
|
240
|
+
const handleScrollToArticle = useCallback(e => {
|
|
241
|
+
e.stopPropagation();
|
|
242
|
+
const dom = ReactEditor.toDOMNode(editor, element);
|
|
243
|
+
const headerHeight = 56 + 37;
|
|
244
|
+
scrollRef.current.scrollTo({
|
|
245
|
+
top: dom.offsetTop - headerHeight,
|
|
246
|
+
behavior: 'smooth'
|
|
247
|
+
});
|
|
248
|
+
}, [editor, element, scrollRef]);
|
|
237
249
|
return /*#__PURE__*/React.createElement("div", {
|
|
238
250
|
id: "comment-item-wrapper_".concat(comment.id),
|
|
239
251
|
className: className,
|
|
240
252
|
onClick: onItemClick
|
|
241
253
|
}, element && /*#__PURE__*/React.createElement("div", {
|
|
242
|
-
className: "comment-item-selected-text-container"
|
|
254
|
+
className: "comment-item-selected-text-container",
|
|
255
|
+
onClick: handleScrollToArticle
|
|
243
256
|
}, /*#__PURE__*/React.createElement("i", {
|
|
244
257
|
className: "sdocfont sdoc-comment-quote mr-2"
|
|
245
258
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -231,7 +231,8 @@ const GlobalComment = _ref => {
|
|
|
231
231
|
onCommentClick: comment => onCommentClick(comment, element),
|
|
232
232
|
hiddenComment: hiddenComment,
|
|
233
233
|
updateScrollPosition: updateScrollPosition,
|
|
234
|
-
isClickCommentPanelBody: isClickCommentPanelBody
|
|
234
|
+
isClickCommentPanelBody: isClickCommentPanelBody,
|
|
235
|
+
editor: editor
|
|
235
236
|
});
|
|
236
237
|
}))), showEditor && /*#__PURE__*/React.createElement(GlobalCommentEditor, {
|
|
237
238
|
isScrollDisplayed: isScrollDisplayed,
|
|
@@ -200,7 +200,8 @@ const Image = _ref => {
|
|
|
200
200
|
className: classNames('sdoc-image-wrapper', className)
|
|
201
201
|
}, attributes, {
|
|
202
202
|
style: _objectSpread({}, style),
|
|
203
|
-
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected)
|
|
203
|
+
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
|
|
204
|
+
contentEditable: "true"
|
|
204
205
|
}), /*#__PURE__*/React.createElement("img", {
|
|
205
206
|
ref: imageRef,
|
|
206
207
|
src: imagePlaceholder,
|
|
@@ -212,9 +213,11 @@ const Image = _ref => {
|
|
|
212
213
|
className: classNames('sdoc-image-wrapper', className)
|
|
213
214
|
}, attributes, {
|
|
214
215
|
style: _objectSpread({}, style),
|
|
215
|
-
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected)
|
|
216
|
+
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
|
|
217
|
+
contentEditable: "true"
|
|
216
218
|
}), /*#__PURE__*/React.createElement("span", {
|
|
217
|
-
className: "sdoc-image-inner"
|
|
219
|
+
className: "sdoc-image-inner",
|
|
220
|
+
contentEditable: "false"
|
|
218
221
|
}, /*#__PURE__*/React.createElement("span", {
|
|
219
222
|
className: "sdoc-image-content"
|
|
220
223
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -311,10 +314,10 @@ export function renderImageBlock(props, editor) {
|
|
|
311
314
|
className: "sdoc-image-block-wrapper",
|
|
312
315
|
style: {
|
|
313
316
|
display: 'flex',
|
|
314
|
-
padding: '5px 0px',
|
|
315
317
|
justifyContent: "".concat(justifyContent)
|
|
316
318
|
}
|
|
317
319
|
}, attributes, {
|
|
318
|
-
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected)
|
|
320
|
+
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
|
|
321
|
+
contentEditable: "false"
|
|
319
322
|
}), children);
|
|
320
323
|
}
|
|
@@ -8,6 +8,7 @@ import { transformToText } from './helper';
|
|
|
8
8
|
import { useScrollContext } from '../../../hooks/use-scroll-context';
|
|
9
9
|
import { INSERT_POSITION } from '../../constants';
|
|
10
10
|
import QuickInsertBlockMenu from '../../toolbar/insert-element-toolbar';
|
|
11
|
+
import { isVoidNode } from '../../toolbar/side-toolbar/helpers';
|
|
11
12
|
const RenderQuickInsert = (_ref, editor) => {
|
|
12
13
|
let {
|
|
13
14
|
attributes,
|
|
@@ -24,6 +25,7 @@ const RenderQuickInsert = (_ref, editor) => {
|
|
|
24
25
|
const insertElmRef = useRef(null);
|
|
25
26
|
const aboveBlockNode = getAboveBlockNode(editor);
|
|
26
27
|
const searchText = Node.string(element);
|
|
28
|
+
const isEmptyNode = isVoidNode(aboveBlockNode === null || aboveBlockNode === void 0 ? void 0 : aboveBlockNode[0]);
|
|
27
29
|
const handleClick = useCallback(e => {
|
|
28
30
|
if (!insertElmRef.current.contains(e.target)) {
|
|
29
31
|
transformToText(editor, element);
|
|
@@ -74,7 +76,8 @@ const RenderQuickInsert = (_ref, editor) => {
|
|
|
74
76
|
ref: sideMenuRef,
|
|
75
77
|
className: "sdoc-side-menu sdoc-dropdown-menu"
|
|
76
78
|
}, /*#__PURE__*/React.createElement(QuickInsertBlockMenu, {
|
|
77
|
-
|
|
79
|
+
isEmptyNode: isEmptyNode,
|
|
80
|
+
insertPosition: isEmptyNode ? INSERT_POSITION.CURRENT : INSERT_POSITION.AFTER,
|
|
78
81
|
slateNode: aboveBlockNode === null || aboveBlockNode === void 0 ? void 0 : aboveBlockNode[0],
|
|
79
82
|
searchText: searchText,
|
|
80
83
|
callback: handleInsertBlock
|
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
4
4
|
import { Transforms } from '@seafile/slate';
|
|
5
|
-
import { insertElement } from '../side-toolbar/helpers';
|
|
5
|
+
import { insertElement, isVoidNode } from '../side-toolbar/helpers';
|
|
6
6
|
import { insertTable } from '../../plugins/table/helpers';
|
|
7
7
|
import TableSizePopover from '../../plugins/table/popover/table-size-popover';
|
|
8
8
|
import { changeToCodeBlock } from '../../plugins/code-block/helpers';
|
|
@@ -21,7 +21,8 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
21
21
|
insertPosition,
|
|
22
22
|
slateNode,
|
|
23
23
|
searchText,
|
|
24
|
-
callback
|
|
24
|
+
callback,
|
|
25
|
+
isEmptyNode
|
|
25
26
|
} = _ref;
|
|
26
27
|
const editor = useSlateStatic();
|
|
27
28
|
const [currentSelectIndex, setCurrentSelectIndex] = useState(0);
|
|
@@ -145,6 +146,7 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
145
146
|
onClick: onInsertCheckList
|
|
146
147
|
}),
|
|
147
148
|
[PARAGRAPH]: /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
149
|
+
disabled: isEmptyNode,
|
|
148
150
|
key: "sdoc-insert-menu-paragraph",
|
|
149
151
|
menuConfig: _objectSpread({}, SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.PARAGRAPH]),
|
|
150
152
|
onClick: () => onInsert(ELEMENT_TYPE.PARAGRAPH)
|
|
@@ -158,7 +160,7 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
158
160
|
});
|
|
159
161
|
});
|
|
160
162
|
return items;
|
|
161
|
-
}, [createTable, editor, onInsert, onInsertCallout, onInsertCheckList, onInsertCodeBlock, onInsertImageToggle, onInsertList, openLinkDialog]);
|
|
163
|
+
}, [createTable, editor, isEmptyNode, onInsert, onInsertCallout, onInsertCheckList, onInsertCodeBlock, onInsertImageToggle, onInsertList, openLinkDialog]);
|
|
162
164
|
const getSelectItemDom = selectIndex => {
|
|
163
165
|
const dropDownItemWrapper = downDownWrapperRef.current;
|
|
164
166
|
const currentSelectItem = dropDownItemWrapper.children[selectIndex];
|
|
@@ -16,7 +16,8 @@ import { wrapCallout } from '../../plugins/callout/helper';
|
|
|
16
16
|
const InsertBlockMenu = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
insertPosition,
|
|
19
|
-
slateNode
|
|
19
|
+
slateNode,
|
|
20
|
+
isNodeEmpty
|
|
20
21
|
} = _ref;
|
|
21
22
|
const editor = useSlateStatic();
|
|
22
23
|
const onInsertImageToggle = useCallback(() => {
|
|
@@ -113,6 +114,7 @@ const InsertBlockMenu = _ref => {
|
|
|
113
114
|
onClick: onInsertCheckList
|
|
114
115
|
}), [SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.PARAGRAPH], ...SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.HEADER]].map(item => {
|
|
115
116
|
return /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
117
|
+
disabled: isNodeEmpty && item.type === PARAGRAPH,
|
|
116
118
|
key: item.id,
|
|
117
119
|
menuConfig: item,
|
|
118
120
|
onClick: () => onInsert(item.type)
|
|
@@ -85,6 +85,7 @@ const SideMenu = _ref => {
|
|
|
85
85
|
slateNode: slateNode,
|
|
86
86
|
onReset: onReset
|
|
87
87
|
}))), isNodeEmpty && /*#__PURE__*/React.createElement(InsertBlockMenu, {
|
|
88
|
+
isNodeEmpty: isNodeEmpty,
|
|
88
89
|
slateNode: slateNode
|
|
89
90
|
}), !isNodeEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
90
91
|
menuConfig: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.65",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a sdoc editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"react-hot-loader": "4.13.1",
|
|
142
142
|
"react-i18next": "12.1.4",
|
|
143
143
|
"react-mentions": "4.4.7",
|
|
144
|
-
"release-it": "
|
|
144
|
+
"release-it": "17.3.0",
|
|
145
145
|
"resolve": "1.12.0",
|
|
146
146
|
"resolve-url-loader": "5.0.0",
|
|
147
147
|
"sass-loader": "13.3.2",
|