@univerjs/sheets-note-ui 0.15.4 → 0.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,35 +1,35 @@
1
- var me = Object.defineProperty;
2
- var Se = (i, e, t) => e in i ? me(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var v = (i, e, t) => Se(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { Inject as h, IUniverInstanceService as D, Disposable as N, InterceptorEffectEnum as Pe, UniverInstanceType as I, DisposableCollection as Ne, RANGE_TYPE as J, Rectangle as Ie, ObjectMatrix as j, CommandType as Me, LocaleService as we, ICommandService as re, DependentOn as be, Injector as Ee, IConfigService as ye, Plugin as $e, merge as xe, touchDependencies as Q } from "@univerjs/core";
5
- import { IRenderManagerService as B } from "@univerjs/engine-render";
6
- import { SheetInterceptorService as He, INTERCEPTOR_POINT as Oe, SheetsSelectionsService as A, WorksheetEditPermission as oe, WorkbookEditablePermission as ne, getSheetCommandTarget as Te } from "@univerjs/sheets";
7
- import { SheetsNoteModel as M, SheetUpdateNoteCommand as Le, SheetDeleteNoteCommand as F, SheetToggleNotePopupCommand as se, UniverSheetsNotePlugin as De } from "@univerjs/sheets-note";
8
- import { debounceTime as Ue, BehaviorSubject as Ve, switchMap as Re, of as Ze, map as U, combineLatest as je } from "rxjs";
9
- import { CellPopupManagerService as ae, IEditorBridgeService as ke, HoverManagerService as Be, SheetSkeletonManagerService as Ae, getCurrentRangeDisable$ as ce } from "@univerjs/sheets-ui";
10
- import { debounceTime as Fe } from "rxjs/operators";
11
- import { IZenZoneService as We, useDependency as b, useConfigValue as ze, useDebounceFn as Ge, MenuItemType as W, getMenuHiddenObservable as Ke, ContextMenuPosition as Ye, ContextMenuGroup as qe, ComponentManager as Je, IMenuManagerService as Qe } from "@univerjs/ui";
12
- import { useRef as ue, createElement as V, forwardRef as z, useState as Xe, useEffect as et, useCallback as X } from "react";
13
- import { jsx as tt } from "react/jsx-runtime";
14
- import { Textarea as it, clsx as rt } from "@univerjs/design";
15
- var ot = Object.getOwnPropertyDescriptor, nt = (i, e, t, r) => {
16
- for (var o = r > 1 ? void 0 : r ? ot(e, t) : e, s = i.length - 1, n; s >= 0; s--)
17
- (n = i[s]) && (o = n(o) || o);
18
- return o;
19
- }, E = (i, e) => (t, r) => e(t, r, i);
20
- let $ = class extends N {
21
- constructor(i, e, t, r) {
22
- super(), this._sheetInterceptorService = i, this._sheetsNoteModel = e, this._renderManagerService = t, this._univerInstanceService = r, this._initViewModelIntercept(), this._initSkeletonChange();
1
+ var Ee = Object.defineProperty;
2
+ var ye = (i, e, t) => e in i ? Ee(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var P = (i, e, t) => ye(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Inject as g, IUniverInstanceService as Z, Disposable as E, InterceptorEffectEnum as $e, UniverInstanceType as y, DisposableCollection as xe, RANGE_TYPE as ne, Rectangle as He, ObjectMatrix as F, CommandType as Oe, LocaleService as Te, ICommandService as de, DependentOn as Le, Injector as Ue, IConfigService as Re, Plugin as De, merge as Ve, touchDependencies as se } from "@univerjs/core";
5
+ import { IRenderManagerService as z } from "@univerjs/engine-render";
6
+ import { SheetInterceptorService as Ze, INTERCEPTOR_POINT as ke, SheetsSelectionsService as G, WorksheetEditPermission as _e, WorkbookEditablePermission as fe, getSheetCommandTarget as je } from "@univerjs/sheets";
7
+ import { SheetsNoteModel as $, SheetUpdateNoteCommand as Be, SheetToggleNotePopupCommand as Ce, SheetDeleteNoteCommand as ge, UniverSheetsNotePlugin as Ae } from "@univerjs/sheets-note";
8
+ import { debounceTime as Fe, BehaviorSubject as We, switchMap as ze, of as Ge, map as k, combineLatest as Ke } from "rxjs";
9
+ import { CellPopupManagerService as ve, IEditorBridgeService as qe, HoverManagerService as Ye, SheetSkeletonManagerService as ce, getCurrentRangeDisable$ as me } from "@univerjs/sheets-ui";
10
+ import { debounceTime as Je } from "rxjs/operators";
11
+ import { IZenZoneService as Qe, useDependency as b, useConfigValue as Xe, useDebounceFn as et, MenuItemType as K, getMenuHiddenObservable as tt, ContextMenuPosition as it, ContextMenuGroup as ot, ComponentManager as rt, IMenuManagerService as nt } from "@univerjs/ui";
12
+ import { useRef as Se, createElement as j, forwardRef as q, useState as st, useEffect as ae, useCallback as ue } from "react";
13
+ import { jsx as ct } from "react/jsx-runtime";
14
+ import { Textarea as at, clsx as ut } from "@univerjs/design";
15
+ var lt = Object.getOwnPropertyDescriptor, pt = (i, e, t, o) => {
16
+ for (var r = o > 1 ? void 0 : o ? lt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
17
+ (n = i[s]) && (r = n(r) || r);
18
+ return r;
19
+ }, H = (i, e) => (t, o) => e(t, o, i);
20
+ let T = class extends E {
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
23
  }
24
24
  _initViewModelIntercept() {
25
25
  this.disposeWithMe(
26
26
  this._sheetInterceptorService.intercept(
27
- Oe.CELL_CONTENT,
27
+ ke.CELL_CONTENT,
28
28
  {
29
- effect: Pe.Style,
29
+ effect: $e.Style,
30
30
  handler: (i, e, t) => {
31
- const { row: r, col: o, unitId: s, subUnitId: n } = e;
32
- return this._sheetsNoteModel.getNote(s, n, r, o) && ((!i || i === e.rawData) && (i = { ...e.rawData }), i.markers = {
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
33
  ...i == null ? void 0 : i.markers,
34
34
  tr: {
35
35
  color: "#FFBD37",
@@ -44,36 +44,36 @@ let $ = class extends N {
44
44
  }
45
45
  _initSkeletonChange() {
46
46
  const i = () => {
47
- var o;
48
- const e = this._univerInstanceService.getCurrentUnitForType(I.UNIVER_SHEET);
47
+ var r;
48
+ const e = this._univerInstanceService.getCurrentUnitForType(y.UNIVER_SHEET);
49
49
  if (!e) return;
50
- const t = e.getUnitId(), r = this._renderManagerService.getRenderById(t);
51
- (o = r == null ? void 0 : r.mainComponent) == null || o.makeForceDirty();
50
+ const t = e.getUnitId(), o = this._renderManagerService.getRenderById(t);
51
+ (r = o == null ? void 0 : o.mainComponent) == null || r.makeForceDirty();
52
52
  };
53
- this.disposeWithMe(this._sheetsNoteModel.change$.pipe(Ue(16)).subscribe(() => {
53
+ this.disposeWithMe(this._sheetsNoteModel.change$.pipe(Fe(16)).subscribe(() => {
54
54
  i();
55
55
  }));
56
56
  }
57
57
  };
58
- $ = nt([
59
- E(0, h(He)),
60
- E(1, h(M)),
61
- E(2, B),
62
- E(3, D)
63
- ], $);
64
- const G = "SHEET_NOTE_COMPONENT";
65
- var st = Object.getOwnPropertyDescriptor, at = (i, e, t, r) => {
66
- for (var o = r > 1 ? void 0 : r ? st(e, t) : e, s = i.length - 1, n; s >= 0; s--)
67
- (n = i[s]) && (o = n(o) || o);
68
- return o;
69
- }, ee = (i, e) => (t, r) => e(t, r, i);
70
- let S = class extends N {
58
+ T = pt([
59
+ H(0, g(Ze)),
60
+ H(1, g($)),
61
+ H(2, z),
62
+ H(3, Z)
63
+ ], T);
64
+ const Y = "SHEET_NOTE_COMPONENT";
65
+ var ht = Object.getOwnPropertyDescriptor, dt = (i, e, t, o) => {
66
+ for (var r = o > 1 ? void 0 : o ? ht(e, t) : e, s = i.length - 1, n; s >= 0; s--)
67
+ (n = i[s]) && (r = n(r) || r);
68
+ return r;
69
+ }, le = (i, e) => (t, o) => e(t, o, i);
70
+ let I = class extends E {
71
71
  constructor(e, t) {
72
72
  super();
73
- v(this, "_lastPopup", null);
74
- v(this, "_activePopup");
75
- v(this, "_activePopup$", new Ve(null));
76
- v(this, "activePopup$", this._activePopup$.asObservable());
73
+ P(this, "_lastPopup", null);
74
+ P(this, "_activePopup");
75
+ P(this, "_activePopup$", new We(null));
76
+ P(this, "activePopup$", this._activePopup$.asObservable());
77
77
  this._zenZoneService = e, this._cellPopupManagerService = t, this._initZenVisible(), this.disposeWithMe(() => {
78
78
  this._activePopup$.complete();
79
79
  });
@@ -90,24 +90,24 @@ let S = class extends N {
90
90
  super.dispose(), this.hidePopup();
91
91
  }
92
92
  showPopup(e, t) {
93
- var c;
94
- const { row: r, col: o, unitId: s, subUnitId: n } = e;
95
- if (this._activePopup && r === this._activePopup.row && o === this._activePopup.col && s === this._activePopup.unitId && n === ((c = this.activePopup) == null ? void 0 : c.subUnitId)) {
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
96
  this._activePopup = e, this._activePopup$.next(e);
97
97
  return;
98
98
  }
99
99
  if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
100
100
  return;
101
101
  this._activePopup = e, this._activePopup$.next(e);
102
- const a = this._cellPopupManagerService.showPopup(
102
+ const c = this._cellPopupManagerService.showPopup(
103
103
  {
104
104
  unitId: s,
105
105
  subUnitId: n,
106
- row: r,
107
- col: o
106
+ row: o,
107
+ col: r
108
108
  },
109
109
  {
110
- componentKey: G,
110
+ componentKey: Y,
111
111
  onClickOutside: () => {
112
112
  this.hidePopup();
113
113
  },
@@ -118,10 +118,10 @@ let S = class extends N {
118
118
  priority: 3
119
119
  }
120
120
  );
121
- if (!a)
121
+ if (!c)
122
122
  throw new Error("[SheetsNotePopupService]: cannot show popup!");
123
- const u = new Ne();
124
- u.add(a), u.add({
123
+ const u = new xe();
124
+ u.add(c), u.add({
125
125
  dispose: () => {
126
126
  t == null || t();
127
127
  }
@@ -137,37 +137,38 @@ let S = class extends N {
137
137
  }, this._activePopup$.next(this._activePopup));
138
138
  }
139
139
  };
140
- S = at([
141
- ee(0, We),
142
- ee(1, h(ae))
143
- ], S);
144
- var ct = Object.getOwnPropertyDescriptor, ut = (i, e, t, r) => {
145
- for (var o = r > 1 ? void 0 : r ? ct(e, t) : e, s = i.length - 1, n; s >= 0; s--)
146
- (n = i[s]) && (o = n(o) || o);
147
- return o;
148
- }, m = (i, e) => (t, r) => e(t, r, i);
149
- let x = class extends N {
150
- constructor(e, t, r, o, s, n) {
140
+ I = dt([
141
+ le(0, Qe),
142
+ le(1, g(ve))
143
+ ], I);
144
+ var _t = Object.getOwnPropertyDescriptor, ft = (i, e, t, o) => {
145
+ for (var r = o > 1 ? void 0 : o ? _t(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 E {
150
+ constructor(e, t, o, r, s, n) {
151
151
  super();
152
- v(this, "_isSwitchingSheet", !1);
153
- this._sheetsNotePopupService = e, this._sheetsNoteModel = t, this._sheetSelectionService = r, this._editorBridgeService = o, this._renderManagerService = s, this._hoverManagerService = n, this._initSelectionUpdateListener(), this._initEditorBridge(), this._initHoverEvent();
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
154
  }
155
- _handleSelectionChange(e, t, r) {
156
- var d, _, f;
157
- const o = (d = e[0]) == null ? void 0 : d.range, s = this._renderManagerService.getRenderById(t), n = (_ = s == null ? void 0 : s.with(Ae).getSkeletonParam(r)) == null ? void 0 : _.skeleton;
158
- if (!n || !o)
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
159
  return;
160
- const a = n.getCellWithCoordByIndex(o.startRow, o.startColumn);
161
- if ((((f = o.rangeType) != null ? f : J.NORMAL) !== J.NORMAL || o.endColumn - o.startColumn > 0 || o.endRow - o.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && Ie.equals(a.mergeInfo, o))) {
160
+ const c = n.getCellWithCoordByIndex(r.startRow, r.startColumn);
161
+ if ((((m = r.rangeType) != null ? m : ne.NORMAL) !== ne.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((c.isMerged || c.isMergedMainCell) && He.equals(c.mergeInfo, r))) {
162
162
  this._sheetsNotePopupService.hidePopup();
163
163
  return;
164
164
  }
165
- const c = a.actualRow, l = a.actualColumn, p = this._sheetsNoteModel.getNote(t, r, c, l);
165
+ const l = c.actualRow, a = c.actualColumn, p = this._sheetsNoteModel.getNote(t, o, { row: l, col: a });
166
166
  p != null && p.show || (p ? this._sheetsNotePopupService.showPopup({
167
167
  unitId: t,
168
- subUnitId: r,
169
- row: c,
170
- col: l
168
+ subUnitId: o,
169
+ noteId: p.id,
170
+ row: l,
171
+ col: a
171
172
  }) : this._sheetsNotePopupService.hidePopup(!0));
172
173
  }
173
174
  _initSelectionUpdateListener() {
@@ -189,57 +190,82 @@ let x = class extends N {
189
190
  }
190
191
  _initHoverEvent() {
191
192
  this.disposeWithMe(
192
- this._hoverManagerService.currentCell$.pipe(Fe(100)).subscribe((e) => {
193
+ this._hoverManagerService.currentCell$.pipe(Je(100)).subscribe((e) => {
194
+ var p;
193
195
  if (!(e != null && e.location)) return;
194
- const { unitId: t, subUnitId: r, row: o, col: s } = e.location, n = this._sheetsNoteModel.getNote(t, r, o, s);
195
- n != null && n.show || (n ? this._sheetsNotePopupService.showPopup({
196
+ const { unitId: t, subUnitId: o, row: r, col: s } = e.location, n = this._renderManagerService.getRenderById(t), c = (p = n == null ? void 0 : n.with(ce).getSkeletonParam(o)) == null ? void 0 : p.skeleton;
197
+ let u = r, l = s, a = this._sheetsNoteModel.getNote(t, o, { row: u, col: l });
198
+ if (!a && c) {
199
+ const d = c.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
+ a = f, u = f.row, l = f.col;
206
+ break;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ a != null && a.show || (a ? this._sheetsNotePopupService.showPopup({
196
212
  unitId: t,
197
- subUnitId: r,
198
- row: o,
199
- col: s,
213
+ subUnitId: o,
214
+ noteId: a.id,
215
+ row: u,
216
+ col: l,
200
217
  temp: !0
201
218
  }) : this._sheetsNotePopupService.hidePopup());
202
219
  })
203
220
  );
204
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: c, newNote: u } = e;
227
+ u === null && e.unitId === t && e.subUnitId === o && (c != null && c.id && c.id === r || (c == null ? void 0 : c.row) === s && c.col === n) && this._sheetsNotePopupService.hidePopup(!0);
228
+ })
229
+ );
230
+ }
205
231
  };
206
- x = ut([
207
- m(0, h(S)),
208
- m(1, h(M)),
209
- m(2, h(A)),
210
- m(3, ke),
211
- m(4, B),
212
- m(5, h(Be))
213
- ], x);
214
- const pe = "sheets-note-ui.config", te = {};
215
- var pt = Object.getOwnPropertyDescriptor, lt = (i, e, t, r) => {
216
- for (var o = r > 1 ? void 0 : r ? pt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
217
- (n = i[s]) && (o = n(o) || o);
218
- return o;
219
- }, y = (i, e) => (t, r) => e(t, r, i);
220
- let H = class extends N {
221
- constructor(e, t, r, o) {
232
+ L = ft([
233
+ w(0, g(I)),
234
+ w(1, g($)),
235
+ w(2, g(G)),
236
+ w(3, qe),
237
+ w(4, z),
238
+ w(5, g(Ye))
239
+ ], L);
240
+ const Ne = "sheets-note-ui.config", pe = {};
241
+ var Ct = Object.getOwnPropertyDescriptor, gt = (i, e, t, o) => {
242
+ for (var r = o > 1 ? void 0 : o ? Ct(e, t) : e, s = i.length - 1, n; s >= 0; s--)
243
+ (n = i[s]) && (r = n(r) || r);
244
+ return r;
245
+ }, O = (i, e) => (t, o) => e(t, o, i);
246
+ let U = class extends E {
247
+ constructor(e, t, o, r) {
222
248
  super();
223
- v(this, "_noteMatrix", new j());
224
- this._sheetsNoteModel = e, this._univerInstanceService = t, this._cellPopupManagerService = r, this._sheetsNotePopupService = o, this._initNoteChangeListener();
249
+ P(this, "_noteMatrix", new F());
250
+ this._sheetsNoteModel = e, this._univerInstanceService = t, this._cellPopupManagerService = o, this._sheetsNotePopupService = r, this._initNoteChangeListener();
225
251
  }
226
- _showPopup(e, t, r, o) {
252
+ _showPopup(e, t, o, r) {
227
253
  return this._sheetsNotePopupService.hidePopup(!0), this._cellPopupManagerService.showPopup(
228
254
  {
229
255
  unitId: e,
230
256
  subUnitId: t,
231
- row: r,
232
- col: o
257
+ row: o,
258
+ col: r
233
259
  },
234
260
  {
235
- componentKey: G,
261
+ componentKey: Y,
236
262
  direction: "horizontal",
237
263
  extraProps: {
238
264
  location: {
239
265
  unitId: e,
240
266
  subUnitId: t,
241
- row: r,
242
- col: o
267
+ row: o,
268
+ col: r
243
269
  }
244
270
  },
245
271
  priority: 3
@@ -247,42 +273,42 @@ let H = class extends N {
247
273
  );
248
274
  }
249
275
  dispose() {
250
- super.dispose(), this._noteMatrix.forValue((e, t, r) => {
251
- r.dispose();
276
+ super.dispose(), this._noteMatrix.forValue((e, t, o) => {
277
+ o.dispose();
252
278
  });
253
279
  }
254
280
  _initSheet(e, t) {
255
281
  var s;
256
- this._noteMatrix.forValue((n, a, u) => {
282
+ this._noteMatrix.forValue((n, c, u) => {
257
283
  u.dispose();
258
- }), this._noteMatrix = new j();
259
- const o = (n, a, u, c, l) => {
260
- const p = this._noteMatrix, d = p.getValue(u, c);
261
- if (l != null && l.show) {
284
+ }), this._noteMatrix = new F();
285
+ const r = (n, c, u, l, a) => {
286
+ const p = this._noteMatrix, d = p.getValue(u, l);
287
+ if (a != null && a.show) {
262
288
  if (!d) {
263
- const _ = this._showPopup(n, a, u, c);
264
- _ && p.setValue(u, c, _);
289
+ const _ = this._showPopup(n, c, u, l);
290
+ _ && p.setValue(u, l, _);
265
291
  }
266
292
  } else
267
- d && (d.dispose(), p.realDeleteValue(u, c));
293
+ d && (d.dispose(), p.realDeleteValue(u, l));
268
294
  };
269
- return (s = this._sheetsNoteModel.getSheetNotes(e, t)) == null || s.forValue((n, a, u) => {
270
- o(e, t, n, a, u);
295
+ return (s = this._sheetsNoteModel.getSheetNotes(e, t)) == null || s.forEach((n) => {
296
+ r(e, t, n.row, n.col, n);
271
297
  }), this._sheetsNoteModel.change$.subscribe((n) => {
272
- if (!(n.unitId !== e || n.sheetId !== t))
298
+ if (!(n.unitId !== e || n.subUnitId !== t))
273
299
  switch (n.type) {
274
300
  case "ref": {
275
- const { unitId: a, sheetId: u, row: c, col: l, newPosition: p, note: d } = n, _ = this._noteMatrix;
276
- if (!d.show) return;
277
- const f = _.getValue(c, l);
278
- f && (f.dispose(), _.realDeleteValue(c, l));
279
- const P = this._showPopup(a, u, p.row, p.col);
280
- P && _.setValue(p.row, p.col, P);
301
+ const { unitId: c, subUnitId: u, oldNote: l, newNote: a } = n;
302
+ if (!a.show) return;
303
+ const p = this._noteMatrix, { row: d, col: _ } = l, { row: m, col: N } = a, S = p.getValue(d, _);
304
+ S && (S.dispose(), p.realDeleteValue(d, _));
305
+ const h = this._showPopup(c, u, m, N);
306
+ h && p.setValue(m, N, h);
281
307
  break;
282
308
  }
283
309
  case "update": {
284
- const { unitId: a, sheetId: u, row: c, col: l, note: p } = n;
285
- o(a, u, c, l, p);
310
+ const { unitId: c, subUnitId: u, oldNote: l, newNote: a } = n, p = a ? a.row : l.row, d = a ? a.col : l.col;
311
+ r(c, u, p, d, a);
286
312
  break;
287
313
  }
288
314
  }
@@ -290,10 +316,10 @@ let H = class extends N {
290
316
  }
291
317
  _initNoteChangeListener() {
292
318
  this.disposeWithMe(
293
- this._univerInstanceService.getCurrentTypeOfUnit$(I.UNIVER_SHEET).pipe(
294
- Re((e) => {
319
+ this._univerInstanceService.getCurrentTypeOfUnit$(y.UNIVER_SHEET).pipe(
320
+ ze((e) => {
295
321
  var t;
296
- return (t = e == null ? void 0 : e.activeSheet$) != null ? t : Ze(null);
322
+ return (t = e == null ? void 0 : e.activeSheet$) != null ? t : Ge(null);
297
323
  })
298
324
  ).subscribe((e) => {
299
325
  if (e) {
@@ -302,66 +328,66 @@ let H = class extends N {
302
328
  t.unsubscribe();
303
329
  };
304
330
  } else
305
- this._noteMatrix.forValue((t, r, o) => {
306
- o.dispose();
307
- }), this._noteMatrix = new j();
331
+ this._noteMatrix.forValue((t, o, r) => {
332
+ r.dispose();
333
+ }), this._noteMatrix = new F();
308
334
  })
309
335
  );
310
336
  }
311
337
  };
312
- H = lt([
313
- y(0, h(M)),
314
- y(1, h(D)),
315
- y(2, h(ae)),
316
- y(3, h(S))
317
- ], H);
318
- function R({ ref: i, ...e }) {
319
- const { icon: t, id: r, className: o, extend: s, ...n } = e, a = `univerjs-icon univerjs-icon-${r} ${o || ""}`.trim(), u = ue(`_${_t()}`);
320
- return le(t, `${r}`, {
338
+ U = gt([
339
+ O(0, g($)),
340
+ O(1, g(Z)),
341
+ O(2, g(ve)),
342
+ O(3, g(I))
343
+ ], U);
344
+ function B({ ref: i, ...e }) {
345
+ const { icon: t, id: o, className: r, extend: s, ...n } = e, c = `univerjs-icon univerjs-icon-${o} ${r || ""}`.trim(), u = Se(`_${St()}`);
346
+ return Pe(t, `${o}`, {
321
347
  defIds: t.defIds,
322
348
  idSuffix: u.current
323
349
  }, {
324
350
  ref: i,
325
- className: a,
351
+ className: c,
326
352
  ...n
327
353
  }, s);
328
354
  }
329
- function le(i, e, t, r, o) {
330
- return V(i.tag, {
355
+ function Pe(i, e, t, o, r) {
356
+ return j(i.tag, {
331
357
  key: e,
332
- ...ht(i, t, o),
333
- ...r
334
- }, (dt(i, t).children || []).map((s, n) => le(s, `${e}-${i.tag}-${n}`, t, void 0, o)));
358
+ ...vt(i, t, r),
359
+ ...o
360
+ }, (mt(i, t).children || []).map((s, n) => Pe(s, `${e}-${i.tag}-${n}`, t, void 0, r)));
335
361
  }
336
- function ht(i, e, t) {
337
- const r = { ...i.attrs };
338
- t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), i.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(([s, n]) => {
339
- s === "mask" && typeof n == "string" && (r[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
362
+ function vt(i, e, t) {
363
+ const o = { ...i.attrs };
364
+ 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]) => {
365
+ s === "mask" && typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
340
366
  });
341
- const { defIds: o } = e;
342
- return !o || o.length === 0 || (i.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(([s, n]) => {
343
- typeof n == "string" && (r[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
344
- })), r;
367
+ const { defIds: r } = e;
368
+ 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]) => {
369
+ typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
370
+ })), o;
345
371
  }
346
- function dt(i, e) {
347
- var r;
372
+ function mt(i, e) {
373
+ var o;
348
374
  const { defIds: t } = e;
349
- return !t || t.length === 0 ? i : i.tag === "defs" && ((r = i.children) != null && r.length) ? {
375
+ return !t || t.length === 0 ? i : i.tag === "defs" && ((o = i.children) != null && o.length) ? {
350
376
  ...i,
351
- children: i.children.map((o) => typeof o.attrs.id == "string" && t && t.includes(o.attrs.id) ? {
352
- ...o,
377
+ children: i.children.map((r) => typeof r.attrs.id == "string" && t && t.includes(r.attrs.id) ? {
378
+ ...r,
353
379
  attrs: {
354
- ...o.attrs,
355
- id: o.attrs.id + e.idSuffix
380
+ ...r.attrs,
381
+ id: r.attrs.id + e.idSuffix
356
382
  }
357
- } : o)
383
+ } : r)
358
384
  } : i;
359
385
  }
360
- function _t() {
386
+ function St() {
361
387
  return Math.random().toString(36).substring(2, 8);
362
388
  }
363
- R.displayName = "UniverIcon";
364
- const Ct = {
389
+ B.displayName = "UniverIcon";
390
+ const Nt = {
365
391
  tag: "svg",
366
392
  attrs: {
367
393
  xmlns: "http://www.w3.org/2000/svg",
@@ -414,15 +440,15 @@ const Ct = {
414
440
  }
415
441
  }
416
442
  ]
417
- }, he = z(function(e, t) {
418
- return V(R, Object.assign({}, e, {
443
+ }, Ie = q(function(e, t) {
444
+ return j(B, Object.assign({}, e, {
419
445
  id: "add-note-icon",
420
446
  ref: t,
421
- icon: Ct
447
+ icon: Nt
422
448
  }));
423
449
  });
424
- he.displayName = "AddNoteIcon";
425
- const ft = {
450
+ Ie.displayName = "AddNoteIcon";
451
+ const Pt = {
426
452
  tag: "svg",
427
453
  attrs: {
428
454
  xmlns: "http://www.w3.org/2000/svg",
@@ -468,15 +494,15 @@ const ft = {
468
494
  }
469
495
  }
470
496
  ]
471
- }, de = z(function(e, t) {
472
- return V(R, Object.assign({}, e, {
497
+ }, we = q(function(e, t) {
498
+ return j(B, Object.assign({}, e, {
473
499
  id: "delete-note-icon",
474
500
  ref: t,
475
- icon: ft
501
+ icon: Pt
476
502
  }));
477
503
  });
478
- de.displayName = "DeleteNoteIcon";
479
- const vt = {
504
+ we.displayName = "DeleteNoteIcon";
505
+ const It = {
480
506
  tag: "svg",
481
507
  attrs: {
482
508
  xmlns: "http://www.w3.org/2000/svg",
@@ -529,158 +555,176 @@ const vt = {
529
555
  }
530
556
  }
531
557
  ]
532
- }, _e = z(function(e, t) {
533
- return V(R, Object.assign({}, e, {
558
+ }, Me = q(function(e, t) {
559
+ return j(B, Object.assign({}, e, {
534
560
  id: "hide-note-icon",
535
561
  ref: t,
536
- icon: vt
562
+ icon: It
537
563
  }));
538
564
  });
539
- _e.displayName = "HideNoteIcon";
540
- const O = {
565
+ Me.displayName = "HideNoteIcon";
566
+ const R = {
541
567
  id: "sheet.operation.add-note-popup",
542
- type: Me.OPERATION,
568
+ type: Oe.OPERATION,
543
569
  handler: async (i, e) => {
544
- const t = i.get(A), r = i.get(S), s = i.get(D).getCurrentUnitForType(I.UNIVER_SHEET);
570
+ var l;
571
+ const t = i.get(G), o = i.get(I), s = i.get(Z).getCurrentUnitForType(y.UNIVER_SHEET);
545
572
  if (!s)
546
573
  return !1;
547
- const n = s.getActiveSheet(), a = t.getCurrentLastSelection();
548
- if (!(a != null && a.primary))
574
+ const n = s.getActiveSheet(), c = t.getCurrentLastSelection();
575
+ if (!(c != null && c.primary))
549
576
  return !1;
550
- const { primary: u } = a;
551
- return r.showPopup({
577
+ const { primary: u } = c;
578
+ return o.showPopup({
552
579
  unitId: s.getUnitId(),
553
580
  subUnitId: n.getSheetId(),
554
581
  row: u.actualRow,
555
582
  col: u.actualColumn,
556
583
  temp: !1,
557
- trigger: e == null ? void 0 : e.trigger
584
+ trigger: (l = e == null ? void 0 : e.trigger) != null ? l : "add-note"
558
585
  }), !0;
559
586
  }
560
- }, gt = (i) => {
561
- var P;
562
- const { popup: e } = i, t = b(M), r = b(we), o = b(B), s = ze(pe), n = (P = e.extraProps) == null ? void 0 : P.location;
563
- if (!n)
587
+ }, wt = (i) => {
588
+ var S;
589
+ const { popup: e } = i, t = b($), o = b(Te), r = b(z), s = b(I), n = Xe(Ne), c = (S = e.extraProps) == null ? void 0 : S.location;
590
+ if (!c)
564
591
  return console.error("Popup extraProps or location is undefined."), null;
565
- const a = ue(null), u = o.getRenderById(n.unitId), [c, l] = Xe(null);
566
- et(() => {
567
- var Y, q;
568
- const { unitId: C, subUnitId: g, row: w, col: fe } = n, { width: ve = 160, height: ge = 72 } = (Y = s == null ? void 0 : s.defaultNoteSize) != null ? Y : {}, Z = (q = t.getNote(C, g, w, fe)) != null ? q : { width: ve, height: ge, note: "" };
569
- a.current && (l(Z), a.current.style.width = `${Z.width}px`, a.current.style.height = `${Z.height}px`);
570
- }, [n, a]);
571
- const p = b(re), d = Ge((C) => {
572
- n && (C.note ? p.executeCommand(Le.id, {
573
- unitId: n.unitId,
574
- sheetId: n.subUnitId,
575
- row: n.row,
576
- col: n.col,
577
- note: C
578
- }) : p.executeCommand(F.id, {
579
- unitId: n.unitId,
580
- sheetId: n.subUnitId,
581
- row: n.row,
582
- col: n.col
583
- }));
584
- }), _ = X((C) => {
585
- if (!c) return;
586
- const g = { ...c, note: C };
587
- l(g), d(g);
588
- }, [c]), f = X((C, g) => {
589
- if (!c) return;
590
- const w = { ...c, width: C, height: g };
591
- l(w), d(w);
592
+ const u = Se(null), l = r.getRenderById(c.unitId), [a, p] = st(null);
593
+ ae(() => {
594
+ var Q, X, ee, te, ie, oe;
595
+ const { unitId: h, subUnitId: C, row: f, col: x } = c, v = t.getNote(h, C, { row: f, col: x }), A = (ee = (X = v == null ? void 0 : v.width) != null ? X : (Q = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : Q.width) != null ? ee : 160, M = (oe = (ie = v == null ? void 0 : v.height) != null ? ie : (te = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : te.height) != null ? oe : 72;
596
+ if (v)
597
+ p(v);
598
+ else {
599
+ const re = {
600
+ width: A,
601
+ height: M,
602
+ note: ""
603
+ };
604
+ p(re), _(re);
605
+ }
606
+ u.current && (u.current.style.width = `${A}px`, u.current.style.height = `${M}px`);
607
+ }, [c, u]), ae(() => {
608
+ if (!c || c.temp || !c.trigger || !u.current) return;
609
+ const h = requestAnimationFrame(() => {
610
+ var C;
611
+ (C = u.current) == null || C.focus();
612
+ });
613
+ return () => cancelAnimationFrame(h);
592
614
  }, [c]);
593
- return /* @__PURE__ */ tt(
594
- it,
615
+ const d = b(de), _ = et((h) => {
616
+ if (!c) return;
617
+ const { unitId: C, subUnitId: f, row: x, col: v } = c;
618
+ if (!d.syncExecuteCommand(Be.id, {
619
+ unitId: C,
620
+ sheetId: f,
621
+ row: x,
622
+ col: v,
623
+ note: h
624
+ })) {
625
+ const M = t.getNote(C, f, { noteId: h.id, row: x, col: v });
626
+ M ? p(M) : s.hidePopup(!0);
627
+ }
628
+ }), m = ue((h) => {
629
+ if (!a || h === a.note) return;
630
+ const C = { ...a, note: h };
631
+ p(C), _(C);
632
+ }, [a]), N = ue((h, C) => {
633
+ if (!a || h === a.width && C === a.height) return;
634
+ const f = { ...a, width: h, height: C };
635
+ p(f), _(f);
636
+ }, [a]);
637
+ return /* @__PURE__ */ ct(
638
+ at,
595
639
  {
596
- ref: a,
640
+ ref: u,
597
641
  "data-u-comp": "note-textarea",
598
- className: rt("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
599
- value: c == null ? void 0 : c.note,
600
- placeholder: r.t("note.placeholder"),
601
- onResize: f,
602
- onValueChange: _,
603
- onWheel: (C) => {
604
- document.activeElement !== a.current && u.engine.getCanvasElement().dispatchEvent(new WheelEvent(C.type, C.nativeEvent));
642
+ className: ut("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
643
+ value: a == null ? void 0 : a.note,
644
+ placeholder: o.t("note.placeholder"),
645
+ onResize: N,
646
+ onValueChange: m,
647
+ onWheel: (h) => {
648
+ document.activeElement !== u.current && l.engine.getCanvasElement().dispatchEvent(new WheelEvent(h.type, h.nativeEvent));
605
649
  }
606
650
  }
607
651
  );
608
652
  };
609
- function K(i) {
610
- const e = i.get(A), t = i.get(D);
611
- return e.selectionMoveEnd$.pipe(U(() => {
612
- const r = e.getCurrentLastSelection();
613
- if (!(r != null && r.primary)) return !1;
614
- const o = Te(t);
615
- if (!o) return !1;
616
- const { actualColumn: s, actualRow: n } = r.primary;
617
- return !!i.get(M).getNote(o.unitId, o.subUnitId, n, s);
653
+ function J(i) {
654
+ const e = i.get(G), t = i.get(Z);
655
+ return e.selectionMoveEnd$.pipe(k(() => {
656
+ const o = e.getCurrentLastSelection();
657
+ if (!(o != null && o.primary)) return !1;
658
+ const r = je(t);
659
+ if (!r) return !1;
660
+ const { actualColumn: s, actualRow: n } = o.primary;
661
+ return !!i.get($).getNote(r.unitId, r.subUnitId, { row: n, col: s });
618
662
  }));
619
663
  }
620
- function mt(i) {
664
+ function Mt(i) {
621
665
  return {
622
- id: O.id,
623
- type: W.BUTTON,
666
+ id: R.id,
667
+ type: K.BUTTON,
624
668
  title: "rightClick.addNote",
625
669
  icon: "AddNoteIcon",
626
- hidden$: je([Ke(i, I.UNIVER_SHEET), K(i)]).pipe(U(([e, t]) => e || t)),
627
- disabled$: ce(i, { workbookTypes: [ne], worksheetTypes: [oe] }),
628
- commandId: O.id
670
+ hidden$: Ke([tt(i, y.UNIVER_SHEET), J(i)]).pipe(k(([e, t]) => e || t)),
671
+ disabled$: me(i, { workbookTypes: [fe], worksheetTypes: [_e] }),
672
+ commandId: R.id
629
673
  };
630
674
  }
631
- function St(i) {
675
+ function bt(i) {
632
676
  return {
633
- id: F.id,
634
- type: W.BUTTON,
677
+ id: ge.id,
678
+ type: K.BUTTON,
635
679
  title: "rightClick.deleteNote",
636
680
  icon: "DeleteNoteIcon",
637
- hidden$: K(i).pipe(U((e) => !e)),
638
- disabled$: ce(i, { workbookTypes: [ne], worksheetTypes: [oe] })
681
+ hidden$: J(i).pipe(k((e) => !e)),
682
+ disabled$: me(i, { workbookTypes: [fe], worksheetTypes: [_e] })
639
683
  };
640
684
  }
641
- function Pt(i) {
685
+ function Et(i) {
642
686
  return {
643
- id: se.id,
644
- type: W.BUTTON,
687
+ id: Ce.id,
688
+ type: K.BUTTON,
645
689
  title: "rightClick.toggleNote",
646
690
  icon: "HideNoteIcon",
647
- hidden$: K(i).pipe(U((e) => !e))
691
+ hidden$: J(i).pipe(k((e) => !e))
648
692
  };
649
693
  }
650
- const Nt = {
651
- [Ye.MAIN_AREA]: {
652
- [qe.OTHERS]: {
694
+ const yt = {
695
+ [it.MAIN_AREA]: {
696
+ [ot.OTHERS]: {
653
697
  order: 0,
654
- [O.id]: {
698
+ [R.id]: {
655
699
  order: 0,
656
- menuItemFactory: mt
700
+ menuItemFactory: Mt
657
701
  },
658
- [F.id]: {
702
+ [ge.id]: {
659
703
  order: 0,
660
- menuItemFactory: St
704
+ menuItemFactory: bt
661
705
  },
662
- [se.id]: {
706
+ [Ce.id]: {
663
707
  order: 0,
664
- menuItemFactory: Pt
708
+ menuItemFactory: Et
665
709
  }
666
710
  }
667
711
  }
668
712
  };
669
- var It = Object.getOwnPropertyDescriptor, Mt = (i, e, t, r) => {
670
- for (var o = r > 1 ? void 0 : r ? It(e, t) : e, s = i.length - 1, n; s >= 0; s--)
671
- (n = i[s]) && (o = n(o) || o);
672
- return o;
673
- }, k = (i, e) => (t, r) => e(t, r, i);
674
- let T = class extends N {
713
+ var $t = Object.getOwnPropertyDescriptor, xt = (i, e, t, o) => {
714
+ for (var r = o > 1 ? void 0 : o ? $t(e, t) : e, s = i.length - 1, n; s >= 0; s--)
715
+ (n = i[s]) && (r = n(r) || r);
716
+ return r;
717
+ }, W = (i, e) => (t, o) => e(t, o, i);
718
+ let D = class extends E {
675
719
  constructor(i, e, t) {
676
720
  super(), this._componentManager = i, this._menuManagerService = e, this._commandService = t, this._initComponents(), this._initMenu(), this._initCommands();
677
721
  }
678
722
  _initComponents() {
679
723
  [
680
- [G, gt],
681
- ["AddNoteIcon", he],
682
- ["DeleteNoteIcon", de],
683
- ["HideNoteIcon", _e]
724
+ [Y, wt],
725
+ ["AddNoteIcon", Ie],
726
+ ["DeleteNoteIcon", we],
727
+ ["HideNoteIcon", Me]
684
728
  ].forEach(([i, e]) => {
685
729
  this.disposeWithMe(
686
730
  this._componentManager.register(i, e)
@@ -688,68 +732,68 @@ let T = class extends N {
688
732
  });
689
733
  }
690
734
  _initMenu() {
691
- this._menuManagerService.mergeMenu(Nt);
735
+ this._menuManagerService.mergeMenu(yt);
692
736
  }
693
737
  _initCommands() {
694
- this._commandService.registerCommand(O);
738
+ this._commandService.registerCommand(R);
695
739
  }
696
740
  };
697
- T = Mt([
698
- k(0, h(Je)),
699
- k(1, h(Qe)),
700
- k(2, re)
701
- ], T);
702
- var wt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, Et = (i, e, t) => e in i ? wt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, yt = (i, e, t, r) => {
703
- for (var o = r > 1 ? void 0 : r ? bt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
704
- (n = i[s]) && (o = n(o) || o);
705
- return o;
706
- }, ie = (i, e) => (t, r) => e(t, r, i), Ce = (i, e, t) => Et(i, typeof e != "symbol" ? e + "" : e, t);
707
- const $t = "SHEET_NOTE_UI_PLUGIN";
708
- let L = class extends $e {
709
- constructor(i = te, e, t) {
741
+ D = xt([
742
+ W(0, g(rt)),
743
+ W(1, g(nt)),
744
+ W(2, de)
745
+ ], D);
746
+ var Ht = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Tt = (i, e, t) => e in i ? Ht(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Lt = (i, e, t, o) => {
747
+ for (var r = o > 1 ? void 0 : o ? Ot(e, t) : e, s = i.length - 1, n; s >= 0; s--)
748
+ (n = i[s]) && (r = n(r) || r);
749
+ return r;
750
+ }, he = (i, e) => (t, o) => e(t, o, i), be = (i, e, t) => Tt(i, typeof e != "symbol" ? e + "" : e, t);
751
+ const Ut = "SHEET_NOTE_UI_PLUGIN";
752
+ let V = class extends De {
753
+ constructor(i = pe, e, t) {
710
754
  super(), this._config = i, this._injector = e, this._configService = t;
711
- const { menu: r, ...o } = xe(
755
+ const { menu: o, ...r } = Ve(
712
756
  {},
713
- te,
757
+ pe,
714
758
  this._config
715
759
  );
716
- r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(pe, o);
760
+ o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(Ne, r);
717
761
  }
718
762
  onStarting() {
719
763
  [
720
- [S],
721
- [$],
722
- [x],
764
+ [I],
723
765
  [T],
724
- [H]
766
+ [L],
767
+ [D],
768
+ [U]
725
769
  ].forEach((i) => {
726
770
  this._injector.add(i);
727
771
  });
728
772
  }
729
773
  onReady() {
730
- Q(this._injector, [
731
- [T],
732
- [$]
774
+ se(this._injector, [
775
+ [D],
776
+ [T]
733
777
  ]);
734
778
  }
735
779
  onRendered() {
736
- Q(this._injector, [
737
- [x],
738
- [H]
780
+ se(this._injector, [
781
+ [L],
782
+ [U]
739
783
  ]);
740
784
  }
741
785
  };
742
- Ce(L, "pluginName", $t);
743
- Ce(L, "type", I.UNIVER_SHEET);
744
- L = yt([
745
- be(De),
746
- ie(1, h(Ee)),
747
- ie(2, ye)
748
- ], L);
786
+ be(V, "pluginName", Ut);
787
+ be(V, "type", y.UNIVER_SHEET);
788
+ V = Lt([
789
+ Le(Ae),
790
+ he(1, g(Ue)),
791
+ he(2, Re)
792
+ ], V);
749
793
  export {
750
- $ as SheetsCellContentController,
751
- gt as SheetsNote,
752
- x as SheetsNotePopupController,
753
- S as SheetsNotePopupService,
754
- L as UniverSheetsNoteUIPlugin
794
+ T as SheetsCellContentController,
795
+ wt as SheetsNote,
796
+ L as SheetsNotePopupController,
797
+ I as SheetsNotePopupService,
798
+ V as UniverSheetsNoteUIPlugin
755
799
  };