@univerjs/sheets-thread-comment-ui 0.4.2-nightly.202411071606 → 0.4.2-nightly.202411081606

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/es/index.js CHANGED
@@ -1,34 +1,34 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { Inject, Disposable, DisposableCollection, CommandType, IUniverInstanceService, InterceptorEffectEnum, UniverInstanceType, useDependency, Tools, ICommandService, Range, RANGE_TYPE, Rectangle, DependentOn, Injector, Plugin, IConfigService } from "@univerjs/core";
6
- import { SheetsSelectionsService, getSheetCommandTarget, SheetInterceptorService, INTERCEPTOR_POINT, WorkbookCommentPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, RemoveSheetCommand } from "@univerjs/sheets";
7
- import { SheetsThreadCommentModel, UniverSheetsThreadCommentPlugin } from "@univerjs/sheets-thread-comment";
8
- import { ThreadCommentPanelService, ThreadCommentTree, ThreadCommentPanel, ToggleSheetCommentPanelOperation, THREAD_COMMENT_PANEL, SetActiveCommentOperation, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
9
- import { IThreadCommentMentionDataService, UniverThreadCommentUIPlugin as UniverThreadCommentUIPlugin2 } from "@univerjs/thread-comment-ui";
10
- import { SheetCanvasPopManagerService, IMarkSelectionService, whenSheetEditorFocused, getCurrentRangeDisable$, ISheetClipboardService, COPY_TYPE, HoverManagerService, SheetPermissionInterceptorBaseController, IEditorBridgeService, SheetSkeletonManagerService, ScrollToRangeOperation } from "@univerjs/sheets-ui";
11
- import { IZenZoneService, useObservable, KeyCode, MetaKeys, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService, IShortcutService } from "@univerjs/ui";
12
- import { BehaviorSubject, debounceTime, map } from "rxjs";
13
- import { IRenderManagerService } from "@univerjs/engine-render";
14
- import React, { forwardRef, useRef, createElement, useMemo, useCallback, useEffect } from "react";
15
- import { singleReferenceToGrid, serializeRange } from "@univerjs/engine-formula";
16
- import { IThreadCommentDataSourceService, DeleteCommentMutation, AddCommentMutation, ThreadCommentModel } from "@univerjs/thread-comment";
17
- import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, IThreadCommentDataSourceService as IThreadCommentDataSourceService2, ResolveCommentCommand, UpdateCommentCommand } from "@univerjs/thread-comment";
18
- const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal", COMMENT_SINGLE_ICON = "comment-single", SHEETS_THREAD_COMMENT = "SHEET_THREAD_COMMENT";
19
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
20
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
21
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
22
- return kind && result && __defProp$7(target, key, result), result;
23
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a;
24
- let SheetsThreadCommentPopupService = (_a = class extends Disposable {
25
- constructor(_canvasPopupManagerService, _zenZoneService) {
1
+ var Ae = Object.defineProperty;
2
+ var je = (o, e, n) => e in o ? Ae(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
+ var E = (o, e, n) => je(o, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Inject as v, Disposable as $, DisposableCollection as Ve, CommandType as Be, IUniverInstanceService as N, InterceptorEffectEnum as He, UniverInstanceType as b, useDependency as O, Tools as Le, ICommandService as ie, Range as Fe, RANGE_TYPE as me, Rectangle as ke, DependentOn as We, Injector as Ze, Plugin as ze, IConfigService as Ge } from "@univerjs/core";
5
+ import { SheetsSelectionsService as pe, getSheetCommandTarget as Ke, SheetInterceptorService as ve, INTERCEPTOR_POINT as Ye, WorkbookCommentPermission as q, WorksheetViewPermission as J, RangeProtectionPermissionViewPoint as Q, SetWorksheetActiveOperation as qe, RemoveSheetCommand as Je } from "@univerjs/sheets";
6
+ import { SheetsThreadCommentModel as D, UniverSheetsThreadCommentPlugin as Qe } from "@univerjs/sheets-thread-comment";
7
+ import { ThreadCommentPanelService as se, ThreadCommentTree as Xe, ThreadCommentPanel as et, ToggleSheetCommentPanelOperation as _e, THREAD_COMMENT_PANEL as tt, SetActiveCommentOperation as ee, UniverThreadCommentUIPlugin as nt } from "@univerjs/thread-comment-ui";
8
+ import { IThreadCommentMentionDataService as Mn, UniverThreadCommentUIPlugin as wn } from "@univerjs/thread-comment-ui";
9
+ import { SheetCanvasPopManagerService as rt, IMarkSelectionService as fe, whenSheetEditorFocused as ot, getCurrentRangeDisable$ as Ce, ISheetClipboardService as it, COPY_TYPE as st, HoverManagerService as at, SheetPermissionInterceptorBaseController as Se, IEditorBridgeService as ct, SheetSkeletonManagerService as ht, ScrollToRangeOperation as mt } from "@univerjs/sheets-ui";
10
+ import { IZenZoneService as dt, useObservable as A, KeyCode as ut, MetaKeys as de, MenuItemType as ge, getMenuHiddenObservable as Ie, RibbonStartGroup as lt, ContextMenuPosition as pt, ContextMenuGroup as vt, ComponentManager as _t, IMenuManagerService as ft, IShortcutService as Ct } from "@univerjs/ui";
11
+ import { BehaviorSubject as St, debounceTime as ae, map as gt } from "rxjs";
12
+ import { IRenderManagerService as Pe } from "@univerjs/engine-render";
13
+ import { jsx as Te } from "react/jsx-runtime";
14
+ import { singleReferenceToGrid as j, serializeRange as It } from "@univerjs/engine-formula";
15
+ import { forwardRef as be, useRef as Me, createElement as we, useMemo as Pt, useCallback as ue, useEffect as Tt } from "react";
16
+ import { IThreadCommentDataSourceService as ye, DeleteCommentMutation as F, AddCommentMutation as oe, ThreadCommentModel as bt } from "@univerjs/thread-comment";
17
+ import { AddCommentCommand as En, DeleteCommentCommand as On, DeleteCommentTreeCommand as Un, IThreadCommentDataSourceService as Rn, ResolveCommentCommand as $n, UpdateCommentCommand as Nn } from "@univerjs/thread-comment";
18
+ const Ee = "univer.sheet.thread-comment-modal", ce = "comment-single", Oe = "SHEET_THREAD_COMMENT";
19
+ var Mt = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, yt = (o, e, n, t) => {
20
+ for (var r = t > 1 ? void 0 : t ? wt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
21
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
22
+ return t && r && Mt(e, n, r), r;
23
+ }, le = (o, e) => (n, t) => e(n, t, o);
24
+ let U = class extends $ {
25
+ constructor(e, n) {
26
26
  super();
27
- __publicField(this, "_lastPopup", null);
28
- __publicField(this, "_activePopup");
29
- __publicField(this, "_activePopup$", new BehaviorSubject(null));
30
- __publicField(this, "activePopup$", this._activePopup$.asObservable());
31
- this._canvasPopupManagerService = _canvasPopupManagerService, this._zenZoneService = _zenZoneService, this._initZenVisible(), this.disposeWithMe(() => {
27
+ E(this, "_lastPopup", null);
28
+ E(this, "_activePopup");
29
+ E(this, "_activePopup$", new St(null));
30
+ E(this, "activePopup$", this._activePopup$.asObservable());
31
+ this._canvasPopupManagerService = e, this._zenZoneService = n, this._initZenVisible(), this.disposeWithMe(() => {
32
32
  this._activePopup$.complete();
33
33
  });
34
34
  }
@@ -36,28 +36,28 @@ let SheetsThreadCommentPopupService = (_a = class extends Disposable {
36
36
  return this._activePopup;
37
37
  }
38
38
  _initZenVisible() {
39
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
40
- visible && this.hidePopup();
39
+ this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
40
+ e && this.hidePopup();
41
41
  }));
42
42
  }
43
- showPopup(location, onHide) {
44
- var _a9;
45
- const { row, col, unitId, subUnitId } = location;
46
- if (this._activePopup && row === this._activePopup.row && col === this._activePopup.col && unitId === this._activePopup.unitId && subUnitId === ((_a9 = this.activePopup) == null ? void 0 : _a9.subUnitId)) {
47
- this._activePopup = location, this._activePopup$.next(location);
43
+ showPopup(e, n) {
44
+ var h;
45
+ const { row: t, col: r, unitId: i, subUnitId: s } = e;
46
+ if (this._activePopup && t === this._activePopup.row && r === this._activePopup.col && i === this._activePopup.unitId && s === ((h = this.activePopup) == null ? void 0 : h.subUnitId)) {
47
+ this._activePopup = e, this._activePopup$.next(e);
48
48
  return;
49
49
  }
50
50
  if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
51
51
  return;
52
- this._activePopup = location, this._activePopup$.next(location);
53
- const popupDisposable = this._canvasPopupManagerService.attachPopupToCell(
54
- row,
55
- col,
52
+ this._activePopup = e, this._activePopup$.next(e);
53
+ const a = this._canvasPopupManagerService.attachPopupToCell(
54
+ t,
55
+ r,
56
56
  {
57
- componentKey: SHEETS_THREAD_COMMENT_MODAL,
58
- onClickOutside: /* @__PURE__ */ __name(() => {
57
+ componentKey: Ee,
58
+ onClickOutside: () => {
59
59
  this.hidePopup();
60
- }, "onClickOutside"),
60
+ },
61
61
  direction: "horizontal",
62
62
  excludeOutside: [
63
63
  ...Array.from(document.querySelectorAll(".univer-thread-comment")),
@@ -65,14 +65,14 @@ let SheetsThreadCommentPopupService = (_a = class extends Disposable {
65
65
  ].filter(Boolean)
66
66
  }
67
67
  );
68
- if (!popupDisposable)
68
+ if (!a)
69
69
  throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
70
- const disposableCollection = new DisposableCollection();
71
- disposableCollection.add(popupDisposable), disposableCollection.add({
72
- dispose: /* @__PURE__ */ __name(() => {
73
- onHide == null || onHide();
74
- }, "dispose")
75
- }), this._lastPopup = disposableCollection;
70
+ const c = new Ve();
71
+ c.add(a), c.add({
72
+ dispose: () => {
73
+ n == null || n();
74
+ }
75
+ }), this._lastPopup = c;
76
76
  }
77
77
  hidePopup() {
78
78
  this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
@@ -83,202 +83,198 @@ let SheetsThreadCommentPopupService = (_a = class extends Disposable {
83
83
  temp: !1
84
84
  }, this._activePopup$.next(this._activePopup));
85
85
  }
86
- }, __name(_a, "SheetsThreadCommentPopupService"), _a);
87
- SheetsThreadCommentPopupService = __decorateClass$7([
88
- __decorateParam$7(0, Inject(SheetCanvasPopManagerService)),
89
- __decorateParam$7(1, IZenZoneService)
90
- ], SheetsThreadCommentPopupService);
91
- const ShowAddSheetCommentModalOperation = {
92
- type: CommandType.OPERATION,
86
+ };
87
+ U = yt([
88
+ le(0, v(rt)),
89
+ le(1, dt)
90
+ ], U);
91
+ const V = {
92
+ type: Be.OPERATION,
93
93
  id: "sheets.operation.show-comment-modal",
94
- handler(accessor) {
95
- var _a9;
96
- const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), sheetsThreadCommentPopupService = accessor.get(SheetsThreadCommentPopupService), threadCommentPanelService = accessor.get(ThreadCommentPanelService), activeCell = (_a9 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a9.primary, model = accessor.get(SheetsThreadCommentModel);
97
- if (!activeCell)
94
+ handler(o) {
95
+ var _;
96
+ const e = o.get(pe), n = o.get(N), t = o.get(U), r = o.get(se), i = (_ = e.getCurrentLastSelection()) == null ? void 0 : _.primary, s = o.get(D);
97
+ if (!i)
98
98
  return !1;
99
- const result = getSheetCommandTarget(univerInstanceService);
100
- if (!result)
99
+ const a = Ke(n);
100
+ if (!a)
101
101
  return !1;
102
- const { workbook, worksheet, unitId, subUnitId } = result, location = {
103
- workbook,
104
- worksheet,
105
- unitId,
106
- subUnitId,
107
- row: activeCell.startRow,
108
- col: activeCell.startColumn
102
+ const { workbook: c, worksheet: h, unitId: d, subUnitId: m } = a, u = {
103
+ workbook: c,
104
+ worksheet: h,
105
+ unitId: d,
106
+ subUnitId: m,
107
+ row: i.startRow,
108
+ col: i.startColumn
109
109
  };
110
- sheetsThreadCommentPopupService.showPopup(location);
111
- const rootId = model.getByLocation(unitId, subUnitId, activeCell.startRow, activeCell.startColumn);
112
- return rootId && threadCommentPanelService.setActiveComment({
113
- unitId,
114
- subUnitId,
115
- commentId: rootId,
110
+ t.showPopup(u);
111
+ const p = s.getByLocation(d, m, i.startRow, i.startColumn);
112
+ return p && r.setActiveComment({
113
+ unitId: d,
114
+ subUnitId: m,
115
+ commentId: p,
116
116
  trigger: "context-menu"
117
117
  }), !0;
118
118
  }
119
- }, PLUGIN_CONFIG_KEY = "sheets-thread-comment.config", defaultPluginConfig = {};
120
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
121
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
122
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
123
- return kind && result && __defProp$6(target, key, result), result;
124
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a2;
125
- let SheetsThreadCommentRenderController = (_a2 = class extends Disposable {
126
- constructor(_sheetInterceptorService, _sheetsThreadCommentModel, _univerInstanceService, _renderManagerService) {
127
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._initViewModelIntercept(), this._initSkeletonChange();
119
+ }, Et = "sheets-thread-comment.config", Ot = {};
120
+ var Ut = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $t = (o, e, n, t) => {
121
+ for (var r = t > 1 ? void 0 : t ? Rt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
122
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
123
+ return t && r && Ut(e, n, r), r;
124
+ }, B = (o, e) => (n, t) => e(n, t, o);
125
+ let k = class extends $ {
126
+ constructor(o, e, n, t) {
127
+ super(), this._sheetInterceptorService = o, this._sheetsThreadCommentModel = e, this._univerInstanceService = n, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
128
128
  }
129
129
  _initViewModelIntercept() {
130
130
  this.disposeWithMe(
131
131
  this._sheetInterceptorService.intercept(
132
- INTERCEPTOR_POINT.CELL_CONTENT,
132
+ Ye.CELL_CONTENT,
133
133
  {
134
- effect: InterceptorEffectEnum.Style,
135
- handler: /* @__PURE__ */ __name((cell, pos, next) => {
136
- const { row, col, unitId, subUnitId } = pos;
137
- return this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col) ? next({
138
- ...cell,
134
+ effect: He.Style,
135
+ handler: (o, e, n) => {
136
+ const { row: t, col: r, unitId: i, subUnitId: s } = e;
137
+ return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, r) ? n({
138
+ ...o,
139
139
  markers: {
140
- ...cell == null ? void 0 : cell.markers,
140
+ ...o == null ? void 0 : o.markers,
141
141
  tr: {
142
142
  color: "#FFBD37",
143
143
  size: 6
144
144
  }
145
145
  }
146
- }) : next(cell);
147
- }, "handler"),
146
+ }) : n(o);
147
+ },
148
148
  priority: 100
149
149
  }
150
150
  )
151
151
  );
152
152
  }
153
153
  _initSkeletonChange() {
154
- const markSkeletonDirty = /* @__PURE__ */ __name(() => {
155
- var _a9;
156
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
157
- if (!workbook) return;
158
- const unitId = workbook.getUnitId(), currentRender = this._renderManagerService.getRenderById(unitId);
159
- (_a9 = currentRender == null ? void 0 : currentRender.mainComponent) == null || _a9.makeForceDirty();
160
- }, "markSkeletonDirty");
161
- this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(debounceTime(16)).subscribe(() => {
162
- markSkeletonDirty();
154
+ const o = () => {
155
+ var r;
156
+ const e = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
157
+ if (!e) return;
158
+ const n = e.getUnitId(), t = this._renderManagerService.getRenderById(n);
159
+ (r = t == null ? void 0 : t.mainComponent) == null || r.makeForceDirty();
160
+ };
161
+ this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(ae(16)).subscribe(() => {
162
+ o();
163
163
  }));
164
164
  }
165
- }, __name(_a2, "SheetsThreadCommentRenderController"), _a2);
166
- SheetsThreadCommentRenderController = __decorateClass$6([
167
- __decorateParam$6(0, Inject(SheetInterceptorService)),
168
- __decorateParam$6(1, Inject(SheetsThreadCommentModel)),
169
- __decorateParam$6(2, IUniverInstanceService),
170
- __decorateParam$6(3, IRenderManagerService)
171
- ], SheetsThreadCommentRenderController);
172
- var __assign = function() {
173
- return __assign = Object.assign || function(t) {
174
- for (var s, i = 1, n = arguments.length; i < n; i++) {
175
- s = arguments[i];
176
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
165
+ };
166
+ k = $t([
167
+ B(0, v(ve)),
168
+ B(1, v(D)),
169
+ B(2, N),
170
+ B(3, Pe)
171
+ ], k);
172
+ var P = function() {
173
+ return P = Object.assign || function(o) {
174
+ for (var e, n = 1, t = arguments.length; n < t; n++) {
175
+ e = arguments[n];
176
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (o[r] = e[r]);
177
177
  }
178
- return t;
179
- }, __assign.apply(this, arguments);
180
- }, __rest = function(s, e) {
181
- var t = {};
182
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
183
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
184
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
185
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
186
- return t;
187
- }, IconBase = forwardRef(function(props, ref) {
188
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
189
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
178
+ return o;
179
+ }, P.apply(this, arguments);
180
+ }, Nt = function(o, e) {
181
+ var n = {};
182
+ for (var t in o) Object.prototype.hasOwnProperty.call(o, t) && e.indexOf(t) < 0 && (n[t] = o[t]);
183
+ if (o != null && typeof Object.getOwnPropertySymbols == "function")
184
+ for (var r = 0, t = Object.getOwnPropertySymbols(o); r < t.length; r++)
185
+ e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
186
+ return n;
187
+ }, Ue = be(function(o, e) {
188
+ var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Nt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c = Me("_".concat(At()));
189
+ return Re(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, P({ ref: e, className: a }, s), i);
190
190
  });
191
- function render(node, id, runtimeProps, rootProps, extend) {
192
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
193
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
191
+ function Re(o, e, n, t, r) {
192
+ return we(o.tag, P(P({ key: e }, Dt(o, n, r)), t), (xt(o, n).children || []).map(function(i, s) {
193
+ return Re(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
194
194
  }));
195
195
  }
196
- __name(render, "render");
197
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
198
- var attrs = __assign({}, node.attrs);
199
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
200
- var defIds = runtimeProps.defIds;
201
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a9) {
202
- var key = _a9[0], value = _a9[1];
203
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
204
- })), attrs;
196
+ function Dt(o, e, n) {
197
+ var t = P({}, o.attrs);
198
+ n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
199
+ var r = e.defIds;
200
+ return !r || r.length === 0 || (o.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(i) {
201
+ var s = i[0], a = i[1];
202
+ typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
203
+ })), t;
205
204
  }
206
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
207
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
208
- var _a9, defIds = runtimeProps.defIds;
209
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a9 = node.children) === null || _a9 === void 0) && _a9.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
210
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
211
- }) }) : node;
205
+ function xt(o, e) {
206
+ var n, t = e.defIds;
207
+ return !t || t.length === 0 ? o : o.tag === "defs" && (!((n = o.children) === null || n === void 0) && n.length) ? P(P({}, o), { children: o.children.map(function(r) {
208
+ return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? P(P({}, r), { attrs: P(P({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
209
+ }) }) : o;
212
210
  }
213
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
214
- function generateShortUuid() {
211
+ function At() {
215
212
  return Math.random().toString(36).substring(2, 8);
216
213
  }
217
- __name(generateShortUuid, "generateShortUuid");
218
- IconBase.displayName = "UniverIcon";
219
- var element = { tag: "svg", attrs: { 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.13521 5.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.13521 8.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.13521 11.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" } }] }, CommentSingle = forwardRef(function(props, ref) {
220
- return createElement(IconBase, Object.assign({}, props, {
214
+ Ue.displayName = "UniverIcon";
215
+ var jt = { tag: "svg", attrs: { 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.13521 5.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.13521 8.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.13521 11.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" } }] }, $e = be(function(o, e) {
216
+ return we(Ue, Object.assign({}, o, {
221
217
  id: "comment-single",
222
- ref,
223
- icon: element
218
+ ref: e,
219
+ icon: jt
224
220
  }));
225
221
  });
226
- CommentSingle.displayName = "CommentSingle";
227
- const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
228
- const univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), activePopup = useObservable(sheetsThreadCommentPopupService.activePopup$), sheetThreadCommentModel = useDependency(SheetsThreadCommentModel);
229
- if (useObservable(sheetThreadCommentModel.commentUpdate$), !activePopup)
222
+ $e.displayName = "CommentSingle";
223
+ const Vt = () => {
224
+ const o = O(N), e = O(U), n = A(e.activePopup$), t = O(D);
225
+ if (A(t.commentUpdate$), !n)
230
226
  return null;
231
- const { row, col, unitId, subUnitId, trigger } = activePopup, rootId = sheetThreadCommentModel.getByLocation(unitId, subUnitId, row, col), ref = `${Tools.chatAtABC(col)}${row + 1}`, onClose = /* @__PURE__ */ __name(() => {
232
- sheetsThreadCommentPopupService.hidePopup();
233
- }, "onClose"), getSubUnitName = /* @__PURE__ */ __name((id) => {
234
- var _a9, _b, _c;
235
- return (_c = (_b = (_a9 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a9.getSheetBySheetId(id)) == null ? void 0 : _b.getName()) != null ? _c : "";
236
- }, "getSubUnitName");
237
- return /* @__PURE__ */ React.createElement(
238
- ThreadCommentTree,
227
+ const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, h = t.getByLocation(s, a, r, i), d = `${Le.chatAtABC(i)}${r + 1}`, m = () => {
228
+ e.hidePopup();
229
+ }, u = (p) => {
230
+ var _, S, R;
231
+ return (R = (S = (_ = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : _.getSheetBySheetId(p)) == null ? void 0 : S.getName()) != null ? R : "";
232
+ };
233
+ return /* @__PURE__ */ Te(
234
+ Xe,
239
235
  {
240
- onClick: /* @__PURE__ */ __name(() => {
241
- sheetsThreadCommentPopupService.persistPopup();
242
- }, "onClick"),
236
+ onClick: () => {
237
+ e.persistPopup();
238
+ },
243
239
  prefix: "cell",
244
- id: rootId,
245
- unitId,
246
- subUnitId,
247
- type: UniverInstanceType.UNIVER_SHEET,
248
- refStr: ref,
249
- onClose,
250
- getSubUnitName,
251
- autoFocus: trigger === "context-menu"
240
+ id: h,
241
+ unitId: s,
242
+ subUnitId: a,
243
+ type: b.UNIVER_SHEET,
244
+ refStr: d,
245
+ onClose: m,
246
+ getSubUnitName: u,
247
+ autoFocus: c === "context-menu"
252
248
  }
253
249
  );
254
- }, "SheetsThreadCommentCell"), SheetsThreadCommentPanel = /* @__PURE__ */ __name(() => {
255
- var _a9;
256
- const markSelectionService = useDependency(IMarkSelectionService), univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), commandService = useDependency(ICommandService), subUnitId$ = useMemo(() => workbook.activeSheet$.pipe(map((i) => i == null ? void 0 : i.getSheetId())), [workbook.activeSheet$]), subUnitId = useObservable(subUnitId$, (_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId()), hoverShapeId = useRef(), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), panelVisible = useObservable(panelService.panelVisible$, panelService.panelVisible), sortComments = useCallback((comments) => {
257
- const worksheets = workbook.getSheets(), sheetIndex = {};
258
- worksheets.forEach((sheet, i) => {
259
- sheetIndex[sheet.getSheetId()] = i;
250
+ }, Bt = () => {
251
+ var g;
252
+ const o = O(fe), e = O(N), n = O(U), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = O(ie), s = Pt(() => t.activeSheet$.pipe(gt((l) => l == null ? void 0 : l.getSheetId())), [t.activeSheet$]), a = A(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = Me(), h = O(se), d = A(h.activeCommentId$), m = A(h.panelVisible$, h.panelVisible), u = ue((l) => {
253
+ const I = t.getSheets(), f = {};
254
+ I.forEach((T, C) => {
255
+ f[T.getSheetId()] = C;
260
256
  });
261
- const sort = /* @__PURE__ */ __name((comments2) => comments2.map((comment) => {
262
- var _a10;
263
- const ref = singleReferenceToGrid(comment.ref), p = [(_a10 = sheetIndex[comment.subUnitId]) != null ? _a10 : 0, ref.row, ref.column];
264
- return { ...comment, p };
265
- }).sort((pre, aft) => pre.p[0] === aft.p[0] ? pre.p[1] === aft.p[1] ? pre.p[2] - aft.p[2] : pre.p[1] - aft.p[1] : pre.p[0] - aft.p[0]), "sort");
257
+ const M = (T) => T.map((C) => {
258
+ var he;
259
+ const y = j(C.ref), xe = [(he = f[C.subUnitId]) != null ? he : 0, y.row, y.column];
260
+ return { ...C, p: xe };
261
+ }).sort((C, y) => C.p[0] === y.p[0] ? C.p[1] === y.p[1] ? C.p[2] - y.p[2] : C.p[1] - y.p[1] : C.p[0] - y.p[0]);
266
262
  return [
267
- ...sort(comments.filter((comment) => !comment.resolved)),
268
- ...sort(comments.filter((comment) => comment.resolved))
263
+ ...M(l.filter((T) => !T.resolved)),
264
+ ...M(l.filter((T) => T.resolved))
269
265
  ];
270
- }, [workbook]), showShape = useCallback((comment) => {
271
- var _a10;
272
- if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
273
- const { row, column } = singleReferenceToGrid(comment.ref), worksheet = workbook.getSheetBySheetId(comment.subUnitId), mergeInfo = (_a10 = worksheet == null ? void 0 : worksheet.getMergedCell(row, column)) != null ? _a10 : {
274
- startColumn: column,
275
- endColumn: column,
276
- startRow: row,
277
- endRow: row
266
+ }, [t]), p = ue((l) => {
267
+ var I;
268
+ if (l.unitId === r && l.subUnitId === a && !l.resolved) {
269
+ const { row: f, column: M } = j(l.ref), T = t.getSheetBySheetId(l.subUnitId), C = (I = T == null ? void 0 : T.getMergedCell(f, M)) != null ? I : {
270
+ startColumn: M,
271
+ endColumn: M,
272
+ startRow: f,
273
+ endRow: f
278
274
  };
279
- if (!Number.isNaN(row) && !Number.isNaN(column))
280
- return markSelectionService.addShape({
281
- range: mergeInfo,
275
+ if (!Number.isNaN(f) && !Number.isNaN(M))
276
+ return o.addShape({
277
+ range: C,
282
278
  style: {
283
279
  hasAutoFill: !1,
284
280
  fill: "rgb(255, 189, 55, 0.35)",
@@ -289,204 +285,203 @@ const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
289
285
  primary: null
290
286
  });
291
287
  }
292
- }, [markSelectionService, subUnitId, unitId]), getSubUnitName = /* @__PURE__ */ __name((id) => {
293
- var _a10, _b;
294
- return (_b = (_a10 = workbook.getSheetBySheetId(id)) == null ? void 0 : _a10.getName()) != null ? _b : "";
295
- }, "getSubUnitName"), handleAdd = /* @__PURE__ */ __name(() => {
296
- commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
297
- }, "handleAdd"), handleHover = /* @__PURE__ */ __name((comment) => {
298
- activeCommentId && activeCommentId.unitId === comment.unitId && activeCommentId.subUnitId === comment.subUnitId && activeCommentId.commentId === comment.id || (hoverShapeId.current && (markSelectionService.removeShape(hoverShapeId.current), hoverShapeId.current = null), hoverShapeId.current = showShape(comment));
299
- }, "handleHover"), handleLeave = /* @__PURE__ */ __name(() => {
300
- hoverShapeId.current && (markSelectionService.removeShape(hoverShapeId.current), hoverShapeId.current = null);
301
- }, "handleLeave"), handleResolve = /* @__PURE__ */ __name((id, resolved) => {
302
- resolved && sheetsThreadCommentPopupService.hidePopup();
303
- }, "handleResolve");
304
- return useEffect(() => {
305
- !panelVisible && hoverShapeId.current && markSelectionService.removeShape(hoverShapeId.current);
306
- }, [markSelectionService, panelVisible]), /* @__PURE__ */ React.createElement(
307
- ThreadCommentPanel,
288
+ }, [o, a, r]), _ = (l) => {
289
+ var I, f;
290
+ return (f = (I = t.getSheetBySheetId(l)) == null ? void 0 : I.getName()) != null ? f : "";
291
+ }, S = () => {
292
+ i.executeCommand(V.id);
293
+ }, R = (l) => {
294
+ d && d.unitId === l.unitId && d.subUnitId === l.subUnitId && d.commentId === l.id || (c.current && (o.removeShape(c.current), c.current = null), c.current = p(l));
295
+ }, x = () => {
296
+ c.current && (o.removeShape(c.current), c.current = null);
297
+ }, X = (l, I) => {
298
+ I && n.hidePopup();
299
+ };
300
+ return Tt(() => {
301
+ !m && c.current && o.removeShape(c.current);
302
+ }, [o, m]), /* @__PURE__ */ Te(
303
+ et,
308
304
  {
309
- unitId,
310
- subUnitId$,
311
- type: UniverInstanceType.UNIVER_SHEET,
312
- onAdd: handleAdd,
313
- getSubUnitName,
314
- onResolve: handleResolve,
315
- sortComments,
316
- onItemEnter: handleHover,
317
- onItemLeave: handleLeave,
318
- onDeleteComment: /* @__PURE__ */ __name(() => (handleLeave(), !0), "onDeleteComment")
305
+ unitId: r,
306
+ subUnitId$: s,
307
+ type: b.UNIVER_SHEET,
308
+ onAdd: S,
309
+ getSubUnitName: _,
310
+ onResolve: X,
311
+ sortComments: u,
312
+ onItemEnter: R,
313
+ onItemLeave: x,
314
+ onDeleteComment: () => (x(), !0)
319
315
  }
320
316
  );
321
- }, "SheetsThreadCommentPanel"), threadCommentMenuFactory = /* @__PURE__ */ __name((accessor) => ({
322
- id: ShowAddSheetCommentModalOperation.id,
323
- type: MenuItemType.BUTTON,
324
- icon: COMMENT_SINGLE_ICON,
317
+ }, Ht = (o) => ({
318
+ id: V.id,
319
+ type: ge.BUTTON,
320
+ icon: ce,
325
321
  title: "sheetThreadComment.menu.addComment",
326
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
327
- disabled$: getCurrentRangeDisable$(accessor, {
328
- workbookTypes: [WorkbookCommentPermission],
329
- worksheetTypes: [WorksheetViewPermission],
330
- rangeTypes: [RangeProtectionPermissionViewPoint]
322
+ hidden$: Ie(o, b.UNIVER_SHEET),
323
+ disabled$: Ce(o, {
324
+ workbookTypes: [q],
325
+ worksheetTypes: [J],
326
+ rangeTypes: [Q]
331
327
  })
332
- }), "threadCommentMenuFactory"), threadPanelMenuFactory = /* @__PURE__ */ __name((accessor) => ({
333
- id: ToggleSheetCommentPanelOperation.id,
334
- type: MenuItemType.BUTTON,
335
- icon: COMMENT_SINGLE_ICON,
328
+ }), Lt = (o) => ({
329
+ id: _e.id,
330
+ type: ge.BUTTON,
331
+ icon: ce,
336
332
  tooltip: "sheetThreadComment.menu.commentManagement",
337
- disabled$: getCurrentRangeDisable$(accessor, {
338
- workbookTypes: [WorkbookCommentPermission],
339
- worksheetTypes: [WorksheetViewPermission],
340
- rangeTypes: [RangeProtectionPermissionViewPoint]
333
+ disabled$: Ce(o, {
334
+ workbookTypes: [q],
335
+ worksheetTypes: [J],
336
+ rangeTypes: [Q]
341
337
  }),
342
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
343
- }), "threadPanelMenuFactory"), AddCommentShortcut = {
344
- id: ShowAddSheetCommentModalOperation.id,
345
- binding: KeyCode.M | MetaKeys.CTRL_COMMAND | MetaKeys.ALT,
346
- preconditions: whenSheetEditorFocused
347
- }, menuSchema = {
348
- [RibbonStartGroup.OTHERS]: {
349
- [ToggleSheetCommentPanelOperation.id]: {
338
+ hidden$: Ie(o, b.UNIVER_SHEET)
339
+ }), Ft = {
340
+ id: V.id,
341
+ binding: ut.M | de.CTRL_COMMAND | de.ALT,
342
+ preconditions: ot
343
+ }, kt = {
344
+ [lt.OTHERS]: {
345
+ [_e.id]: {
350
346
  order: 1,
351
- menuItemFactory: threadPanelMenuFactory
347
+ menuItemFactory: Lt
352
348
  }
353
349
  },
354
- [ContextMenuPosition.MAIN_AREA]: {
355
- [ContextMenuGroup.OTHERS]: {
356
- [ShowAddSheetCommentModalOperation.id]: {
350
+ [pt.MAIN_AREA]: {
351
+ [vt.OTHERS]: {
352
+ [V.id]: {
357
353
  order: 0,
358
- menuItemFactory: threadCommentMenuFactory
354
+ menuItemFactory: Ht
359
355
  }
360
356
  }
361
357
  }
362
358
  };
363
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
364
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
365
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
366
- return kind && result && __defProp$5(target, key, result), result;
367
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a3;
368
- let SheetsThreadCommentController = (_a3 = class extends Disposable {
369
- constructor(_menuManagerService, _componentManager, _shortcutService) {
370
- super(), this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._shortcutService = _shortcutService, this._initMenu(), this._initShortcut(), this._initComponent();
359
+ var Wt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, zt = (o, e, n, t) => {
360
+ for (var r = t > 1 ? void 0 : t ? Zt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
361
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
362
+ return t && r && Wt(e, n, r), r;
363
+ }, te = (o, e) => (n, t) => e(n, t, o);
364
+ let W = class extends $ {
365
+ constructor(o, e, n) {
366
+ super(), this._menuManagerService = o, this._componentManager = e, this._shortcutService = n, this._initMenu(), this._initShortcut(), this._initComponent();
371
367
  }
372
368
  _initShortcut() {
373
- this._shortcutService.registerShortcut(AddCommentShortcut);
369
+ this._shortcutService.registerShortcut(Ft);
374
370
  }
375
371
  _initMenu() {
376
- this._menuManagerService.mergeMenu(menuSchema);
372
+ this._menuManagerService.mergeMenu(kt);
377
373
  }
378
374
  _initComponent() {
379
375
  [
380
- [SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell],
381
- [THREAD_COMMENT_PANEL, SheetsThreadCommentPanel],
382
- [COMMENT_SINGLE_ICON, CommentSingle]
383
- ].forEach(([key, comp]) => {
384
- this._componentManager.register(key, comp);
376
+ [Ee, Vt],
377
+ [tt, Bt],
378
+ [ce, $e]
379
+ ].forEach(([o, e]) => {
380
+ this._componentManager.register(o, e);
385
381
  });
386
382
  }
387
- }, __name(_a3, "SheetsThreadCommentController"), _a3);
388
- SheetsThreadCommentController = __decorateClass$5([
389
- __decorateParam$5(0, IMenuManagerService),
390
- __decorateParam$5(1, Inject(ComponentManager)),
391
- __decorateParam$5(2, IShortcutService)
392
- ], SheetsThreadCommentController);
393
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
394
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
395
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
396
- return kind && result && __defProp$4(target, key, result), result;
397
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
398
- const transformRef = /* @__PURE__ */ __name((ref, source, target) => {
399
- const refObj = singleReferenceToGrid(ref), offsetRow = target.row - source.row, offsetCol = target.column - source.column, targetRange = {
400
- startColumn: refObj.column + offsetCol,
401
- startRow: refObj.row + offsetRow,
402
- endColumn: refObj.column + offsetCol,
403
- endRow: refObj.row + offsetRow
383
+ };
384
+ W = zt([
385
+ te(0, ft),
386
+ te(1, v(_t)),
387
+ te(2, Ct)
388
+ ], W);
389
+ var Gt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Yt = (o, e, n, t) => {
390
+ for (var r = t > 1 ? void 0 : t ? Kt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
391
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
392
+ return t && r && Gt(e, n, r), r;
393
+ }, ne = (o, e) => (n, t) => e(n, t, o);
394
+ const qt = (o, e, n) => {
395
+ const t = j(o), r = n.row - e.row, i = n.column - e.column, s = {
396
+ startColumn: t.column + i,
397
+ startRow: t.row + r,
398
+ endColumn: t.column + i,
399
+ endRow: t.row + r
404
400
  };
405
- return serializeRange(targetRange);
406
- }, "transformRef");
407
- var _a4;
408
- let SheetsThreadCommentCopyPasteController = (_a4 = class extends Disposable {
409
- constructor(_sheetClipboardService, _sheetsThreadCommentModel, _threadCommentDataSourceService) {
401
+ return It(s);
402
+ };
403
+ let Z = class extends $ {
404
+ constructor(e, n, t) {
410
405
  super();
411
- __publicField(this, "_copyInfo");
412
- this._sheetClipboardService = _sheetClipboardService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initClipboardHook();
406
+ E(this, "_copyInfo");
407
+ this._sheetClipboardService = e, this._sheetsThreadCommentModel = n, this._threadCommentDataSourceService = t, this._initClipboardHook();
413
408
  }
414
409
  // eslint-disable-next-line max-lines-per-function
415
410
  _initClipboardHook() {
416
411
  this.disposeWithMe(
417
412
  this._sheetClipboardService.addClipboardHook({
418
- id: SHEETS_THREAD_COMMENT,
419
- onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => {
413
+ id: Oe,
414
+ onBeforeCopy: (e, n, t) => {
420
415
  this._copyInfo = {
421
- unitId,
422
- subUnitId,
423
- range
416
+ unitId: e,
417
+ subUnitId: n,
418
+ range: t
424
419
  };
425
- }, "onBeforeCopy"),
420
+ },
426
421
  // eslint-disable-next-line max-lines-per-function
427
- onPasteCells: /* @__PURE__ */ __name((_pasteFrom, pasteTo, _data, payload) => {
428
- const { unitId: targetUnitId, subUnitId: targetSubUnitId, range } = pasteTo, targetPos = {
429
- row: range.rows[0],
430
- column: range.cols[0]
422
+ onPasteCells: (e, n, t, r) => {
423
+ const { unitId: i, subUnitId: s, range: a } = n, c = {
424
+ row: a.rows[0],
425
+ column: a.cols[0]
431
426
  };
432
- if (payload.copyType === COPY_TYPE.CUT && this._copyInfo) {
433
- const { range: range2, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._copyInfo, sourcePos = {
434
- row: range2.startRow,
435
- column: range2.startColumn
427
+ if (r.copyType === st.CUT && this._copyInfo) {
428
+ const { range: h, unitId: d, subUnitId: m } = this._copyInfo, u = {
429
+ row: h.startRow,
430
+ column: h.startColumn
436
431
  };
437
- if (!(targetUnitId === sourceUnitId && targetSubUnitId === sourceSubUnitId)) {
438
- const roots = [];
439
- Range.foreach(range2, (row, col) => {
440
- const comments = this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId, sourceSubUnitId, row, col);
441
- this._threadCommentDataSourceService.syncUpdateMutationToColla ? comments.forEach((comment) => {
442
- roots.push(comment);
443
- }) : comments.forEach(({ children, ...comment }) => {
444
- comment.parentId || roots.push(comment);
432
+ if (!(i === d && s === m)) {
433
+ const p = [];
434
+ Fe.foreach(h, (g, l) => {
435
+ const I = this._sheetsThreadCommentModel.getAllByLocation(d, m, g, l);
436
+ this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((f) => {
437
+ p.push(f);
438
+ }) : I.forEach(({ children: f, ...M }) => {
439
+ M.parentId || p.push(M);
445
440
  });
446
441
  });
447
- const sourceRedos = [], sourceUndos = [], targetRedos = [], targetUndos = [], handleCommentItem = /* @__PURE__ */ __name((item) => {
448
- sourceRedos.unshift({
449
- id: DeleteCommentMutation.id,
442
+ const _ = [], S = [], R = [], x = [], X = (g) => {
443
+ _.unshift({
444
+ id: F.id,
450
445
  params: {
451
- unitId: sourceUnitId,
452
- subUnitId: sourceSubUnitId,
453
- commentId: item.id
446
+ unitId: d,
447
+ subUnitId: m,
448
+ commentId: g.id
454
449
  }
455
- }), targetRedos.push({
456
- id: AddCommentMutation.id,
450
+ }), R.push({
451
+ id: oe.id,
457
452
  params: {
458
- unitId: targetUnitId,
459
- subUnitId: targetSubUnitId,
453
+ unitId: i,
454
+ subUnitId: s,
460
455
  comment: {
461
- ...item,
462
- ref: transformRef(item.ref, sourcePos, targetPos),
463
- unitId: targetUnitId,
464
- subUnitId: targetSubUnitId
456
+ ...g,
457
+ ref: qt(g.ref, u, c),
458
+ unitId: i,
459
+ subUnitId: s
465
460
  },
466
461
  sync: !0
467
462
  }
468
- }), sourceUndos.push({
469
- id: AddCommentMutation.id,
463
+ }), S.push({
464
+ id: oe.id,
470
465
  params: {
471
- unitId: sourceUnitId,
472
- subUnitId: sourceSubUnitId,
473
- comment: item,
466
+ unitId: d,
467
+ subUnitId: m,
468
+ comment: g,
474
469
  sync: !0
475
470
  }
476
- }), targetUndos.unshift({
477
- id: DeleteCommentMutation.id,
471
+ }), x.unshift({
472
+ id: F.id,
478
473
  params: {
479
- unitId: targetUnitId,
480
- subUnitId: targetSubUnitId,
481
- commentId: item.id
474
+ unitId: i,
475
+ subUnitId: s,
476
+ commentId: g.id
482
477
  }
483
478
  });
484
- }, "handleCommentItem");
485
- return roots.forEach((root) => {
486
- handleCommentItem(root);
479
+ };
480
+ return p.forEach((g) => {
481
+ X(g);
487
482
  }), {
488
- redos: [...sourceRedos, ...targetRedos],
489
- undos: [...targetUndos, ...sourceUndos]
483
+ redos: [..._, ...R],
484
+ undos: [...x, ...S]
490
485
  };
491
486
  }
492
487
  }
@@ -494,188 +489,188 @@ let SheetsThreadCommentCopyPasteController = (_a4 = class extends Disposable {
494
489
  redos: [],
495
490
  undos: []
496
491
  };
497
- }, "onPasteCells")
492
+ }
498
493
  })
499
494
  );
500
495
  }
501
- }, __name(_a4, "SheetsThreadCommentCopyPasteController"), _a4);
502
- SheetsThreadCommentCopyPasteController = __decorateClass$4([
503
- __decorateParam$4(0, Inject(ISheetClipboardService)),
504
- __decorateParam$4(1, Inject(SheetsThreadCommentModel)),
505
- __decorateParam$4(2, IThreadCommentDataSourceService)
506
- ], SheetsThreadCommentCopyPasteController);
507
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
508
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
509
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
510
- return kind && result && __defProp$3(target, key, result), result;
511
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a5;
512
- let SheetsThreadCommentHoverController = (_a5 = class extends Disposable {
513
- constructor(_hoverManagerService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _sheetPermissionInterceptorBaseController) {
514
- super(), this._hoverManagerService = _hoverManagerService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._initHoverEvent();
496
+ };
497
+ Z = Yt([
498
+ ne(0, v(it)),
499
+ ne(1, v(D)),
500
+ ne(2, ye)
501
+ ], Z);
502
+ var Jt = Object.defineProperty, Qt = Object.getOwnPropertyDescriptor, Xt = (o, e, n, t) => {
503
+ for (var r = t > 1 ? void 0 : t ? Qt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
504
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
505
+ return t && r && Jt(e, n, r), r;
506
+ }, H = (o, e) => (n, t) => e(n, t, o);
507
+ let z = class extends $ {
508
+ constructor(o, e, n, t) {
509
+ super(), this._hoverManagerService = o, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = n, this._sheetPermissionInterceptorBaseController = t, this._initHoverEvent();
515
510
  }
516
511
  _initHoverEvent() {
517
512
  this.disposeWithMe(
518
- this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cell) => {
519
- const currentPopup = this._sheetsThreadCommentPopupService.activePopup;
520
- if (cell && (currentPopup && currentPopup.temp || !currentPopup)) {
521
- const { location } = cell, { unitId, subUnitId, row, col } = location, commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
522
- if (commentId) {
513
+ this._hoverManagerService.currentCell$.pipe(ae(100)).subscribe((o) => {
514
+ const e = this._sheetsThreadCommentPopupService.activePopup;
515
+ if (o && (e && e.temp || !e)) {
516
+ const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, a = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
517
+ if (a) {
523
518
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
524
- workbookTypes: [WorkbookCommentPermission],
525
- worksheetTypes: [WorksheetViewPermission],
526
- rangeTypes: [RangeProtectionPermissionViewPoint]
527
- }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
519
+ workbookTypes: [q],
520
+ worksheetTypes: [J],
521
+ rangeTypes: [Q]
522
+ }, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
528
523
  return;
529
- const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
530
- comment && !comment.resolved && this._sheetsThreadCommentPopupService.showPopup({
531
- unitId,
532
- subUnitId,
533
- row,
534
- col,
535
- commentId,
524
+ const h = this._sheetsThreadCommentModel.getComment(t, r, a);
525
+ h && !h.resolved && this._sheetsThreadCommentPopupService.showPopup({
526
+ unitId: t,
527
+ subUnitId: r,
528
+ row: i,
529
+ col: s,
530
+ commentId: a,
536
531
  temp: !0
537
532
  });
538
533
  } else
539
- currentPopup && this._sheetsThreadCommentPopupService.hidePopup();
534
+ e && this._sheetsThreadCommentPopupService.hidePopup();
540
535
  }
541
536
  })
542
537
  );
543
538
  }
544
- }, __name(_a5, "SheetsThreadCommentHoverController"), _a5);
545
- SheetsThreadCommentHoverController = __decorateClass$3([
546
- __decorateParam$3(0, Inject(HoverManagerService)),
547
- __decorateParam$3(1, Inject(SheetsThreadCommentPopupService)),
548
- __decorateParam$3(2, Inject(SheetsThreadCommentModel)),
549
- __decorateParam$3(3, Inject(SheetPermissionInterceptorBaseController))
550
- ], SheetsThreadCommentHoverController);
551
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
552
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
553
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
554
- return kind && result && __defProp$2(target, key, result), result;
555
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a6;
556
- let SheetsThreadCommentPopupController = (_a6 = class extends Disposable {
557
- constructor(_commandService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _threadCommentPanelService, _univerInstanceService, _sheetPermissionInterceptorBaseController, _markSelectionService, _sheetSelectionService, _editorBridgeService, _renderManagerService) {
539
+ };
540
+ z = Xt([
541
+ H(0, v(at)),
542
+ H(1, v(U)),
543
+ H(2, v(D)),
544
+ H(3, v(Se))
545
+ ], z);
546
+ var en = Object.defineProperty, tn = Object.getOwnPropertyDescriptor, nn = (o, e, n, t) => {
547
+ for (var r = t > 1 ? void 0 : t ? tn(e, n) : e, i = o.length - 1, s; i >= 0; i--)
548
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
549
+ return t && r && en(e, n, r), r;
550
+ }, w = (o, e) => (n, t) => e(n, t, o);
551
+ let G = class extends $ {
552
+ constructor(e, n, t, r, i, s, a, c, h, d) {
558
553
  super();
559
- __publicField(this, "_isSwitchToCommenting", !1);
560
- __publicField(this, "_selectionShapeInfo", null);
561
- this._commandService = _commandService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentPanelService = _threadCommentPanelService, this._univerInstanceService = _univerInstanceService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._markSelectionService = _markSelectionService, this._sheetSelectionService = _sheetSelectionService, this._editorBridgeService = _editorBridgeService, this._renderManagerService = _renderManagerService, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
562
- }
563
- _handleSelectionChange(selections, unitId, subUnitId) {
564
- var _a9, _b, _c;
565
- const range = (_a9 = selections[0]) == null ? void 0 : _a9.range, render2 = this._renderManagerService.getRenderById(unitId), skeleton = (_b = render2 == null ? void 0 : render2.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b.skeleton;
566
- if (!skeleton || !range)
554
+ E(this, "_isSwitchToCommenting", !1);
555
+ E(this, "_selectionShapeInfo", null);
556
+ this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this._sheetPermissionInterceptorBaseController = s, this._markSelectionService = a, this._sheetSelectionService = c, this._editorBridgeService = h, this._renderManagerService = d, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
557
+ }
558
+ _handleSelectionChange(e, n, t) {
559
+ var u, p, _;
560
+ const r = (u = e[0]) == null ? void 0 : u.range, i = this._renderManagerService.getRenderById(n), s = (p = i == null ? void 0 : i.with(ht).getWorksheetSkeleton(t)) == null ? void 0 : p.skeleton;
561
+ if (!s || !r)
567
562
  return;
568
- const actualCell = skeleton.getCellByIndex(range.startRow, range.startColumn);
569
- if ((((_c = range.rangeType) != null ? _c : 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))) {
570
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
563
+ const a = s.getCellByIndex(r.startRow, r.startColumn);
564
+ if ((((_ = r.rangeType) != null ? _ : me.NORMAL) !== me.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && ke.equals(a.mergeInfo, r))) {
565
+ this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ee.id);
571
566
  return;
572
567
  }
573
- const row = actualCell.actualRow, col = actualCell.actualColumn;
574
- if (!this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col)) {
575
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
568
+ const h = a.actualRow, d = a.actualColumn;
569
+ if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, h, d)) {
570
+ this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ee.id);
576
571
  return;
577
572
  }
578
- const commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
579
- commentId && this._commandService.executeCommand(SetActiveCommentOperation.id, {
580
- unitId,
581
- subUnitId,
582
- commentId
573
+ const m = this._sheetsThreadCommentModel.getByLocation(n, t, h, d);
574
+ m && this._commandService.executeCommand(ee.id, {
575
+ unitId: n,
576
+ subUnitId: t,
577
+ commentId: m
583
578
  });
584
579
  }
585
580
  _initSelectionUpdateListener() {
586
581
  this.disposeWithMe(
587
- this._sheetSelectionService.selectionMoveEnd$.subscribe((selections) => {
582
+ this._sheetSelectionService.selectionMoveEnd$.subscribe((e) => {
588
583
  if (this._isSwitchToCommenting)
589
584
  return;
590
- const current = this._sheetSelectionService.currentSelectionParam;
591
- current && this._handleSelectionChange(selections, current.unitId, current.sheetId);
585
+ const n = this._sheetSelectionService.currentSelectionParam;
586
+ n && this._handleSelectionChange(e, n.unitId, n.sheetId);
592
587
  })
593
588
  );
594
589
  }
595
590
  _initEditorBridge() {
596
591
  this.disposeWithMe(
597
- this._editorBridgeService.visible$.subscribe((visible) => {
598
- visible.visible && this._sheetsThreadCommentPopupService.hidePopup();
592
+ this._editorBridgeService.visible$.subscribe((e) => {
593
+ e.visible && this._sheetsThreadCommentPopupService.hidePopup();
599
594
  })
600
595
  );
601
596
  }
602
597
  _initCommandListener() {
603
- this._commandService.onCommandExecuted((commandInfo) => {
604
- if (commandInfo.id === DeleteCommentMutation.id) {
605
- const params = commandInfo.params, active = this._sheetsThreadCommentPopupService.activePopup;
606
- if (!active)
598
+ this._commandService.onCommandExecuted((e) => {
599
+ if (e.id === F.id) {
600
+ const n = e.params, t = this._sheetsThreadCommentPopupService.activePopup;
601
+ if (!t)
607
602
  return;
608
- const { unitId, subUnitId, commentId } = active;
609
- params.unitId === unitId && params.subUnitId === subUnitId && params.commentId === commentId && this._sheetsThreadCommentPopupService.hidePopup();
603
+ const { unitId: r, subUnitId: i, commentId: s } = t;
604
+ n.unitId === r && n.subUnitId === i && n.commentId === s && this._sheetsThreadCommentPopupService.hidePopup();
610
605
  }
611
606
  });
612
607
  }
613
608
  _initPanelListener() {
614
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (commentInfo) => {
615
- var _a9;
616
- if (commentInfo) {
617
- const { unitId, subUnitId, commentId, trigger } = commentInfo, comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
618
- if (!comment || comment.resolved)
609
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (e) => {
610
+ var n;
611
+ if (e) {
612
+ const { unitId: t, subUnitId: r, commentId: i, trigger: s } = e, a = this._sheetsThreadCommentModel.getComment(t, r, i);
613
+ if (!a || a.resolved)
619
614
  return;
620
- const currentUnit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
621
- if (!currentUnit || currentUnit.getUnitId() !== unitId)
615
+ const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
616
+ if (!c || c.getUnitId() !== t)
622
617
  return;
623
- this._isSwitchToCommenting = !0, ((_a9 = currentUnit.getActiveSheet()) == null ? void 0 : _a9.getSheetId()) !== subUnitId && await this._commandService.executeCommand(SetWorksheetActiveOperation.id, {
624
- unitId,
625
- subUnitId
618
+ this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(qe.id, {
619
+ unitId: t,
620
+ subUnitId: r
626
621
  }), this._isSwitchToCommenting = !1;
627
- const location = singleReferenceToGrid(comment.ref), { row, column: col } = location;
622
+ const m = j(a.ref), { row: u, column: p } = m;
628
623
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
629
- workbookTypes: [WorkbookCommentPermission],
630
- worksheetTypes: [WorksheetViewPermission],
631
- rangeTypes: [RangeProtectionPermissionViewPoint]
632
- }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
624
+ workbookTypes: [q],
625
+ worksheetTypes: [J],
626
+ rangeTypes: [Q]
627
+ }, [{ startRow: u, startColumn: p, endRow: u, endColumn: p }]))
633
628
  return;
634
- const GAP = 1;
635
- if (await this._commandService.executeCommand(ScrollToRangeOperation.id, {
629
+ const S = 1;
630
+ if (await this._commandService.executeCommand(mt.id, {
636
631
  range: {
637
- startRow: Math.max(location.row - GAP, 0),
638
- endRow: location.row + GAP,
639
- startColumn: Math.max(location.column - GAP, 0),
640
- endColumn: location.column + GAP
632
+ startRow: Math.max(m.row - S, 0),
633
+ endRow: m.row + S,
634
+ startColumn: Math.max(m.column - S, 0),
635
+ endColumn: m.column + S
641
636
  }
642
637
  }), this._editorBridgeService.isVisible().visible)
643
638
  return;
644
639
  this._sheetsThreadCommentPopupService.showPopup({
645
- unitId,
646
- subUnitId,
647
- row: location.row,
648
- col: location.column,
649
- commentId: comment.id,
650
- trigger
640
+ unitId: t,
641
+ subUnitId: r,
642
+ row: m.row,
643
+ col: m.column,
644
+ commentId: a.id,
645
+ trigger: s
651
646
  });
652
647
  } else
653
648
  this._sheetsThreadCommentPopupService.hidePopup();
654
649
  }));
655
650
  }
656
651
  _initMarkSelection() {
657
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(debounceTime(100)).subscribe((activeComment) => {
658
- var _a9, _b;
659
- if (!activeComment) {
652
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(ae(100)).subscribe((e) => {
653
+ var u, p;
654
+ if (!e) {
660
655
  this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
661
656
  return;
662
657
  }
663
- const { unitId, subUnitId, commentId } = activeComment;
658
+ const { unitId: n, subUnitId: t, commentId: r } = e;
664
659
  this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
665
- const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
666
- if (!comment)
660
+ const i = this._sheetsThreadCommentModel.getComment(n, t, r);
661
+ if (!i)
667
662
  return;
668
- const location = singleReferenceToGrid(comment.ref), { row, column } = location;
669
- if (Number.isNaN(row) || Number.isNaN(column))
663
+ const s = j(i.ref), { row: a, column: c } = s;
664
+ if (Number.isNaN(a) || Number.isNaN(c))
670
665
  return null;
671
- const worksheet = (_a9 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a9.getSheetBySheetId(subUnitId), mergeInfo = (_b = worksheet == null ? void 0 : worksheet.getMergedCell(row, column)) != null ? _b : {
672
- startColumn: column,
673
- endColumn: column,
674
- startRow: row,
675
- endRow: row
676
- }, shapeId = this._markSelectionService.addShape(
666
+ const h = (u = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : u.getSheetBySheetId(t), d = (p = h == null ? void 0 : h.getMergedCell(a, c)) != null ? p : {
667
+ startColumn: c,
668
+ endColumn: c,
669
+ startRow: a,
670
+ endRow: a
671
+ }, m = this._markSelectionService.addShape(
677
672
  {
678
- range: mergeInfo,
673
+ range: d,
679
674
  style: {
680
675
  hasAutoFill: !1,
681
676
  fill: "rgb(255, 189, 55, 0.35)",
@@ -688,131 +683,131 @@ let SheetsThreadCommentPopupController = (_a6 = class extends Disposable {
688
683
  [],
689
684
  -1
690
685
  );
691
- shapeId && (this._selectionShapeInfo = {
692
- ...activeComment,
693
- shapeId
686
+ m && (this._selectionShapeInfo = {
687
+ ...e,
688
+ shapeId: m
694
689
  });
695
690
  }));
696
691
  }
697
- }, __name(_a6, "SheetsThreadCommentPopupController"), _a6);
698
- SheetsThreadCommentPopupController = __decorateClass$2([
699
- __decorateParam$2(0, ICommandService),
700
- __decorateParam$2(1, Inject(SheetsThreadCommentPopupService)),
701
- __decorateParam$2(2, Inject(SheetsThreadCommentModel)),
702
- __decorateParam$2(3, Inject(ThreadCommentPanelService)),
703
- __decorateParam$2(4, IUniverInstanceService),
704
- __decorateParam$2(5, Inject(SheetPermissionInterceptorBaseController)),
705
- __decorateParam$2(6, IMarkSelectionService),
706
- __decorateParam$2(7, Inject(SheetsSelectionsService)),
707
- __decorateParam$2(8, IEditorBridgeService),
708
- __decorateParam$2(9, IRenderManagerService)
709
- ], SheetsThreadCommentPopupController);
710
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
711
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
712
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
713
- return kind && result && __defProp$1(target, key, result), result;
714
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a7;
715
- let ThreadCommentRemoveSheetsController = (_a7 = class extends Disposable {
716
- constructor(_sheetInterceptorService, _univerInstanceService, _threadCommentModel, _threadCommentDataSourceService) {
717
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._threadCommentModel = _threadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initSheetChange();
692
+ };
693
+ G = nn([
694
+ w(0, ie),
695
+ w(1, v(U)),
696
+ w(2, v(D)),
697
+ w(3, v(se)),
698
+ w(4, N),
699
+ w(5, v(Se)),
700
+ w(6, fe),
701
+ w(7, v(pe)),
702
+ w(8, ct),
703
+ w(9, Pe)
704
+ ], G);
705
+ var rn = Object.defineProperty, on = Object.getOwnPropertyDescriptor, sn = (o, e, n, t) => {
706
+ for (var r = t > 1 ? void 0 : t ? on(e, n) : e, i = o.length - 1, s; i >= 0; i--)
707
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
708
+ return t && r && rn(e, n, r), r;
709
+ }, L = (o, e) => (n, t) => e(n, t, o);
710
+ let K = class extends $ {
711
+ constructor(o, e, n, t) {
712
+ super(), this._sheetInterceptorService = o, this._univerInstanceService = e, this._threadCommentModel = n, this._threadCommentDataSourceService = t, this._initSheetChange();
718
713
  }
719
714
  _initSheetChange() {
720
715
  this.disposeWithMe(
721
716
  this._sheetInterceptorService.interceptCommand({
722
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
723
- var _a9;
724
- if (commandInfo.id === RemoveSheetCommand.id) {
725
- const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
726
- if (!workbook)
717
+ getMutations: (o) => {
718
+ var e;
719
+ if (o.id === Je.id) {
720
+ const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
721
+ if (!t)
727
722
  return { redos: [], undos: [] };
728
- const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId());
729
- if (!subUnitId)
723
+ const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
724
+ if (!i)
730
725
  return { redos: [], undos: [] };
731
- const commentMap = this._threadCommentModel.ensureMap(unitId, subUnitId), comments = Array.from(commentMap.values()).filter((comment) => !comment.parentId), ids = comments.map((comment) => comment.id), shouldSync = this._threadCommentDataSourceService.syncUpdateMutationToColla, redos = ids.map((id) => ({
732
- id: DeleteCommentMutation.id,
726
+ const s = this._threadCommentModel.ensureMap(r, i), a = Array.from(s.values()).filter((u) => !u.parentId), c = a.map((u) => u.id), h = this._threadCommentDataSourceService.syncUpdateMutationToColla, d = c.map((u) => ({
727
+ id: F.id,
733
728
  params: {
734
- unitId,
735
- subUnitId,
736
- commentId: id
729
+ unitId: r,
730
+ subUnitId: i,
731
+ commentId: u
737
732
  }
738
- })), undos = comments.map(({ children, ...comment }) => ({
739
- id: AddCommentMutation.id,
733
+ })), m = a.map(({ children: u, ...p }) => ({
734
+ id: oe.id,
740
735
  params: {
741
- unitId,
742
- subUnitId,
736
+ unitId: r,
737
+ subUnitId: i,
743
738
  comment: {
744
- ...comment,
745
- children: shouldSync ? children : void 0
739
+ ...p,
740
+ children: h ? u : void 0
746
741
  },
747
- sync: !shouldSync
742
+ sync: !h
748
743
  }
749
744
  }));
750
- return { redos, undos };
745
+ return { redos: d, undos: m };
751
746
  }
752
747
  return { redos: [], undos: [] };
753
- }, "getMutations")
748
+ }
754
749
  })
755
750
  );
756
751
  }
757
- }, __name(_a7, "ThreadCommentRemoveSheetsController"), _a7);
758
- ThreadCommentRemoveSheetsController = __decorateClass$1([
759
- __decorateParam$1(0, Inject(SheetInterceptorService)),
760
- __decorateParam$1(1, IUniverInstanceService),
761
- __decorateParam$1(2, Inject(ThreadCommentModel)),
762
- __decorateParam$1(3, IThreadCommentDataSourceService)
763
- ], ThreadCommentRemoveSheetsController);
764
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
765
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
766
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
767
- return kind && result && __defProp2(target, key, result), result;
768
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a8;
769
- let UniverSheetsThreadCommentUIPlugin = (_a8 = class extends Plugin {
770
- constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
771
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
772
- const { menu, ...rest } = this._config;
773
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
752
+ };
753
+ K = sn([
754
+ L(0, v(ve)),
755
+ L(1, N),
756
+ L(2, v(bt)),
757
+ L(3, ye)
758
+ ], K);
759
+ var Ne = Object.defineProperty, an = Object.getOwnPropertyDescriptor, cn = (o, e, n) => e in o ? Ne(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, hn = (o, e, n, t) => {
760
+ for (var r = t > 1 ? void 0 : t ? an(e, n) : e, i = o.length - 1, s; i >= 0; i--)
761
+ (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
762
+ return t && r && Ne(e, n, r), r;
763
+ }, re = (o, e) => (n, t) => e(n, t, o), De = (o, e, n) => cn(o, typeof e != "symbol" ? e + "" : e, n);
764
+ let Y = class extends ze {
765
+ constructor(o = Ot, e, n, t) {
766
+ super(), this._config = o, this._injector = e, this._commandService = n, this._configService = t;
767
+ const { menu: r, ...i } = this._config;
768
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Et, i);
774
769
  }
775
770
  onStarting() {
776
771
  [
777
- [SheetsThreadCommentController],
778
- [SheetsThreadCommentRenderController],
779
- [SheetsThreadCommentCopyPasteController],
780
- [SheetsThreadCommentHoverController],
781
- [ThreadCommentRemoveSheetsController],
782
- [SheetsThreadCommentPopupController],
783
- [SheetsThreadCommentPopupService]
784
- ].forEach((dep) => {
785
- this._injector.add(dep);
786
- }), [ShowAddSheetCommentModalOperation].forEach((command) => {
787
- this._commandService.registerCommand(command);
788
- }), this._injector.get(SheetsThreadCommentController);
772
+ [W],
773
+ [k],
774
+ [Z],
775
+ [z],
776
+ [K],
777
+ [G],
778
+ [U]
779
+ ].forEach((o) => {
780
+ this._injector.add(o);
781
+ }), [V].forEach((o) => {
782
+ this._commandService.registerCommand(o);
783
+ }), this._injector.get(W);
789
784
  }
790
785
  onReady() {
791
- this._injector.get(SheetsThreadCommentRenderController), this._injector.get(ThreadCommentRemoveSheetsController);
786
+ this._injector.get(k), this._injector.get(K);
792
787
  }
793
788
  onRendered() {
794
- this._injector.get(SheetsThreadCommentCopyPasteController), this._injector.get(SheetsThreadCommentHoverController), this._injector.get(SheetsThreadCommentPopupController);
795
- }
796
- }, __name(_a8, "UniverSheetsThreadCommentUIPlugin"), _a8);
797
- __publicField2(UniverSheetsThreadCommentUIPlugin, "pluginName", SHEETS_THREAD_COMMENT);
798
- __publicField2(UniverSheetsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
799
- UniverSheetsThreadCommentUIPlugin = __decorateClass([
800
- DependentOn(UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin),
801
- __decorateParam(1, Inject(Injector)),
802
- __decorateParam(2, Inject(ICommandService)),
803
- __decorateParam(3, IConfigService)
804
- ], UniverSheetsThreadCommentUIPlugin);
789
+ this._injector.get(Z), this._injector.get(z), this._injector.get(G);
790
+ }
791
+ };
792
+ De(Y, "pluginName", Oe);
793
+ De(Y, "type", b.UNIVER_SHEET);
794
+ Y = hn([
795
+ We(nt, Qe),
796
+ re(1, v(Ze)),
797
+ re(2, v(ie)),
798
+ re(3, Ge)
799
+ ], Y);
805
800
  export {
806
- AddCommentCommand,
807
- DeleteCommentCommand,
808
- DeleteCommentTreeCommand,
809
- IThreadCommentDataSourceService2 as IThreadCommentDataSourceService,
810
- IThreadCommentMentionDataService,
811
- ResolveCommentCommand,
812
- SHEETS_THREAD_COMMENT,
813
- SheetsThreadCommentPopupService,
814
- ShowAddSheetCommentModalOperation,
815
- UniverSheetsThreadCommentUIPlugin,
816
- UniverThreadCommentUIPlugin2 as UniverThreadCommentUIPlugin,
817
- UpdateCommentCommand
801
+ En as AddCommentCommand,
802
+ On as DeleteCommentCommand,
803
+ Un as DeleteCommentTreeCommand,
804
+ Rn as IThreadCommentDataSourceService,
805
+ Mn as IThreadCommentMentionDataService,
806
+ $n as ResolveCommentCommand,
807
+ Oe as SHEETS_THREAD_COMMENT,
808
+ U as SheetsThreadCommentPopupService,
809
+ V as ShowAddSheetCommentModalOperation,
810
+ Y as UniverSheetsThreadCommentUIPlugin,
811
+ wn as UniverThreadCommentUIPlugin,
812
+ Nn as UpdateCommentCommand
818
813
  };