@seafile/sdoc-editor 1.0.176-beta1 → 1.0.177
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/comment/components/comment-editor.js +0 -1
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +19 -10
- package/dist/basic-sdk/comment/components/comment-list.css +2 -6
- package/dist/basic-sdk/comment/components/comment-list.js +29 -39
- package/dist/basic-sdk/comment/components/editor-comment.js +13 -2
- package/package.json +1 -1
|
@@ -30,7 +30,9 @@ const CommentItemWrapper = _ref => {
|
|
|
30
30
|
updateScrollPosition,
|
|
31
31
|
hiddenComment,
|
|
32
32
|
setCurrentCommentGroup,
|
|
33
|
-
onCommentClick
|
|
33
|
+
onCommentClick,
|
|
34
|
+
isEmptyComment,
|
|
35
|
+
addNewComment
|
|
34
36
|
} = _ref;
|
|
35
37
|
const listRef = (0, _react.useRef)(null);
|
|
36
38
|
const {
|
|
@@ -38,7 +40,7 @@ const CommentItemWrapper = _ref => {
|
|
|
38
40
|
} = (0, _useCommentContext.useCommentContext)();
|
|
39
41
|
const scrollRef = (0, _react.useRef)(document.querySelector('.sdoc-scroll-container'));
|
|
40
42
|
const [isShowDeleteDialog, setIsShowDeleteDialog] = (0, _react.useState)(false);
|
|
41
|
-
const commentOpToolsId = `commentOpTools_${comment.id}`;
|
|
43
|
+
const commentOpToolsId = `commentOpTools_${comment === null || comment === void 0 ? void 0 : comment.id}`;
|
|
42
44
|
const deleteComment = (0, _react.useCallback)(async commentId => {
|
|
43
45
|
await _context.default.deleteComment(commentId);
|
|
44
46
|
const {
|
|
@@ -249,12 +251,11 @@ const CommentItemWrapper = _ref => {
|
|
|
249
251
|
}, [isActive]);
|
|
250
252
|
const className = (0, _classnames.default)('comment-ui-container', {
|
|
251
253
|
'active': isActive,
|
|
252
|
-
'sdoc-resolved': comment.resolved,
|
|
254
|
+
'sdoc-resolved': comment === null || comment === void 0 ? void 0 : comment.resolved,
|
|
253
255
|
'd-flex flex-column': element,
|
|
254
256
|
'global-comment-item-detail-wrapper': isGlobalComment,
|
|
255
257
|
'comment-item-detail-wrapper': !isGlobalComment
|
|
256
258
|
});
|
|
257
|
-
const tip = comment.resolved ? 'Reopen_discussion' : 'Enter_reply_shift_Enter_for_new_line_Enter_to_send';
|
|
258
259
|
const handleScrollToArticle = (0, _react.useCallback)(e => {
|
|
259
260
|
e.stopPropagation();
|
|
260
261
|
const dom = _slateReact.ReactEditor.toDOMNode(editor, element);
|
|
@@ -265,7 +266,7 @@ const CommentItemWrapper = _ref => {
|
|
|
265
266
|
});
|
|
266
267
|
}, [editor, element, scrollRef]);
|
|
267
268
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
268
|
-
id: `comment-item-wrapper_${comment.id}`,
|
|
269
|
+
id: `comment-item-wrapper_${comment === null || comment === void 0 ? void 0 : comment.id}`,
|
|
269
270
|
className: className,
|
|
270
271
|
onClick: onItemClick
|
|
271
272
|
}, element && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -275,7 +276,7 @@ const CommentItemWrapper = _ref => {
|
|
|
275
276
|
className: "sdocfont sdoc-comment-quote mr-2"
|
|
276
277
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
277
278
|
className: "comment-item-selected-text"
|
|
278
|
-
}, _slate.Node.string(element))), /*#__PURE__*/_react.default.createElement("div", {
|
|
279
|
+
}, _slate.Node.string(element))), !isEmptyComment && /*#__PURE__*/_react.default.createElement("div", {
|
|
279
280
|
ref: listRef,
|
|
280
281
|
className: "comment-item-list"
|
|
281
282
|
}, /*#__PURE__*/_react.default.createElement(_commentItemContent.default, {
|
|
@@ -297,11 +298,19 @@ const CommentItemWrapper = _ref => {
|
|
|
297
298
|
updateReply
|
|
298
299
|
};
|
|
299
300
|
return /*#__PURE__*/_react.default.createElement(_commentItemReply.default, props);
|
|
300
|
-
})), !isGlobalComment &&
|
|
301
|
-
className: "sdoc-reply-wrapper"
|
|
302
|
-
|
|
301
|
+
})), !isGlobalComment && /*#__PURE__*/_react.default.createElement("div", {
|
|
302
|
+
className: "sdoc-reply-wrapper",
|
|
303
|
+
style: {
|
|
304
|
+
paddingTop: isEmptyComment ? '16px' : ''
|
|
305
|
+
}
|
|
306
|
+
}, isEmptyComment && /*#__PURE__*/_react.default.createElement(_commentEditor.default, {
|
|
307
|
+
type: "comment",
|
|
308
|
+
placeholder: 'Enter_reply_shift_Enter_for_new_line_Enter_to_send',
|
|
309
|
+
insertContent: addNewComment,
|
|
310
|
+
hiddenComment: hiddenComment
|
|
311
|
+
}), !isEmptyComment && /*#__PURE__*/_react.default.createElement(_commentEditor.default, {
|
|
303
312
|
type: "reply",
|
|
304
|
-
placeholder:
|
|
313
|
+
placeholder: 'Enter_reply_shift_Enter_for_new_line_Enter_to_send',
|
|
305
314
|
insertContent: insertContent,
|
|
306
315
|
hiddenComment: hiddenComment
|
|
307
316
|
})), isShowDeleteDialog && isActive && /*#__PURE__*/_react.default.createElement(_commentDeletePopover.default, {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdoc-comment-list-container .comment-ui-container {
|
|
12
|
-
background-color: rgba(255, 255, 255
|
|
12
|
+
background-color: rgba(255, 255, 255);
|
|
13
13
|
margin-bottom: 0px;
|
|
14
14
|
box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 4px 8px 3px rgba(0, 0, 0, .15);
|
|
15
15
|
padding: 16px;
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
.sdoc-comment-list-container .comment-ui-container.active {
|
|
38
38
|
position: relative;
|
|
39
39
|
left: -5px;
|
|
40
|
-
background: rgba(255, 255, 255,
|
|
40
|
+
background: rgba(255, 255, 255, 1);
|
|
41
41
|
box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 4px 8px 3px rgba(0, 0, 0, .15);
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -340,10 +340,6 @@
|
|
|
340
340
|
justify-content: flex-end;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
.sdoc-reply-wrapper {
|
|
344
|
-
padding: 0 10px;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
343
|
.sdoc-doc-comment-editor-container.sdoc-comment-list-container .comment-ui-container {
|
|
348
344
|
padding-left: 10px;
|
|
349
345
|
padding-right: 10px;
|
|
@@ -11,24 +11,23 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
11
11
|
var _context = _interopRequireDefault(require("../../../context"));
|
|
12
12
|
var _useSelectionPosition = require("../../hooks/use-selection-position");
|
|
13
13
|
var _useCommentContext = require("../hooks/comment-hooks/use-comment-context");
|
|
14
|
-
var _commentEditor = _interopRequireDefault(require("./comment-editor"));
|
|
15
14
|
var _commentItemWrapper = _interopRequireDefault(require("./comment-item-wrapper"));
|
|
16
15
|
var _commentItemCollapseWrapper = _interopRequireDefault(require("./comment-item-collapse-wrapper"));
|
|
17
16
|
require("./comment-list.css");
|
|
18
17
|
const CommentList = _ref => {
|
|
19
|
-
var _topLevelComment$repl, _topLevelComment$repl2;
|
|
20
18
|
let {
|
|
21
19
|
editor,
|
|
22
|
-
comments,
|
|
20
|
+
comments = [],
|
|
21
|
+
commentDetail = {},
|
|
23
22
|
activeElement,
|
|
24
|
-
|
|
23
|
+
isShowCommentDetail,
|
|
24
|
+
onSetCommentDetail,
|
|
25
|
+
deleteUnseenNotifications
|
|
25
26
|
} = _ref;
|
|
26
|
-
const commentRef = (0, _react.useRef)(null);
|
|
27
27
|
const position = (0, _useSelectionPosition.useCommentListPosition)(activeElement);
|
|
28
28
|
const {
|
|
29
29
|
dispatch
|
|
30
30
|
} = (0, _useCommentContext.useCommentContext)();
|
|
31
|
-
const [isShowCommentDetail, setIsShowCommentDetail] = (0, _react.useState)(false);
|
|
32
31
|
const insertComment = (0, _react.useCallback)(async (elementId, comment) => {
|
|
33
32
|
const res = await _context.default.insertComment(comment);
|
|
34
33
|
const {
|
|
@@ -48,7 +47,8 @@ const CommentList = _ref => {
|
|
|
48
47
|
comment: newComment
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
|
-
|
|
50
|
+
onSetCommentDetail(newComment);
|
|
51
|
+
}, [dispatch, onSetCommentDetail]);
|
|
52
52
|
const insertContent = (0, _react.useCallback)(content => {
|
|
53
53
|
const user = _context.default.getUserInfo();
|
|
54
54
|
const elementId = activeElement === null || activeElement === void 0 ? void 0 : activeElement.id;
|
|
@@ -63,47 +63,37 @@ const CommentList = _ref => {
|
|
|
63
63
|
updated_at: time
|
|
64
64
|
};
|
|
65
65
|
insertComment(elementId, comment);
|
|
66
|
-
setIsShowCommentDetail(true);
|
|
67
66
|
}, [insertComment, activeElement === null || activeElement === void 0 ? void 0 : activeElement.id]);
|
|
68
|
-
const setCurrentCommentGroup = (0, _react.useCallback)(() => {
|
|
69
|
-
setIsShowCommentDetail(true);
|
|
70
|
-
}, []);
|
|
71
|
-
const topLevelComment = (comments === null || comments === void 0 ? void 0 : comments.length) > 0 ? comments[0] : {};
|
|
72
|
-
const replyCount = topLevelComment === null || topLevelComment === void 0 ? void 0 : (_topLevelComment$repl = topLevelComment.replies) === null || _topLevelComment$repl === void 0 ? void 0 : _topLevelComment$repl.length;
|
|
73
|
-
const latestReply = ((_topLevelComment$repl2 = topLevelComment.replies) === null || _topLevelComment$repl2 === void 0 ? void 0 : _topLevelComment$repl2.length) > 0 ? topLevelComment.replies[topLevelComment.replies.length - 1] : null;
|
|
74
67
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
75
|
-
ref: commentRef,
|
|
76
68
|
id: "sdoc-comment-list-container",
|
|
77
69
|
className: "sdoc-comment-list-container sdoc-comment-list-container-popover",
|
|
78
70
|
style: {
|
|
79
71
|
top: position.y,
|
|
80
72
|
width: '300px'
|
|
81
73
|
}
|
|
82
|
-
}, !isShowCommentDetail &&
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
topLevelComment: topLevelComment
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
}, !isShowCommentDetail && comments.map(comment => {
|
|
75
|
+
var _topLevelComment$repl, _topLevelComment$repl2;
|
|
76
|
+
const topLevelComment = comment || {};
|
|
77
|
+
const replyCount = topLevelComment === null || topLevelComment === void 0 ? void 0 : (_topLevelComment$repl = topLevelComment.replies) === null || _topLevelComment$repl === void 0 ? void 0 : _topLevelComment$repl.length;
|
|
78
|
+
const latestReply = ((_topLevelComment$repl2 = topLevelComment.replies) === null || _topLevelComment$repl2 === void 0 ? void 0 : _topLevelComment$repl2.length) > 0 ? topLevelComment.replies[topLevelComment.replies.length - 1] : null;
|
|
79
|
+
return /*#__PURE__*/_react.default.createElement(_commentItemCollapseWrapper.default, {
|
|
80
|
+
key: topLevelComment.id,
|
|
81
|
+
editor: editor,
|
|
82
|
+
topLevelComment: topLevelComment,
|
|
83
|
+
replyCount: replyCount,
|
|
84
|
+
latestReply: latestReply,
|
|
85
|
+
setCurrentCommentGroup: () => {
|
|
86
|
+
deleteUnseenNotifications && deleteUnseenNotifications(topLevelComment);
|
|
87
|
+
onSetCommentDetail(topLevelComment);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}), isShowCommentDetail && /*#__PURE__*/_react.default.createElement("div", {
|
|
98
91
|
className: "comment-list"
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
isActive: true
|
|
105
|
-
};
|
|
106
|
-
return /*#__PURE__*/_react.default.createElement(_commentItemWrapper.default, props);
|
|
92
|
+
}, /*#__PURE__*/_react.default.createElement(_commentItemWrapper.default, {
|
|
93
|
+
comment: commentDetail,
|
|
94
|
+
isActive: true,
|
|
95
|
+
isEmptyComment: Object.keys(commentDetail).length ? false : true,
|
|
96
|
+
addNewComment: insertContent
|
|
107
97
|
})));
|
|
108
98
|
};
|
|
109
99
|
var _default = exports.default = CommentList;
|
|
@@ -32,6 +32,8 @@ const EditorComment = _ref => {
|
|
|
32
32
|
const [activeElement, setActiveElement] = (0, _react.useState)(null); // The slate node currently activated by clicking
|
|
33
33
|
const [comments, setComments] = (0, _react.useState)([]);
|
|
34
34
|
const [isShowComments, setIsShowComments] = (0, _react.useState)(false);
|
|
35
|
+
const [isShowCommentDetail, setIsShowCommentDetail] = (0, _react.useState)(true);
|
|
36
|
+
const [commentDetail, setCommentDetail] = (0, _react.useState)({});
|
|
35
37
|
const onAddCommentToggle = (0, _react.useCallback)(event => {
|
|
36
38
|
event.stopPropagation();
|
|
37
39
|
let activeElement = currentSelectionElement;
|
|
@@ -41,6 +43,8 @@ const EditorComment = _ref => {
|
|
|
41
43
|
}
|
|
42
44
|
setActiveElement(activeElement);
|
|
43
45
|
setIsShowComments(true);
|
|
46
|
+
setIsShowCommentDetail(true);
|
|
47
|
+
setCommentDetail({});
|
|
44
48
|
}, [currentSelectionElement]);
|
|
45
49
|
const onSelectElement = (0, _react.useCallback)(elementId => {
|
|
46
50
|
const activeElement = (0, _index.getCommentElementById)(elementId, editor);
|
|
@@ -48,9 +52,15 @@ const EditorComment = _ref => {
|
|
|
48
52
|
const unresolvedComments = element_comments_map[elementId].filter(item => !item.resolved);
|
|
49
53
|
setComments(unresolvedComments);
|
|
50
54
|
setIsShowComments(true);
|
|
55
|
+
setIsShowCommentDetail(false);
|
|
51
56
|
}, [editor, element_comments_map]);
|
|
57
|
+
const onSetCommentDetail = (0, _react.useCallback)(comment => {
|
|
58
|
+
setCommentDetail(comment);
|
|
59
|
+
setIsShowCommentDetail(true);
|
|
60
|
+
}, []);
|
|
52
61
|
const hiddenComment = (0, _react.useCallback)(() => {
|
|
53
62
|
setComments([]);
|
|
63
|
+
setCommentDetail({});
|
|
54
64
|
setIsShowComments(false);
|
|
55
65
|
}, []);
|
|
56
66
|
|
|
@@ -117,8 +127,9 @@ const EditorComment = _ref => {
|
|
|
117
127
|
editor: editor,
|
|
118
128
|
comments: comments,
|
|
119
129
|
activeElement: activeElement,
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
isShowCommentDetail: isShowCommentDetail,
|
|
131
|
+
commentDetail: commentDetail,
|
|
132
|
+
onSetCommentDetail: onSetCommentDetail,
|
|
122
133
|
deleteUnseenNotifications: deleteUnseenNotifications
|
|
123
134
|
})));
|
|
124
135
|
};
|