@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/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
|
|
|
@@ -88,7 +66,27 @@ const DeleteDocCommentComment = {
|
|
|
88
66
|
};
|
|
89
67
|
|
|
90
68
|
//#endregion
|
|
91
|
-
//#region
|
|
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
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
92
90
|
function _typeof(o) {
|
|
93
91
|
"@babel/helpers - typeof";
|
|
94
92
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -99,7 +97,7 @@ function _typeof(o) {
|
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
//#endregion
|
|
102
|
-
//#region \0@oxc-project+runtime@0.
|
|
100
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
103
101
|
function toPrimitive(t, r) {
|
|
104
102
|
if ("object" != _typeof(t) || !t) return t;
|
|
105
103
|
var e = t[Symbol.toPrimitive];
|
|
@@ -112,14 +110,14 @@ function toPrimitive(t, r) {
|
|
|
112
110
|
}
|
|
113
111
|
|
|
114
112
|
//#endregion
|
|
115
|
-
//#region \0@oxc-project+runtime@0.
|
|
113
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
116
114
|
function toPropertyKey(t) {
|
|
117
115
|
var i = toPrimitive(t, "string");
|
|
118
116
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
//#endregion
|
|
122
|
-
//#region \0@oxc-project+runtime@0.
|
|
120
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
123
121
|
function _defineProperty(e, r, t) {
|
|
124
122
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
125
123
|
value: t,
|
|
@@ -130,7 +128,7 @@ function _defineProperty(e, r, t) {
|
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
//#endregion
|
|
133
|
-
//#region \0@oxc-project+runtime@0.
|
|
131
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
134
132
|
function __decorateParam(paramIndex, decorator) {
|
|
135
133
|
return function(target, key) {
|
|
136
134
|
decorator(target, key, paramIndex);
|
|
@@ -138,7 +136,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
//#endregion
|
|
141
|
-
//#region \0@oxc-project+runtime@0.
|
|
139
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
142
140
|
function __decorate(decorators, target, key, desc) {
|
|
143
141
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
144
142
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -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.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
371
|
+
[_univerjs_ui.RibbonInsertGroup.OTHERS]: {
|
|
372
|
+
[ToggleCommentPanelOperation.id]: {
|
|
373
|
+
order: 0,
|
|
374
|
+
gridLayout: {
|
|
375
|
+
row: 1,
|
|
376
|
+
column: 1,
|
|
377
|
+
showLabel: true
|
|
378
|
+
},
|
|
379
|
+
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
380
|
+
},
|
|
381
|
+
[StartAddCommentOperation.id]: {
|
|
382
|
+
order: .1,
|
|
383
|
+
gridLayout: {
|
|
384
|
+
row: 2,
|
|
385
|
+
column: 1,
|
|
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";
|
|
336
413
|
|
|
337
414
|
//#endregion
|
|
338
415
|
//#region src/config/config.ts
|
|
@@ -342,17 +419,45 @@ 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
|
-
const doc = (0,
|
|
349
|
-
const
|
|
428
|
+
const doc$ = (0, react.useMemo)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.filter)((doc) => !!doc && !(0, _univerjs_core.isInternalEditorID)(doc.getUnitId()))), [univerInstanceService]);
|
|
429
|
+
const doc = (0, _univerjs_ui.useObservable)(doc$);
|
|
430
|
+
const draftService = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment_ui.ThreadCommentDraftService);
|
|
431
|
+
const drawingDraft = (0, _univerjs_ui.useObservable)(draftService.draft$, draftService.draft);
|
|
432
|
+
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
433
|
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
351
434
|
const selectionChange$ = (0, react.useMemo)(() => docSelectionManagerService.textSelection$.pipe((0, rxjs.debounceTime)(16)), [docSelectionManagerService.textSelection$]);
|
|
352
|
-
const
|
|
435
|
+
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
436
|
+
const disableAddChange$ = (0, react.useMemo)(() => (0, rxjs.merge)(selectionChange$, permissionService.permissionPointUpdate$), [permissionService.permissionPointUpdate$, selectionChange$]);
|
|
437
|
+
const disableAdd = (0, _univerjs_ui.useObservable)(() => disableAddChange$.pipe((0, rxjs.map)(() => shouldDisableAddComment(injector))), shouldDisableAddComment(injector), false, [disableAddChange$, injector]);
|
|
353
438
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
439
|
+
const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
|
|
440
|
+
(0, _univerjs_ui.useObservable)(threadCommentModel.commentUpdate$);
|
|
354
441
|
const docCommentService = (0, _univerjs_ui.useDependency)(DocThreadCommentService);
|
|
355
|
-
const
|
|
442
|
+
const textTempComment = (0, _univerjs_ui.useObservable)(docCommentService.addingComment$);
|
|
443
|
+
const userManagerService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
|
|
444
|
+
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()) ? {
|
|
445
|
+
id: "",
|
|
446
|
+
threadId: "",
|
|
447
|
+
unitId: drawingDraft.unitId,
|
|
448
|
+
subUnitId: drawingDraft.subUnitId,
|
|
449
|
+
ref: (0, _univerjs_thread_comment.serializeThreadCommentAnchor)(drawingDraft.anchor),
|
|
450
|
+
dT: "",
|
|
451
|
+
personId: userManagerService.getCurrentUser().userID,
|
|
452
|
+
text: { dataStream: "\r\n" }
|
|
453
|
+
} : null;
|
|
454
|
+
const tempComment = drawingTempComment ?? textTempComment;
|
|
455
|
+
const drawingIds = new Set(Object.keys((doc === null || doc === void 0 ? void 0 : doc.getSnapshot().drawings) ?? {}));
|
|
456
|
+
const isDrawingComment = (comment) => {
|
|
457
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(comment.ref);
|
|
458
|
+
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));
|
|
459
|
+
};
|
|
460
|
+
const drawingCommentIds = doc ? threadCommentModel.getUnit(doc.getUnitId()).filter((thread) => isDrawingComment(thread.root)).map((thread) => thread.root.id) : [];
|
|
356
461
|
const [commentIds, setCommentIds] = (0, react.useState)([]);
|
|
357
462
|
(0, react.useEffect)(() => {
|
|
358
463
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -389,31 +494,36 @@ const DocThreadCommentPanel = () => {
|
|
|
389
494
|
getSubUnitName: () => "",
|
|
390
495
|
disableAdd,
|
|
391
496
|
tempComment,
|
|
392
|
-
onAddComment: (comment) => {
|
|
497
|
+
onAddComment: async (comment) => {
|
|
498
|
+
if (drawingTempComment && !comment.parentId) return true;
|
|
393
499
|
if (!comment.parentId) {
|
|
394
500
|
const params = {
|
|
395
501
|
unitId,
|
|
396
|
-
range:
|
|
502
|
+
range: textTempComment,
|
|
397
503
|
comment
|
|
398
504
|
};
|
|
399
|
-
commandService.executeCommand(AddDocCommentComment.id, params);
|
|
505
|
+
if (!await commandService.executeCommand(AddDocCommentComment.id, params)) throw new Error("Failed to add document comment.");
|
|
400
506
|
docCommentService.endAdd();
|
|
401
507
|
return false;
|
|
402
508
|
}
|
|
403
509
|
return true;
|
|
404
510
|
},
|
|
405
|
-
|
|
511
|
+
onAfterDeleteComment: async (comment) => {
|
|
406
512
|
if (!comment.parentId) {
|
|
513
|
+
if (isDrawingComment(comment)) return;
|
|
407
514
|
const params = {
|
|
408
515
|
unitId,
|
|
409
516
|
commentId: comment.id
|
|
410
517
|
};
|
|
411
|
-
commandService.executeCommand(DeleteDocCommentComment.id, params);
|
|
412
|
-
return false;
|
|
518
|
+
await commandService.executeCommand(DeleteDocCommentComment.id, params);
|
|
413
519
|
}
|
|
414
|
-
return true;
|
|
415
520
|
},
|
|
416
|
-
showComments: commentIds
|
|
521
|
+
showComments: [...commentIds, ...drawingCommentIds],
|
|
522
|
+
onTempCommentClose: () => draftService.cancel(),
|
|
523
|
+
formatRef: (comment) => {
|
|
524
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(comment.ref);
|
|
525
|
+
return (anchor === null || anchor === void 0 ? void 0 : anchor.kind) === _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING ? `#${anchor.elementId}` : comment.ref;
|
|
526
|
+
}
|
|
417
527
|
});
|
|
418
528
|
};
|
|
419
529
|
|
|
@@ -448,7 +558,10 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
448
558
|
});
|
|
449
559
|
}
|
|
450
560
|
_registerIcons() {
|
|
451
|
-
this.disposeWithMe(this._iconManager.register({
|
|
561
|
+
this.disposeWithMe(this._iconManager.register({
|
|
562
|
+
CommentIcon: _univerjs_icons.CommentIcon,
|
|
563
|
+
InsertCommentDoubleIcon: _univerjs_icons.InsertCommentDoubleIcon
|
|
564
|
+
}));
|
|
452
565
|
}
|
|
453
566
|
};
|
|
454
567
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
@@ -479,19 +592,12 @@ let DocThreadCommentSelectionController = class DocThreadCommentSelectionControl
|
|
|
479
592
|
lastSelection = primary;
|
|
480
593
|
if (primary && doc) {
|
|
481
594
|
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
|
-
}
|
|
595
|
+
const selectionEnd = collapsed ? startOffset : endOffset - 1;
|
|
596
|
+
const customRange = this._findActiveCommentDecoration(doc, unitId, startOffset, selectionEnd);
|
|
490
597
|
if (customRange) {
|
|
491
|
-
|
|
492
|
-
if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
598
|
+
this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
493
599
|
unitId,
|
|
494
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
600
|
+
subUnitId: _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID,
|
|
495
601
|
commentId: customRange.id
|
|
496
602
|
} });
|
|
497
603
|
return;
|
|
@@ -500,20 +606,27 @@ let DocThreadCommentSelectionController = class DocThreadCommentSelectionControl
|
|
|
500
606
|
if (!this._threadCommentPanelService.activeCommentId) return;
|
|
501
607
|
const addingComment = this._docThreadCommentService.addingComment;
|
|
502
608
|
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) ===
|
|
609
|
+
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
610
|
this._commandService.executeCommand(_univerjs_thread_comment_ui.SetActiveCommentOperation.id);
|
|
505
611
|
}
|
|
506
612
|
}));
|
|
507
613
|
}
|
|
614
|
+
_findActiveCommentDecoration(doc, unitId, selectionStart, selectionEnd) {
|
|
615
|
+
var _doc$getBody;
|
|
616
|
+
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) => {
|
|
617
|
+
const comment = this._threadCommentModel.getComment(unitId, _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID, decoration.id);
|
|
618
|
+
return comment && !comment.resolved;
|
|
619
|
+
});
|
|
620
|
+
}
|
|
508
621
|
_initActiveCommandChange() {
|
|
509
622
|
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
|
|
510
623
|
var _this$_docThreadComme;
|
|
511
624
|
if (activeComment) {
|
|
512
625
|
const doc = this._univerInstanceService.getUnit(activeComment.unitId);
|
|
513
626
|
if (doc) {
|
|
514
|
-
var _this$_renderManagerS, _doc$
|
|
627
|
+
var _this$_renderManagerS, _doc$getBody2;
|
|
515
628
|
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$
|
|
629
|
+
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
630
|
if (customRange && backScrollController) backScrollController.scrollToRange({
|
|
518
631
|
startOffset: customRange.startIndex,
|
|
519
632
|
endOffset: customRange.endIndex,
|
|
@@ -536,50 +649,156 @@ DocThreadCommentSelectionController = __decorate([
|
|
|
536
649
|
|
|
537
650
|
//#endregion
|
|
538
651
|
//#region src/controllers/render-controllers/render.controller.ts
|
|
652
|
+
const DOC_COMMENT_DRAWING_OVERLAY_KEY = "doc-thread-comment-drawing-overlay";
|
|
653
|
+
const DOC_COMMENT_DRAWING_OVERLAY_LAYER_INDEX = 10100;
|
|
539
654
|
let DocThreadCommentRenderController = class DocThreadCommentRenderController extends _univerjs_core.Disposable {
|
|
540
|
-
constructor(_context, _docInterceptorService, _threadCommentPanelService,
|
|
655
|
+
constructor(_context, _docInterceptorService, _threadCommentPanelService, _univerInstanceService, _threadCommentModel, _commandService, _drawingManagerService, _themeService) {
|
|
541
656
|
super();
|
|
542
657
|
this._context = _context;
|
|
543
658
|
this._docInterceptorService = _docInterceptorService;
|
|
544
659
|
this._threadCommentPanelService = _threadCommentPanelService;
|
|
545
|
-
this._docRenderController = _docRenderController;
|
|
546
660
|
this._univerInstanceService = _univerInstanceService;
|
|
547
661
|
this._threadCommentModel = _threadCommentModel;
|
|
548
662
|
this._commandService = _commandService;
|
|
663
|
+
this._drawingManagerService = _drawingManagerService;
|
|
664
|
+
this._themeService = _themeService;
|
|
665
|
+
_defineProperty(this, "_drawingOverlay", void 0);
|
|
666
|
+
_defineProperty(this, "_drawingCommentSubUnits", /* @__PURE__ */ new Map());
|
|
667
|
+
this._drawingOverlay = new _univerjs_thread_comment_ui.ThreadCommentCanvasOverlay(DOC_COMMENT_DRAWING_OVERLAY_KEY, {
|
|
668
|
+
...this._getDrawingOverlayColors(),
|
|
669
|
+
zoomRatio: 1,
|
|
670
|
+
markers: [],
|
|
671
|
+
underlines: []
|
|
672
|
+
});
|
|
673
|
+
this._context.scene.addObject(this._drawingOverlay, DOC_COMMENT_DRAWING_OVERLAY_LAYER_INDEX);
|
|
549
674
|
this._interceptorViewModel();
|
|
550
675
|
this._initReRender();
|
|
551
676
|
this._initSyncComments();
|
|
677
|
+
this._initDrawingOverlay();
|
|
552
678
|
}
|
|
553
679
|
_initReRender() {
|
|
554
|
-
this.
|
|
680
|
+
[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
681
|
var _this$_univerInstance;
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
682
|
+
const currentUnitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
|
|
683
|
+
if ((/* @__PURE__ */ new Set([
|
|
684
|
+
previous === null || previous === void 0 ? void 0 : previous.unitId,
|
|
685
|
+
current === null || current === void 0 ? void 0 : current.unitId,
|
|
686
|
+
currentUnitId
|
|
687
|
+
])).has(this._context.unitId)) {
|
|
688
|
+
var _this$_context$mainCo;
|
|
689
|
+
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty(true);
|
|
559
690
|
}
|
|
560
|
-
|
|
561
|
-
if (unitId) this._docRenderController.reRender(unitId);
|
|
562
|
-
}));
|
|
691
|
+
})));
|
|
563
692
|
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
|
|
564
|
-
if (update.type === "resolve"
|
|
693
|
+
if (update.type === "resolve" && update.unitId === this._context.unitId) {
|
|
694
|
+
var _this$_context$mainCo2;
|
|
695
|
+
(_this$_context$mainCo2 = this._context.mainComponent) === null || _this$_context$mainCo2 === void 0 || _this$_context$mainCo2.makeDirty(true);
|
|
696
|
+
}
|
|
697
|
+
if (update.unitId === this._context.unitId) this._syncDrawingOverlay();
|
|
565
698
|
}));
|
|
566
699
|
}
|
|
700
|
+
_initDrawingOverlay() {
|
|
701
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._drawingOverlay.onPointerDown$.subscribeEvent((_event, state) => {
|
|
702
|
+
const commentId = this._drawingOverlay.hitCommentId;
|
|
703
|
+
const subUnitId = commentId && this._drawingCommentSubUnits.get(commentId);
|
|
704
|
+
if (!commentId || !subUnitId) return;
|
|
705
|
+
state.stopPropagation();
|
|
706
|
+
this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
707
|
+
unitId: this._context.unitId,
|
|
708
|
+
subUnitId,
|
|
709
|
+
commentId,
|
|
710
|
+
trigger: "doc-canvas"
|
|
711
|
+
} });
|
|
712
|
+
})));
|
|
713
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._context.engine.onTransformChange$.subscribeEvent(() => this._syncDrawingOverlay())));
|
|
714
|
+
[this._threadCommentPanelService.activeCommentId$, this._threadCommentPanelService.hoveredCommentId$].forEach((observable) => this.disposeWithMe(observable.subscribe(() => this._syncDrawingOverlay())));
|
|
715
|
+
[
|
|
716
|
+
this._drawingManagerService.add$,
|
|
717
|
+
this._drawingManagerService.update$,
|
|
718
|
+
this._drawingManagerService.remove$
|
|
719
|
+
].forEach((observable) => this.disposeWithMe(observable.subscribe((drawings) => {
|
|
720
|
+
if (drawings.some((drawing) => drawing.unitId === this._context.unitId)) this._syncDrawingOverlay();
|
|
721
|
+
})));
|
|
722
|
+
this.disposeWithMe(this._themeService.currentTheme$.subscribe(() => this._syncDrawingOverlay()));
|
|
723
|
+
this._syncDrawingOverlay();
|
|
724
|
+
}
|
|
725
|
+
_syncDrawingOverlay() {
|
|
726
|
+
const underlines = /* @__PURE__ */ new Map();
|
|
727
|
+
this._drawingCommentSubUnits.clear();
|
|
728
|
+
this._threadCommentModel.query({
|
|
729
|
+
unitIds: [this._context.unitId],
|
|
730
|
+
anchorKinds: [_univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING],
|
|
731
|
+
resolved: false
|
|
732
|
+
}).forEach(({ root, subUnitId }) => {
|
|
733
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(root.ref);
|
|
734
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING) return;
|
|
735
|
+
const outline = this._getDrawingOutline(anchor.pageId ?? subUnitId, anchor.elementId);
|
|
736
|
+
if (!outline) return;
|
|
737
|
+
this._drawingCommentSubUnits.set(root.id, subUnitId);
|
|
738
|
+
underlines.set(`${anchor.pageId ?? subUnitId}\0${anchor.elementId}`, {
|
|
739
|
+
commentId: root.id,
|
|
740
|
+
left: outline.left,
|
|
741
|
+
top: outline.top + outline.height + 2,
|
|
742
|
+
width: outline.width
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
const focusedCommentIds = [];
|
|
746
|
+
const focusOutlines = /* @__PURE__ */ new Map();
|
|
747
|
+
[this._threadCommentPanelService.activeCommentId, this._threadCommentPanelService.hoveredCommentId].forEach((target) => {
|
|
748
|
+
if (!target || target.unitId !== this._context.unitId) return;
|
|
749
|
+
const comment = this._threadCommentModel.getComment(target.unitId, target.subUnitId, target.commentId);
|
|
750
|
+
const anchor = comment && (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(comment.ref);
|
|
751
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== _univerjs_thread_comment.ThreadCommentAnchorKind.DOC_DRAWING) return;
|
|
752
|
+
focusedCommentIds.push(target.commentId);
|
|
753
|
+
const outline = this._getDrawingOutline(anchor.pageId ?? target.subUnitId, anchor.elementId);
|
|
754
|
+
if (outline) focusOutlines.set(`${anchor.pageId ?? target.subUnitId}\0${anchor.elementId}`, outline);
|
|
755
|
+
});
|
|
756
|
+
this._drawingOverlay.updateState({
|
|
757
|
+
...this._getDrawingOverlayColors(),
|
|
758
|
+
markers: [],
|
|
759
|
+
underlines: Array.from(underlines.values()),
|
|
760
|
+
focusedCommentIds,
|
|
761
|
+
focusOutlines: Array.from(focusOutlines.values())
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
_getDrawingOutline(subUnitId, drawingId) {
|
|
765
|
+
var _this$_context$scene$, _this$_context$scene;
|
|
766
|
+
const objectKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
|
|
767
|
+
unitId: this._context.unitId,
|
|
768
|
+
subUnitId,
|
|
769
|
+
drawingId
|
|
770
|
+
});
|
|
771
|
+
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);
|
|
772
|
+
if (!object) return null;
|
|
773
|
+
const bounds = object.getRealBound();
|
|
774
|
+
return {
|
|
775
|
+
left: bounds.left,
|
|
776
|
+
top: bounds.top,
|
|
777
|
+
width: bounds.width,
|
|
778
|
+
height: bounds.height
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
_getDrawingOverlayColors() {
|
|
782
|
+
return {
|
|
783
|
+
accentColor: this._themeService.getColorFromTheme("yellow.400"),
|
|
784
|
+
foregroundColor: this._themeService.getColorFromTheme("gray.900"),
|
|
785
|
+
outlineColor: this._themeService.getColorFromTheme("white")
|
|
786
|
+
};
|
|
787
|
+
}
|
|
567
788
|
_interceptorViewModel() {
|
|
568
789
|
this._docInterceptorService.intercept(_univerjs_docs.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION, { handler: (data, pos, next) => {
|
|
569
790
|
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);
|
|
791
|
+
const { unitId } = pos;
|
|
792
|
+
const focusedComments = [this._threadCommentPanelService.activeCommentId, this._threadCommentPanelService.hoveredCommentId];
|
|
793
|
+
const comment = this._threadCommentModel.getComment(unitId, _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID, data.id);
|
|
574
794
|
if (!comment) return next({
|
|
575
795
|
...data,
|
|
576
796
|
show: false
|
|
577
797
|
});
|
|
578
|
-
const
|
|
579
|
-
const isActive = commentUnitID === unitId && data.id === commentId;
|
|
798
|
+
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
799
|
return next({
|
|
581
800
|
...data,
|
|
582
|
-
active: isActive
|
|
801
|
+
active: isActive,
|
|
583
802
|
show: !comment.resolved
|
|
584
803
|
});
|
|
585
804
|
} });
|
|
@@ -587,9 +806,9 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
|
|
|
587
806
|
_initSyncComments() {
|
|
588
807
|
var _this$_context$unit$g;
|
|
589
808
|
const unitId = this._context.unit.getUnitId();
|
|
590
|
-
const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
|
|
809
|
+
const subUnitId = _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID;
|
|
591
810
|
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(),
|
|
811
|
+
threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), _univerjs_docs_thread_comment.DEFAULT_DOC_SUBUNIT_ID, threadIds);
|
|
593
812
|
let prevThreadIds = threadIds.sort();
|
|
594
813
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
595
814
|
if (commandInfo.id === _univerjs_docs.RichTextEditingMutation.id) {
|
|
@@ -613,10 +832,11 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
|
|
|
613
832
|
DocThreadCommentRenderController = __decorate([
|
|
614
833
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocInterceptorService)),
|
|
615
834
|
__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,
|
|
835
|
+
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
836
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_thread_comment.ThreadCommentModel)),
|
|
837
|
+
__decorateParam(5, _univerjs_core.ICommandService),
|
|
838
|
+
__decorateParam(6, _univerjs_drawing.IDrawingManagerService),
|
|
839
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
620
840
|
], DocThreadCommentRenderController);
|
|
621
841
|
|
|
622
842
|
//#endregion
|
|
@@ -646,6 +866,7 @@ let DocThreadCommentUIController = class DocThreadCommentUIController extends _u
|
|
|
646
866
|
}
|
|
647
867
|
_initCommands() {
|
|
648
868
|
[
|
|
869
|
+
AddDocDrawingCommentOperation,
|
|
649
870
|
AddDocCommentComment,
|
|
650
871
|
DeleteDocCommentComment,
|
|
651
872
|
ShowCommentPanelOperation,
|
|
@@ -663,8 +884,8 @@ let DocThreadCommentUIController = class DocThreadCommentUIController extends _u
|
|
|
663
884
|
DocThreadCommentUIController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, _univerjs_ui.IMenuManagerService)], DocThreadCommentUIController);
|
|
664
885
|
|
|
665
886
|
//#endregion
|
|
666
|
-
//#region src/plugin.ts
|
|
667
|
-
let
|
|
887
|
+
//#region src/mobile-plugin.ts
|
|
888
|
+
let UniverDocsThreadCommentMobileUIPlugin = class UniverDocsThreadCommentMobileUIPlugin extends _univerjs_core.Plugin {
|
|
668
889
|
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
669
890
|
super();
|
|
670
891
|
this._config = _config;
|
|
@@ -676,15 +897,15 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
676
897
|
this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
677
898
|
}
|
|
678
899
|
onStarting() {
|
|
679
|
-
this._injector.add([ComponentsController]);
|
|
680
|
-
this._injector.get(ComponentsController);
|
|
681
900
|
[
|
|
901
|
+
[ComponentsController],
|
|
682
902
|
[DocThreadCommentUIController],
|
|
683
903
|
[DocThreadCommentSelectionController],
|
|
684
904
|
[DocThreadCommentService]
|
|
685
905
|
].forEach((dep) => {
|
|
686
906
|
this._injector.add(dep);
|
|
687
907
|
});
|
|
908
|
+
this._injector.get(ComponentsController);
|
|
688
909
|
}
|
|
689
910
|
onRendered() {
|
|
690
911
|
this._initRenderModule();
|
|
@@ -692,17 +913,60 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
692
913
|
this._injector.get(DocThreadCommentUIController);
|
|
693
914
|
}
|
|
694
915
|
_initRenderModule() {
|
|
695
|
-
[DocThreadCommentRenderController]
|
|
696
|
-
|
|
916
|
+
this._renderManagerSrv.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_DOC, [DocThreadCommentRenderController]);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "pluginName", PLUGIN_NAME);
|
|
920
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "packageName", name);
|
|
921
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "version", version);
|
|
922
|
+
_defineProperty(UniverDocsThreadCommentMobileUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
923
|
+
UniverDocsThreadCommentMobileUIPlugin = __decorate([
|
|
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.UniverDocsMobileUIPlugin, _univerjs_thread_comment_ui.UniverThreadCommentMobileUIPlugin),
|
|
925
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
926
|
+
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
927
|
+
__decorateParam(3, _univerjs_core.IConfigService)
|
|
928
|
+
], UniverDocsThreadCommentMobileUIPlugin);
|
|
929
|
+
|
|
930
|
+
//#endregion
|
|
931
|
+
//#region src/plugin.ts
|
|
932
|
+
const STARTING_DEPENDENCIES = [
|
|
933
|
+
[DocThreadCommentUIController],
|
|
934
|
+
[DocThreadCommentSelectionController],
|
|
935
|
+
[DocThreadCommentService]
|
|
936
|
+
];
|
|
937
|
+
let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin extends _univerjs_core.Plugin {
|
|
938
|
+
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
939
|
+
super();
|
|
940
|
+
this._config = _config;
|
|
941
|
+
this._injector = _injector;
|
|
942
|
+
this._renderManagerSrv = _renderManagerSrv;
|
|
943
|
+
this._configService = _configService;
|
|
944
|
+
const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
945
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
946
|
+
this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
947
|
+
}
|
|
948
|
+
onStarting() {
|
|
949
|
+
this._injector.add([ComponentsController]);
|
|
950
|
+
this._injector.get(ComponentsController);
|
|
951
|
+
STARTING_DEPENDENCIES.forEach((dep) => {
|
|
952
|
+
this._injector.add(dep);
|
|
697
953
|
});
|
|
698
954
|
}
|
|
955
|
+
onRendered() {
|
|
956
|
+
this._initRenderModule();
|
|
957
|
+
this._injector.get(DocThreadCommentSelectionController);
|
|
958
|
+
this._injector.get(DocThreadCommentUIController);
|
|
959
|
+
}
|
|
960
|
+
_initRenderModule() {
|
|
961
|
+
this._renderManagerSrv.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_DOC, [DocThreadCommentRenderController]);
|
|
962
|
+
}
|
|
699
963
|
};
|
|
700
964
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
|
|
701
965
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "packageName", name);
|
|
702
966
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "version", version);
|
|
703
967
|
_defineProperty(UniverDocsThreadCommentUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
704
968
|
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),
|
|
969
|
+
(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
970
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
707
971
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
708
972
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
@@ -714,6 +978,12 @@ exports.DeleteDocCommentComment = DeleteDocCommentComment;
|
|
|
714
978
|
exports.DocsThreadCommentUIMenuSchema = menuSchema;
|
|
715
979
|
exports.ShowCommentPanelOperation = ShowCommentPanelOperation;
|
|
716
980
|
exports.StartAddCommentOperation = StartAddCommentOperation;
|
|
981
|
+
Object.defineProperty(exports, 'UniverDocsThreadCommentMobileUIPlugin', {
|
|
982
|
+
enumerable: true,
|
|
983
|
+
get: function () {
|
|
984
|
+
return UniverDocsThreadCommentMobileUIPlugin;
|
|
985
|
+
}
|
|
986
|
+
});
|
|
717
987
|
Object.defineProperty(exports, 'UniverDocsThreadCommentUIPlugin', {
|
|
718
988
|
enumerable: true,
|
|
719
989
|
get: function () {
|