@seafile/sdoc-editor 0.2.18 → 0.2.20
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/code-block.css +3 -3
- package/dist/basic-sdk/assets/css/default.css +21 -0
- package/dist/basic-sdk/comment/components/editor-comment.js +8 -3
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +13 -4
- package/dist/basic-sdk/comment/components/{global-comment-header.js → global-comment/global-comment-body-header.js} +44 -36
- package/dist/basic-sdk/comment/components/global-comment/global-comment-editor.js +32 -0
- package/dist/basic-sdk/comment/components/global-comment/global-comment-header.js +31 -0
- package/dist/basic-sdk/comment/components/global-comment/index.css +130 -0
- package/dist/basic-sdk/comment/components/global-comment/index.js +176 -0
- package/dist/basic-sdk/comment/components/style.css +0 -119
- package/dist/basic-sdk/comment/constants/index.js +6 -4
- package/dist/basic-sdk/comment/hooks/use-comment-list.js +10 -5
- package/dist/basic-sdk/extension/core/queries/index.js +8 -4
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +17 -1
- package/dist/basic-sdk/extension/render/custom-element.js +15 -1
- package/dist/components/doc-operations/collaborators-operation/collaborators-popover.js +1 -0
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +2 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +4 -3
- package/public/locales/zh_CN/sdoc-editor.json +2 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +4 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +14 -6
- package/dist/basic-sdk/comment/components/global-comment.js +0 -105
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
.sdoc-code-block-code .sdoc-code-line {
|
|
19
19
|
position: relative;
|
|
20
20
|
counter-increment: number;
|
|
21
|
+
margin-left: 32px;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
.sdoc-code-block-code .sdoc-code-line::before {
|
|
24
25
|
content: counter(number);
|
|
25
26
|
color: #ccc;
|
|
26
|
-
display: inline-block;
|
|
27
27
|
width: 40px;
|
|
28
28
|
text-align: end;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
position: absolute;
|
|
30
|
+
left: -50px;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.sdoc-code-line
|
|
@@ -15,3 +15,24 @@
|
|
|
15
15
|
.element-icon {
|
|
16
16
|
color: #444 !important;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
.sdoc-icon-btn {
|
|
20
|
+
height: 24px;
|
|
21
|
+
width: 24px;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sdoc-icon-btn:hover {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sdoc-icon-btn .sdocfont {
|
|
32
|
+
color: #999;
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sdoc-icon-btn:hover .sdocfont {
|
|
37
|
+
color: #5a5a5a;
|
|
38
|
+
}
|
|
@@ -8,6 +8,7 @@ import CommentList from './comment-list';
|
|
|
8
8
|
import { useSelectionElement } from '../../hooks/use-selection-element';
|
|
9
9
|
import { useCommentContext } from '../hooks/use-comment-context';
|
|
10
10
|
import ElementsCommentCount from './elements-comment-count';
|
|
11
|
+
import { ELEMENT_TYPE } from '../../extension/constants';
|
|
11
12
|
var EditorComment = function EditorComment() {
|
|
12
13
|
useSelectionUpdate();
|
|
13
14
|
var editor = useSlateStatic();
|
|
@@ -43,9 +44,13 @@ var EditorComment = function EditorComment() {
|
|
|
43
44
|
var cursor = useCursorPosition();
|
|
44
45
|
var style = useMemo(function () {
|
|
45
46
|
var _Node$string;
|
|
46
|
-
if (selectionElement && ((_Node$string = Node.string(selectionElement)) === null || _Node$string === void 0 ? void 0 : _Node$string.length) === 0)
|
|
47
|
-
|
|
48
|
-
}
|
|
47
|
+
if (selectionElement && ((_Node$string = Node.string(selectionElement)) === null || _Node$string === void 0 ? void 0 : _Node$string.length) === 0 && !selectionElement.children.find(function (n) {
|
|
48
|
+
return n.type === ELEMENT_TYPE.IMAGE;
|
|
49
|
+
})) {
|
|
50
|
+
return {
|
|
51
|
+
top: '-99999px'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
49
54
|
var comments = element_comments_map[selectionElement === null || selectionElement === void 0 ? void 0 : selectionElement.id];
|
|
50
55
|
var unresolvedComments = comments && comments.filter(function (item) {
|
|
51
56
|
return !item.resolved;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
3
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
3
4
|
import { Editor } from '@seafile/slate';
|
|
4
5
|
import { getNodeById, focusEditor, findPath } from '../../../extension/core';
|
|
@@ -6,12 +7,15 @@ import { useScrollContext } from '../../../hooks/use-scroll-context';
|
|
|
6
7
|
import { getElementCommentCountTop } from '../../helper';
|
|
7
8
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
8
9
|
var ElementCommentCount = function ElementCommentCount(_ref) {
|
|
9
|
-
var _scrollRef$current;
|
|
10
10
|
var elementId = _ref.elementId,
|
|
11
11
|
commentsCount = _ref.commentsCount;
|
|
12
12
|
var editor = useSlateStatic();
|
|
13
13
|
var element = getNodeById(editor.children, elementId);
|
|
14
14
|
var scrollRef = useScrollContext();
|
|
15
|
+
var _useState = useState(-9999),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
top = _useState2[0],
|
|
18
|
+
setTop = _useState2[1];
|
|
15
19
|
var onClick = useCallback(function (event) {
|
|
16
20
|
eventStopPropagation(event);
|
|
17
21
|
var path = findPath(editor, element);
|
|
@@ -22,9 +26,14 @@ var ElementCommentCount = function ElementCommentCount(_ref) {
|
|
|
22
26
|
};
|
|
23
27
|
focusEditor(editor, range);
|
|
24
28
|
}, [editor, element]);
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
var _scrollRef$current;
|
|
31
|
+
if (!element) return;
|
|
32
|
+
var scrollTop = (scrollRef === null || scrollRef === void 0 ? void 0 : (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) || 0;
|
|
33
|
+
var newTop = getElementCommentCountTop(editor, element, scrollTop);
|
|
34
|
+
setTop(newTop);
|
|
35
|
+
}, [editor, elementId, element, scrollRef]);
|
|
25
36
|
if (!element) return null;
|
|
26
|
-
var scrollTop = (scrollRef === null || scrollRef === void 0 ? void 0 : (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) || 0;
|
|
27
|
-
var top = getElementCommentCountTop(editor, element, scrollTop);
|
|
28
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
38
|
className: "element-comments-count",
|
|
30
39
|
style: {
|
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
|
5
|
-
import { eventStopPropagation } from '
|
|
6
|
-
import { COMMENT_TYPES } from '
|
|
7
|
-
import CommentAllParticipants from '
|
|
8
|
-
function
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
6
|
+
import { COMMENT_TYPES } from '../../constants';
|
|
7
|
+
import CommentAllParticipants from '../comment-all-participants';
|
|
8
|
+
var CommentTypeDropdownItem = function CommentTypeDropdownItem(_ref) {
|
|
9
|
+
var type = _ref.type,
|
|
10
|
+
setCommentType = _ref.setCommentType;
|
|
11
|
+
var _useTranslation = useTranslation(),
|
|
12
|
+
t = _useTranslation.t;
|
|
13
|
+
var handleCommentTypeChanged = useCallback(function (event, type) {
|
|
14
|
+
eventStopPropagation(event);
|
|
15
|
+
setCommentType(type);
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
+
}, []);
|
|
19
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
20
|
+
className: "sdoc-dropdown-menu-item",
|
|
21
|
+
tag: 'div',
|
|
22
|
+
onClick: function onClick(event) {
|
|
23
|
+
return handleCommentTypeChanged(event, type);
|
|
24
|
+
}
|
|
25
|
+
}, t(type));
|
|
26
|
+
};
|
|
27
|
+
var GlobalCommentBodyHeader = function GlobalCommentBodyHeader(_ref2) {
|
|
28
|
+
var commentList = _ref2.commentList,
|
|
29
|
+
commentType = _ref2.commentType,
|
|
30
|
+
setCommentType = _ref2.setCommentType;
|
|
31
|
+
var _useTranslation2 = useTranslation(),
|
|
32
|
+
t = _useTranslation2.t;
|
|
13
33
|
var _useState = useState(false),
|
|
14
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
15
35
|
isDropdownOpen = _useState2[0],
|
|
@@ -22,12 +42,6 @@ function GlobalCommentHeader(_ref) {
|
|
|
22
42
|
count: commentList.length
|
|
23
43
|
});
|
|
24
44
|
}
|
|
25
|
-
var handleCommentTypeChanged = useCallback(function (event, type) {
|
|
26
|
-
eventStopPropagation(event);
|
|
27
|
-
onCommentTypeChanged(type);
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
-
}, []);
|
|
31
45
|
var id = 'comment-type-controller';
|
|
32
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
33
47
|
className: "comments-panel-body__header"
|
|
@@ -50,26 +64,20 @@ function GlobalCommentHeader(_ref) {
|
|
|
50
64
|
}, t(commentType))), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
51
65
|
className: "sdoc-dropdown-menu",
|
|
52
66
|
container: "comment-types"
|
|
53
|
-
}, /*#__PURE__*/React.createElement(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
className: "sdoc-dropdown-menu-item",
|
|
67
|
-
tag: 'div',
|
|
68
|
-
onClick: function onClick(event) {
|
|
69
|
-
return handleCommentTypeChanged(event, COMMENT_TYPES.unresolved);
|
|
70
|
-
}
|
|
71
|
-
}, t(COMMENT_TYPES.unresolved))))), /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
}, /*#__PURE__*/React.createElement(CommentTypeDropdownItem, {
|
|
68
|
+
type: COMMENT_TYPES.ALL,
|
|
69
|
+
setCommentType: setCommentType
|
|
70
|
+
}), /*#__PURE__*/React.createElement(CommentTypeDropdownItem, {
|
|
71
|
+
type: COMMENT_TYPES.DOC,
|
|
72
|
+
setCommentType: setCommentType
|
|
73
|
+
}), /*#__PURE__*/React.createElement(CommentTypeDropdownItem, {
|
|
74
|
+
type: COMMENT_TYPES.RESOLVED,
|
|
75
|
+
setCommentType: setCommentType
|
|
76
|
+
}), /*#__PURE__*/React.createElement(CommentTypeDropdownItem, {
|
|
77
|
+
type: COMMENT_TYPES.UNRESOLVED,
|
|
78
|
+
setCommentType: setCommentType
|
|
79
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
72
80
|
className: "comment-count-tip"
|
|
73
81
|
}, commentTip)));
|
|
74
|
-
}
|
|
75
|
-
export default
|
|
82
|
+
};
|
|
83
|
+
export default GlobalCommentBodyHeader;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import CommentEditor from '../comment-editor';
|
|
3
|
+
var GlobalCommentEditor = function GlobalCommentEditor(_ref) {
|
|
4
|
+
var insertDocComment = _ref.insertDocComment,
|
|
5
|
+
hiddenCommentEditor = _ref.hiddenCommentEditor;
|
|
6
|
+
var ref = useRef(null);
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
var hidden = function hidden(event) {
|
|
9
|
+
if (!ref.current.contains(event.target)) {
|
|
10
|
+
hiddenCommentEditor();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
document.addEventListener('click', hidden);
|
|
14
|
+
return function () {
|
|
15
|
+
document.removeEventListener('click', hidden);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, []);
|
|
20
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: "sdoc-doc-comment-editor-container sdoc-comment-list-container",
|
|
22
|
+
ref: ref
|
|
23
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: "comment-ui-container active"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(CommentEditor, {
|
|
26
|
+
type: "comment",
|
|
27
|
+
className: "sdoc-doc-comment-editor",
|
|
28
|
+
insertContent: insertDocComment,
|
|
29
|
+
hiddenComment: hiddenCommentEditor
|
|
30
|
+
})));
|
|
31
|
+
};
|
|
32
|
+
export default GlobalCommentEditor;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
4
|
+
var GlobalCommentHeader = function GlobalCommentHeader(_ref) {
|
|
5
|
+
var toggle = _ref.toggle,
|
|
6
|
+
toggleGlobalCommentEditor = _ref.toggleGlobalCommentEditor;
|
|
7
|
+
var _useTranslation = useTranslation(),
|
|
8
|
+
t = _useTranslation.t;
|
|
9
|
+
var toggleADDComment = useCallback(function (event) {
|
|
10
|
+
eventStopPropagation(event);
|
|
11
|
+
toggleGlobalCommentEditor();
|
|
12
|
+
}, [toggleGlobalCommentEditor]);
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "comments-panel-header"
|
|
15
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
16
|
+
className: "title"
|
|
17
|
+
}, t('Comments')), /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "comments-panel-header-right"
|
|
19
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "sdoc-icon-btn",
|
|
21
|
+
onClick: toggleADDComment
|
|
22
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
23
|
+
className: "sdocfont sdoc-add-comment"
|
|
24
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "sdoc-icon-btn",
|
|
26
|
+
onClick: toggle
|
|
27
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
28
|
+
className: "sdocfont sdoc-sm-close"
|
|
29
|
+
}))));
|
|
30
|
+
};
|
|
31
|
+
export default GlobalCommentHeader;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
.global-comments-popover {
|
|
2
|
+
position: absolute;
|
|
3
|
+
right: 10px;
|
|
4
|
+
top: 50px;
|
|
5
|
+
z-index: 103;
|
|
6
|
+
width: 340px;
|
|
7
|
+
height: 540px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.global-comments-popover .comments-panel-wrapper {
|
|
11
|
+
height: 100%;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
background: #fff;
|
|
15
|
+
border: 1px solid #EAECEF;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.global-comments-popover .comments-panel-header {
|
|
21
|
+
padding: 0 16px;
|
|
22
|
+
height: 46px;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
border-bottom: 1px solid #EAECEF;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.global-comments-popover .comments-panel-header .title {
|
|
30
|
+
color: #212529;
|
|
31
|
+
font-size: 16px;
|
|
32
|
+
font-weight: 500;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.global-comments-popover .comments-panel-header .comments-panel-header-right {
|
|
36
|
+
display: flex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.global-comments-popover .comments-panel-header-right .sdoc-icon-btn:not(:last-child) {
|
|
40
|
+
margin-right: 4px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.global-comments-popover .comments-panel-header .sdoc-icon-btn .sdocfont {
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.global-comments-popover .comments-panel-body {
|
|
48
|
+
flex: 1;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
min-height: 0;
|
|
52
|
+
position: relative;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.global-comments-popover .comments-panel-body__header {
|
|
56
|
+
height: 80px;
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
padding: 0 16px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.global-comments-popover .comments-panel-body__header .comments-types-count {
|
|
63
|
+
height: 38px;
|
|
64
|
+
display: flex;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
align-items: center;
|
|
67
|
+
padding: 16px 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.global-comments-popover .comments-panel-body__header .comment-type {
|
|
71
|
+
color: #212529;
|
|
72
|
+
font-size: 12px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.global-comments-popover .comments-panel-body__header .comment-type{
|
|
76
|
+
color: #212529;
|
|
77
|
+
font-size: 12px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.global-comments-popover .comments-panel-body__header .comment-count-tip {
|
|
81
|
+
color: #999;
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.global-comments-popover .comments-panel-body__content {
|
|
86
|
+
flex: 1;
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
padding: 16px;
|
|
90
|
+
overflow: auto;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.global-comments-popover .comments-panel-body__content .sdoc-comment-list-container {
|
|
94
|
+
position: relative;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.global-comments-popover .comments-panel-body__content .comment-item-list {
|
|
98
|
+
max-width: 308px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.global-comments-popover .comments-panel-body__content .comment-ui-container.active {
|
|
102
|
+
left: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.global-comments-popover .comments-panel-body__content .comment-ui-container.sdoc-resolved {
|
|
106
|
+
background: #f5f5f5;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.global-comments-popover .comments-panel-body__content .comment-ui-container.active.sdoc-resolved {
|
|
110
|
+
background: #f5f5f5;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.sdoc-dropdown-menu .dropdown-item {
|
|
114
|
+
font-size: 14px;
|
|
115
|
+
color: #212529;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* doc comment add editor */
|
|
119
|
+
.global-comments-popover .comments-panel-body .sdoc-doc-comment-editor-container {
|
|
120
|
+
position: absolute;
|
|
121
|
+
left: 16px;
|
|
122
|
+
width: calc(100% - 32px);
|
|
123
|
+
background-color: #fff;
|
|
124
|
+
top: 78px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.global-comments-popover .sdoc-doc-comment-editor-container .comment-ui-container.active {
|
|
128
|
+
left: 0;
|
|
129
|
+
margin-bottom: 0;
|
|
130
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import { ElementPopover } from '../../../extension/commons';
|
|
8
|
+
import EventBus from '../../../utils/event-bus';
|
|
9
|
+
import useCommentList from '../../hooks/use-comment-list';
|
|
10
|
+
import CommentItemWrapper from '../comment-item-wrapper';
|
|
11
|
+
import GlobalCommentHeader from './global-comment-header';
|
|
12
|
+
import GlobalCommentBodyHeader from './global-comment-body-header';
|
|
13
|
+
import { DOC_COMMENT_ELEMENT_ID } from '../../constants';
|
|
14
|
+
import context from '../../../../context';
|
|
15
|
+
import { useCommentContext } from '../../hooks/use-comment-context';
|
|
16
|
+
import GlobalCommentEditor from './global-comment-editor';
|
|
17
|
+
import './index.css';
|
|
18
|
+
var GlobalComment = function GlobalComment() {
|
|
19
|
+
var _useState = useState(null),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
activeComment = _useState2[0],
|
|
22
|
+
setActiveComment = _useState2[1];
|
|
23
|
+
var commentRef = useRef(null);
|
|
24
|
+
var contentRef = useRef(null);
|
|
25
|
+
var _useCommentList = useCommentList(),
|
|
26
|
+
commentList = _useCommentList.commentList,
|
|
27
|
+
commentType = _useCommentList.commentType,
|
|
28
|
+
setCommentType = _useCommentList.setCommentType;
|
|
29
|
+
var _useState3 = useState(false),
|
|
30
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
31
|
+
isShowCommentList = _useState4[0],
|
|
32
|
+
setShowCommentList = _useState4[1];
|
|
33
|
+
var _useState5 = useState(false),
|
|
34
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
35
|
+
showEditor = _useState6[0],
|
|
36
|
+
setShowEditor = _useState6[1];
|
|
37
|
+
var toggle = useCallback(function () {
|
|
38
|
+
if (isShowCommentList) {
|
|
39
|
+
setActiveComment(null);
|
|
40
|
+
setShowCommentList(false);
|
|
41
|
+
setShowEditor(false);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setShowCommentList(true);
|
|
45
|
+
}, [isShowCommentList]);
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
if (!isShowCommentList) return;
|
|
48
|
+
var toggleOuterSide = function toggleOuterSide(e) {
|
|
49
|
+
var commentWrapper = commentRef.current;
|
|
50
|
+
var clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
51
|
+
if (clickIsInComment) return;
|
|
52
|
+
toggle();
|
|
53
|
+
};
|
|
54
|
+
document.addEventListener('click', toggleOuterSide);
|
|
55
|
+
return function () {
|
|
56
|
+
document.removeEventListener('click', toggleOuterSide);
|
|
57
|
+
};
|
|
58
|
+
}, [isShowCommentList, toggle]);
|
|
59
|
+
useEffect(function () {
|
|
60
|
+
var eventBus = EventBus.getInstance();
|
|
61
|
+
var unsubscribe = eventBus.subscribe('COMMENT_LIST_CLICK', toggle);
|
|
62
|
+
return function () {
|
|
63
|
+
unsubscribe();
|
|
64
|
+
};
|
|
65
|
+
}, [toggle]);
|
|
66
|
+
var updateScrollPosition = useCallback(function () {
|
|
67
|
+
var resolvedDom = document.querySelector('.sdoc-resolved');
|
|
68
|
+
contentRef.current.scrollTo({
|
|
69
|
+
top: resolvedDom.offsetTop,
|
|
70
|
+
behavior: 'smooth'
|
|
71
|
+
});
|
|
72
|
+
}, []);
|
|
73
|
+
var hiddenComment = useCallback(function () {
|
|
74
|
+
setActiveComment(null);
|
|
75
|
+
}, []);
|
|
76
|
+
var onCommentClick = useCallback(function (comment) {
|
|
77
|
+
if (activeComment && activeComment.id === comment.id) return;
|
|
78
|
+
setActiveComment(comment);
|
|
79
|
+
}, [activeComment]);
|
|
80
|
+
var _useCommentContext = useCommentContext(),
|
|
81
|
+
dispatch = _useCommentContext.dispatch;
|
|
82
|
+
var insertComment = useCallback( /*#__PURE__*/function () {
|
|
83
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(elementId, comment) {
|
|
84
|
+
var res, returnComment, newComment;
|
|
85
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
86
|
+
while (1) switch (_context.prev = _context.next) {
|
|
87
|
+
case 0:
|
|
88
|
+
_context.next = 2;
|
|
89
|
+
return context.insertComment(comment);
|
|
90
|
+
case 2:
|
|
91
|
+
res = _context.sent;
|
|
92
|
+
returnComment = res.data.comment;
|
|
93
|
+
newComment = _objectSpread(_objectSpread({}, comment), {}, {
|
|
94
|
+
id: returnComment.id,
|
|
95
|
+
user_name: returnComment.user_name,
|
|
96
|
+
avatar_url: returnComment.avatar_url,
|
|
97
|
+
replies: []
|
|
98
|
+
});
|
|
99
|
+
dispatch({
|
|
100
|
+
type: 'INSERT_COMMENT',
|
|
101
|
+
payload: {
|
|
102
|
+
element_id: elementId,
|
|
103
|
+
comment: newComment
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
setShowEditor(false);
|
|
107
|
+
case 7:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee);
|
|
112
|
+
}));
|
|
113
|
+
return function (_x, _x2) {
|
|
114
|
+
return _ref.apply(this, arguments);
|
|
115
|
+
};
|
|
116
|
+
}(), [dispatch]);
|
|
117
|
+
var insertDocComment = useCallback(function (commentDetail) {
|
|
118
|
+
var user = context.getUserInfo();
|
|
119
|
+
var elementId = DOC_COMMENT_ELEMENT_ID;
|
|
120
|
+
var time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
121
|
+
var comment = {
|
|
122
|
+
comment: commentDetail,
|
|
123
|
+
detail: {
|
|
124
|
+
element_id: elementId,
|
|
125
|
+
comment: commentDetail
|
|
126
|
+
},
|
|
127
|
+
author: user.username,
|
|
128
|
+
updated_at: time
|
|
129
|
+
};
|
|
130
|
+
insertComment(elementId, comment);
|
|
131
|
+
}, [insertComment]);
|
|
132
|
+
var toggleGlobalCommentEditor = useCallback(function () {
|
|
133
|
+
setShowEditor(!showEditor);
|
|
134
|
+
setActiveComment(null);
|
|
135
|
+
}, [showEditor]);
|
|
136
|
+
var hiddenCommentEditor = useCallback(function () {
|
|
137
|
+
setShowEditor(false);
|
|
138
|
+
}, []);
|
|
139
|
+
if (!isShowCommentList) return null;
|
|
140
|
+
return /*#__PURE__*/React.createElement(ElementPopover, {
|
|
141
|
+
className: "global-comments-popover"
|
|
142
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
ref: commentRef,
|
|
144
|
+
className: "comments-panel-wrapper"
|
|
145
|
+
}, /*#__PURE__*/React.createElement(GlobalCommentHeader, {
|
|
146
|
+
toggle: toggle,
|
|
147
|
+
toggleGlobalCommentEditor: toggleGlobalCommentEditor
|
|
148
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
className: "comments-panel-body"
|
|
150
|
+
}, /*#__PURE__*/React.createElement(GlobalCommentBodyHeader, {
|
|
151
|
+
commentList: commentList,
|
|
152
|
+
commentType: commentType,
|
|
153
|
+
setCommentType: setCommentType
|
|
154
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
155
|
+
ref: contentRef,
|
|
156
|
+
className: "comments-panel-body__content"
|
|
157
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
158
|
+
id: "global-comment-list-container",
|
|
159
|
+
className: "sdoc-comment-list-container"
|
|
160
|
+
}, commentList.map(function (comment) {
|
|
161
|
+
var isActive = activeComment && activeComment.id === comment.id;
|
|
162
|
+
return /*#__PURE__*/React.createElement(CommentItemWrapper, {
|
|
163
|
+
key: comment.id,
|
|
164
|
+
container: "global-comment-list-container",
|
|
165
|
+
comment: comment,
|
|
166
|
+
isActive: isActive,
|
|
167
|
+
onCommentClick: onCommentClick,
|
|
168
|
+
hiddenComment: hiddenComment,
|
|
169
|
+
updateScrollPosition: updateScrollPosition
|
|
170
|
+
});
|
|
171
|
+
}))), showEditor && /*#__PURE__*/React.createElement(GlobalCommentEditor, {
|
|
172
|
+
hiddenCommentEditor: hiddenCommentEditor,
|
|
173
|
+
insertDocComment: insertDocComment
|
|
174
|
+
}))));
|
|
175
|
+
};
|
|
176
|
+
export default GlobalComment;
|
|
@@ -37,122 +37,3 @@
|
|
|
37
37
|
left: 14px;
|
|
38
38
|
width: 280px;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
/* global comment css */
|
|
42
|
-
.global-comments-popover {
|
|
43
|
-
position: absolute;
|
|
44
|
-
right: 10px;
|
|
45
|
-
top: 50px;
|
|
46
|
-
z-index: 103;
|
|
47
|
-
width: 340px;
|
|
48
|
-
height: 540px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.global-comments-popover .comments-panel-wrapper {
|
|
52
|
-
height: 100%;
|
|
53
|
-
display: flex;
|
|
54
|
-
flex-direction: column;
|
|
55
|
-
background: #fff;
|
|
56
|
-
border: 1px solid #EAECEF;
|
|
57
|
-
border-radius: 4px;
|
|
58
|
-
box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.global-comments-popover .comments-panel-header {
|
|
62
|
-
padding: 0 16px;
|
|
63
|
-
height: 46px;
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
justify-content: space-between;
|
|
67
|
-
border-bottom: 1px solid #EAECEF;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.global-comments-popover .comments-panel-header .title {
|
|
71
|
-
color: #212529;
|
|
72
|
-
font-size: 16px;
|
|
73
|
-
font-weight: 500;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.global-comments-popover .comments-panel-header .sdoc-sm-close {
|
|
77
|
-
display: flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
justify-content: center;
|
|
80
|
-
font-size: 16px;
|
|
81
|
-
font-weight: 700;
|
|
82
|
-
color: #999;
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.global-comments-popover .comments-panel-header .sdoc-sm-close:hover {
|
|
87
|
-
color: #5a5a5a;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.global-comments-popover .comments-panel-body {
|
|
91
|
-
flex: 1;
|
|
92
|
-
display: flex;
|
|
93
|
-
flex-direction: column;
|
|
94
|
-
min-height: 0;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.global-comments-popover .comments-panel-body__header {
|
|
98
|
-
height: 80px;
|
|
99
|
-
display: flex;
|
|
100
|
-
flex-direction: column;
|
|
101
|
-
padding: 0 16px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.global-comments-popover .comments-panel-body__header .comments-types-count {
|
|
105
|
-
height: 38px;
|
|
106
|
-
display: flex;
|
|
107
|
-
justify-content: space-between;
|
|
108
|
-
align-items: center;
|
|
109
|
-
padding: 16px 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.global-comments-popover .comments-panel-body__header .comment-type {
|
|
113
|
-
color: #212529;
|
|
114
|
-
font-size: 12px;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.global-comments-popover .comments-panel-body__header .comment-type{
|
|
118
|
-
color: #212529;
|
|
119
|
-
font-size: 12px;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.global-comments-popover .comments-panel-body__header .comment-count-tip {
|
|
123
|
-
color: #999;
|
|
124
|
-
font-size: 12px;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.global-comments-popover .comments-panel-body__content {
|
|
128
|
-
flex: 1;
|
|
129
|
-
display: flex;
|
|
130
|
-
flex-direction: column;
|
|
131
|
-
padding: 16px;
|
|
132
|
-
overflow: auto;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.global-comments-popover .comments-panel-body__content .sdoc-comment-list-container {
|
|
136
|
-
position: relative;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.global-comments-popover .comments-panel-body__content .comment-item-list {
|
|
140
|
-
max-width: 308px;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.global-comments-popover .comments-panel-body__content .comment-ui-container.active {
|
|
144
|
-
left: 0;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.global-comments-popover .comments-panel-body__content .comment-ui-container.sdoc-resolved {
|
|
148
|
-
background: #f5f5f5;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.global-comments-popover .comments-panel-body__content .comment-ui-container.active.sdoc-resolved {
|
|
152
|
-
background: #f5f5f5;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.sdoc-dropdown-menu .dropdown-item {
|
|
156
|
-
font-size: 14px;
|
|
157
|
-
color: #212529;
|
|
158
|
-
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export var COMMENT_TYPES = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
DOC: 'Doc_comments',
|
|
3
|
+
ALL: 'All_comments',
|
|
4
|
+
RESOLVED: 'Resolved_comments',
|
|
5
|
+
UNRESOLVED: 'Unresolved_comments'
|
|
5
6
|
};
|
|
6
7
|
export var DOWN = 'down';
|
|
7
8
|
export var UP = 'up';
|
|
8
9
|
export var FONT_SIZE_WIDTH = 15;
|
|
9
10
|
export var LINE_HEIGHT = 22;
|
|
10
11
|
export var POPOVER_ADDING_HEIGHT = 10;
|
|
11
|
-
export var COMMENT_URL_CLASSNAME = 'sdoc-comment-url';
|
|
12
|
+
export var COMMENT_URL_CLASSNAME = 'sdoc-comment-url';
|
|
13
|
+
export var DOC_COMMENT_ELEMENT_ID = '0';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { useCommentContext } from './use-comment-context';
|
|
4
|
-
import { COMMENT_TYPES } from '../constants';
|
|
4
|
+
import { COMMENT_TYPES, DOC_COMMENT_ELEMENT_ID } from '../constants';
|
|
5
5
|
var useCommentList = function useCommentList() {
|
|
6
6
|
var _useCommentContext = useCommentContext(),
|
|
7
7
|
commentsInfo = _useCommentContext.commentsInfo;
|
|
8
8
|
var _ref = commentsInfo || [],
|
|
9
9
|
comment_list = _ref.comment_list;
|
|
10
|
-
var _useState = useState(COMMENT_TYPES.
|
|
10
|
+
var _useState = useState(COMMENT_TYPES.ALL),
|
|
11
11
|
_useState2 = _slicedToArray(_useState, 2),
|
|
12
12
|
commentType = _useState2[0],
|
|
13
13
|
setCommentType = _useState2[1];
|
|
@@ -16,18 +16,23 @@ var useCommentList = function useCommentList() {
|
|
|
16
16
|
commentList = _useState4[0],
|
|
17
17
|
setCommentList = _useState4[1];
|
|
18
18
|
useEffect(function () {
|
|
19
|
-
if (commentType === COMMENT_TYPES.
|
|
19
|
+
if (commentType === COMMENT_TYPES.ALL) {
|
|
20
20
|
setCommentList(comment_list);
|
|
21
|
-
} else if (commentType === COMMENT_TYPES.
|
|
21
|
+
} else if (commentType === COMMENT_TYPES.RESOLVED) {
|
|
22
22
|
var _commentList = comment_list.filter(function (item) {
|
|
23
23
|
return item.resolved;
|
|
24
24
|
});
|
|
25
25
|
setCommentList(_commentList);
|
|
26
|
-
} else if (commentType === COMMENT_TYPES.
|
|
26
|
+
} else if (commentType === COMMENT_TYPES.UNRESOLVED) {
|
|
27
27
|
var _commentList2 = comment_list.filter(function (item) {
|
|
28
28
|
return !item.resolved;
|
|
29
29
|
});
|
|
30
30
|
setCommentList(_commentList2);
|
|
31
|
+
} else if (commentType === COMMENT_TYPES.DOC) {
|
|
32
|
+
var _commentList3 = comment_list.filter(function (comment) {
|
|
33
|
+
return comment.detail.element_id === DOC_COMMENT_ELEMENT_ID;
|
|
34
|
+
});
|
|
35
|
+
setCommentList(_commentList3);
|
|
31
36
|
}
|
|
32
37
|
}, [commentType, comment_list]);
|
|
33
38
|
return {
|
|
@@ -8,6 +8,7 @@ import { Editor, Text, Path, Span, Element, Node, Range } from '@seafile/slate';
|
|
|
8
8
|
import { ReactEditor } from '@seafile/slate-react';
|
|
9
9
|
import { match } from '../utils';
|
|
10
10
|
import ObjectUtils from '../../../utils/object-utils';
|
|
11
|
+
import { CODE_LINE } from '../../constants';
|
|
11
12
|
|
|
12
13
|
// options
|
|
13
14
|
export var getQueryOptions = function getQueryOptions(editor, options) {
|
|
@@ -479,16 +480,19 @@ export var isBlockAboveEmpty = function isBlockAboveEmpty(editor) {
|
|
|
479
480
|
return isAncestorEmpty(editor, block);
|
|
480
481
|
};
|
|
481
482
|
export var isSelectionAtBlockStart = function isSelectionAtBlockStart(editor, options) {
|
|
482
|
-
var _getAboveBlockNode2;
|
|
483
483
|
var selection = editor.selection;
|
|
484
484
|
if (!selection) return false;
|
|
485
|
-
var
|
|
485
|
+
var nodeEntry = getAboveBlockNode(editor, options);
|
|
486
|
+
var path = nodeEntry === null || nodeEntry === void 0 ? void 0 : nodeEntry[1];
|
|
487
|
+
if ((nodeEntry === null || nodeEntry === void 0 ? void 0 : nodeEntry[0].type) === CODE_LINE) {
|
|
488
|
+
path = [path[0]];
|
|
489
|
+
}
|
|
486
490
|
if (!path) return false;
|
|
487
491
|
return isStartPoint(editor, selection.focus, path) || Range.isExpanded(editor.selection) && isStartPoint(editor, selection.anchor, path);
|
|
488
492
|
};
|
|
489
493
|
export var isSelectionAtBlockEnd = function isSelectionAtBlockEnd(editor, options) {
|
|
490
|
-
var
|
|
491
|
-
var path = (
|
|
494
|
+
var _getAboveBlockNode2, _editor$selection;
|
|
495
|
+
var path = (_getAboveBlockNode2 = getAboveBlockNode(editor, options)) === null || _getAboveBlockNode2 === void 0 ? void 0 : _getAboveBlockNode2[1];
|
|
492
496
|
return !!path && isEndPoint(editor, (_editor$selection = editor.selection) === null || _editor$selection === void 0 ? void 0 : _editor$selection.focus, path);
|
|
493
497
|
};
|
|
494
498
|
export var isLastNode = function isLastNode(editor, node) {
|
|
@@ -112,7 +112,7 @@ var FileLink = function FileLink(_ref) {
|
|
|
112
112
|
className: "sdoc-file-link-icon",
|
|
113
113
|
style: style
|
|
114
114
|
}, /*#__PURE__*/React.createElement("i", {
|
|
115
|
-
className: "sdocfont sdoc-
|
|
115
|
+
className: "sdocfont sdoc-link-file"
|
|
116
116
|
})), /*#__PURE__*/React.createElement("span", {
|
|
117
117
|
className: "sdoc-file-text-link",
|
|
118
118
|
style: style
|
|
@@ -279,7 +279,8 @@ function renderImage(props, editor) {
|
|
|
279
279
|
var isSelected = useSelected();
|
|
280
280
|
|
|
281
281
|
// decorate diff-viewer
|
|
282
|
-
var element = props.element
|
|
282
|
+
var element = props.element,
|
|
283
|
+
leaf = props.leaf;
|
|
283
284
|
if (element.ADD || element.DELETE) {
|
|
284
285
|
var style = element.ADD ? ADDED_STYLE : DELETED_STYLE;
|
|
285
286
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -290,6 +291,21 @@ function renderImage(props, editor) {
|
|
|
290
291
|
height: 'fit-content'
|
|
291
292
|
}
|
|
292
293
|
}, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
|
|
294
|
+
className: classNames(props.className || '', 'm-0'),
|
|
295
|
+
editor: editor,
|
|
296
|
+
isSelected: isSelected
|
|
297
|
+
})));
|
|
298
|
+
}
|
|
299
|
+
if (leaf && leaf.computed_background_color) {
|
|
300
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
301
|
+
className: "d-inline-block p-1",
|
|
302
|
+
style: {
|
|
303
|
+
backgroundColor: leaf.computed_background_color,
|
|
304
|
+
width: 'fit-content',
|
|
305
|
+
height: 'fit-content'
|
|
306
|
+
}
|
|
307
|
+
}, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
|
|
308
|
+
className: classNames(props.className || '', 'm-0'),
|
|
293
309
|
editor: editor,
|
|
294
310
|
isSelected: isSelected
|
|
295
311
|
})));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import { useCallback } from 'react';
|
|
3
4
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
@@ -5,6 +6,7 @@ import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4,
|
|
|
5
6
|
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin } from '../plugins';
|
|
6
7
|
import EventBus from '../../utils/event-bus';
|
|
7
8
|
import { INTERNAL_EVENT } from '../../constants';
|
|
9
|
+
import { getParentNode } from '../core';
|
|
8
10
|
var CustomRenderElement = function CustomRenderElement(props) {
|
|
9
11
|
var editor = useSlateStatic();
|
|
10
12
|
var element = props.element,
|
|
@@ -102,9 +104,21 @@ var CustomRenderElement = function CustomRenderElement(props) {
|
|
|
102
104
|
}
|
|
103
105
|
case IMAGE:
|
|
104
106
|
{
|
|
107
|
+
var _editor$element_comme;
|
|
108
|
+
var parentNode = getParentNode(editor.children, element.id);
|
|
109
|
+
var comments = ((_editor$element_comme = editor.element_comments_map) === null || _editor$element_comme === void 0 ? void 0 : _editor$element_comme[parentNode.id]) || [];
|
|
110
|
+
var unresolvedComments = comments && comments.filter(function (item) {
|
|
111
|
+
return !item.resolved;
|
|
112
|
+
});
|
|
113
|
+
var leaf = {};
|
|
114
|
+
if (unresolvedComments && unresolvedComments.length > 0) {
|
|
115
|
+
leaf['computed_background_color'] = 'rgba(129, 237, 247, 0.5)';
|
|
116
|
+
}
|
|
105
117
|
var _ImagePlugin$renderEl = _slicedToArray(ImagePlugin.renderElements, 1),
|
|
106
118
|
renderImage = _ImagePlugin$renderEl[0];
|
|
107
|
-
return renderImage(props,
|
|
119
|
+
return renderImage(_objectSpread(_objectSpread({}, props), {}, {
|
|
120
|
+
leaf: leaf
|
|
121
|
+
}), editor);
|
|
108
122
|
}
|
|
109
123
|
case ELEMENT_TYPE.TABLE:
|
|
110
124
|
{
|
|
@@ -25,6 +25,7 @@ var CollaboratorsPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
25
25
|
popperClassName: "collaborators-popover",
|
|
26
26
|
trigger: "legacy",
|
|
27
27
|
hideArrow: true,
|
|
28
|
+
fade: false,
|
|
28
29
|
security: "fixed"
|
|
29
30
|
}, /*#__PURE__*/React.createElement(PopoverHeader, {
|
|
30
31
|
className: "popover-header"
|
package/package.json
CHANGED
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Smazání se nezdařilo",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Löschen fehlgeschlagen",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Delete failed",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Eliminar falló",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Échec de la suppression",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Rimozione fallita",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -389,7 +389,8 @@
|
|
|
389
389
|
"Published": "Опубликовано",
|
|
390
390
|
"Delete_Successfully": "Удалено",
|
|
391
391
|
"Delete_failed": "Не удалось удалить",
|
|
392
|
-
"Insert_caption": "
|
|
393
|
-
"No_collaborators_available": "
|
|
394
|
-
"Find_a_collaborator": "
|
|
392
|
+
"Insert_caption": "Вставить подпись",
|
|
393
|
+
"No_collaborators_available": "Нет доступных соавторов",
|
|
394
|
+
"Find_a_collaborator": "Найти соавтора",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
Binary file
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="check-mark" unicode="" d="M329.6 96l-284.8 275.2c-25.6 22.4-25.6 60.8-3.2 86.4 25.6 25.6 64 25.6 89.6 0l265.6-256L892.8 697.6c22.4 22.4 64 25.6 86.4 0 22.4-22.4 25.6-60.8 3.2-83.2L464 99.2c-35.2-38.4-96-38.4-134.4-3.2z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
19
|
+
<glyph glyph-name="add" unicode="" d="M448 448V832h128v-384h384v-128H576v-384h-128V320H64v128h384z" horiz-adv-x="1024" />
|
|
20
|
+
|
|
17
21
|
<glyph glyph-name="sdoc-add" unicode="" d="M512-128C227.2-128 0 99.2 0 384S227.2 896 512 896s512-227.2 512-512-227.2-512-512-512z m-51.2 563.2H291.2c-19.2 0-35.2-12.8-35.2-35.2v-35.2c0-19.2 12.8-35.2 35.2-35.2h169.6V160c0-19.2 12.8-35.2 35.2-35.2h35.2c19.2 0 35.2 12.8 35.2 35.2v169.6H736c19.2 0 35.2 12.8 35.2 35.2v35.2c0 19.2-12.8 35.2-35.2 35.2h-169.6V604.8c0 19.2-12.8 35.2-35.2 35.2h-35.2c-19.2 0-35.2-12.8-35.2-35.2v-169.6z" horiz-adv-x="1024" />
|
|
18
22
|
|
|
19
23
|
<glyph glyph-name="sdoc-tag" unicode="" d="M521.353986 860.33363l466.979644-466.979644c22.389435-22.389435 35.183398-51.175851 35.183398-83.160758s-12.793963-60.771324-35.183398-83.160759l-323.047562-319.849071c-22.389435-22.389435-51.175851-35.183398-79.962268-35.183398-31.984907 0-60.771324 12.793963-83.160758 35.183398L35.183398 374.163042c-25.587926 25.587926-38.381889 60.771324-31.984907 95.954721l31.984907 291.062655c6.396981 54.374342 47.977361 95.954721 102.351703 102.351703l291.062654 31.984907c31.984907 3.198491 67.168305-9.595472 92.756231-35.183398zM444.590209 767.577399L159.924536 735.592492l-31.984908-281.467182L578.926819-0.060372l316.65058 313.45209L444.590209 767.577399z m12.793963-127.939628c57.572833-57.572833 57.572833-147.130573 0-204.703406-25.587926-25.587926-63.969814-41.580379-102.351703-41.580379-38.381889 0-73.565286 12.793963-102.351703 41.580379-57.572833 57.572833-57.572833 147.130573 0 204.703406 57.572833 57.572833 150.329063 57.572833 204.703406 0z m-102.351703-70.366796c-6.396981 0-15.992454-3.198491-22.389435-9.595472-12.793963-12.793963-12.793963-31.984907 0-44.77887 12.793963-12.793963 31.984907-12.793963 44.77887 0 12.793963 12.793963 12.793963 31.984907 0 44.77887-6.396981 6.396981-12.793963 9.595472-22.389435 9.595472z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "sdocfont"; /* Project id 4097705 */
|
|
3
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1699007792511'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1699007792511#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1699007792511') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1699007792511') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1699007792511') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1699007792511#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.check-mark:before {
|
|
20
|
+
content: "\e65b";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.add:before {
|
|
24
|
+
content: "\e65a";
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
.sdoc-add:before {
|
|
20
28
|
content: "\e658";
|
|
21
29
|
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { ElementPopover } from '../../extension/commons';
|
|
4
|
-
import EventBus from '../../utils/event-bus';
|
|
5
|
-
import useCommentList from '../hooks/use-comment-list';
|
|
6
|
-
import CommentItemWrapper from './comment-item-wrapper';
|
|
7
|
-
import { withTranslation } from 'react-i18next';
|
|
8
|
-
import GlobalCommentHeader from './global-comment-header';
|
|
9
|
-
var GlobalComment = function GlobalComment(_ref) {
|
|
10
|
-
var t = _ref.t;
|
|
11
|
-
var _useState = useState(null),
|
|
12
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
-
activeComment = _useState2[0],
|
|
14
|
-
setActiveComment = _useState2[1];
|
|
15
|
-
var onCommentClick = useCallback(function (comment) {
|
|
16
|
-
if (activeComment && activeComment.id === comment.id) return;
|
|
17
|
-
setActiveComment(comment);
|
|
18
|
-
}, [activeComment]);
|
|
19
|
-
var commentRef = useRef(null);
|
|
20
|
-
var _useCommentList = useCommentList(),
|
|
21
|
-
commentList = _useCommentList.commentList,
|
|
22
|
-
commentType = _useCommentList.commentType,
|
|
23
|
-
setCommentType = _useCommentList.setCommentType;
|
|
24
|
-
var _useState3 = useState(false),
|
|
25
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
-
isShowCommentList = _useState4[0],
|
|
27
|
-
setShowCommentList = _useState4[1];
|
|
28
|
-
useEffect(function () {
|
|
29
|
-
if (!isShowCommentList) return;
|
|
30
|
-
var toggleOuterSide = function toggleOuterSide(e) {
|
|
31
|
-
var commentWrapper = commentRef.current;
|
|
32
|
-
var clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
33
|
-
if (clickIsInComment) return;
|
|
34
|
-
setActiveComment(null);
|
|
35
|
-
setShowCommentList(false);
|
|
36
|
-
};
|
|
37
|
-
document.addEventListener('click', toggleOuterSide);
|
|
38
|
-
return function () {
|
|
39
|
-
document.removeEventListener('click', toggleOuterSide);
|
|
40
|
-
};
|
|
41
|
-
}, [isShowCommentList]);
|
|
42
|
-
useEffect(function () {
|
|
43
|
-
var eventBus = EventBus.getInstance();
|
|
44
|
-
var unsubscribe = eventBus.subscribe('COMMENT_LIST_CLICK', function () {
|
|
45
|
-
setActiveComment(null);
|
|
46
|
-
setShowCommentList(!isShowCommentList);
|
|
47
|
-
});
|
|
48
|
-
return function () {
|
|
49
|
-
unsubscribe();
|
|
50
|
-
};
|
|
51
|
-
}, [isShowCommentList]);
|
|
52
|
-
var contentRef = useRef(null);
|
|
53
|
-
var updateScrollPosition = useCallback(function () {
|
|
54
|
-
var resolvedDom = document.querySelector('.sdoc-resolved');
|
|
55
|
-
contentRef.current.scrollTo({
|
|
56
|
-
top: resolvedDom.offsetTop,
|
|
57
|
-
behavior: 'smooth'
|
|
58
|
-
});
|
|
59
|
-
}, []);
|
|
60
|
-
var hiddenComment = useCallback(function () {
|
|
61
|
-
setActiveComment(null);
|
|
62
|
-
}, []);
|
|
63
|
-
if (!isShowCommentList) return null;
|
|
64
|
-
return /*#__PURE__*/React.createElement(ElementPopover, {
|
|
65
|
-
className: "global-comments-popover"
|
|
66
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
67
|
-
ref: commentRef,
|
|
68
|
-
className: "comments-panel-wrapper"
|
|
69
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
70
|
-
className: "comments-panel-header"
|
|
71
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
72
|
-
className: "title"
|
|
73
|
-
}, t('Comments')), /*#__PURE__*/React.createElement("span", {
|
|
74
|
-
className: "close-wrapper",
|
|
75
|
-
onClick: function onClick() {
|
|
76
|
-
return setShowCommentList(false);
|
|
77
|
-
}
|
|
78
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
79
|
-
className: "sdocfont sdoc-sm-close"
|
|
80
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
81
|
-
className: "comments-panel-body"
|
|
82
|
-
}, /*#__PURE__*/React.createElement(GlobalCommentHeader, {
|
|
83
|
-
commentType: commentType,
|
|
84
|
-
commentList: commentList,
|
|
85
|
-
onCommentTypeChanged: setCommentType
|
|
86
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
87
|
-
ref: contentRef,
|
|
88
|
-
className: "comments-panel-body__content"
|
|
89
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
-
id: "global-comment-list-container",
|
|
91
|
-
className: "sdoc-comment-list-container"
|
|
92
|
-
}, commentList.map(function (comment) {
|
|
93
|
-
var isActive = activeComment && activeComment.id === comment.id;
|
|
94
|
-
return /*#__PURE__*/React.createElement(CommentItemWrapper, {
|
|
95
|
-
key: comment.id,
|
|
96
|
-
container: 'global-comment-list-container',
|
|
97
|
-
comment: comment,
|
|
98
|
-
isActive: isActive,
|
|
99
|
-
onCommentClick: onCommentClick,
|
|
100
|
-
hiddenComment: hiddenComment,
|
|
101
|
-
updateScrollPosition: updateScrollPosition
|
|
102
|
-
});
|
|
103
|
-
}))))));
|
|
104
|
-
};
|
|
105
|
-
export default withTranslation('sdoc-editor')(GlobalComment);
|