@univerjs/docs-thread-comment-ui 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.0
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/LICENSE +176 -0
- package/README.md +22 -6
- package/lib/cjs/index.js +346 -127
- package/lib/cjs/locale/ar-SA.js +2 -1
- package/lib/cjs/locale/ca-ES.js +2 -1
- package/lib/cjs/locale/de-DE.js +2 -1
- package/lib/cjs/locale/en-US.js +2 -1
- package/lib/cjs/locale/es-ES.js +2 -1
- package/lib/cjs/locale/fa-IR.js +2 -1
- package/lib/cjs/locale/fr-FR.js +2 -1
- package/lib/cjs/locale/id-ID.js +2 -1
- package/lib/cjs/locale/it-IT.js +2 -1
- package/lib/cjs/locale/ja-JP.js +2 -1
- package/lib/cjs/locale/ko-KR.js +2 -1
- package/lib/cjs/locale/pl-PL.js +2 -1
- package/lib/cjs/locale/pt-BR.js +2 -1
- package/lib/cjs/locale/ru-RU.js +2 -1
- package/lib/cjs/locale/sk-SK.js +2 -1
- package/lib/cjs/locale/vi-VN.js +2 -1
- package/lib/cjs/locale/zh-CN.js +2 -1
- package/lib/cjs/locale/zh-HK.js +2 -1
- package/lib/cjs/locale/zh-TW.js +2 -1
- package/lib/es/index.js +347 -128
- package/lib/es/locale/ar-SA.js +2 -1
- package/lib/es/locale/ca-ES.js +2 -1
- package/lib/es/locale/de-DE.js +2 -1
- package/lib/es/locale/en-US.js +2 -1
- package/lib/es/locale/es-ES.js +2 -1
- package/lib/es/locale/fa-IR.js +2 -1
- package/lib/es/locale/fr-FR.js +2 -1
- package/lib/es/locale/id-ID.js +2 -1
- package/lib/es/locale/it-IT.js +2 -1
- package/lib/es/locale/ja-JP.js +2 -1
- package/lib/es/locale/ko-KR.js +2 -1
- package/lib/es/locale/pl-PL.js +2 -1
- package/lib/es/locale/pt-BR.js +2 -1
- package/lib/es/locale/ru-RU.js +2 -1
- package/lib/es/locale/sk-SK.js +2 -1
- package/lib/es/locale/vi-VN.js +2 -1
- package/lib/es/locale/zh-CN.js +2 -1
- package/lib/es/locale/zh-HK.js +2 -1
- package/lib/es/locale/zh-TW.js +2 -1
- package/lib/index.js +347 -128
- package/lib/locale/ar-SA.js +2 -1
- package/lib/locale/ca-ES.js +2 -1
- package/lib/locale/de-DE.js +2 -1
- package/lib/locale/en-US.js +2 -1
- package/lib/locale/es-ES.js +2 -1
- package/lib/locale/fa-IR.js +2 -1
- package/lib/locale/fr-FR.js +2 -1
- package/lib/locale/id-ID.js +2 -1
- package/lib/locale/it-IT.js +2 -1
- package/lib/locale/ja-JP.js +2 -1
- package/lib/locale/ko-KR.js +2 -1
- package/lib/locale/pl-PL.js +2 -1
- package/lib/locale/pt-BR.js +2 -1
- package/lib/locale/ru-RU.js +2 -1
- package/lib/locale/sk-SK.js +2 -1
- package/lib/locale/vi-VN.js +2 -1
- package/lib/locale/zh-CN.js +2 -1
- package/lib/locale/zh-HK.js +2 -1
- package/lib/locale/zh-TW.js +2 -1
- package/lib/types/commands/commands/add-doc-comment.command.d.ts +4 -7
- package/lib/types/commands/operations/show-comment-panel.operation.d.ts +1 -0
- package/lib/types/common/const.d.ts +0 -1
- package/lib/types/controllers/doc-thread-comment-selection.controller.d.ts +1 -0
- package/lib/types/controllers/render-controllers/render.controller.d.ts +11 -4
- package/lib/types/locale/en-US.d.ts +1 -0
- package/lib/types/menu/menu.d.ts +30 -6
- package/lib/types/views/DocThreadCommentPanel.d.ts +4 -0
- package/lib/umd/index.js +3 -2
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +15 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1,71 +1,49 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let _univerjs_core = require("@univerjs/core");
|
|
3
|
-
let _univerjs_docs_ui = require("@univerjs/docs-ui");
|
|
4
|
-
let _univerjs_thread_comment = require("@univerjs/thread-comment");
|
|
5
|
-
let _univerjs_thread_comment_ui = require("@univerjs/thread-comment-ui");
|
|
6
3
|
let _univerjs_docs = require("@univerjs/docs");
|
|
4
|
+
let _univerjs_docs_thread_comment = require("@univerjs/docs-thread-comment");
|
|
5
|
+
let _univerjs_thread_comment_ui = require("@univerjs/thread-comment-ui");
|
|
6
|
+
let _univerjs_docs_ui = require("@univerjs/docs-ui");
|
|
7
|
+
let _univerjs_drawing = require("@univerjs/drawing");
|
|
7
8
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
9
|
+
let _univerjs_thread_comment = require("@univerjs/thread-comment");
|
|
8
10
|
let _univerjs_ui = require("@univerjs/ui");
|
|
9
11
|
let rxjs = require("rxjs");
|
|
12
|
+
let _univerjs_protocol = require("@univerjs/protocol");
|
|
10
13
|
let _univerjs_icons = require("@univerjs/icons");
|
|
11
14
|
let react = require("react");
|
|
12
15
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
16
|
|
|
14
|
-
//#region src/common/const.ts
|
|
15
|
-
/**
|
|
16
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
17
|
-
*
|
|
18
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
|
-
* you may not use this file except in compliance with the License.
|
|
20
|
-
* You may obtain a copy of the License at
|
|
21
|
-
*
|
|
22
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
-
*
|
|
24
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
-
* See the License for the specific language governing permissions and
|
|
28
|
-
* limitations under the License.
|
|
29
|
-
*/
|
|
30
|
-
const DOCS_THREAD_COMMENT_PANEL = "univer.doc.thread-comment-panel";
|
|
31
|
-
const PLUGIN_NAME = "DOC_THREAD_COMMENT_UI_PLUGIN";
|
|
32
|
-
const DEFAULT_DOC_SUBUNIT_ID = "default_doc";
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
17
|
//#region src/commands/commands/add-doc-comment.command.ts
|
|
18
|
+
/** Adds a document comment and activates it in the UI comment panel. */
|
|
36
19
|
const AddDocCommentComment = {
|
|
37
20
|
id: "docs.command.add-comment",
|
|
38
21
|
type: _univerjs_core.CommandType.COMMAND,
|
|
39
22
|
async handler(accessor, params) {
|
|
40
23
|
if (!params) return false;
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (doMutation) return (await (0, _univerjs_core.sequenceExecute)([
|
|
50
|
-
{
|
|
51
|
-
id: _univerjs_thread_comment.AddCommentMutation.id,
|
|
52
|
-
params: {
|
|
53
|
-
unitId,
|
|
54
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
55
|
-
comment
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
doMutation,
|
|
59
|
-
{
|
|
60
|
-
id: _univerjs_thread_comment_ui.SetActiveCommentOperation.id,
|
|
61
|
-
params: {
|
|
62
|
-
unitId,
|
|
63
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
64
|
-
commentId: comment.id
|
|
65
|
-
}
|
|
24
|
+
const prepared = await (0, _univerjs_docs_thread_comment.prepareDocTextRangeComment)(accessor, params);
|
|
25
|
+
if (!prepared) return false;
|
|
26
|
+
const activeOperation = {
|
|
27
|
+
id: _univerjs_thread_comment_ui.SetActiveCommentOperation.id,
|
|
28
|
+
params: {
|
|
29
|
+
unitId: prepared.comment.unitId,
|
|
30
|
+
subUnitId: prepared.comment.subUnitId,
|
|
31
|
+
commentId: prepared.comment.id
|
|
66
32
|
}
|
|
67
|
-
|
|
68
|
-
|
|
33
|
+
};
|
|
34
|
+
const decorationMutation = {
|
|
35
|
+
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
36
|
+
params: {
|
|
37
|
+
...prepared.decorationMutationParams,
|
|
38
|
+
textRanges: null,
|
|
39
|
+
noNeedSetTextRange: true
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return (await (0, _univerjs_core.sequenceExecute)([
|
|
43
|
+
prepared.commentMutation,
|
|
44
|
+
decorationMutation,
|
|
45
|
+
activeOperation
|
|
46
|
+
], accessor.get(_univerjs_core.ICommandService))).result;
|
|
69
47
|
}
|
|
70
48
|
};
|
|
71
49
|
|
|
@@ -87,6 +65,26 @@ const DeleteDocCommentComment = {
|
|
|
87
65
|
}
|
|
88
66
|
};
|
|
89
67
|
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/common/const.ts
|
|
70
|
+
/**
|
|
71
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
72
|
+
*
|
|
73
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
74
|
+
* you may not use this file except in compliance with the License.
|
|
75
|
+
* You may obtain a copy of the License at
|
|
76
|
+
*
|
|
77
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
78
|
+
*
|
|
79
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
80
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
81
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
82
|
+
* See the License for the specific language governing permissions and
|
|
83
|
+
* limitations under the License.
|
|
84
|
+
*/
|
|
85
|
+
const DOCS_THREAD_COMMENT_PANEL = "univer.doc.thread-comment-panel";
|
|
86
|
+
const PLUGIN_NAME = "DOC_THREAD_COMMENT_UI_PLUGIN";
|
|
87
|
+
|
|
90
88
|
//#endregion
|
|
91
89
|
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
92
90
|
function _typeof(o) {
|
|
@@ -244,7 +242,7 @@ const StartAddCommentOperation = {
|
|
|
244
242
|
const unitId = doc.getUnitId();
|
|
245
243
|
const dataStream = (((_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "").slice(textRange.startOffset, textRange.endOffset);
|
|
246
244
|
const text = _univerjs_core.BuildTextUtils.transform.getPlainText(dataStream);
|
|
247
|
-
const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
|
|
245
|
+
const subUnitId = _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID;
|
|
248
246
|
const commentId = "";
|
|
249
247
|
const comment = {
|
|
250
248
|
unitId,
|
|
@@ -269,14 +267,76 @@ const StartAddCommentOperation = {
|
|
|
269
267
|
return true;
|
|
270
268
|
}
|
|
271
269
|
};
|
|
270
|
+
const AddDocDrawingCommentOperation = {
|
|
271
|
+
id: "docs.operation.add-drawing-comment",
|
|
272
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
273
|
+
handler(accessor) {
|
|
274
|
+
const drawing = accessor.get(_univerjs_drawing.IDrawingManagerService).getFocusDrawings()[0];
|
|
275
|
+
const doc = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
276
|
+
if (!drawing || !doc || drawing.unitId !== doc.getUnitId()) return false;
|
|
277
|
+
accessor.get(_univerjs_thread_comment_ui.ThreadCommentDraftService).place({
|
|
278
|
+
unitId: drawing.unitId,
|
|
279
|
+
subUnitId: drawing.subUnitId,
|
|
280
|
+
anchor: {
|
|
281
|
+
kind: _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING,
|
|
282
|
+
pageId: drawing.subUnitId,
|
|
283
|
+
elementId: drawing.drawingId
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
const panelService = accessor.get(_univerjs_thread_comment_ui.ThreadCommentPanelService);
|
|
287
|
+
accessor.get(_univerjs_ui.ISidebarService).open({
|
|
288
|
+
header: { title: "docs-thread-comment-ui.panel.title" },
|
|
289
|
+
children: { label: DOCS_THREAD_COMMENT_PANEL },
|
|
290
|
+
width: 320,
|
|
291
|
+
onClose: () => panelService.setPanelVisible(false)
|
|
292
|
+
});
|
|
293
|
+
panelService.setPanelVisible(true);
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
272
297
|
|
|
273
298
|
//#endregion
|
|
274
299
|
//#region src/menu/menu.ts
|
|
300
|
+
/**
|
|
301
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
302
|
+
*
|
|
303
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
304
|
+
* you may not use this file except in compliance with the License.
|
|
305
|
+
* You may obtain a copy of the License at
|
|
306
|
+
*
|
|
307
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
308
|
+
*
|
|
309
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
310
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
311
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
312
|
+
* See the License for the specific language governing permissions and
|
|
313
|
+
* limitations under the License.
|
|
314
|
+
*/
|
|
315
|
+
function getCommentPermissionDisabled$(accessor) {
|
|
316
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
317
|
+
const permissionService = accessor.get(_univerjs_core.IPermissionService);
|
|
318
|
+
return (0, rxjs.combineLatest)([instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), permissionService.permissionPointUpdate$.pipe((0, rxjs.startWith)(void 0))]).pipe((0, rxjs.map)(([document]) => !document || !(0, _univerjs_docs.getDocumentPermissionValue)(permissionService, document.getUnitId(), document.getUnitId(), _univerjs_protocol.UnitAction.Comment)));
|
|
319
|
+
}
|
|
320
|
+
function AddDocDrawingCommentMenuItemFactory(accessor) {
|
|
321
|
+
return {
|
|
322
|
+
id: AddDocDrawingCommentOperation.id,
|
|
323
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
324
|
+
icon: "InsertCommentDoubleIcon",
|
|
325
|
+
title: "docs-thread-comment-ui.panel.addComment",
|
|
326
|
+
tooltip: "docs-thread-comment-ui.panel.addComment",
|
|
327
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC),
|
|
328
|
+
disabled$: getCommentPermissionDisabled$(accessor)
|
|
329
|
+
};
|
|
330
|
+
}
|
|
275
331
|
const shouldDisableAddComment = (accessor) => {
|
|
276
332
|
var _withCurrentTypeOfRen;
|
|
277
333
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
278
334
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
279
|
-
const
|
|
335
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
336
|
+
const permissionService = accessor.get(_univerjs_core.IPermissionService);
|
|
337
|
+
const document = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
338
|
+
if (!document || !(0, _univerjs_docs.getDocumentPermissionValue)(permissionService, document.getUnitId(), document.getUnitId(), _univerjs_protocol.UnitAction.Comment)) return true;
|
|
339
|
+
const skeleton = (_withCurrentTypeOfRen = (0, _univerjs_engine_render.withCurrentTypeOfRenderer)(_univerjs_core.UniverInstanceType.UNIVER_DOC, _univerjs_docs.DocSkeletonManagerService, instanceService, renderManagerService)) === null || _withCurrentTypeOfRen === void 0 ? void 0 : _withCurrentTypeOfRen.getSkeleton();
|
|
280
340
|
const editArea = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getViewModel().getEditArea();
|
|
281
341
|
if (editArea === _univerjs_engine_render.DocumentEditArea.FOOTER || editArea === _univerjs_engine_render.DocumentEditArea.HEADER) return true;
|
|
282
342
|
const range = docSelectionManagerService.getActiveTextRange();
|
|
@@ -287,18 +347,11 @@ function AddDocCommentMenuItemFactory(accessor) {
|
|
|
287
347
|
return {
|
|
288
348
|
id: StartAddCommentOperation.id,
|
|
289
349
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
290
|
-
icon: "
|
|
350
|
+
icon: "InsertCommentDoubleIcon",
|
|
291
351
|
title: "docs-thread-comment-ui.panel.addComment",
|
|
292
352
|
tooltip: "docs-thread-comment-ui.panel.addComment",
|
|
293
353
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC, void 0, _univerjs_core.SHEET_EDITOR_UNITS),
|
|
294
|
-
disabled$:
|
|
295
|
-
const observer = accessor.get(_univerjs_docs.DocSelectionManagerService).textSelection$.pipe((0, rxjs.debounceTime)(16)).subscribe(() => {
|
|
296
|
-
subscribe.next(shouldDisableAddComment(accessor));
|
|
297
|
-
});
|
|
298
|
-
return () => {
|
|
299
|
-
observer.unsubscribe();
|
|
300
|
-
};
|
|
301
|
-
})
|
|
354
|
+
disabled$: (0, rxjs.combineLatest)([accessor.get(_univerjs_docs.DocSelectionManagerService).textSelection$.pipe((0, rxjs.debounceTime)(16), (0, rxjs.map)(() => shouldDisableAddComment(accessor)), (0, rxjs.startWith)(shouldDisableAddComment(accessor))), getCommentPermissionDisabled$(accessor)]).pipe((0, rxjs.map)(([selectionDisabled, permissionDisabled]) => selectionDisabled || permissionDisabled))
|
|
302
355
|
};
|
|
303
356
|
}
|
|
304
357
|
function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
@@ -306,8 +359,8 @@ function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
|
306
359
|
id: ToggleCommentPanelOperation.id,
|
|
307
360
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
308
361
|
icon: "CommentIcon",
|
|
309
|
-
title: "docs-thread-comment-ui.panel.
|
|
310
|
-
tooltip: "docs-thread-comment-ui.panel.
|
|
362
|
+
title: "docs-thread-comment-ui.panel.openComments",
|
|
363
|
+
tooltip: "docs-thread-comment-ui.panel.openComments",
|
|
311
364
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
312
365
|
};
|
|
313
366
|
}
|
|
@@ -315,24 +368,48 @@ function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
|
315
368
|
//#endregion
|
|
316
369
|
//#region src/menu/schema.ts
|
|
317
370
|
const menuSchema = {
|
|
318
|
-
[_univerjs_ui.RibbonInsertGroup.MEDIA]: {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
371
|
+
[_univerjs_ui.RibbonInsertGroup.MEDIA]: {
|
|
372
|
+
[ToggleCommentPanelOperation.id]: {
|
|
373
|
+
order: 3,
|
|
374
|
+
gridLayout: {
|
|
375
|
+
row: 1,
|
|
376
|
+
column: 4,
|
|
377
|
+
showLabel: true
|
|
378
|
+
},
|
|
379
|
+
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
380
|
+
},
|
|
381
|
+
[StartAddCommentOperation.id]: {
|
|
382
|
+
order: 3.1,
|
|
383
|
+
gridLayout: {
|
|
384
|
+
row: 2,
|
|
385
|
+
column: 4,
|
|
386
|
+
showLabel: true
|
|
387
|
+
},
|
|
388
|
+
menuItemFactory: AddDocCommentMenuItemFactory
|
|
389
|
+
}
|
|
390
|
+
},
|
|
322
391
|
[_univerjs_docs_ui.FLOAT_TOOLBAR_MENU_POSITION]: { [StartAddCommentOperation.id]: {
|
|
323
392
|
order: 21,
|
|
324
393
|
menuItemFactory: AddDocCommentMenuItemFactory
|
|
325
394
|
} },
|
|
395
|
+
[_univerjs_ui.FloatingObjectToolbarPosition.DOC]: { [AddDocDrawingCommentOperation.id]: {
|
|
396
|
+
order: 10,
|
|
397
|
+
menuItemFactory: AddDocDrawingCommentMenuItemFactory
|
|
398
|
+
} },
|
|
326
399
|
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.DATA]: { [StartAddCommentOperation.id]: {
|
|
327
400
|
order: 1,
|
|
328
401
|
menuItemFactory: AddDocCommentMenuItemFactory
|
|
402
|
+
} } },
|
|
403
|
+
[_univerjs_ui.ContextMenuPosition.DRAWING]: { [_univerjs_ui.ContextMenuGroup.DATA]: { [AddDocDrawingCommentOperation.id]: {
|
|
404
|
+
order: 1,
|
|
405
|
+
menuItemFactory: AddDocDrawingCommentMenuItemFactory
|
|
329
406
|
} } }
|
|
330
407
|
};
|
|
331
408
|
|
|
332
409
|
//#endregion
|
|
333
410
|
//#region package.json
|
|
334
411
|
var name = "@univerjs/docs-thread-comment-ui";
|
|
335
|
-
var version = "1.0.0-
|
|
412
|
+
var version = "1.0.0-rc.0";
|
|
336
413
|
|
|
337
414
|
//#endregion
|
|
338
415
|
//#region src/config/config.ts
|
|
@@ -342,17 +419,44 @@ const defaultPluginConfig = {};
|
|
|
342
419
|
|
|
343
420
|
//#endregion
|
|
344
421
|
//#region src/views/DocThreadCommentPanel.tsx
|
|
422
|
+
function getDocCommentPanelSubUnitId(draft, unitId) {
|
|
423
|
+
return draft && draft.unitId === unitId ? draft.subUnitId : _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID;
|
|
424
|
+
}
|
|
345
425
|
const DocThreadCommentPanel = () => {
|
|
346
426
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
347
427
|
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
348
428
|
const doc = (0, _univerjs_ui.useObservable)((0, react.useMemo)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.filter)((doc) => !!doc && !(0, _univerjs_core.isInternalEditorID)(doc.getUnitId()))), [univerInstanceService]));
|
|
349
|
-
const
|
|
429
|
+
const draftService = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment_ui.ThreadCommentDraftService);
|
|
430
|
+
const drawingDraft = (0, _univerjs_ui.useObservable)(draftService.draft$, draftService.draft);
|
|
431
|
+
const subUnitId$ = (0, react.useMemo)(() => new rxjs.Observable((sub) => sub.next(getDocCommentPanelSubUnitId(drawingDraft, doc === null || doc === void 0 ? void 0 : doc.getUnitId()))), [doc, drawingDraft]);
|
|
350
432
|
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
351
433
|
const selectionChange$ = (0, react.useMemo)(() => docSelectionManagerService.textSelection$.pipe((0, rxjs.debounceTime)(16)), [docSelectionManagerService.textSelection$]);
|
|
352
|
-
const
|
|
434
|
+
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
435
|
+
const disableAddChange$ = (0, react.useMemo)(() => (0, rxjs.merge)(selectionChange$, permissionService.permissionPointUpdate$), [permissionService.permissionPointUpdate$, selectionChange$]);
|
|
436
|
+
const disableAdd = (0, _univerjs_ui.useObservable)(() => disableAddChange$.pipe((0, rxjs.map)(() => shouldDisableAddComment(injector))), shouldDisableAddComment(injector), false, [disableAddChange$, injector]);
|
|
353
437
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
438
|
+
const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
|
|
439
|
+
(0, _univerjs_ui.useObservable)(threadCommentModel.commentUpdate$);
|
|
354
440
|
const docCommentService = (0, _univerjs_ui.useDependency)(DocThreadCommentService);
|
|
355
|
-
const
|
|
441
|
+
const textTempComment = (0, _univerjs_ui.useObservable)(docCommentService.addingComment$);
|
|
442
|
+
const userManagerService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
|
|
443
|
+
const drawingTempComment = (drawingDraft === null || drawingDraft === void 0 ? void 0 : drawingDraft.anchor.kind) === _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING && drawingDraft.unitId === (doc === null || doc === void 0 ? void 0 : doc.getUnitId()) ? {
|
|
444
|
+
id: "",
|
|
445
|
+
threadId: "",
|
|
446
|
+
unitId: drawingDraft.unitId,
|
|
447
|
+
subUnitId: drawingDraft.subUnitId,
|
|
448
|
+
ref: (0, _univerjs_thread_comment.serializeThreadCommentAnchor)(drawingDraft.anchor),
|
|
449
|
+
dT: "",
|
|
450
|
+
personId: userManagerService.getCurrentUser().userID,
|
|
451
|
+
text: { dataStream: "\r\n" }
|
|
452
|
+
} : null;
|
|
453
|
+
const tempComment = drawingTempComment ?? textTempComment;
|
|
454
|
+
const drawingIds = new Set(Object.keys((doc === null || doc === void 0 ? void 0 : doc.getSnapshot().drawings) ?? {}));
|
|
455
|
+
const isDrawingComment = (comment) => {
|
|
456
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(comment.ref);
|
|
457
|
+
return (anchor === null || anchor === void 0 ? void 0 : anchor.kind) === _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING || comment.ref.startsWith("#") && drawingIds.has(comment.ref.slice(1));
|
|
458
|
+
};
|
|
459
|
+
const drawingCommentIds = doc ? threadCommentModel.getUnit(doc.getUnitId()).filter((thread) => isDrawingComment(thread.root)).map((thread) => thread.root.id) : [];
|
|
356
460
|
const [commentIds, setCommentIds] = (0, react.useState)([]);
|
|
357
461
|
(0, react.useEffect)(() => {
|
|
358
462
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -389,31 +493,36 @@ const DocThreadCommentPanel = () => {
|
|
|
389
493
|
getSubUnitName: () => "",
|
|
390
494
|
disableAdd,
|
|
391
495
|
tempComment,
|
|
392
|
-
onAddComment: (comment) => {
|
|
496
|
+
onAddComment: async (comment) => {
|
|
497
|
+
if (drawingTempComment && !comment.parentId) return true;
|
|
393
498
|
if (!comment.parentId) {
|
|
394
499
|
const params = {
|
|
395
500
|
unitId,
|
|
396
|
-
range:
|
|
501
|
+
range: textTempComment,
|
|
397
502
|
comment
|
|
398
503
|
};
|
|
399
|
-
commandService.executeCommand(AddDocCommentComment.id, params);
|
|
504
|
+
if (!await commandService.executeCommand(AddDocCommentComment.id, params)) throw new Error("Failed to add document comment.");
|
|
400
505
|
docCommentService.endAdd();
|
|
401
506
|
return false;
|
|
402
507
|
}
|
|
403
508
|
return true;
|
|
404
509
|
},
|
|
405
|
-
|
|
510
|
+
onAfterDeleteComment: async (comment) => {
|
|
406
511
|
if (!comment.parentId) {
|
|
512
|
+
if (isDrawingComment(comment)) return;
|
|
407
513
|
const params = {
|
|
408
514
|
unitId,
|
|
409
515
|
commentId: comment.id
|
|
410
516
|
};
|
|
411
|
-
commandService.executeCommand(DeleteDocCommentComment.id, params);
|
|
412
|
-
return false;
|
|
517
|
+
await commandService.executeCommand(DeleteDocCommentComment.id, params);
|
|
413
518
|
}
|
|
414
|
-
return true;
|
|
415
519
|
},
|
|
416
|
-
showComments: commentIds
|
|
520
|
+
showComments: [...commentIds, ...drawingCommentIds],
|
|
521
|
+
onTempCommentClose: () => draftService.cancel(),
|
|
522
|
+
formatRef: (comment) => {
|
|
523
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(comment.ref);
|
|
524
|
+
return (anchor === null || anchor === void 0 ? void 0 : anchor.kind) === _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING ? `#${anchor.elementId}` : comment.ref;
|
|
525
|
+
}
|
|
417
526
|
});
|
|
418
527
|
};
|
|
419
528
|
|
|
@@ -448,7 +557,10 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
448
557
|
});
|
|
449
558
|
}
|
|
450
559
|
_registerIcons() {
|
|
451
|
-
this.disposeWithMe(this._iconManager.register({
|
|
560
|
+
this.disposeWithMe(this._iconManager.register({
|
|
561
|
+
CommentIcon: _univerjs_icons.CommentIcon,
|
|
562
|
+
InsertCommentDoubleIcon: _univerjs_icons.InsertCommentDoubleIcon
|
|
563
|
+
}));
|
|
452
564
|
}
|
|
453
565
|
};
|
|
454
566
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
@@ -479,19 +591,12 @@ let DocThreadCommentSelectionController = class DocThreadCommentSelectionControl
|
|
|
479
591
|
lastSelection = primary;
|
|
480
592
|
if (primary && doc) {
|
|
481
593
|
const { startOffset, endOffset, collapsed } = primary;
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
var _doc$getBody;
|
|
485
|
-
customRange = (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 || (_doc$getBody = _doc$getBody.customDecorations) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1);
|
|
486
|
-
} else {
|
|
487
|
-
var _doc$getBody2;
|
|
488
|
-
customRange = (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 || (_doc$getBody2 = _doc$getBody2.customDecorations) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1);
|
|
489
|
-
}
|
|
594
|
+
const selectionEnd = collapsed ? startOffset : endOffset - 1;
|
|
595
|
+
const customRange = this._findActiveCommentDecoration(doc, unitId, startOffset, selectionEnd);
|
|
490
596
|
if (customRange) {
|
|
491
|
-
|
|
492
|
-
if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
597
|
+
this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
493
598
|
unitId,
|
|
494
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
599
|
+
subUnitId: _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID,
|
|
495
600
|
commentId: customRange.id
|
|
496
601
|
} });
|
|
497
602
|
return;
|
|
@@ -500,20 +605,27 @@ let DocThreadCommentSelectionController = class DocThreadCommentSelectionControl
|
|
|
500
605
|
if (!this._threadCommentPanelService.activeCommentId) return;
|
|
501
606
|
const addingComment = this._docThreadCommentService.addingComment;
|
|
502
607
|
const activeComment = this._threadCommentPanelService.activeCommentId;
|
|
503
|
-
if (addingComment && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.unitId) === addingComment.unitId && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.subUnitId) ===
|
|
608
|
+
if (addingComment && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.unitId) === addingComment.unitId && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.subUnitId) === _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.commentId) === addingComment.id) return;
|
|
504
609
|
this._commandService.executeCommand(_univerjs_thread_comment_ui.SetActiveCommentOperation.id);
|
|
505
610
|
}
|
|
506
611
|
}));
|
|
507
612
|
}
|
|
613
|
+
_findActiveCommentDecoration(doc, unitId, selectionStart, selectionEnd) {
|
|
614
|
+
var _doc$getBody;
|
|
615
|
+
return [...((_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.customDecorations) ?? []].reverse().filter((decoration) => decoration.type === _univerjs_core.CustomDecorationType.COMMENT && decoration.startIndex <= selectionStart && decoration.endIndex >= selectionEnd).sort((left, right) => left.endIndex - left.startIndex - (right.endIndex - right.startIndex)).find((decoration) => {
|
|
616
|
+
const comment = this._threadCommentModel.getComment(unitId, _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID, decoration.id);
|
|
617
|
+
return comment && !comment.resolved;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
508
620
|
_initActiveCommandChange() {
|
|
509
621
|
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
|
|
510
622
|
var _this$_docThreadComme;
|
|
511
623
|
if (activeComment) {
|
|
512
624
|
const doc = this._univerInstanceService.getUnit(activeComment.unitId);
|
|
513
625
|
if (doc) {
|
|
514
|
-
var _this$_renderManagerS, _doc$
|
|
626
|
+
var _this$_renderManagerS, _doc$getBody2;
|
|
515
627
|
const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(activeComment.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs_ui.DocBackScrollRenderController);
|
|
516
|
-
const customRange = (_doc$
|
|
628
|
+
const customRange = (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 || (_doc$getBody2 = _doc$getBody2.customDecorations) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.find((range) => range.id === activeComment.commentId);
|
|
517
629
|
if (customRange && backScrollController) backScrollController.scrollToRange({
|
|
518
630
|
startOffset: customRange.startIndex,
|
|
519
631
|
endOffset: customRange.endIndex,
|
|
@@ -536,50 +648,156 @@ DocThreadCommentSelectionController = __decorate([
|
|
|
536
648
|
|
|
537
649
|
//#endregion
|
|
538
650
|
//#region src/controllers/render-controllers/render.controller.ts
|
|
651
|
+
const DOC_COMMENT_DRAWING_OVERLAY_KEY = "doc-thread-comment-drawing-overlay";
|
|
652
|
+
const DOC_COMMENT_DRAWING_OVERLAY_LAYER_INDEX = 10100;
|
|
539
653
|
let DocThreadCommentRenderController = class DocThreadCommentRenderController extends _univerjs_core.Disposable {
|
|
540
|
-
constructor(_context, _docInterceptorService, _threadCommentPanelService,
|
|
654
|
+
constructor(_context, _docInterceptorService, _threadCommentPanelService, _univerInstanceService, _threadCommentModel, _commandService, _drawingManagerService, _themeService) {
|
|
541
655
|
super();
|
|
542
656
|
this._context = _context;
|
|
543
657
|
this._docInterceptorService = _docInterceptorService;
|
|
544
658
|
this._threadCommentPanelService = _threadCommentPanelService;
|
|
545
|
-
this._docRenderController = _docRenderController;
|
|
546
659
|
this._univerInstanceService = _univerInstanceService;
|
|
547
660
|
this._threadCommentModel = _threadCommentModel;
|
|
548
661
|
this._commandService = _commandService;
|
|
662
|
+
this._drawingManagerService = _drawingManagerService;
|
|
663
|
+
this._themeService = _themeService;
|
|
664
|
+
_defineProperty(this, "_drawingOverlay", void 0);
|
|
665
|
+
_defineProperty(this, "_drawingCommentSubUnits", /* @__PURE__ */ new Map());
|
|
666
|
+
this._drawingOverlay = new _univerjs_thread_comment_ui.ThreadCommentCanvasOverlay(DOC_COMMENT_DRAWING_OVERLAY_KEY, {
|
|
667
|
+
...this._getDrawingOverlayColors(),
|
|
668
|
+
zoomRatio: 1,
|
|
669
|
+
markers: [],
|
|
670
|
+
underlines: []
|
|
671
|
+
});
|
|
672
|
+
this._context.scene.addObject(this._drawingOverlay, DOC_COMMENT_DRAWING_OVERLAY_LAYER_INDEX);
|
|
549
673
|
this._interceptorViewModel();
|
|
550
674
|
this._initReRender();
|
|
551
675
|
this._initSyncComments();
|
|
676
|
+
this._initDrawingOverlay();
|
|
552
677
|
}
|
|
553
678
|
_initReRender() {
|
|
554
|
-
this.
|
|
679
|
+
[this._threadCommentPanelService.activeCommentId$, this._threadCommentPanelService.hoveredCommentId$].forEach((observable) => this.disposeWithMe(observable.pipe((0, rxjs.skip)(1), (0, rxjs.startWith)(void 0), (0, rxjs.pairwise)()).subscribe(([previous, current]) => {
|
|
555
680
|
var _this$_univerInstance;
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
681
|
+
const currentUnitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
|
|
682
|
+
if ((/* @__PURE__ */ new Set([
|
|
683
|
+
previous === null || previous === void 0 ? void 0 : previous.unitId,
|
|
684
|
+
current === null || current === void 0 ? void 0 : current.unitId,
|
|
685
|
+
currentUnitId
|
|
686
|
+
])).has(this._context.unitId)) {
|
|
687
|
+
var _this$_context$mainCo;
|
|
688
|
+
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty(true);
|
|
559
689
|
}
|
|
560
|
-
|
|
561
|
-
if (unitId) this._docRenderController.reRender(unitId);
|
|
562
|
-
}));
|
|
690
|
+
})));
|
|
563
691
|
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
|
|
564
|
-
if (update.type === "resolve"
|
|
692
|
+
if (update.type === "resolve" && update.unitId === this._context.unitId) {
|
|
693
|
+
var _this$_context$mainCo2;
|
|
694
|
+
(_this$_context$mainCo2 = this._context.mainComponent) === null || _this$_context$mainCo2 === void 0 || _this$_context$mainCo2.makeDirty(true);
|
|
695
|
+
}
|
|
696
|
+
if (update.unitId === this._context.unitId) this._syncDrawingOverlay();
|
|
565
697
|
}));
|
|
566
698
|
}
|
|
699
|
+
_initDrawingOverlay() {
|
|
700
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._drawingOverlay.onPointerDown$.subscribeEvent((_event, state) => {
|
|
701
|
+
const commentId = this._drawingOverlay.hitCommentId;
|
|
702
|
+
const subUnitId = commentId && this._drawingCommentSubUnits.get(commentId);
|
|
703
|
+
if (!commentId || !subUnitId) return;
|
|
704
|
+
state.stopPropagation();
|
|
705
|
+
this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
706
|
+
unitId: this._context.unitId,
|
|
707
|
+
subUnitId,
|
|
708
|
+
commentId,
|
|
709
|
+
trigger: "doc-canvas"
|
|
710
|
+
} });
|
|
711
|
+
})));
|
|
712
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._context.engine.onTransformChange$.subscribeEvent(() => this._syncDrawingOverlay())));
|
|
713
|
+
[this._threadCommentPanelService.activeCommentId$, this._threadCommentPanelService.hoveredCommentId$].forEach((observable) => this.disposeWithMe(observable.subscribe(() => this._syncDrawingOverlay())));
|
|
714
|
+
[
|
|
715
|
+
this._drawingManagerService.add$,
|
|
716
|
+
this._drawingManagerService.update$,
|
|
717
|
+
this._drawingManagerService.remove$
|
|
718
|
+
].forEach((observable) => this.disposeWithMe(observable.subscribe((drawings) => {
|
|
719
|
+
if (drawings.some((drawing) => drawing.unitId === this._context.unitId)) this._syncDrawingOverlay();
|
|
720
|
+
})));
|
|
721
|
+
this.disposeWithMe(this._themeService.currentTheme$.subscribe(() => this._syncDrawingOverlay()));
|
|
722
|
+
this._syncDrawingOverlay();
|
|
723
|
+
}
|
|
724
|
+
_syncDrawingOverlay() {
|
|
725
|
+
const underlines = /* @__PURE__ */ new Map();
|
|
726
|
+
this._drawingCommentSubUnits.clear();
|
|
727
|
+
this._threadCommentModel.query({
|
|
728
|
+
unitIds: [this._context.unitId],
|
|
729
|
+
anchorKinds: [_univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING],
|
|
730
|
+
resolved: false
|
|
731
|
+
}).forEach(({ root, subUnitId }) => {
|
|
732
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(root.ref);
|
|
733
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING) return;
|
|
734
|
+
const outline = this._getDrawingOutline(anchor.pageId ?? subUnitId, anchor.elementId);
|
|
735
|
+
if (!outline) return;
|
|
736
|
+
this._drawingCommentSubUnits.set(root.id, subUnitId);
|
|
737
|
+
underlines.set(`${anchor.pageId ?? subUnitId}\0${anchor.elementId}`, {
|
|
738
|
+
commentId: root.id,
|
|
739
|
+
left: outline.left,
|
|
740
|
+
top: outline.top + outline.height + 2,
|
|
741
|
+
width: outline.width
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
const focusedCommentIds = [];
|
|
745
|
+
const focusOutlines = /* @__PURE__ */ new Map();
|
|
746
|
+
[this._threadCommentPanelService.activeCommentId, this._threadCommentPanelService.hoveredCommentId].forEach((target) => {
|
|
747
|
+
if (!target || target.unitId !== this._context.unitId) return;
|
|
748
|
+
const comment = this._threadCommentModel.getComment(target.unitId, target.subUnitId, target.commentId);
|
|
749
|
+
const anchor = comment && (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(comment.ref);
|
|
750
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING) return;
|
|
751
|
+
focusedCommentIds.push(target.commentId);
|
|
752
|
+
const outline = this._getDrawingOutline(anchor.pageId ?? target.subUnitId, anchor.elementId);
|
|
753
|
+
if (outline) focusOutlines.set(`${anchor.pageId ?? target.subUnitId}\0${anchor.elementId}`, outline);
|
|
754
|
+
});
|
|
755
|
+
this._drawingOverlay.updateState({
|
|
756
|
+
...this._getDrawingOverlayColors(),
|
|
757
|
+
markers: [],
|
|
758
|
+
underlines: Array.from(underlines.values()),
|
|
759
|
+
focusedCommentIds,
|
|
760
|
+
focusOutlines: Array.from(focusOutlines.values())
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
_getDrawingOutline(subUnitId, drawingId) {
|
|
764
|
+
var _this$_context$scene$, _this$_context$scene;
|
|
765
|
+
const objectKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
|
|
766
|
+
unitId: this._context.unitId,
|
|
767
|
+
subUnitId,
|
|
768
|
+
drawingId
|
|
769
|
+
});
|
|
770
|
+
const object = ((_this$_context$scene$ = (_this$_context$scene = this._context.scene).getObjectIncludeInGroup) === null || _this$_context$scene$ === void 0 ? void 0 : _this$_context$scene$.call(_this$_context$scene, objectKey)) ?? this._context.scene.getObject(objectKey);
|
|
771
|
+
if (!object) return null;
|
|
772
|
+
const bounds = object.getRealBound();
|
|
773
|
+
return {
|
|
774
|
+
left: bounds.left,
|
|
775
|
+
top: bounds.top,
|
|
776
|
+
width: bounds.width,
|
|
777
|
+
height: bounds.height
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
_getDrawingOverlayColors() {
|
|
781
|
+
return {
|
|
782
|
+
accentColor: this._themeService.getColorFromTheme("yellow.400"),
|
|
783
|
+
foregroundColor: this._themeService.getColorFromTheme("gray.900"),
|
|
784
|
+
outlineColor: this._themeService.getColorFromTheme("white")
|
|
785
|
+
};
|
|
786
|
+
}
|
|
567
787
|
_interceptorViewModel() {
|
|
568
788
|
this._docInterceptorService.intercept(_univerjs_docs.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION, { handler: (data, pos, next) => {
|
|
569
789
|
if (!data) return next(data);
|
|
570
|
-
const { unitId
|
|
571
|
-
const
|
|
572
|
-
const
|
|
573
|
-
const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, data.id);
|
|
790
|
+
const { unitId } = pos;
|
|
791
|
+
const focusedComments = [this._threadCommentPanelService.activeCommentId, this._threadCommentPanelService.hoveredCommentId];
|
|
792
|
+
const comment = this._threadCommentModel.getComment(unitId, _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID, data.id);
|
|
574
793
|
if (!comment) return next({
|
|
575
794
|
...data,
|
|
576
795
|
show: false
|
|
577
796
|
});
|
|
578
|
-
const
|
|
579
|
-
const isActive = commentUnitID === unitId && data.id === commentId;
|
|
797
|
+
const isActive = focusedComments.some((focusedComment) => (focusedComment === null || focusedComment === void 0 ? void 0 : focusedComment.unitId) === unitId && focusedComment.subUnitId === _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID && focusedComment.commentId === data.id);
|
|
580
798
|
return next({
|
|
581
799
|
...data,
|
|
582
|
-
active: isActive
|
|
800
|
+
active: isActive,
|
|
583
801
|
show: !comment.resolved
|
|
584
802
|
});
|
|
585
803
|
} });
|
|
@@ -587,9 +805,9 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
|
|
|
587
805
|
_initSyncComments() {
|
|
588
806
|
var _this$_context$unit$g;
|
|
589
807
|
const unitId = this._context.unit.getUnitId();
|
|
590
|
-
const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
|
|
808
|
+
const subUnitId = _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID;
|
|
591
809
|
const threadIds = ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.customDecorations) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.filter((i) => i.type === _univerjs_core.CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
|
|
592
|
-
threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),
|
|
810
|
+
threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID, threadIds);
|
|
593
811
|
let prevThreadIds = threadIds.sort();
|
|
594
812
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
595
813
|
if (commandInfo.id === _univerjs_docs.RichTextEditingMutation.id) {
|
|
@@ -613,10 +831,11 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
|
|
|
613
831
|
DocThreadCommentRenderController = __decorate([
|
|
614
832
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocInterceptorService)),
|
|
615
833
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_thread_comment_ui.ThreadCommentPanelService)),
|
|
616
|
-
__decorateParam(3,
|
|
617
|
-
__decorateParam(4, _univerjs_core.
|
|
618
|
-
__decorateParam(5,
|
|
619
|
-
__decorateParam(6,
|
|
834
|
+
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
835
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_thread_comment.ThreadCommentModel)),
|
|
836
|
+
__decorateParam(5, _univerjs_core.ICommandService),
|
|
837
|
+
__decorateParam(6, _univerjs_drawing.IDrawingManagerService),
|
|
838
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
620
839
|
], DocThreadCommentRenderController);
|
|
621
840
|
|
|
622
841
|
//#endregion
|
|
@@ -646,6 +865,7 @@ let DocThreadCommentUIController = class DocThreadCommentUIController extends _u
|
|
|
646
865
|
}
|
|
647
866
|
_initCommands() {
|
|
648
867
|
[
|
|
868
|
+
AddDocDrawingCommentOperation,
|
|
649
869
|
AddDocCommentComment,
|
|
650
870
|
DeleteDocCommentComment,
|
|
651
871
|
ShowCommentPanelOperation,
|
|
@@ -664,6 +884,11 @@ DocThreadCommentUIController = __decorate([__decorateParam(0, _univerjs_core.ICo
|
|
|
664
884
|
|
|
665
885
|
//#endregion
|
|
666
886
|
//#region src/plugin.ts
|
|
887
|
+
const STARTING_DEPENDENCIES = [
|
|
888
|
+
[DocThreadCommentUIController],
|
|
889
|
+
[DocThreadCommentSelectionController],
|
|
890
|
+
[DocThreadCommentService]
|
|
891
|
+
];
|
|
667
892
|
let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin extends _univerjs_core.Plugin {
|
|
668
893
|
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
669
894
|
super();
|
|
@@ -678,11 +903,7 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
678
903
|
onStarting() {
|
|
679
904
|
this._injector.add([ComponentsController]);
|
|
680
905
|
this._injector.get(ComponentsController);
|
|
681
|
-
|
|
682
|
-
[DocThreadCommentUIController],
|
|
683
|
-
[DocThreadCommentSelectionController],
|
|
684
|
-
[DocThreadCommentService]
|
|
685
|
-
].forEach((dep) => {
|
|
906
|
+
STARTING_DEPENDENCIES.forEach((dep) => {
|
|
686
907
|
this._injector.add(dep);
|
|
687
908
|
});
|
|
688
909
|
}
|
|
@@ -692,9 +913,7 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
692
913
|
this._injector.get(DocThreadCommentUIController);
|
|
693
914
|
}
|
|
694
915
|
_initRenderModule() {
|
|
695
|
-
[DocThreadCommentRenderController]
|
|
696
|
-
this._renderManagerSrv.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_DOC, dep);
|
|
697
|
-
});
|
|
916
|
+
this._renderManagerSrv.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_DOC, [DocThreadCommentRenderController]);
|
|
698
917
|
}
|
|
699
918
|
};
|
|
700
919
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
|
|
@@ -702,7 +921,7 @@ _defineProperty(UniverDocsThreadCommentUIPlugin, "packageName", name);
|
|
|
702
921
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "version", version);
|
|
703
922
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
704
923
|
UniverDocsThreadCommentUIPlugin = __decorate([
|
|
705
|
-
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin),
|
|
924
|
+
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_docs_thread_comment.UniverDocsThreadCommentPlugin, _univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_drawing.UniverDrawingPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin),
|
|
706
925
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
707
926
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
708
927
|
__decorateParam(3, _univerjs_core.IConfigService)
|