@seafile/comment-editor 0.0.1-alpha.4 → 0.0.1-alpha.41
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/layout.css +1 -45
- package/dist/basic-sdk/comment/utils.js +39 -0
- package/dist/basic-sdk/context.js +8 -21
- package/dist/basic-sdk/editor/comment-editor.css +138 -0
- package/dist/basic-sdk/{comment/components → editor}/comment-editor.js +42 -43
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/use-copy-image.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +1 -1
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +13 -9
- package/dist/basic-sdk/hooks/use-comment.js +27 -180
- package/dist/basic-sdk/index.js +3 -10
- package/dist/basic-sdk/socket/helpers.js +14 -1
- package/dist/index.js +0 -12
- package/dist/pages/seafile-comment-editor.js +47 -19
- package/package.json +6 -6
- package/dist/assets/css/plugin-editor.css +0 -7
- package/dist/assets/css/simple-viewer.css +0 -6
- package/dist/basic-sdk/comment/components/comment-all-participants/index.css +0 -83
- package/dist/basic-sdk/comment/components/comment-all-participants/index.js +0 -67
- package/dist/basic-sdk/comment/components/comment-all-participants/participant-avatar.js +0 -43
- package/dist/basic-sdk/comment/components/comment-delete-popover.js +0 -80
- package/dist/basic-sdk/comment/components/comment-item-collapse-wrapper.js +0 -160
- package/dist/basic-sdk/comment/components/comment-item-content.js +0 -154
- package/dist/basic-sdk/comment/components/comment-item-reply.js +0 -124
- package/dist/basic-sdk/comment/components/comment-item-resolved-reply.js +0 -38
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +0 -364
- package/dist/basic-sdk/comment/components/comment-list.css +0 -422
- package/dist/basic-sdk/comment/components/comment-list.js +0 -216
- package/dist/basic-sdk/comment/components/comment-participants-editor/index.css +0 -132
- package/dist/basic-sdk/comment/components/comment-participants-editor/index.js +0 -69
- package/dist/basic-sdk/comment/components/comment-participants-editor/searched-collaborators.js +0 -62
- package/dist/basic-sdk/comment/components/comment-participants-editor/selected-participants.js +0 -48
- package/dist/basic-sdk/comment/components/editor-comment.js +0 -183
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +0 -64
- package/dist/basic-sdk/comment/components/elements-comment-count/index.css +0 -29
- package/dist/basic-sdk/comment/components/elements-comment-count/index.js +0 -49
- package/dist/basic-sdk/comment/components/global-comment/global-comment-body-header.js +0 -88
- package/dist/basic-sdk/comment/components/global-comment/global-comment-header.js +0 -90
- package/dist/basic-sdk/comment/components/global-comment/index.css +0 -328
- package/dist/basic-sdk/comment/components/global-comment/index.js +0 -217
- package/dist/basic-sdk/comment/components/index.js +0 -21
- package/dist/basic-sdk/comment/components/style.css +0 -40
- package/dist/basic-sdk/comment/helper.js +0 -184
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-context.js +0 -20
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-list.js +0 -45
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-mount.js +0 -57
- package/dist/basic-sdk/comment/hooks/notification-hooks/index.js +0 -25
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-context.js +0 -20
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-mount.js +0 -70
- package/dist/basic-sdk/comment/hooks/use-participants.js +0 -26
- package/dist/basic-sdk/comment/index.js +0 -21
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +0 -353
- package/dist/basic-sdk/comment/reducer/notification-reducer.js +0 -89
- package/dist/basic-sdk/comment/utils/get-event-transfer.js +0 -77
- package/dist/basic-sdk/comment/utils/index.js +0 -281
- package/dist/basic-sdk/comment/utils/notification-utils.js +0 -62
- package/dist/basic-sdk/layout/comment-layout/index.css +0 -15
- package/dist/basic-sdk/layout/comment-layout/index.js +0 -87
- package/dist/basic-sdk/layout/comment-layout/resize-width/index.css +0 -38
- package/dist/basic-sdk/layout/comment-layout/resize-width/index.js +0 -132
- package/dist/basic-sdk/layout/editor-container.js +0 -32
- package/dist/basic-sdk/layout/index.js +0 -13
- package/dist/basic-sdk/socket/index.js +0 -20
- package/dist/basic-sdk/socket/socket-client.js +0 -211
- package/dist/basic-sdk/socket/socket-manager.js +0 -386
- package/dist/basic-sdk/socket/with-socket-io.js +0 -73
- /package/dist/basic-sdk/comment/{constants/index.js → constants.js} +0 -0
|
@@ -7,201 +7,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.useComment = exports.CommentProvider = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
11
|
-
var _constants = require("../comment/constants");
|
|
12
|
-
var _useCommentMount = require("../comment/hooks/comment-hooks/use-comment-mount");
|
|
13
|
-
var _notificationHooks = require("../comment/hooks/notification-hooks");
|
|
14
|
-
var _commentReducer = require("../comment/reducer/comment-reducer");
|
|
15
|
-
var _notificationReducer = require("../comment/reducer/notification-reducer");
|
|
16
|
-
var _utils = require("../comment/utils");
|
|
17
|
-
var _toast = _interopRequireDefault(require("../components/toast"));
|
|
18
|
-
var _constants2 = require("../constants");
|
|
10
|
+
var _context = _interopRequireDefault(require("../context"));
|
|
19
11
|
var _model = require("../model");
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
require("../assets/css/layout.css");
|
|
13
|
+
require("../assets/css/default.css");
|
|
14
|
+
require("../assets/css/sdoc-editor-article.css");
|
|
15
|
+
require("../assets/css/sdoc-editor-plugins.css");
|
|
16
|
+
require("../assets/css/sdoc-comment-editor-plugin.css");
|
|
17
|
+
require("../assets/css/dropdown-menu.css");
|
|
22
18
|
const CommentContext = /*#__PURE__*/_react.default.createContext(null);
|
|
23
19
|
const CommentProvider = _ref => {
|
|
24
20
|
let {
|
|
25
21
|
children,
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
type,
|
|
23
|
+
// comment or replay
|
|
28
24
|
className = '',
|
|
25
|
+
pluginName = '',
|
|
26
|
+
// sdoc or wiki or txt ...
|
|
29
27
|
pluginEventBus,
|
|
30
28
|
pluginEvent,
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
collaborators = [],
|
|
30
|
+
participants = [],
|
|
31
|
+
addParticipants
|
|
33
32
|
} = _ref;
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const [commentsInfo, dispatch] = (0, _react.useReducer)(_commentReducer.commentReducer, _commentReducer.initCommentsInfo);
|
|
42
|
-
(0, _useCommentMount.useCommentsMount)(dispatch, api);
|
|
43
|
-
const [notificationsInfo, notificationsDispatch] = (0, _react.useReducer)(_notificationReducer.notificationReducer, _notificationReducer.initNotificationsInfo);
|
|
44
|
-
(0, _notificationHooks.useNotificationsMount)(dispatch, api, collaborators);
|
|
45
|
-
(0, _react.useEffect)(() => {
|
|
46
|
-
if (Object.keys(commentsInfo.element_comments_map).length) {
|
|
47
|
-
editor.element_comments_map = commentsInfo.element_comments_map;
|
|
48
|
-
}
|
|
49
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
-
}, [commentsInfo.element_comments_map]);
|
|
51
|
-
(0, _react.useEffect)(() => {
|
|
52
|
-
editor.notifications_map = {
|
|
53
|
-
...notificationsInfo.notifications_map
|
|
54
|
-
};
|
|
55
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
-
}, [notificationsInfo]);
|
|
57
|
-
(0, _react.useEffect)(() => {
|
|
58
|
-
const {
|
|
59
|
-
comment_list
|
|
60
|
-
} = commentsInfo;
|
|
61
|
-
if (commentType === _constants.COMMENT_TYPES.ALL) {
|
|
62
|
-
const commentList = comment_list.map(item => {
|
|
63
|
-
item.replies = item.replies.filter(reply => !['True', 'False'].includes(reply.reply));
|
|
64
|
-
return item;
|
|
65
|
-
});
|
|
66
|
-
setCommentList(commentList);
|
|
67
|
-
} else if (commentType === _constants.COMMENT_TYPES.RESOLVED) {
|
|
68
|
-
const commentList = comment_list.filter(item => item.resolved);
|
|
69
|
-
setCommentList(commentList);
|
|
70
|
-
} else if (commentType === _constants.COMMENT_TYPES.UNRESOLVED) {
|
|
71
|
-
const commentList = comment_list.filter(item => !item.resolved);
|
|
72
|
-
setCommentList(commentList);
|
|
73
|
-
} else if (commentType === _constants.COMMENT_TYPES.DOC) {
|
|
74
|
-
const commentList = comment_list.filter(comment => comment.detail.element_id === _constants.DOC_COMMENT_ELEMENT_ID);
|
|
75
|
-
setCommentList(commentList);
|
|
76
|
-
}
|
|
77
|
-
}, [commentType, commentsInfo]);
|
|
78
|
-
|
|
79
|
-
// Participants
|
|
80
|
-
const updateLocalParticipants = (0, _react.useCallback)(function () {
|
|
81
|
-
let added = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
82
|
-
if (!Array.isArray(added) || added.length === 0) return;
|
|
83
|
-
let newParticipants = participants.slice(0);
|
|
84
|
-
added.forEach(participant => {
|
|
85
|
-
const newParticipant = new _model.User(participant);
|
|
86
|
-
if (!newParticipants.find(item => item.username === newParticipant.username)) {
|
|
87
|
-
newParticipants.push(newParticipant);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
setParticipants(newParticipants);
|
|
91
|
-
}, [participants]);
|
|
92
|
-
const deleteLocalParticipant = (0, _react.useCallback)(email => {
|
|
93
|
-
if (!participants.find(participant => participant.username === email)) return;
|
|
94
|
-
let newParticipants = participants.slice(0);
|
|
95
|
-
newParticipants = newParticipants.filter(participant => participant.username !== email);
|
|
96
|
-
setParticipants(newParticipants);
|
|
97
|
-
}, [participants]);
|
|
98
|
-
const addParticipants = (0, _react.useCallback)(otherEmail => {
|
|
99
|
-
if (participants.find(participant => participant.username === otherEmail)) return;
|
|
100
|
-
api.addParticipants([otherEmail]).then(res => {
|
|
101
|
-
const {
|
|
102
|
-
success
|
|
103
|
-
} = res.data;
|
|
104
|
-
updateLocalParticipants(success);
|
|
105
|
-
}).catch(error => {
|
|
106
|
-
const errorMessage = (0, _commonUtils.getErrorMsg)(error);
|
|
107
|
-
_toast.default.danger(t(errorMessage));
|
|
108
|
-
});
|
|
109
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
|
-
}, [updateLocalParticipants, participants]);
|
|
111
|
-
const deleteParticipant = (0, _react.useCallback)(email => {
|
|
112
|
-
if (!participants.find(participant => participant.username === email)) return;
|
|
113
|
-
api.deleteParticipants(email).then(res => {
|
|
114
|
-
let newParticipants = participants.slice(0);
|
|
115
|
-
newParticipants = newParticipants.filter(participant => participant.username !== email);
|
|
116
|
-
setParticipants(newParticipants);
|
|
117
|
-
}).catch(error => {
|
|
118
|
-
const errorMessage = (0, _commonUtils.getErrorMsg)(error);
|
|
119
|
-
_toast.default.danger(t(errorMessage));
|
|
120
|
-
});
|
|
121
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
const getCollaborators = (0, _react.useCallback)(() => {
|
|
34
|
+
const newCollaborators = collaborators.map(user => new _model.User(user));
|
|
35
|
+
return newCollaborators;
|
|
36
|
+
}, [collaborators]);
|
|
37
|
+
const getParticipants = (0, _react.useCallback)(() => {
|
|
38
|
+
const newParticipants = participants.map(user => new _model.User(user));
|
|
39
|
+
return newParticipants;
|
|
122
40
|
}, [participants]);
|
|
123
|
-
|
|
124
|
-
// Notifications
|
|
125
|
-
const deleteUnseenNotifications = (0, _react.useCallback)(comment => {
|
|
126
|
-
let unseenCommentIds = [];
|
|
127
|
-
let unseenNotificationKeys = [];
|
|
128
|
-
const commentNotificationKey = (0, _utils.generatorNotificationKey)(comment.id);
|
|
129
|
-
const commentNotification = notificationsInfo.notifications_map[commentNotificationKey];
|
|
130
|
-
if (commentNotification) {
|
|
131
|
-
unseenNotificationKeys.push(commentNotification.key);
|
|
132
|
-
unseenCommentIds.push(commentNotification.id);
|
|
133
|
-
}
|
|
134
|
-
Array.isArray(comment.replies) && comment.replies.forEach(reply => {
|
|
135
|
-
const replyNotificationKey = (0, _utils.generatorNotificationKey)(reply.comment_id, reply.id);
|
|
136
|
-
const replyNotification = notificationsInfo.notifications_map[replyNotificationKey];
|
|
137
|
-
if (replyNotification) {
|
|
138
|
-
unseenNotificationKeys.push(replyNotification.key);
|
|
139
|
-
unseenCommentIds.push(replyNotification.id);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
api.deleteUnseenNotifications(unseenCommentIds).then(res => {
|
|
143
|
-
notificationsDispatch({
|
|
144
|
-
type: _constants.DOC_NOTIFICATION_REDUCER_TYPE.DEL,
|
|
145
|
-
payload: unseenNotificationKeys
|
|
146
|
-
});
|
|
147
|
-
}).catch(error => {
|
|
148
|
-
//
|
|
149
|
-
});
|
|
150
|
-
}, [api, notificationsInfo.notifications_map]);
|
|
151
|
-
|
|
152
|
-
// Mount
|
|
153
|
-
(0, _react.useEffect)(() => {
|
|
154
|
-
// get participants
|
|
155
|
-
api.listParticipants().then(res => {
|
|
156
|
-
const participants = res.data.participant_list;
|
|
157
|
-
updateLocalParticipants(participants);
|
|
158
|
-
}).catch(error => {
|
|
159
|
-
console.log(error);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// get collaborators
|
|
163
|
-
api.listRelatedUsers().then(res => {
|
|
164
|
-
const collaborators = [];
|
|
165
|
-
res.data.related_users.forEach(user => {
|
|
166
|
-
const collaborator = new _model.User(user);
|
|
167
|
-
collaborators.push(collaborator);
|
|
168
|
-
});
|
|
169
|
-
setCollaborators(collaborators);
|
|
170
|
-
}).catch(error => {
|
|
171
|
-
console.log(error);
|
|
172
|
-
});
|
|
173
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
174
|
-
}, []);
|
|
175
|
-
|
|
176
|
-
// Listening
|
|
177
|
-
(0, _react.useEffect)(() => {
|
|
178
|
-
const eventBus = _eventBus.default.getInstance();
|
|
179
|
-
const unsubscribeParticipantAdded = eventBus.subscribe(_constants2.INTERNAL_EVENT.PARTICIPANT_ADDED, updateLocalParticipants);
|
|
180
|
-
const unsubscribeParticipantRemoved = eventBus.subscribe(_constants2.INTERNAL_EVENT.PARTICIPANT_REMOVED, deleteLocalParticipant);
|
|
181
|
-
return () => {
|
|
182
|
-
unsubscribeParticipantAdded();
|
|
183
|
-
unsubscribeParticipantRemoved();
|
|
184
|
-
};
|
|
185
|
-
}, [updateLocalParticipants, deleteLocalParticipant]);
|
|
186
41
|
return /*#__PURE__*/_react.default.createElement(CommentContext.Provider, {
|
|
187
42
|
value: {
|
|
188
|
-
|
|
43
|
+
type,
|
|
44
|
+
userInfo: _context.default.getUserInfo(),
|
|
189
45
|
className,
|
|
190
|
-
|
|
46
|
+
pluginName,
|
|
191
47
|
pluginEventBus,
|
|
192
48
|
pluginEvent,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
dispatch,
|
|
197
|
-
setCommentType,
|
|
198
|
-
onCloseCommentPanel,
|
|
199
|
-
collaborators,
|
|
200
|
-
notificationsInfo,
|
|
201
|
-
deleteUnseenNotifications,
|
|
202
|
-
addParticipants,
|
|
203
|
-
deleteParticipant,
|
|
204
|
-
participants
|
|
49
|
+
collaborators: getCollaborators(),
|
|
50
|
+
participants: getParticipants(),
|
|
51
|
+
addParticipants
|
|
205
52
|
}
|
|
206
53
|
}, children);
|
|
207
54
|
};
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "CommentEditor", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return
|
|
10
|
+
return _commentEditor.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "CommentProvider", {
|
|
@@ -148,26 +148,19 @@ Object.defineProperty(exports, "withNodeId", {
|
|
|
148
148
|
return _nodeId.default;
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
-
Object.defineProperty(exports, "withSocketIO", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
get: function () {
|
|
154
|
-
return _socket.withSocketIO;
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
151
|
var _fileLoading = _interopRequireDefault(require("./components/file-loading"));
|
|
158
152
|
var _loading = _interopRequireDefault(require("./components/loading"));
|
|
159
153
|
var _toast = _interopRequireDefault(require("./components/toast"));
|
|
160
154
|
var _tooltip = _interopRequireDefault(require("./components/tooltip"));
|
|
161
155
|
var _constants = require("./constants");
|
|
162
156
|
var _context = _interopRequireDefault(require("./context"));
|
|
157
|
+
var _commentEditor = _interopRequireDefault(require("./editor/comment-editor"));
|
|
163
158
|
var _extension = require("./extension");
|
|
164
159
|
var _dropdownMenuItem = _interopRequireDefault(require("./extension/commons/dropdown-menu-item"));
|
|
165
160
|
var _menuShortcutIndicator = _interopRequireDefault(require("./extension/commons/menu-shortcut-indicator"));
|
|
166
161
|
var _useComment = require("./hooks/use-comment");
|
|
167
|
-
var _commentLayout = _interopRequireDefault(require("./layout/comment-layout"));
|
|
168
162
|
var _nodeId = _interopRequireDefault(require("./node-id"));
|
|
169
163
|
var _slateConvert = require("./slate-convert");
|
|
170
|
-
var _socket = require("./socket");
|
|
171
164
|
var _commonUtils = require("./utils/common-utils");
|
|
172
165
|
var _eventBus = _interopRequireDefault(require("./utils/event-bus"));
|
|
173
166
|
var _localStorageUtils = _interopRequireDefault(require("./utils/local-storage-utils"));
|
|
@@ -290,7 +290,20 @@ exports.syncRemoteOperations = syncRemoteOperations;
|
|
|
290
290
|
const syncRemoteCursorLocation = (editor, user, location, cursorData) => {
|
|
291
291
|
const currentUser = editor.user;
|
|
292
292
|
if (user && user.username !== currentUser.username) {
|
|
293
|
-
|
|
293
|
+
// Get front Point as cursor
|
|
294
|
+
const {
|
|
295
|
+
anchor,
|
|
296
|
+
focus
|
|
297
|
+
} = location;
|
|
298
|
+
let newLocation = location;
|
|
299
|
+
if (!_slate.Point.equals(anchor, focus)) {
|
|
300
|
+
const frontPoint = _slate.Editor.start(editor, location);
|
|
301
|
+
newLocation = {
|
|
302
|
+
anchor: frontPoint,
|
|
303
|
+
focus: frontPoint
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
(0, _helper.setCursor)(editor, user, newLocation, cursorData);
|
|
294
307
|
|
|
295
308
|
// sync cursor position
|
|
296
309
|
editor.onCursor && editor.onCursor(editor.cursors);
|
package/dist/index.js
CHANGED
|
@@ -22,18 +22,6 @@ Object.defineProperty(exports, "SeafileCommentEditor", {
|
|
|
22
22
|
return _seafileCommentEditor.default;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
Object.defineProperty(exports, "createCommentEditor", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _basicSdk.createCommentEditor;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "withNodeId", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _basicSdk.withNodeId;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
25
|
var _basicSdk = require("./basic-sdk");
|
|
38
26
|
var _constants = require("./constants");
|
|
39
27
|
var _seafileCommentEditor = _interopRequireDefault(require("./pages/seafile-comment-editor"));
|
|
@@ -6,30 +6,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _reactI18next = require("react-i18next");
|
|
10
9
|
var _basicSdk = require("../basic-sdk");
|
|
11
|
-
|
|
10
|
+
// import ErrorBoundary from '../components/error-boundary';
|
|
11
|
+
|
|
12
12
|
const SeafileCommentEditor = _ref => {
|
|
13
13
|
let {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Provider
|
|
15
|
+
type,
|
|
16
|
+
// comment or replay
|
|
16
17
|
className = '',
|
|
18
|
+
pluginName = '',
|
|
19
|
+
// sdoc or wiki or txt ...
|
|
17
20
|
pluginEventBus,
|
|
18
21
|
pluginEvent,
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
// Comment editor
|
|
23
|
+
content,
|
|
24
|
+
insertContent,
|
|
25
|
+
onContentChange,
|
|
26
|
+
hiddenUserInfo,
|
|
27
|
+
hiddenComment,
|
|
28
|
+
toolMenus,
|
|
29
|
+
closePanel,
|
|
30
|
+
collaborators,
|
|
31
|
+
participants,
|
|
32
|
+
addParticipants,
|
|
33
|
+
// settings
|
|
34
|
+
settings,
|
|
35
|
+
api
|
|
21
36
|
} = _ref;
|
|
22
|
-
_basicSdk.context.init();
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
_basicSdk.context.init(settings, api);
|
|
38
|
+
return (
|
|
39
|
+
/*#__PURE__*/
|
|
40
|
+
// <ErrorBoundary>
|
|
41
|
+
_react.default.createElement(_basicSdk.CommentProvider, {
|
|
42
|
+
type: type,
|
|
43
|
+
className: className,
|
|
44
|
+
pluginName: pluginName,
|
|
45
|
+
pluginEventBus: pluginEventBus,
|
|
46
|
+
pluginEvent: pluginEvent,
|
|
47
|
+
collaborators: collaborators,
|
|
48
|
+
participants: participants,
|
|
49
|
+
addParticipants: addParticipants
|
|
50
|
+
}, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
|
|
51
|
+
content: content,
|
|
52
|
+
insertContent: insertContent,
|
|
53
|
+
onContentChange: onContentChange,
|
|
54
|
+
hiddenUserInfo: hiddenUserInfo,
|
|
55
|
+
hiddenComment: hiddenComment,
|
|
56
|
+
toolMenus: toolMenus,
|
|
57
|
+
closePanel: closePanel,
|
|
58
|
+
addParticipants: addParticipants
|
|
59
|
+
}))
|
|
60
|
+
// </ErrorBoundary>
|
|
61
|
+
);
|
|
34
62
|
};
|
|
35
|
-
var _default = exports.default =
|
|
63
|
+
var _default = exports.default = SeafileCommentEditor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/comment-editor",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.41",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a comment editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -115,10 +115,10 @@
|
|
|
115
115
|
"fs-extra": "^10.0.0",
|
|
116
116
|
"html-webpack-plugin": "^5.5.0",
|
|
117
117
|
"husky": "8.0.3",
|
|
118
|
-
"i18next": "
|
|
119
|
-
"i18next-browser-languagedetector": "
|
|
120
|
-
"i18next-
|
|
121
|
-
"identity-obj-proxy": "3.0.0",
|
|
118
|
+
"i18next": "^25.2.1",
|
|
119
|
+
"i18next-browser-languagedetector": "^8.1.0",
|
|
120
|
+
"i18next-http-backend": "^3.0.2",
|
|
121
|
+
"identity-obj-proxy": "^3.0.0",
|
|
122
122
|
"is-wsl": "^1.1.0",
|
|
123
123
|
"jest": "29.7.0",
|
|
124
124
|
"jest-environment-jsdom": "29.7.0",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"react-app-polyfill": "^3.0.0",
|
|
142
142
|
"react-dev-utils": "^12.0.1",
|
|
143
143
|
"react-dom": "18.3.1",
|
|
144
|
-
"react-i18next": "
|
|
144
|
+
"react-i18next": "15.5.2",
|
|
145
145
|
"react-refresh": "^0.11.0",
|
|
146
146
|
"react-router": "7.5.2",
|
|
147
147
|
"react-router-dom": "7.1.3",
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
.comment-drawer .comments-panel-body__header .comments-participants-container {
|
|
2
|
-
width: fit-content;
|
|
3
|
-
max-width: 100%;
|
|
4
|
-
height: 42px;
|
|
5
|
-
padding-top: 6px;
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
position: relative;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.comment-drawer .comments-panel-body__header .comments-participants-editor-target {
|
|
12
|
-
position: absolute;
|
|
13
|
-
left: -1px;
|
|
14
|
-
top: 0;
|
|
15
|
-
z-index: -1;
|
|
16
|
-
height: 100%;
|
|
17
|
-
width: 1px;
|
|
18
|
-
background-color: transparent;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.comment-drawer .comments-panel-body__header .comment-participant-avatar {
|
|
22
|
-
border-radius: 50%;
|
|
23
|
-
vertical-align: middle;
|
|
24
|
-
margin-right: -0.5rem;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.comment-drawer .comments-panel-body__header .comment-participant-avatar img {
|
|
28
|
-
width: 28px;
|
|
29
|
-
height: 28px;
|
|
30
|
-
border: 2px solid #fff;
|
|
31
|
-
line-height: 2rem;
|
|
32
|
-
border-radius: 50%;
|
|
33
|
-
display: inline-block;
|
|
34
|
-
background: #ced4da no-repeat center/cover;
|
|
35
|
-
position: relative;
|
|
36
|
-
text-align: center;
|
|
37
|
-
color: #868e96;
|
|
38
|
-
font-weight: 600;
|
|
39
|
-
vertical-align: bottom;
|
|
40
|
-
font-size: .875rem;
|
|
41
|
-
user-select: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.comment-drawer .comments-panel-body__header .add-comments-participants {
|
|
45
|
-
position: relative;
|
|
46
|
-
bottom: -3px;
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
margin-right: -0.5rem;
|
|
49
|
-
height: 20px;
|
|
50
|
-
width: 20px;
|
|
51
|
-
background-color: #fff;
|
|
52
|
-
border: 1px solid #fff;
|
|
53
|
-
border-radius: 50%;
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
justify-content: center;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.comment-drawer .add-comments-participants .sdocfont {
|
|
60
|
-
font-size: 16px;
|
|
61
|
-
color: #ff8000;
|
|
62
|
-
border-radius: 50%;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.comment-drawer .comment-participants-more {
|
|
66
|
-
position: absolute;
|
|
67
|
-
top: 0;
|
|
68
|
-
left: 0;
|
|
69
|
-
width: 28px;
|
|
70
|
-
height: 28px;
|
|
71
|
-
border-radius: 50%;
|
|
72
|
-
display: flex;
|
|
73
|
-
align-items: center;
|
|
74
|
-
justify-content: center;
|
|
75
|
-
overflow: hidden;
|
|
76
|
-
background-color: rgba(0, 0, 0, .6);
|
|
77
|
-
border: 2px solid #fff;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.comment-drawer .comment-participants-more .sdocfont {
|
|
81
|
-
color: #fff;
|
|
82
|
-
font-size: 12px;
|
|
83
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
11
|
-
var _slateReact = require("@seafile/slate-react");
|
|
12
|
-
var _tooltip = _interopRequireDefault(require("../../../components/tooltip"));
|
|
13
|
-
var _useParticipants = require("../../hooks/use-participants");
|
|
14
|
-
var _commentParticipantsEditor = _interopRequireDefault(require("../comment-participants-editor"));
|
|
15
|
-
var _participantAvatar = _interopRequireDefault(require("./participant-avatar"));
|
|
16
|
-
require("./index.css");
|
|
17
|
-
const CommentAllParticipants = () => {
|
|
18
|
-
const popoverRef = (0, _react.useRef)();
|
|
19
|
-
const {
|
|
20
|
-
participants
|
|
21
|
-
} = (0, _useParticipants.useParticipantsContext)();
|
|
22
|
-
const editor = (0, _slateReact.useSlateStatic)();
|
|
23
|
-
const {
|
|
24
|
-
t
|
|
25
|
-
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
26
|
-
const addParticipantId = 'sdoc-add-participants';
|
|
27
|
-
const commentsParticipantsId = 'sdoc-comments-participants';
|
|
28
|
-
const [isDidMount, setDidMount] = (0, _react.useState)(false);
|
|
29
|
-
(0, _react.useEffect)(() => {
|
|
30
|
-
setDidMount(true);
|
|
31
|
-
}, []);
|
|
32
|
-
const toggle = (0, _react.useCallback)(() => {
|
|
33
|
-
popoverRef.current && popoverRef.current.toggle();
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
-
}, [popoverRef.current]);
|
|
37
|
-
const participantsCount = participants.length;
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
39
|
-
className: "comments-participants-container"
|
|
40
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
41
|
-
className: "comments-participants-editor-target",
|
|
42
|
-
id: commentsParticipantsId
|
|
43
|
-
}), participants.slice(0, 14).map((participant, index) => {
|
|
44
|
-
const {
|
|
45
|
-
username
|
|
46
|
-
} = participant;
|
|
47
|
-
return /*#__PURE__*/_react.default.createElement(_participantAvatar.default, {
|
|
48
|
-
key: username,
|
|
49
|
-
participant: participant,
|
|
50
|
-
index: index,
|
|
51
|
-
showMore: participantsCount > 13 && index === 13
|
|
52
|
-
});
|
|
53
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
54
|
-
className: "add-comments-participants",
|
|
55
|
-
id: addParticipantId,
|
|
56
|
-
onClick: toggle
|
|
57
|
-
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
58
|
-
className: "sdocfont sdoc-add"
|
|
59
|
-
})), isDidMount && /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
60
|
-
target: addParticipantId
|
|
61
|
-
}, t('Add_participants'))), isDidMount && /*#__PURE__*/_react.default.createElement(_commentParticipantsEditor.default, {
|
|
62
|
-
target: commentsParticipantsId,
|
|
63
|
-
ref: popoverRef,
|
|
64
|
-
editor: editor
|
|
65
|
-
}));
|
|
66
|
-
};
|
|
67
|
-
var _default = exports.default = CommentAllParticipants;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _tooltip = _interopRequireDefault(require("../../../components/tooltip"));
|
|
12
|
-
const ParticipantAvatar = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
participant,
|
|
15
|
-
index,
|
|
16
|
-
showMore
|
|
17
|
-
} = _ref;
|
|
18
|
-
const [showTooltip, setShowTooltip] = (0, _react.useState)(false);
|
|
19
|
-
(0, _react.useEffect)(() => {
|
|
20
|
-
setShowTooltip(true);
|
|
21
|
-
}, []);
|
|
22
|
-
const {
|
|
23
|
-
name,
|
|
24
|
-
avatar_url
|
|
25
|
-
} = participant;
|
|
26
|
-
const id = `comment-participant-avatar-${index}-${Math.floor(Math.random() * 1000)}`;
|
|
27
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
-
className: (0, _classnames.default)('comment-participant-avatar', {
|
|
29
|
-
'position-relative': showMore
|
|
30
|
-
}),
|
|
31
|
-
id: id
|
|
32
|
-
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
33
|
-
src: avatar_url,
|
|
34
|
-
alt: ""
|
|
35
|
-
}), showTooltip && /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
36
|
-
target: id
|
|
37
|
-
}, name), showMore && /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
-
className: "comment-participants-more"
|
|
39
|
-
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
40
|
-
className: "sdocfont sdoc-more"
|
|
41
|
-
})));
|
|
42
|
-
};
|
|
43
|
-
var _default = exports.default = ParticipantAvatar;
|