@univerjs/sheets-note-ui 0.17.0 → 0.18.0

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 (76) hide show
  1. package/lib/cjs/index.js +4 -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 +4 -804
  15. package/lib/es/locale/ca-ES.js +1 -13
  16. package/lib/es/locale/en-US.js +1 -13
  17. package/lib/es/locale/es-ES.js +1 -13
  18. package/lib/es/locale/fa-IR.js +1 -13
  19. package/lib/es/locale/fr-FR.js +1 -13
  20. package/lib/es/locale/ja-JP.js +1 -13
  21. package/lib/es/locale/ko-KR.js +1 -13
  22. package/lib/es/locale/ru-RU.js +1 -13
  23. package/lib/es/locale/sk-SK.js +1 -13
  24. package/lib/es/locale/vi-VN.js +1 -13
  25. package/lib/es/locale/zh-CN.js +1 -13
  26. package/lib/es/locale/zh-TW.js +1 -13
  27. package/lib/index.css +31 -1
  28. package/lib/index.js +4 -804
  29. package/lib/locale/ca-ES.js +1 -13
  30. package/lib/locale/en-US.js +1 -13
  31. package/lib/locale/es-ES.js +1 -13
  32. package/lib/locale/fa-IR.js +1 -13
  33. package/lib/locale/fr-FR.js +1 -13
  34. package/lib/locale/ja-JP.js +1 -13
  35. package/lib/locale/ko-KR.js +1 -13
  36. package/lib/locale/ru-RU.js +1 -13
  37. package/lib/locale/sk-SK.js +1 -13
  38. package/lib/locale/vi-VN.js +1 -13
  39. package/lib/locale/zh-CN.js +1 -13
  40. package/lib/locale/zh-TW.js +1 -13
  41. package/lib/types/commands/operations/add-note-popup.operation.d.ts +16 -1
  42. package/lib/types/config/config.d.ts +16 -1
  43. package/lib/types/controllers/sheets-cell-content.controller.d.ts +15 -0
  44. package/lib/types/controllers/sheets-note-attachment.controller.d.ts +15 -0
  45. package/lib/types/controllers/sheets-note-popup.controller.d.ts +15 -0
  46. package/lib/types/controllers/sheets-note-ui.controller.d.ts +15 -0
  47. package/lib/types/locale/ca-ES.d.ts +16 -1
  48. package/lib/types/locale/es-ES.d.ts +16 -1
  49. package/lib/types/locale/fa-IR.d.ts +16 -1
  50. package/lib/types/locale/fr-FR.d.ts +16 -1
  51. package/lib/types/locale/ja-JP.d.ts +16 -1
  52. package/lib/types/locale/ko-KR.d.ts +16 -1
  53. package/lib/types/locale/ru-RU.d.ts +16 -1
  54. package/lib/types/locale/sk-SK.d.ts +16 -1
  55. package/lib/types/locale/vi-VN.d.ts +16 -1
  56. package/lib/types/locale/zh-CN.d.ts +16 -1
  57. package/lib/types/locale/zh-TW.d.ts +16 -1
  58. package/lib/types/menu/note.menu.d.ts +17 -2
  59. package/lib/types/menu/schema.d.ts +16 -1
  60. package/lib/types/plugin.d.ts +16 -1
  61. package/lib/types/services/sheets-note-popup.service.d.ts +19 -3
  62. package/lib/types/views/note.d.ts +17 -2
  63. package/lib/umd/index.js +4 -1
  64. package/lib/umd/locale/ca-ES.js +1 -1
  65. package/lib/umd/locale/en-US.js +1 -1
  66. package/lib/umd/locale/es-ES.js +1 -1
  67. package/lib/umd/locale/fa-IR.js +1 -1
  68. package/lib/umd/locale/fr-FR.js +1 -1
  69. package/lib/umd/locale/ja-JP.js +1 -1
  70. package/lib/umd/locale/ko-KR.js +1 -1
  71. package/lib/umd/locale/ru-RU.js +1 -1
  72. package/lib/umd/locale/sk-SK.js +1 -1
  73. package/lib/umd/locale/vi-VN.js +1 -1
  74. package/lib/umd/locale/zh-CN.js +1 -1
  75. package/lib/umd/locale/zh-TW.js +1 -1
  76. package/package.json +13 -13
package/lib/index.js CHANGED
@@ -1,804 +1,4 @@
1
- var ye = Object.defineProperty;
2
- var $e = (i, e, t) => e in i ? ye(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var P = (i, e, t) => $e(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { Inject as g, IUniverInstanceService as k, Disposable as y, InterceptorEffectEnum as xe, UniverInstanceType as $, DisposableCollection as He, RANGE_TYPE as se, Rectangle as Oe, ObjectMatrix as W, CommandType as Te, LocaleService as Re, generateRandomId as Le, ICommandService as _e, DependentOn as Ue, Injector as De, IConfigService as Ve, Plugin as ke, merge as Ze, touchDependencies as ae } from "@univerjs/core";
5
- import { IRenderManagerService as G } from "@univerjs/engine-render";
6
- import { SheetInterceptorService as je, INTERCEPTOR_POINT as Be, SheetsSelectionsService as K, WorksheetEditPermission as fe, WorkbookEditablePermission as Ce, getSheetCommandTarget as Ae } from "@univerjs/sheets";
7
- import { SheetsNoteModel as x, SheetToggleNotePopupCommand as ge, SheetDeleteNoteCommand as ve, SheetUpdateNoteCommand as Fe, UniverSheetsNotePlugin as We } from "@univerjs/sheets-note";
8
- import { debounceTime as ze, BehaviorSubject as Ge, switchMap as Ke, of as qe, map as Z, combineLatest as Ye } from "rxjs";
9
- import { CellPopupManagerService as me, IEditorBridgeService as Je, HoverManagerService as Qe, SheetSkeletonManagerService as ce, getCurrentRangeDisable$ as Se } from "@univerjs/sheets-ui";
10
- import { debounceTime as Xe } from "rxjs/operators";
11
- import { IZenZoneService as et, MenuItemType as q, getMenuHiddenObservable as tt, ContextMenuPosition as it, ContextMenuGroup as ot, useDependency as E, useConfigValue as rt, useDebounceFn as nt, ComponentManager as st, IMenuManagerService as at } from "@univerjs/ui";
12
- import { useRef as Ne, createElement as j, forwardRef as Y, useState as ct, useEffect as ue, useCallback as le } from "react";
13
- import { jsx as ut } from "react/jsx-runtime";
14
- import { Textarea as lt, clsx as pt } from "@univerjs/design";
15
- var ht = Object.getOwnPropertyDescriptor, dt = (i, e, t, o) => {
16
- for (var r = o > 1 ? void 0 : o ? ht(e, t) : e, s = i.length - 1, n; s >= 0; s--)
17
- (n = i[s]) && (r = n(r) || r);
18
- return r;
19
- }, O = (i, e) => (t, o) => e(t, o, i);
20
- let R = class extends y {
21
- constructor(i, e, t, o) {
22
- super(), this._sheetInterceptorService = i, this._sheetsNoteModel = e, this._renderManagerService = t, this._univerInstanceService = o, this._initViewModelIntercept(), this._initSkeletonChange();
23
- }
24
- _initViewModelIntercept() {
25
- this.disposeWithMe(
26
- this._sheetInterceptorService.intercept(
27
- Be.CELL_CONTENT,
28
- {
29
- effect: xe.Style,
30
- handler: (i, e, t) => {
31
- const { row: o, col: r, unitId: s, subUnitId: n } = e;
32
- return this._sheetsNoteModel.getNote(s, n, { row: o, col: r }) && ((!i || i === e.rawData) && (i = { ...e.rawData }), i.markers = {
33
- ...i == null ? void 0 : i.markers,
34
- tr: {
35
- color: "#FFBD37",
36
- size: 6
37
- }
38
- }), t(i);
39
- },
40
- priority: 100
41
- }
42
- )
43
- );
44
- }
45
- _initSkeletonChange() {
46
- const i = () => {
47
- var r;
48
- const e = this._univerInstanceService.getCurrentUnitForType($.UNIVER_SHEET);
49
- if (!e) return;
50
- const t = e.getUnitId(), o = this._renderManagerService.getRenderById(t);
51
- (r = o == null ? void 0 : o.mainComponent) == null || r.makeForceDirty();
52
- };
53
- this.disposeWithMe(this._sheetsNoteModel.change$.pipe(ze(16)).subscribe(() => {
54
- i();
55
- }));
56
- }
57
- };
58
- R = dt([
59
- O(0, g(je)),
60
- O(1, g(x)),
61
- O(2, G),
62
- O(3, k)
63
- ], R);
64
- const J = "SHEET_NOTE_COMPONENT";
65
- var _t = Object.getOwnPropertyDescriptor, ft = (i, e, t, o) => {
66
- for (var r = o > 1 ? void 0 : o ? _t(e, t) : e, s = i.length - 1, n; s >= 0; s--)
67
- (n = i[s]) && (r = n(r) || r);
68
- return r;
69
- }, pe = (i, e) => (t, o) => e(t, o, i);
70
- let I = class extends y {
71
- constructor(e, t) {
72
- super();
73
- P(this, "_lastPopup", null);
74
- P(this, "_activePopup");
75
- P(this, "_activePopup$", new Ge(null));
76
- P(this, "activePopup$", this._activePopup$.asObservable());
77
- this._zenZoneService = e, this._cellPopupManagerService = t, this._initZenVisible(), this.disposeWithMe(() => {
78
- this._activePopup$.complete();
79
- });
80
- }
81
- get activePopup() {
82
- return this._activePopup;
83
- }
84
- _initZenVisible() {
85
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
86
- e && this.hidePopup();
87
- }));
88
- }
89
- dispose() {
90
- super.dispose(), this.hidePopup();
91
- }
92
- showPopup(e, t) {
93
- var l;
94
- const { row: o, col: r, unitId: s, subUnitId: n } = e;
95
- if (this._activePopup && o === this._activePopup.row && r === this._activePopup.col && s === this._activePopup.unitId && n === ((l = this.activePopup) == null ? void 0 : l.subUnitId)) {
96
- this._activePopup = e, this._activePopup$.next(e);
97
- return;
98
- }
99
- if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
100
- return;
101
- this._activePopup = e, this._activePopup$.next(e);
102
- const a = this._cellPopupManagerService.showPopup(
103
- {
104
- unitId: s,
105
- subUnitId: n,
106
- row: o,
107
- col: r
108
- },
109
- {
110
- componentKey: J,
111
- onClickOutside: () => {
112
- this.hidePopup();
113
- },
114
- direction: "horizontal",
115
- extraProps: {
116
- location: e
117
- },
118
- priority: 3
119
- }
120
- );
121
- if (!a)
122
- throw new Error("[SheetsNotePopupService]: cannot show popup!");
123
- const u = new He();
124
- u.add(a), u.add({
125
- dispose: () => {
126
- t == null || t();
127
- }
128
- }), this._lastPopup = u;
129
- }
130
- hidePopup(e) {
131
- this._activePopup && (!e && !this._activePopup.temp || (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null)));
132
- }
133
- persistPopup() {
134
- !this._activePopup || !this._activePopup.temp || (this._activePopup = {
135
- ...this._activePopup,
136
- temp: !1
137
- }, this._activePopup$.next(this._activePopup));
138
- }
139
- };
140
- I = ft([
141
- pe(0, et),
142
- pe(1, g(me))
143
- ], I);
144
- var Ct = Object.getOwnPropertyDescriptor, gt = (i, e, t, o) => {
145
- for (var r = o > 1 ? void 0 : o ? Ct(e, t) : e, s = i.length - 1, n; s >= 0; s--)
146
- (n = i[s]) && (r = n(r) || r);
147
- return r;
148
- }, w = (i, e) => (t, o) => e(t, o, i);
149
- let L = class extends y {
150
- constructor(e, t, o, r, s, n) {
151
- super();
152
- P(this, "_isSwitchingSheet", !1);
153
- this._sheetsNotePopupService = e, this._sheetsNoteModel = t, this._sheetSelectionService = o, this._editorBridgeService = r, this._renderManagerService = s, this._hoverManagerService = n, this._initSelectionUpdateListener(), this._initEditorBridge(), this._initHoverEvent(), this._initDeleteNoteListener();
154
- }
155
- _handleSelectionChange(e, t, o) {
156
- var d, _, m;
157
- const r = (d = e[0]) == null ? void 0 : d.range, s = this._renderManagerService.getRenderById(t), n = (_ = s == null ? void 0 : s.with(ce).getSkeletonParam(o)) == null ? void 0 : _.skeleton;
158
- if (!n || !r)
159
- return;
160
- const a = n.getCellWithCoordByIndex(r.startRow, r.startColumn);
161
- if ((((m = r.rangeType) != null ? m : se.NORMAL) !== se.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && Oe.equals(a.mergeInfo, r))) {
162
- this._sheetsNotePopupService.hidePopup();
163
- return;
164
- }
165
- const l = a.actualRow, c = a.actualColumn, p = this._sheetsNoteModel.getNote(t, o, { row: l, col: c });
166
- p != null && p.show || (p ? this._sheetsNotePopupService.showPopup({
167
- unitId: t,
168
- subUnitId: o,
169
- noteId: p.id,
170
- row: l,
171
- col: c
172
- }) : this._sheetsNotePopupService.hidePopup(!0));
173
- }
174
- _initSelectionUpdateListener() {
175
- this.disposeWithMe(
176
- this._sheetSelectionService.selectionMoveEnd$.subscribe((e) => {
177
- if (this._isSwitchingSheet)
178
- return;
179
- const t = this._sheetSelectionService.currentSelectionParam;
180
- t && this._handleSelectionChange(e, t.unitId, t.sheetId);
181
- })
182
- );
183
- }
184
- _initEditorBridge() {
185
- this.disposeWithMe(
186
- this._editorBridgeService.visible$.subscribe((e) => {
187
- e.visible && this._sheetsNotePopupService.hidePopup(!0);
188
- })
189
- );
190
- }
191
- _initHoverEvent() {
192
- this.disposeWithMe(
193
- this._hoverManagerService.currentCell$.pipe(Xe(100)).subscribe((e) => {
194
- var p;
195
- if (!(e != null && e.location)) return;
196
- const { unitId: t, subUnitId: o, row: r, col: s } = e.location, n = this._renderManagerService.getRenderById(t), a = (p = n == null ? void 0 : n.with(ce).getSkeletonParam(o)) == null ? void 0 : p.skeleton;
197
- let u = r, l = s, c = this._sheetsNoteModel.getNote(t, o, { row: u, col: l });
198
- if (!c && a) {
199
- const d = a.getCellWithCoordByIndex(r, s), { startRow: _, endRow: m, startColumn: N, endColumn: S } = d.mergeInfo;
200
- if (_ !== m || N !== S) {
201
- const h = this._sheetsNoteModel.getSheetNotes(t, o);
202
- if (h) {
203
- for (const [C, f] of h)
204
- if (f.row >= _ && f.row <= m && f.col >= N && f.col <= S) {
205
- c = f, u = f.row, l = f.col;
206
- break;
207
- }
208
- }
209
- }
210
- }
211
- c != null && c.show || (c ? this._sheetsNotePopupService.showPopup({
212
- unitId: t,
213
- subUnitId: o,
214
- noteId: c.id,
215
- row: u,
216
- col: l,
217
- temp: !0
218
- }) : this._sheetsNotePopupService.hidePopup());
219
- })
220
- );
221
- }
222
- _initDeleteNoteListener() {
223
- this.disposeWithMe(
224
- this._sheetsNoteModel.change$.subscribe((e) => {
225
- if (!this._sheetsNotePopupService.activePopup) return;
226
- const { unitId: t, subUnitId: o, noteId: r, row: s, col: n } = this._sheetsNotePopupService.activePopup, { oldNote: a, newNote: u } = e;
227
- u === null && e.unitId === t && e.subUnitId === o && (a != null && a.id && a.id === r || (a == null ? void 0 : a.row) === s && a.col === n) && this._sheetsNotePopupService.hidePopup(!0);
228
- })
229
- );
230
- }
231
- };
232
- L = gt([
233
- w(0, g(I)),
234
- w(1, g(x)),
235
- w(2, g(K)),
236
- w(3, Je),
237
- w(4, G),
238
- w(5, g(Qe))
239
- ], L);
240
- const vt = "@univerjs/sheets-note-ui", mt = "0.17.0", Pe = {
241
- name: vt,
242
- version: mt
243
- }, Ie = "sheets-note-ui.config", he = {};
244
- var St = Object.getOwnPropertyDescriptor, Nt = (i, e, t, o) => {
245
- for (var r = o > 1 ? void 0 : o ? St(e, t) : e, s = i.length - 1, n; s >= 0; s--)
246
- (n = i[s]) && (r = n(r) || r);
247
- return r;
248
- }, T = (i, e) => (t, o) => e(t, o, i);
249
- let U = class extends y {
250
- constructor(e, t, o, r) {
251
- super();
252
- P(this, "_noteMatrix", new W());
253
- this._sheetsNoteModel = e, this._univerInstanceService = t, this._cellPopupManagerService = o, this._sheetsNotePopupService = r, this._initNoteChangeListener();
254
- }
255
- _showPopup(e, t, o, r) {
256
- return this._sheetsNotePopupService.hidePopup(!0), this._cellPopupManagerService.showPopup(
257
- {
258
- unitId: e,
259
- subUnitId: t,
260
- row: o,
261
- col: r
262
- },
263
- {
264
- componentKey: J,
265
- direction: "horizontal",
266
- extraProps: {
267
- location: {
268
- unitId: e,
269
- subUnitId: t,
270
- row: o,
271
- col: r
272
- }
273
- },
274
- priority: 3
275
- }
276
- );
277
- }
278
- dispose() {
279
- super.dispose(), this._noteMatrix.forValue((e, t, o) => {
280
- o.dispose();
281
- });
282
- }
283
- _initSheet(e, t) {
284
- var s;
285
- this._noteMatrix.forValue((n, a, u) => {
286
- u.dispose();
287
- }), this._noteMatrix = new W();
288
- const r = (n, a, u, l, c) => {
289
- const p = this._noteMatrix, d = p.getValue(u, l);
290
- if (c != null && c.show) {
291
- if (!d) {
292
- const _ = this._showPopup(n, a, u, l);
293
- _ && p.setValue(u, l, _);
294
- }
295
- } else
296
- d && (d.dispose(), p.realDeleteValue(u, l));
297
- };
298
- return (s = this._sheetsNoteModel.getSheetNotes(e, t)) == null || s.forEach((n) => {
299
- r(e, t, n.row, n.col, n);
300
- }), this._sheetsNoteModel.change$.subscribe((n) => {
301
- if (!(n.unitId !== e || n.subUnitId !== t))
302
- switch (n.type) {
303
- case "ref": {
304
- const { unitId: a, subUnitId: u, oldNote: l, newNote: c } = n;
305
- if (!c.show) return;
306
- const p = this._noteMatrix, { row: d, col: _ } = l, { row: m, col: N } = c, S = p.getValue(d, _);
307
- S && (S.dispose(), p.realDeleteValue(d, _));
308
- const h = this._showPopup(a, u, m, N);
309
- h && p.setValue(m, N, h);
310
- break;
311
- }
312
- case "update": {
313
- const { unitId: a, subUnitId: u, oldNote: l, newNote: c } = n, p = c ? c.row : l.row, d = c ? c.col : l.col;
314
- r(a, u, p, d, c);
315
- break;
316
- }
317
- }
318
- });
319
- }
320
- _initNoteChangeListener() {
321
- this.disposeWithMe(
322
- this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET).pipe(
323
- Ke((e) => {
324
- var t;
325
- return (t = e == null ? void 0 : e.activeSheet$) != null ? t : qe(null);
326
- })
327
- ).subscribe((e) => {
328
- if (e) {
329
- const t = this._initSheet(e.getUnitId(), e.getSheetId());
330
- return () => {
331
- t.unsubscribe();
332
- };
333
- } else
334
- this._noteMatrix.forValue((t, o, r) => {
335
- r.dispose();
336
- }), this._noteMatrix = new W();
337
- })
338
- );
339
- }
340
- };
341
- U = Nt([
342
- T(0, g(x)),
343
- T(1, g(k)),
344
- T(2, g(me)),
345
- T(3, g(I))
346
- ], U);
347
- function B({ ref: i, ...e }) {
348
- const { icon: t, id: o, className: r, extend: s, ...n } = e, a = `univerjs-icon univerjs-icon-${o} ${r || ""}`.trim(), u = Ne(`_${wt()}`);
349
- return we(t, `${o}`, {
350
- defIds: t.defIds,
351
- idSuffix: u.current
352
- }, {
353
- ref: i,
354
- className: a,
355
- ...n
356
- }, s);
357
- }
358
- function we(i, e, t, o, r) {
359
- return j(i.tag, {
360
- key: e,
361
- ...Pt(i, t, r),
362
- ...o
363
- }, (It(i, t).children || []).map((s, n) => we(s, `${e}-${i.tag}-${n}`, t, void 0, r)));
364
- }
365
- function Pt(i, e, t) {
366
- const o = { ...i.attrs };
367
- t != null && t.colorChannel1 && o.fill === "colorChannel1" && (o.fill = t.colorChannel1), i.tag === "mask" && o.id && (o.id = o.id + e.idSuffix), Object.entries(o).forEach(([s, n]) => {
368
- s === "mask" && typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
369
- });
370
- const { defIds: r } = e;
371
- return !r || r.length === 0 || (i.tag === "use" && o["xlink:href"] && (o["xlink:href"] = o["xlink:href"] + e.idSuffix), Object.entries(o).forEach(([s, n]) => {
372
- typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
373
- })), o;
374
- }
375
- function It(i, e) {
376
- var o;
377
- const { defIds: t } = e;
378
- return !t || t.length === 0 ? i : i.tag === "defs" && ((o = i.children) != null && o.length) ? {
379
- ...i,
380
- children: i.children.map((r) => typeof r.attrs.id == "string" && t && t.includes(r.attrs.id) ? {
381
- ...r,
382
- attrs: {
383
- ...r.attrs,
384
- id: r.attrs.id + e.idSuffix
385
- }
386
- } : r)
387
- } : i;
388
- }
389
- function wt() {
390
- return Math.random().toString(36).substring(2, 8);
391
- }
392
- B.displayName = "UniverIcon";
393
- const Mt = {
394
- tag: "svg",
395
- attrs: {
396
- xmlns: "http://www.w3.org/2000/svg",
397
- fill: "none",
398
- viewBox: "0 0 16 16",
399
- width: "1em",
400
- height: "1em"
401
- },
402
- children: [
403
- {
404
- tag: "path",
405
- attrs: {
406
- fill: "currentColor",
407
- d: "M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"
408
- }
409
- },
410
- {
411
- tag: "path",
412
- attrs: {
413
- fill: "currentColor",
414
- d: "M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"
415
- }
416
- },
417
- {
418
- tag: "path",
419
- attrs: {
420
- fill: "currentColor",
421
- d: "M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"
422
- }
423
- },
424
- {
425
- tag: "path",
426
- attrs: {
427
- fill: "currentColor",
428
- d: "M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"
429
- }
430
- },
431
- {
432
- tag: "path",
433
- attrs: {
434
- fill: "currentColor",
435
- d: "M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"
436
- }
437
- },
438
- {
439
- tag: "path",
440
- attrs: {
441
- fill: "currentColor",
442
- d: "M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"
443
- }
444
- }
445
- ]
446
- }, Me = Y(function(e, t) {
447
- return j(B, Object.assign({}, e, {
448
- id: "add-note-icon",
449
- ref: t,
450
- icon: Mt
451
- }));
452
- });
453
- Me.displayName = "AddNoteIcon";
454
- const bt = {
455
- tag: "svg",
456
- attrs: {
457
- xmlns: "http://www.w3.org/2000/svg",
458
- fill: "none",
459
- viewBox: "0 0 16 16",
460
- width: "1em",
461
- height: "1em"
462
- },
463
- children: [
464
- {
465
- tag: "path",
466
- attrs: {
467
- fill: "currentColor",
468
- d: "M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"
469
- }
470
- },
471
- {
472
- tag: "path",
473
- attrs: {
474
- fill: "currentColor",
475
- d: "M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"
476
- }
477
- },
478
- {
479
- tag: "path",
480
- attrs: {
481
- fill: "currentColor",
482
- d: "M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"
483
- }
484
- },
485
- {
486
- tag: "path",
487
- attrs: {
488
- fill: "currentColor",
489
- d: "M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"
490
- }
491
- },
492
- {
493
- tag: "path",
494
- attrs: {
495
- fill: "currentColor",
496
- d: "M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"
497
- }
498
- }
499
- ]
500
- }, be = Y(function(e, t) {
501
- return j(B, Object.assign({}, e, {
502
- id: "delete-note-icon",
503
- ref: t,
504
- icon: bt
505
- }));
506
- });
507
- be.displayName = "DeleteNoteIcon";
508
- const Et = {
509
- tag: "svg",
510
- attrs: {
511
- xmlns: "http://www.w3.org/2000/svg",
512
- fill: "none",
513
- viewBox: "0 0 16 16",
514
- width: "1em",
515
- height: "1em"
516
- },
517
- children: [
518
- {
519
- tag: "path",
520
- attrs: {
521
- fill: "currentColor",
522
- d: "M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"
523
- }
524
- },
525
- {
526
- tag: "path",
527
- attrs: {
528
- fill: "currentColor",
529
- d: "M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"
530
- }
531
- },
532
- {
533
- tag: "path",
534
- attrs: {
535
- fill: "currentColor",
536
- d: "M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"
537
- }
538
- },
539
- {
540
- tag: "path",
541
- attrs: {
542
- fill: "currentColor",
543
- d: "M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"
544
- }
545
- },
546
- {
547
- tag: "path",
548
- attrs: {
549
- fill: "currentColor",
550
- d: "M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"
551
- }
552
- },
553
- {
554
- tag: "path",
555
- attrs: {
556
- fill: "currentColor",
557
- d: "M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"
558
- }
559
- }
560
- ]
561
- }, Ee = Y(function(e, t) {
562
- return j(B, Object.assign({}, e, {
563
- id: "hide-note-icon",
564
- ref: t,
565
- icon: Et
566
- }));
567
- });
568
- Ee.displayName = "HideNoteIcon";
569
- const D = {
570
- id: "sheet.operation.add-note-popup",
571
- type: Te.OPERATION,
572
- handler: async (i, e) => {
573
- var l;
574
- const t = i.get(K), o = i.get(I), s = i.get(k).getCurrentUnitForType($.UNIVER_SHEET);
575
- if (!s)
576
- return !1;
577
- const n = s.getActiveSheet(), a = t.getCurrentLastSelection();
578
- if (!(a != null && a.primary))
579
- return !1;
580
- const { primary: u } = a;
581
- return o.showPopup({
582
- unitId: s.getUnitId(),
583
- subUnitId: n.getSheetId(),
584
- row: u.actualRow,
585
- col: u.actualColumn,
586
- temp: !1,
587
- trigger: (l = e == null ? void 0 : e.trigger) != null ? l : "add-note"
588
- }), !0;
589
- }
590
- };
591
- function Q(i) {
592
- const e = i.get(K), t = i.get(k);
593
- return e.selectionMoveEnd$.pipe(Z(() => {
594
- const o = e.getCurrentLastSelection();
595
- if (!(o != null && o.primary)) return !1;
596
- const r = Ae(t);
597
- if (!r) return !1;
598
- const { actualColumn: s, actualRow: n } = o.primary;
599
- return !!i.get(x).getNote(r.unitId, r.subUnitId, { row: n, col: s });
600
- }));
601
- }
602
- function yt(i) {
603
- return {
604
- id: D.id,
605
- type: q.BUTTON,
606
- title: "rightClick.addNote",
607
- icon: "AddNoteIcon",
608
- hidden$: Ye([tt(i, $.UNIVER_SHEET), Q(i)]).pipe(Z(([e, t]) => e || t)),
609
- disabled$: Se(i, { workbookTypes: [Ce], worksheetTypes: [fe] }),
610
- commandId: D.id
611
- };
612
- }
613
- function $t(i) {
614
- return {
615
- id: ve.id,
616
- type: q.BUTTON,
617
- title: "rightClick.deleteNote",
618
- icon: "DeleteNoteIcon",
619
- hidden$: Q(i).pipe(Z((e) => !e)),
620
- disabled$: Se(i, { workbookTypes: [Ce], worksheetTypes: [fe] })
621
- };
622
- }
623
- function xt(i) {
624
- return {
625
- id: ge.id,
626
- type: q.BUTTON,
627
- title: "rightClick.toggleNote",
628
- icon: "HideNoteIcon",
629
- hidden$: Q(i).pipe(Z((e) => !e))
630
- };
631
- }
632
- const Ht = {
633
- [it.MAIN_AREA]: {
634
- [ot.OTHERS]: {
635
- order: 0,
636
- [D.id]: {
637
- order: 0,
638
- menuItemFactory: yt
639
- },
640
- [ve.id]: {
641
- order: 0,
642
- menuItemFactory: $t
643
- },
644
- [ge.id]: {
645
- order: 0,
646
- menuItemFactory: xt
647
- }
648
- }
649
- }
650
- }, Ot = (i) => {
651
- var S;
652
- const { popup: e } = i, t = E(x), o = E(Re), r = E(G), s = E(I), n = rt(Ie), a = (S = e.extraProps) == null ? void 0 : S.location;
653
- if (!a)
654
- return console.error("Popup extraProps or location is undefined."), null;
655
- const u = Ne(null), l = r.getRenderById(a.unitId), [c, p] = ct(null);
656
- ue(() => {
657
- var X, ee, te, ie, oe, re;
658
- const { unitId: h, subUnitId: C, row: f, col: H } = a, v = t.getNote(h, C, { row: f, col: H }), F = (te = (ee = v == null ? void 0 : v.width) != null ? ee : (X = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : X.width) != null ? te : 160, b = (re = (oe = v == null ? void 0 : v.height) != null ? oe : (ie = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : ie.height) != null ? re : 72;
659
- if (v)
660
- p(v);
661
- else {
662
- const ne = {
663
- id: Le(6),
664
- width: F,
665
- height: b,
666
- note: ""
667
- };
668
- p(ne), _(ne);
669
- }
670
- u.current && (u.current.style.width = `${F}px`, u.current.style.height = `${b}px`);
671
- }, [a, u]), ue(() => {
672
- if (!a || a.temp || !a.trigger || !u.current) return;
673
- const h = requestAnimationFrame(() => {
674
- var C;
675
- (C = u.current) == null || C.focus();
676
- });
677
- return () => cancelAnimationFrame(h);
678
- }, [a]);
679
- const d = E(_e), _ = nt((h) => {
680
- if (!a) return;
681
- const { unitId: C, subUnitId: f, row: H, col: v } = a;
682
- if (!d.syncExecuteCommand(Fe.id, {
683
- unitId: C,
684
- sheetId: f,
685
- row: H,
686
- col: v,
687
- note: h
688
- })) {
689
- const b = t.getNote(C, f, { noteId: h.id, row: H, col: v });
690
- b ? p(b) : s.hidePopup(!0);
691
- }
692
- }), m = le((h) => {
693
- if (!c || h === c.note) return;
694
- const C = { ...c, note: h };
695
- p(C), _(C);
696
- }, [c]), N = le((h, C) => {
697
- if (!c || h === c.width && C === c.height) return;
698
- const f = { ...c, width: h, height: C };
699
- p(f), _(f);
700
- }, [c]);
701
- return /* @__PURE__ */ ut(
702
- lt,
703
- {
704
- ref: u,
705
- "data-u-comp": "note-textarea",
706
- className: pt("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
707
- value: c == null ? void 0 : c.note,
708
- placeholder: o.t("note.placeholder"),
709
- onResize: N,
710
- onValueChange: m,
711
- onWheel: (h) => {
712
- document.activeElement !== u.current && l.engine.getCanvasElement().dispatchEvent(new WheelEvent(h.type, h.nativeEvent));
713
- }
714
- }
715
- );
716
- };
717
- var Tt = Object.getOwnPropertyDescriptor, Rt = (i, e, t, o) => {
718
- for (var r = o > 1 ? void 0 : o ? Tt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
719
- (n = i[s]) && (r = n(r) || r);
720
- return r;
721
- }, z = (i, e) => (t, o) => e(t, o, i);
722
- let V = class extends y {
723
- constructor(i, e, t) {
724
- super(), this._componentManager = i, this._menuManagerService = e, this._commandService = t, this._initComponents(), this._initMenu(), this._initCommands();
725
- }
726
- _initComponents() {
727
- [
728
- [J, Ot],
729
- ["AddNoteIcon", Me],
730
- ["DeleteNoteIcon", be],
731
- ["HideNoteIcon", Ee]
732
- ].forEach(([i, e]) => {
733
- this.disposeWithMe(
734
- this._componentManager.register(i, e)
735
- );
736
- });
737
- }
738
- _initMenu() {
739
- this._menuManagerService.mergeMenu(Ht);
740
- }
741
- _initCommands() {
742
- this._commandService.registerCommand(D);
743
- }
744
- };
745
- V = Rt([
746
- z(0, g(st)),
747
- z(1, g(at)),
748
- z(2, _e)
749
- ], V);
750
- var Lt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, Dt = (i, e, t) => e in i ? Lt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Vt = (i, e, t, o) => {
751
- for (var r = o > 1 ? void 0 : o ? Ut(e, t) : e, s = i.length - 1, n; s >= 0; s--)
752
- (n = i[s]) && (r = n(r) || r);
753
- return r;
754
- }, de = (i, e) => (t, o) => e(t, o, i), A = (i, e, t) => Dt(i, typeof e != "symbol" ? e + "" : e, t);
755
- let M = class extends ke {
756
- constructor(i = he, e, t) {
757
- super(), this._config = i, this._injector = e, this._configService = t;
758
- const { menu: o, ...r } = Ze(
759
- {},
760
- he,
761
- this._config
762
- );
763
- o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(Ie, r);
764
- }
765
- onStarting() {
766
- [
767
- [I],
768
- [R],
769
- [L],
770
- [V],
771
- [U]
772
- ].forEach((i) => {
773
- this._injector.add(i);
774
- });
775
- }
776
- onReady() {
777
- ae(this._injector, [
778
- [V],
779
- [R]
780
- ]);
781
- }
782
- onRendered() {
783
- ae(this._injector, [
784
- [L],
785
- [U]
786
- ]);
787
- }
788
- };
789
- A(M, "pluginName", "SHEET_NOTE_UI_PLUGIN");
790
- A(M, "packageName", Pe.name);
791
- A(M, "version", Pe.version);
792
- A(M, "type", $.UNIVER_SHEET);
793
- M = Vt([
794
- Ue(We),
795
- de(1, g(De)),
796
- de(2, Ve)
797
- ], M);
798
- export {
799
- R as SheetsCellContentController,
800
- Ot as SheetsNote,
801
- L as SheetsNotePopupController,
802
- I as SheetsNotePopupService,
803
- M as UniverSheetsNoteUIPlugin
804
- };
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,LocaleService as u,ObjectMatrix as d,Plugin as f,RANGE_TYPE as p,Rectangle as m,UniverInstanceType as h,generateRandomId as ee,merge as g,touchDependencies as _}from"@univerjs/core";import{IRenderManagerService as v}from"@univerjs/engine-render";import{INTERCEPTOR_POINT as y,SheetInterceptorService as te,SheetsSelectionsService as b,WorkbookEditablePermission as x,WorksheetEditPermission as S,getSheetCommandTarget as ne}from"@univerjs/sheets";import{SheetDeleteNoteCommand as C,SheetToggleNotePopupCommand as w,SheetUpdateNoteCommand as re,SheetsNoteModel as T,UniverSheetsNotePlugin as ie}from"@univerjs/sheets-note";import{BehaviorSubject as ae,combineLatest as oe,debounceTime as se,map as E,of as ce,switchMap as D}from"rxjs";import{CellPopupManagerService as O,HoverManagerService as le,IEditorBridgeService as ue,SheetSkeletonManagerService as k,getCurrentRangeDisable$ as A}from"@univerjs/sheets-ui";import{debounceTime as de}from"rxjs/operators";import{ComponentManager as fe,ContextMenuGroup as pe,ContextMenuPosition as me,IMenuManagerService as he,IZenZoneService as ge,MenuItemType as j,getMenuHiddenObservable as _e,useConfigValue as ve,useDebounceFn as ye,useDependency as M}from"@univerjs/ui";import{AddNoteIcon as N,DeleteNoteIcon as P,HideNoteIcon as be}from"@univerjs/icons";import{Textarea as xe,clsx as F}from"@univerjs/design";import{useCallback as I,useEffect as L,useRef as Se,useState as Ce}from"react";import{jsx as we}from"react/jsx-runtime";function R(e,t){return function(n,r){t(n,r,e)}}function z(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 B=class extends n{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=n,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(y.CELL_CONTENT,{effect:l.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsNoteModel.getNote(a,o,{row:r,col: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._sheetsNoteModel.change$.pipe(se(16)).subscribe(()=>{e()}))}};B=z([R(0,s(te)),R(1,s(T)),R(2,v),R(3,o)],B);const V=`SHEET_NOTE_COMPONENT`;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 Te(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 Ee(e){var t=Te(e,`string`);return H(t)==`symbol`?t:t+``}function U(e,t,n){return(t=Ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let W=class extends n{get activePopup(){return this._activePopup}constructor(e,t){super(),this._zenZoneService=e,this._cellPopupManagerService=t,U(this,`_lastPopup`,null),U(this,`_activePopup`,void 0),U(this,`_activePopup$`,new ae(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({unitId:o,subUnitId:s,row:i,col:a},{componentKey:V,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,extraProps:{location:e},priority:3});if(!c)throw Error(`[SheetsNotePopupService]: cannot show popup!`);let l=new r;l.add(c),l.add({dispose:()=>{t==null||t()}}),this._lastPopup=l}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(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))}};W=z([R(0,ge),R(1,s(O))],W);let G=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetsNotePopupService=e,this._sheetsNoteModel=t,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=i,this._hoverManagerService=a,U(this,`_isSwitchingSheet`,!1),this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_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(k).getSkeletonParam(n))==null?void 0:i.skeleton;if(!c||!o)return;let l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((a=o.rangeType)==null?p.NORMAL:a)!==p.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((l.isMerged||l.isMergedMainCell)&&m.equals(l.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}let u=l.actualRow,d=l.actualColumn,f=this._sheetsNoteModel.getNote(t,n,{row:u,col:d});f!=null&&f.show||(f?this._sheetsNotePopupService.showPopup({unitId:t,subUnitId:n,noteId:f.id,row:u,col:d}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)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._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(de(100)).subscribe(e=>{var t;if(!(e!=null&&e.location))return;let{unitId:n,subUnitId:r,row:i,col:a}=e.location,o=this._renderManagerService.getRenderById(n),s=o==null||(t=o.with(k).getSkeletonParam(r))==null?void 0:t.skeleton,c=i,l=a,u=this._sheetsNoteModel.getNote(n,r,{row:c,col:l});if(!u&&s){let{startRow:e,endRow:t,startColumn:o,endColumn:d}=s.getCellWithCoordByIndex(i,a).mergeInfo;if(e!==t||o!==d){let i=this._sheetsNoteModel.getSheetNotes(n,r);if(i){for(let[n,r]of i)if(r.row>=e&&r.row<=t&&r.col>=o&&r.col<=d){u=r,c=r.row,l=r.col;break}}}}u!=null&&u.show||(u?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:u.id,row:c,col:l,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;let{unitId:t,subUnitId:n,noteId:r,row:i,col:a}=this._sheetsNotePopupService.activePopup,{oldNote:o,newNote:s}=e;s===null&&e.unitId===t&&e.subUnitId===n&&(o!=null&&o.id&&o.id===r||(o==null?void 0:o.row)===i&&o.col===a)&&this._sheetsNotePopupService.hidePopup(!0)}))}};G=z([R(0,s(W)),R(1,s(T)),R(2,s(b)),R(3,ue),R(4,v),R(5,s(le))],G);var De=`@univerjs/sheets-note-ui`,Oe=`0.18.0`;const K=`sheets-note-ui.config`;Symbol(K);const q={};let J=class extends n{constructor(e,t,n,r){super(),this._sheetsNoteModel=e,this._univerInstanceService=t,this._cellPopupManagerService=n,this._sheetsNotePopupService=r,U(this,`_noteMatrix`,new d),this._initNoteChangeListener()}_showPopup(e,t,n,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:n,col:r},{componentKey:V,direction:`horizontal`,extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((e,t,n)=>{n.dispose()})}_initSheet(e,t){var n;this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new d;let r=(e,t,n,r,i)=>{let a=this._noteMatrix,o=a.getValue(n,r);if(i!=null&&i.show){if(!o){let i=this._showPopup(e,t,n,r);i&&a.setValue(n,r,i)}}else o&&(o.dispose(),a.realDeleteValue(n,r))};return(n=this._sheetsNoteModel.getSheetNotes(e,t))==null||n.forEach(n=>{r(e,t,n.row,n.col,n)}),this._sheetsNoteModel.change$.subscribe(n=>{if(!(n.unitId!==e||n.subUnitId!==t))switch(n.type){case`ref`:{let{unitId:e,subUnitId:t,oldNote:r,newNote:i}=n;if(!i.show)return;let a=this._noteMatrix,{row:o,col:s}=r,{row:c,col:l}=i,u=a.getValue(o,s);u&&(u.dispose(),a.realDeleteValue(o,s));let d=this._showPopup(e,t,c,l);d&&a.setValue(c,l,d);break}case`update`:{let{unitId:e,subUnitId:t,oldNote:i,newNote:a}=n;r(e,t,a?a.row:i.row,a?a.col:i.col,a);break}default:break}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(h.UNIVER_SHEET).pipe(D(e=>{var t;return(t=e==null?void 0:e.activeSheet$)==null?ce(null):t})).subscribe(e=>{if(e){let t=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{t.unsubscribe()}}else this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new d}))}};J=z([R(0,s(T)),R(1,s(o)),R(2,s(O)),R(3,s(W))],J);const Y={id:`sheet.operation.add-note-popup`,type:e.OPERATION,handler:async(e,t)=>{var n;let r=e.get(b),i=e.get(W),a=e.get(o).getCurrentUnitForType(h.UNIVER_SHEET);if(!a)return!1;let s=a.getActiveSheet(),c=r.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;let{primary:l}=c;return i.showPopup({unitId:a.getUnitId(),subUnitId:s.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:(n=t==null?void 0:t.trigger)==null?`add-note`:n}),!0}};function X(e){let t=e.get(b),n=e.get(o);return t.selectionMoveEnd$.pipe(E(()=>{let r=t.getCurrentLastSelection();if(!(r!=null&&r.primary))return!1;let i=ne(n);if(!i)return!1;let{actualColumn:a,actualRow:o}=r.primary;return!!e.get(T).getNote(i.unitId,i.subUnitId,{row:o,col:a})}))}function ke(e){return{id:Y.id,type:j.BUTTON,title:`rightClick.addNote`,icon:`AddNoteIcon`,hidden$:oe([_e(e,h.UNIVER_SHEET),X(e)]).pipe(E(([e,t])=>e||t)),disabled$:A(e,{workbookTypes:[x],worksheetTypes:[S]}),commandId:Y.id}}function Ae(e){return{id:C.id,type:j.BUTTON,title:`rightClick.deleteNote`,icon:`DeleteNoteIcon`,hidden$:X(e).pipe(E(e=>!e)),disabled$:A(e,{workbookTypes:[x],worksheetTypes:[S]})}}function je(e){return{id:w.id,type:j.BUTTON,title:`rightClick.toggleNote`,icon:`HideNoteIcon`,hidden$:X(e).pipe(E(e=>!e))}}const Me={[me.MAIN_AREA]:{[pe.OTHERS]:{order:0,[Y.id]:{order:0,menuItemFactory:ke},[C.id]:{order:0,menuItemFactory:Ae},[w.id]:{order:0,menuItemFactory:je}}}},Z=e=>{var t;let{popup:n}=e,r=M(T),a=M(u),o=M(v),s=M(W),c=ve(K),l=(t=n.extraProps)==null?void 0:t.location;if(!l)return console.error(`Popup extraProps or location is undefined.`),null;let d=Se(null),f=o.getRenderById(l.unitId),[p,m]=Ce(null);L(()=>{var e,t,n,i,a,o;let{unitId:s,subUnitId:u,row:f,col:p}=l,h=r.getNote(s,u,{row:f,col:p}),_=(e=(t=h==null?void 0:h.width)==null?c==null||(n=c.defaultNoteSize)==null?void 0:n.width:t)==null?160:e,v=(i=(a=h==null?void 0:h.height)==null?c==null||(o=c.defaultNoteSize)==null?void 0:o.height:a)==null?72:i;if(h)m(h);else{let e={id:ee(6),width:_,height:v,note:``};m(e),g(e)}d.current&&(d.current.style.width=`${_}px`,d.current.style.height=`${v}px`)},[l,d]),L(()=>{if(!l||l.temp||!l.trigger||!d.current)return;let e=requestAnimationFrame(()=>{var e;(e=d.current)==null||e.focus()});return()=>cancelAnimationFrame(e)},[l]);let h=M(i),g=ye(e=>{if(!l)return;let{unitId:t,subUnitId:n,row:i,col:a}=l;if(!h.syncExecuteCommand(re.id,{unitId:t,sheetId:n,row:i,col:a,note:e})){let o=r.getNote(t,n,{noteId:e.id,row:i,col:a});o?m(o):s.hidePopup(!0)}}),_=I(e=>{if(!p||e===p.note)return;let t={...p,note:e};m(t),g(t)},[p]),y=I((e,t)=>{if(!p||e===p.width&&t===p.height)return;let n={...p,width:e,height:t};m(n),g(n)},[p]);return we(xe,{ref:d,"data-u-comp":`note-textarea`,className:F(`
2
+ univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow
3
+ dark:!univer-bg-gray-800
4
+ `),value:p==null?void 0:p.note,placeholder:a.t(`note.placeholder`),onResize:y,onValueChange:_,onWheel:e=>{document.activeElement!==d.current&&f.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type,e.nativeEvent))}})};let Q=class extends n{constructor(e,t,n){super(),this._componentManager=e,this._menuManagerService=t,this._commandService=n,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[V,Z],[`AddNoteIcon`,N],[`DeleteNoteIcon`,P],[`HideNoteIcon`,be]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initMenu(){this._menuManagerService.mergeMenu(Me)}_initCommands(){this._commandService.registerCommand(Y)}};Q=z([R(0,s(fe)),R(1,s(he)),R(2,i)],Q);let $=class extends f{constructor(e=q,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=g({},q,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(K,i)}onStarting(){[[W],[B],[G],[Q],[J]].forEach(e=>{this._injector.add(e)})}onReady(){_(this._injector,[[Q],[B]])}onRendered(){_(this._injector,[[G],[J]])}};U($,`pluginName`,`SHEET_NOTE_UI_PLUGIN`),U($,`packageName`,De),U($,`version`,Oe),U($,`type`,h.UNIVER_SHEET),$=z([t(ie),R(1,s(c)),R(2,a)],$);export{B as SheetsCellContentController,Z as SheetsNote,G as SheetsNotePopupController,W as SheetsNotePopupService,$ as UniverSheetsNoteUIPlugin};