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

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