@seafile/sdoc-editor 0.1.93 → 0.1.95
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/comment/comment-editor.js +3 -1
- package/dist/basic-sdk/comment/comment/comment-item-content.js +39 -11
- package/dist/basic-sdk/comment/comment/comment-item-reply.js +14 -10
- package/dist/basic-sdk/comment/comment/comment-item-wrapper.js +82 -26
- package/dist/basic-sdk/comment/comment/index.js +3 -3
- package/dist/basic-sdk/comment/comment/style.css +20 -1
- package/dist/basic-sdk/comment/comment-context-provider.js +1 -1
- package/dist/basic-sdk/comment/comment-decorate.js +3 -3
- package/dist/basic-sdk/comment/hooks/use-comment-mount.js +3 -20
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +59 -30
- package/dist/basic-sdk/extension/plugins/table/helpers.js +2 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.css +1 -0
- package/dist/basic-sdk/extension/render/render-element.js +1 -1
- package/dist/components/doc-operations/revision-operations/revisions/index.js +2 -1
- package/dist/components/doc-operations/revision-operations/view-changes/index.js +2 -1
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +2 -1
- 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 +22 -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 +50 -6
|
@@ -6,6 +6,7 @@ var CommentEditor = function CommentEditor(_ref) {
|
|
|
6
6
|
placeholder = _ref.placeholder,
|
|
7
7
|
insertContent = _ref.insertContent,
|
|
8
8
|
updateContent = _ref.updateContent,
|
|
9
|
+
setIsEditing = _ref.setIsEditing,
|
|
9
10
|
t = _ref.t;
|
|
10
11
|
var inputRef = useRef();
|
|
11
12
|
var _useState = useState(content || ''),
|
|
@@ -34,8 +35,9 @@ var CommentEditor = function CommentEditor(_ref) {
|
|
|
34
35
|
}
|
|
35
36
|
if (event.keyCode === 27) {
|
|
36
37
|
setValue('');
|
|
38
|
+
setIsEditing && setIsEditing(false);
|
|
37
39
|
}
|
|
38
|
-
}, []);
|
|
40
|
+
}, [setIsEditing]);
|
|
39
41
|
placeholder = t(placeholder);
|
|
40
42
|
return /*#__PURE__*/React.createElement("input", {
|
|
41
43
|
ref: inputRef,
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { Fragment, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { withTranslation } from 'react-i18next';
|
|
4
|
-
import { PopoverBody, UncontrolledPopover } from 'reactstrap';
|
|
4
|
+
import { PopoverBody, UncontrolledPopover, UncontrolledTooltip } from 'reactstrap';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import CommentEditor from './comment-editor';
|
|
7
7
|
import DeleteCommentDialog from '../dialogs/delete-comment-dialog';
|
|
8
8
|
var CommentItem = function CommentItem(_ref) {
|
|
9
|
-
var
|
|
9
|
+
var isActive = _ref.isActive,
|
|
10
|
+
comment = _ref.comment,
|
|
10
11
|
selectionElement = _ref.selectionElement,
|
|
11
12
|
updateComment = _ref.updateComment,
|
|
13
|
+
updateCommentState = _ref.updateCommentState,
|
|
12
14
|
deleteComment = _ref.deleteComment,
|
|
13
15
|
t = _ref.t;
|
|
14
16
|
var popoverRef = useRef(null);
|
|
15
17
|
var _useState = useState(false),
|
|
16
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
isMouseOver = _useState2[0],
|
|
20
|
+
setMouseOver = _useState2[1];
|
|
19
21
|
var onMouseEnter = useCallback(function () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
if (!isActive) return;
|
|
23
|
+
setMouseOver(true);
|
|
24
|
+
}, [isActive]);
|
|
22
25
|
var onMouseLeave = useCallback(function () {
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (!isActive) return;
|
|
27
|
+
setMouseOver(false);
|
|
28
|
+
}, [isActive]);
|
|
25
29
|
|
|
26
30
|
// const [isShowItemMenu, setIsShowItemMenu] = useState(false);
|
|
27
31
|
var _useState3 = useState(false),
|
|
@@ -60,6 +64,13 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
60
64
|
}
|
|
61
65
|
setIsEditing(false);
|
|
62
66
|
}, [comment, selectionElement.id, updateComment]);
|
|
67
|
+
var updateCommentResolved = useCallback(function () {
|
|
68
|
+
var elementId = selectionElement.id;
|
|
69
|
+
var newComment = {
|
|
70
|
+
resolved: true
|
|
71
|
+
};
|
|
72
|
+
updateCommentState(elementId, comment.id, newComment);
|
|
73
|
+
}, [comment.id, selectionElement.id, updateCommentState]);
|
|
63
74
|
var menuId = useMemo(function () {
|
|
64
75
|
return "comment_".concat(comment.id);
|
|
65
76
|
}, [comment]);
|
|
@@ -82,11 +93,27 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
82
93
|
className: "name"
|
|
83
94
|
}, comment.user_name), /*#__PURE__*/React.createElement("span", {
|
|
84
95
|
className: "time"
|
|
85
|
-
}, dayjs(comment.updated_at).format('MM-DD HH:mm')))),
|
|
96
|
+
}, dayjs(comment.updated_at).format('MM-DD HH:mm')))), isMouseOver && /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: "d-flex"
|
|
98
|
+
}, !comment.resolved && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
className: "comment-operation mr-2",
|
|
100
|
+
onClick: updateCommentResolved
|
|
101
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
102
|
+
id: "tooltip_".concat(menuId),
|
|
103
|
+
className: "sdocfont sdoc-confirm"
|
|
104
|
+
})), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
|
|
105
|
+
target: "tooltip_".concat(menuId),
|
|
106
|
+
delay: {
|
|
107
|
+
show: 0,
|
|
108
|
+
hide: 0
|
|
109
|
+
},
|
|
110
|
+
fade: false,
|
|
111
|
+
placement: "bottom"
|
|
112
|
+
}, t('Resolved_tip'))), /*#__PURE__*/React.createElement("div", {
|
|
86
113
|
id: menuId,
|
|
87
114
|
className: "comment-operation"
|
|
88
115
|
}, /*#__PURE__*/React.createElement("i", {
|
|
89
|
-
className: "sdocfont sdoc-more
|
|
116
|
+
className: "sdocfont sdoc-more-options"
|
|
90
117
|
})), /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
91
118
|
ref: popoverRef,
|
|
92
119
|
trigger: "legacy",
|
|
@@ -108,7 +135,8 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
108
135
|
className: "comment-content"
|
|
109
136
|
}, isEditing && /*#__PURE__*/React.createElement(CommentEditor, {
|
|
110
137
|
content: comment.comment,
|
|
111
|
-
updateContent: updateContent
|
|
138
|
+
updateContent: updateContent,
|
|
139
|
+
setIsEditing: setIsEditing
|
|
112
140
|
}), !isEditing && /*#__PURE__*/React.createElement(React.Fragment, null, comment.comment))), isShowDeleteDialog && /*#__PURE__*/React.createElement(DeleteCommentDialog, {
|
|
113
141
|
type: 'comment',
|
|
114
142
|
deleteConfirm: _deleteComment,
|
|
@@ -6,21 +6,24 @@ import dayjs from 'dayjs';
|
|
|
6
6
|
import CommentEditor from './comment-editor';
|
|
7
7
|
import DeleteCommentDialog from '../dialogs/delete-comment-dialog';
|
|
8
8
|
var CommentReplyItem = function CommentReplyItem(_ref) {
|
|
9
|
-
var
|
|
9
|
+
var isActive = _ref.isActive,
|
|
10
|
+
reply = _ref.reply,
|
|
10
11
|
deleteReply = _ref.deleteReply,
|
|
11
12
|
updateReply = _ref.updateReply,
|
|
12
13
|
t = _ref.t;
|
|
13
14
|
var popoverRef = useRef(null);
|
|
14
15
|
var _useState = useState(false),
|
|
15
16
|
_useState2 = _slicedToArray(_useState, 2),
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
isMouseOver = _useState2[0],
|
|
18
|
+
setMouseOver = _useState2[1];
|
|
18
19
|
var onMouseEnter = useCallback(function () {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (!isActive) return;
|
|
21
|
+
setMouseOver(true);
|
|
22
|
+
}, [isActive]);
|
|
21
23
|
var onMouseLeave = useCallback(function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
if (!isActive) return;
|
|
25
|
+
setMouseOver(false);
|
|
26
|
+
}, [isActive]);
|
|
24
27
|
|
|
25
28
|
// const [isShowItemMenu, setIsShowItemMenu] = useState(false);
|
|
26
29
|
var _useState3 = useState(false),
|
|
@@ -76,11 +79,11 @@ var CommentReplyItem = function CommentReplyItem(_ref) {
|
|
|
76
79
|
className: "name"
|
|
77
80
|
}, reply.user_name), /*#__PURE__*/React.createElement("span", {
|
|
78
81
|
className: "time"
|
|
79
|
-
}, dayjs(reply.updated_at).format('MM-DD HH:mm')))),
|
|
82
|
+
}, dayjs(reply.updated_at).format('MM-DD HH:mm')))), isMouseOver && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
80
83
|
id: menuId,
|
|
81
84
|
className: "comment-operation"
|
|
82
85
|
}, /*#__PURE__*/React.createElement("i", {
|
|
83
|
-
className: "sdocfont sdoc-more
|
|
86
|
+
className: "sdocfont sdoc-more-options"
|
|
84
87
|
})), /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
85
88
|
ref: popoverRef,
|
|
86
89
|
trigger: "legacy",
|
|
@@ -102,7 +105,8 @@ var CommentReplyItem = function CommentReplyItem(_ref) {
|
|
|
102
105
|
className: "comment-content"
|
|
103
106
|
}, isEditing && /*#__PURE__*/React.createElement(CommentEditor, {
|
|
104
107
|
content: reply.reply,
|
|
105
|
-
updateContent: updateContent
|
|
108
|
+
updateContent: updateContent,
|
|
109
|
+
setIsEditing: setIsEditing
|
|
106
110
|
}), !isEditing && /*#__PURE__*/React.createElement(React.Fragment, null, reply.reply))), isShowDeleteDialog && /*#__PURE__*/React.createElement(DeleteCommentDialog, {
|
|
107
111
|
type: "reply",
|
|
108
112
|
deleteConfirm: _deleteReply,
|
|
@@ -69,15 +69,23 @@ export default function CommentItemWrapper(_ref) {
|
|
|
69
69
|
return _ref3.apply(this, arguments);
|
|
70
70
|
};
|
|
71
71
|
}(), [dispatch]);
|
|
72
|
-
var
|
|
73
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(elementId, commentId,
|
|
74
|
-
var res, returnReply, newReply;
|
|
72
|
+
var updateCommentState = useCallback( /*#__PURE__*/function () {
|
|
73
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(elementId, commentId, newComment) {
|
|
74
|
+
var time, user, reply, res, returnReply, newReply;
|
|
75
75
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
76
76
|
while (1) switch (_context3.prev = _context3.next) {
|
|
77
77
|
case 0:
|
|
78
|
-
|
|
78
|
+
time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
79
|
+
user = context.getUserInfo();
|
|
80
|
+
reply = {
|
|
81
|
+
type: 'comment',
|
|
82
|
+
reply: newComment.resolved,
|
|
83
|
+
updated_at: time,
|
|
84
|
+
author: user.username
|
|
85
|
+
};
|
|
86
|
+
_context3.next = 5;
|
|
79
87
|
return context.insertReply(commentId, reply);
|
|
80
|
-
case
|
|
88
|
+
case 5:
|
|
81
89
|
res = _context3.sent;
|
|
82
90
|
returnReply = res.data.reply;
|
|
83
91
|
newReply = _objectSpread(_objectSpread({}, reply), {}, {
|
|
@@ -85,6 +93,51 @@ export default function CommentItemWrapper(_ref) {
|
|
|
85
93
|
user_name: returnReply.user_name,
|
|
86
94
|
avatar_url: returnReply.avatar_url
|
|
87
95
|
});
|
|
96
|
+
dispatch({
|
|
97
|
+
type: 'INSET_REPLY',
|
|
98
|
+
payload: {
|
|
99
|
+
element_id: elementId,
|
|
100
|
+
comment_id: commentId,
|
|
101
|
+
reply: newReply
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
_context3.next = 11;
|
|
105
|
+
return context.updateComment(commentId, newComment);
|
|
106
|
+
case 11:
|
|
107
|
+
dispatch({
|
|
108
|
+
type: 'UPDATE_COMMENT_STATE',
|
|
109
|
+
payload: {
|
|
110
|
+
element_id: elementId,
|
|
111
|
+
comment_id: commentId,
|
|
112
|
+
comment: newComment
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
case 12:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context3.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee3);
|
|
120
|
+
}));
|
|
121
|
+
return function (_x5, _x6, _x7) {
|
|
122
|
+
return _ref4.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}(), [dispatch]);
|
|
125
|
+
var insertReply = useCallback( /*#__PURE__*/function () {
|
|
126
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(elementId, commentId, reply) {
|
|
127
|
+
var res, returnReply, newReply;
|
|
128
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
129
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
_context4.next = 2;
|
|
132
|
+
return context.insertReply(commentId, reply);
|
|
133
|
+
case 2:
|
|
134
|
+
res = _context4.sent;
|
|
135
|
+
returnReply = res.data.reply;
|
|
136
|
+
newReply = _objectSpread(_objectSpread({}, reply), {}, {
|
|
137
|
+
id: returnReply.id,
|
|
138
|
+
user_name: returnReply.user_name,
|
|
139
|
+
avatar_url: returnReply.avatar_url
|
|
140
|
+
});
|
|
88
141
|
dispatch({
|
|
89
142
|
type: 'INSERT_REPLY',
|
|
90
143
|
payload: {
|
|
@@ -98,12 +151,12 @@ export default function CommentItemWrapper(_ref) {
|
|
|
98
151
|
}, 0);
|
|
99
152
|
case 7:
|
|
100
153
|
case "end":
|
|
101
|
-
return
|
|
154
|
+
return _context4.stop();
|
|
102
155
|
}
|
|
103
|
-
},
|
|
156
|
+
}, _callee4);
|
|
104
157
|
}));
|
|
105
|
-
return function (
|
|
106
|
-
return
|
|
158
|
+
return function (_x8, _x9, _x10) {
|
|
159
|
+
return _ref5.apply(this, arguments);
|
|
107
160
|
};
|
|
108
161
|
}(), [dispatch]);
|
|
109
162
|
var insertContent = useCallback(function (content) {
|
|
@@ -119,13 +172,13 @@ export default function CommentItemWrapper(_ref) {
|
|
|
119
172
|
insertReply(elementId, comment.id, reply);
|
|
120
173
|
}, [comment, insertReply, selectionElement.id]);
|
|
121
174
|
var deleteReply = useCallback( /*#__PURE__*/function () {
|
|
122
|
-
var
|
|
175
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(replyId) {
|
|
123
176
|
var elementId;
|
|
124
|
-
return _regeneratorRuntime().wrap(function
|
|
125
|
-
while (1) switch (
|
|
177
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
178
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
126
179
|
case 0:
|
|
127
180
|
elementId = selectionElement.id;
|
|
128
|
-
|
|
181
|
+
_context5.next = 3;
|
|
129
182
|
return context.deleteReply(comment.id, replyId);
|
|
130
183
|
case 3:
|
|
131
184
|
dispatch({
|
|
@@ -138,23 +191,23 @@ export default function CommentItemWrapper(_ref) {
|
|
|
138
191
|
});
|
|
139
192
|
case 4:
|
|
140
193
|
case "end":
|
|
141
|
-
return
|
|
194
|
+
return _context5.stop();
|
|
142
195
|
}
|
|
143
|
-
},
|
|
196
|
+
}, _callee5);
|
|
144
197
|
}));
|
|
145
|
-
return function (
|
|
146
|
-
return
|
|
198
|
+
return function (_x11) {
|
|
199
|
+
return _ref6.apply(this, arguments);
|
|
147
200
|
};
|
|
148
201
|
}(), [comment.id, dispatch, selectionElement.id]);
|
|
149
202
|
var updateReply = useCallback( /*#__PURE__*/function () {
|
|
150
|
-
var
|
|
203
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(replyId, newReply) {
|
|
151
204
|
var elementId, commentId;
|
|
152
|
-
return _regeneratorRuntime().wrap(function
|
|
153
|
-
while (1) switch (
|
|
205
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
206
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
154
207
|
case 0:
|
|
155
208
|
elementId = selectionElement.id;
|
|
156
209
|
commentId = comment.id;
|
|
157
|
-
|
|
210
|
+
_context6.next = 4;
|
|
158
211
|
return context.updateReply(commentId, replyId, newReply);
|
|
159
212
|
case 4:
|
|
160
213
|
dispatch({
|
|
@@ -168,12 +221,12 @@ export default function CommentItemWrapper(_ref) {
|
|
|
168
221
|
});
|
|
169
222
|
case 5:
|
|
170
223
|
case "end":
|
|
171
|
-
return
|
|
224
|
+
return _context6.stop();
|
|
172
225
|
}
|
|
173
|
-
},
|
|
226
|
+
}, _callee6);
|
|
174
227
|
}));
|
|
175
|
-
return function (
|
|
176
|
-
return
|
|
228
|
+
return function (_x12, _x13) {
|
|
229
|
+
return _ref7.apply(this, arguments);
|
|
177
230
|
};
|
|
178
231
|
}(), [comment.id, dispatch, selectionElement.id]);
|
|
179
232
|
var onItemClick = useCallback(function () {
|
|
@@ -188,13 +241,16 @@ export default function CommentItemWrapper(_ref) {
|
|
|
188
241
|
className: "comment-item-list"
|
|
189
242
|
}, /*#__PURE__*/React.createElement(CommentItemContent, {
|
|
190
243
|
key: comment.id,
|
|
244
|
+
isActive: isActive,
|
|
191
245
|
comment: comment,
|
|
192
246
|
selectionElement: selectionElement,
|
|
193
247
|
deleteComment: deleteComment,
|
|
194
|
-
updateComment: updateComment
|
|
248
|
+
updateComment: updateComment,
|
|
249
|
+
updateCommentState: updateCommentState
|
|
195
250
|
}), comment.replies && comment.replies.length > 0 && comment.replies.map(function (reply) {
|
|
196
251
|
return /*#__PURE__*/React.createElement(CommentItemReply, {
|
|
197
252
|
key: reply.id,
|
|
253
|
+
isActive: isActive,
|
|
198
254
|
reply: reply,
|
|
199
255
|
deleteReply: deleteReply,
|
|
200
256
|
updateReply: updateReply
|
|
@@ -28,9 +28,9 @@ var Comment = function Comment() {
|
|
|
28
28
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
29
|
comments = _useState4[0],
|
|
30
30
|
setComments = _useState4[1];
|
|
31
|
-
var
|
|
31
|
+
var element_comments_map = useCommentContext().commentsInfo.element_comments_map;
|
|
32
32
|
useEffect(function () {
|
|
33
|
-
var comments =
|
|
33
|
+
var comments = element_comments_map[selectionElement === null || selectionElement === void 0 ? void 0 : selectionElement.id];
|
|
34
34
|
var hasComments = comments && comments.length > 0;
|
|
35
35
|
if (hasComments) {
|
|
36
36
|
setIsShowComments(true);
|
|
@@ -39,7 +39,7 @@ var Comment = function Comment() {
|
|
|
39
39
|
}
|
|
40
40
|
setComments([]);
|
|
41
41
|
setIsShowComments(false);
|
|
42
|
-
}, [
|
|
42
|
+
}, [element_comments_map, selectionElement]);
|
|
43
43
|
return /*#__PURE__*/React.createElement("div", {
|
|
44
44
|
className: "sdoc-comment-container"
|
|
45
45
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
box-shadow: 0 0 2px rgba(0,0,0,.04);
|
|
51
51
|
padding: 16px 0;
|
|
52
52
|
margin-bottom: 20px;
|
|
53
|
+
cursor: pointer;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
.sdoc-comment-container .comment-ui-container.active {
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
cursor: default;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
.sdoc-comment-container .comment-
|
|
77
|
+
.sdoc-comment-container .comment-ui-container.active .comment-item:hover {
|
|
77
78
|
background: #fafafa;
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -135,6 +136,24 @@
|
|
|
135
136
|
cursor: pointer;
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
.sdoc-comment-container .comment-ui-container .comment-operation {
|
|
140
|
+
width: 32px;
|
|
141
|
+
height: 32px;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.sdoc-comment-container .comment-ui-container.active .comment-operation:hover {
|
|
148
|
+
border-radius: 100%;
|
|
149
|
+
background-color: #f0f0f0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.sdoc-comment-container .comment-ui-container .comment-operation .sdoc-confirm {
|
|
153
|
+
color: #20a0ff;
|
|
154
|
+
font-weight: 800;
|
|
155
|
+
}
|
|
156
|
+
|
|
138
157
|
.sdoc-comment-menu {
|
|
139
158
|
padding: 0;
|
|
140
159
|
border-radius: 2px;
|
|
@@ -14,7 +14,7 @@ var CommentContextProvider = function CommentContextProvider(_ref) {
|
|
|
14
14
|
useCommentsMount(dispatch);
|
|
15
15
|
var editor = useSlateStatic();
|
|
16
16
|
useEffect(function () {
|
|
17
|
-
editor.
|
|
17
|
+
editor.element_comments_map = _objectSpread({}, commentsInfo.element_comments_map);
|
|
18
18
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
19
|
}, [commentsInfo]);
|
|
20
20
|
return /*#__PURE__*/React.createElement(CommentContext.Provider, {
|
|
@@ -2,12 +2,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import { Node } from '@seafile/slate';
|
|
3
3
|
export var commentDecorate = function commentDecorate(editor) {
|
|
4
4
|
return function (_ref) {
|
|
5
|
-
var _editor$
|
|
5
|
+
var _editor$element_comme;
|
|
6
6
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
7
7
|
node = _ref2[0],
|
|
8
8
|
path = _ref2[1];
|
|
9
9
|
var decorations = [];
|
|
10
|
-
var comments = ((_editor$
|
|
10
|
+
var comments = ((_editor$element_comme = editor.element_comments_map) === null || _editor$element_comme === void 0 ? void 0 : _editor$element_comme[node.id]) || [];
|
|
11
11
|
if (comments && comments.length > 0) {
|
|
12
12
|
var decoration = {
|
|
13
13
|
anchor: {
|
|
@@ -21,7 +21,7 @@ export var commentDecorate = function commentDecorate(editor) {
|
|
|
21
21
|
};
|
|
22
22
|
// rgba prevents occlusion of the cursor
|
|
23
23
|
decoration['computed_bg_color'] = 'rgba(129, 237, 247, 0.5)';
|
|
24
|
-
decoration['comment_count'] = editor.
|
|
24
|
+
decoration['comment_count'] = editor.element_comments_map[node.id].length;
|
|
25
25
|
decorations.push(decoration);
|
|
26
26
|
}
|
|
27
27
|
return decorations;
|
|
@@ -2,26 +2,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
3
|
import { useCallback, useEffect } from 'react';
|
|
4
4
|
import context from '../../../context';
|
|
5
|
-
var formatCommentsData = function formatCommentsData(comments) {
|
|
6
|
-
var commentsMap = {};
|
|
7
|
-
for (var i = 0; i < comments.length; i++) {
|
|
8
|
-
var item = comments[i];
|
|
9
|
-
try {
|
|
10
|
-
item.detail = JSON.parse(item.detail);
|
|
11
|
-
} catch (err) {
|
|
12
|
-
item.detail = {};
|
|
13
|
-
}
|
|
14
|
-
var element_id = item.detail.element_id;
|
|
15
|
-
if (!commentsMap[element_id]) {
|
|
16
|
-
commentsMap[element_id] = [];
|
|
17
|
-
}
|
|
18
|
-
commentsMap[element_id].push(item);
|
|
19
|
-
}
|
|
20
|
-
return commentsMap;
|
|
21
|
-
};
|
|
22
5
|
export var useCommentsMount = function useCommentsMount(dispatch) {
|
|
23
6
|
var request = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
24
|
-
var res,
|
|
7
|
+
var res, comments;
|
|
25
8
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
26
9
|
while (1) switch (_context.prev = _context.next) {
|
|
27
10
|
case 0:
|
|
@@ -33,10 +16,10 @@ export var useCommentsMount = function useCommentsMount(dispatch) {
|
|
|
33
16
|
return context.listComments();
|
|
34
17
|
case 4:
|
|
35
18
|
res = _context.sent;
|
|
36
|
-
|
|
19
|
+
comments = res.data.comments;
|
|
37
20
|
dispatch({
|
|
38
21
|
type: 'RECEIVE_STATE',
|
|
39
|
-
payload:
|
|
22
|
+
payload: comments
|
|
40
23
|
});
|
|
41
24
|
_context.next = 13;
|
|
42
25
|
break;
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
export var formatCommentsData = function formatCommentsData(comments) {
|
|
4
|
+
var elementCommentsMap = {};
|
|
5
|
+
for (var i = 0; i < comments.length; i++) {
|
|
6
|
+
var item = comments[i];
|
|
7
|
+
|
|
8
|
+
// the comment is not in sdoc document
|
|
9
|
+
if (!item.detail || item.resolved) continue;
|
|
10
|
+
try {
|
|
11
|
+
item.detail = JSON.parse(item.detail);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
var element_id = item.detail.element_id;
|
|
16
|
+
if (!elementCommentsMap[element_id]) {
|
|
17
|
+
elementCommentsMap[element_id] = [];
|
|
18
|
+
}
|
|
19
|
+
elementCommentsMap[element_id].push(item);
|
|
20
|
+
}
|
|
21
|
+
return elementCommentsMap;
|
|
22
|
+
};
|
|
3
23
|
export var initCommentsInfo = {
|
|
4
24
|
isFetching: true,
|
|
5
|
-
|
|
25
|
+
comment_list: [],
|
|
26
|
+
element_comments_map: {},
|
|
6
27
|
error: false
|
|
7
28
|
};
|
|
8
29
|
export var commentReducer = function commentReducer(state, action) {
|
|
@@ -13,9 +34,11 @@ export var commentReducer = function commentReducer(state, action) {
|
|
|
13
34
|
}
|
|
14
35
|
case 'RECEIVE_STATE':
|
|
15
36
|
{
|
|
37
|
+
var element_comments_map = formatCommentsData(action.payload);
|
|
16
38
|
return {
|
|
17
39
|
isFetching: false,
|
|
18
|
-
|
|
40
|
+
comment_list: action.payload,
|
|
41
|
+
element_comments_map: element_comments_map,
|
|
19
42
|
error: false
|
|
20
43
|
};
|
|
21
44
|
}
|
|
@@ -23,47 +46,47 @@ export var commentReducer = function commentReducer(state, action) {
|
|
|
23
46
|
{
|
|
24
47
|
return {
|
|
25
48
|
isFetching: false,
|
|
26
|
-
|
|
49
|
+
element_comments_map: {},
|
|
27
50
|
error: true
|
|
28
51
|
};
|
|
29
52
|
}
|
|
30
53
|
case 'INSERT_COMMENT':
|
|
31
54
|
{
|
|
32
|
-
var
|
|
55
|
+
var _element_comments_map = state.element_comments_map;
|
|
33
56
|
var _action$payload = action.payload,
|
|
34
57
|
element_id = _action$payload.element_id,
|
|
35
58
|
comment = _action$payload.comment;
|
|
36
|
-
if (!
|
|
37
|
-
|
|
59
|
+
if (!_element_comments_map[element_id]) {
|
|
60
|
+
_element_comments_map[element_id] = [];
|
|
38
61
|
}
|
|
39
|
-
|
|
62
|
+
_element_comments_map[element_id] = [].concat(_toConsumableArray(_element_comments_map[element_id]), [comment]);
|
|
40
63
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
41
|
-
|
|
64
|
+
element_comments_map: _objectSpread({}, _element_comments_map)
|
|
42
65
|
});
|
|
43
66
|
}
|
|
44
67
|
case 'DELETE_COMMENT':
|
|
45
68
|
{
|
|
46
|
-
var
|
|
69
|
+
var _element_comments_map2 = state.element_comments_map;
|
|
47
70
|
var _action$payload2 = action.payload,
|
|
48
71
|
_element_id = _action$payload2.element_id,
|
|
49
72
|
comment_id = _action$payload2.comment_id;
|
|
50
|
-
if (
|
|
51
|
-
|
|
73
|
+
if (_element_comments_map2[_element_id]) {
|
|
74
|
+
_element_comments_map2[_element_id] = _element_comments_map2[_element_id].filter(function (item) {
|
|
52
75
|
return item.id !== comment_id;
|
|
53
76
|
});
|
|
54
77
|
}
|
|
55
78
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
56
|
-
|
|
79
|
+
element_comments_map: _objectSpread({}, _element_comments_map2)
|
|
57
80
|
});
|
|
58
81
|
}
|
|
59
82
|
case 'UPDATE_COMMENT':
|
|
60
83
|
{
|
|
61
|
-
var
|
|
84
|
+
var _element_comments_map3 = state.element_comments_map;
|
|
62
85
|
var _action$payload3 = action.payload,
|
|
63
86
|
_element_id2 = _action$payload3.element_id,
|
|
64
87
|
_comment_id = _action$payload3.comment_id,
|
|
65
88
|
_comment = _action$payload3.comment;
|
|
66
|
-
|
|
89
|
+
_element_comments_map3[_element_id2] = _element_comments_map3[_element_id2].map(function (item) {
|
|
67
90
|
if (item.id === _comment_id) {
|
|
68
91
|
item.comment = _comment.comment;
|
|
69
92
|
item.detail = _comment.detail;
|
|
@@ -73,54 +96,60 @@ export var commentReducer = function commentReducer(state, action) {
|
|
|
73
96
|
return item;
|
|
74
97
|
});
|
|
75
98
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
76
|
-
|
|
99
|
+
element_comments_map: _objectSpread({}, _element_comments_map3)
|
|
77
100
|
});
|
|
78
101
|
}
|
|
79
102
|
case 'UPDATE_COMMENT_STATE':
|
|
80
103
|
{
|
|
81
|
-
var
|
|
104
|
+
var _element_comments_map4 = state.element_comments_map;
|
|
82
105
|
var _action$payload4 = action.payload,
|
|
83
106
|
_element_id3 = _action$payload4.element_id,
|
|
84
107
|
_comment_id2 = _action$payload4.comment_id,
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
_comment2 = _action$payload4.comment;
|
|
109
|
+
|
|
110
|
+
// modify comment state
|
|
111
|
+
_element_comments_map4[_element_id3] = _element_comments_map4[_element_id3].map(function (item) {
|
|
87
112
|
if (item.id === _comment_id2) {
|
|
88
|
-
item.resolved = resolved
|
|
113
|
+
item.resolved = _comment2.resolved;
|
|
89
114
|
return item;
|
|
90
115
|
}
|
|
91
116
|
return item;
|
|
92
117
|
});
|
|
118
|
+
|
|
119
|
+
// remove it form current list
|
|
120
|
+
_element_comments_map4[_element_id3] = _element_comments_map4[_element_id3].filter(function (item) {
|
|
121
|
+
return item.id !== _comment_id2;
|
|
122
|
+
});
|
|
93
123
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
94
|
-
|
|
124
|
+
element_comments_map: _objectSpread({}, _element_comments_map4)
|
|
95
125
|
});
|
|
96
126
|
}
|
|
97
127
|
case 'INSERT_REPLY':
|
|
98
128
|
{
|
|
99
|
-
var
|
|
129
|
+
var _element_comments_map5 = state.element_comments_map;
|
|
100
130
|
var _action$payload5 = action.payload,
|
|
101
131
|
_element_id4 = _action$payload5.element_id,
|
|
102
132
|
_comment_id3 = _action$payload5.comment_id,
|
|
103
133
|
reply = _action$payload5.reply;
|
|
104
|
-
|
|
134
|
+
_element_comments_map5[_element_id4] = _element_comments_map5[_element_id4].map(function (item) {
|
|
105
135
|
if (item.id === _comment_id3) {
|
|
106
|
-
console.log('xiaoqaing');
|
|
107
136
|
item.replies = [].concat(_toConsumableArray(item.replies), [reply]);
|
|
108
137
|
return item;
|
|
109
138
|
}
|
|
110
139
|
return item;
|
|
111
140
|
});
|
|
112
141
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
113
|
-
|
|
142
|
+
element_comments_map: _objectSpread({}, _element_comments_map5)
|
|
114
143
|
});
|
|
115
144
|
}
|
|
116
145
|
case 'DELETE_REPLY':
|
|
117
146
|
{
|
|
118
|
-
var
|
|
147
|
+
var _element_comments_map6 = state.element_comments_map;
|
|
119
148
|
var _action$payload6 = action.payload,
|
|
120
149
|
_element_id5 = _action$payload6.element_id,
|
|
121
150
|
_comment_id4 = _action$payload6.comment_id,
|
|
122
151
|
reply_id = _action$payload6.reply_id;
|
|
123
|
-
|
|
152
|
+
_element_comments_map6[_element_id5] = _element_comments_map6[_element_id5].map(function (item) {
|
|
124
153
|
if (item.id === _comment_id4) {
|
|
125
154
|
item.replies = item.replies.filter(function (reply) {
|
|
126
155
|
return reply.id !== reply_id;
|
|
@@ -130,18 +159,18 @@ export var commentReducer = function commentReducer(state, action) {
|
|
|
130
159
|
return item;
|
|
131
160
|
});
|
|
132
161
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
133
|
-
|
|
162
|
+
element_comments_map: _objectSpread({}, _element_comments_map6)
|
|
134
163
|
});
|
|
135
164
|
}
|
|
136
165
|
case 'UPDATE_REPLY':
|
|
137
166
|
{
|
|
138
|
-
var
|
|
167
|
+
var _element_comments_map7 = state.element_comments_map;
|
|
139
168
|
var _action$payload7 = action.payload,
|
|
140
169
|
_element_id6 = _action$payload7.element_id,
|
|
141
170
|
_comment_id5 = _action$payload7.comment_id,
|
|
142
171
|
_reply_id = _action$payload7.reply_id,
|
|
143
172
|
_reply = _action$payload7.reply;
|
|
144
|
-
|
|
173
|
+
_element_comments_map7[_element_id6] = _element_comments_map7[_element_id6].map(function (item) {
|
|
145
174
|
if (item.id === _comment_id5) {
|
|
146
175
|
item.replies = item.replies.map(function (replyItem) {
|
|
147
176
|
if (replyItem.id === _reply_id) {
|
|
@@ -155,7 +184,7 @@ export var commentReducer = function commentReducer(state, action) {
|
|
|
155
184
|
return item;
|
|
156
185
|
});
|
|
157
186
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
158
|
-
|
|
187
|
+
element_comments_map: _objectSpread({}, _element_comments_map7)
|
|
159
188
|
});
|
|
160
189
|
}
|
|
161
190
|
default:
|
|
@@ -735,7 +735,7 @@ export var focusCell = function focusCell(editor, event) {
|
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
|
-
},
|
|
738
|
+
}, 10);
|
|
739
739
|
return;
|
|
740
740
|
}
|
|
741
741
|
event.preventDefault();
|
|
@@ -791,7 +791,7 @@ export var focusCell = function focusCell(editor, event) {
|
|
|
791
791
|
});
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
|
-
},
|
|
794
|
+
}, 10);
|
|
795
795
|
return;
|
|
796
796
|
}
|
|
797
797
|
event.preventDefault();
|
|
@@ -148,7 +148,7 @@ var RenderElement = function RenderElement(props) {
|
|
|
148
148
|
|
|
149
149
|
// const { element } = props;
|
|
150
150
|
// const editor = useSlateStatic();
|
|
151
|
-
// const comments = editor.
|
|
151
|
+
// const comments = editor.element_comments_map?.[element.id] || [];
|
|
152
152
|
// return (
|
|
153
153
|
// <div className='seafile-block-container'>
|
|
154
154
|
// <CustomElement {...props} />
|
|
@@ -36,10 +36,11 @@ var Revisions = function Revisions() {
|
|
|
36
36
|
var closeRevisions = useCallback(function () {
|
|
37
37
|
setShowRevisions(false);
|
|
38
38
|
}, []);
|
|
39
|
+
if (revisionsCount === 0) return null;
|
|
39
40
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
40
41
|
className: "sdoc-revisions-count",
|
|
41
42
|
onClick: showRevisions
|
|
42
|
-
}, revisionsCount ===
|
|
43
|
+
}, revisionsCount === 1 && /*#__PURE__*/React.createElement(React.Fragment, null, t('1_revision')), revisionsCount > 1 && /*#__PURE__*/React.createElement(React.Fragment, null, t('x_revisions', {
|
|
43
44
|
count: revisionsCount
|
|
44
45
|
}))), isShowRevisions && /*#__PURE__*/React.createElement(RevisionsDialog, {
|
|
45
46
|
updateRevisionsCount: setRevisionsCount,
|
|
@@ -20,7 +20,8 @@ var ViewChanges = function ViewChanges(_ref) {
|
|
|
20
20
|
onChange: onToggleViewCHanges,
|
|
21
21
|
className: "sdoc-toggle-revision-changes d-flex align-items-center"
|
|
22
22
|
})), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
|
|
23
|
-
target: "sdoc-toggle-revision-changes-container"
|
|
23
|
+
target: "sdoc-toggle-revision-changes-container",
|
|
24
|
+
fade: false
|
|
24
25
|
}, t('View_changes')));
|
|
25
26
|
};
|
|
26
27
|
export default withTranslation('sdoc-editor')(ViewChanges);
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -14,6 +14,28 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-check-mark" unicode="" d="M390.4 0c-41.6 0-86.4 16-112 48l-256 300.8c-35.2 32-25.6 89.6 16 121.6 35.2 25.6 86.4 25.6 118.4-9.6l230.4-278.4L870.4 713.6c35.2 32 92.8 22.4 128-9.6 28.8-32 35.2-83.2 9.6-115.2L499.2 51.2c-25.6-35.2-67.2-51.2-108.8-51.2z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
19
|
+
<glyph glyph-name="sdoc-auto-linefeed" unicode="" d="M96 864h768c41.6 0 64-22.4 64-64s-22.4-64-64-64H96c-41.6 0-64 22.4-64 64s22.4 64 64 64z m832-291.2c35.2 0 64-28.8 64-64V288c0-172.8-134.4-313.6-307.2-320H672v-51.2c0-19.2-12.8-32-32-32-9.6 0-16 3.2-22.4 9.6L480 32l137.6 137.6c12.8 12.8 32 12.8 44.8 0 6.4-6.4 9.6-12.8 9.6-22.4V96c102.4 0 185.6 80 192 179.2V508.8c0 38.4 28.8 64 64 64zM352 96c41.6 0 60.8-19.2 64-57.6v-6.4c0-41.6-22.4-64-64-64H96c-41.6 0-60.8 19.2-64 57.6V32c0 41.6 22.4 64 64 64h256z m256 384c41.6 0 60.8-19.2 64-57.6v-6.4c0-41.6-22.4-64-64-64H96c-41.6 0-60.8 19.2-64 57.6V416c0 41.6 22.4 64 64 64h512z" horiz-adv-x="1024" />
|
|
20
|
+
|
|
21
|
+
<glyph glyph-name="sdoc-document" unicode="" d="M640 864v-256h256v-672c0-19.2-12.8-32-32-32H160c-19.2 0-32 12.8-32 32V832c0 19.2 12.8 32 32 32h480z m192-352H192v-544h640V512z m-512-128h224c19.2 0 32-12.8 32-32s-12.8-32-32-32h-224c-19.2 0-32 12.8-32 32s12.8 32 32 32z m0-128h384c19.2 0 32-12.8 32-32s-12.8-32-32-32H320c-19.2 0-32 12.8-32 32s12.8 32 32 32z m384-128c19.2 0 32-12.8 32-32s-12.8-32-32-32H320c-19.2 0-32 12.8-32 32s12.8 32 32 32h384zM672 864l224-224h-224V864z" horiz-adv-x="1024" />
|
|
22
|
+
|
|
23
|
+
<glyph glyph-name="sdoc-text-link" unicode="" d="M0 800h99.2v-576H0V800z m246.4-89.6c12.8-12.8 19.2-28.8 19.2-44.8 0-19.2-6.4-35.2-19.2-48-12.8-12.8-28.8-19.2-44.8-19.2-16 0-32 6.4-44.8 16-9.6 16-16 32-16 51.2 0 16 6.4 35.2 19.2 44.8 12.8 12.8 28.8 19.2 44.8 16 16 3.2 32-3.2 41.6-16zM153.6 585.6h99.2V224H153.6V585.6zM630.4 224h-99.2v224c0 28.8-6.4 44.8-12.8 54.4-9.6 9.6-22.4 16-41.6 16-12.8 0-25.6-6.4-35.2-16-9.6-12.8-19.2-28.8-19.2-54.4v-224H320V611.2h99.2v-19.2c22.4 19.2 51.2 28.8 76.8 28.8 41.6 0 76.8-12.8 99.2-41.6 22.4-28.8 32-70.4 32-124.8V224zM1024 96v-128H0v128h1024zM774.4 800v-281.6l108.8 128h134.4l-156.8-179.2L1024 224h-128l-105.6 160-16-16V224h-99.2V800h99.2z" horiz-adv-x="1024" />
|
|
24
|
+
|
|
25
|
+
<glyph glyph-name="sdoc-inline-link" unicode="" d="M960 96v-128H64v128h896zM448 576v-384H64V576h384z m512-128v-128H512v128h448z m-640 0H192v-128h128v128zM960 800v-128H64V800h896z" horiz-adv-x="1024" />
|
|
26
|
+
|
|
27
|
+
<glyph glyph-name="sdoc-copy" unicode="" d="M243.2 592v-416c0-32 19.2-60.8 57.6-60.8h419.2v-89.6c0-28.8-28.8-60.8-60.8-60.8H172.8C134.4-32 96 9.6 96 44.8v480c0 35.2 32 64 64 64h83.2zM867.2 800c32 0 60.8-25.6 60.8-60.8v-505.6c0-32-25.6-60.8-60.8-60.8H364.8c-32 0-60.8 25.6-60.8 60.8V739.2c0 32 25.6 60.8 60.8 60.8h502.4z" horiz-adv-x="1024" />
|
|
28
|
+
|
|
29
|
+
<glyph glyph-name="sdoc-insert" unicode="" d="M512 896c281.6 0 512-230.4 512-512s-230.4-512-512-512S0 102.4 0 384 230.4 896 512 896z m0-115.2C291.2 780.8 115.2 604.8 115.2 384S291.2-12.8 512-12.8 908.8 163.2 908.8 384 732.8 780.8 512 780.8z m0-112c32 0 57.6-25.6 57.6-57.6v-169.6h169.6c32 0 57.6-25.6 57.6-57.6s-25.6-57.6-57.6-57.6h-169.6v-169.6c0-32-25.6-57.6-57.6-57.6s-57.6 25.6-57.6 57.6v169.6H284.8c-32 0-57.6 25.6-57.6 57.6s25.6 57.6 57.6 57.6h169.6V611.2c0 32 25.6 57.6 57.6 57.6z" horiz-adv-x="1024" />
|
|
30
|
+
|
|
31
|
+
<glyph glyph-name="sdoc-card-link" unicode="" d="M960 96v-128H64v128h896z m0 512v-448H64V608h896z m-128-128H192v-192h640v192z m128 320v-128H64V800h896z" horiz-adv-x="1024" />
|
|
32
|
+
|
|
33
|
+
<glyph glyph-name="sdoc-confirm" unicode="" d="M364.8 19.2L0 422.4l60.8 51.2 304-336L963.2 768 1024 716.8z" horiz-adv-x="1024" />
|
|
34
|
+
|
|
35
|
+
<glyph glyph-name="sdoc-more-options" unicode="" d="M518.4 624C464 624 416 672 416 729.6S464 832 518.4 832s102.4-48 102.4-102.4-44.8-105.6-102.4-105.6z m0-342.4c-54.4 0-102.4 44.8-102.4 102.4s48 102.4 102.4 102.4 102.4-48 102.4-102.4-44.8-102.4-102.4-102.4z m0-345.6c-54.4 0-102.4 48-102.4 102.4s48 102.4 102.4 102.4 102.4-48 102.4-102.4S576-64 518.4-64z" horiz-adv-x="1024" />
|
|
36
|
+
|
|
37
|
+
<glyph glyph-name="sdoc-comments" unicode="" d="M960 896c35.2 0 64-28.8 64-64v-736c0-35.2-28.8-64-64-64h-198.4l-16-121.6c-3.2-16-12.8-28.8-25.6-35.2-6.4-3.2-9.6-3.2-16-3.2-9.6 0-19.2 3.2-28.8 9.6L505.6 32H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896z m-96-128H160c-19.2 0-32-12.8-32-32v-544c0-19.2 12.8-32 32-32h361.6c9.6 0 22.4-3.2 28.8-9.6l124.8-102.4 9.6 76.8c3.2 22.4 22.4 38.4 41.6 35.2H864c19.2 0 32 12.8 32 32V736c0 19.2-12.8 32-32 32z m-112-352c9.6 0 16-6.4 16-16v-96c0-9.6-6.4-16-16-16h-480c-9.6 0-16 6.4-16 16v96c0 9.6 6.4 16 16 16h480z m0 224c9.6 0 16-6.4 16-16v-96c0-9.6-6.4-16-16-16h-480c-9.6 0-16 6.4-16 16v96c0 9.6 6.4 16 16 16h480z" horiz-adv-x="1024" />
|
|
38
|
+
|
|
17
39
|
<glyph glyph-name="sdoc-font-color" unicode="" d="M960-96h-160l-80 224h-416L224-96H64L403.2 864h211.2L960-96zM512 704l-160-448h320L512 704z" horiz-adv-x="1024" />
|
|
18
40
|
|
|
19
41
|
<glyph glyph-name="sdoc-highlight-color" unicode="" d="M992 528L640-67.2l-144 80-64-108.8H32l163.2 278.4L32 275.2 380.8 896 992 528zM198.4 320l406.4-224 233.6 390.4L428.8 736 198.4 320z" 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=1690866983588'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1690866983588#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1690866983588') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1690866983588') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1690866983588') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1690866983588#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,6 +16,50 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.sdoc-check-mark:before {
|
|
20
|
+
content: "\e64b";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sdoc-auto-linefeed:before {
|
|
24
|
+
content: "\e64a";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sdoc-document:before {
|
|
28
|
+
content: "\e646";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sdoc-text-link:before {
|
|
32
|
+
content: "\e647";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sdoc-inline-link:before {
|
|
36
|
+
content: "\e648";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sdoc-copy:before {
|
|
40
|
+
content: "\e643";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sdoc-insert:before {
|
|
44
|
+
content: "\e644";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sdoc-card-link:before {
|
|
48
|
+
content: "\e645";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.sdoc-confirm:before {
|
|
52
|
+
content: "\e640";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.sdoc-more-options:before {
|
|
56
|
+
content: "\e641";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sdoc-comments:before {
|
|
60
|
+
content: "\e642";
|
|
61
|
+
}
|
|
62
|
+
|
|
19
63
|
.sdoc-font-color:before {
|
|
20
64
|
content: "\e606";
|
|
21
65
|
}
|