@seafile/sdoc-editor 0.1.97 → 0.1.99
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/assets/css/simple-editor.css +3 -1
- package/dist/basic-sdk/comment/comment/comment-item-content.js +28 -15
- package/dist/basic-sdk/comment/comment/comment-item-reply.js +7 -4
- package/dist/basic-sdk/comment/comment/comment-item-resolved-reply.js +28 -0
- package/dist/basic-sdk/comment/comment/comment-item-wrapper.js +135 -53
- package/dist/basic-sdk/comment/comment/comment-list.css +165 -0
- package/dist/basic-sdk/comment/comment/comment-list.js +9 -7
- package/dist/basic-sdk/comment/comment/editor-comment.js +66 -0
- package/dist/basic-sdk/comment/comment/global-comment-header.js +66 -0
- package/dist/basic-sdk/comment/comment/global-comment.js +94 -0
- package/dist/basic-sdk/comment/comment/index.js +3 -66
- package/dist/basic-sdk/comment/comment/style.css +66 -125
- package/dist/basic-sdk/comment/hooks/use-comment-list.js +39 -0
- package/dist/basic-sdk/comment/index.js +2 -2
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +143 -35
- package/dist/basic-sdk/extension/commons/menu/menu-item.js +1 -2
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +3 -6
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.css +11 -2
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +7 -7
- package/dist/components/doc-operations/comments-operation/index.js +14 -0
- package/dist/components/doc-operations/index.js +3 -2
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +8 -0
- package/public/locales/zh-CN/sdoc-editor.json +8 -0
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -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 +11 -6
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
.sdoc-comment-list-container {
|
|
2
|
+
position: absolute;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.sdoc-comment-list-container .comment-ui-container {
|
|
6
|
+
background-color: #edf2fa;
|
|
7
|
+
border-radius: 8px;
|
|
8
|
+
box-shadow: 0 0 2px rgba(0,0,0,.04);
|
|
9
|
+
padding: 16px 0;
|
|
10
|
+
margin-bottom: 10px;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sdoc-comment-list-container .comment-ui-container.active {
|
|
15
|
+
position: relative;
|
|
16
|
+
left: -24px;
|
|
17
|
+
background: rgba(255, 255, 255, .92);
|
|
18
|
+
box-shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 8px 3px rgba(0,0,0,.15);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sdoc-comment-list-container .comment-item-list {
|
|
22
|
+
max-height: 350px;
|
|
23
|
+
min-width: 280px;
|
|
24
|
+
overflow-x: hidden;
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sdoc-comment-list-container .comment-item {
|
|
30
|
+
position: relative;
|
|
31
|
+
padding: 16px 16px 0;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sdoc-comment-list-container .comment-ui-container.active .comment-item:hover {
|
|
36
|
+
background: #fafafa;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sdoc-comment-list-container .comment-item .comment-header,
|
|
40
|
+
.sdoc-comment-list-container .comment-item .comment-author {
|
|
41
|
+
display: flex;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
align-items: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sdoc-comment-list-container .comment-item .comment-content {
|
|
47
|
+
padding-bottom: 10px;
|
|
48
|
+
margin-top: 10px;
|
|
49
|
+
margin-left: 30px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.sdoc-comment-list-container .comment-header .comment-author__avatar {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sdoc-comment-list-container .comment-header .comment-author__avatar img {
|
|
58
|
+
width: 32px;
|
|
59
|
+
height: 32px;
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.sdoc-comment-list-container .comment-header .comment-author__info {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
align-items: start;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
padding-left: 10px;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sdoc-comment-list-container .comment-header .comment-author__info .name {
|
|
76
|
+
color: #1f1f1f;
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
line-height: 20px;
|
|
79
|
+
font-weight: 500;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.sdoc-comment-list-container .comment-header .comment-author__info .time {
|
|
83
|
+
color: #444746;
|
|
84
|
+
font-size: 12px;
|
|
85
|
+
line-height: 16px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.sdoc-comment-list-container .comment-header .comment-operation {
|
|
89
|
+
line-height: 20px;
|
|
90
|
+
font-size: 20px;
|
|
91
|
+
color: rgb(70, 77, 90);
|
|
92
|
+
width: 20px;
|
|
93
|
+
height: 20px;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sdoc-comment-list-container .comment-ui-container .comment-operation {
|
|
98
|
+
width: 32px;
|
|
99
|
+
height: 32px;
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.sdoc-comment-list-container .comment-ui-container.active .comment-operation:hover {
|
|
106
|
+
border-radius: 100%;
|
|
107
|
+
background-color: #f0f0f0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sdoc-comment-list-container .comment-ui-container .comment-operation .sdoc-confirm {
|
|
111
|
+
color: #20a0ff;
|
|
112
|
+
font-weight: 800;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.sdoc-comment-menu {
|
|
116
|
+
padding: 0;
|
|
117
|
+
border-radius: 2px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.sdoc-popover-menu {
|
|
121
|
+
background: rgb(255, 255, 255);
|
|
122
|
+
width: 140px;
|
|
123
|
+
padding: 8px 0;
|
|
124
|
+
height: auto;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.sdoc-popover-menu__item {
|
|
128
|
+
padding: 4px 24px;
|
|
129
|
+
height: 28px;
|
|
130
|
+
vertical-align: middle;
|
|
131
|
+
font-size: 14px;
|
|
132
|
+
background-color: transparent;
|
|
133
|
+
cursor: default;
|
|
134
|
+
color: #202428;
|
|
135
|
+
background-color: #fff;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.sdoc-popover-menu__item:hover {
|
|
139
|
+
background-color: #20a0ff;
|
|
140
|
+
color: #fff;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.sdoc-comment-list-container .comment-editor-wrapper {
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
padding: 0 16px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.sdoc-comment-list-container .comment-editor-wrapper .comment-editor {
|
|
151
|
+
height: 40px;
|
|
152
|
+
width: 248px;
|
|
153
|
+
background: #fff;
|
|
154
|
+
border: 1px solid rgba(0, 0, 0, .12);
|
|
155
|
+
border-radius: 4px;
|
|
156
|
+
padding: 8px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.sdoc-comment-list-container .comment-editor-wrapper .comment-editor:focus-visible {
|
|
160
|
+
outline: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.sdoc-comment-list-container .comment-editor-wrapper .comment-editor:focus {
|
|
164
|
+
border: 1px solid rgba(0, 0, 0, .12);
|
|
165
|
+
}
|
|
@@ -9,6 +9,7 @@ import { useCommentListPosition } from '../../hooks/use-selection-position';
|
|
|
9
9
|
import { useCommentContext } from '../hooks/use-comment-context';
|
|
10
10
|
import CommentEditor from './comment-editor';
|
|
11
11
|
import CommentItemWrapper from './comment-item-wrapper';
|
|
12
|
+
import './comment-list.css';
|
|
12
13
|
var CommentList = function CommentList(_ref) {
|
|
13
14
|
var comments = _ref.comments,
|
|
14
15
|
selectionElement = _ref.selectionElement;
|
|
@@ -60,7 +61,7 @@ var CommentList = function CommentList(_ref) {
|
|
|
60
61
|
}(), [dispatch]);
|
|
61
62
|
var insertContent = useCallback(function (content) {
|
|
62
63
|
var user = context.getUserInfo();
|
|
63
|
-
var elementId = selectionElement.id;
|
|
64
|
+
var elementId = selectionElement === null || selectionElement === void 0 ? void 0 : selectionElement.id;
|
|
64
65
|
var time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
65
66
|
var comment = {
|
|
66
67
|
comment: content,
|
|
@@ -72,11 +73,11 @@ var CommentList = function CommentList(_ref) {
|
|
|
72
73
|
updated_at: time
|
|
73
74
|
};
|
|
74
75
|
insertComment(elementId, comment);
|
|
75
|
-
}, [insertComment, selectionElement
|
|
76
|
+
}, [insertComment, selectionElement]);
|
|
76
77
|
var resetActiveComment = useCallback(function (e) {
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
if (
|
|
78
|
+
var commentWrapper = commentRef.current;
|
|
79
|
+
var clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
80
|
+
if (clickIsInComment) return;
|
|
80
81
|
setActiveComment(null);
|
|
81
82
|
}, []);
|
|
82
83
|
useEffect(function () {
|
|
@@ -87,19 +88,20 @@ var CommentList = function CommentList(_ref) {
|
|
|
87
88
|
}, [resetActiveComment]);
|
|
88
89
|
return /*#__PURE__*/React.createElement("div", {
|
|
89
90
|
ref: commentRef,
|
|
90
|
-
|
|
91
|
+
id: "sdoc-comment-list-container",
|
|
92
|
+
className: "sdoc-comment-list-container",
|
|
91
93
|
style: {
|
|
92
94
|
top: position.y
|
|
93
95
|
}
|
|
94
96
|
}, comments.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
95
97
|
className: "comment-list"
|
|
96
98
|
}, comments.map(function (comment) {
|
|
99
|
+
if (comment.resolved) return null;
|
|
97
100
|
var isActive = activeComment && activeComment.id === comment.id;
|
|
98
101
|
var props = {
|
|
99
102
|
key: comment.id,
|
|
100
103
|
comment: comment,
|
|
101
104
|
isActive: isActive,
|
|
102
|
-
selectionElement: selectionElement,
|
|
103
105
|
onCommentClick: onCommentClick
|
|
104
106
|
};
|
|
105
107
|
return /*#__PURE__*/React.createElement(CommentItemWrapper, props);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import useSelectionUpdate from '../../hooks/use-selection-update';
|
|
4
|
+
import { useCursorPosition } from '../helper';
|
|
5
|
+
import CommentList from './comment-list';
|
|
6
|
+
import { useSelectionElement } from '../../hooks/use-selection-element';
|
|
7
|
+
import { useCommentContext } from '../hooks/use-comment-context';
|
|
8
|
+
var EditorComment = function EditorComment() {
|
|
9
|
+
useSelectionUpdate();
|
|
10
|
+
var selectionElement = useSelectionElement();
|
|
11
|
+
var _useState = useState(false),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
isShowComments = _useState2[0],
|
|
14
|
+
setIsShowComments = _useState2[1];
|
|
15
|
+
var onAddCommentToggle = useCallback(function () {
|
|
16
|
+
setIsShowComments(true);
|
|
17
|
+
}, []);
|
|
18
|
+
var cursor = useCursorPosition();
|
|
19
|
+
var style = useMemo(function () {
|
|
20
|
+
return {
|
|
21
|
+
top: cursor.y === 0 || isShowComments ? '-99999px' : cursor.y
|
|
22
|
+
};
|
|
23
|
+
}, [cursor, isShowComments]);
|
|
24
|
+
|
|
25
|
+
// When selectionElement update, recalculate comment's panel state
|
|
26
|
+
var _useState3 = useState([]),
|
|
27
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
28
|
+
comments = _useState4[0],
|
|
29
|
+
setComments = _useState4[1];
|
|
30
|
+
var element_comments_map = useCommentContext().commentsInfo.element_comments_map;
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var comments = element_comments_map[selectionElement === null || selectionElement === void 0 ? void 0 : selectionElement.id];
|
|
33
|
+
var hasComments = comments && comments.length > 0;
|
|
34
|
+
if (hasComments) {
|
|
35
|
+
setIsShowComments(true);
|
|
36
|
+
setComments(comments);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
setComments([]);
|
|
40
|
+
setIsShowComments(false);
|
|
41
|
+
}, [element_comments_map, selectionElement]);
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "sdoc-comment-container"
|
|
44
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: "comment-container-main"
|
|
46
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: "comment-container-right"
|
|
48
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: "comment-add-wrapper",
|
|
50
|
+
style: style
|
|
51
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "add-comment-icon",
|
|
53
|
+
onClick: onAddCommentToggle
|
|
54
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
55
|
+
className: "sdocfont sdoc-comment mr-1"
|
|
56
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "comment-list-wrapper",
|
|
58
|
+
style: isShowComments ? {
|
|
59
|
+
width: '294px'
|
|
60
|
+
} : null
|
|
61
|
+
}, isShowComments && /*#__PURE__*/React.createElement(CommentList, {
|
|
62
|
+
comments: comments,
|
|
63
|
+
selectionElement: selectionElement
|
|
64
|
+
}))));
|
|
65
|
+
};
|
|
66
|
+
export default EditorComment;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
|
5
|
+
export var COMMENT_TYPES = {
|
|
6
|
+
all: 'All_comments',
|
|
7
|
+
resolved: 'Resolved_comments',
|
|
8
|
+
unresolved: 'Unresolved_comments'
|
|
9
|
+
};
|
|
10
|
+
function GlobalCommentHeader(_ref) {
|
|
11
|
+
var commentType = _ref.commentType,
|
|
12
|
+
commentList = _ref.commentList,
|
|
13
|
+
t = _ref.t,
|
|
14
|
+
onCommentTypeChanged = _ref.onCommentTypeChanged;
|
|
15
|
+
var _useState = useState(false),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
isDropdownOpen = _useState2[0],
|
|
18
|
+
setDropdownOpen = _useState2[1];
|
|
19
|
+
var commentTip = null;
|
|
20
|
+
if (commentList.length === 1) {
|
|
21
|
+
commentTip = t('Total_1_comment');
|
|
22
|
+
} else if (commentList.length > 1) {
|
|
23
|
+
commentTip = t('Total_count_comments', {
|
|
24
|
+
count: commentList.length
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var id = 'comment-type-controller';
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "comments-panel-body__header"
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
id: "comment-types",
|
|
32
|
+
className: "comment-type"
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
34
|
+
isOpen: isDropdownOpen,
|
|
35
|
+
toggle: function toggle() {
|
|
36
|
+
return setDropdownOpen(!isDropdownOpen);
|
|
37
|
+
}
|
|
38
|
+
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
39
|
+
tag: 'div',
|
|
40
|
+
caret: true,
|
|
41
|
+
className: "d-flex align-items-center justify-content-center"
|
|
42
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
id: id
|
|
44
|
+
}, t(commentType))), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
45
|
+
container: "comment-types",
|
|
46
|
+
className: "sdoc-comment-list-menu"
|
|
47
|
+
}, /*#__PURE__*/React.createElement(DropdownItem, {
|
|
48
|
+
tag: 'div',
|
|
49
|
+
onClick: function onClick() {
|
|
50
|
+
return onCommentTypeChanged(COMMENT_TYPES.all);
|
|
51
|
+
}
|
|
52
|
+
}, t(COMMENT_TYPES.all)), /*#__PURE__*/React.createElement(DropdownItem, {
|
|
53
|
+
tag: 'div',
|
|
54
|
+
onClick: function onClick() {
|
|
55
|
+
return onCommentTypeChanged(COMMENT_TYPES.resolved);
|
|
56
|
+
}
|
|
57
|
+
}, t(COMMENT_TYPES.resolved)), /*#__PURE__*/React.createElement(DropdownItem, {
|
|
58
|
+
tag: 'div',
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
return onCommentTypeChanged(COMMENT_TYPES.unresolved);
|
|
61
|
+
}
|
|
62
|
+
}, t(COMMENT_TYPES.unresolved))))), /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: "comment-count-tip"
|
|
64
|
+
}, commentTip));
|
|
65
|
+
}
|
|
66
|
+
export default withTranslation('sdoc-editor')(GlobalCommentHeader);
|
|
@@ -0,0 +1,94 @@
|
|
|
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 commentRef = useRef(null);
|
|
12
|
+
var _useCommentList = useCommentList(),
|
|
13
|
+
commentList = _useCommentList.commentList,
|
|
14
|
+
commentType = _useCommentList.commentType,
|
|
15
|
+
setCommentType = _useCommentList.setCommentType;
|
|
16
|
+
var _useState = useState(false),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
isShowCommentList = _useState2[0],
|
|
19
|
+
setShowCommentList = _useState2[1];
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
var toggleOuterSide = function toggleOuterSide(e) {
|
|
22
|
+
var commentWrapper = commentRef.current;
|
|
23
|
+
var clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
24
|
+
if (clickIsInComment) return;
|
|
25
|
+
setShowCommentList(false);
|
|
26
|
+
};
|
|
27
|
+
var eventBus = EventBus.getInstance();
|
|
28
|
+
var unsubscribe = eventBus.subscribe('COMMENT_LIST_CLICK', function () {
|
|
29
|
+
return setShowCommentList(!isShowCommentList);
|
|
30
|
+
});
|
|
31
|
+
document.addEventListener('click', toggleOuterSide, true);
|
|
32
|
+
return function () {
|
|
33
|
+
unsubscribe();
|
|
34
|
+
document.removeEventListener('click', toggleOuterSide, true);
|
|
35
|
+
};
|
|
36
|
+
}, [isShowCommentList]);
|
|
37
|
+
var _useState3 = useState(false),
|
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
+
activeComment = _useState4[0],
|
|
40
|
+
setActiveComment = _useState4[1];
|
|
41
|
+
var onCommentClick = useCallback(function (comment) {
|
|
42
|
+
if (activeComment && activeComment.id === comment.id) return;
|
|
43
|
+
setActiveComment(comment);
|
|
44
|
+
}, [activeComment]);
|
|
45
|
+
var contentRef = useRef(null);
|
|
46
|
+
var updateScrollPosition = useCallback(function () {
|
|
47
|
+
var resolvedDom = document.querySelector('.sdoc-resolved');
|
|
48
|
+
contentRef.current.scrollTo({
|
|
49
|
+
top: resolvedDom.offsetTop,
|
|
50
|
+
behavior: 'smooth'
|
|
51
|
+
});
|
|
52
|
+
}, []);
|
|
53
|
+
if (!isShowCommentList) return null;
|
|
54
|
+
return /*#__PURE__*/React.createElement(ElementPopover, {
|
|
55
|
+
className: 'global-comments-popover'
|
|
56
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
ref: commentRef,
|
|
58
|
+
className: "comments-panel-wrapper"
|
|
59
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "comments-panel-header"
|
|
61
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
62
|
+
className: "title"
|
|
63
|
+
}, t('Comments')), /*#__PURE__*/React.createElement("span", {
|
|
64
|
+
className: "close-wrapper",
|
|
65
|
+
onClick: function onClick() {
|
|
66
|
+
return setShowCommentList(false);
|
|
67
|
+
}
|
|
68
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
69
|
+
className: "sdocfont sdoc-close"
|
|
70
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "comments-panel-body"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(GlobalCommentHeader, {
|
|
73
|
+
commentType: commentType,
|
|
74
|
+
commentList: commentList,
|
|
75
|
+
onCommentTypeChanged: setCommentType
|
|
76
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
ref: contentRef,
|
|
78
|
+
className: "comments-panel-body__content"
|
|
79
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
id: "global-comment-list-container",
|
|
81
|
+
className: "sdoc-comment-list-container"
|
|
82
|
+
}, commentList.map(function (comment) {
|
|
83
|
+
var isActive = activeComment && activeComment.id === comment.id;
|
|
84
|
+
return /*#__PURE__*/React.createElement(CommentItemWrapper, {
|
|
85
|
+
key: comment.id,
|
|
86
|
+
container: 'global-comment-list-container',
|
|
87
|
+
comment: comment,
|
|
88
|
+
isActive: isActive,
|
|
89
|
+
onCommentClick: onCommentClick,
|
|
90
|
+
updateScrollPosition: updateScrollPosition
|
|
91
|
+
});
|
|
92
|
+
}))))));
|
|
93
|
+
};
|
|
94
|
+
export default withTranslation('sdoc-editor')(GlobalComment);
|
|
@@ -1,67 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import useSelectionUpdate from '../../hooks/use-selection-update';
|
|
4
|
-
import { useCursorPosition } from '../helper';
|
|
5
|
-
import CommentList from './comment-list';
|
|
6
|
-
import { useSelectionElement } from '../../hooks/use-selection-element';
|
|
7
|
-
import { useCommentContext } from '../hooks/use-comment-context';
|
|
1
|
+
import EditorComment from './editor-comment';
|
|
2
|
+
import GlobalComment from './global-comment';
|
|
8
3
|
import './style.css';
|
|
9
|
-
|
|
10
|
-
useSelectionUpdate();
|
|
11
|
-
var selectionElement = useSelectionElement();
|
|
12
|
-
var _useState = useState(false),
|
|
13
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
-
isShowComments = _useState2[0],
|
|
15
|
-
setIsShowComments = _useState2[1];
|
|
16
|
-
var onAddCommentToggle = useCallback(function () {
|
|
17
|
-
setIsShowComments(true);
|
|
18
|
-
}, []);
|
|
19
|
-
var cursor = useCursorPosition();
|
|
20
|
-
var style = useMemo(function () {
|
|
21
|
-
return {
|
|
22
|
-
top: cursor.y === 0 || isShowComments ? '-99999px' : cursor.y
|
|
23
|
-
};
|
|
24
|
-
}, [cursor, isShowComments]);
|
|
25
|
-
|
|
26
|
-
// When selectionElement update, recalculate comment's panel state
|
|
27
|
-
var _useState3 = useState([]),
|
|
28
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
-
comments = _useState4[0],
|
|
30
|
-
setComments = _useState4[1];
|
|
31
|
-
var element_comments_map = useCommentContext().commentsInfo.element_comments_map;
|
|
32
|
-
useEffect(function () {
|
|
33
|
-
var comments = element_comments_map[selectionElement === null || selectionElement === void 0 ? void 0 : selectionElement.id];
|
|
34
|
-
var hasComments = comments && comments.length > 0;
|
|
35
|
-
if (hasComments) {
|
|
36
|
-
setIsShowComments(true);
|
|
37
|
-
setComments(comments);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
setComments([]);
|
|
41
|
-
setIsShowComments(false);
|
|
42
|
-
}, [element_comments_map, selectionElement]);
|
|
43
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
-
className: "sdoc-comment-container"
|
|
45
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
46
|
-
className: "comment-container-main"
|
|
47
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
48
|
-
className: "comment-container-right"
|
|
49
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
50
|
-
className: "comment-add-wrapper",
|
|
51
|
-
style: style
|
|
52
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
53
|
-
className: "add-comment-icon",
|
|
54
|
-
onClick: onAddCommentToggle
|
|
55
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
56
|
-
className: "sdocfont sdoc-comment mr-1"
|
|
57
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
58
|
-
className: "comment-list-wrapper",
|
|
59
|
-
style: isShowComments ? {
|
|
60
|
-
width: '294px'
|
|
61
|
-
} : null
|
|
62
|
-
}, isShowComments && /*#__PURE__*/React.createElement(CommentList, {
|
|
63
|
-
comments: comments,
|
|
64
|
-
selectionElement: selectionElement
|
|
65
|
-
}))));
|
|
66
|
-
};
|
|
67
|
-
export default Comment;
|
|
4
|
+
export { EditorComment, GlobalComment };
|