@seafile/comment-editor 0.0.1-alpha.3 → 0.0.1-alpha.30
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 -14
- package/dist/basic-sdk/editor/comment-editor.css +138 -0
- package/dist/basic-sdk/{comment/components → editor}/comment-editor.js +41 -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 +7 -3
- package/dist/basic-sdk/hooks/use-comment.js +19 -182
- package/dist/basic-sdk/index.js +3 -10
- package/dist/index.js +0 -12
- package/dist/pages/seafile-comment-editor.js +37 -13
- package/package.json +1 -1
- 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/helpers.js +0 -299
- 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
|
@@ -1,207 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.useComment = exports.CommentProvider = void 0;
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _utils = require("../comment/utils");
|
|
17
|
-
var _toast = _interopRequireDefault(require("../components/toast"));
|
|
18
|
-
var _constants2 = require("../constants");
|
|
19
|
-
var _model = require("../model");
|
|
20
|
-
var _commonUtils = require("../utils/common-utils");
|
|
21
|
-
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
9
|
+
require("../assets/css/layout.css");
|
|
10
|
+
require("../assets/css/default.css");
|
|
11
|
+
require("../assets/css/sdoc-editor-article.css");
|
|
12
|
+
require("../assets/css/sdoc-editor-plugins.css");
|
|
13
|
+
require("../assets/css/sdoc-comment-editor-plugin.css");
|
|
14
|
+
require("../assets/css/dropdown-menu.css");
|
|
22
15
|
const CommentContext = /*#__PURE__*/_react.default.createContext(null);
|
|
23
16
|
const CommentProvider = _ref => {
|
|
24
17
|
let {
|
|
25
18
|
children,
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
type,
|
|
20
|
+
// comment or replay
|
|
21
|
+
userInfo,
|
|
28
22
|
className = '',
|
|
23
|
+
pluginName = '',
|
|
24
|
+
// sdoc or wiki or txt ...
|
|
29
25
|
pluginEventBus,
|
|
30
26
|
pluginEvent,
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
collaborators,
|
|
28
|
+
participants,
|
|
29
|
+
addParticipants
|
|
33
30
|
} = _ref;
|
|
34
|
-
const {
|
|
35
|
-
t
|
|
36
|
-
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
37
|
-
const [collaborators, setCollaborators] = (0, _react.useState)([]);
|
|
38
|
-
const [participants, setParticipants] = (0, _react.useState)([]);
|
|
39
|
-
const [commentType, setCommentType] = (0, _react.useState)(_constants.COMMENT_TYPES.ALL);
|
|
40
|
-
const [commentList, setCommentList] = (0, _react.useState)([]);
|
|
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
|
|
122
|
-
}, [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
31
|
return /*#__PURE__*/_react.default.createElement(CommentContext.Provider, {
|
|
187
32
|
value: {
|
|
188
|
-
|
|
33
|
+
type,
|
|
34
|
+
userInfo,
|
|
189
35
|
className,
|
|
190
|
-
|
|
36
|
+
pluginName,
|
|
191
37
|
pluginEventBus,
|
|
192
38
|
pluginEvent,
|
|
193
|
-
commentsInfo,
|
|
194
|
-
commentType,
|
|
195
|
-
commentList,
|
|
196
|
-
dispatch,
|
|
197
|
-
setCommentType,
|
|
198
|
-
onCloseCommentPanel,
|
|
199
39
|
collaborators,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
addParticipants,
|
|
203
|
-
deleteParticipant,
|
|
204
|
-
participants
|
|
40
|
+
participants,
|
|
41
|
+
addParticipants
|
|
205
42
|
}
|
|
206
43
|
}, children);
|
|
207
44
|
};
|
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"));
|
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"));
|
|
@@ -1,36 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _reactI18next = require("react-i18next");
|
|
11
10
|
var _basicSdk = require("../basic-sdk");
|
|
12
11
|
var _errorBoundary = _interopRequireDefault(require("../components/error-boundary"));
|
|
13
12
|
const SeafileCommentEditor = _ref => {
|
|
14
13
|
let {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// Provider
|
|
15
|
+
type,
|
|
16
|
+
// comment or replay
|
|
17
|
+
userInfo,
|
|
17
18
|
className = '',
|
|
19
|
+
pluginName = '',
|
|
20
|
+
// sdoc or wiki or txt ...
|
|
18
21
|
pluginEventBus,
|
|
19
22
|
pluginEvent,
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
// Comment editor
|
|
24
|
+
content,
|
|
25
|
+
insertContent,
|
|
26
|
+
onContentChange,
|
|
27
|
+
hiddenUserInfo,
|
|
28
|
+
hiddenComment,
|
|
29
|
+
hiddenToolMenu,
|
|
30
|
+
closePanel,
|
|
31
|
+
collaborators,
|
|
32
|
+
participants,
|
|
33
|
+
addParticipants,
|
|
34
|
+
// settings
|
|
35
|
+
settings,
|
|
36
|
+
api
|
|
22
37
|
} = _ref;
|
|
23
|
-
_basicSdk.context.init();
|
|
38
|
+
_basicSdk.context.init(settings, api);
|
|
24
39
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentProvider, {
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
type: type,
|
|
41
|
+
userInfo: userInfo,
|
|
27
42
|
className: className,
|
|
43
|
+
pluginName: pluginName,
|
|
28
44
|
pluginEventBus: pluginEventBus,
|
|
29
45
|
pluginEvent: pluginEvent,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
collaborators: collaborators,
|
|
47
|
+
participants: participants,
|
|
48
|
+
addParticipants: addParticipants
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
|
|
50
|
+
content: content,
|
|
51
|
+
insertContent: insertContent,
|
|
52
|
+
onContentChange: onContentChange,
|
|
53
|
+
hiddenUserInfo: hiddenUserInfo,
|
|
54
|
+
hiddenComment: hiddenComment,
|
|
55
|
+
hiddenToolMenu: hiddenToolMenu,
|
|
56
|
+
closePanel: closePanel,
|
|
57
|
+
addParticipants: addParticipants
|
|
34
58
|
})));
|
|
35
59
|
};
|
|
36
60
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(SeafileCommentEditor);
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -1,80 +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 _reactstrap = require("reactstrap");
|
|
12
|
-
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
13
|
-
var _utils = require("../utils");
|
|
14
|
-
require("./comment-list.css");
|
|
15
|
-
const CommentDeletePopover = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
type,
|
|
18
|
-
setIsShowDeletePopover,
|
|
19
|
-
deleteConfirm,
|
|
20
|
-
targetId,
|
|
21
|
-
parentDom
|
|
22
|
-
} = _ref;
|
|
23
|
-
const popoverRef = (0, _react.useRef)(null);
|
|
24
|
-
const hide = (0, _react.useCallback)(event => {
|
|
25
|
-
if (popoverRef.current && !(0, _utils.getEventClassName)(event).includes('popover') && !popoverRef.current.contains(event.target)) {
|
|
26
|
-
setIsShowDeletePopover(false);
|
|
27
|
-
event.preventDefault();
|
|
28
|
-
event.stopPropagation();
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}, [setIsShowDeletePopover]);
|
|
32
|
-
const onHotKey = (0, _react.useCallback)(event => {
|
|
33
|
-
if ((0, _isHotkey.default)('esc', event)) {
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
setIsShowDeletePopover(false);
|
|
36
|
-
}
|
|
37
|
-
}, [setIsShowDeletePopover]);
|
|
38
|
-
(0, _react.useEffect)(() => {
|
|
39
|
-
document.addEventListener('click', hide, true);
|
|
40
|
-
document.addEventListener('keydown', onHotKey);
|
|
41
|
-
return () => {
|
|
42
|
-
document.removeEventListener('click', hide, true);
|
|
43
|
-
document.removeEventListener('keydown', onHotKey);
|
|
44
|
-
};
|
|
45
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
-
}, []);
|
|
47
|
-
const {
|
|
48
|
-
t
|
|
49
|
-
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
50
|
-
const onDeleteCancel = (0, _react.useCallback)(event => {
|
|
51
|
-
event.stopPropagation();
|
|
52
|
-
setIsShowDeletePopover(false);
|
|
53
|
-
}, [setIsShowDeletePopover]);
|
|
54
|
-
const handleConfirm = (0, _react.useCallback)(event => {
|
|
55
|
-
event.stopPropagation();
|
|
56
|
-
deleteConfirm();
|
|
57
|
-
}, [deleteConfirm]);
|
|
58
|
-
return /*#__PURE__*/_react.default.createElement(_reactstrap.UncontrolledPopover, {
|
|
59
|
-
container: parentDom,
|
|
60
|
-
target: targetId,
|
|
61
|
-
onClick: event => event.stopPropagation(),
|
|
62
|
-
placement: "left",
|
|
63
|
-
className: "comment-delete-popover",
|
|
64
|
-
isOpen: true
|
|
65
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
-
className: "comment-delete-popover-container",
|
|
67
|
-
ref: popoverRef
|
|
68
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
69
|
-
className: "delete-tip"
|
|
70
|
-
}, t(`Are_you_sure_to_delete_this_${type === 'comment' ? 'comment' : 'reply'}`)), /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
-
className: "delete-control mt-5"
|
|
72
|
-
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
73
|
-
className: "btn btn-secondary mr-2",
|
|
74
|
-
onClick: onDeleteCancel
|
|
75
|
-
}, t('Cancel')), /*#__PURE__*/_react.default.createElement("button", {
|
|
76
|
-
className: "btn btn-primary",
|
|
77
|
-
onClick: handleConfirm
|
|
78
|
-
}, t('Confirm')))));
|
|
79
|
-
};
|
|
80
|
-
var _default = exports.default = CommentDeletePopover;
|