@seafile/sdoc-editor 0.5.63 → 0.5.64
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.
|
@@ -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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.64",
|
|
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",
|