@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 +176 -0
- package/lib/cjs/index.js +130 -162
- package/lib/es/index.js +132 -164
- package/lib/index.js +132 -164
- package/lib/types/controllers/{ui.controller.d.ts → doc-thread-comment-ui.controller.d.ts} +4 -2
- package/lib/types/menu/menu.d.ts +2 -3
- package/lib/types/views/{DocThreadCommentPanel.d.ts → doc-thread-comment-panel/index.d.ts} +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
- package/lib/types/controllers/components.controller.d.ts +0 -24
- package/lib/types/locale/types.d.ts +0 -18
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
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 { DocBackScrollRenderController, DocRenderController, DocSelectionRenderService,
|
|
2
|
+
import { DocBackScrollRenderController, DocRenderController, DocSelectionRenderService, addCustomDecorationBySelectionFactory, deleteCustomDecorationFactory } from "@univerjs/docs-ui";
|
|
3
3
|
import { AddCommentMutation, IThreadCommentDataSourceService, ThreadCommentModel, getDT } from "@univerjs/thread-comment";
|
|
4
4
|
import { SetActiveCommentOperation, ThreadCommentPanel, ThreadCommentPanelService, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
5
5
|
import { DOC_INTERCEPTOR_POINT, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation } from "@univerjs/docs";
|
|
6
6
|
import { DocumentEditArea, IRenderManagerService, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
|
|
7
|
-
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, ISidebarService,
|
|
7
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, ISidebarService, MenuItemType, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
8
8
|
import { BehaviorSubject, Observable, debounceTime, filter } from "rxjs";
|
|
9
9
|
import { CommentIcon } from "@univerjs/icons";
|
|
10
10
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -87,7 +87,7 @@ const DeleteDocCommentComment = {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
//#endregion
|
|
90
|
-
//#region \0@oxc-project+runtime@0.
|
|
90
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
91
91
|
function _typeof(o) {
|
|
92
92
|
"@babel/helpers - typeof";
|
|
93
93
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -98,7 +98,7 @@ function _typeof(o) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
//#endregion
|
|
101
|
-
//#region \0@oxc-project+runtime@0.
|
|
101
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
102
102
|
function toPrimitive(t, r) {
|
|
103
103
|
if ("object" != _typeof(t) || !t) return t;
|
|
104
104
|
var e = t[Symbol.toPrimitive];
|
|
@@ -111,14 +111,14 @@ function toPrimitive(t, r) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
//#endregion
|
|
114
|
-
//#region \0@oxc-project+runtime@0.
|
|
114
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
115
115
|
function toPropertyKey(t) {
|
|
116
116
|
var i = toPrimitive(t, "string");
|
|
117
117
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
|
-
//#region \0@oxc-project+runtime@0.
|
|
121
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
122
122
|
function _defineProperty(e, r, t) {
|
|
123
123
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
124
124
|
value: t,
|
|
@@ -129,7 +129,7 @@ function _defineProperty(e, r, t) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
//#endregion
|
|
132
|
-
//#region \0@oxc-project+runtime@0.
|
|
132
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
133
133
|
function __decorateParam(paramIndex, decorator) {
|
|
134
134
|
return function(target, key) {
|
|
135
135
|
decorator(target, key, paramIndex);
|
|
@@ -137,7 +137,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
//#endregion
|
|
140
|
-
//#region \0@oxc-project+runtime@0.
|
|
140
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
141
141
|
function __decorate(decorators, target, key, desc) {
|
|
142
142
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
143
143
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -272,7 +272,7 @@ const StartAddCommentOperation = {
|
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region package.json
|
|
274
274
|
var name = "@univerjs/docs-thread-comment-ui";
|
|
275
|
-
var version = "0.25.
|
|
275
|
+
var version = "0.25.1";
|
|
276
276
|
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/config/config.ts
|
|
@@ -280,6 +280,87 @@ const DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "docs-thread-comment-ui.config"
|
|
|
280
280
|
const configSymbol = Symbol(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY);
|
|
281
281
|
const defaultPluginConfig = {};
|
|
282
282
|
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/controllers/doc-thread-comment-selection.controller.ts
|
|
285
|
+
let DocThreadCommentSelectionController = class DocThreadCommentSelectionController extends Disposable {
|
|
286
|
+
constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
|
|
287
|
+
super();
|
|
288
|
+
this._threadCommentPanelService = _threadCommentPanelService;
|
|
289
|
+
this._univerInstanceService = _univerInstanceService;
|
|
290
|
+
this._commandService = _commandService;
|
|
291
|
+
this._docThreadCommentService = _docThreadCommentService;
|
|
292
|
+
this._renderManagerService = _renderManagerService;
|
|
293
|
+
this._threadCommentModel = _threadCommentModel;
|
|
294
|
+
this._initSelectionChange();
|
|
295
|
+
this._initActiveCommandChange();
|
|
296
|
+
}
|
|
297
|
+
_initSelectionChange() {
|
|
298
|
+
let lastSelection;
|
|
299
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
300
|
+
if (commandInfo.id === SetTextSelectionsOperation.id) {
|
|
301
|
+
const { unitId, ranges } = commandInfo.params;
|
|
302
|
+
if (isInternalEditorID(unitId)) return;
|
|
303
|
+
const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
304
|
+
const primary = ranges[0];
|
|
305
|
+
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;
|
|
306
|
+
lastSelection = primary;
|
|
307
|
+
if (primary && doc) {
|
|
308
|
+
const { startOffset, endOffset, collapsed } = primary;
|
|
309
|
+
let customRange;
|
|
310
|
+
if (collapsed) {
|
|
311
|
+
var _doc$getBody;
|
|
312
|
+
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);
|
|
313
|
+
} else {
|
|
314
|
+
var _doc$getBody2;
|
|
315
|
+
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);
|
|
316
|
+
}
|
|
317
|
+
if (customRange) {
|
|
318
|
+
const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, customRange.id);
|
|
319
|
+
if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
320
|
+
unitId,
|
|
321
|
+
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
322
|
+
commentId: customRange.id
|
|
323
|
+
} });
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (!this._threadCommentPanelService.activeCommentId) return;
|
|
328
|
+
const addingComment = this._docThreadCommentService.addingComment;
|
|
329
|
+
const activeComment = this._threadCommentPanelService.activeCommentId;
|
|
330
|
+
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;
|
|
331
|
+
this._commandService.executeCommand(SetActiveCommentOperation.id);
|
|
332
|
+
}
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
_initActiveCommandChange() {
|
|
336
|
+
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
|
|
337
|
+
var _this$_docThreadComme;
|
|
338
|
+
if (activeComment) {
|
|
339
|
+
const doc = this._univerInstanceService.getUnit(activeComment.unitId);
|
|
340
|
+
if (doc) {
|
|
341
|
+
var _this$_renderManagerS, _doc$getBody3;
|
|
342
|
+
const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderById(activeComment.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocBackScrollRenderController);
|
|
343
|
+
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);
|
|
344
|
+
if (customRange && backScrollController) backScrollController.scrollToRange({
|
|
345
|
+
startOffset: customRange.startIndex,
|
|
346
|
+
endOffset: customRange.endIndex,
|
|
347
|
+
collapsed: false
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!activeComment || activeComment.commentId !== ((_this$_docThreadComme = this._docThreadCommentService.addingComment) === null || _this$_docThreadComme === void 0 ? void 0 : _this$_docThreadComme.id)) this._docThreadCommentService.endAdd();
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
DocThreadCommentSelectionController = __decorate([
|
|
356
|
+
__decorateParam(0, Inject(ThreadCommentPanelService)),
|
|
357
|
+
__decorateParam(1, IUniverInstanceService),
|
|
358
|
+
__decorateParam(2, ICommandService),
|
|
359
|
+
__decorateParam(3, Inject(DocThreadCommentService)),
|
|
360
|
+
__decorateParam(4, IRenderManagerService),
|
|
361
|
+
__decorateParam(5, Inject(ThreadCommentModel))
|
|
362
|
+
], DocThreadCommentSelectionController);
|
|
363
|
+
|
|
283
364
|
//#endregion
|
|
284
365
|
//#region src/menu/menu.ts
|
|
285
366
|
const shouldDisableAddComment = (accessor) => {
|
|
@@ -323,7 +404,20 @@ function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
|
323
404
|
}
|
|
324
405
|
|
|
325
406
|
//#endregion
|
|
326
|
-
//#region src/
|
|
407
|
+
//#region src/menu/schema.ts
|
|
408
|
+
const menuSchema = {
|
|
409
|
+
[RibbonInsertGroup.MEDIA]: { [ToggleCommentPanelOperation.id]: {
|
|
410
|
+
order: 3,
|
|
411
|
+
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
412
|
+
} },
|
|
413
|
+
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.DATA]: { [StartAddCommentOperation.id]: {
|
|
414
|
+
order: 1,
|
|
415
|
+
menuItemFactory: AddDocCommentMenuItemFactory
|
|
416
|
+
} } }
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/views/doc-thread-comment-panel/index.tsx
|
|
327
421
|
const DocThreadCommentPanel = () => {
|
|
328
422
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
329
423
|
const injector = useDependency(Injector);
|
|
@@ -402,7 +496,7 @@ const DocThreadCommentPanel = () => {
|
|
|
402
496
|
};
|
|
403
497
|
|
|
404
498
|
//#endregion
|
|
405
|
-
//#region src/controllers/
|
|
499
|
+
//#region src/controllers/doc-thread-comment-ui.controller.ts
|
|
406
500
|
/**
|
|
407
501
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
408
502
|
*
|
|
@@ -418,105 +512,41 @@ const DocThreadCommentPanel = () => {
|
|
|
418
512
|
* See the License for the specific language governing permissions and
|
|
419
513
|
* limitations under the License.
|
|
420
514
|
*/
|
|
421
|
-
let
|
|
422
|
-
constructor(
|
|
515
|
+
let DocThreadCommentUIController = class DocThreadCommentUIController extends Disposable {
|
|
516
|
+
constructor(_commandService, _menuManagerService, _componentManager) {
|
|
423
517
|
super();
|
|
518
|
+
this._commandService = _commandService;
|
|
519
|
+
this._menuManagerService = _menuManagerService;
|
|
424
520
|
this._componentManager = _componentManager;
|
|
425
|
-
this.
|
|
426
|
-
this.
|
|
427
|
-
this.
|
|
521
|
+
this._initCommands();
|
|
522
|
+
this._initMenus();
|
|
523
|
+
this._initComponents();
|
|
428
524
|
}
|
|
429
|
-
|
|
430
|
-
[
|
|
431
|
-
|
|
525
|
+
_initCommands() {
|
|
526
|
+
[
|
|
527
|
+
AddDocCommentComment,
|
|
528
|
+
DeleteDocCommentComment,
|
|
529
|
+
ShowCommentPanelOperation,
|
|
530
|
+
StartAddCommentOperation,
|
|
531
|
+
ToggleCommentPanelOperation
|
|
532
|
+
].forEach((command) => {
|
|
533
|
+
this.disposeWithMe(this._commandService.registerCommand(command));
|
|
432
534
|
});
|
|
433
535
|
}
|
|
434
|
-
|
|
435
|
-
this.
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
439
|
-
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/controllers/doc-thread-comment-selection.controller.ts
|
|
442
|
-
let DocThreadCommentSelectionController = class DocThreadCommentSelectionController extends Disposable {
|
|
443
|
-
constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
|
|
444
|
-
super();
|
|
445
|
-
this._threadCommentPanelService = _threadCommentPanelService;
|
|
446
|
-
this._univerInstanceService = _univerInstanceService;
|
|
447
|
-
this._commandService = _commandService;
|
|
448
|
-
this._docThreadCommentService = _docThreadCommentService;
|
|
449
|
-
this._renderManagerService = _renderManagerService;
|
|
450
|
-
this._threadCommentModel = _threadCommentModel;
|
|
451
|
-
this._initSelectionChange();
|
|
452
|
-
this._initActiveCommandChange();
|
|
453
|
-
}
|
|
454
|
-
_initSelectionChange() {
|
|
455
|
-
let lastSelection;
|
|
456
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
457
|
-
if (commandInfo.id === SetTextSelectionsOperation.id) {
|
|
458
|
-
const { unitId, ranges } = commandInfo.params;
|
|
459
|
-
if (isInternalEditorID(unitId)) return;
|
|
460
|
-
const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
461
|
-
const primary = ranges[0];
|
|
462
|
-
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;
|
|
463
|
-
lastSelection = primary;
|
|
464
|
-
if (primary && doc) {
|
|
465
|
-
const { startOffset, endOffset, collapsed } = primary;
|
|
466
|
-
let customRange;
|
|
467
|
-
if (collapsed) {
|
|
468
|
-
var _doc$getBody;
|
|
469
|
-
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);
|
|
470
|
-
} else {
|
|
471
|
-
var _doc$getBody2;
|
|
472
|
-
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);
|
|
473
|
-
}
|
|
474
|
-
if (customRange) {
|
|
475
|
-
const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, customRange.id);
|
|
476
|
-
if (comment && !comment.resolved) this._commandService.executeCommand(ShowCommentPanelOperation.id, { activeComment: {
|
|
477
|
-
unitId,
|
|
478
|
-
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
479
|
-
commentId: customRange.id
|
|
480
|
-
} });
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
if (!this._threadCommentPanelService.activeCommentId) return;
|
|
485
|
-
const addingComment = this._docThreadCommentService.addingComment;
|
|
486
|
-
const activeComment = this._threadCommentPanelService.activeCommentId;
|
|
487
|
-
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;
|
|
488
|
-
this._commandService.executeCommand(SetActiveCommentOperation.id);
|
|
489
|
-
}
|
|
490
|
-
}));
|
|
536
|
+
_initMenus() {
|
|
537
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
491
538
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
const doc = this._univerInstanceService.getUnit(activeComment.unitId);
|
|
497
|
-
if (doc) {
|
|
498
|
-
var _this$_renderManagerS, _doc$getBody3;
|
|
499
|
-
const backScrollController = (_this$_renderManagerS = this._renderManagerService.getRenderById(activeComment.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocBackScrollRenderController);
|
|
500
|
-
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);
|
|
501
|
-
if (customRange && backScrollController) backScrollController.scrollToRange({
|
|
502
|
-
startOffset: customRange.startIndex,
|
|
503
|
-
endOffset: customRange.endIndex,
|
|
504
|
-
collapsed: false
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
if (!activeComment || activeComment.commentId !== ((_this$_docThreadComme = this._docThreadCommentService.addingComment) === null || _this$_docThreadComme === void 0 ? void 0 : _this$_docThreadComme.id)) this._docThreadCommentService.endAdd();
|
|
509
|
-
}));
|
|
539
|
+
_initComponents() {
|
|
540
|
+
[[DOCS_THREAD_COMMENT_PANEL, DocThreadCommentPanel], ["CommentIcon", CommentIcon]].forEach(([id, comp]) => {
|
|
541
|
+
this.disposeWithMe(this._componentManager.register(id, comp));
|
|
542
|
+
});
|
|
510
543
|
}
|
|
511
544
|
};
|
|
512
|
-
|
|
513
|
-
__decorateParam(0,
|
|
514
|
-
__decorateParam(1,
|
|
515
|
-
__decorateParam(2,
|
|
516
|
-
|
|
517
|
-
__decorateParam(4, IRenderManagerService),
|
|
518
|
-
__decorateParam(5, Inject(ThreadCommentModel))
|
|
519
|
-
], DocThreadCommentSelectionController);
|
|
545
|
+
DocThreadCommentUIController = __decorate([
|
|
546
|
+
__decorateParam(0, ICommandService),
|
|
547
|
+
__decorateParam(1, IMenuManagerService),
|
|
548
|
+
__decorateParam(2, Inject(ComponentManager))
|
|
549
|
+
], DocThreadCommentUIController);
|
|
520
550
|
|
|
521
551
|
//#endregion
|
|
522
552
|
//#region src/controllers/render-controllers/render.controller.ts
|
|
@@ -603,66 +633,6 @@ DocThreadCommentRenderController = __decorate([
|
|
|
603
633
|
__decorateParam(6, ICommandService)
|
|
604
634
|
], DocThreadCommentRenderController);
|
|
605
635
|
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/menu/schema.ts
|
|
608
|
-
const menuSchema = {
|
|
609
|
-
[RibbonInsertGroup.MEDIA]: { [ToggleCommentPanelOperation.id]: {
|
|
610
|
-
order: 3,
|
|
611
|
-
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
612
|
-
} },
|
|
613
|
-
[FLOAT_TOOLBAR_MENU_POSITION]: { [StartAddCommentOperation.id]: {
|
|
614
|
-
order: 21,
|
|
615
|
-
menuItemFactory: AddDocCommentMenuItemFactory
|
|
616
|
-
} },
|
|
617
|
-
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.DATA]: { [StartAddCommentOperation.id]: {
|
|
618
|
-
order: 1,
|
|
619
|
-
menuItemFactory: AddDocCommentMenuItemFactory
|
|
620
|
-
} } }
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
//#endregion
|
|
624
|
-
//#region src/controllers/ui.controller.ts
|
|
625
|
-
/**
|
|
626
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
627
|
-
*
|
|
628
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
629
|
-
* you may not use this file except in compliance with the License.
|
|
630
|
-
* You may obtain a copy of the License at
|
|
631
|
-
*
|
|
632
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
633
|
-
*
|
|
634
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
635
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
636
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
637
|
-
* See the License for the specific language governing permissions and
|
|
638
|
-
* limitations under the License.
|
|
639
|
-
*/
|
|
640
|
-
let DocThreadCommentUIController = class DocThreadCommentUIController extends Disposable {
|
|
641
|
-
constructor(_commandService, _menuManagerService) {
|
|
642
|
-
super();
|
|
643
|
-
this._commandService = _commandService;
|
|
644
|
-
this._menuManagerService = _menuManagerService;
|
|
645
|
-
this._initCommands();
|
|
646
|
-
this._initMenus();
|
|
647
|
-
}
|
|
648
|
-
_initCommands() {
|
|
649
|
-
[
|
|
650
|
-
AddDocCommentComment,
|
|
651
|
-
DeleteDocCommentComment,
|
|
652
|
-
ShowCommentPanelOperation,
|
|
653
|
-
StartAddCommentOperation,
|
|
654
|
-
ToggleCommentPanelOperation
|
|
655
|
-
].forEach((command) => {
|
|
656
|
-
this.disposeWithMe(this._commandService.registerCommand(command));
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
_initMenus() {
|
|
660
|
-
this._menuManagerService.appendRootMenu({ [FLOAT_TOOLBAR_MENU_POSITION]: {} });
|
|
661
|
-
this._menuManagerService.mergeMenu(menuSchema);
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
DocThreadCommentUIController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IMenuManagerService)], DocThreadCommentUIController);
|
|
665
|
-
|
|
666
636
|
//#endregion
|
|
667
637
|
//#region src/plugin.ts
|
|
668
638
|
let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin extends Plugin {
|
|
@@ -677,8 +647,6 @@ let UniverDocsThreadCommentUIPlugin = class UniverDocsThreadCommentUIPlugin exte
|
|
|
677
647
|
this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
678
648
|
}
|
|
679
649
|
onStarting() {
|
|
680
|
-
this._injector.add([ComponentsController]);
|
|
681
|
-
this._injector.get(ComponentsController);
|
|
682
650
|
[
|
|
683
651
|
[DocThreadCommentUIController],
|
|
684
652
|
[DocThreadCommentSelectionController],
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Disposable, ICommandService } from '@univerjs/core';
|
|
17
|
-
import { IMenuManagerService } from '@univerjs/ui';
|
|
17
|
+
import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
|
|
18
18
|
export declare class DocThreadCommentUIController extends Disposable {
|
|
19
19
|
private readonly _commandService;
|
|
20
20
|
private readonly _menuManagerService;
|
|
21
|
-
|
|
21
|
+
private readonly _componentManager;
|
|
22
|
+
constructor(_commandService: ICommandService, _menuManagerService: IMenuManagerService, _componentManager: ComponentManager);
|
|
22
23
|
private _initCommands;
|
|
23
24
|
private _initMenus;
|
|
25
|
+
private _initComponents;
|
|
24
26
|
}
|
package/lib/types/menu/menu.d.ts
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { IAccessor } from '@univerjs/core';
|
|
17
17
|
import type { IMenuButtonItem } from '@univerjs/ui';
|
|
18
|
-
import type { LocaleKey } from '../locale/types';
|
|
19
18
|
export declare const shouldDisableAddComment: (accessor: IAccessor) => boolean;
|
|
20
|
-
export declare function AddDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonItem
|
|
21
|
-
export declare function ToolbarDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonItem
|
|
19
|
+
export declare function AddDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
|
|
20
|
+
export declare function ToolbarDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export declare const DocThreadCommentPanel: () => import("react").JSX.Element | null;
|
|
16
|
+
export declare const DocThreadCommentPanel: () => import("react/jsx-runtime").JSX.Element | null;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs-ui`,`@univerjs/thread-comment`,`@univerjs/thread-comment-ui`,`@univerjs/docs`,`@univerjs/engine-render`,`@univerjs/ui`,`rxjs`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsThreadCommentUi={},e.UniverCore,e.UniverDocsUi,e.UniverThreadComment,e.UniverThreadCommentUi,e.UniverDocs,e.UniverEngineRender,e.UniverUi,e.rxjs,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let d=`univer.doc.thread-comment-panel`,f=`default_doc`,p={id:`docs.command.add-comment`,type:t.CommandType.COMMAND,async handler(e,a){if(!a)return!1;let{comment:o,unitId:s}=a,c=await e.get(r.IThreadCommentDataSourceService).addComment(o),l=e.get(t.ICommandService),u=(0,n.addCustomDecorationBySelectionFactory)(e,{id:c.threadId,type:t.CustomDecorationType.COMMENT,unitId:s});return u?(await(0,t.sequenceExecute)([{id:r.AddCommentMutation.id,params:{unitId:s,subUnitId:f,comment:c}},u,{id:i.SetActiveCommentOperation.id,params:{unitId:s,subUnitId:f,commentId:c.id}}],l)).result:!1}},m={id:`docs.command.delete-comment`,type:t.CommandType.COMMAND,async handler(e,r){if(!r)return!1;let{commentId:i,unitId:a}=r,o=e.get(t.ICommandService),s=(0,n.deleteCustomDecorationFactory)(e,{id:i,unitId:a});return s?(await(0,t.sequenceExecute)([s],o)).result:!1}};function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends t.Disposable{get addingComment(){return this._addingComment$.getValue()}constructor(e,t){super(),this._sidebarService=e,this._threadCommentPanelService=t,v(this,`_addingComment$`,new c.BehaviorSubject(void 0)),v(this,`addingComment$`,this._addingComment$.asObservable()),this.disposeWithMe(()=>{this._addingComment$.complete()})}startAdd(e){this._addingComment$.next(e)}endAdd(){this._addingComment$.next(void 0)}};x=b([y(0,s.ISidebarService),y(1,(0,t.Inject)(i.ThreadCommentPanelService))],x);let S={id:`docs.operation.show-comment-panel`,type:t.CommandType.OPERATION,handler(e,t){var n;let r=e.get(i.ThreadCommentPanelService),a=e.get(s.ISidebarService);return(!r.panelVisible||((n=a.options.children)==null?void 0:n.label)!==`univer.doc.thread-comment-panel`)&&(a.open({header:{title:`docs-thread-comment-ui.panel.title`},children:{label:d},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},C={id:`docs.operation.toggle-comment-panel`,type:t.CommandType.OPERATION,handler(e){var t;let n=e.get(i.ThreadCommentPanelService),r=e.get(s.ISidebarService);return!n.panelVisible||((t=r.options.children)==null?void 0:t.label)!==`univer.doc.thread-comment-panel`?(r.open({header:{title:`docs-thread-comment-ui.panel.title`},children:{label:d},width:320,onClose:()=>n.setPanelVisible(!1)}),n.setPanelVisible(!0)):(r.close(),n.setPanelVisible(!1),n.setActiveComment(null)),!0}},w={id:`docs.operation.start-add-comment`,type:t.CommandType.OPERATION,handler(e){var c,l,u;let d=e.get(i.ThreadCommentPanelService),p=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),m=e.get(a.DocSelectionManagerService),h=e.get(o.IRenderManagerService),g=e.get(t.UserManagerService),_=e.get(x),v=e.get(t.ICommandService),y=e.get(s.ISidebarService),b=m.getActiveTextRange();if(!p||!b)return!1;let C=(c=h.getRenderById(p.getUnitId()))==null?void 0:c.with(n.DocSelectionRenderService);if(C==null||C.setReserveRangesStatus(!0),b.collapsed)return d.panelVisible?(d.setPanelVisible(!1),y.close()):v.executeCommand(S.id),!0;v.executeCommand(S.id);let w=p.getUnitId(),T=((l=(u=p.getBody())==null?void 0:u.dataStream)==null?``:l).slice(b.startOffset,b.endOffset),E=t.BuildTextUtils.transform.getPlainText(T),D=f,O={unitId:w,subUnitId:D,id:``,ref:E,dT:(0,r.getDT)(),personId:g.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
-
`},startOffset:b.startOffset,endOffset:b.endOffset,collapsed:!0,threadId:``};return C==null||C.blur(),_.startAdd(O),d.setActiveComment({unitId:w,subUnitId:D,commentId:``}),!0}};var T=`@univerjs/docs-thread-comment-ui`,E=`0.25.0-insiders.20260623-012b5a8`;let D={};function O({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,l.useRef)(`_${M()}`);return k(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function k(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...A(e,n,i),...r},(j(e,n).children||[]).map((r,a)=>k(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function A(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function j(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function M(){return Math.random().toString(36).substring(2,8)}O.displayName=`UniverIcon`;let N={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},P=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(O,Object.assign({},e,{id:`comment-icon`,ref:t,icon:N}))});P.displayName=`CommentIcon`;let F=e=>{var n;let r=e.get(o.IRenderManagerService),i=e.get(a.DocSelectionManagerService),s=(n=(0,o.withCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_DOC,a.DocSkeletonManagerService,e.get(t.IUniverInstanceService),r))==null?void 0:n.getSkeleton(),c=s==null?void 0:s.getViewModel().getEditArea();if(c===o.DocumentEditArea.FOOTER||c===o.DocumentEditArea.HEADER)return!0;let l=i.getActiveTextRange();return!!(l==null||l.collapsed)};function I(e){return{id:w.id,type:s.MenuItemType.BUTTON,icon:`CommentIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,void 0,t.SHEET_EDITOR_UNITS),disabled$:new c.Observable(function(t){let n=e.get(a.DocSelectionManagerService).textSelection$.pipe((0,c.debounceTime)(16)).subscribe(()=>{t.next(F(e))});return()=>{n.unsubscribe()}})}}function L(e){return{id:C.id,type:s.MenuItemType.BUTTON,icon:`CommentIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let R=()=>{let e=(0,s.useDependency)(t.IUniverInstanceService),n=(0,s.useDependency)(t.Injector),r=(0,s.useObservable)((0,l.useMemo)(()=>e.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,c.filter)(e=>!!e&&!(0,t.isInternalEditorID)(e.getUnitId()))),[e])),o=(0,l.useMemo)(()=>new c.Observable(e=>e.next(f)),[]),d=(0,s.useDependency)(a.DocSelectionManagerService);(0,s.useObservable)((0,l.useMemo)(()=>d.textSelection$.pipe((0,c.debounceTime)(16)),[d.textSelection$]));let h=(0,s.useDependency)(t.ICommandService),g=(0,s.useDependency)(x),_=(0,s.useObservable)(g.addingComment$),[v,y]=(0,l.useState)([]);if((0,l.useEffect)(()=>{var e;let t=new Set,n=r==null?void 0:r.getCustomDecorations();y((e=n==null?void 0:n.map(e=>e.id).filter(e=>{let n=t.has(e);return t.add(e),!n}))==null?[]:e);let i=h.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){var t;let e=new Set,n=r==null?void 0:r.getCustomDecorations();y((t=n==null?void 0:n.map(e=>e.id).filter(t=>{let n=e.has(t);return e.add(t),!n}))==null?[]:t)}});return()=>{i.dispose()}},[h,r]),!r)return null;let b=F(n),S=r.getUnitId();return(0,u.jsx)(i.ThreadCommentPanel,{unitId:S,subUnitId$:o,type:t.UniverInstanceType.UNIVER_DOC,onAdd:()=>{h.executeCommand(w.id)},getSubUnitName:()=>``,disableAdd:b,tempComment:_,onAddComment:e=>{if(!e.parentId){let t={unitId:S,range:_,comment:e};return h.executeCommand(p.id,t),g.endAdd(),!1}return!0},onDeleteComment:e=>{if(!e.parentId){let t={unitId:S,commentId:e.id};return h.executeCommand(m.id,t),!1}return!0},showComments:v})},z=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[d,R]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({CommentIcon:P}))}};z=b([y(0,(0,t.Inject)(s.ComponentManager)),y(1,(0,t.Inject)(s.IconManager))],z);let B=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=n,this._docThreadCommentService=r,this._renderManagerService=i,this._threadCommentModel=a,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===a.SetTextSelectionsOperation.id){let{unitId:a,ranges:s}=n.params;if((0,t.isInternalEditorID)(a))return;let c=this._univerInstanceService.getUnit(a,t.UniverInstanceType.UNIVER_DOC),l=s[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&c){let{startOffset:e,endOffset:t,collapsed:n}=l,i;if(n){var r;i=(r=c.getBody())==null||(r=r.customDecorations)==null?void 0:r.find(n=>n.startIndex<=e&&n.endIndex>=t-1)}else{var o;i=(o=c.getBody())==null||(o=o.customDecorations)==null?void 0:o.find(n=>n.startIndex<=e&&n.endIndex>=t-1)}if(i){let e=this._threadCommentModel.getComment(a,f,i.id);e&&!e.resolved&&this._commandService.executeCommand(S.id,{activeComment:{unitId:a,subUnitId:f,commentId:i.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;let u=this._docThreadCommentService.addingComment,d=this._threadCommentPanelService.activeCommentId;if(u&&(d==null?void 0:d.unitId)===u.unitId&&(d==null?void 0:d.subUnitId)===`default_doc`&&(d==null?void 0:d.commentId)===u.id)return;this._commandService.executeCommand(i.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t;if(e){let t=this._univerInstanceService.getUnit(e.unitId);if(t){var r,i;let a=(r=this._renderManagerService.getRenderById(e.unitId))==null?void 0:r.with(n.DocBackScrollRenderController),o=(i=t.getBody())==null||(i=i.customDecorations)==null?void 0:i.find(t=>t.id===e.commentId);o&&a&&a.scrollToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1})}}(!e||e.commentId!==((t=this._docThreadCommentService.addingComment)==null?void 0:t.id))&&this._docThreadCommentService.endAdd()}))}};B=b([y(0,(0,t.Inject)(i.ThreadCommentPanelService)),y(1,t.IUniverInstanceService),y(2,t.ICommandService),y(3,(0,t.Inject)(x)),y(4,o.IRenderManagerService),y(5,(0,t.Inject)(r.ThreadCommentModel))],B);let V=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=n,this._docRenderController=r,this._univerInstanceService=i,this._threadCommentModel=a,this._commandService=o,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var n;if(e){this._docRenderController.reRender(e.unitId);return}let r=(n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId();r&&this._docRenderController.reRender(r)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type===`resolve`&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(a.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i,customDecorations:a}=t,{commentId:o,unitId:s}=this._threadCommentPanelService.activeCommentId||{},c=a.find(e=>e.id===o),l=this._threadCommentModel.getComment(r,f,e.id);if(!l)return n({...e,show:!1});let u=c&&i>=c.startIndex&&i<=c.endIndex,d=s===r&&e.id===o;return n({...e,active:d||u,show:!l.resolved})}})}_initSyncComments(){var e,n;let r=this._context.unit.getUnitId(),i=(e=(n=this._context.unit.getBody())==null||(n=n.customDecorations)==null?void 0:n.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))==null?[]:e;i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),`default_doc`,i);let o=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){var n,i;if(e.params.unitId!==this._context.unit.getUnitId())return;let a=(n=(i=this._context.unit.getBody())==null||(i=i.customDecorations)==null?void 0:i.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))==null?[]:n,s=a.sort();if(JSON.stringify(o)!==JSON.stringify(s)){let e=new Set(o),t=new Set;a.forEach(n=>{e.has(n)||t.add(n)}),o=s,this._threadCommentModel.syncThreadComments(r,`default_doc`,[...t])}}}))}};V=b([y(1,(0,t.Inject)(a.DocInterceptorService)),y(2,(0,t.Inject)(i.ThreadCommentPanelService)),y(3,(0,t.Inject)(n.DocRenderController)),y(4,t.IUniverInstanceService),y(5,(0,t.Inject)(r.ThreadCommentModel)),y(6,t.ICommandService)],V);let H={[s.RibbonInsertGroup.MEDIA]:{[C.id]:{order:3,menuItemFactory:L}},[n.FLOAT_TOOLBAR_MENU_POSITION]:{[w.id]:{order:21,menuItemFactory:I}},[s.ContextMenuPosition.MAIN_AREA]:{[s.ContextMenuGroup.DATA]:{[w.id]:{order:1,menuItemFactory:I}}}},U=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._menuManagerService=t,this._initCommands(),this._initMenus()}_initCommands(){[p,m,S,w,C].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.appendRootMenu({[n.FLOAT_TOOLBAR_MENU_POSITION]:{}}),this._menuManagerService.mergeMenu(H)}};U=b([y(0,t.ICommandService),y(1,s.IMenuManagerService)],U);let W=class extends t.Plugin{constructor(e=D,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},D,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`docs-thread-comment-ui.config`,o)}onStarting(){this._injector.add([z]),this._injector.get(z),[[U],[B],[x]].forEach(e=>{this._injector.add(e)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(U)}_initRenderModule(){[V].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};v(W,`pluginName`,`DOC_THREAD_COMMENT_UI_PLUGIN`),v(W,`packageName`,T),v(W,`version`,E),v(W,`type`,t.UniverInstanceType.UNIVER_DOC),W=b([(0,t.DependentOn)(i.UniverThreadCommentUIPlugin),y(1,(0,t.Inject)(t.Injector)),y(2,o.IRenderManagerService),y(3,t.IConfigService)],W),e.AddDocCommentComment=p,e.DeleteDocCommentComment=m,e.ShowCommentPanelOperation=S,e.StartAddCommentOperation=w,Object.defineProperty(e,"UniverDocsThreadCommentUIPlugin",{enumerable:!0,get:function(){return W}})});
|
|
2
|
+
`},startOffset:b.startOffset,endOffset:b.endOffset,collapsed:!0,threadId:``};return C==null||C.blur(),_.startAdd(O),d.setActiveComment({unitId:w,subUnitId:D,commentId:``}),!0}};var T=`@univerjs/docs-thread-comment-ui`,E=`0.25.1`;let D={},O=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=n,this._docThreadCommentService=r,this._renderManagerService=i,this._threadCommentModel=a,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===a.SetTextSelectionsOperation.id){let{unitId:a,ranges:s}=n.params;if((0,t.isInternalEditorID)(a))return;let c=this._univerInstanceService.getUnit(a,t.UniverInstanceType.UNIVER_DOC),l=s[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&c){let{startOffset:e,endOffset:t,collapsed:n}=l,i;if(n){var r;i=(r=c.getBody())==null||(r=r.customDecorations)==null?void 0:r.find(n=>n.startIndex<=e&&n.endIndex>=t-1)}else{var o;i=(o=c.getBody())==null||(o=o.customDecorations)==null?void 0:o.find(n=>n.startIndex<=e&&n.endIndex>=t-1)}if(i){let e=this._threadCommentModel.getComment(a,f,i.id);e&&!e.resolved&&this._commandService.executeCommand(S.id,{activeComment:{unitId:a,subUnitId:f,commentId:i.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;let u=this._docThreadCommentService.addingComment,d=this._threadCommentPanelService.activeCommentId;if(u&&(d==null?void 0:d.unitId)===u.unitId&&(d==null?void 0:d.subUnitId)===`default_doc`&&(d==null?void 0:d.commentId)===u.id)return;this._commandService.executeCommand(i.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t;if(e){let t=this._univerInstanceService.getUnit(e.unitId);if(t){var r,i;let a=(r=this._renderManagerService.getRenderById(e.unitId))==null?void 0:r.with(n.DocBackScrollRenderController),o=(i=t.getBody())==null||(i=i.customDecorations)==null?void 0:i.find(t=>t.id===e.commentId);o&&a&&a.scrollToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1})}}(!e||e.commentId!==((t=this._docThreadCommentService.addingComment)==null?void 0:t.id))&&this._docThreadCommentService.endAdd()}))}};O=b([y(0,(0,t.Inject)(i.ThreadCommentPanelService)),y(1,t.IUniverInstanceService),y(2,t.ICommandService),y(3,(0,t.Inject)(x)),y(4,o.IRenderManagerService),y(5,(0,t.Inject)(r.ThreadCommentModel))],O);function k({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,l.useRef)(`_${N()}`);return A(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function A(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...j(e,n,i),...r},(M(e,n).children||[]).map((r,a)=>A(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function j(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function M(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function N(){return Math.random().toString(36).substring(2,8)}k.displayName=`UniverIcon`;let P={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},F=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(k,Object.assign({},e,{id:`comment-icon`,ref:t,icon:P}))});F.displayName=`CommentIcon`;let I=e=>{var n;let r=e.get(o.IRenderManagerService),i=e.get(a.DocSelectionManagerService),s=(n=(0,o.withCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_DOC,a.DocSkeletonManagerService,e.get(t.IUniverInstanceService),r))==null?void 0:n.getSkeleton(),c=s==null?void 0:s.getViewModel().getEditArea();if(c===o.DocumentEditArea.FOOTER||c===o.DocumentEditArea.HEADER)return!0;let l=i.getActiveTextRange();return!!(l==null||l.collapsed)};function L(e){return{id:w.id,type:s.MenuItemType.BUTTON,icon:`CommentIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,void 0,t.SHEET_EDITOR_UNITS),disabled$:new c.Observable(function(t){let n=e.get(a.DocSelectionManagerService).textSelection$.pipe((0,c.debounceTime)(16)).subscribe(()=>{t.next(I(e))});return()=>{n.unsubscribe()}})}}function R(e){return{id:C.id,type:s.MenuItemType.BUTTON,icon:`CommentIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let z={[s.RibbonInsertGroup.MEDIA]:{[C.id]:{order:3,menuItemFactory:R}},[s.ContextMenuPosition.MAIN_AREA]:{[s.ContextMenuGroup.DATA]:{[w.id]:{order:1,menuItemFactory:L}}}},B=()=>{let e=(0,s.useDependency)(t.IUniverInstanceService),n=(0,s.useDependency)(t.Injector),r=(0,s.useObservable)((0,l.useMemo)(()=>e.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,c.filter)(e=>!!e&&!(0,t.isInternalEditorID)(e.getUnitId()))),[e])),o=(0,l.useMemo)(()=>new c.Observable(e=>e.next(f)),[]),d=(0,s.useDependency)(a.DocSelectionManagerService);(0,s.useObservable)((0,l.useMemo)(()=>d.textSelection$.pipe((0,c.debounceTime)(16)),[d.textSelection$]));let h=(0,s.useDependency)(t.ICommandService),g=(0,s.useDependency)(x),_=(0,s.useObservable)(g.addingComment$),[v,y]=(0,l.useState)([]);if((0,l.useEffect)(()=>{var e;let t=new Set,n=r==null?void 0:r.getCustomDecorations();y((e=n==null?void 0:n.map(e=>e.id).filter(e=>{let n=t.has(e);return t.add(e),!n}))==null?[]:e);let i=h.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){var t;let e=new Set,n=r==null?void 0:r.getCustomDecorations();y((t=n==null?void 0:n.map(e=>e.id).filter(t=>{let n=e.has(t);return e.add(t),!n}))==null?[]:t)}});return()=>{i.dispose()}},[h,r]),!r)return null;let b=I(n),S=r.getUnitId();return(0,u.jsx)(i.ThreadCommentPanel,{unitId:S,subUnitId$:o,type:t.UniverInstanceType.UNIVER_DOC,onAdd:()=>{h.executeCommand(w.id)},getSubUnitName:()=>``,disableAdd:b,tempComment:_,onAddComment:e=>{if(!e.parentId){let t={unitId:S,range:_,comment:e};return h.executeCommand(p.id,t),g.endAdd(),!1}return!0},onDeleteComment:e=>{if(!e.parentId){let t={unitId:S,commentId:e.id};return h.executeCommand(m.id,t),!1}return!0},showComments:v})},V=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=n,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[p,m,S,w,C].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(z)}_initComponents(){[[d,B],[`CommentIcon`,F]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};V=b([y(0,t.ICommandService),y(1,s.IMenuManagerService),y(2,(0,t.Inject)(s.ComponentManager))],V);let H=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=n,this._docRenderController=r,this._univerInstanceService=i,this._threadCommentModel=a,this._commandService=o,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var n;if(e){this._docRenderController.reRender(e.unitId);return}let r=(n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId();r&&this._docRenderController.reRender(r)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type===`resolve`&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(a.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i,customDecorations:a}=t,{commentId:o,unitId:s}=this._threadCommentPanelService.activeCommentId||{},c=a.find(e=>e.id===o),l=this._threadCommentModel.getComment(r,f,e.id);if(!l)return n({...e,show:!1});let u=c&&i>=c.startIndex&&i<=c.endIndex,d=s===r&&e.id===o;return n({...e,active:d||u,show:!l.resolved})}})}_initSyncComments(){var e,n;let r=this._context.unit.getUnitId(),i=(e=(n=this._context.unit.getBody())==null||(n=n.customDecorations)==null?void 0:n.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))==null?[]:e;i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),`default_doc`,i);let o=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){var n,i;if(e.params.unitId!==this._context.unit.getUnitId())return;let a=(n=(i=this._context.unit.getBody())==null||(i=i.customDecorations)==null?void 0:i.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))==null?[]:n,s=a.sort();if(JSON.stringify(o)!==JSON.stringify(s)){let e=new Set(o),t=new Set;a.forEach(n=>{e.has(n)||t.add(n)}),o=s,this._threadCommentModel.syncThreadComments(r,`default_doc`,[...t])}}}))}};H=b([y(1,(0,t.Inject)(a.DocInterceptorService)),y(2,(0,t.Inject)(i.ThreadCommentPanelService)),y(3,(0,t.Inject)(n.DocRenderController)),y(4,t.IUniverInstanceService),y(5,(0,t.Inject)(r.ThreadCommentModel)),y(6,t.ICommandService)],H);let U=class extends t.Plugin{constructor(e=D,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},D,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`docs-thread-comment-ui.config`,o)}onStarting(){[[V],[O],[x]].forEach(e=>{this._injector.add(e)})}onRendered(){this._initRenderModule(),this._injector.get(O),this._injector.get(V)}_initRenderModule(){[H].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};v(U,`pluginName`,`DOC_THREAD_COMMENT_UI_PLUGIN`),v(U,`packageName`,T),v(U,`version`,E),v(U,`type`,t.UniverInstanceType.UNIVER_DOC),U=b([(0,t.DependentOn)(i.UniverThreadCommentUIPlugin),y(1,(0,t.Inject)(t.Injector)),y(2,o.IRenderManagerService),y(3,t.IConfigService)],U),e.AddDocCommentComment=p,e.DeleteDocCommentComment=m,e.ShowCommentPanelOperation=S,e.StartAddCommentOperation=w,Object.defineProperty(e,"UniverDocsThreadCommentUIPlugin",{enumerable:!0,get:function(){return U}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-thread-comment-ui",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Thread comment UI integration for Univer Docs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "1.
|
|
62
|
-
"@univerjs/docs": "0.25.
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/engine-render": "0.25.
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/ui": "0.25.
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/
|
|
61
|
+
"@univerjs/icons": "1.4.0",
|
|
62
|
+
"@univerjs/docs": "0.25.1",
|
|
63
|
+
"@univerjs/docs-ui": "0.25.1",
|
|
64
|
+
"@univerjs/engine-render": "0.25.1",
|
|
65
|
+
"@univerjs/thread-comment": "0.25.1",
|
|
66
|
+
"@univerjs/thread-comment-ui": "0.25.1",
|
|
67
|
+
"@univerjs/ui": "0.25.1",
|
|
68
|
+
"@univerjs/core": "0.25.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"postcss": "^8.5.15",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"rxjs": "^7.8.2",
|
|
74
74
|
"tailwindcss": "3.4.18",
|
|
75
75
|
"typescript": "^6.0.3",
|
|
76
|
-
"vitest": "^4.1.
|
|
77
|
-
"@univerjs-infra/shared": "0.25.
|
|
76
|
+
"vitest": "^4.1.7",
|
|
77
|
+
"@univerjs-infra/shared": "0.25.1"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"test": "vitest run",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Disposable } from '@univerjs/core';
|
|
17
|
-
import { ComponentManager, IconManager } from '@univerjs/ui';
|
|
18
|
-
export declare class ComponentsController extends Disposable {
|
|
19
|
-
private readonly _componentManager;
|
|
20
|
-
private readonly _iconManager;
|
|
21
|
-
constructor(_componentManager: ComponentManager, _iconManager: IconManager);
|
|
22
|
-
private _registerComponents;
|
|
23
|
-
private _registerIcons;
|
|
24
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { LocaleLeafKeys } from '@univerjs/core';
|
|
17
|
-
import type enUS from './en-US';
|
|
18
|
-
export type LocaleKey = LocaleLeafKeys<typeof enUS>;
|