@univerjs/sheets-thread-comment-ui 0.16.1 → 0.17.0-insiders.20260318-d69dc16

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