@univerjs/docs-thread-comment-ui 1.0.0-insiders.20260813-7c9aa50 → 1.0.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 +402 -132
- package/lib/cjs/locale/ar-SA.js +2 -2
- package/lib/cjs/locale/ca-ES.js +2 -2
- package/lib/cjs/locale/de-DE.js +2 -2
- package/lib/cjs/locale/en-US.js +2 -2
- package/lib/cjs/locale/es-ES.js +2 -2
- package/lib/cjs/locale/fa-IR.js +2 -2
- package/lib/cjs/locale/fr-FR.js +2 -2
- package/lib/cjs/locale/id-ID.js +2 -2
- package/lib/cjs/locale/it-IT.js +2 -2
- package/lib/cjs/locale/ja-JP.js +2 -2
- package/lib/cjs/locale/ko-KR.js +2 -2
- package/lib/cjs/locale/pl-PL.js +2 -2
- package/lib/cjs/locale/pt-BR.js +2 -2
- package/lib/cjs/locale/ru-RU.js +2 -2
- package/lib/cjs/locale/sk-SK.js +2 -2
- package/lib/cjs/locale/vi-VN.js +2 -2
- package/lib/cjs/locale/zh-CN.js +2 -2
- package/lib/cjs/locale/zh-HK.js +2 -2
- package/lib/cjs/locale/zh-TW.js +2 -2
- package/lib/es/index.js +398 -134
- 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 +398 -134
- 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/doc-thread-comment-ui.controller.d.ts +26 -0
- package/lib/types/controllers/render-controllers/render.controller.d.ts +11 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +1 -0
- package/lib/types/menu/menu.d.ts +30 -6
- package/lib/types/mobile-plugin.d.ts +32 -0
- package/lib/types/views/DocThreadCommentPanel.d.ts +4 -0
- package/lib/types/views/doc-thread-comment-panel/index.d.ts +16 -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/es/index.js
CHANGED
|
@@ -1,70 +1,48 @@
|
|
|
1
|
-
import { BuildTextUtils, CommandType, CustomDecorationType, DependentOn, Disposable, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, Plugin, SHEET_EDITOR_UNITS, UniverInstanceType, UserManagerService, isInternalEditorID, merge, sequenceExecute } from "@univerjs/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SetActiveCommentOperation, ThreadCommentPanel, ThreadCommentPanelService, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
5
|
-
import {
|
|
1
|
+
import { BuildTextUtils, CommandType, CustomDecorationType, DependentOn, Disposable, ICommandService, IConfigService, IPermissionService, IUniverInstanceService, Inject, Injector, Plugin, SHEET_EDITOR_UNITS, ThemeService, UniverInstanceType, UserManagerService, isInternalEditorID, merge, sequenceExecute, toDisposable } from "@univerjs/core";
|
|
2
|
+
import { DOC_INTERCEPTOR_POINT, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin, getDocumentPermissionValue } from "@univerjs/docs";
|
|
3
|
+
import { DEFAULT_DOC_SUBUNIT_ID, UniverDocsThreadCommentPlugin, prepareDocTextRangeComment } from "@univerjs/docs-thread-comment";
|
|
4
|
+
import { SetActiveCommentOperation, ThreadCommentCanvasOverlay, ThreadCommentDraftService, ThreadCommentPanel, ThreadCommentPanelService, UniverThreadCommentMobileUIPlugin, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
5
|
+
import { DocBackScrollRenderController, DocSelectionRenderService, FLOAT_TOOLBAR_MENU_POSITION, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, deleteCustomDecorationFactory } from "@univerjs/docs-ui";
|
|
6
|
+
import { IDrawingManagerService, UniverDrawingPlugin, getDrawingShapeKeyByDrawingSearch } from "@univerjs/drawing";
|
|
6
7
|
import { DocumentEditArea, IRenderManagerService, UniverRenderEnginePlugin, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { ThreadCommentAnchorKind, ThreadCommentModel, UniverThreadCommentPlugin, deserializeThreadCommentAnchor, getDT, serializeThreadCommentAnchor } from "@univerjs/thread-comment";
|
|
9
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, FloatingObjectToolbarPosition, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
10
|
+
import { BehaviorSubject, Observable, combineLatest, debounceTime, filter, map, merge as merge$1, pairwise, skip, startWith } from "rxjs";
|
|
11
|
+
import { UnitAction } from "@univerjs/protocol";
|
|
12
|
+
import { CommentIcon, InsertCommentDoubleIcon } from "@univerjs/icons";
|
|
10
13
|
import { useEffect, useMemo, useState } from "react";
|
|
11
14
|
import { jsx } from "react/jsx-runtime";
|
|
12
15
|
|
|
13
|
-
//#region src/common/const.ts
|
|
14
|
-
/**
|
|
15
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
16
|
-
*
|
|
17
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
-
* you may not use this file except in compliance with the License.
|
|
19
|
-
* You may obtain a copy of the License at
|
|
20
|
-
*
|
|
21
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
-
* See the License for the specific language governing permissions and
|
|
27
|
-
* limitations under the License.
|
|
28
|
-
*/
|
|
29
|
-
const DOCS_THREAD_COMMENT_PANEL = "univer.doc.thread-comment-panel";
|
|
30
|
-
const PLUGIN_NAME = "DOC_THREAD_COMMENT_UI_PLUGIN";
|
|
31
|
-
const DEFAULT_DOC_SUBUNIT_ID = "default_doc";
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
16
|
//#region src/commands/commands/add-doc-comment.command.ts
|
|
17
|
+
/** Adds a document comment and activates it in the UI comment panel. */
|
|
35
18
|
const AddDocCommentComment = {
|
|
36
19
|
id: "docs.command.add-comment",
|
|
37
20
|
type: CommandType.COMMAND,
|
|
38
21
|
async handler(accessor, params) {
|
|
39
22
|
if (!params) return false;
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (doMutation) return (await sequenceExecute([
|
|
49
|
-
{
|
|
50
|
-
id: AddCommentMutation.id,
|
|
51
|
-
params: {
|
|
52
|
-
unitId,
|
|
53
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
54
|
-
comment
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
doMutation,
|
|
58
|
-
{
|
|
59
|
-
id: SetActiveCommentOperation.id,
|
|
60
|
-
params: {
|
|
61
|
-
unitId,
|
|
62
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
63
|
-
commentId: comment.id
|
|
64
|
-
}
|
|
23
|
+
const prepared = await prepareDocTextRangeComment(accessor, params);
|
|
24
|
+
if (!prepared) return false;
|
|
25
|
+
const activeOperation = {
|
|
26
|
+
id: SetActiveCommentOperation.id,
|
|
27
|
+
params: {
|
|
28
|
+
unitId: prepared.comment.unitId,
|
|
29
|
+
subUnitId: prepared.comment.subUnitId,
|
|
30
|
+
commentId: prepared.comment.id
|
|
65
31
|
}
|
|
66
|
-
|
|
67
|
-
|
|
32
|
+
};
|
|
33
|
+
const decorationMutation = {
|
|
34
|
+
id: RichTextEditingMutation.id,
|
|
35
|
+
params: {
|
|
36
|
+
...prepared.decorationMutationParams,
|
|
37
|
+
textRanges: null,
|
|
38
|
+
noNeedSetTextRange: true
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return (await sequenceExecute([
|
|
42
|
+
prepared.commentMutation,
|
|
43
|
+
decorationMutation,
|
|
44
|
+
activeOperation
|
|
45
|
+
], accessor.get(ICommandService))).result;
|
|
68
46
|
}
|
|
69
47
|
};
|
|
70
48
|
|
|
@@ -87,7 +65,27 @@ const DeleteDocCommentComment = {
|
|
|
87
65
|
};
|
|
88
66
|
|
|
89
67
|
//#endregion
|
|
90
|
-
//#region
|
|
68
|
+
//#region src/common/const.ts
|
|
69
|
+
/**
|
|
70
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
71
|
+
*
|
|
72
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
73
|
+
* you may not use this file except in compliance with the License.
|
|
74
|
+
* You may obtain a copy of the License at
|
|
75
|
+
*
|
|
76
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
77
|
+
*
|
|
78
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
79
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
80
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
81
|
+
* See the License for the specific language governing permissions and
|
|
82
|
+
* limitations under the License.
|
|
83
|
+
*/
|
|
84
|
+
const DOCS_THREAD_COMMENT_PANEL = "univer.doc.thread-comment-panel";
|
|
85
|
+
const PLUGIN_NAME = "DOC_THREAD_COMMENT_UI_PLUGIN";
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
91
89
|
function _typeof(o) {
|
|
92
90
|
"@babel/helpers - typeof";
|
|
93
91
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -98,7 +96,7 @@ function _typeof(o) {
|
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
//#endregion
|
|
101
|
-
//#region \0@oxc-project+runtime@0.
|
|
99
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
102
100
|
function toPrimitive(t, r) {
|
|
103
101
|
if ("object" != _typeof(t) || !t) return t;
|
|
104
102
|
var e = t[Symbol.toPrimitive];
|
|
@@ -111,14 +109,14 @@ function toPrimitive(t, r) {
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
//#endregion
|
|
114
|
-
//#region \0@oxc-project+runtime@0.
|
|
112
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
115
113
|
function toPropertyKey(t) {
|
|
116
114
|
var i = toPrimitive(t, "string");
|
|
117
115
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
//#endregion
|
|
121
|
-
//#region \0@oxc-project+runtime@0.
|
|
119
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
122
120
|
function _defineProperty(e, r, t) {
|
|
123
121
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
124
122
|
value: t,
|
|
@@ -129,7 +127,7 @@ function _defineProperty(e, r, t) {
|
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
//#endregion
|
|
132
|
-
//#region \0@oxc-project+runtime@0.
|
|
130
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
133
131
|
function __decorateParam(paramIndex, decorator) {
|
|
134
132
|
return function(target, key) {
|
|
135
133
|
decorator(target, key, paramIndex);
|
|
@@ -137,7 +135,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
//#endregion
|
|
140
|
-
//#region \0@oxc-project+runtime@0.
|
|
138
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
141
139
|
function __decorate(decorators, target, key, desc) {
|
|
142
140
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
143
141
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -268,14 +266,76 @@ const StartAddCommentOperation = {
|
|
|
268
266
|
return true;
|
|
269
267
|
}
|
|
270
268
|
};
|
|
269
|
+
const AddDocDrawingCommentOperation = {
|
|
270
|
+
id: "docs.operation.add-drawing-comment",
|
|
271
|
+
type: CommandType.OPERATION,
|
|
272
|
+
handler(accessor) {
|
|
273
|
+
const drawing = accessor.get(IDrawingManagerService).getFocusDrawings()[0];
|
|
274
|
+
const doc = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
275
|
+
if (!drawing || !doc || drawing.unitId !== doc.getUnitId()) return false;
|
|
276
|
+
accessor.get(ThreadCommentDraftService).place({
|
|
277
|
+
unitId: drawing.unitId,
|
|
278
|
+
subUnitId: drawing.subUnitId,
|
|
279
|
+
anchor: {
|
|
280
|
+
kind: ThreadCommentAnchorKind.DOC_DRAWING,
|
|
281
|
+
pageId: drawing.subUnitId,
|
|
282
|
+
elementId: drawing.drawingId
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
const panelService = accessor.get(ThreadCommentPanelService);
|
|
286
|
+
accessor.get(ISidebarService).open({
|
|
287
|
+
header: { title: "docs-thread-comment-ui.panel.title" },
|
|
288
|
+
children: { label: DOCS_THREAD_COMMENT_PANEL },
|
|
289
|
+
width: 320,
|
|
290
|
+
onClose: () => panelService.setPanelVisible(false)
|
|
291
|
+
});
|
|
292
|
+
panelService.setPanelVisible(true);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
271
296
|
|
|
272
297
|
//#endregion
|
|
273
298
|
//#region src/menu/menu.ts
|
|
299
|
+
/**
|
|
300
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
301
|
+
*
|
|
302
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
303
|
+
* you may not use this file except in compliance with the License.
|
|
304
|
+
* You may obtain a copy of the License at
|
|
305
|
+
*
|
|
306
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
307
|
+
*
|
|
308
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
309
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
310
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
311
|
+
* See the License for the specific language governing permissions and
|
|
312
|
+
* limitations under the License.
|
|
313
|
+
*/
|
|
314
|
+
function getCommentPermissionDisabled$(accessor) {
|
|
315
|
+
const instanceService = accessor.get(IUniverInstanceService);
|
|
316
|
+
const permissionService = accessor.get(IPermissionService);
|
|
317
|
+
return combineLatest([instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), permissionService.permissionPointUpdate$.pipe(startWith(void 0))]).pipe(map(([document]) => !document || !getDocumentPermissionValue(permissionService, document.getUnitId(), document.getUnitId(), UnitAction.Comment)));
|
|
318
|
+
}
|
|
319
|
+
function AddDocDrawingCommentMenuItemFactory(accessor) {
|
|
320
|
+
return {
|
|
321
|
+
id: AddDocDrawingCommentOperation.id,
|
|
322
|
+
type: MenuItemType.BUTTON,
|
|
323
|
+
icon: "InsertCommentDoubleIcon",
|
|
324
|
+
title: "docs-thread-comment-ui.panel.addComment",
|
|
325
|
+
tooltip: "docs-thread-comment-ui.panel.addComment",
|
|
326
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
|
|
327
|
+
disabled$: getCommentPermissionDisabled$(accessor)
|
|
328
|
+
};
|
|
329
|
+
}
|
|
274
330
|
const shouldDisableAddComment = (accessor) => {
|
|
275
331
|
var _withCurrentTypeOfRen;
|
|
276
332
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
277
333
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
|
|
278
|
-
const
|
|
334
|
+
const instanceService = accessor.get(IUniverInstanceService);
|
|
335
|
+
const permissionService = accessor.get(IPermissionService);
|
|
336
|
+
const document = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
337
|
+
if (!document || !getDocumentPermissionValue(permissionService, document.getUnitId(), document.getUnitId(), UnitAction.Comment)) return true;
|
|
338
|
+
const skeleton = (_withCurrentTypeOfRen = withCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, DocSkeletonManagerService, instanceService, renderManagerService)) === null || _withCurrentTypeOfRen === void 0 ? void 0 : _withCurrentTypeOfRen.getSkeleton();
|
|
279
339
|
const editArea = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getViewModel().getEditArea();
|
|
280
340
|
if (editArea === DocumentEditArea.FOOTER || editArea === DocumentEditArea.HEADER) return true;
|
|
281
341
|
const range = docSelectionManagerService.getActiveTextRange();
|
|
@@ -286,18 +346,11 @@ function AddDocCommentMenuItemFactory(accessor) {
|
|
|
286
346
|
return {
|
|
287
347
|
id: StartAddCommentOperation.id,
|
|
288
348
|
type: MenuItemType.BUTTON,
|
|
289
|
-
icon: "
|
|
349
|
+
icon: "InsertCommentDoubleIcon",
|
|
290
350
|
title: "docs-thread-comment-ui.panel.addComment",
|
|
291
351
|
tooltip: "docs-thread-comment-ui.panel.addComment",
|
|
292
352
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, void 0, SHEET_EDITOR_UNITS),
|
|
293
|
-
disabled$:
|
|
294
|
-
const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
|
|
295
|
-
subscribe.next(shouldDisableAddComment(accessor));
|
|
296
|
-
});
|
|
297
|
-
return () => {
|
|
298
|
-
observer.unsubscribe();
|
|
299
|
-
};
|
|
300
|
-
})
|
|
353
|
+
disabled$: combineLatest([accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16), map(() => shouldDisableAddComment(accessor)), startWith(shouldDisableAddComment(accessor))), getCommentPermissionDisabled$(accessor)]).pipe(map(([selectionDisabled, permissionDisabled]) => selectionDisabled || permissionDisabled))
|
|
301
354
|
};
|
|
302
355
|
}
|
|
303
356
|
function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
@@ -305,8 +358,8 @@ function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
|
305
358
|
id: ToggleCommentPanelOperation.id,
|
|
306
359
|
type: MenuItemType.BUTTON,
|
|
307
360
|
icon: "CommentIcon",
|
|
308
|
-
title: "docs-thread-comment-ui.panel.
|
|
309
|
-
tooltip: "docs-thread-comment-ui.panel.
|
|
361
|
+
title: "docs-thread-comment-ui.panel.openComments",
|
|
362
|
+
tooltip: "docs-thread-comment-ui.panel.openComments",
|
|
310
363
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
311
364
|
};
|
|
312
365
|
}
|
|
@@ -314,24 +367,48 @@ function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
|
314
367
|
//#endregion
|
|
315
368
|
//#region src/menu/schema.ts
|
|
316
369
|
const menuSchema = {
|
|
317
|
-
[RibbonInsertGroup.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
370
|
+
[RibbonInsertGroup.OTHERS]: {
|
|
371
|
+
[ToggleCommentPanelOperation.id]: {
|
|
372
|
+
order: 0,
|
|
373
|
+
gridLayout: {
|
|
374
|
+
row: 1,
|
|
375
|
+
column: 1,
|
|
376
|
+
showLabel: true
|
|
377
|
+
},
|
|
378
|
+
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
379
|
+
},
|
|
380
|
+
[StartAddCommentOperation.id]: {
|
|
381
|
+
order: .1,
|
|
382
|
+
gridLayout: {
|
|
383
|
+
row: 2,
|
|
384
|
+
column: 1,
|
|
385
|
+
showLabel: true
|
|
386
|
+
},
|
|
387
|
+
menuItemFactory: AddDocCommentMenuItemFactory
|
|
388
|
+
}
|
|
389
|
+
},
|
|
321
390
|
[FLOAT_TOOLBAR_MENU_POSITION]: { [StartAddCommentOperation.id]: {
|
|
322
391
|
order: 21,
|
|
323
392
|
menuItemFactory: AddDocCommentMenuItemFactory
|
|
324
393
|
} },
|
|
394
|
+
[FloatingObjectToolbarPosition.DOC]: { [AddDocDrawingCommentOperation.id]: {
|
|
395
|
+
order: 10,
|
|
396
|
+
menuItemFactory: AddDocDrawingCommentMenuItemFactory
|
|
397
|
+
} },
|
|
325
398
|
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.DATA]: { [StartAddCommentOperation.id]: {
|
|
326
399
|
order: 1,
|
|
327
400
|
menuItemFactory: AddDocCommentMenuItemFactory
|
|
401
|
+
} } },
|
|
402
|
+
[ContextMenuPosition.DRAWING]: { [ContextMenuGroup.DATA]: { [AddDocDrawingCommentOperation.id]: {
|
|
403
|
+
order: 1,
|
|
404
|
+
menuItemFactory: AddDocDrawingCommentMenuItemFactory
|
|
328
405
|
} } }
|
|
329
406
|
};
|
|
330
407
|
|
|
331
408
|
//#endregion
|
|
332
409
|
//#region package.json
|
|
333
410
|
var name = "@univerjs/docs-thread-comment-ui";
|
|
334
|
-
var version = "1.0.0
|
|
411
|
+
var version = "1.0.0";
|
|
335
412
|
|
|
336
413
|
//#endregion
|
|
337
414
|
//#region src/config/config.ts
|
|
@@ -341,17 +418,45 @@ const defaultPluginConfig = {};
|
|
|
341
418
|
|
|
342
419
|
//#endregion
|
|
343
420
|
//#region src/views/DocThreadCommentPanel.tsx
|
|
421
|
+
function getDocCommentPanelSubUnitId(draft, unitId) {
|
|
422
|
+
return draft && draft.unitId === unitId ? draft.subUnitId : DEFAULT_DOC_SUBUNIT_ID;
|
|
423
|
+
}
|
|
344
424
|
const DocThreadCommentPanel = () => {
|
|
345
425
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
346
426
|
const injector = useDependency(Injector);
|
|
347
|
-
const doc =
|
|
348
|
-
const
|
|
427
|
+
const doc$ = useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(filter((doc) => !!doc && !isInternalEditorID(doc.getUnitId()))), [univerInstanceService]);
|
|
428
|
+
const doc = useObservable(doc$);
|
|
429
|
+
const draftService = useDependency(ThreadCommentDraftService);
|
|
430
|
+
const drawingDraft = useObservable(draftService.draft$, draftService.draft);
|
|
431
|
+
const subUnitId$ = useMemo(() => new Observable((sub) => sub.next(getDocCommentPanelSubUnitId(drawingDraft, doc === null || doc === void 0 ? void 0 : doc.getUnitId()))), [doc, drawingDraft]);
|
|
349
432
|
const docSelectionManagerService = useDependency(DocSelectionManagerService);
|
|
350
433
|
const selectionChange$ = useMemo(() => docSelectionManagerService.textSelection$.pipe(debounceTime(16)), [docSelectionManagerService.textSelection$]);
|
|
351
|
-
const
|
|
434
|
+
const permissionService = useDependency(IPermissionService);
|
|
435
|
+
const disableAddChange$ = useMemo(() => merge$1(selectionChange$, permissionService.permissionPointUpdate$), [permissionService.permissionPointUpdate$, selectionChange$]);
|
|
436
|
+
const disableAdd = useObservable(() => disableAddChange$.pipe(map(() => shouldDisableAddComment(injector))), shouldDisableAddComment(injector), false, [disableAddChange$, injector]);
|
|
352
437
|
const commandService = useDependency(ICommandService);
|
|
438
|
+
const threadCommentModel = useDependency(ThreadCommentModel);
|
|
439
|
+
useObservable(threadCommentModel.commentUpdate$);
|
|
353
440
|
const docCommentService = useDependency(DocThreadCommentService);
|
|
354
|
-
const
|
|
441
|
+
const textTempComment = useObservable(docCommentService.addingComment$);
|
|
442
|
+
const userManagerService = useDependency(UserManagerService);
|
|
443
|
+
const drawingTempComment = (drawingDraft === null || drawingDraft === void 0 ? void 0 : drawingDraft.anchor.kind) === 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: 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 = deserializeThreadCommentAnchor(comment.ref);
|
|
457
|
+
return (anchor === null || anchor === void 0 ? void 0 : anchor.kind) === 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) : [];
|
|
355
460
|
const [commentIds, setCommentIds] = useState([]);
|
|
356
461
|
useEffect(() => {
|
|
357
462
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -388,31 +493,36 @@ const DocThreadCommentPanel = () => {
|
|
|
388
493
|
getSubUnitName: () => "",
|
|
389
494
|
disableAdd,
|
|
390
495
|
tempComment,
|
|
391
|
-
onAddComment: (comment) => {
|
|
496
|
+
onAddComment: async (comment) => {
|
|
497
|
+
if (drawingTempComment && !comment.parentId) return true;
|
|
392
498
|
if (!comment.parentId) {
|
|
393
499
|
const params = {
|
|
394
500
|
unitId,
|
|
395
|
-
range:
|
|
501
|
+
range: textTempComment,
|
|
396
502
|
comment
|
|
397
503
|
};
|
|
398
|
-
commandService.executeCommand(AddDocCommentComment.id, params);
|
|
504
|
+
if (!await commandService.executeCommand(AddDocCommentComment.id, params)) throw new Error("Failed to add document comment.");
|
|
399
505
|
docCommentService.endAdd();
|
|
400
506
|
return false;
|
|
401
507
|
}
|
|
402
508
|
return true;
|
|
403
509
|
},
|
|
404
|
-
|
|
510
|
+
onAfterDeleteComment: async (comment) => {
|
|
405
511
|
if (!comment.parentId) {
|
|
512
|
+
if (isDrawingComment(comment)) return;
|
|
406
513
|
const params = {
|
|
407
514
|
unitId,
|
|
408
515
|
commentId: comment.id
|
|
409
516
|
};
|
|
410
|
-
commandService.executeCommand(DeleteDocCommentComment.id, params);
|
|
411
|
-
return false;
|
|
517
|
+
await commandService.executeCommand(DeleteDocCommentComment.id, params);
|
|
412
518
|
}
|
|
413
|
-
return true;
|
|
414
519
|
},
|
|
415
|
-
showComments: commentIds
|
|
520
|
+
showComments: [...commentIds, ...drawingCommentIds],
|
|
521
|
+
onTempCommentClose: () => draftService.cancel(),
|
|
522
|
+
formatRef: (comment) => {
|
|
523
|
+
const anchor = deserializeThreadCommentAnchor(comment.ref);
|
|
524
|
+
return (anchor === null || anchor === void 0 ? void 0 : anchor.kind) === ThreadCommentAnchorKind.DOC_DRAWING ? `#${anchor.elementId}` : comment.ref;
|
|
525
|
+
}
|
|
416
526
|
});
|
|
417
527
|
};
|
|
418
528
|
|
|
@@ -447,7 +557,10 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
447
557
|
});
|
|
448
558
|
}
|
|
449
559
|
_registerIcons() {
|
|
450
|
-
this.disposeWithMe(this._iconManager.register({
|
|
560
|
+
this.disposeWithMe(this._iconManager.register({
|
|
561
|
+
CommentIcon,
|
|
562
|
+
InsertCommentDoubleIcon
|
|
563
|
+
}));
|
|
451
564
|
}
|
|
452
565
|
};
|
|
453
566
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
@@ -478,17 +591,10 @@ let DocThreadCommentSelectionController = class DocThreadCommentSelectionControl
|
|
|
478
591
|
lastSelection = primary;
|
|
479
592
|
if (primary && doc) {
|
|
480
593
|
const { startOffset, endOffset, collapsed } = primary;
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
var _doc$getBody;
|
|
484
|
-
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);
|
|
485
|
-
} else {
|
|
486
|
-
var _doc$getBody2;
|
|
487
|
-
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);
|
|
488
|
-
}
|
|
594
|
+
const selectionEnd = collapsed ? startOffset : endOffset - 1;
|
|
595
|
+
const customRange = this._findActiveCommentDecoration(doc, unitId, startOffset, selectionEnd);
|
|
489
596
|
if (customRange) {
|
|
490
|
-
|
|
491
|
-
if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
597
|
+
this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
492
598
|
unitId,
|
|
493
599
|
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
494
600
|
commentId: customRange.id
|
|
@@ -499,20 +605,27 @@ let DocThreadCommentSelectionController = class DocThreadCommentSelectionControl
|
|
|
499
605
|
if (!this._threadCommentPanelService.activeCommentId) return;
|
|
500
606
|
const addingComment = this._docThreadCommentService.addingComment;
|
|
501
607
|
const activeComment = this._threadCommentPanelService.activeCommentId;
|
|
502
|
-
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) === DEFAULT_DOC_SUBUNIT_ID && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.commentId) === addingComment.id) return;
|
|
503
609
|
this._commandService.executeCommand(SetActiveCommentOperation.id);
|
|
504
610
|
}
|
|
505
611
|
}));
|
|
506
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 === 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, DEFAULT_DOC_SUBUNIT_ID, decoration.id);
|
|
617
|
+
return comment && !comment.resolved;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
507
620
|
_initActiveCommandChange() {
|
|
508
621
|
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
|
|
509
622
|
var _this$_docThreadComme;
|
|
510
623
|
if (activeComment) {
|
|
511
624
|
const doc = this._univerInstanceService.getUnit(activeComment.unitId);
|
|
512
625
|
if (doc) {
|
|
513
|
-
var _this$_renderManagerS, _doc$
|
|
626
|
+
var _this$_renderManagerS, _doc$getBody2;
|
|
514
627
|
const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(activeComment.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocBackScrollRenderController);
|
|
515
|
-
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);
|
|
516
629
|
if (customRange && backScrollController) backScrollController.scrollToRange({
|
|
517
630
|
startOffset: customRange.startIndex,
|
|
518
631
|
endOffset: customRange.endIndex,
|
|
@@ -535,50 +648,156 @@ DocThreadCommentSelectionController = __decorate([
|
|
|
535
648
|
|
|
536
649
|
//#endregion
|
|
537
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;
|
|
538
653
|
let DocThreadCommentRenderController = class DocThreadCommentRenderController extends Disposable {
|
|
539
|
-
constructor(_context, _docInterceptorService, _threadCommentPanelService,
|
|
654
|
+
constructor(_context, _docInterceptorService, _threadCommentPanelService, _univerInstanceService, _threadCommentModel, _commandService, _drawingManagerService, _themeService) {
|
|
540
655
|
super();
|
|
541
656
|
this._context = _context;
|
|
542
657
|
this._docInterceptorService = _docInterceptorService;
|
|
543
658
|
this._threadCommentPanelService = _threadCommentPanelService;
|
|
544
|
-
this._docRenderController = _docRenderController;
|
|
545
659
|
this._univerInstanceService = _univerInstanceService;
|
|
546
660
|
this._threadCommentModel = _threadCommentModel;
|
|
547
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 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);
|
|
548
673
|
this._interceptorViewModel();
|
|
549
674
|
this._initReRender();
|
|
550
675
|
this._initSyncComments();
|
|
676
|
+
this._initDrawingOverlay();
|
|
551
677
|
}
|
|
552
678
|
_initReRender() {
|
|
553
|
-
this.
|
|
679
|
+
[this._threadCommentPanelService.activeCommentId$, this._threadCommentPanelService.hoveredCommentId$].forEach((observable) => this.disposeWithMe(observable.pipe(skip(1), startWith(void 0), pairwise()).subscribe(([previous, current]) => {
|
|
554
680
|
var _this$_univerInstance;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
681
|
+
const currentUnitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(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);
|
|
558
689
|
}
|
|
559
|
-
|
|
560
|
-
if (unitId) this._docRenderController.reRender(unitId);
|
|
561
|
-
}));
|
|
690
|
+
})));
|
|
562
691
|
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
|
|
563
|
-
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();
|
|
564
697
|
}));
|
|
565
698
|
}
|
|
699
|
+
_initDrawingOverlay() {
|
|
700
|
+
this.disposeWithMe(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(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: [ThreadCommentAnchorKind.DOC_DRAWING],
|
|
730
|
+
resolved: false
|
|
731
|
+
}).forEach(({ root, subUnitId }) => {
|
|
732
|
+
const anchor = deserializeThreadCommentAnchor(root.ref);
|
|
733
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== 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 && deserializeThreadCommentAnchor(comment.ref);
|
|
750
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== 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 = 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
|
+
}
|
|
566
787
|
_interceptorViewModel() {
|
|
567
788
|
this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION, { handler: (data, pos, next) => {
|
|
568
789
|
if (!data) return next(data);
|
|
569
|
-
const { unitId
|
|
570
|
-
const
|
|
571
|
-
const activeCustomDecoration = customDecorations.find((i) => i.id === commentId);
|
|
790
|
+
const { unitId } = pos;
|
|
791
|
+
const focusedComments = [this._threadCommentPanelService.activeCommentId, this._threadCommentPanelService.hoveredCommentId];
|
|
572
792
|
const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, data.id);
|
|
573
793
|
if (!comment) return next({
|
|
574
794
|
...data,
|
|
575
795
|
show: false
|
|
576
796
|
});
|
|
577
|
-
const
|
|
578
|
-
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 === DEFAULT_DOC_SUBUNIT_ID && focusedComment.commentId === data.id);
|
|
579
798
|
return next({
|
|
580
799
|
...data,
|
|
581
|
-
active: isActive
|
|
800
|
+
active: isActive,
|
|
582
801
|
show: !comment.resolved
|
|
583
802
|
});
|
|
584
803
|
} });
|
|
@@ -588,7 +807,7 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
|
|
|
588
807
|
const unitId = this._context.unit.getUnitId();
|
|
589
808
|
const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
|
|
590
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 === CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
|
|
591
|
-
threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),
|
|
810
|
+
threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), DEFAULT_DOC_SUBUNIT_ID, threadIds);
|
|
592
811
|
let prevThreadIds = threadIds.sort();
|
|
593
812
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
594
813
|
if (commandInfo.id === RichTextEditingMutation.id) {
|
|
@@ -612,10 +831,11 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
|
|
|
612
831
|
DocThreadCommentRenderController = __decorate([
|
|
613
832
|
__decorateParam(1, Inject(DocInterceptorService)),
|
|
614
833
|
__decorateParam(2, Inject(ThreadCommentPanelService)),
|
|
615
|
-
__decorateParam(3,
|
|
616
|
-
__decorateParam(4,
|
|
617
|
-
__decorateParam(5,
|
|
618
|
-
__decorateParam(6,
|
|
834
|
+
__decorateParam(3, IUniverInstanceService),
|
|
835
|
+
__decorateParam(4, Inject(ThreadCommentModel)),
|
|
836
|
+
__decorateParam(5, ICommandService),
|
|
837
|
+
__decorateParam(6, IDrawingManagerService),
|
|
838
|
+
__decorateParam(7, Inject(ThemeService))
|
|
619
839
|
], DocThreadCommentRenderController);
|
|
620
840
|
|
|
621
841
|
//#endregion
|
|
@@ -645,6 +865,7 @@ let DocThreadCommentUIController = class DocThreadCommentUIController extends Di
|
|
|
645
865
|
}
|
|
646
866
|
_initCommands() {
|
|
647
867
|
[
|
|
868
|
+
AddDocDrawingCommentOperation,
|
|
648
869
|
AddDocCommentComment,
|
|
649
870
|
DeleteDocCommentComment,
|
|
650
871
|
ShowCommentPanelOperation,
|
|
@@ -662,8 +883,8 @@ let DocThreadCommentUIController = class DocThreadCommentUIController extends Di
|
|
|
662
883
|
DocThreadCommentUIController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IMenuManagerService)], DocThreadCommentUIController);
|
|
663
884
|
|
|
664
885
|
//#endregion
|
|
665
|
-
//#region src/plugin.ts
|
|
666
|
-
let
|
|
886
|
+
//#region src/mobile-plugin.ts
|
|
887
|
+
let UniverDocsThreadCommentMobileUIPlugin = class UniverDocsThreadCommentMobileUIPlugin extends Plugin {
|
|
667
888
|
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
668
889
|
super();
|
|
669
890
|
this._config = _config;
|
|
@@ -675,15 +896,15 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
675
896
|
this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
676
897
|
}
|
|
677
898
|
onStarting() {
|
|
678
|
-
this._injector.add([ComponentsController]);
|
|
679
|
-
this._injector.get(ComponentsController);
|
|
680
899
|
[
|
|
900
|
+
[ComponentsController],
|
|
681
901
|
[DocThreadCommentUIController],
|
|
682
902
|
[DocThreadCommentSelectionController],
|
|
683
903
|
[DocThreadCommentService]
|
|
684
904
|
].forEach((dep) => {
|
|
685
905
|
this._injector.add(dep);
|
|
686
906
|
});
|
|
907
|
+
this._injector.get(ComponentsController);
|
|
687
908
|
}
|
|
688
909
|
onRendered() {
|
|
689
910
|
this._initRenderModule();
|
|
@@ -691,21 +912,64 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
691
912
|
this._injector.get(DocThreadCommentUIController);
|
|
692
913
|
}
|
|
693
914
|
_initRenderModule() {
|
|
694
|
-
[DocThreadCommentRenderController]
|
|
695
|
-
|
|
915
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocThreadCommentRenderController]);
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "pluginName", PLUGIN_NAME);
|
|
919
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "packageName", name);
|
|
920
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "version", version);
|
|
921
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
922
|
+
UniverDocsThreadCommentMobileUIPlugin = __decorate([
|
|
923
|
+
DependentOn(UniverDocsPlugin, UniverDocsThreadCommentPlugin, UniverThreadCommentPlugin, UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsMobileUIPlugin, UniverThreadCommentMobileUIPlugin),
|
|
924
|
+
__decorateParam(1, Inject(Injector)),
|
|
925
|
+
__decorateParam(2, IRenderManagerService),
|
|
926
|
+
__decorateParam(3, IConfigService)
|
|
927
|
+
], UniverDocsThreadCommentMobileUIPlugin);
|
|
928
|
+
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region src/plugin.ts
|
|
931
|
+
const STARTING_DEPENDENCIES = [
|
|
932
|
+
[DocThreadCommentUIController],
|
|
933
|
+
[DocThreadCommentSelectionController],
|
|
934
|
+
[DocThreadCommentService]
|
|
935
|
+
];
|
|
936
|
+
let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin extends Plugin {
|
|
937
|
+
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
938
|
+
super();
|
|
939
|
+
this._config = _config;
|
|
940
|
+
this._injector = _injector;
|
|
941
|
+
this._renderManagerSrv = _renderManagerSrv;
|
|
942
|
+
this._configService = _configService;
|
|
943
|
+
const { menu, ...rest } = merge({}, defaultPluginConfig, this._config);
|
|
944
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
945
|
+
this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
946
|
+
}
|
|
947
|
+
onStarting() {
|
|
948
|
+
this._injector.add([ComponentsController]);
|
|
949
|
+
this._injector.get(ComponentsController);
|
|
950
|
+
STARTING_DEPENDENCIES.forEach((dep) => {
|
|
951
|
+
this._injector.add(dep);
|
|
696
952
|
});
|
|
697
953
|
}
|
|
954
|
+
onRendered() {
|
|
955
|
+
this._initRenderModule();
|
|
956
|
+
this._injector.get(DocThreadCommentSelectionController);
|
|
957
|
+
this._injector.get(DocThreadCommentUIController);
|
|
958
|
+
}
|
|
959
|
+
_initRenderModule() {
|
|
960
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocThreadCommentRenderController]);
|
|
961
|
+
}
|
|
698
962
|
};
|
|
699
963
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
|
|
700
964
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "packageName", name);
|
|
701
965
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "version", version);
|
|
702
966
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
703
967
|
UniverDocsThreadCommentUIPlugin = __decorate([
|
|
704
|
-
DependentOn(UniverDocsPlugin, UniverThreadCommentPlugin, UniverRenderEnginePlugin, UniverDocsUIPlugin, UniverThreadCommentUIPlugin),
|
|
968
|
+
DependentOn(UniverDocsPlugin, UniverDocsThreadCommentPlugin, UniverThreadCommentPlugin, UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsUIPlugin, UniverThreadCommentUIPlugin),
|
|
705
969
|
__decorateParam(1, Inject(Injector)),
|
|
706
970
|
__decorateParam(2, IRenderManagerService),
|
|
707
971
|
__decorateParam(3, IConfigService)
|
|
708
972
|
], UniverDocsThreadCommentUIPlugin);
|
|
709
973
|
|
|
710
974
|
//#endregion
|
|
711
|
-
export { AddDocCommentComment, DeleteDocCommentComment, menuSchema as DocsThreadCommentUIMenuSchema, ShowCommentPanelOperation, StartAddCommentOperation, UniverDocsThreadCommentUIPlugin };
|
|
975
|
+
export { AddDocCommentComment, DeleteDocCommentComment, menuSchema as DocsThreadCommentUIMenuSchema, ShowCommentPanelOperation, StartAddCommentOperation, UniverDocsThreadCommentMobileUIPlugin, UniverDocsThreadCommentUIPlugin };
|