@univerjs/docs-thread-comment-ui 0.25.0-insiders.20260623-012b5a8 → 0.25.1

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 ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/index.js CHANGED
@@ -88,7 +88,7 @@ const DeleteDocCommentComment = {
88
88
  };
89
89
 
90
90
  //#endregion
91
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
91
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
92
92
  function _typeof(o) {
93
93
  "@babel/helpers - typeof";
94
94
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -99,7 +99,7 @@ function _typeof(o) {
99
99
  }
100
100
 
101
101
  //#endregion
102
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
102
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
103
103
  function toPrimitive(t, r) {
104
104
  if ("object" != _typeof(t) || !t) return t;
105
105
  var e = t[Symbol.toPrimitive];
@@ -112,14 +112,14 @@ function toPrimitive(t, r) {
112
112
  }
113
113
 
114
114
  //#endregion
115
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
115
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
116
116
  function toPropertyKey(t) {
117
117
  var i = toPrimitive(t, "string");
118
118
  return "symbol" == _typeof(i) ? i : i + "";
119
119
  }
120
120
 
121
121
  //#endregion
122
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
122
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
123
123
  function _defineProperty(e, r, t) {
124
124
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
125
125
  value: t,
@@ -130,7 +130,7 @@ function _defineProperty(e, r, t) {
130
130
  }
131
131
 
132
132
  //#endregion
133
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
133
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
134
134
  function __decorateParam(paramIndex, decorator) {
135
135
  return function(target, key) {
136
136
  decorator(target, key, paramIndex);
@@ -138,7 +138,7 @@ function __decorateParam(paramIndex, decorator) {
138
138
  }
139
139
 
140
140
  //#endregion
141
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
141
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
142
142
  function __decorate(decorators, target, key, desc) {
143
143
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
144
144
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -273,7 +273,7 @@ const StartAddCommentOperation = {
273
273
  //#endregion
274
274
  //#region package.json
275
275
  var name = "@univerjs/docs-thread-comment-ui";
276
- var version = "0.25.0-insiders.20260623-012b5a8";
276
+ var version = "0.25.1";
277
277
 
278
278
  //#endregion
279
279
  //#region src/config/config.ts
@@ -281,6 +281,87 @@ const DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "docs-thread-comment-ui.config"
281
281
  const configSymbol = Symbol(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY);
282
282
  const defaultPluginConfig = {};
283
283
 
284
+ //#endregion
285
+ //#region src/controllers/doc-thread-comment-selection.controller.ts
286
+ let DocThreadCommentSelectionController = class DocThreadCommentSelectionController extends _univerjs_core.Disposable {
287
+ constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
288
+ super();
289
+ this._threadCommentPanelService = _threadCommentPanelService;
290
+ this._univerInstanceService = _univerInstanceService;
291
+ this._commandService = _commandService;
292
+ this._docThreadCommentService = _docThreadCommentService;
293
+ this._renderManagerService = _renderManagerService;
294
+ this._threadCommentModel = _threadCommentModel;
295
+ this._initSelectionChange();
296
+ this._initActiveCommandChange();
297
+ }
298
+ _initSelectionChange() {
299
+ let lastSelection;
300
+ this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
301
+ if (commandInfo.id === _univerjs_docs.SetTextSelectionsOperation.id) {
302
+ const { unitId, ranges } = commandInfo.params;
303
+ if ((0, _univerjs_core.isInternalEditorID)(unitId)) return;
304
+ const doc = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
305
+ const primary = ranges[0];
306
+ if ((lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.startOffset) === (primary === null || primary === void 0 ? void 0 : primary.startOffset) && (lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.endOffset) === (primary === null || primary === void 0 ? void 0 : primary.endOffset)) return;
307
+ lastSelection = primary;
308
+ if (primary && doc) {
309
+ const { startOffset, endOffset, collapsed } = primary;
310
+ let customRange;
311
+ if (collapsed) {
312
+ var _doc$getBody;
313
+ 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);
314
+ } else {
315
+ var _doc$getBody2;
316
+ 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);
317
+ }
318
+ if (customRange) {
319
+ const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, customRange.id);
320
+ if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
321
+ unitId,
322
+ subUnitId: DEFAULT_DOC_SUBUNIT_ID,
323
+ commentId: customRange.id
324
+ } });
325
+ return;
326
+ }
327
+ }
328
+ if (!this._threadCommentPanelService.activeCommentId) return;
329
+ const addingComment = this._docThreadCommentService.addingComment;
330
+ const activeComment = this._threadCommentPanelService.activeCommentId;
331
+ if (addingComment && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.unitId) === addingComment.unitId && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.subUnitId) === "default_doc" && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.commentId) === addingComment.id) return;
332
+ this._commandService.executeCommand(_univerjs_thread_comment_ui.SetActiveCommentOperation.id);
333
+ }
334
+ }));
335
+ }
336
+ _initActiveCommandChange() {
337
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
338
+ var _this$_docThreadComme;
339
+ if (activeComment) {
340
+ const doc = this._univerInstanceService.getUnit(activeComment.unitId);
341
+ if (doc) {
342
+ var _this$_renderManagerS, _doc$getBody3;
343
+ const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderById(activeComment.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs_ui.DocBackScrollRenderController);
344
+ const customRange = (_doc$getBody3 = doc.getBody()) === null || _doc$getBody3 === void 0 || (_doc$getBody3 = _doc$getBody3.customDecorations) === null || _doc$getBody3 === void 0 ? void 0 : _doc$getBody3.find((range) => range.id === activeComment.commentId);
345
+ if (customRange && backScrollController) backScrollController.scrollToRange({
346
+ startOffset: customRange.startIndex,
347
+ endOffset: customRange.endIndex,
348
+ collapsed: false
349
+ });
350
+ }
351
+ }
352
+ if (!activeComment || activeComment.commentId !== ((_this$_docThreadComme = this._docThreadCommentService.addingComment) === null || _this$_docThreadComme === void 0 ? void 0 : _this$_docThreadComme.id)) this._docThreadCommentService.endAdd();
353
+ }));
354
+ }
355
+ };
356
+ DocThreadCommentSelectionController = __decorate([
357
+ __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_thread_comment_ui.ThreadCommentPanelService)),
358
+ __decorateParam(1, _univerjs_core.IUniverInstanceService),
359
+ __decorateParam(2, _univerjs_core.ICommandService),
360
+ __decorateParam(3, (0, _univerjs_core.Inject)(DocThreadCommentService)),
361
+ __decorateParam(4, _univerjs_engine_render.IRenderManagerService),
362
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_thread_comment.ThreadCommentModel))
363
+ ], DocThreadCommentSelectionController);
364
+
284
365
  //#endregion
285
366
  //#region src/menu/menu.ts
286
367
  const shouldDisableAddComment = (accessor) => {
@@ -324,7 +405,20 @@ function ToolbarDocCommentMenuItemFactory(accessor) {
324
405
  }
325
406
 
326
407
  //#endregion
327
- //#region src/views/DocThreadCommentPanel.tsx
408
+ //#region src/menu/schema.ts
409
+ const menuSchema = {
410
+ [_univerjs_ui.RibbonInsertGroup.MEDIA]: { [ToggleCommentPanelOperation.id]: {
411
+ order: 3,
412
+ menuItemFactory: ToolbarDocCommentMenuItemFactory
413
+ } },
414
+ [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.DATA]: { [StartAddCommentOperation.id]: {
415
+ order: 1,
416
+ menuItemFactory: AddDocCommentMenuItemFactory
417
+ } } }
418
+ };
419
+
420
+ //#endregion
421
+ //#region src/views/doc-thread-comment-panel/index.tsx
328
422
  const DocThreadCommentPanel = () => {
329
423
  const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
330
424
  const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
@@ -403,7 +497,7 @@ const DocThreadCommentPanel = () => {
403
497
  };
404
498
 
405
499
  //#endregion
406
- //#region src/controllers/components.controller.ts
500
+ //#region src/controllers/doc-thread-comment-ui.controller.ts
407
501
  /**
408
502
  * Copyright 2023-present DreamNum Co., Ltd.
409
503
  *
@@ -419,105 +513,41 @@ const DocThreadCommentPanel = () => {
419
513
  * See the License for the specific language governing permissions and
420
514
  * limitations under the License.
421
515
  */
422
- let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
423
- constructor(_componentManager, _iconManager) {
516
+ let DocThreadCommentUIController = class DocThreadCommentUIController extends _univerjs_core.Disposable {
517
+ constructor(_commandService, _menuManagerService, _componentManager) {
424
518
  super();
519
+ this._commandService = _commandService;
520
+ this._menuManagerService = _menuManagerService;
425
521
  this._componentManager = _componentManager;
426
- this._iconManager = _iconManager;
427
- this._registerComponents();
428
- this._registerIcons();
522
+ this._initCommands();
523
+ this._initMenus();
524
+ this._initComponents();
429
525
  }
430
- _registerComponents() {
431
- [[DOCS_THREAD_COMMENT_PANEL, DocThreadCommentPanel]].forEach(([id, comp]) => {
432
- this.disposeWithMe(this._componentManager.register(id, comp));
526
+ _initCommands() {
527
+ [
528
+ AddDocCommentComment,
529
+ DeleteDocCommentComment,
530
+ ShowCommentPanelOperation,
531
+ StartAddCommentOperation,
532
+ ToggleCommentPanelOperation
533
+ ].forEach((command) => {
534
+ this.disposeWithMe(this._commandService.registerCommand(command));
433
535
  });
434
536
  }
435
- _registerIcons() {
436
- this.disposeWithMe(this._iconManager.register({ CommentIcon: _univerjs_icons.CommentIcon }));
437
- }
438
- };
439
- ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
440
-
441
- //#endregion
442
- //#region src/controllers/doc-thread-comment-selection.controller.ts
443
- let DocThreadCommentSelectionController = class DocThreadCommentSelectionController extends _univerjs_core.Disposable {
444
- constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
445
- super();
446
- this._threadCommentPanelService = _threadCommentPanelService;
447
- this._univerInstanceService = _univerInstanceService;
448
- this._commandService = _commandService;
449
- this._docThreadCommentService = _docThreadCommentService;
450
- this._renderManagerService = _renderManagerService;
451
- this._threadCommentModel = _threadCommentModel;
452
- this._initSelectionChange();
453
- this._initActiveCommandChange();
454
- }
455
- _initSelectionChange() {
456
- let lastSelection;
457
- this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
458
- if (commandInfo.id === _univerjs_docs.SetTextSelectionsOperation.id) {
459
- const { unitId, ranges } = commandInfo.params;
460
- if ((0, _univerjs_core.isInternalEditorID)(unitId)) return;
461
- const doc = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
462
- const primary = ranges[0];
463
- if ((lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.startOffset) === (primary === null || primary === void 0 ? void 0 : primary.startOffset) && (lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.endOffset) === (primary === null || primary === void 0 ? void 0 : primary.endOffset)) return;
464
- lastSelection = primary;
465
- if (primary && doc) {
466
- const { startOffset, endOffset, collapsed } = primary;
467
- let customRange;
468
- if (collapsed) {
469
- var _doc$getBody;
470
- 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);
471
- } else {
472
- var _doc$getBody2;
473
- 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);
474
- }
475
- if (customRange) {
476
- const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, customRange.id);
477
- if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
478
- unitId,
479
- subUnitId: DEFAULT_DOC_SUBUNIT_ID,
480
- commentId: customRange.id
481
- } });
482
- return;
483
- }
484
- }
485
- if (!this._threadCommentPanelService.activeCommentId) return;
486
- const addingComment = this._docThreadCommentService.addingComment;
487
- const activeComment = this._threadCommentPanelService.activeCommentId;
488
- if (addingComment && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.unitId) === addingComment.unitId && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.subUnitId) === "default_doc" && (activeComment === null || activeComment === void 0 ? void 0 : activeComment.commentId) === addingComment.id) return;
489
- this._commandService.executeCommand(_univerjs_thread_comment_ui.SetActiveCommentOperation.id);
490
- }
491
- }));
537
+ _initMenus() {
538
+ this._menuManagerService.mergeMenu(menuSchema);
492
539
  }
493
- _initActiveCommandChange() {
494
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
495
- var _this$_docThreadComme;
496
- if (activeComment) {
497
- const doc = this._univerInstanceService.getUnit(activeComment.unitId);
498
- if (doc) {
499
- var _this$_renderManagerS, _doc$getBody3;
500
- const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderById(activeComment.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs_ui.DocBackScrollRenderController);
501
- const customRange = (_doc$getBody3 = doc.getBody()) === null || _doc$getBody3 === void 0 || (_doc$getBody3 = _doc$getBody3.customDecorations) === null || _doc$getBody3 === void 0 ? void 0 : _doc$getBody3.find((range) => range.id === activeComment.commentId);
502
- if (customRange && backScrollController) backScrollController.scrollToRange({
503
- startOffset: customRange.startIndex,
504
- endOffset: customRange.endIndex,
505
- collapsed: false
506
- });
507
- }
508
- }
509
- if (!activeComment || activeComment.commentId !== ((_this$_docThreadComme = this._docThreadCommentService.addingComment) === null || _this$_docThreadComme === void 0 ? void 0 : _this$_docThreadComme.id)) this._docThreadCommentService.endAdd();
510
- }));
540
+ _initComponents() {
541
+ [[DOCS_THREAD_COMMENT_PANEL, DocThreadCommentPanel], ["CommentIcon", _univerjs_icons.CommentIcon]].forEach(([id, comp]) => {
542
+ this.disposeWithMe(this._componentManager.register(id, comp));
543
+ });
511
544
  }
512
545
  };
513
- DocThreadCommentSelectionController = __decorate([
514
- __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_thread_comment_ui.ThreadCommentPanelService)),
515
- __decorateParam(1, _univerjs_core.IUniverInstanceService),
516
- __decorateParam(2, _univerjs_core.ICommandService),
517
- __decorateParam(3, (0, _univerjs_core.Inject)(DocThreadCommentService)),
518
- __decorateParam(4, _univerjs_engine_render.IRenderManagerService),
519
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_thread_comment.ThreadCommentModel))
520
- ], DocThreadCommentSelectionController);
546
+ DocThreadCommentUIController = __decorate([
547
+ __decorateParam(0, _univerjs_core.ICommandService),
548
+ __decorateParam(1, _univerjs_ui.IMenuManagerService),
549
+ __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))
550
+ ], DocThreadCommentUIController);
521
551
 
522
552
  //#endregion
523
553
  //#region src/controllers/render-controllers/render.controller.ts
@@ -604,66 +634,6 @@ DocThreadCommentRenderController = __decorate([
604
634
  __decorateParam(6, _univerjs_core.ICommandService)
605
635
  ], DocThreadCommentRenderController);
606
636
 
607
- //#endregion
608
- //#region src/menu/schema.ts
609
- const menuSchema = {
610
- [_univerjs_ui.RibbonInsertGroup.MEDIA]: { [ToggleCommentPanelOperation.id]: {
611
- order: 3,
612
- menuItemFactory: ToolbarDocCommentMenuItemFactory
613
- } },
614
- [_univerjs_docs_ui.FLOAT_TOOLBAR_MENU_POSITION]: { [StartAddCommentOperation.id]: {
615
- order: 21,
616
- menuItemFactory: AddDocCommentMenuItemFactory
617
- } },
618
- [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.DATA]: { [StartAddCommentOperation.id]: {
619
- order: 1,
620
- menuItemFactory: AddDocCommentMenuItemFactory
621
- } } }
622
- };
623
-
624
- //#endregion
625
- //#region src/controllers/ui.controller.ts
626
- /**
627
- * Copyright 2023-present DreamNum Co., Ltd.
628
- *
629
- * Licensed under the Apache License, Version 2.0 (the "License");
630
- * you may not use this file except in compliance with the License.
631
- * You may obtain a copy of the License at
632
- *
633
- * http://www.apache.org/licenses/LICENSE-2.0
634
- *
635
- * Unless required by applicable law or agreed to in writing, software
636
- * distributed under the License is distributed on an "AS IS" BASIS,
637
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
638
- * See the License for the specific language governing permissions and
639
- * limitations under the License.
640
- */
641
- let DocThreadCommentUIController = class DocThreadCommentUIController extends _univerjs_core.Disposable {
642
- constructor(_commandService, _menuManagerService) {
643
- super();
644
- this._commandService = _commandService;
645
- this._menuManagerService = _menuManagerService;
646
- this._initCommands();
647
- this._initMenus();
648
- }
649
- _initCommands() {
650
- [
651
- AddDocCommentComment,
652
- DeleteDocCommentComment,
653
- ShowCommentPanelOperation,
654
- StartAddCommentOperation,
655
- ToggleCommentPanelOperation
656
- ].forEach((command) => {
657
- this.disposeWithMe(this._commandService.registerCommand(command));
658
- });
659
- }
660
- _initMenus() {
661
- this._menuManagerService.appendRootMenu({ [_univerjs_docs_ui.FLOAT_TOOLBAR_MENU_POSITION]: {} });
662
- this._menuManagerService.mergeMenu(menuSchema);
663
- }
664
- };
665
- DocThreadCommentUIController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, _univerjs_ui.IMenuManagerService)], DocThreadCommentUIController);
666
-
667
637
  //#endregion
668
638
  //#region src/plugin.ts
669
639
  let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin extends _univerjs_core.Plugin {
@@ -678,8 +648,6 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
678
648
  this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
679
649
  }
680
650
  onStarting() {
681
- this._injector.add([ComponentsController]);
682
- this._injector.get(ComponentsController);
683
651
  [
684
652
  [DocThreadCommentUIController],
685
653
  [DocThreadCommentSelectionController],