@univerjs/sheets-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
@@ -280,7 +280,7 @@ const menuSchema = {
280
280
  //#endregion
281
281
  //#region package.json
282
282
  var name = "@univerjs/sheets-thread-comment-ui";
283
- var version = "1.0.0-alpha.8";
283
+ var version = "1.0.0-beta.1";
284
284
 
285
285
  //#endregion
286
286
  //#region src/config/config.ts
@@ -303,8 +303,8 @@ const SheetsThreadCommentCell = () => {
303
303
  sheetsThreadCommentPopupService.hidePopup();
304
304
  };
305
305
  const getSubUnitName = (id) => {
306
- var _univerInstanceServic, _univerInstanceServic2;
307
- return (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic2 = _univerInstanceServic2.getSheetBySheetId(id)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getName()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : "";
306
+ var _univerInstanceServic;
307
+ return ((_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(id)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "";
308
308
  };
309
309
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_thread_comment_ui.ThreadCommentTree, {
310
310
  onClick: () => {
@@ -346,10 +346,9 @@ const SheetsThreadCommentPanel = () => {
346
346
  });
347
347
  const sort = (comments) => {
348
348
  return comments.map((comment) => {
349
- var _sheetIndex$comment$s;
350
349
  const ref = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
351
350
  const p = [
352
- (_sheetIndex$comment$s = sheetIndex[comment.subUnitId]) !== null && _sheetIndex$comment$s !== void 0 ? _sheetIndex$comment$s : 0,
351
+ sheetIndex[comment.subUnitId] ?? 0,
353
352
  ref.row,
354
353
  ref.column
355
354
  ];
@@ -369,10 +368,9 @@ const SheetsThreadCommentPanel = () => {
369
368
  }, [workbook]);
370
369
  const showShape = (0, react.useCallback)((comment) => {
371
370
  if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
372
- var _worksheet$getMergedC;
373
371
  const { row, column } = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
374
372
  const worksheet = workbook.getSheetBySheetId(comment.subUnitId);
375
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
373
+ const mergeInfo = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) ?? {
376
374
  startColumn: column,
377
375
  endColumn: column,
378
376
  startRow: row,
@@ -396,8 +394,8 @@ const SheetsThreadCommentPanel = () => {
396
394
  unitId
397
395
  ]);
398
396
  const getSubUnitName = (id) => {
399
- var _workbook$getSheetByS, _workbook$getSheetByS2;
400
- return (_workbook$getSheetByS = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName()) !== null && _workbook$getSheetByS !== void 0 ? _workbook$getSheetByS : "";
397
+ var _workbook$getSheetByS;
398
+ return ((_workbook$getSheetByS = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName()) ?? "";
401
399
  };
402
400
  const handleAdd = () => {
403
401
  commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
@@ -820,14 +818,14 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
820
818
  this._initEditorBridge();
821
819
  }
822
820
  _handleSelectionChange(selections, unitId, subUnitId) {
823
- var _selections$, _render$with$getSkele, _range$rangeType;
821
+ var _selections$, _render$with$getSkele;
824
822
  const range = (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.range;
825
823
  const render = this._renderManagerService.getRenderUnitById(unitId);
826
824
  const skeleton = render === null || render === void 0 || (_render$with$getSkele = render.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele === void 0 ? void 0 : _render$with$getSkele.skeleton;
827
825
  if (!skeleton) return;
828
826
  if (!range) return;
829
827
  const actualCell = skeleton.getCellWithCoordByIndex(range.startRow, range.startColumn);
830
- if ((((_range$rangeType = range.rangeType) !== null && _range$rangeType !== void 0 ? _range$rangeType : _univerjs_core.RANGE_TYPE.NORMAL) !== _univerjs_core.RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && _univerjs_core.Rectangle.equals(actualCell.mergeInfo, range))) {
828
+ if (((range.rangeType ?? _univerjs_core.RANGE_TYPE.NORMAL) !== _univerjs_core.RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && _univerjs_core.Rectangle.equals(actualCell.mergeInfo, range))) {
831
829
  if (this._threadCommentPanelService.activeCommentId) this._commandService.executeCommand(_univerjs_thread_comment_ui.SetActiveCommentOperation.id);
832
830
  return;
833
831
  }
@@ -917,7 +915,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
917
915
  }
918
916
  _initMarkSelection() {
919
917
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe((0, rxjs.debounceTime)(100)).subscribe((activeComment) => {
920
- var _this$_univerInstance, _worksheet$getMergedC;
918
+ var _this$_univerInstance;
921
919
  if (!activeComment) {
922
920
  if (this._selectionShapeInfo) {
923
921
  this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId);
@@ -935,7 +933,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
935
933
  const { row, column } = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
936
934
  if (Number.isNaN(row) || Number.isNaN(column)) return null;
937
935
  const worksheet = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
938
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
936
+ const mergeInfo = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) ?? {
939
937
  startColumn: column,
940
938
  endColumn: column,
941
939
  startRow: row,
@@ -1053,7 +1051,7 @@ _defineProperty(UniverSheetsThreadCommentUIPlugin, "packageName", name);
1053
1051
  _defineProperty(UniverSheetsThreadCommentUIPlugin, "version", version);
1054
1052
  _defineProperty(UniverSheetsThreadCommentUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
1055
1053
  UniverSheetsThreadCommentUIPlugin = __decorate([
1056
- (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverUIPlugin, _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin, _univerjs_sheets_thread_comment.UniverSheetsThreadCommentPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
1054
+ (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin, _univerjs_sheets_thread_comment.UniverSheetsThreadCommentPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
1057
1055
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
1058
1056
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
1059
1057
  __decorateParam(3, _univerjs_core.IConfigService)
package/lib/es/index.js CHANGED
@@ -2,7 +2,7 @@ import { CommandType, DependentOn, Disposable, DisposableCollection, ICommandSer
2
2
  import { INTERCEPTOR_POINT, RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCommentPermission, WorksheetViewPermission, getSheetCommandTarget } from "@univerjs/sheets";
3
3
  import { SheetsThreadCommentModel, UniverSheetsThreadCommentPlugin } from "@univerjs/sheets-thread-comment";
4
4
  import { SetActiveCommentOperation, ThreadCommentPanel, ThreadCommentPanelService, ThreadCommentTree, ThreadCommentTreeLocation, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
5
- import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IShortcutService, ISidebarService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
5
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IShortcutService, ISidebarService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
6
6
  import { COPY_TYPE, CellPopupManagerService, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ScrollToRangeOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCurrentRangeDisable$, whenSheetEditorFocused } from "@univerjs/sheets-ui";
7
7
  import { BehaviorSubject, debounceTime, map, startWith } from "rxjs";
8
8
  import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
@@ -279,7 +279,7 @@ const menuSchema = {
279
279
  //#endregion
280
280
  //#region package.json
281
281
  var name = "@univerjs/sheets-thread-comment-ui";
282
- var version = "1.0.0-alpha.8";
282
+ var version = "1.0.0-beta.1";
283
283
 
284
284
  //#endregion
285
285
  //#region src/config/config.ts
@@ -302,8 +302,8 @@ const SheetsThreadCommentCell = () => {
302
302
  sheetsThreadCommentPopupService.hidePopup();
303
303
  };
304
304
  const getSubUnitName = (id) => {
305
- var _univerInstanceServic, _univerInstanceServic2;
306
- return (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic2 = _univerInstanceServic2.getSheetBySheetId(id)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getName()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : "";
305
+ var _univerInstanceServic;
306
+ return ((_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(id)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "";
307
307
  };
308
308
  return /* @__PURE__ */ jsx(ThreadCommentTree, {
309
309
  onClick: () => {
@@ -345,10 +345,9 @@ const SheetsThreadCommentPanel = () => {
345
345
  });
346
346
  const sort = (comments) => {
347
347
  return comments.map((comment) => {
348
- var _sheetIndex$comment$s;
349
348
  const ref = singleReferenceToGrid(comment.ref);
350
349
  const p = [
351
- (_sheetIndex$comment$s = sheetIndex[comment.subUnitId]) !== null && _sheetIndex$comment$s !== void 0 ? _sheetIndex$comment$s : 0,
350
+ sheetIndex[comment.subUnitId] ?? 0,
352
351
  ref.row,
353
352
  ref.column
354
353
  ];
@@ -368,10 +367,9 @@ const SheetsThreadCommentPanel = () => {
368
367
  }, [workbook]);
369
368
  const showShape = useCallback((comment) => {
370
369
  if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
371
- var _worksheet$getMergedC;
372
370
  const { row, column } = singleReferenceToGrid(comment.ref);
373
371
  const worksheet = workbook.getSheetBySheetId(comment.subUnitId);
374
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
372
+ const mergeInfo = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) ?? {
375
373
  startColumn: column,
376
374
  endColumn: column,
377
375
  startRow: row,
@@ -395,8 +393,8 @@ const SheetsThreadCommentPanel = () => {
395
393
  unitId
396
394
  ]);
397
395
  const getSubUnitName = (id) => {
398
- var _workbook$getSheetByS, _workbook$getSheetByS2;
399
- return (_workbook$getSheetByS = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName()) !== null && _workbook$getSheetByS !== void 0 ? _workbook$getSheetByS : "";
396
+ var _workbook$getSheetByS;
397
+ return ((_workbook$getSheetByS = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName()) ?? "";
400
398
  };
401
399
  const handleAdd = () => {
402
400
  commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
@@ -819,14 +817,14 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
819
817
  this._initEditorBridge();
820
818
  }
821
819
  _handleSelectionChange(selections, unitId, subUnitId) {
822
- var _selections$, _render$with$getSkele, _range$rangeType;
820
+ var _selections$, _render$with$getSkele;
823
821
  const range = (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.range;
824
822
  const render = this._renderManagerService.getRenderUnitById(unitId);
825
823
  const skeleton = render === null || render === void 0 || (_render$with$getSkele = render.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele === void 0 ? void 0 : _render$with$getSkele.skeleton;
826
824
  if (!skeleton) return;
827
825
  if (!range) return;
828
826
  const actualCell = skeleton.getCellWithCoordByIndex(range.startRow, range.startColumn);
829
- if ((((_range$rangeType = range.rangeType) !== null && _range$rangeType !== void 0 ? _range$rangeType : RANGE_TYPE.NORMAL) !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && Rectangle.equals(actualCell.mergeInfo, range))) {
827
+ if (((range.rangeType ?? RANGE_TYPE.NORMAL) !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && Rectangle.equals(actualCell.mergeInfo, range))) {
830
828
  if (this._threadCommentPanelService.activeCommentId) this._commandService.executeCommand(SetActiveCommentOperation.id);
831
829
  return;
832
830
  }
@@ -916,7 +914,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
916
914
  }
917
915
  _initMarkSelection() {
918
916
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(debounceTime(100)).subscribe((activeComment) => {
919
- var _this$_univerInstance, _worksheet$getMergedC;
917
+ var _this$_univerInstance;
920
918
  if (!activeComment) {
921
919
  if (this._selectionShapeInfo) {
922
920
  this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId);
@@ -934,7 +932,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
934
932
  const { row, column } = singleReferenceToGrid(comment.ref);
935
933
  if (Number.isNaN(row) || Number.isNaN(column)) return null;
936
934
  const worksheet = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
937
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
935
+ const mergeInfo = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) ?? {
938
936
  startColumn: column,
939
937
  endColumn: column,
940
938
  startRow: row,
@@ -1052,7 +1050,7 @@ _defineProperty(UniverSheetsThreadCommentUIPlugin, "packageName", name);
1052
1050
  _defineProperty(UniverSheetsThreadCommentUIPlugin, "version", version);
1053
1051
  _defineProperty(UniverSheetsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1054
1052
  UniverSheetsThreadCommentUIPlugin = __decorate([
1055
- DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverSheetsPlugin, UniverUIPlugin, UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin, UniverSheetsUIPlugin),
1053
+ DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverSheetsPlugin, UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin, UniverSheetsUIPlugin),
1056
1054
  __decorateParam(1, Inject(Injector)),
1057
1055
  __decorateParam(2, Inject(ICommandService)),
1058
1056
  __decorateParam(3, IConfigService)
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { CommandType, DependentOn, Disposable, DisposableCollection, ICommandSer
2
2
  import { INTERCEPTOR_POINT, RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCommentPermission, WorksheetViewPermission, getSheetCommandTarget } from "@univerjs/sheets";
3
3
  import { SheetsThreadCommentModel, UniverSheetsThreadCommentPlugin } from "@univerjs/sheets-thread-comment";
4
4
  import { SetActiveCommentOperation, ThreadCommentPanel, ThreadCommentPanelService, ThreadCommentTree, ThreadCommentTreeLocation, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
5
- import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IShortcutService, ISidebarService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
5
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IMenuManagerService, IShortcutService, ISidebarService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
6
6
  import { COPY_TYPE, CellPopupManagerService, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ScrollToRangeOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCurrentRangeDisable$, whenSheetEditorFocused } from "@univerjs/sheets-ui";
7
7
  import { BehaviorSubject, debounceTime, map, startWith } from "rxjs";
8
8
  import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
@@ -279,7 +279,7 @@ const menuSchema = {
279
279
  //#endregion
280
280
  //#region package.json
281
281
  var name = "@univerjs/sheets-thread-comment-ui";
282
- var version = "1.0.0-alpha.8";
282
+ var version = "1.0.0-beta.1";
283
283
 
284
284
  //#endregion
285
285
  //#region src/config/config.ts
@@ -302,8 +302,8 @@ const SheetsThreadCommentCell = () => {
302
302
  sheetsThreadCommentPopupService.hidePopup();
303
303
  };
304
304
  const getSubUnitName = (id) => {
305
- var _univerInstanceServic, _univerInstanceServic2;
306
- return (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic2 = _univerInstanceServic2.getSheetBySheetId(id)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getName()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : "";
305
+ var _univerInstanceServic;
306
+ return ((_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(id)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "";
307
307
  };
308
308
  return /* @__PURE__ */ jsx(ThreadCommentTree, {
309
309
  onClick: () => {
@@ -345,10 +345,9 @@ const SheetsThreadCommentPanel = () => {
345
345
  });
346
346
  const sort = (comments) => {
347
347
  return comments.map((comment) => {
348
- var _sheetIndex$comment$s;
349
348
  const ref = singleReferenceToGrid(comment.ref);
350
349
  const p = [
351
- (_sheetIndex$comment$s = sheetIndex[comment.subUnitId]) !== null && _sheetIndex$comment$s !== void 0 ? _sheetIndex$comment$s : 0,
350
+ sheetIndex[comment.subUnitId] ?? 0,
352
351
  ref.row,
353
352
  ref.column
354
353
  ];
@@ -368,10 +367,9 @@ const SheetsThreadCommentPanel = () => {
368
367
  }, [workbook]);
369
368
  const showShape = useCallback((comment) => {
370
369
  if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
371
- var _worksheet$getMergedC;
372
370
  const { row, column } = singleReferenceToGrid(comment.ref);
373
371
  const worksheet = workbook.getSheetBySheetId(comment.subUnitId);
374
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
372
+ const mergeInfo = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) ?? {
375
373
  startColumn: column,
376
374
  endColumn: column,
377
375
  startRow: row,
@@ -395,8 +393,8 @@ const SheetsThreadCommentPanel = () => {
395
393
  unitId
396
394
  ]);
397
395
  const getSubUnitName = (id) => {
398
- var _workbook$getSheetByS, _workbook$getSheetByS2;
399
- return (_workbook$getSheetByS = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName()) !== null && _workbook$getSheetByS !== void 0 ? _workbook$getSheetByS : "";
396
+ var _workbook$getSheetByS;
397
+ return ((_workbook$getSheetByS = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName()) ?? "";
400
398
  };
401
399
  const handleAdd = () => {
402
400
  commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
@@ -819,14 +817,14 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
819
817
  this._initEditorBridge();
820
818
  }
821
819
  _handleSelectionChange(selections, unitId, subUnitId) {
822
- var _selections$, _render$with$getSkele, _range$rangeType;
820
+ var _selections$, _render$with$getSkele;
823
821
  const range = (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.range;
824
822
  const render = this._renderManagerService.getRenderUnitById(unitId);
825
823
  const skeleton = render === null || render === void 0 || (_render$with$getSkele = render.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _render$with$getSkele === void 0 ? void 0 : _render$with$getSkele.skeleton;
826
824
  if (!skeleton) return;
827
825
  if (!range) return;
828
826
  const actualCell = skeleton.getCellWithCoordByIndex(range.startRow, range.startColumn);
829
- if ((((_range$rangeType = range.rangeType) !== null && _range$rangeType !== void 0 ? _range$rangeType : RANGE_TYPE.NORMAL) !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && Rectangle.equals(actualCell.mergeInfo, range))) {
827
+ if (((range.rangeType ?? RANGE_TYPE.NORMAL) !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && Rectangle.equals(actualCell.mergeInfo, range))) {
830
828
  if (this._threadCommentPanelService.activeCommentId) this._commandService.executeCommand(SetActiveCommentOperation.id);
831
829
  return;
832
830
  }
@@ -916,7 +914,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
916
914
  }
917
915
  _initMarkSelection() {
918
916
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(debounceTime(100)).subscribe((activeComment) => {
919
- var _this$_univerInstance, _worksheet$getMergedC;
917
+ var _this$_univerInstance;
920
918
  if (!activeComment) {
921
919
  if (this._selectionShapeInfo) {
922
920
  this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId);
@@ -934,7 +932,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
934
932
  const { row, column } = singleReferenceToGrid(comment.ref);
935
933
  if (Number.isNaN(row) || Number.isNaN(column)) return null;
936
934
  const worksheet = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
937
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
935
+ const mergeInfo = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) ?? {
938
936
  startColumn: column,
939
937
  endColumn: column,
940
938
  startRow: row,
@@ -1052,7 +1050,7 @@ _defineProperty(UniverSheetsThreadCommentUIPlugin, "packageName", name);
1052
1050
  _defineProperty(UniverSheetsThreadCommentUIPlugin, "version", version);
1053
1051
  _defineProperty(UniverSheetsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1054
1052
  UniverSheetsThreadCommentUIPlugin = __decorate([
1055
- DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverSheetsPlugin, UniverUIPlugin, UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin, UniverSheetsUIPlugin),
1053
+ DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverSheetsPlugin, UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin, UniverSheetsUIPlugin),
1056
1054
  __decorateParam(1, Inject(Injector)),
1057
1055
  __decorateParam(2, Inject(ICommandService)),
1058
1056
  __decorateParam(3, IConfigService)
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/thread-comment"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-thread-comment`,`@univerjs/thread-comment-ui`,`@univerjs/ui`,`@univerjs/sheets-ui`,`rxjs`,`@univerjs/engine-render`,`@univerjs/thread-comment`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadCommentUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsThreadComment,e.UniverThreadCommentUi,e.UniverUi,e.UniverSheetsUi,e.rxjs,e.UniverEngineRender,e.UniverThreadComment,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p=`univer.sheet.thread-comment-modal`,m=`univer.sheet.thread-comment-panel`,h=`SHEET_THREAD_COMMENT_UI_PLUGIN`;function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){return function(n,r){t(n,r,e)}}function x(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 S=class extends t.Disposable{get activePopup(){return this._activePopup}constructor(e,t){super(),this._canvasPopupManagerService=e,this._cellPopupManagerService=t,y(this,`_lastPopup`,null),y(this,`_activePopup`,void 0),y(this,`_activePopup$`,new s.BehaviorSubject(null)),y(this,`activePopup$`,this._activePopup$.asObservable()),this.disposeWithMe(()=>{this._activePopup$.complete()})}dispose(){super.dispose(),this.hidePopup()}showPopup(e,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=e;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}this._lastPopup&&this._lastPopup.dispose(),this._activePopup=e,this._activePopup$.next(e);let c=this._cellPopupManagerService.showPopup({row:i,col:a,unitId:o,subUnitId:s},{componentKey:p,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,excludeOutside:[...Array.from(document.querySelectorAll(`.univer-thread-comment`)),document.getElementById(`thread-comment-add`)].filter(Boolean),priority:2});if(!c)throw Error(`[SheetsThreadCommentPopupService]: cannot show popup!`);let l=new t.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};S=x([b(0,(0,t.Inject)(o.SheetCanvasPopManagerService)),b(1,(0,t.Inject)(o.CellPopupManagerService))],S);let C={type:t.CommandType.OPERATION,id:`sheet.operation.show-comment-modal`,handler(e){var a;let o=e.get(n.SheetsSelectionsService),s=e.get(t.IUniverInstanceService),c=e.get(S),l=e.get(i.ThreadCommentPanelService),u=(a=o.getCurrentLastSelection())==null?void 0:a.primary,d=e.get(r.SheetsThreadCommentModel);if(!u)return!1;let f=(0,n.getSheetCommandTarget)(s);if(!f)return!1;let{workbook:p,worksheet:m,unitId:h,subUnitId:g}=f,_={workbook:p,worksheet:m,unitId:h,subUnitId:g,row:u.startRow,col:u.startColumn};c.showPopup(_);let v=d.getByLocation(h,g,u.startRow,u.startColumn);return v&&l.setActiveComment({unitId:h,subUnitId:g,commentId:v,trigger:`context-menu`}),!0}},w={id:`sheet.operation.toggle-comment-panel`,type:t.CommandType.OPERATION,handler(e){let t=e.get(a.ISidebarService),n=e.get(i.ThreadCommentPanelService);return n.panelVisible?(t.close(),n.setPanelVisible(!1)):(t.open({header:{title:`sheets-thread-comment-ui.panel.title`},children:{label:m},width:360}),n.setPanelVisible(!0)),!0}},T=e=>({id:C.id,type:a.MenuItemType.BUTTON,icon:`CommentIcon`,title:`sheets-thread-comment-ui.menu.addComment`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]})}),E=e=>({id:w.id,type:a.MenuItemType.BUTTON,icon:`CommentIcon`,tooltip:`sheets-thread-comment-ui.menu.commentManagement`,disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]}),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET)}),D={id:C.id,binding:a.KeyCode.M|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.ALT,preconditions:o.whenSheetEditorFocused},O={[a.RibbonInsertGroup.MEDIA]:{[w.id]:{order:2,gridLayout:{row:1,column:3,rowSpan:2,showLabel:!0},menuItemFactory:E}},[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.OTHERS]:{[C.id]:{order:0,menuItemFactory:T}}}};var k=`@univerjs/sheets-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,u.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,u.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,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`comment-icon`,ref:t,icon:L}))});R.displayName=`CommentIcon`;let z=()=>{let e=(0,a.useDependency)(t.IUniverInstanceService),n=(0,a.useDependency)(S),o=(0,a.useObservable)(n.activePopup$),c=(0,a.useDependency)(r.SheetsThreadCommentModel),l=(0,a.useObservable)(o?()=>c.commentUpdate$.pipe((0,s.map)(()=>c.getByLocation(o.unitId,o.subUnitId,o.row,o.col)),(0,s.startWith)(c.getByLocation(o.unitId,o.subUnitId,o.row,o.col))):null,void 0,!1,[o,c]);if(!o)return null;let{row:u,col:f,unitId:p,subUnitId:m,trigger:h}=o,g=`${t.Tools.chatAtABC(f)}${u+1}`;return(0,d.jsx)(i.ThreadCommentTree,{onClick:()=>{n.persistPopup()},location:i.ThreadCommentTreeLocation.CELL,id:l,unitId:p,subUnitId:m,type:t.UniverInstanceType.UNIVER_SHEET,refStr:g,onClose:()=>{n.hidePopup()},getSubUnitName:n=>{var r,i;return(r=(i=e.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetId(n))==null?void 0:i.getName())==null?``:r},autoFocus:h===`context-menu`})},B=()=>{var e;let n=(0,a.useDependency)(o.IMarkSelectionService),r=(0,a.useDependency)(t.IUniverInstanceService),c=(0,a.useDependency)(S),l=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),p=l.getUnitId(),m=(0,a.useDependency)(t.ICommandService),h=(0,u.useMemo)(()=>l.activeSheet$.pipe((0,s.map)(e=>e==null?void 0:e.getSheetId())),[l.activeSheet$]),g=(0,a.useObservable)(h,(e=l.getActiveSheet())==null?void 0:e.getSheetId()),_=(0,u.useRef)(null),v=(0,a.useDependency)(i.ThreadCommentPanelService),y=(0,a.useObservable)(v.activeCommentId$),b=(0,a.useObservable)(v.panelVisible$,v.panelVisible),x=(0,u.useCallback)(e=>{let t=l.getSheets(),n={};t.forEach((e,t)=>{n[e.getSheetId()]=t});let r=e=>e.map(e=>{var t;let r=(0,f.singleReferenceToGrid)(e.ref),i=[(t=n[e.subUnitId])==null?0:t,r.row,r.column];return{...e,p:i}}).sort((e,t)=>e.p[0]===t.p[0]?e.p[1]===t.p[1]?e.p[2]-t.p[2]:e.p[1]-t.p[1]:e.p[0]-t.p[0]);return[...r(e.filter(e=>!e.resolved)),...r(e.filter(e=>e.resolved))]},[l]),w=(0,u.useCallback)(e=>{if(e.unitId===p&&e.subUnitId===g&&!e.resolved){var t;let{row:r,column:i}=(0,f.singleReferenceToGrid)(e.ref),a=l.getSheetBySheetId(e.subUnitId),o=(t=a==null?void 0:a.getMergedCell(r,i))==null?{startColumn:i,endColumn:i,startRow:r,endRow:r}:t;if(!Number.isNaN(r)&&!Number.isNaN(i))return n.addShape({range:o,style:{fill:`rgb(255, 189, 55, 0.35)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null})}return null},[n,g,p]),T=e=>{var t,n;return(t=(n=l.getSheetBySheetId(e))==null?void 0:n.getName())==null?``:t},E=()=>{m.executeCommand(C.id)},D=e=>{_.current&&(n.removeShape(_.current),_.current=null),!(y&&y.unitId===e.unitId&&y.subUnitId===e.subUnitId&&y.commentId===e.id)&&(_.current=w(e))},O=()=>{_.current&&(n.removeShape(_.current),_.current=null)};return(0,u.useEffect)(()=>{!b&&_.current&&(n.removeShape(_.current),_.current=null)},[n,b]),(0,d.jsx)(i.ThreadCommentPanel,{unitId:p,subUnitId$:h,type:t.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:T,onResolve:(e,t)=>{t&&c.hidePopup()},sortComments:x,onItemEnter:D,onItemLeave:O,onDeleteComment:()=>(O(),!0)})},V=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[p,z],[m,B]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({CommentIcon:R}))}};V=x([b(0,(0,t.Inject)(a.ComponentManager)),b(1,(0,t.Inject)(a.IconManager))],V);let H=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsThreadCommentModel.showCommentMarker(a,o,r,i)?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let e=()=>{var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderUnitById(r);i==null||(e=i.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe((0,s.debounceTime)(16)).subscribe(()=>{e()}))}};H=x([b(0,(0,t.Inject)(n.SheetInterceptorService)),b(1,(0,t.Inject)(r.SheetsThreadCommentModel)),b(2,t.IUniverInstanceService),b(3,c.IRenderManagerService)],H);let U=(e,t,n)=>{let r=(0,f.singleReferenceToGrid)(e),i=n.row-t.row,a=n.column-t.column;return(0,f.serializeRange)({startColumn:r.column+a,startRow:r.row+i,endColumn:r.column+a,endRow:r.row+i})},W=class extends t.Disposable{constructor(e,t,n){super(),this._sheetClipboardService=e,this._sheetsThreadCommentModel=t,this._threadCommentDataSourceService=n,y(this,`_copyInfo`,void 0),this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:h,onBeforeCopy:(e,t,n)=>{this._copyInfo={unitId:e,subUnitId:t,range:n}},onPasteCells:(e,n,r,i)=>{let{unitId:a,subUnitId:s,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===o.COPY_TYPE.CUT&&this._copyInfo){let{range:e,unitId:n,subUnitId:r}=this._copyInfo,i={row:e.startRow,column:e.startColumn};if(a!==n||s!==r){let o=[];t.Range.foreach(e,(e,t)=>{let i=this._sheetsThreadCommentModel.getAllByLocation(n,r,e,t);this._threadCommentDataSourceService.syncUpdateMutationToColla?i.forEach(e=>{o.push(e)}):i.forEach(({children:e,...t})=>{t.parentId||o.push(t)})});let c=[],d=[],f=[],p=[],m=e=>{c.unshift({id:l.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:e.id}}),f.push({id:l.AddCommentMutation.id,params:{unitId:a,subUnitId:s,comment:{...e,ref:U(e.ref,i,u),unitId:a,subUnitId:s},sync:!0}}),d.push({id:l.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:e,sync:!0}}),p.unshift({id:l.DeleteCommentMutation.id,params:{unitId:a,subUnitId:s,commentId:e.id}})};return o.forEach(e=>{m(e)}),{redos:[...c,...f],undos:[...p,...d]}}}return{redos:[],undos:[]}}}))}};W=x([b(0,(0,t.Inject)(o.ISheetClipboardService)),b(1,(0,t.Inject)(r.SheetsThreadCommentModel)),b(2,l.IThreadCommentDataSourceService)],W);let G=class extends t.Disposable{constructor(e,t,n,r){super(),this._hoverManagerService=e,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=r,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{let t=this._sheetsThreadCommentPopupService.activePopup;if(e&&(t&&t.temp||!t)){let{location:r}=e,{unitId:i,subUnitId:a,row:o,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(i,a,o,s);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}],i,a))return;let e=this._sheetsThreadCommentModel.getComment(i,a,c);e&&!e.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:i,subUnitId:a,row:o,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=x([b(0,(0,t.Inject)(o.HoverManagerService)),b(1,(0,t.Inject)(S)),b(2,(0,t.Inject)(r.SheetsThreadCommentModel)),b(3,(0,t.Inject)(n.SheetPermissionCheckController))],G);let K=class extends t.Disposable{constructor(e,t,n,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._sheetsThreadCommentModel=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{let{id:t}=e;if(t===C.id||t===w.id)this._sheetPermissionCheckController.permissionCheckWithoutRange({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`));else if(t===l.AddCommentCommand.id){let{unitId:t,subUnitId:r,comment:i}=e.params,{row:a,column:o}=(0,f.singleReferenceToGrid)(i.ref);this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`))}else if(t===l.UpdateCommentCommand.id){let{unitId:t,subUnitId:r,payload:i}=e.params,{commentId:a}=i,o=this._sheetsThreadCommentModel.getComment(t,r,a);if(o){let{row:e,column:i}=(0,f.singleReferenceToGrid)(o.ref);this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:e,startColumn:i,endRow:e,endColumn:i}],t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`))}}else if(t===l.ResolveCommentCommand.id||t===l.DeleteCommentCommand.id||t===l.DeleteCommentTreeCommand.id){let{unitId:t,subUnitId:r,commentId:i}=e.params,a=this._sheetsThreadCommentModel.getComment(t,r,i);if(a){let{row:e,column:i}=(0,f.singleReferenceToGrid)(a.ref);this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:e,startColumn:i,endRow:e,endColumn:i}],t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`))}}}))}};K=x([b(0,(0,t.Inject)(t.LocaleService)),b(1,t.ICommandService),b(2,(0,t.Inject)(n.SheetPermissionCheckController)),b(3,(0,t.Inject)(r.SheetsThreadCommentModel))],K);let q=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._commandService=e,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=a,this._markSelectionService=o,this._sheetSelectionService=s,this._editorBridgeService=c,this._renderManagerService=l,y(this,`_isSwitchToCommenting`,!1),y(this,`_selectionShapeInfo`,null),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,r){var a,s,c;let l=(a=e[0])==null?void 0:a.range,u=this._renderManagerService.getRenderUnitById(n),d=u==null||(s=u.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:s.skeleton;if(!d||!l)return;let f=d.getCellWithCoordByIndex(l.startRow,l.startColumn);if((((c=l.rangeType)==null?t.RANGE_TYPE.NORMAL:c)!==t.RANGE_TYPE.NORMAL||l.endColumn-l.startColumn>0||l.endRow-l.startRow>0)&&!((f.isMerged||f.isMergedMainCell)&&t.Rectangle.equals(f.mergeInfo,l))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(i.SetActiveCommentOperation.id);return}let p=f.actualRow,m=f.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,r,p,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(i.SetActiveCommentOperation.id);return}let h=this._sheetsThreadCommentModel.getByLocation(n,r,p,m);h&&this._commandService.executeCommand(i.SetActiveCommentOperation.id,{unitId:n,subUnitId:r,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===l.DeleteCommentMutation.id){let t=e.params,n=this._sheetsThreadCommentPopupService.activePopup;if(!n)return;let{unitId:r,subUnitId:i,commentId:a}=n;t.unitId===r&&t.subUnitId===i&&t.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{if(e){var r;let{unitId:i,subUnitId:a,commentId:s,trigger:c}=e,l=this._sheetsThreadCommentModel.getComment(i,a,s);if(!l||l.resolved)return;let u=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==i)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==a&&await this._commandService.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:a}),this._isSwitchToCommenting=!1;let d=(0,f.singleReferenceToGrid)(l.ref),{row:p,column:m}=d;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:m,endRow:p,endColumn:m}],i,a)||(await this._commandService.executeCommand(o.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-1,0),endRow:d.row+1,startColumn:Math.max(d.column-1,0),endColumn:d.column+1}}),this._editorBridgeService.isVisible().visible))return;this._sheetsThreadCommentPopupService.showPopup({unitId:i,subUnitId:a,row:d.row,col:d.column,commentId:l.id,trigger:c})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe((0,s.debounceTime)(100)).subscribe(e=>{var n,r;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}let{unitId:i,subUnitId:a,commentId:o}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);let s=this._sheetsThreadCommentModel.getComment(i,a,o);if(!s)return;let{row:c,column:l}=(0,f.singleReferenceToGrid)(s.ref);if(Number.isNaN(c)||Number.isNaN(l))return null;let u=(n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getSheetBySheetId(a),d=(r=u==null?void 0:u.getMergedCell(c,l))==null?{startColumn:l,endColumn:l,startRow:c,endRow:c}:r,p=this._markSelectionService.addShape({range:d,style:{fill:`rgba(255, 189, 55, 0.35)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1);p&&(this._selectionShapeInfo={...e,shapeId:p})}))}};q=x([b(0,t.ICommandService),b(1,(0,t.Inject)(S)),b(2,(0,t.Inject)(r.SheetsThreadCommentModel)),b(3,(0,t.Inject)(i.ThreadCommentPanelService)),b(4,t.IUniverInstanceService),b(5,(0,t.Inject)(n.SheetPermissionCheckController)),b(6,o.IMarkSelectionService),b(7,(0,t.Inject)(n.SheetsSelectionsService)),b(8,o.IEditorBridgeService),b(9,c.IRenderManagerService)],q);let J=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._shortcutService=t,this._initMenu(),this._initShortcut()}_initShortcut(){this._shortcutService.registerShortcut(D)}_initMenu(){this._menuManagerService.mergeMenu(O)}};J=x([b(0,a.IMenuManagerService),b(1,a.IShortcutService)],J);let Y=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._commandService=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(`sheets-thread-comment.config`,o)}onStarting(){this._injector.add([V]),this._injector.get(V),[[J],[H],[W],[G],[q],[S],[K]].forEach(e=>{this._injector.add(e)}),[C,w].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(J)}onReady(){this._injector.get(H)}onRendered(){this._injector.get(W),this._injector.get(G),this._injector.get(q),this._injector.get(K)}};y(Y,`pluginName`,h),y(Y,`packageName`,k),y(Y,`version`,A),y(Y,`type`,t.UniverInstanceType.UNIVER_SHEET),Y=x([(0,t.DependentOn)(c.UniverRenderEnginePlugin,l.UniverThreadCommentPlugin,n.UniverSheetsPlugin,a.UniverUIPlugin,i.UniverThreadCommentUIPlugin,r.UniverSheetsThreadCommentPlugin,o.UniverSheetsUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,(0,t.Inject)(t.ICommandService)),b(3,t.IConfigService)],Y),Object.defineProperty(e,"SheetsThreadCommentPopupService",{enumerable:!0,get:function(){return S}}),e.SheetsThreadCommentUIMenuSchema=O,e.ShowAddSheetCommentModalOperation=C,e.ToggleSheetCommentPanelOperation=w,Object.defineProperty(e,"UniverSheetsThreadCommentUIPlugin",{enumerable:!0,get:function(){return Y}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/thread-comment"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-thread-comment`,`@univerjs/thread-comment-ui`,`@univerjs/ui`,`@univerjs/sheets-ui`,`rxjs`,`@univerjs/engine-render`,`@univerjs/thread-comment`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadCommentUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsThreadComment,e.UniverThreadCommentUi,e.UniverUi,e.UniverSheetsUi,e.rxjs,e.UniverEngineRender,e.UniverThreadComment,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p=`univer.sheet.thread-comment-modal`,m=`univer.sheet.thread-comment-panel`,h=`SHEET_THREAD_COMMENT_UI_PLUGIN`;function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){return function(n,r){t(n,r,e)}}function x(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 S=class extends t.Disposable{get activePopup(){return this._activePopup}constructor(e,t){super(),this._canvasPopupManagerService=e,this._cellPopupManagerService=t,y(this,`_lastPopup`,null),y(this,`_activePopup`,void 0),y(this,`_activePopup$`,new s.BehaviorSubject(null)),y(this,`activePopup$`,this._activePopup$.asObservable()),this.disposeWithMe(()=>{this._activePopup$.complete()})}dispose(){super.dispose(),this.hidePopup()}showPopup(e,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=e;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}this._lastPopup&&this._lastPopup.dispose(),this._activePopup=e,this._activePopup$.next(e);let c=this._cellPopupManagerService.showPopup({row:i,col:a,unitId:o,subUnitId:s},{componentKey:p,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,excludeOutside:[...Array.from(document.querySelectorAll(`.univer-thread-comment`)),document.getElementById(`thread-comment-add`)].filter(Boolean),priority:2});if(!c)throw Error(`[SheetsThreadCommentPopupService]: cannot show popup!`);let l=new t.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};S=x([b(0,(0,t.Inject)(o.SheetCanvasPopManagerService)),b(1,(0,t.Inject)(o.CellPopupManagerService))],S);let C={type:t.CommandType.OPERATION,id:`sheet.operation.show-comment-modal`,handler(e){var a;let o=e.get(n.SheetsSelectionsService),s=e.get(t.IUniverInstanceService),c=e.get(S),l=e.get(i.ThreadCommentPanelService),u=(a=o.getCurrentLastSelection())==null?void 0:a.primary,d=e.get(r.SheetsThreadCommentModel);if(!u)return!1;let f=(0,n.getSheetCommandTarget)(s);if(!f)return!1;let{workbook:p,worksheet:m,unitId:h,subUnitId:g}=f,_={workbook:p,worksheet:m,unitId:h,subUnitId:g,row:u.startRow,col:u.startColumn};c.showPopup(_);let v=d.getByLocation(h,g,u.startRow,u.startColumn);return v&&l.setActiveComment({unitId:h,subUnitId:g,commentId:v,trigger:`context-menu`}),!0}},w={id:`sheet.operation.toggle-comment-panel`,type:t.CommandType.OPERATION,handler(e){let t=e.get(a.ISidebarService),n=e.get(i.ThreadCommentPanelService);return n.panelVisible?(t.close(),n.setPanelVisible(!1)):(t.open({header:{title:`sheets-thread-comment-ui.panel.title`},children:{label:m},width:360}),n.setPanelVisible(!0)),!0}},T=e=>({id:C.id,type:a.MenuItemType.BUTTON,icon:`CommentIcon`,title:`sheets-thread-comment-ui.menu.addComment`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]})}),E=e=>({id:w.id,type:a.MenuItemType.BUTTON,icon:`CommentIcon`,tooltip:`sheets-thread-comment-ui.menu.commentManagement`,disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]}),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET)}),D={id:C.id,binding:a.KeyCode.M|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.ALT,preconditions:o.whenSheetEditorFocused},O={[a.RibbonInsertGroup.MEDIA]:{[w.id]:{order:2,gridLayout:{row:1,column:3,rowSpan:2,showLabel:!0},menuItemFactory:E}},[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.OTHERS]:{[C.id]:{order:0,menuItemFactory:T}}}};var k=`@univerjs/sheets-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,u.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,u.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,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`comment-icon`,ref:t,icon:L}))});R.displayName=`CommentIcon`;let z=()=>{let e=(0,a.useDependency)(t.IUniverInstanceService),n=(0,a.useDependency)(S),o=(0,a.useObservable)(n.activePopup$),c=(0,a.useDependency)(r.SheetsThreadCommentModel),l=(0,a.useObservable)(o?()=>c.commentUpdate$.pipe((0,s.map)(()=>c.getByLocation(o.unitId,o.subUnitId,o.row,o.col)),(0,s.startWith)(c.getByLocation(o.unitId,o.subUnitId,o.row,o.col))):null,void 0,!1,[o,c]);if(!o)return null;let{row:u,col:f,unitId:p,subUnitId:m,trigger:h}=o,g=`${t.Tools.chatAtABC(f)}${u+1}`;return(0,d.jsx)(i.ThreadCommentTree,{onClick:()=>{n.persistPopup()},location:i.ThreadCommentTreeLocation.CELL,id:l,unitId:p,subUnitId:m,type:t.UniverInstanceType.UNIVER_SHEET,refStr:g,onClose:()=>{n.hidePopup()},getSubUnitName:n=>{var r;return((r=e.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET))==null||(r=r.getSheetBySheetId(n))==null?void 0:r.getName())??``},autoFocus:h===`context-menu`})},B=()=>{var e;let n=(0,a.useDependency)(o.IMarkSelectionService),r=(0,a.useDependency)(t.IUniverInstanceService),c=(0,a.useDependency)(S),l=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),p=l.getUnitId(),m=(0,a.useDependency)(t.ICommandService),h=(0,u.useMemo)(()=>l.activeSheet$.pipe((0,s.map)(e=>e==null?void 0:e.getSheetId())),[l.activeSheet$]),g=(0,a.useObservable)(h,(e=l.getActiveSheet())==null?void 0:e.getSheetId()),_=(0,u.useRef)(null),v=(0,a.useDependency)(i.ThreadCommentPanelService),y=(0,a.useObservable)(v.activeCommentId$),b=(0,a.useObservable)(v.panelVisible$,v.panelVisible),x=(0,u.useCallback)(e=>{let t=l.getSheets(),n={};t.forEach((e,t)=>{n[e.getSheetId()]=t});let r=e=>e.map(e=>{let t=(0,f.singleReferenceToGrid)(e.ref),r=[n[e.subUnitId]??0,t.row,t.column];return{...e,p:r}}).sort((e,t)=>e.p[0]===t.p[0]?e.p[1]===t.p[1]?e.p[2]-t.p[2]:e.p[1]-t.p[1]:e.p[0]-t.p[0]);return[...r(e.filter(e=>!e.resolved)),...r(e.filter(e=>e.resolved))]},[l]),w=(0,u.useCallback)(e=>{if(e.unitId===p&&e.subUnitId===g&&!e.resolved){let{row:t,column:r}=(0,f.singleReferenceToGrid)(e.ref),i=l.getSheetBySheetId(e.subUnitId),a=(i==null?void 0:i.getMergedCell(t,r))??{startColumn:r,endColumn:r,startRow:t,endRow:t};if(!Number.isNaN(t)&&!Number.isNaN(r))return n.addShape({range:a,style:{fill:`rgb(255, 189, 55, 0.35)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null})}return null},[n,g,p]),T=e=>{var t;return((t=l.getSheetBySheetId(e))==null?void 0:t.getName())??``},E=()=>{m.executeCommand(C.id)},D=e=>{_.current&&=(n.removeShape(_.current),null),!(y&&y.unitId===e.unitId&&y.subUnitId===e.subUnitId&&y.commentId===e.id)&&(_.current=w(e))},O=()=>{_.current&&=(n.removeShape(_.current),null)};return(0,u.useEffect)(()=>{!b&&_.current&&(n.removeShape(_.current),_.current=null)},[n,b]),(0,d.jsx)(i.ThreadCommentPanel,{unitId:p,subUnitId$:h,type:t.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:T,onResolve:(e,t)=>{t&&c.hidePopup()},sortComments:x,onItemEnter:D,onItemLeave:O,onDeleteComment:()=>(O(),!0)})},V=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[p,z],[m,B]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({CommentIcon:R}))}};V=x([b(0,(0,t.Inject)(a.ComponentManager)),b(1,(0,t.Inject)(a.IconManager))],V);let H=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsThreadCommentModel.showCommentMarker(a,o,r,i)?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let e=()=>{var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderUnitById(r);i==null||(e=i.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe((0,s.debounceTime)(16)).subscribe(()=>{e()}))}};H=x([b(0,(0,t.Inject)(n.SheetInterceptorService)),b(1,(0,t.Inject)(r.SheetsThreadCommentModel)),b(2,t.IUniverInstanceService),b(3,c.IRenderManagerService)],H);let U=(e,t,n)=>{let r=(0,f.singleReferenceToGrid)(e),i=n.row-t.row,a=n.column-t.column;return(0,f.serializeRange)({startColumn:r.column+a,startRow:r.row+i,endColumn:r.column+a,endRow:r.row+i})},W=class extends t.Disposable{constructor(e,t,n){super(),this._sheetClipboardService=e,this._sheetsThreadCommentModel=t,this._threadCommentDataSourceService=n,y(this,`_copyInfo`,void 0),this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:h,onBeforeCopy:(e,t,n)=>{this._copyInfo={unitId:e,subUnitId:t,range:n}},onPasteCells:(e,n,r,i)=>{let{unitId:a,subUnitId:s,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===o.COPY_TYPE.CUT&&this._copyInfo){let{range:e,unitId:n,subUnitId:r}=this._copyInfo,i={row:e.startRow,column:e.startColumn};if(a!==n||s!==r){let o=[];t.Range.foreach(e,(e,t)=>{let i=this._sheetsThreadCommentModel.getAllByLocation(n,r,e,t);this._threadCommentDataSourceService.syncUpdateMutationToColla?i.forEach(e=>{o.push(e)}):i.forEach(({children:e,...t})=>{t.parentId||o.push(t)})});let c=[],d=[],f=[],p=[],m=e=>{c.unshift({id:l.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:e.id}}),f.push({id:l.AddCommentMutation.id,params:{unitId:a,subUnitId:s,comment:{...e,ref:U(e.ref,i,u),unitId:a,subUnitId:s},sync:!0}}),d.push({id:l.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:e,sync:!0}}),p.unshift({id:l.DeleteCommentMutation.id,params:{unitId:a,subUnitId:s,commentId:e.id}})};return o.forEach(e=>{m(e)}),{redos:[...c,...f],undos:[...p,...d]}}}return{redos:[],undos:[]}}}))}};W=x([b(0,(0,t.Inject)(o.ISheetClipboardService)),b(1,(0,t.Inject)(r.SheetsThreadCommentModel)),b(2,l.IThreadCommentDataSourceService)],W);let G=class extends t.Disposable{constructor(e,t,n,r){super(),this._hoverManagerService=e,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=r,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{let t=this._sheetsThreadCommentPopupService.activePopup;if(e&&(t&&t.temp||!t)){let{location:r}=e,{unitId:i,subUnitId:a,row:o,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(i,a,o,s);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}],i,a))return;let e=this._sheetsThreadCommentModel.getComment(i,a,c);e&&!e.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:i,subUnitId:a,row:o,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=x([b(0,(0,t.Inject)(o.HoverManagerService)),b(1,(0,t.Inject)(S)),b(2,(0,t.Inject)(r.SheetsThreadCommentModel)),b(3,(0,t.Inject)(n.SheetPermissionCheckController))],G);let K=class extends t.Disposable{constructor(e,t,n,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._sheetsThreadCommentModel=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{let{id:t}=e;if(t===C.id||t===w.id)this._sheetPermissionCheckController.permissionCheckWithoutRange({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`));else if(t===l.AddCommentCommand.id){let{unitId:t,subUnitId:r,comment:i}=e.params,{row:a,column:o}=(0,f.singleReferenceToGrid)(i.ref);this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`))}else if(t===l.UpdateCommentCommand.id){let{unitId:t,subUnitId:r,payload:i}=e.params,{commentId:a}=i,o=this._sheetsThreadCommentModel.getComment(t,r,a);if(o){let{row:e,column:i}=(0,f.singleReferenceToGrid)(o.ref);this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:e,startColumn:i,endRow:e,endColumn:i}],t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`))}}else if(t===l.ResolveCommentCommand.id||t===l.DeleteCommentCommand.id||t===l.DeleteCommentTreeCommand.id){let{unitId:t,subUnitId:r,commentId:i}=e.params,a=this._sheetsThreadCommentModel.getComment(t,r,i);if(a){let{row:e,column:i}=(0,f.singleReferenceToGrid)(a.ref);this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:e,startColumn:i,endRow:e,endColumn:i}],t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-thread-comment-ui.permission.commentErr`))}}}))}};K=x([b(0,(0,t.Inject)(t.LocaleService)),b(1,t.ICommandService),b(2,(0,t.Inject)(n.SheetPermissionCheckController)),b(3,(0,t.Inject)(r.SheetsThreadCommentModel))],K);let q=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._commandService=e,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=a,this._markSelectionService=o,this._sheetSelectionService=s,this._editorBridgeService=c,this._renderManagerService=l,y(this,`_isSwitchToCommenting`,!1),y(this,`_selectionShapeInfo`,null),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,r){var a,s;let c=(a=e[0])==null?void 0:a.range,l=this._renderManagerService.getRenderUnitById(n),u=l==null||(s=l.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:s.skeleton;if(!u||!c)return;let d=u.getCellWithCoordByIndex(c.startRow,c.startColumn);if(((c.rangeType??t.RANGE_TYPE.NORMAL)!==t.RANGE_TYPE.NORMAL||c.endColumn-c.startColumn>0||c.endRow-c.startRow>0)&&!((d.isMerged||d.isMergedMainCell)&&t.Rectangle.equals(d.mergeInfo,c))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(i.SetActiveCommentOperation.id);return}let f=d.actualRow,p=d.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,r,f,p)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(i.SetActiveCommentOperation.id);return}let m=this._sheetsThreadCommentModel.getByLocation(n,r,f,p);m&&this._commandService.executeCommand(i.SetActiveCommentOperation.id,{unitId:n,subUnitId:r,commentId:m})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===l.DeleteCommentMutation.id){let t=e.params,n=this._sheetsThreadCommentPopupService.activePopup;if(!n)return;let{unitId:r,subUnitId:i,commentId:a}=n;t.unitId===r&&t.subUnitId===i&&t.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{if(e){var r;let{unitId:i,subUnitId:a,commentId:s,trigger:c}=e,l=this._sheetsThreadCommentModel.getComment(i,a,s);if(!l||l.resolved)return;let u=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==i)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==a&&await this._commandService.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:a}),this._isSwitchToCommenting=!1;let d=(0,f.singleReferenceToGrid)(l.ref),{row:p,column:m}=d;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookCommentPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:m,endRow:p,endColumn:m}],i,a)||(await this._commandService.executeCommand(o.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-1,0),endRow:d.row+1,startColumn:Math.max(d.column-1,0),endColumn:d.column+1}}),this._editorBridgeService.isVisible().visible))return;this._sheetsThreadCommentPopupService.showPopup({unitId:i,subUnitId:a,row:d.row,col:d.column,commentId:l.id,trigger:c})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe((0,s.debounceTime)(100)).subscribe(e=>{var n;if(!e){this._selectionShapeInfo&&=(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),null);return}let{unitId:r,subUnitId:i,commentId:a}=e;this._selectionShapeInfo&&=(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),null);let o=this._sheetsThreadCommentModel.getComment(r,i,a);if(!o)return;let{row:s,column:c}=(0,f.singleReferenceToGrid)(o.ref);if(Number.isNaN(s)||Number.isNaN(c))return null;let l=(n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getSheetBySheetId(i),u=(l==null?void 0:l.getMergedCell(s,c))??{startColumn:c,endColumn:c,startRow:s,endRow:s},d=this._markSelectionService.addShape({range:u,style:{fill:`rgba(255, 189, 55, 0.35)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1);d&&(this._selectionShapeInfo={...e,shapeId:d})}))}};q=x([b(0,t.ICommandService),b(1,(0,t.Inject)(S)),b(2,(0,t.Inject)(r.SheetsThreadCommentModel)),b(3,(0,t.Inject)(i.ThreadCommentPanelService)),b(4,t.IUniverInstanceService),b(5,(0,t.Inject)(n.SheetPermissionCheckController)),b(6,o.IMarkSelectionService),b(7,(0,t.Inject)(n.SheetsSelectionsService)),b(8,o.IEditorBridgeService),b(9,c.IRenderManagerService)],q);let J=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._shortcutService=t,this._initMenu(),this._initShortcut()}_initShortcut(){this._shortcutService.registerShortcut(D)}_initMenu(){this._menuManagerService.mergeMenu(O)}};J=x([b(0,a.IMenuManagerService),b(1,a.IShortcutService)],J);let Y=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._commandService=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(`sheets-thread-comment.config`,o)}onStarting(){this._injector.add([V]),this._injector.get(V),[[J],[H],[W],[G],[q],[S],[K]].forEach(e=>{this._injector.add(e)}),[C,w].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(J)}onReady(){this._injector.get(H)}onRendered(){this._injector.get(W),this._injector.get(G),this._injector.get(q),this._injector.get(K)}};y(Y,`pluginName`,h),y(Y,`packageName`,k),y(Y,`version`,A),y(Y,`type`,t.UniverInstanceType.UNIVER_SHEET),Y=x([(0,t.DependentOn)(c.UniverRenderEnginePlugin,l.UniverThreadCommentPlugin,n.UniverSheetsPlugin,i.UniverThreadCommentUIPlugin,r.UniverSheetsThreadCommentPlugin,o.UniverSheetsUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,(0,t.Inject)(t.ICommandService)),b(3,t.IConfigService)],Y),Object.defineProperty(e,"SheetsThreadCommentPopupService",{enumerable:!0,get:function(){return S}}),e.SheetsThreadCommentUIMenuSchema=O,e.ShowAddSheetCommentModalOperation=C,e.ToggleSheetCommentPanelOperation=w,Object.defineProperty(e,"UniverSheetsThreadCommentUIPlugin",{enumerable:!0,get:function(){return Y}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-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 Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,25 +58,25 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/icons": "1.34.0",
62
- "@univerjs/core": "1.0.0-alpha.8",
63
- "@univerjs/engine-formula": "1.0.0-alpha.8",
64
- "@univerjs/sheets": "1.0.0-alpha.8",
65
- "@univerjs/sheets-thread-comment": "1.0.0-alpha.8",
66
- "@univerjs/engine-render": "1.0.0-alpha.8",
67
- "@univerjs/sheets-ui": "1.0.0-alpha.8",
68
- "@univerjs/thread-comment": "1.0.0-alpha.8",
69
- "@univerjs/thread-comment-ui": "1.0.0-alpha.8",
70
- "@univerjs/ui": "1.0.0-alpha.8"
61
+ "@univerjs/icons": "1.35.0",
62
+ "@univerjs/core": "1.0.0-beta.1",
63
+ "@univerjs/engine-formula": "1.0.0-beta.1",
64
+ "@univerjs/sheets": "1.0.0-beta.1",
65
+ "@univerjs/engine-render": "1.0.0-beta.1",
66
+ "@univerjs/sheets-ui": "1.0.0-beta.1",
67
+ "@univerjs/thread-comment": "1.0.0-beta.1",
68
+ "@univerjs/thread-comment-ui": "1.0.0-beta.1",
69
+ "@univerjs/ui": "1.0.0-beta.1",
70
+ "@univerjs/sheets-thread-comment": "1.0.0-beta.1"
71
71
  },
72
72
  "devDependencies": {
73
- "postcss": "^8.5.23",
73
+ "postcss": "^8.5.25",
74
74
  "react": "18.3.1",
75
75
  "rxjs": "^7.8.2",
76
76
  "tailwindcss": "3.4.18",
77
77
  "typescript": "^6.0.3",
78
78
  "vitest": "^4.1.10",
79
- "@univerjs-infra/shared": "1.0.0-alpha.8"
79
+ "@univerjs-infra/shared": "1.0.0-beta.1"
80
80
  },
81
81
  "scripts": {
82
82
  "test": "vitest run",