@seafile/comment-editor 0.0.1-alpha.5 → 0.0.1-alpha.50
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/_i18n/index.js +37 -0
- package/dist/basic-sdk/context.js +8 -21
- package/dist/basic-sdk/editor/comment-editor.js +16 -58
- package/dist/basic-sdk/extension/commons/color-menu/color-item.js +4 -2
- package/dist/basic-sdk/extension/commons/color-menu/index.js +4 -2
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +5 -3
- 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/plugins/sdoc-link/hover-menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/color-item.js +4 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/comemnt-editor-menu.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/video/render-elem.js +1 -2
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +13 -9
- package/dist/basic-sdk/hooks/use-comment.js +24 -16
- package/dist/basic-sdk/model/index.js +1 -8
- package/dist/basic-sdk/socket/helpers.js +312 -0
- package/dist/components/error-boundary/error-page.js +4 -4
- package/dist/pages/seafile-comment-editor.js +39 -17
- package/package.json +6 -6
- 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/model/notification.js +0 -18
|
@@ -4,17 +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, "Notification", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _notification.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
7
|
Object.defineProperty(exports, "User", {
|
|
14
8
|
enumerable: true,
|
|
15
9
|
get: function () {
|
|
16
10
|
return _user.default;
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
|
-
var _user = _interopRequireDefault(require("./user"));
|
|
20
|
-
var _notification = _interopRequireDefault(require("./notification"));
|
|
13
|
+
var _user = _interopRequireDefault(require("./user"));
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.validateOperation = exports.syncRemoteOperations = exports.syncRemoteCursorLocation = exports.revertOperationList = exports.reExecRevertOperationList = exports.getRevertOperationList = exports.getNodePathById = void 0;
|
|
9
|
+
var _slate = require("@seafile/slate");
|
|
10
|
+
var _deepCopy = _interopRequireDefault(require("deep-copy"));
|
|
11
|
+
var _helper = require("../cursor/helper");
|
|
12
|
+
var _core = require("../extension/core");
|
|
13
|
+
var OPERATION = _interopRequireWildcard(require("../node-id/constants"));
|
|
14
|
+
const getNodePathById = function (rootNode, nodeId) {
|
|
15
|
+
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
16
|
+
if (rootNode.id === nodeId) return path;
|
|
17
|
+
const {
|
|
18
|
+
children = []
|
|
19
|
+
} = rootNode;
|
|
20
|
+
for (let i = 0; i < children.length; i++) {
|
|
21
|
+
const child = children[i];
|
|
22
|
+
path.push(i);
|
|
23
|
+
const nodePath = getNodePathById(child, nodeId, path);
|
|
24
|
+
if (nodePath) return nodePath;
|
|
25
|
+
path.pop();
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
exports.getNodePathById = getNodePathById;
|
|
30
|
+
const validateOperation = (editor, operation) => {
|
|
31
|
+
let isValid = false;
|
|
32
|
+
let newOperation = (0, _deepCopy.default)(operation);
|
|
33
|
+
const {
|
|
34
|
+
type
|
|
35
|
+
} = newOperation;
|
|
36
|
+
switch (type) {
|
|
37
|
+
case OPERATION.INSERT_TEXT:
|
|
38
|
+
case OPERATION.REMOVE_TEXT:
|
|
39
|
+
{
|
|
40
|
+
const {
|
|
41
|
+
node_id,
|
|
42
|
+
path
|
|
43
|
+
} = newOperation;
|
|
44
|
+
const node = (0, _core.getNode)(editor, path);
|
|
45
|
+
// node is exist and node path is not changed
|
|
46
|
+
if (node && node.id === node_id) {
|
|
47
|
+
isValid = true;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// node is exist but node path is changed
|
|
52
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
53
|
+
if (nodePath) {
|
|
54
|
+
isValid = true;
|
|
55
|
+
newOperation.path = nodePath;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
// node is not exist
|
|
59
|
+
isValid = false;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case OPERATION.INSERT_NODE:
|
|
63
|
+
{
|
|
64
|
+
let {
|
|
65
|
+
parent_node_id,
|
|
66
|
+
path
|
|
67
|
+
} = newOperation;
|
|
68
|
+
const parentNodePath = getNodePathById(editor, parent_node_id);
|
|
69
|
+
if (!parentNodePath) {
|
|
70
|
+
isValid = false;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const parentPath = path.slice(0, path.length - 1);
|
|
74
|
+
if (parentPath.join() === parentNodePath.join()) {
|
|
75
|
+
isValid = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// reset insert node path
|
|
80
|
+
const parentNode = (0, _core.getNode)(editor, path);
|
|
81
|
+
if (parentNode) {
|
|
82
|
+
const childLength = parentNode.children.length;
|
|
83
|
+
const index = Math.min(path[path.length - 1], childLength);
|
|
84
|
+
newOperation.path = parentNodePath.concat([index]);
|
|
85
|
+
isValid = true;
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case OPERATION.REMOVE_NODE:
|
|
90
|
+
{
|
|
91
|
+
const {
|
|
92
|
+
node_id,
|
|
93
|
+
path
|
|
94
|
+
} = newOperation;
|
|
95
|
+
const node = (0, _core.getNode)(editor, path);
|
|
96
|
+
// node is exist and node path is not changed
|
|
97
|
+
if (node && node.id === node_id) {
|
|
98
|
+
isValid = true;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// node is exist but node path is changed
|
|
103
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
104
|
+
if (nodePath) {
|
|
105
|
+
isValid = true;
|
|
106
|
+
newOperation.path = nodePath;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// node is not exist
|
|
111
|
+
isValid = false;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case OPERATION.MERGE_NODE:
|
|
115
|
+
{
|
|
116
|
+
// merge next node into prev node
|
|
117
|
+
const {
|
|
118
|
+
node_id,
|
|
119
|
+
path
|
|
120
|
+
} = newOperation;
|
|
121
|
+
const node = (0, _core.getNode)(editor, path);
|
|
122
|
+
// node is exist and node path is not changed
|
|
123
|
+
if (node && node.id === node_id) {
|
|
124
|
+
isValid = true;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// node is exist but node path is changed
|
|
129
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
130
|
+
if (nodePath) {
|
|
131
|
+
isValid = true;
|
|
132
|
+
newOperation.path = nodePath;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// node is not exist
|
|
137
|
+
isValid = false;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case OPERATION.SPLIT_NODE:
|
|
141
|
+
{
|
|
142
|
+
const {
|
|
143
|
+
node_id,
|
|
144
|
+
path
|
|
145
|
+
} = newOperation;
|
|
146
|
+
const node = (0, _core.getNode)(editor, path);
|
|
147
|
+
// node is exist and node path is not changed
|
|
148
|
+
if (node && node.id === node_id) {
|
|
149
|
+
isValid = true;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// node is exist but node path is changed
|
|
154
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
155
|
+
if (nodePath) {
|
|
156
|
+
isValid = true;
|
|
157
|
+
newOperation.path = nodePath;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// node is not exist
|
|
162
|
+
isValid = false;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case OPERATION.SET_NODE:
|
|
166
|
+
{
|
|
167
|
+
const {
|
|
168
|
+
node_id,
|
|
169
|
+
path,
|
|
170
|
+
properties
|
|
171
|
+
} = newOperation;
|
|
172
|
+
const node = (0, _core.getNode)(editor, path);
|
|
173
|
+
// node is exist and node path is not changed
|
|
174
|
+
if (node && node.id === node_id) {
|
|
175
|
+
isValid = true;
|
|
176
|
+
newOperation.properties = {
|
|
177
|
+
...properties,
|
|
178
|
+
type: node.type
|
|
179
|
+
};
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// node is exist but node path is changed
|
|
184
|
+
const nodePath = getNodePathById(editor, node_id);
|
|
185
|
+
if (nodePath) {
|
|
186
|
+
isValid = true;
|
|
187
|
+
const node = (0, _core.getNode)(editor, nodePath);
|
|
188
|
+
newOperation.properties = {
|
|
189
|
+
...properties,
|
|
190
|
+
type: node.type
|
|
191
|
+
};
|
|
192
|
+
newOperation.path = nodePath;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// node is not exist
|
|
197
|
+
isValid = false;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case OPERATION.MOVE_NODE:
|
|
201
|
+
{
|
|
202
|
+
const {
|
|
203
|
+
node_id,
|
|
204
|
+
path
|
|
205
|
+
} = newOperation;
|
|
206
|
+
const node = (0, _core.getNode)(editor, path);
|
|
207
|
+
// node is exist and node path is not changed
|
|
208
|
+
if (node && node.id === node_id) {
|
|
209
|
+
isValid = true;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// TODO: newPath can not calculate by nodePath
|
|
214
|
+
// node is exist but node path is changed
|
|
215
|
+
// const nodePath = getNodePathById(editor, node_id);
|
|
216
|
+
// if (nodePath) {}
|
|
217
|
+
|
|
218
|
+
// node is not exist
|
|
219
|
+
isValid = false;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
default:
|
|
223
|
+
{
|
|
224
|
+
// set_selection
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (isValid) return newOperation;
|
|
229
|
+
return isValid;
|
|
230
|
+
};
|
|
231
|
+
exports.validateOperation = validateOperation;
|
|
232
|
+
const getRevertOperationList = operationList => {
|
|
233
|
+
if (operationList.length === 0) return [];
|
|
234
|
+
|
|
235
|
+
// Generate a duplicate operationList, The original value cannot be modified here
|
|
236
|
+
let revertOperationList = (0, _deepCopy.default)(operationList);
|
|
237
|
+
revertOperationList = revertOperationList.reverse();
|
|
238
|
+
return revertOperationList.map(operations => {
|
|
239
|
+
const ops = operations.reverse();
|
|
240
|
+
return ops.map(item => _slate.Operation.inverse(item));
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
exports.getRevertOperationList = getRevertOperationList;
|
|
244
|
+
const revertOperationList = (editor, operationList) => {
|
|
245
|
+
if (operationList.length === 0) return [];
|
|
246
|
+
const revertOperationList = getRevertOperationList(operationList);
|
|
247
|
+
|
|
248
|
+
// Cancel locale execute operations
|
|
249
|
+
for (let i = 0; i < revertOperationList.length; i++) {
|
|
250
|
+
const operations = revertOperationList[i];
|
|
251
|
+
_slate.Editor.withoutNormalizing(editor, () => {
|
|
252
|
+
for (let j = 0; j < operations.length; j++) {
|
|
253
|
+
const op = operations[j];
|
|
254
|
+
editor.apply(op);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
exports.revertOperationList = revertOperationList;
|
|
260
|
+
const reExecRevertOperationList = (editor, revertOperationList) => {
|
|
261
|
+
if (revertOperationList.length === 0) return;
|
|
262
|
+
|
|
263
|
+
// Re-execute revert operations
|
|
264
|
+
for (let i = 0; i < revertOperationList.length; i++) {
|
|
265
|
+
const operations = revertOperationList[i];
|
|
266
|
+
_slate.Editor.withoutNormalizing(editor, () => {
|
|
267
|
+
for (let j = 0; j < operations.length; j++) {
|
|
268
|
+
const op = validateOperation(editor, operations[j]);
|
|
269
|
+
if (op) {
|
|
270
|
+
editor.apply(op);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
exports.reExecRevertOperationList = reExecRevertOperationList;
|
|
277
|
+
const syncRemoteOperations = (editor, remoteOperations) => {
|
|
278
|
+
if (remoteOperations.length === 0) return;
|
|
279
|
+
_slate.Editor.withoutNormalizing(editor, () => {
|
|
280
|
+
for (let i = 0; i < remoteOperations.length; i++) {
|
|
281
|
+
const op = remoteOperations[i];
|
|
282
|
+
if (op.type === 'set_selection') {
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
editor.apply(op);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
exports.syncRemoteOperations = syncRemoteOperations;
|
|
290
|
+
const syncRemoteCursorLocation = (editor, user, location, cursorData) => {
|
|
291
|
+
const currentUser = editor.user;
|
|
292
|
+
if (user && user.username !== currentUser.username) {
|
|
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);
|
|
307
|
+
|
|
308
|
+
// sync cursor position
|
|
309
|
+
editor.onCursor && editor.onCursor(editor.cursors);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
exports.syncRemoteCursorLocation = syncRemoteCursorLocation;
|
|
@@ -10,10 +10,10 @@ var _reactI18next = require("react-i18next");
|
|
|
10
10
|
var _reactstrap = require("reactstrap");
|
|
11
11
|
var _basicSdk = require("../../basic-sdk");
|
|
12
12
|
require("./error-page.css");
|
|
13
|
-
function ErrorPage(
|
|
14
|
-
|
|
13
|
+
function ErrorPage() {
|
|
14
|
+
const {
|
|
15
15
|
t
|
|
16
|
-
} =
|
|
16
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
17
17
|
const normalizeSdoc = (0, _react.useCallback)(async () => {
|
|
18
18
|
const res = await _basicSdk.context.normalizeSdocContent();
|
|
19
19
|
const {
|
|
@@ -33,4 +33,4 @@ function ErrorPage(_ref) {
|
|
|
33
33
|
onClick: () => normalizeSdoc()
|
|
34
34
|
}, t('Repair')));
|
|
35
35
|
}
|
|
36
|
-
var _default = exports.default =
|
|
36
|
+
var _default = exports.default = ErrorPage;
|
|
@@ -8,35 +8,57 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactI18next = require("react-i18next");
|
|
10
10
|
var _basicSdk = require("../basic-sdk");
|
|
11
|
+
var _i18n = require("../_i18n");
|
|
11
12
|
var _errorBoundary = _interopRequireDefault(require("../components/error-boundary"));
|
|
12
13
|
const SeafileCommentEditor = _ref => {
|
|
13
14
|
let {
|
|
14
|
-
|
|
15
|
-
className = '',
|
|
15
|
+
// Provider
|
|
16
16
|
type,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onContentChange,
|
|
17
|
+
// comment or replay
|
|
18
|
+
className = '',
|
|
19
|
+
pluginName = '',
|
|
20
|
+
// sdoc or wiki or txt ...
|
|
22
21
|
pluginEventBus,
|
|
23
22
|
pluginEvent,
|
|
23
|
+
// Comment editor
|
|
24
|
+
content,
|
|
25
|
+
insertContent,
|
|
26
|
+
onContentChange,
|
|
27
|
+
hiddenUserInfo,
|
|
28
|
+
hiddenComment,
|
|
29
|
+
toolMenus,
|
|
30
|
+
closePanel,
|
|
31
|
+
collaborators,
|
|
32
|
+
participants,
|
|
33
|
+
addParticipants,
|
|
34
|
+
// settings
|
|
35
|
+
settings,
|
|
24
36
|
api
|
|
25
37
|
} = _ref;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
const {
|
|
39
|
+
lang
|
|
40
|
+
} = settings || {};
|
|
41
|
+
_basicSdk.context.init(settings, api);
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_reactI18next.I18nextProvider, {
|
|
43
|
+
i18n: (0, _i18n.getI18n)(lang || 'en')
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentProvider, {
|
|
45
|
+
type: type,
|
|
29
46
|
className: className,
|
|
47
|
+
pluginName: pluginName,
|
|
30
48
|
pluginEventBus: pluginEventBus,
|
|
31
49
|
pluginEvent: pluginEvent,
|
|
32
|
-
|
|
50
|
+
collaborators: collaborators,
|
|
51
|
+
participants: participants,
|
|
52
|
+
addParticipants: addParticipants
|
|
33
53
|
}, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
|
|
34
|
-
|
|
35
|
-
commentContent: commentContent,
|
|
36
|
-
hiddenUserInfo: hiddenUserInfo,
|
|
54
|
+
content: content,
|
|
37
55
|
insertContent: insertContent,
|
|
56
|
+
onContentChange: onContentChange,
|
|
57
|
+
hiddenUserInfo: hiddenUserInfo,
|
|
38
58
|
hiddenComment: hiddenComment,
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
toolMenus: toolMenus,
|
|
60
|
+
closePanel: closePanel,
|
|
61
|
+
addParticipants: addParticipants
|
|
62
|
+
}))));
|
|
41
63
|
};
|
|
42
|
-
var _default = exports.default =
|
|
64
|
+
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.50",
|
|
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,15 +0,0 @@
|
|
|
1
|
-
.comment-layout-wrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: row;
|
|
4
|
-
max-width: 620px;
|
|
5
|
-
min-width: 360px;
|
|
6
|
-
position: relative;
|
|
7
|
-
right: 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.comment-layout-wrapper .sdoc-content-right-panel {
|
|
11
|
-
width: 100%;
|
|
12
|
-
height: 100%;
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
border-left: 1px solid #d8d8d8;
|
|
15
|
-
}
|
|
@@ -1,87 +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 _comment = _interopRequireDefault(require("../../comment"));
|
|
11
|
-
var _constants = require("../../constants");
|
|
12
|
-
var _useComment = require("../../hooks/use-comment");
|
|
13
|
-
var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
|
|
14
|
-
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
15
|
-
var _resizeWidth = _interopRequireDefault(require("./resize-width"));
|
|
16
|
-
require("./index.css");
|
|
17
|
-
const MIN_PANEL_WIDTH = 360;
|
|
18
|
-
const MAX_PANEL_WIDTH = 620;
|
|
19
|
-
const CommentLayout = _ref => {
|
|
20
|
-
let {
|
|
21
|
-
editor
|
|
22
|
-
} = _ref;
|
|
23
|
-
const {
|
|
24
|
-
className,
|
|
25
|
-
pluginName,
|
|
26
|
-
pluginEventBus,
|
|
27
|
-
pluginEvent
|
|
28
|
-
} = (0, _useComment.useComment)();
|
|
29
|
-
const [width, setWidth] = (0, _react.useState)(MIN_PANEL_WIDTH);
|
|
30
|
-
const panelWrapperStyle = (0, _react.useMemo)(() => {
|
|
31
|
-
if (!pluginName) return null;
|
|
32
|
-
let style = {
|
|
33
|
-
width,
|
|
34
|
-
zIndex: 101
|
|
35
|
-
};
|
|
36
|
-
if (!style.width || style.width < MIN_PANEL_WIDTH) {
|
|
37
|
-
style.width = MIN_PANEL_WIDTH;
|
|
38
|
-
} else if (style.width > MAX_PANEL_WIDTH) {
|
|
39
|
-
style.width = MAX_PANEL_WIDTH;
|
|
40
|
-
}
|
|
41
|
-
return style;
|
|
42
|
-
}, [width, pluginName]);
|
|
43
|
-
const resizeWidth = (0, _react.useCallback)(width => {
|
|
44
|
-
setWidth(width);
|
|
45
|
-
}, []);
|
|
46
|
-
const resizeWidthEnd = (0, _react.useCallback)(width => {
|
|
47
|
-
const settings = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
48
|
-
_localStorageUtils.default.setItem(_constants.SDOC_STORAGE, JSON.stringify({
|
|
49
|
-
...settings,
|
|
50
|
-
panelWidth: width
|
|
51
|
-
}));
|
|
52
|
-
const eventBus = _eventBus.default.getInstance();
|
|
53
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
54
|
-
}, []);
|
|
55
|
-
(0, _react.useEffect)(() => {
|
|
56
|
-
const isShowGlobalComments = pluginName === 'sdoc' ? true : false;
|
|
57
|
-
const settings = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
58
|
-
_localStorageUtils.default.setItem(_constants.SDOC_STORAGE, {
|
|
59
|
-
...settings,
|
|
60
|
-
isShowGlobalComments
|
|
61
|
-
});
|
|
62
|
-
const eventBus = pluginEventBus.getInstance();
|
|
63
|
-
eventBus.dispatch(pluginEvent.RESIZE_ARTICLE);
|
|
64
|
-
}, [pluginEvent.RESIZE_ARTICLE, pluginEventBus, pluginName]);
|
|
65
|
-
(0, _react.useEffect)(() => {
|
|
66
|
-
const settings = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
67
|
-
const {
|
|
68
|
-
panelWidth
|
|
69
|
-
} = settings;
|
|
70
|
-
const width = Math.max(MIN_PANEL_WIDTH, Math.min(parseInt(panelWidth, 10) || MIN_PANEL_WIDTH, MAX_PANEL_WIDTH));
|
|
71
|
-
setWidth(width);
|
|
72
|
-
}, []);
|
|
73
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
-
className: `comment-layout-wrapper ${className}`,
|
|
75
|
-
style: panelWrapperStyle
|
|
76
|
-
}, /*#__PURE__*/_react.default.createElement(_resizeWidth.default, {
|
|
77
|
-
minWidth: MIN_PANEL_WIDTH,
|
|
78
|
-
maxWidth: MAX_PANEL_WIDTH,
|
|
79
|
-
resizeWidth: resizeWidth,
|
|
80
|
-
resizeWidthEnd: resizeWidthEnd
|
|
81
|
-
}), /*#__PURE__*/_react.default.createElement(_comment.default, {
|
|
82
|
-
editor: editor,
|
|
83
|
-
type: "global",
|
|
84
|
-
width: width
|
|
85
|
-
}));
|
|
86
|
-
};
|
|
87
|
-
var _default = exports.default = CommentLayout;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
.comment-layout-resize-width-handler {
|
|
2
|
-
height: 100%;
|
|
3
|
-
position: absolute;
|
|
4
|
-
right: 0;
|
|
5
|
-
top: 0;
|
|
6
|
-
width: 6px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.comment-layout-resize-width-handler.resize-handler-placement-right {
|
|
10
|
-
left: 0;
|
|
11
|
-
right: auto;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.comment-layout-resize-width-handler:hover {
|
|
15
|
-
cursor: col-resize;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.comment-layout-resize-width-handler .comment-layout-resize-width-handler-content {
|
|
19
|
-
background-color: initial;
|
|
20
|
-
height: 100%;
|
|
21
|
-
position: relative;
|
|
22
|
-
width: 2px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.comment-layout-resize-width-handler:hover .comment-layout-resize-width-handler-content {
|
|
26
|
-
background-color: #ccc;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.comment-layout-resize-width-handler .comment-layout-resize-width-handler-bar {
|
|
30
|
-
background-color: #2d7ff9;
|
|
31
|
-
border-radius: 3px;
|
|
32
|
-
content: "";
|
|
33
|
-
left: 50%;
|
|
34
|
-
margin-left: -3px;
|
|
35
|
-
position: absolute;
|
|
36
|
-
width: 6px;
|
|
37
|
-
}
|
|
38
|
-
|