@univerjs/docs-thread-comment-ui 1.0.0-alpha.8 → 1.0.0-beta.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/lib/cjs/index.js CHANGED
@@ -220,7 +220,7 @@ const StartAddCommentOperation = {
220
220
  id: "docs.operation.start-add-comment",
221
221
  type: _univerjs_core.CommandType.OPERATION,
222
222
  handler(accessor) {
223
- var _renderManagerService, _doc$getBody$dataStre, _doc$getBody;
223
+ var _renderManagerService, _doc$getBody;
224
224
  const panelService = accessor.get(_univerjs_thread_comment_ui.ThreadCommentPanelService);
225
225
  const doc = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
226
226
  const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
@@ -242,7 +242,7 @@ const StartAddCommentOperation = {
242
242
  }
243
243
  commandService.executeCommand(ShowCommentPanelOperation.id);
244
244
  const unitId = doc.getUnitId();
245
- const dataStream = ((_doc$getBody$dataStre = (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "").slice(textRange.startOffset, textRange.endOffset);
245
+ const dataStream = (((_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "").slice(textRange.startOffset, textRange.endOffset);
246
246
  const text = _univerjs_core.BuildTextUtils.transform.getPlainText(dataStream);
247
247
  const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
248
248
  const commentId = "";
@@ -332,7 +332,7 @@ const menuSchema = {
332
332
  //#endregion
333
333
  //#region package.json
334
334
  var name = "@univerjs/docs-thread-comment-ui";
335
- var version = "1.0.0-alpha.8";
335
+ var version = "1.0.0-beta.1";
336
336
 
337
337
  //#endregion
338
338
  //#region src/config/config.ts
@@ -355,24 +355,22 @@ const DocThreadCommentPanel = () => {
355
355
  const tempComment = (0, _univerjs_ui.useObservable)(docCommentService.addingComment$);
356
356
  const [commentIds, setCommentIds] = (0, react.useState)([]);
357
357
  (0, react.useEffect)(() => {
358
- var _customRanges$map$fil;
359
358
  const set = /* @__PURE__ */ new Set();
360
359
  const customRanges = doc === null || doc === void 0 ? void 0 : doc.getCustomDecorations();
361
- setCommentIds((_customRanges$map$fil = customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
360
+ setCommentIds((customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
362
361
  const hasRepeat = set.has(i);
363
362
  set.add(i);
364
363
  return !hasRepeat;
365
- })) !== null && _customRanges$map$fil !== void 0 ? _customRanges$map$fil : []);
364
+ })) ?? []);
366
365
  const dispose = commandService.onCommandExecuted((command) => {
367
366
  if (command.id === _univerjs_docs.RichTextEditingMutation.id) {
368
- var _customRanges$map$fil2;
369
367
  const set = /* @__PURE__ */ new Set();
370
368
  const customRanges = doc === null || doc === void 0 ? void 0 : doc.getCustomDecorations();
371
- setCommentIds((_customRanges$map$fil2 = customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
369
+ setCommentIds((customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
372
370
  const hasRepeat = set.has(i);
373
371
  set.add(i);
374
372
  return !hasRepeat;
375
- })) !== null && _customRanges$map$fil2 !== void 0 ? _customRanges$map$fil2 : []);
373
+ })) ?? []);
376
374
  }
377
375
  });
378
376
  return () => {
@@ -587,17 +585,17 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
587
585
  } });
588
586
  }
589
587
  _initSyncComments() {
590
- var _this$_context$unit$g, _this$_context$unit$g2;
588
+ var _this$_context$unit$g;
591
589
  const unitId = this._context.unit.getUnitId();
592
590
  const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
593
- const threadIds = (_this$_context$unit$g = (_this$_context$unit$g2 = this._context.unit.getBody()) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.customDecorations) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.filter((i) => i.type === _univerjs_core.CustomDecorationType.COMMENT).map((i) => i.id)) !== null && _this$_context$unit$g !== void 0 ? _this$_context$unit$g : [];
591
+ const threadIds = ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.customDecorations) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.filter((i) => i.type === _univerjs_core.CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
594
592
  threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), "default_doc", threadIds);
595
593
  let prevThreadIds = threadIds.sort();
596
594
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
597
595
  if (commandInfo.id === _univerjs_docs.RichTextEditingMutation.id) {
598
- var _this$_context$unit$g3, _this$_context$unit$g4;
596
+ var _this$_context$unit$g2;
599
597
  if (commandInfo.params.unitId !== this._context.unit.getUnitId()) return;
600
- const currentThreadIds = (_this$_context$unit$g3 = (_this$_context$unit$g4 = this._context.unit.getBody()) === null || _this$_context$unit$g4 === void 0 || (_this$_context$unit$g4 = _this$_context$unit$g4.customDecorations) === null || _this$_context$unit$g4 === void 0 ? void 0 : _this$_context$unit$g4.filter((i) => i.type === _univerjs_core.CustomDecorationType.COMMENT).map((i) => i.id)) !== null && _this$_context$unit$g3 !== void 0 ? _this$_context$unit$g3 : [];
598
+ const currentThreadIds = ((_this$_context$unit$g2 = this._context.unit.getBody()) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.customDecorations) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.filter((i) => i.type === _univerjs_core.CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
601
599
  const currentThreadIdsSorted = currentThreadIds.sort();
602
600
  if (JSON.stringify(prevThreadIds) !== JSON.stringify(currentThreadIdsSorted)) {
603
601
  const preIds = new Set(prevThreadIds);
@@ -704,7 +702,7 @@ _defineProperty(UniverDocsThreadCommentUIPlugin, "packageName", name);
704
702
  _defineProperty(UniverDocsThreadCommentUIPlugin, "version", version);
705
703
  _defineProperty(UniverDocsThreadCommentUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_DOC);
706
704
  UniverDocsThreadCommentUIPlugin = __decorate([
707
- (0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_ui.UniverUIPlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin),
705
+ (0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin),
708
706
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
709
707
  __decorateParam(2, _univerjs_engine_render.IRenderManagerService),
710
708
  __decorateParam(3, _univerjs_core.IConfigService)
package/lib/es/index.js CHANGED
@@ -4,7 +4,7 @@ import { AddCommentMutation, IThreadCommentDataSourceService, ThreadCommentModel
4
4
  import { SetActiveCommentOperation, ThreadCommentPanel, ThreadCommentPanelService, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
5
5
  import { DOC_INTERCEPTOR_POINT, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin } from "@univerjs/docs";
6
6
  import { DocumentEditArea, IRenderManagerService, UniverRenderEnginePlugin, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
7
- import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonInsertGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
7
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
8
8
  import { BehaviorSubject, Observable, debounceTime, filter, map } from "rxjs";
9
9
  import { CommentIcon } from "@univerjs/icons";
10
10
  import { useEffect, useMemo, useState } from "react";
@@ -219,7 +219,7 @@ const StartAddCommentOperation = {
219
219
  id: "docs.operation.start-add-comment",
220
220
  type: CommandType.OPERATION,
221
221
  handler(accessor) {
222
- var _renderManagerService, _doc$getBody$dataStre, _doc$getBody;
222
+ var _renderManagerService, _doc$getBody;
223
223
  const panelService = accessor.get(ThreadCommentPanelService);
224
224
  const doc = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
225
225
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
@@ -241,7 +241,7 @@ const StartAddCommentOperation = {
241
241
  }
242
242
  commandService.executeCommand(ShowCommentPanelOperation.id);
243
243
  const unitId = doc.getUnitId();
244
- const dataStream = ((_doc$getBody$dataStre = (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "").slice(textRange.startOffset, textRange.endOffset);
244
+ const dataStream = (((_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "").slice(textRange.startOffset, textRange.endOffset);
245
245
  const text = BuildTextUtils.transform.getPlainText(dataStream);
246
246
  const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
247
247
  const commentId = "";
@@ -331,7 +331,7 @@ const menuSchema = {
331
331
  //#endregion
332
332
  //#region package.json
333
333
  var name = "@univerjs/docs-thread-comment-ui";
334
- var version = "1.0.0-alpha.8";
334
+ var version = "1.0.0-beta.1";
335
335
 
336
336
  //#endregion
337
337
  //#region src/config/config.ts
@@ -354,24 +354,22 @@ const DocThreadCommentPanel = () => {
354
354
  const tempComment = useObservable(docCommentService.addingComment$);
355
355
  const [commentIds, setCommentIds] = useState([]);
356
356
  useEffect(() => {
357
- var _customRanges$map$fil;
358
357
  const set = /* @__PURE__ */ new Set();
359
358
  const customRanges = doc === null || doc === void 0 ? void 0 : doc.getCustomDecorations();
360
- setCommentIds((_customRanges$map$fil = customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
359
+ setCommentIds((customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
361
360
  const hasRepeat = set.has(i);
362
361
  set.add(i);
363
362
  return !hasRepeat;
364
- })) !== null && _customRanges$map$fil !== void 0 ? _customRanges$map$fil : []);
363
+ })) ?? []);
365
364
  const dispose = commandService.onCommandExecuted((command) => {
366
365
  if (command.id === RichTextEditingMutation.id) {
367
- var _customRanges$map$fil2;
368
366
  const set = /* @__PURE__ */ new Set();
369
367
  const customRanges = doc === null || doc === void 0 ? void 0 : doc.getCustomDecorations();
370
- setCommentIds((_customRanges$map$fil2 = customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
368
+ setCommentIds((customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
371
369
  const hasRepeat = set.has(i);
372
370
  set.add(i);
373
371
  return !hasRepeat;
374
- })) !== null && _customRanges$map$fil2 !== void 0 ? _customRanges$map$fil2 : []);
372
+ })) ?? []);
375
373
  }
376
374
  });
377
375
  return () => {
@@ -586,17 +584,17 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
586
584
  } });
587
585
  }
588
586
  _initSyncComments() {
589
- var _this$_context$unit$g, _this$_context$unit$g2;
587
+ var _this$_context$unit$g;
590
588
  const unitId = this._context.unit.getUnitId();
591
589
  const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
592
- const threadIds = (_this$_context$unit$g = (_this$_context$unit$g2 = this._context.unit.getBody()) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.customDecorations) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) !== null && _this$_context$unit$g !== void 0 ? _this$_context$unit$g : [];
590
+ const threadIds = ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.customDecorations) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
593
591
  threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), "default_doc", threadIds);
594
592
  let prevThreadIds = threadIds.sort();
595
593
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
596
594
  if (commandInfo.id === RichTextEditingMutation.id) {
597
- var _this$_context$unit$g3, _this$_context$unit$g4;
595
+ var _this$_context$unit$g2;
598
596
  if (commandInfo.params.unitId !== this._context.unit.getUnitId()) return;
599
- const currentThreadIds = (_this$_context$unit$g3 = (_this$_context$unit$g4 = this._context.unit.getBody()) === null || _this$_context$unit$g4 === void 0 || (_this$_context$unit$g4 = _this$_context$unit$g4.customDecorations) === null || _this$_context$unit$g4 === void 0 ? void 0 : _this$_context$unit$g4.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) !== null && _this$_context$unit$g3 !== void 0 ? _this$_context$unit$g3 : [];
597
+ const currentThreadIds = ((_this$_context$unit$g2 = this._context.unit.getBody()) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.customDecorations) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
600
598
  const currentThreadIdsSorted = currentThreadIds.sort();
601
599
  if (JSON.stringify(prevThreadIds) !== JSON.stringify(currentThreadIdsSorted)) {
602
600
  const preIds = new Set(prevThreadIds);
@@ -703,7 +701,7 @@ _defineProperty(UniverDocsThreadCommentUIPlugin, "packageName", name);
703
701
  _defineProperty(UniverDocsThreadCommentUIPlugin, "version", version);
704
702
  _defineProperty(UniverDocsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
705
703
  UniverDocsThreadCommentUIPlugin = __decorate([
706
- DependentOn(UniverDocsPlugin, UniverThreadCommentPlugin, UniverRenderEnginePlugin, UniverUIPlugin, UniverDocsUIPlugin, UniverThreadCommentUIPlugin),
704
+ DependentOn(UniverDocsPlugin, UniverThreadCommentPlugin, UniverRenderEnginePlugin, UniverDocsUIPlugin, UniverThreadCommentUIPlugin),
707
705
  __decorateParam(1, Inject(Injector)),
708
706
  __decorateParam(2, IRenderManagerService),
709
707
  __decorateParam(3, IConfigService)
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { AddCommentMutation, IThreadCommentDataSourceService, ThreadCommentModel
4
4
  import { SetActiveCommentOperation, ThreadCommentPanel, ThreadCommentPanelService, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
5
5
  import { DOC_INTERCEPTOR_POINT, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin } from "@univerjs/docs";
6
6
  import { DocumentEditArea, IRenderManagerService, UniverRenderEnginePlugin, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
7
- import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonInsertGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
7
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
8
8
  import { BehaviorSubject, Observable, debounceTime, filter, map } from "rxjs";
9
9
  import { CommentIcon } from "@univerjs/icons";
10
10
  import { useEffect, useMemo, useState } from "react";
@@ -219,7 +219,7 @@ const StartAddCommentOperation = {
219
219
  id: "docs.operation.start-add-comment",
220
220
  type: CommandType.OPERATION,
221
221
  handler(accessor) {
222
- var _renderManagerService, _doc$getBody$dataStre, _doc$getBody;
222
+ var _renderManagerService, _doc$getBody;
223
223
  const panelService = accessor.get(ThreadCommentPanelService);
224
224
  const doc = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
225
225
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
@@ -241,7 +241,7 @@ const StartAddCommentOperation = {
241
241
  }
242
242
  commandService.executeCommand(ShowCommentPanelOperation.id);
243
243
  const unitId = doc.getUnitId();
244
- const dataStream = ((_doc$getBody$dataStre = (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "").slice(textRange.startOffset, textRange.endOffset);
244
+ const dataStream = (((_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "").slice(textRange.startOffset, textRange.endOffset);
245
245
  const text = BuildTextUtils.transform.getPlainText(dataStream);
246
246
  const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
247
247
  const commentId = "";
@@ -331,7 +331,7 @@ const menuSchema = {
331
331
  //#endregion
332
332
  //#region package.json
333
333
  var name = "@univerjs/docs-thread-comment-ui";
334
- var version = "1.0.0-alpha.8";
334
+ var version = "1.0.0-beta.1";
335
335
 
336
336
  //#endregion
337
337
  //#region src/config/config.ts
@@ -354,24 +354,22 @@ const DocThreadCommentPanel = () => {
354
354
  const tempComment = useObservable(docCommentService.addingComment$);
355
355
  const [commentIds, setCommentIds] = useState([]);
356
356
  useEffect(() => {
357
- var _customRanges$map$fil;
358
357
  const set = /* @__PURE__ */ new Set();
359
358
  const customRanges = doc === null || doc === void 0 ? void 0 : doc.getCustomDecorations();
360
- setCommentIds((_customRanges$map$fil = customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
359
+ setCommentIds((customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
361
360
  const hasRepeat = set.has(i);
362
361
  set.add(i);
363
362
  return !hasRepeat;
364
- })) !== null && _customRanges$map$fil !== void 0 ? _customRanges$map$fil : []);
363
+ })) ?? []);
365
364
  const dispose = commandService.onCommandExecuted((command) => {
366
365
  if (command.id === RichTextEditingMutation.id) {
367
- var _customRanges$map$fil2;
368
366
  const set = /* @__PURE__ */ new Set();
369
367
  const customRanges = doc === null || doc === void 0 ? void 0 : doc.getCustomDecorations();
370
- setCommentIds((_customRanges$map$fil2 = customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
368
+ setCommentIds((customRanges === null || customRanges === void 0 ? void 0 : customRanges.map((r) => r.id).filter((i) => {
371
369
  const hasRepeat = set.has(i);
372
370
  set.add(i);
373
371
  return !hasRepeat;
374
- })) !== null && _customRanges$map$fil2 !== void 0 ? _customRanges$map$fil2 : []);
372
+ })) ?? []);
375
373
  }
376
374
  });
377
375
  return () => {
@@ -586,17 +584,17 @@ let DocThreadCommentRenderController = class DocThreadCommentRenderController ex
586
584
  } });
587
585
  }
588
586
  _initSyncComments() {
589
- var _this$_context$unit$g, _this$_context$unit$g2;
587
+ var _this$_context$unit$g;
590
588
  const unitId = this._context.unit.getUnitId();
591
589
  const subUnitId = DEFAULT_DOC_SUBUNIT_ID;
592
- const threadIds = (_this$_context$unit$g = (_this$_context$unit$g2 = this._context.unit.getBody()) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.customDecorations) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) !== null && _this$_context$unit$g !== void 0 ? _this$_context$unit$g : [];
590
+ const threadIds = ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.customDecorations) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
593
591
  threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), "default_doc", threadIds);
594
592
  let prevThreadIds = threadIds.sort();
595
593
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
596
594
  if (commandInfo.id === RichTextEditingMutation.id) {
597
- var _this$_context$unit$g3, _this$_context$unit$g4;
595
+ var _this$_context$unit$g2;
598
596
  if (commandInfo.params.unitId !== this._context.unit.getUnitId()) return;
599
- const currentThreadIds = (_this$_context$unit$g3 = (_this$_context$unit$g4 = this._context.unit.getBody()) === null || _this$_context$unit$g4 === void 0 || (_this$_context$unit$g4 = _this$_context$unit$g4.customDecorations) === null || _this$_context$unit$g4 === void 0 ? void 0 : _this$_context$unit$g4.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) !== null && _this$_context$unit$g3 !== void 0 ? _this$_context$unit$g3 : [];
597
+ const currentThreadIds = ((_this$_context$unit$g2 = this._context.unit.getBody()) === null || _this$_context$unit$g2 === void 0 || (_this$_context$unit$g2 = _this$_context$unit$g2.customDecorations) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) ?? [];
600
598
  const currentThreadIdsSorted = currentThreadIds.sort();
601
599
  if (JSON.stringify(prevThreadIds) !== JSON.stringify(currentThreadIdsSorted)) {
602
600
  const preIds = new Set(prevThreadIds);
@@ -703,7 +701,7 @@ _defineProperty(UniverDocsThreadCommentUIPlugin, "packageName", name);
703
701
  _defineProperty(UniverDocsThreadCommentUIPlugin, "version", version);
704
702
  _defineProperty(UniverDocsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
705
703
  UniverDocsThreadCommentUIPlugin = __decorate([
706
- DependentOn(UniverDocsPlugin, UniverThreadCommentPlugin, UniverRenderEnginePlugin, UniverUIPlugin, UniverDocsUIPlugin, UniverThreadCommentUIPlugin),
704
+ DependentOn(UniverDocsPlugin, UniverThreadCommentPlugin, UniverRenderEnginePlugin, UniverDocsUIPlugin, UniverThreadCommentUIPlugin),
707
705
  __decorateParam(1, Inject(Injector)),
708
706
  __decorateParam(2, IRenderManagerService),
709
707
  __decorateParam(3, IConfigService)
package/lib/umd/index.js CHANGED
@@ -1,2 +1,2 @@
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.getRenderUnitById(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}},T=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 E(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(T(e))});return()=>{n.unsubscribe()}})}}function D(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 O={[s.RibbonInsertGroup.MEDIA]:{[C.id]:{order:3,menuItemFactory:D}},[n.FLOAT_TOOLBAR_MENU_POSITION]:{[w.id]:{order:21,menuItemFactory:E}},[s.ContextMenuPosition.MAIN_AREA]:{[s.ContextMenuGroup.DATA]:{[w.id]:{order:1,menuItemFactory:E}}}};var k=`@univerjs/docs-thread-comment-ui`,A=`1.0.0-alpha.8`;let j={};function M({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)(`_${I()}`);return N(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function N(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...P(e,n,i),...r},(F(e,n).children||[]).map((r,a)=>N(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function P(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 F(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 I(){return Math.random().toString(36).substring(2,8)}M.displayName=`UniverIcon`;let L={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`}}]},R=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`comment-icon`,ref:t,icon:L}))});R.displayName=`CommentIcon`;let z=()=>{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),h=(0,l.useMemo)(()=>d.textSelection$.pipe((0,c.debounceTime)(16)),[d.textSelection$]),g=(0,s.useObservable)(()=>h.pipe((0,c.map)(()=>T(n))),T(n),!1,[n,h]),_=(0,s.useDependency)(t.ICommandService),v=(0,s.useDependency)(x),y=(0,s.useObservable)(v.addingComment$),[b,S]=(0,l.useState)([]);if((0,l.useEffect)(()=>{var e;let t=new Set,n=r==null?void 0:r.getCustomDecorations();S((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=_.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){var t;let e=new Set,n=r==null?void 0:r.getCustomDecorations();S((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()}},[_,r]),!r)return null;let C=r.getUnitId();return(0,u.jsx)(i.ThreadCommentPanel,{unitId:C,subUnitId$:o,type:t.UniverInstanceType.UNIVER_DOC,onAdd:()=>{_.executeCommand(w.id)},getSubUnitName:()=>``,disableAdd:g,tempComment:y,onAddComment:e=>{if(!e.parentId){let t={unitId:C,range:y,comment:e};return _.executeCommand(p.id,t),v.endAdd(),!1}return!0},onDeleteComment:e=>{if(!e.parentId){let t={unitId:C,commentId:e.id};return _.executeCommand(m.id,t),!1}return!0},showComments:b})},B=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[d,z]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({CommentIcon:R}))}};B=b([y(0,(0,t.Inject)(s.ComponentManager)),y(1,(0,t.Inject)(s.IconManager))],B);let V=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.getRenderUnitById(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()}))}};V=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))],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.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(O)}};U=b([y(0,t.ICommandService),y(1,s.IMenuManagerService)],U);let W=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},j,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`docs-thread-comment-ui.config`,o)}onStarting(){this._injector.add([B]),this._injector.get(B),[[U],[V],[x]].forEach(e=>{this._injector.add(e)})}onRendered(){this._initRenderModule(),this._injector.get(V),this._injector.get(U)}_initRenderModule(){[H].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};v(W,`pluginName`,`DOC_THREAD_COMMENT_UI_PLUGIN`),v(W,`packageName`,k),v(W,`version`,A),v(W,`type`,t.UniverInstanceType.UNIVER_DOC),W=b([(0,t.DependentOn)(a.UniverDocsPlugin,r.UniverThreadCommentPlugin,o.UniverRenderEnginePlugin,s.UniverUIPlugin,n.UniverDocsUIPlugin,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.DocsThreadCommentUIMenuSchema=O,e.ShowCommentPanelOperation=S,e.StartAddCommentOperation=w,Object.defineProperty(e,"UniverDocsThreadCommentUIPlugin",{enumerable:!0,get:function(){return W}})});
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;let u=e.get(i.ThreadCommentPanelService),d=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),p=e.get(a.DocSelectionManagerService),m=e.get(o.IRenderManagerService),h=e.get(t.UserManagerService),g=e.get(x),_=e.get(t.ICommandService),v=e.get(s.ISidebarService),y=p.getActiveTextRange();if(!d||!y)return!1;let b=(c=m.getRenderUnitById(d.getUnitId()))==null?void 0:c.with(n.DocSelectionRenderService);if(b==null||b.setReserveRangesStatus(!0),y.collapsed)return u.panelVisible?(u.setPanelVisible(!1),v.close()):_.executeCommand(S.id),!0;_.executeCommand(S.id);let C=d.getUnitId(),w=(((l=d.getBody())==null?void 0:l.dataStream)??``).slice(y.startOffset,y.endOffset),T=t.BuildTextUtils.transform.getPlainText(w),E=f,D={unitId:C,subUnitId:E,id:``,ref:T,dT:(0,r.getDT)(),personId:h.getCurrentUser().userID,text:{dataStream:`\r
2
+ `},startOffset:y.startOffset,endOffset:y.endOffset,collapsed:!0,threadId:``};return b==null||b.blur(),g.startAdd(D),u.setActiveComment({unitId:C,subUnitId:E,commentId:``}),!0}},T=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 E(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(T(e))});return()=>{n.unsubscribe()}})}}function D(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 O={[s.RibbonInsertGroup.MEDIA]:{[C.id]:{order:3,menuItemFactory:D}},[n.FLOAT_TOOLBAR_MENU_POSITION]:{[w.id]:{order:21,menuItemFactory:E}},[s.ContextMenuPosition.MAIN_AREA]:{[s.ContextMenuGroup.DATA]:{[w.id]:{order:1,menuItemFactory:E}}}};var k=`@univerjs/docs-thread-comment-ui`,A=`1.0.0-beta.1`;let j={};function M({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)(`_${I()}`);return N(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function N(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...P(e,n,i),...r},(F(e,n).children||[]).map((r,a)=>N(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function P(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 F(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 I(){return Math.random().toString(36).substring(2,8)}M.displayName=`UniverIcon`;let L={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`}}]},R=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`comment-icon`,ref:t,icon:L}))});R.displayName=`CommentIcon`;let z=()=>{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),h=(0,l.useMemo)(()=>d.textSelection$.pipe((0,c.debounceTime)(16)),[d.textSelection$]),g=(0,s.useObservable)(()=>h.pipe((0,c.map)(()=>T(n))),T(n),!1,[n,h]),_=(0,s.useDependency)(t.ICommandService),v=(0,s.useDependency)(x),y=(0,s.useObservable)(v.addingComment$),[b,S]=(0,l.useState)([]);if((0,l.useEffect)(()=>{let e=new Set,t=r==null?void 0:r.getCustomDecorations();S((t==null?void 0:t.map(e=>e.id).filter(t=>{let n=e.has(t);return e.add(t),!n}))??[]);let n=_.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){let e=new Set,t=r==null?void 0:r.getCustomDecorations();S((t==null?void 0:t.map(e=>e.id).filter(t=>{let n=e.has(t);return e.add(t),!n}))??[])}});return()=>{n.dispose()}},[_,r]),!r)return null;let C=r.getUnitId();return(0,u.jsx)(i.ThreadCommentPanel,{unitId:C,subUnitId$:o,type:t.UniverInstanceType.UNIVER_DOC,onAdd:()=>{_.executeCommand(w.id)},getSubUnitName:()=>``,disableAdd:g,tempComment:y,onAddComment:e=>{if(!e.parentId){let t={unitId:C,range:y,comment:e};return _.executeCommand(p.id,t),v.endAdd(),!1}return!0},onDeleteComment:e=>{if(!e.parentId){let t={unitId:C,commentId:e.id};return _.executeCommand(m.id,t),!1}return!0},showComments:b})},B=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[d,z]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({CommentIcon:R}))}};B=b([y(0,(0,t.Inject)(s.ComponentManager)),y(1,(0,t.Inject)(s.IconManager))],B);let V=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.getRenderUnitById(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()}))}};V=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))],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;let n=this._context.unit.getUnitId(),r=((e=this._context.unit.getBody())==null||(e=e.customDecorations)==null?void 0:e.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))??[];r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),`default_doc`,r);let i=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===a.RichTextEditingMutation.id){var r;if(e.params.unitId!==this._context.unit.getUnitId())return;let a=((r=this._context.unit.getBody())==null||(r=r.customDecorations)==null?void 0:r.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))??[],o=a.sort();if(JSON.stringify(i)!==JSON.stringify(o)){let e=new Set(i),t=new Set;a.forEach(n=>{e.has(n)||t.add(n)}),i=o,this._threadCommentModel.syncThreadComments(n,`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.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(O)}};U=b([y(0,t.ICommandService),y(1,s.IMenuManagerService)],U);let W=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},j,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`docs-thread-comment-ui.config`,o)}onStarting(){this._injector.add([B]),this._injector.get(B),[[U],[V],[x]].forEach(e=>{this._injector.add(e)})}onRendered(){this._initRenderModule(),this._injector.get(V),this._injector.get(U)}_initRenderModule(){[H].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};v(W,`pluginName`,`DOC_THREAD_COMMENT_UI_PLUGIN`),v(W,`packageName`,k),v(W,`version`,A),v(W,`type`,t.UniverInstanceType.UNIVER_DOC),W=b([(0,t.DependentOn)(a.UniverDocsPlugin,r.UniverThreadCommentPlugin,o.UniverRenderEnginePlugin,n.UniverDocsUIPlugin,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.DocsThreadCommentUIMenuSchema=O,e.ShowCommentPanelOperation=S,e.StartAddCommentOperation=w,Object.defineProperty(e,"UniverDocsThreadCommentUIPlugin",{enumerable:!0,get:function(){return W}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-thread-comment-ui",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0-beta.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,23 +58,23 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/icons": "1.34.0",
62
- "@univerjs/docs": "1.0.0-alpha.8",
63
- "@univerjs/core": "1.0.0-alpha.8",
64
- "@univerjs/engine-render": "1.0.0-alpha.8",
65
- "@univerjs/thread-comment": "1.0.0-alpha.8",
66
- "@univerjs/thread-comment-ui": "1.0.0-alpha.8",
67
- "@univerjs/ui": "1.0.0-alpha.8",
68
- "@univerjs/docs-ui": "1.0.0-alpha.8"
61
+ "@univerjs/icons": "1.35.0",
62
+ "@univerjs/core": "1.0.0-beta.1",
63
+ "@univerjs/docs-ui": "1.0.0-beta.1",
64
+ "@univerjs/docs": "1.0.0-beta.1",
65
+ "@univerjs/engine-render": "1.0.0-beta.1",
66
+ "@univerjs/thread-comment": "1.0.0-beta.1",
67
+ "@univerjs/thread-comment-ui": "1.0.0-beta.1",
68
+ "@univerjs/ui": "1.0.0-beta.1"
69
69
  },
70
70
  "devDependencies": {
71
- "postcss": "^8.5.23",
71
+ "postcss": "^8.5.25",
72
72
  "react": "18.3.1",
73
73
  "rxjs": "^7.8.2",
74
74
  "tailwindcss": "3.4.18",
75
75
  "typescript": "^6.0.3",
76
76
  "vitest": "^4.1.10",
77
- "@univerjs-infra/shared": "1.0.0-alpha.8"
77
+ "@univerjs-infra/shared": "1.0.0-beta.1"
78
78
  },
79
79
  "scripts": {
80
80
  "test": "vitest run",