@univerjs/sheets-note 0.25.0-insiders.20260623-012b5a8 → 0.25.1

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/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/facade.js CHANGED
@@ -83,10 +83,7 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
83
83
  return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
84
84
  if (change.type === "update" && !change.oldNote && change.newNote) {
85
85
  const { unitId, subUnitId, newNote } = change;
86
- const target = this.getSheetCommandTarget({
87
- unitId,
88
- subUnitId
89
- });
86
+ const target = this.getSheetTarget(unitId, subUnitId);
90
87
  if (!target) return;
91
88
  const { workbook, worksheet } = target;
92
89
  const eventParams = {
@@ -104,10 +101,7 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
104
101
  return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
105
102
  if (change.type === "update" && change.oldNote && !change.newNote) {
106
103
  const { unitId, subUnitId, oldNote } = change;
107
- const target = this.getSheetCommandTarget({
108
- unitId,
109
- subUnitId
110
- });
104
+ const target = this.getSheetTarget(unitId, subUnitId);
111
105
  if (!target) return;
112
106
  const { workbook, worksheet } = target;
113
107
  const eventParams = {
@@ -125,10 +119,7 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
125
119
  return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
126
120
  if (change.type === "update" && change.oldNote && change.newNote) {
127
121
  const { unitId, subUnitId, oldNote, newNote } = change;
128
- const target = this.getSheetCommandTarget({
129
- unitId,
130
- subUnitId
131
- });
122
+ const target = this.getSheetTarget(unitId, subUnitId);
132
123
  if (!target) return;
133
124
  const { workbook, worksheet } = target;
134
125
  const eventParams = {
@@ -147,10 +138,7 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
147
138
  return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
148
139
  if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
149
140
  const { unitId, subUnitId, newNote } = change;
150
- const target = this.getSheetCommandTarget({
151
- unitId,
152
- subUnitId
153
- });
141
+ const target = this.getSheetTarget(unitId, subUnitId);
154
142
  if (!target) return;
155
143
  const { workbook, worksheet } = target;
156
144
  const eventParams = {
@@ -167,10 +155,7 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
167
155
  return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
168
156
  if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
169
157
  const { unitId, subUnitId, newNote } = change;
170
- const target = this.getSheetCommandTarget({
171
- unitId,
172
- subUnitId
173
- });
158
+ const target = this.getSheetTarget(unitId, subUnitId);
174
159
  if (!target) return;
175
160
  const { workbook, worksheet } = target;
176
161
  const eventParams = {
@@ -185,16 +170,15 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
185
170
  }));
186
171
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
187
172
  if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
188
- const params = command.params;
189
- const target = this.getSheetCommandTarget(params);
173
+ const { unitId, sheetId, row, col, note } = command.params;
174
+ const target = this.getSheetTarget(unitId, sheetId);
190
175
  if (!target) return;
191
- const { workbook, worksheet, unitId, subUnitId } = target;
192
- const { row, col, note } = params;
193
- if (injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
176
+ if (injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
194
177
  noteId: note.id,
195
178
  row,
196
179
  col
197
180
  })) return;
181
+ const { workbook, worksheet } = target;
198
182
  const eventParams = {
199
183
  workbook,
200
184
  worksheet,
@@ -207,17 +191,16 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
207
191
  })));
208
192
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
209
193
  if (command.id === _univerjs_sheets_note.SheetDeleteNoteCommand.id) {
210
- const target = this.getSheetCommandTarget();
194
+ const { unitId, sheetId, row, col } = command.params;
195
+ const target = this.getSheetTarget(unitId, sheetId);
211
196
  if (!target) return;
212
- const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
213
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
214
- const { workbook, worksheet, unitId, subUnitId } = target;
215
- const { actualRow: row, actualColumn: col } = selection.primary;
216
- const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
197
+ if (row === void 0 || col === void 0) return;
198
+ const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
217
199
  row,
218
200
  col
219
201
  });
220
202
  if (!oldNote) return;
203
+ const { workbook, worksheet } = target;
221
204
  const eventParams = {
222
205
  workbook,
223
206
  worksheet,
@@ -230,16 +213,15 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
230
213
  })));
231
214
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
232
215
  if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
233
- const params = command.params;
234
- const target = this.getSheetCommandTarget(params);
216
+ const { unitId, sheetId, row, col, note } = command.params;
217
+ const target = this.getSheetTarget(unitId, sheetId);
235
218
  if (!target) return;
236
- const { workbook, worksheet, unitId, subUnitId } = target;
237
- const { row, col, note } = params;
238
- const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
219
+ const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
239
220
  row,
240
221
  col
241
222
  });
242
223
  if (!oldNote) return;
224
+ const { workbook, worksheet } = target;
243
225
  const eventParams = {
244
226
  workbook,
245
227
  worksheet,
@@ -253,44 +235,54 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
253
235
  })));
254
236
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
255
237
  if (command.id === _univerjs_sheets_note.SheetToggleNotePopupCommand.id) {
256
- const target = this.getSheetCommandTarget();
238
+ const target = (0, _univerjs_sheets.getSheetCommandTarget)(injector.get(_univerjs_core.IUniverInstanceService));
257
239
  if (!target) return;
240
+ const { unitId, subUnitId } = target;
241
+ const workbook = this.getUniverSheet(unitId);
242
+ if (!workbook) return;
243
+ const worksheet = workbook.getSheetBySheetId(subUnitId);
244
+ if (!worksheet) return;
258
245
  const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
259
246
  if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
260
- const { workbook, worksheet, unitId, subUnitId } = target;
261
- const { actualRow: row, actualColumn: col } = selection.primary;
262
- const note = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
263
- row,
264
- col
247
+ const sheetsNoteModel = injector.get(_univerjs_sheets_note.SheetsNoteModel);
248
+ const { actualColumn, actualRow } = selection.primary;
249
+ const note = sheetsNoteModel.getNote(unitId, subUnitId, {
250
+ row: actualRow,
251
+ col: actualColumn
265
252
  });
266
253
  if (!note || note.show) return;
267
254
  const eventParams = {
268
255
  workbook,
269
256
  worksheet,
270
- row,
271
- col
257
+ row: actualRow,
258
+ col: actualColumn
272
259
  };
273
260
  if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new _univerjs_core.CanceledError();
274
261
  }
275
262
  })));
276
263
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
277
264
  if (command.id === _univerjs_sheets_note.SheetToggleNotePopupCommand.id) {
278
- const target = this.getSheetCommandTarget();
265
+ const target = (0, _univerjs_sheets.getSheetCommandTarget)(injector.get(_univerjs_core.IUniverInstanceService));
279
266
  if (!target) return;
267
+ const { unitId, subUnitId } = target;
268
+ const workbook = this.getUniverSheet(unitId);
269
+ if (!workbook) return;
270
+ const worksheet = workbook.getSheetBySheetId(subUnitId);
271
+ if (!worksheet) return;
280
272
  const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
281
273
  if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
282
- const { workbook, worksheet, unitId, subUnitId } = target;
283
- const { actualRow: row, actualColumn: col } = selection.primary;
284
- const note = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
285
- row,
286
- col
274
+ const sheetsNoteModel = injector.get(_univerjs_sheets_note.SheetsNoteModel);
275
+ const { actualColumn, actualRow } = selection.primary;
276
+ const note = sheetsNoteModel.getNote(unitId, subUnitId, {
277
+ row: actualRow,
278
+ col: actualColumn
287
279
  });
288
280
  if (!note || !note.show) return;
289
281
  const eventParams = {
290
282
  workbook,
291
283
  worksheet,
292
- row,
293
- col
284
+ row: actualRow,
285
+ col: actualColumn
294
286
  };
295
287
  if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new _univerjs_core.CanceledError();
296
288
  }
package/lib/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ let _univerjs_core = require("@univerjs/core");
3
3
  let _univerjs_sheets = require("@univerjs/sheets");
4
4
  let rxjs = require("rxjs");
5
5
 
6
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
6
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -14,7 +14,7 @@ function _typeof(o) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
18
18
  function toPrimitive(t, r) {
19
19
  if ("object" != _typeof(t) || !t) return t;
20
20
  var e = t[Symbol.toPrimitive];
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
27
27
  }
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
30
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
31
31
  function toPropertyKey(t) {
32
32
  var i = toPrimitive(t, "string");
33
33
  return "symbol" == _typeof(i) ? i : i + "";
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
37
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
38
38
  function _defineProperty(e, r, t) {
39
39
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
40
40
  value: t,
@@ -441,7 +441,7 @@ const SheetUpdateNoteCommand = {
441
441
  const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
442
442
 
443
443
  //#endregion
444
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
444
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
445
445
  function __decorateParam(paramIndex, decorator) {
446
446
  return function(target, key) {
447
447
  decorator(target, key, paramIndex);
@@ -449,7 +449,7 @@ function __decorateParam(paramIndex, decorator) {
449
449
  }
450
450
 
451
451
  //#endregion
452
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
452
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
453
453
  function __decorate(decorators, target, key, desc) {
454
454
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
455
455
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -617,7 +617,7 @@ SheetsNoteResourceController = __decorate([
617
617
  //#endregion
618
618
  //#region package.json
619
619
  var name = "@univerjs/sheets-note";
620
- var version = "0.25.0-insiders.20260623-012b5a8";
620
+ var version = "0.25.1";
621
621
 
622
622
  //#endregion
623
623
  //#region src/config/config.ts
package/lib/es/facade.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FEventName, FUniver } from "@univerjs/core/facade";
2
2
  import { RemoveNoteMutation, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UpdateNoteMutation } from "@univerjs/sheets-note";
3
3
  import { FRange, FWorksheet } from "@univerjs/sheets/facade";
4
- import { CanceledError, ICommandService } from "@univerjs/core";
5
- import { SheetsSelectionsService } from "@univerjs/sheets";
4
+ import { CanceledError, ICommandService, IUniverInstanceService } from "@univerjs/core";
5
+ import { SheetsSelectionsService, getSheetCommandTarget } from "@univerjs/sheets";
6
6
 
7
7
  //#region src/facade/f-event.ts
8
8
  /**
@@ -82,10 +82,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
82
82
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
83
83
  if (change.type === "update" && !change.oldNote && change.newNote) {
84
84
  const { unitId, subUnitId, newNote } = change;
85
- const target = this.getSheetCommandTarget({
86
- unitId,
87
- subUnitId
88
- });
85
+ const target = this.getSheetTarget(unitId, subUnitId);
89
86
  if (!target) return;
90
87
  const { workbook, worksheet } = target;
91
88
  const eventParams = {
@@ -103,10 +100,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
103
100
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
104
101
  if (change.type === "update" && change.oldNote && !change.newNote) {
105
102
  const { unitId, subUnitId, oldNote } = change;
106
- const target = this.getSheetCommandTarget({
107
- unitId,
108
- subUnitId
109
- });
103
+ const target = this.getSheetTarget(unitId, subUnitId);
110
104
  if (!target) return;
111
105
  const { workbook, worksheet } = target;
112
106
  const eventParams = {
@@ -124,10 +118,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
124
118
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
125
119
  if (change.type === "update" && change.oldNote && change.newNote) {
126
120
  const { unitId, subUnitId, oldNote, newNote } = change;
127
- const target = this.getSheetCommandTarget({
128
- unitId,
129
- subUnitId
130
- });
121
+ const target = this.getSheetTarget(unitId, subUnitId);
131
122
  if (!target) return;
132
123
  const { workbook, worksheet } = target;
133
124
  const eventParams = {
@@ -146,10 +137,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
146
137
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
147
138
  if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
148
139
  const { unitId, subUnitId, newNote } = change;
149
- const target = this.getSheetCommandTarget({
150
- unitId,
151
- subUnitId
152
- });
140
+ const target = this.getSheetTarget(unitId, subUnitId);
153
141
  if (!target) return;
154
142
  const { workbook, worksheet } = target;
155
143
  const eventParams = {
@@ -166,10 +154,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
166
154
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
167
155
  if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
168
156
  const { unitId, subUnitId, newNote } = change;
169
- const target = this.getSheetCommandTarget({
170
- unitId,
171
- subUnitId
172
- });
157
+ const target = this.getSheetTarget(unitId, subUnitId);
173
158
  if (!target) return;
174
159
  const { workbook, worksheet } = target;
175
160
  const eventParams = {
@@ -184,16 +169,15 @@ var FUniverSheetsNoteMixin = class extends FUniver {
184
169
  }));
185
170
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
186
171
  if (command.id === SheetUpdateNoteCommand.id) {
187
- const params = command.params;
188
- const target = this.getSheetCommandTarget(params);
172
+ const { unitId, sheetId, row, col, note } = command.params;
173
+ const target = this.getSheetTarget(unitId, sheetId);
189
174
  if (!target) return;
190
- const { workbook, worksheet, unitId, subUnitId } = target;
191
- const { row, col, note } = params;
192
- if (injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
175
+ if (injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
193
176
  noteId: note.id,
194
177
  row,
195
178
  col
196
179
  })) return;
180
+ const { workbook, worksheet } = target;
197
181
  const eventParams = {
198
182
  workbook,
199
183
  worksheet,
@@ -206,17 +190,16 @@ var FUniverSheetsNoteMixin = class extends FUniver {
206
190
  })));
207
191
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
208
192
  if (command.id === SheetDeleteNoteCommand.id) {
209
- const target = this.getSheetCommandTarget();
193
+ const { unitId, sheetId, row, col } = command.params;
194
+ const target = this.getSheetTarget(unitId, sheetId);
210
195
  if (!target) return;
211
- const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
212
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
213
- const { workbook, worksheet, unitId, subUnitId } = target;
214
- const { actualRow: row, actualColumn: col } = selection.primary;
215
- const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
196
+ if (row === void 0 || col === void 0) return;
197
+ const oldNote = injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
216
198
  row,
217
199
  col
218
200
  });
219
201
  if (!oldNote) return;
202
+ const { workbook, worksheet } = target;
220
203
  const eventParams = {
221
204
  workbook,
222
205
  worksheet,
@@ -229,16 +212,15 @@ var FUniverSheetsNoteMixin = class extends FUniver {
229
212
  })));
230
213
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
231
214
  if (command.id === SheetUpdateNoteCommand.id) {
232
- const params = command.params;
233
- const target = this.getSheetCommandTarget(params);
215
+ const { unitId, sheetId, row, col, note } = command.params;
216
+ const target = this.getSheetTarget(unitId, sheetId);
234
217
  if (!target) return;
235
- const { workbook, worksheet, unitId, subUnitId } = target;
236
- const { row, col, note } = params;
237
- const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
218
+ const oldNote = injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
238
219
  row,
239
220
  col
240
221
  });
241
222
  if (!oldNote) return;
223
+ const { workbook, worksheet } = target;
242
224
  const eventParams = {
243
225
  workbook,
244
226
  worksheet,
@@ -252,44 +234,54 @@ var FUniverSheetsNoteMixin = class extends FUniver {
252
234
  })));
253
235
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
254
236
  if (command.id === SheetToggleNotePopupCommand.id) {
255
- const target = this.getSheetCommandTarget();
237
+ const target = getSheetCommandTarget(injector.get(IUniverInstanceService));
256
238
  if (!target) return;
239
+ const { unitId, subUnitId } = target;
240
+ const workbook = this.getUniverSheet(unitId);
241
+ if (!workbook) return;
242
+ const worksheet = workbook.getSheetBySheetId(subUnitId);
243
+ if (!worksheet) return;
257
244
  const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
258
245
  if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
259
- const { workbook, worksheet, unitId, subUnitId } = target;
260
- const { actualRow: row, actualColumn: col } = selection.primary;
261
- const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
262
- row,
263
- col
246
+ const sheetsNoteModel = injector.get(SheetsNoteModel);
247
+ const { actualColumn, actualRow } = selection.primary;
248
+ const note = sheetsNoteModel.getNote(unitId, subUnitId, {
249
+ row: actualRow,
250
+ col: actualColumn
264
251
  });
265
252
  if (!note || note.show) return;
266
253
  const eventParams = {
267
254
  workbook,
268
255
  worksheet,
269
- row,
270
- col
256
+ row: actualRow,
257
+ col: actualColumn
271
258
  };
272
259
  if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new CanceledError();
273
260
  }
274
261
  })));
275
262
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
276
263
  if (command.id === SheetToggleNotePopupCommand.id) {
277
- const target = this.getSheetCommandTarget();
264
+ const target = getSheetCommandTarget(injector.get(IUniverInstanceService));
278
265
  if (!target) return;
266
+ const { unitId, subUnitId } = target;
267
+ const workbook = this.getUniverSheet(unitId);
268
+ if (!workbook) return;
269
+ const worksheet = workbook.getSheetBySheetId(subUnitId);
270
+ if (!worksheet) return;
279
271
  const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
280
272
  if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
281
- const { workbook, worksheet, unitId, subUnitId } = target;
282
- const { actualRow: row, actualColumn: col } = selection.primary;
283
- const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
284
- row,
285
- col
273
+ const sheetsNoteModel = injector.get(SheetsNoteModel);
274
+ const { actualColumn, actualRow } = selection.primary;
275
+ const note = sheetsNoteModel.getNote(unitId, subUnitId, {
276
+ row: actualRow,
277
+ col: actualColumn
286
278
  });
287
279
  if (!note || !note.show) return;
288
280
  const eventParams = {
289
281
  workbook,
290
282
  worksheet,
291
- row,
292
- col
283
+ row: actualRow,
284
+ col: actualColumn
293
285
  };
294
286
  if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new CanceledError();
295
287
  }
package/lib/es/index.js CHANGED
@@ -2,7 +2,7 @@ import { CommandType, DependentOn, Disposable, ICommandService, IConfigService,
2
2
  import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, getSheetCommandTarget, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
3
3
  import { Subject, filter, map } from "rxjs";
4
4
 
5
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
5
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
6
6
  function _typeof(o) {
7
7
  "@babel/helpers - typeof";
8
8
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -13,7 +13,7 @@ function _typeof(o) {
13
13
  }
14
14
 
15
15
  //#endregion
16
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
16
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
17
17
  function toPrimitive(t, r) {
18
18
  if ("object" != _typeof(t) || !t) return t;
19
19
  var e = t[Symbol.toPrimitive];
@@ -26,14 +26,14 @@ function toPrimitive(t, r) {
26
26
  }
27
27
 
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
29
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
30
30
  function toPropertyKey(t) {
31
31
  var i = toPrimitive(t, "string");
32
32
  return "symbol" == _typeof(i) ? i : i + "";
33
33
  }
34
34
 
35
35
  //#endregion
36
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
36
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
37
37
  function _defineProperty(e, r, t) {
38
38
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
39
39
  value: t,
@@ -440,7 +440,7 @@ const SheetUpdateNoteCommand = {
440
440
  const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
441
441
 
442
442
  //#endregion
443
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
443
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
444
444
  function __decorateParam(paramIndex, decorator) {
445
445
  return function(target, key) {
446
446
  decorator(target, key, paramIndex);
@@ -448,7 +448,7 @@ function __decorateParam(paramIndex, decorator) {
448
448
  }
449
449
 
450
450
  //#endregion
451
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
451
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
452
452
  function __decorate(decorators, target, key, desc) {
453
453
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
454
454
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -616,7 +616,7 @@ SheetsNoteResourceController = __decorate([
616
616
  //#endregion
617
617
  //#region package.json
618
618
  var name = "@univerjs/sheets-note";
619
- var version = "0.25.0-insiders.20260623-012b5a8";
619
+ var version = "0.25.1";
620
620
 
621
621
  //#endregion
622
622
  //#region src/config/config.ts
package/lib/facade.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FEventName, FUniver } from "@univerjs/core/facade";
2
2
  import { RemoveNoteMutation, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UpdateNoteMutation } from "@univerjs/sheets-note";
3
3
  import { FRange, FWorksheet } from "@univerjs/sheets/facade";
4
- import { CanceledError, ICommandService } from "@univerjs/core";
5
- import { SheetsSelectionsService } from "@univerjs/sheets";
4
+ import { CanceledError, ICommandService, IUniverInstanceService } from "@univerjs/core";
5
+ import { SheetsSelectionsService, getSheetCommandTarget } from "@univerjs/sheets";
6
6
 
7
7
  //#region src/facade/f-event.ts
8
8
  /**
@@ -82,10 +82,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
82
82
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
83
83
  if (change.type === "update" && !change.oldNote && change.newNote) {
84
84
  const { unitId, subUnitId, newNote } = change;
85
- const target = this.getSheetCommandTarget({
86
- unitId,
87
- subUnitId
88
- });
85
+ const target = this.getSheetTarget(unitId, subUnitId);
89
86
  if (!target) return;
90
87
  const { workbook, worksheet } = target;
91
88
  const eventParams = {
@@ -103,10 +100,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
103
100
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
104
101
  if (change.type === "update" && change.oldNote && !change.newNote) {
105
102
  const { unitId, subUnitId, oldNote } = change;
106
- const target = this.getSheetCommandTarget({
107
- unitId,
108
- subUnitId
109
- });
103
+ const target = this.getSheetTarget(unitId, subUnitId);
110
104
  if (!target) return;
111
105
  const { workbook, worksheet } = target;
112
106
  const eventParams = {
@@ -124,10 +118,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
124
118
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
125
119
  if (change.type === "update" && change.oldNote && change.newNote) {
126
120
  const { unitId, subUnitId, oldNote, newNote } = change;
127
- const target = this.getSheetCommandTarget({
128
- unitId,
129
- subUnitId
130
- });
121
+ const target = this.getSheetTarget(unitId, subUnitId);
131
122
  if (!target) return;
132
123
  const { workbook, worksheet } = target;
133
124
  const eventParams = {
@@ -146,10 +137,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
146
137
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
147
138
  if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
148
139
  const { unitId, subUnitId, newNote } = change;
149
- const target = this.getSheetCommandTarget({
150
- unitId,
151
- subUnitId
152
- });
140
+ const target = this.getSheetTarget(unitId, subUnitId);
153
141
  if (!target) return;
154
142
  const { workbook, worksheet } = target;
155
143
  const eventParams = {
@@ -166,10 +154,7 @@ var FUniverSheetsNoteMixin = class extends FUniver {
166
154
  return injector.get(SheetsNoteModel).change$.subscribe((change) => {
167
155
  if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
168
156
  const { unitId, subUnitId, newNote } = change;
169
- const target = this.getSheetCommandTarget({
170
- unitId,
171
- subUnitId
172
- });
157
+ const target = this.getSheetTarget(unitId, subUnitId);
173
158
  if (!target) return;
174
159
  const { workbook, worksheet } = target;
175
160
  const eventParams = {
@@ -184,16 +169,15 @@ var FUniverSheetsNoteMixin = class extends FUniver {
184
169
  }));
185
170
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
186
171
  if (command.id === SheetUpdateNoteCommand.id) {
187
- const params = command.params;
188
- const target = this.getSheetCommandTarget(params);
172
+ const { unitId, sheetId, row, col, note } = command.params;
173
+ const target = this.getSheetTarget(unitId, sheetId);
189
174
  if (!target) return;
190
- const { workbook, worksheet, unitId, subUnitId } = target;
191
- const { row, col, note } = params;
192
- if (injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
175
+ if (injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
193
176
  noteId: note.id,
194
177
  row,
195
178
  col
196
179
  })) return;
180
+ const { workbook, worksheet } = target;
197
181
  const eventParams = {
198
182
  workbook,
199
183
  worksheet,
@@ -206,17 +190,16 @@ var FUniverSheetsNoteMixin = class extends FUniver {
206
190
  })));
207
191
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
208
192
  if (command.id === SheetDeleteNoteCommand.id) {
209
- const target = this.getSheetCommandTarget();
193
+ const { unitId, sheetId, row, col } = command.params;
194
+ const target = this.getSheetTarget(unitId, sheetId);
210
195
  if (!target) return;
211
- const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
212
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
213
- const { workbook, worksheet, unitId, subUnitId } = target;
214
- const { actualRow: row, actualColumn: col } = selection.primary;
215
- const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
196
+ if (row === void 0 || col === void 0) return;
197
+ const oldNote = injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
216
198
  row,
217
199
  col
218
200
  });
219
201
  if (!oldNote) return;
202
+ const { workbook, worksheet } = target;
220
203
  const eventParams = {
221
204
  workbook,
222
205
  worksheet,
@@ -229,16 +212,15 @@ var FUniverSheetsNoteMixin = class extends FUniver {
229
212
  })));
230
213
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
231
214
  if (command.id === SheetUpdateNoteCommand.id) {
232
- const params = command.params;
233
- const target = this.getSheetCommandTarget(params);
215
+ const { unitId, sheetId, row, col, note } = command.params;
216
+ const target = this.getSheetTarget(unitId, sheetId);
234
217
  if (!target) return;
235
- const { workbook, worksheet, unitId, subUnitId } = target;
236
- const { row, col, note } = params;
237
- const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
218
+ const oldNote = injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
238
219
  row,
239
220
  col
240
221
  });
241
222
  if (!oldNote) return;
223
+ const { workbook, worksheet } = target;
242
224
  const eventParams = {
243
225
  workbook,
244
226
  worksheet,
@@ -252,44 +234,54 @@ var FUniverSheetsNoteMixin = class extends FUniver {
252
234
  })));
253
235
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
254
236
  if (command.id === SheetToggleNotePopupCommand.id) {
255
- const target = this.getSheetCommandTarget();
237
+ const target = getSheetCommandTarget(injector.get(IUniverInstanceService));
256
238
  if (!target) return;
239
+ const { unitId, subUnitId } = target;
240
+ const workbook = this.getUniverSheet(unitId);
241
+ if (!workbook) return;
242
+ const worksheet = workbook.getSheetBySheetId(subUnitId);
243
+ if (!worksheet) return;
257
244
  const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
258
245
  if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
259
- const { workbook, worksheet, unitId, subUnitId } = target;
260
- const { actualRow: row, actualColumn: col } = selection.primary;
261
- const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
262
- row,
263
- col
246
+ const sheetsNoteModel = injector.get(SheetsNoteModel);
247
+ const { actualColumn, actualRow } = selection.primary;
248
+ const note = sheetsNoteModel.getNote(unitId, subUnitId, {
249
+ row: actualRow,
250
+ col: actualColumn
264
251
  });
265
252
  if (!note || note.show) return;
266
253
  const eventParams = {
267
254
  workbook,
268
255
  worksheet,
269
- row,
270
- col
256
+ row: actualRow,
257
+ col: actualColumn
271
258
  };
272
259
  if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new CanceledError();
273
260
  }
274
261
  })));
275
262
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
276
263
  if (command.id === SheetToggleNotePopupCommand.id) {
277
- const target = this.getSheetCommandTarget();
264
+ const target = getSheetCommandTarget(injector.get(IUniverInstanceService));
278
265
  if (!target) return;
266
+ const { unitId, subUnitId } = target;
267
+ const workbook = this.getUniverSheet(unitId);
268
+ if (!workbook) return;
269
+ const worksheet = workbook.getSheetBySheetId(subUnitId);
270
+ if (!worksheet) return;
279
271
  const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
280
272
  if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
281
- const { workbook, worksheet, unitId, subUnitId } = target;
282
- const { actualRow: row, actualColumn: col } = selection.primary;
283
- const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
284
- row,
285
- col
273
+ const sheetsNoteModel = injector.get(SheetsNoteModel);
274
+ const { actualColumn, actualRow } = selection.primary;
275
+ const note = sheetsNoteModel.getNote(unitId, subUnitId, {
276
+ row: actualRow,
277
+ col: actualColumn
286
278
  });
287
279
  if (!note || !note.show) return;
288
280
  const eventParams = {
289
281
  workbook,
290
282
  worksheet,
291
- row,
292
- col
283
+ row: actualRow,
284
+ col: actualColumn
293
285
  };
294
286
  if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new CanceledError();
295
287
  }
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { CommandType, DependentOn, Disposable, ICommandService, IConfigService,
2
2
  import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, getSheetCommandTarget, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
3
3
  import { Subject, filter, map } from "rxjs";
4
4
 
5
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
5
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
6
6
  function _typeof(o) {
7
7
  "@babel/helpers - typeof";
8
8
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -13,7 +13,7 @@ function _typeof(o) {
13
13
  }
14
14
 
15
15
  //#endregion
16
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
16
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
17
17
  function toPrimitive(t, r) {
18
18
  if ("object" != _typeof(t) || !t) return t;
19
19
  var e = t[Symbol.toPrimitive];
@@ -26,14 +26,14 @@ function toPrimitive(t, r) {
26
26
  }
27
27
 
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
29
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
30
30
  function toPropertyKey(t) {
31
31
  var i = toPrimitive(t, "string");
32
32
  return "symbol" == _typeof(i) ? i : i + "";
33
33
  }
34
34
 
35
35
  //#endregion
36
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
36
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
37
37
  function _defineProperty(e, r, t) {
38
38
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
39
39
  value: t,
@@ -440,7 +440,7 @@ const SheetUpdateNoteCommand = {
440
440
  const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
441
441
 
442
442
  //#endregion
443
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
443
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
444
444
  function __decorateParam(paramIndex, decorator) {
445
445
  return function(target, key) {
446
446
  decorator(target, key, paramIndex);
@@ -448,7 +448,7 @@ function __decorateParam(paramIndex, decorator) {
448
448
  }
449
449
 
450
450
  //#endregion
451
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
451
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
452
452
  function __decorate(decorators, target, key, desc) {
453
453
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
454
454
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -616,7 +616,7 @@ SheetsNoteResourceController = __decorate([
616
616
  //#endregion
617
617
  //#region package.json
618
618
  var name = "@univerjs/sheets-note";
619
- var version = "0.25.0-insiders.20260623-012b5a8";
619
+ var version = "0.25.1";
620
620
 
621
621
  //#endregion
622
622
  //#region src/config/config.ts
@@ -16,13 +16,6 @@
16
16
  import type { Nullable } from '@univerjs/core';
17
17
  import type { ISheetNote } from '@univerjs/sheets-note';
18
18
  import { FRange } from '@univerjs/sheets/facade';
19
- export interface ICreateOrUpdateNoteOptions {
20
- id?: string;
21
- width: number;
22
- height: number;
23
- note: string;
24
- show?: boolean;
25
- }
26
19
  /**
27
20
  * @ignore
28
21
  */
@@ -43,7 +36,7 @@ export interface IFRangeSheetsNoteMixin {
43
36
  getNote(): Nullable<ISheetNote>;
44
37
  /**
45
38
  * Create or update the annotation of the top-left cell in the range
46
- * @param {ICreateOrUpdateNoteOptions} note The annotation to create or update
39
+ * @param {ISheetNote} note The annotation to create or update
47
40
  * @returns {FRange} This range for method chaining
48
41
  * @example
49
42
  * ```ts
@@ -59,7 +52,7 @@ export interface IFRangeSheetsNoteMixin {
59
52
  * });
60
53
  * ```
61
54
  */
62
- createOrUpdateNote(note: ICreateOrUpdateNoteOptions): FRange;
55
+ createOrUpdateNote(note: ISheetNote): FRange;
63
56
  /**
64
57
  * Delete the annotation of the top-left cell in the range
65
58
  * @returns {FRange} This range for method chaining
@@ -81,7 +74,7 @@ export interface IFRangeSheetsNoteMixin {
81
74
  deleteNote(): FRange;
82
75
  }
83
76
  export declare class FRangeSheetsNoteMixin extends FRange implements IFRangeSheetsNoteMixin {
84
- createOrUpdateNote(note: ICreateOrUpdateNoteOptions): FRange;
77
+ createOrUpdateNote(note: ISheetNote): FRange;
85
78
  deleteNote(): FRange;
86
79
  getNote(): Nullable<ISheetNote>;
87
80
  }
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/sheets")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core/facade`,`@univerjs/sheets-note`,`@univerjs/sheets/facade`,`@univerjs/core`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteFacade={},e.UniverCoreFacade,e.UniverSheetsNote,e.UniverSheetsFacade,e.UniverCore,e.UniverSheets))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=class extends t.FEventName{get SheetNoteAdd(){return`SheetNoteAdd`}get SheetNoteDelete(){return`SheetNoteDelete`}get SheetNoteUpdate(){return`SheetNoteUpdate`}get SheetNoteShow(){return`SheetNoteShow`}get SheetNoteHide(){return`SheetNoteHide`}get BeforeSheetNoteAdd(){return`BeforeSheetNoteAdd`}get BeforeSheetNoteDelete(){return`BeforeSheetNoteDelete`}get BeforeSheetNoteUpdate(){return`BeforeSheetNoteUpdate`}get BeforeSheetNoteShow(){return`BeforeSheetNoteShow`}get BeforeSheetNoteHide(){return`BeforeSheetNoteHide`}};t.FEventName.extend(o);var s=class extends r.FRange{createOrUpdateNote(e){return this._commandService.syncExecuteCommand(n.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:e}),this}deleteNote(){return this._commandService.syncExecuteCommand(n.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(n.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),{row:this.getRow(),col:this.getColumn()})}};r.FRange.extend(s);var c=class extends t.FUniver{_initialize(e){let t=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&!e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col,note:r};this.fireEvent(this.Event.SheetNoteAdd,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&!e.newNote){let{unitId:t,subUnitId:n,oldNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col,oldNote:r};this.fireEvent(this.Event.SheetNoteDelete,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!a)return;let{workbook:o,worksheet:s}=a,c={workbook:o,worksheet:s,row:i.row,col:i.col,note:i,oldNote:r};this.fireEvent(this.Event.SheetNoteUpdate,c)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote&&!e.oldNote.show&&e.newNote.show){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col};this.fireEvent(this.Event.SheetNoteShow,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote&&e.oldNote.show&&!e.newNote.show){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col};this.fireEvent(this.Event.SheetNoteHide,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetUpdateNoteCommand.id){let r=t.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=a,{row:u,col:d,note:f}=r;if(e.get(n.SheetsNoteModel).getNote(c,l,{noteId:f.id,row:u,col:d}))return;let p={workbook:o,worksheet:s,row:u,col:d,note:f};if(this.fireEvent(this.Event.BeforeSheetNoteAdd,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetDeleteNoteCommand.id){let t=this.getSheetCommandTarget();if(!t)return;let r=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(r!=null&&r.primary))return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=t,{actualRow:u,actualColumn:d}=r.primary,f=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!f)return;let p={workbook:o,worksheet:s,row:u,col:d,oldNote:f};if(this.fireEvent(this.Event.BeforeSheetNoteDelete,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetUpdateNoteCommand.id){let r=t.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=a,{row:u,col:d,note:f}=r,p=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!p)return;let m={workbook:o,worksheet:s,row:u,col:d,note:f,oldNote:p};if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,m))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetToggleNotePopupCommand.id){let t=this.getSheetCommandTarget();if(!t)return;let r=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(r!=null&&r.primary))return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=t,{actualRow:u,actualColumn:d}=r.primary,f=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!f||f.show)return;let p={workbook:o,worksheet:s,row:u,col:d};if(this.fireEvent(this.Event.BeforeSheetNoteShow,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetToggleNotePopupCommand.id){let t=this.getSheetCommandTarget();if(!t)return;let r=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(r!=null&&r.primary))return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=t,{actualRow:u,actualColumn:d}=r.primary,f=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!f||!f.show)return;let p={workbook:o,worksheet:s,row:u,col:d};if(this.fireEvent(this.Event.BeforeSheetNoteHide,p))throw new i.CanceledError}})))}};t.FUniver.extend(c);var l=class extends r.FWorksheet{getNotes(){let e=this._injector.get(n.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId());return e?Array.from(e.values()).map(e=>({...e})):[]}};r.FWorksheet.extend(l),e.FRangeSheetsNoteMixin=s,e.FSheetsNoteEventNameMixin=o,e.FUniverSheetsNoteMixin=c,e.FWorksheetNoteMixin=l});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/sheets")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core/facade`,`@univerjs/sheets-note`,`@univerjs/sheets/facade`,`@univerjs/core`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteFacade={},e.UniverCoreFacade,e.UniverSheetsNote,e.UniverSheetsFacade,e.UniverCore,e.UniverSheets))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=class extends t.FEventName{get SheetNoteAdd(){return`SheetNoteAdd`}get SheetNoteDelete(){return`SheetNoteDelete`}get SheetNoteUpdate(){return`SheetNoteUpdate`}get SheetNoteShow(){return`SheetNoteShow`}get SheetNoteHide(){return`SheetNoteHide`}get BeforeSheetNoteAdd(){return`BeforeSheetNoteAdd`}get BeforeSheetNoteDelete(){return`BeforeSheetNoteDelete`}get BeforeSheetNoteUpdate(){return`BeforeSheetNoteUpdate`}get BeforeSheetNoteShow(){return`BeforeSheetNoteShow`}get BeforeSheetNoteHide(){return`BeforeSheetNoteHide`}};t.FEventName.extend(o);var s=class extends r.FRange{createOrUpdateNote(e){return this._commandService.syncExecuteCommand(n.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:e}),this}deleteNote(){return this._commandService.syncExecuteCommand(n.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(n.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),{row:this.getRow(),col:this.getColumn()})}};r.FRange.extend(s);var c=class extends t.FUniver{_initialize(e){let t=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&!e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetTarget(t,n);if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col,note:r};this.fireEvent(this.Event.SheetNoteAdd,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&!e.newNote){let{unitId:t,subUnitId:n,oldNote:r}=e,i=this.getSheetTarget(t,n);if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col,oldNote:r};this.fireEvent(this.Event.SheetNoteDelete,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=this.getSheetTarget(t,n);if(!a)return;let{workbook:o,worksheet:s}=a,c={workbook:o,worksheet:s,row:i.row,col:i.col,note:i,oldNote:r};this.fireEvent(this.Event.SheetNoteUpdate,c)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote&&!e.oldNote.show&&e.newNote.show){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetTarget(t,n);if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col};this.fireEvent(this.Event.SheetNoteShow,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote&&e.oldNote.show&&!e.newNote.show){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetTarget(t,n);if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col};this.fireEvent(this.Event.SheetNoteHide,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetUpdateNoteCommand.id){let{unitId:r,sheetId:a,row:o,col:s,note:c}=t.params,l=this.getSheetTarget(r,a);if(!l||e.get(n.SheetsNoteModel).getNote(r,a,{noteId:c.id,row:o,col:s}))return;let{workbook:u,worksheet:d}=l,f={workbook:u,worksheet:d,row:o,col:s,note:c};if(this.fireEvent(this.Event.BeforeSheetNoteAdd,f))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetDeleteNoteCommand.id){let{unitId:r,sheetId:a,row:o,col:s}=t.params,c=this.getSheetTarget(r,a);if(!c||o===void 0||s===void 0)return;let l=e.get(n.SheetsNoteModel).getNote(r,a,{row:o,col:s});if(!l)return;let{workbook:u,worksheet:d}=c,f={workbook:u,worksheet:d,row:o,col:s,oldNote:l};if(this.fireEvent(this.Event.BeforeSheetNoteDelete,f))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetUpdateNoteCommand.id){let{unitId:r,sheetId:a,row:o,col:s,note:c}=t.params,l=this.getSheetTarget(r,a);if(!l)return;let u=e.get(n.SheetsNoteModel).getNote(r,a,{row:o,col:s});if(!u)return;let{workbook:d,worksheet:f}=l,p={workbook:d,worksheet:f,row:o,col:s,note:c,oldNote:u};if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetToggleNotePopupCommand.id){let t=(0,a.getSheetCommandTarget)(e.get(i.IUniverInstanceService));if(!t)return;let{unitId:r,subUnitId:o}=t,s=this.getUniverSheet(r);if(!s)return;let c=s.getSheetBySheetId(o);if(!c)return;let l=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(l!=null&&l.primary))return;let u=e.get(n.SheetsNoteModel),{actualColumn:d,actualRow:f}=l.primary,p=u.getNote(r,o,{row:f,col:d});if(!p||p.show)return;let m={workbook:s,worksheet:c,row:f,col:d};if(this.fireEvent(this.Event.BeforeSheetNoteShow,m))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetToggleNotePopupCommand.id){let t=(0,a.getSheetCommandTarget)(e.get(i.IUniverInstanceService));if(!t)return;let{unitId:r,subUnitId:o}=t,s=this.getUniverSheet(r);if(!s)return;let c=s.getSheetBySheetId(o);if(!c)return;let l=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(l!=null&&l.primary))return;let u=e.get(n.SheetsNoteModel),{actualColumn:d,actualRow:f}=l.primary,p=u.getNote(r,o,{row:f,col:d});if(!p||!p.show)return;let m={workbook:s,worksheet:c,row:f,col:d};if(this.fireEvent(this.Event.BeforeSheetNoteHide,m))throw new i.CanceledError}})))}};t.FUniver.extend(c);var l=class extends r.FWorksheet{getNotes(){let e=this._injector.get(n.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId());return e?Array.from(e.values()).map(e=>({...e})):[]}};r.FWorksheet.extend(l),e.FRangeSheetsNoteMixin=s,e.FSheetsNoteEventNameMixin=o,e.FUniverSheetsNoteMixin=c,e.FWorksheetNoteMixin=l});
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNote={},e.UniverCore,e.UniverSheets,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function i(e){"@babel/helpers - typeof";return i=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},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=class extends t.Disposable{constructor(...e){super(...e),s(this,`_notesMap`,new Map),s(this,`_change$`,new r.Subject),s(this,`change$`,this._change$.asObservable())}_ensureNotesMap(e,t){let n=this._notesMap.get(e);n||(n=new Map,this._notesMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_getNoteByPosition(e,t,n,r){let i=this._ensureNotesMap(e,t);for(let[e,t]of i)if(t.row===n&&t.col===r)return t}_getNoteById(e,t,n){return this._ensureNotesMap(e,t).get(n)}_getNoteByParams(e,t,n){let{noteId:r,row:i,col:a}=n;return r?this._getNoteById(e,t,r):i!==void 0&&a!==void 0?this._getNoteByPosition(e,t,i,a):null}getSheetShowNotes$(e,t){return this._change$.pipe((0,r.filter)(({unitId:n,subUnitId:r})=>n===e&&r===t),(0,r.map)(()=>{let n=this._ensureNotesMap(e,t),r=[];for(let[i,a]of n)a.show&&r.push({loc:{row:a.row,col:a.col,unitId:e,subUnitId:t},note:a});return r}))}getCellNoteChange$(e,t,n,i){return this._change$.pipe((0,r.filter)(({unitId:r,subUnitId:a,oldNote:o})=>r!==e||a!==t||!o?!1:o.row===n&&o.col===i),(0,r.map)(e=>e))}updateNote(e,n,r,i,a,o){let s=this._getNoteByParams(e,n,{noteId:a==null?void 0:a.id,row:r,col:i}),c=this._ensureNotesMap(e,n),l={...a,id:(s==null?void 0:s.id)||a.id||(0,t.generateRandomId)(6),row:r,col:i};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:n,oldNote:s,type:`update`,newNote:l,silent:o})}removeNote(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});s&&(this._ensureNotesMap(e,t).delete(s.id),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:null,silent:o}))}toggleNotePopup(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!s)return;let c=this._ensureNotesMap(e,t),l={...s,show:!s.show};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:l,silent:o})}updateNotePosition(e,t,n){let{noteId:r,row:i,col:a,newRow:o,newCol:s,silent:c}=n,l=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!l)return;let u=this._ensureNotesMap(e,t),d={...l,row:o,col:s};u.set(d.id,d),this._change$.next({unitId:e,subUnitId:t,oldNote:l,type:`ref`,newNote:d,silent:c})}getNote(e,t,n){return this._getNoteByParams(e,t,n)}getNotes(){return this._notesMap}getUnitNotes(e){return this._notesMap.get(e)}getSheetNotes(e,t){let n=this._notesMap.get(e);if(n)return n.get(t)}deleteUnitNotes(e){this._notesMap.delete(e)}};let l={id:`sheet.mutation.update-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,row:i,col:a,note:o,silent:s}=t;return e.get(c).updateNote(n,r,i,a,o,s),!0}},u={id:`sheet.mutation.remove-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).removeNote(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},d={id:`sheet.mutation.toggle-note-popup`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).toggleNotePopup(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},f={id:`sheet.mutation.update-note-position`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,newPosition:s,silent:l}=t;return e.get(c).updateNotePosition(n,r,{noteId:i,row:a,col:o,newRow:s.row,newCol:s.col,silent:l}),!0}},p={id:`sheet.command.delete-note`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:d,actualRow:f}=i.primary,p=a.getNote(o,s,{row:f,col:d});if(!p)return!1;let m=e.get(t.ICommandService),h=e.get(t.IUndoRedoService),g={id:u.id,params:{unitId:o,sheetId:s,noteId:p.id}},_={id:l.id,params:{unitId:o,sheetId:s,row:f,col:d,note:{...p}}};return m.syncExecuteCommand(g.id,g.params)?(h.pushUndoRedo({unitID:o,redoMutations:[g],undoMutations:[_]}),!0):!1}},m={id:`sheet.command.toggle-note-popup`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:l,actualRow:u}=i.primary,f=a.getNote(o,s,{row:u,col:l});if(!f)return!1;let p=e.get(t.ICommandService),m=e.get(t.IUndoRedoService),h={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}},g={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}};return p.syncExecuteCommand(h.id,h.params)?(m.pushUndoRedo({unitID:o,redoMutations:[h],undoMutations:[g]}),!0):!1}},h={id:`sheet.command.update-note`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(c),{unitId:d,subUnitId:f}=i,{row:p,col:m,note:h}=r,g=s.getNote(d,f,{noteId:h.id,row:p,col:m}),_={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:h}},v=[];if(g){let e={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:{...g}}};v.push(e)}else{let e={id:u.id,params:{unitId:d,sheetId:f,row:p,col:m}};v.push(e)}return a.syncExecuteCommand(_.id,_.params)?(o.pushUndoRedo({unitID:d,redoMutations:[_],undoMutations:v}),!0):!1}},g=`SHEET_NOTE_PLUGIN`;function _(e,t){return function(n,r){t(n,r,e)}}function v(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 y=class extends t.Disposable{constructor(e,t,n,r){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._sheetsNoteModel=r,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){let e=e=>{let t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return``;let n={};return t.forEach((e,t)=>{let r={};e.forEach(e=>{let{row:t,col:n}=e;r[t]||(r[t]={}),r[t][n]=e}),Object.keys(r).length>0&&(n[t]=r)}),JSON.stringify(n)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:g,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([t,n])=>{Object.entries(n).forEach(([n,r])=>{Object.entries(r).forEach(([r,i])=>{this._sheetsNoteModel.updateNote(e,t,Number(n),Number(r),i)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===n.RemoveSheetCommand.id){var r;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetsNoteModel.getSheetNotes(i,a);if(!o)return{redos:[],undos:[]};let s=[],c=[];return o.forEach(e=>{s.push({id:u.id,params:{unitId:i,sheetId:a,noteId:e.id,row:e.row,col:e.col}}),c.push({id:l.id,params:{unitId:i,sheetId:a,row:e.row,col:e.col,note:e}})}),{redos:s,undos:c}}else if(e.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetsNoteModel.getSheetNotes(n,r);if(!a)return{redos:[],undos:[]};let o=[],s=[];return a.forEach(e=>{let r={...e,id:(0,t.generateRandomId)(6)};o.push({id:l.id,params:{unitId:n,sheetId:i,row:r.row,col:r.col,note:r}}),s.push({id:u.id,params:{unitId:n,sheetId:i,noteId:r.id,row:r.row,col:r.col}})}),{redos:o,undos:s}}return{redos:[],undos:[]}}}))}};y=v([_(0,t.IResourceManagerService),_(1,t.IUniverInstanceService),_(2,(0,t.Inject)(n.SheetInterceptorService)),_(3,(0,t.Inject)(c))],y);var b=`@univerjs/sheets-note`,x=`0.25.0-insiders.20260623-012b5a8`;let S={},C=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._sheetsNoteModel=t,this._selectionManagerService=n,this._commandService=r,s(this,`_disposableMap`,new Map),s(this,`_watcherMap`,new Map),s(this,`_handleRangeChange`,(e,t,n,r,i,a,o)=>a?{redos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:a.startRow,col:a.startColumn},silent:o}}],undos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:r,col:i},note:n,silent:o}}]}:{redos:[{id:u.id,params:{unitId:e,sheetId:t,noteId:n.id}}],undos:[{id:l.id,params:{unitId:e,sheetId:t,row:r,col:i,note:n}}]}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n,r){return`${e}-${t}-${n}-${r}`}_register(e,t,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._disposableMap.set(this._getIdWithUnitId(e,t,i,a),this._refRangeService.registerRefRange(o,s=>{let c=(0,n.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(o,s,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===o.startColumn&&l.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,r,i,a,l,!1)},e,t))}_watch(e,n,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._watcherMap.set(this._getIdWithUnitId(e,n,i,a),this._refRangeService.watchRange(e,n,o,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,i.startRow,i.startColumn,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._watcherMap.get(a))==null||i.dispose(),this._watcherMap.delete(a)}_unregister(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._disposableMap.get(a))==null||i.dispose(),this._disposableMap.delete(a)}_initData(){let e=this._sheetsNoteModel.getNotes();for(let[t,n]of e)for(let[e,r]of n)r.forEach(n=>{this._register(t,e,n,n.row,n.col),this._watch(t,e,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{switch(e.type){case`update`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=i?i.row:r.row,o=i?i.col:r.col,s=this._getIdWithUnitId(t,n,a,o);i?this._disposableMap.has(s)||(this._register(t,n,i,a,o),this._watch(t,n,i,a,o)):(this._unregister(t,n,a,o),this._unwatch(t,n,a,o));break}case`ref`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i,silent:a}=e,{row:o,col:s}=r,{row:c,col:l}=i;this._unregister(t,n,o,s),a||(this._unwatch(t,n,o,s),this._watch(t,n,i,c,l)),this._register(t,n,i,c,l);break}}}))}};C=v([_(0,(0,t.Inject)(n.RefRangeService)),_(1,(0,t.Inject)(c)),_(2,(0,t.Inject)(n.SheetsSelectionsService)),_(3,t.ICommandService)],C);let w=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._initialize()}_initialize(){[f,d,l,u,p,m,h].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}};w=v([_(0,t.ICommandService)],w);let T=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._configService=n,this._injector=r;let{...i}=(0,t.merge)({},S,this._config);this._configService.setConfig(`sheets-note.config`,i)}onStarting(){[[c],[w],[y],[C]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[c],[w],[y]])}onReady(){(0,t.touchDependencies)(this._injector,[[C]])}};s(T,`pluginName`,g),s(T,`packageName`,b),s(T,`version`,x),s(T,`type`,t.UniverInstanceType.UNIVER_SHEET),T=v([(0,t.DependentOn)(n.UniverSheetsPlugin),_(1,t.IConfigService),_(2,(0,t.Inject)(t.Injector))],T),e.RemoveNoteMutation=u,e.SheetDeleteNoteCommand=p,e.SheetToggleNotePopupCommand=m,e.SheetUpdateNoteCommand=h,e.SheetsNoteModel=c,Object.defineProperty(e,"SheetsNoteResourceController",{enumerable:!0,get:function(){return y}}),e.ToggleNotePopupMutation=d,Object.defineProperty(e,"UniverSheetsNotePlugin",{enumerable:!0,get:function(){return T}}),e.UpdateNoteMutation=l,e.UpdateNotePositionMutation=f});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNote={},e.UniverCore,e.UniverSheets,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function i(e){"@babel/helpers - typeof";return i=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},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=class extends t.Disposable{constructor(...e){super(...e),s(this,`_notesMap`,new Map),s(this,`_change$`,new r.Subject),s(this,`change$`,this._change$.asObservable())}_ensureNotesMap(e,t){let n=this._notesMap.get(e);n||(n=new Map,this._notesMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_getNoteByPosition(e,t,n,r){let i=this._ensureNotesMap(e,t);for(let[e,t]of i)if(t.row===n&&t.col===r)return t}_getNoteById(e,t,n){return this._ensureNotesMap(e,t).get(n)}_getNoteByParams(e,t,n){let{noteId:r,row:i,col:a}=n;return r?this._getNoteById(e,t,r):i!==void 0&&a!==void 0?this._getNoteByPosition(e,t,i,a):null}getSheetShowNotes$(e,t){return this._change$.pipe((0,r.filter)(({unitId:n,subUnitId:r})=>n===e&&r===t),(0,r.map)(()=>{let n=this._ensureNotesMap(e,t),r=[];for(let[i,a]of n)a.show&&r.push({loc:{row:a.row,col:a.col,unitId:e,subUnitId:t},note:a});return r}))}getCellNoteChange$(e,t,n,i){return this._change$.pipe((0,r.filter)(({unitId:r,subUnitId:a,oldNote:o})=>r!==e||a!==t||!o?!1:o.row===n&&o.col===i),(0,r.map)(e=>e))}updateNote(e,n,r,i,a,o){let s=this._getNoteByParams(e,n,{noteId:a==null?void 0:a.id,row:r,col:i}),c=this._ensureNotesMap(e,n),l={...a,id:(s==null?void 0:s.id)||a.id||(0,t.generateRandomId)(6),row:r,col:i};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:n,oldNote:s,type:`update`,newNote:l,silent:o})}removeNote(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});s&&(this._ensureNotesMap(e,t).delete(s.id),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:null,silent:o}))}toggleNotePopup(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!s)return;let c=this._ensureNotesMap(e,t),l={...s,show:!s.show};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:l,silent:o})}updateNotePosition(e,t,n){let{noteId:r,row:i,col:a,newRow:o,newCol:s,silent:c}=n,l=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!l)return;let u=this._ensureNotesMap(e,t),d={...l,row:o,col:s};u.set(d.id,d),this._change$.next({unitId:e,subUnitId:t,oldNote:l,type:`ref`,newNote:d,silent:c})}getNote(e,t,n){return this._getNoteByParams(e,t,n)}getNotes(){return this._notesMap}getUnitNotes(e){return this._notesMap.get(e)}getSheetNotes(e,t){let n=this._notesMap.get(e);if(n)return n.get(t)}deleteUnitNotes(e){this._notesMap.delete(e)}};let l={id:`sheet.mutation.update-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,row:i,col:a,note:o,silent:s}=t;return e.get(c).updateNote(n,r,i,a,o,s),!0}},u={id:`sheet.mutation.remove-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).removeNote(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},d={id:`sheet.mutation.toggle-note-popup`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).toggleNotePopup(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},f={id:`sheet.mutation.update-note-position`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,newPosition:s,silent:l}=t;return e.get(c).updateNotePosition(n,r,{noteId:i,row:a,col:o,newRow:s.row,newCol:s.col,silent:l}),!0}},p={id:`sheet.command.delete-note`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:d,actualRow:f}=i.primary,p=a.getNote(o,s,{row:f,col:d});if(!p)return!1;let m=e.get(t.ICommandService),h=e.get(t.IUndoRedoService),g={id:u.id,params:{unitId:o,sheetId:s,noteId:p.id}},_={id:l.id,params:{unitId:o,sheetId:s,row:f,col:d,note:{...p}}};return m.syncExecuteCommand(g.id,g.params)?(h.pushUndoRedo({unitID:o,redoMutations:[g],undoMutations:[_]}),!0):!1}},m={id:`sheet.command.toggle-note-popup`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:l,actualRow:u}=i.primary,f=a.getNote(o,s,{row:u,col:l});if(!f)return!1;let p=e.get(t.ICommandService),m=e.get(t.IUndoRedoService),h={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}},g={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}};return p.syncExecuteCommand(h.id,h.params)?(m.pushUndoRedo({unitID:o,redoMutations:[h],undoMutations:[g]}),!0):!1}},h={id:`sheet.command.update-note`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(c),{unitId:d,subUnitId:f}=i,{row:p,col:m,note:h}=r,g=s.getNote(d,f,{noteId:h.id,row:p,col:m}),_={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:h}},v=[];if(g){let e={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:{...g}}};v.push(e)}else{let e={id:u.id,params:{unitId:d,sheetId:f,row:p,col:m}};v.push(e)}return a.syncExecuteCommand(_.id,_.params)?(o.pushUndoRedo({unitID:d,redoMutations:[_],undoMutations:v}),!0):!1}},g=`SHEET_NOTE_PLUGIN`;function _(e,t){return function(n,r){t(n,r,e)}}function v(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 y=class extends t.Disposable{constructor(e,t,n,r){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._sheetsNoteModel=r,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){let e=e=>{let t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return``;let n={};return t.forEach((e,t)=>{let r={};e.forEach(e=>{let{row:t,col:n}=e;r[t]||(r[t]={}),r[t][n]=e}),Object.keys(r).length>0&&(n[t]=r)}),JSON.stringify(n)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:g,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([t,n])=>{Object.entries(n).forEach(([n,r])=>{Object.entries(r).forEach(([r,i])=>{this._sheetsNoteModel.updateNote(e,t,Number(n),Number(r),i)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===n.RemoveSheetCommand.id){var r;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetsNoteModel.getSheetNotes(i,a);if(!o)return{redos:[],undos:[]};let s=[],c=[];return o.forEach(e=>{s.push({id:u.id,params:{unitId:i,sheetId:a,noteId:e.id,row:e.row,col:e.col}}),c.push({id:l.id,params:{unitId:i,sheetId:a,row:e.row,col:e.col,note:e}})}),{redos:s,undos:c}}else if(e.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetsNoteModel.getSheetNotes(n,r);if(!a)return{redos:[],undos:[]};let o=[],s=[];return a.forEach(e=>{let r={...e,id:(0,t.generateRandomId)(6)};o.push({id:l.id,params:{unitId:n,sheetId:i,row:r.row,col:r.col,note:r}}),s.push({id:u.id,params:{unitId:n,sheetId:i,noteId:r.id,row:r.row,col:r.col}})}),{redos:o,undos:s}}return{redos:[],undos:[]}}}))}};y=v([_(0,t.IResourceManagerService),_(1,t.IUniverInstanceService),_(2,(0,t.Inject)(n.SheetInterceptorService)),_(3,(0,t.Inject)(c))],y);var b=`@univerjs/sheets-note`,x=`0.25.1`;let S={},C=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._sheetsNoteModel=t,this._selectionManagerService=n,this._commandService=r,s(this,`_disposableMap`,new Map),s(this,`_watcherMap`,new Map),s(this,`_handleRangeChange`,(e,t,n,r,i,a,o)=>a?{redos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:a.startRow,col:a.startColumn},silent:o}}],undos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:r,col:i},note:n,silent:o}}]}:{redos:[{id:u.id,params:{unitId:e,sheetId:t,noteId:n.id}}],undos:[{id:l.id,params:{unitId:e,sheetId:t,row:r,col:i,note:n}}]}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n,r){return`${e}-${t}-${n}-${r}`}_register(e,t,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._disposableMap.set(this._getIdWithUnitId(e,t,i,a),this._refRangeService.registerRefRange(o,s=>{let c=(0,n.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(o,s,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===o.startColumn&&l.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,r,i,a,l,!1)},e,t))}_watch(e,n,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._watcherMap.set(this._getIdWithUnitId(e,n,i,a),this._refRangeService.watchRange(e,n,o,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,i.startRow,i.startColumn,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._watcherMap.get(a))==null||i.dispose(),this._watcherMap.delete(a)}_unregister(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._disposableMap.get(a))==null||i.dispose(),this._disposableMap.delete(a)}_initData(){let e=this._sheetsNoteModel.getNotes();for(let[t,n]of e)for(let[e,r]of n)r.forEach(n=>{this._register(t,e,n,n.row,n.col),this._watch(t,e,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{switch(e.type){case`update`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=i?i.row:r.row,o=i?i.col:r.col,s=this._getIdWithUnitId(t,n,a,o);i?this._disposableMap.has(s)||(this._register(t,n,i,a,o),this._watch(t,n,i,a,o)):(this._unregister(t,n,a,o),this._unwatch(t,n,a,o));break}case`ref`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i,silent:a}=e,{row:o,col:s}=r,{row:c,col:l}=i;this._unregister(t,n,o,s),a||(this._unwatch(t,n,o,s),this._watch(t,n,i,c,l)),this._register(t,n,i,c,l);break}}}))}};C=v([_(0,(0,t.Inject)(n.RefRangeService)),_(1,(0,t.Inject)(c)),_(2,(0,t.Inject)(n.SheetsSelectionsService)),_(3,t.ICommandService)],C);let w=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._initialize()}_initialize(){[f,d,l,u,p,m,h].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}};w=v([_(0,t.ICommandService)],w);let T=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._configService=n,this._injector=r;let{...i}=(0,t.merge)({},S,this._config);this._configService.setConfig(`sheets-note.config`,i)}onStarting(){[[c],[w],[y],[C]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[c],[w],[y]])}onReady(){(0,t.touchDependencies)(this._injector,[[C]])}};s(T,`pluginName`,g),s(T,`packageName`,b),s(T,`version`,x),s(T,`type`,t.UniverInstanceType.UNIVER_SHEET),T=v([(0,t.DependentOn)(n.UniverSheetsPlugin),_(1,t.IConfigService),_(2,(0,t.Inject)(t.Injector))],T),e.RemoveNoteMutation=u,e.SheetDeleteNoteCommand=p,e.SheetToggleNotePopupCommand=m,e.SheetUpdateNoteCommand=h,e.SheetsNoteModel=c,Object.defineProperty(e,"SheetsNoteResourceController",{enumerable:!0,get:function(){return y}}),e.ToggleNotePopupMutation=d,Object.defineProperty(e,"UniverSheetsNotePlugin",{enumerable:!0,get:function(){return T}}),e.UpdateNoteMutation=l,e.UpdateNotePositionMutation=f});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-note",
3
- "version": "0.25.0-insiders.20260623-012b5a8",
3
+ "version": "0.25.1",
4
4
  "private": false,
5
5
  "description": "Cell note model and commands for Univer Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -62,17 +62,17 @@
62
62
  "rxjs": ">=7.0.0"
63
63
  },
64
64
  "dependencies": {
65
- "@univerjs/core": "0.25.0-insiders.20260623-012b5a8",
66
- "@univerjs/sheets": "0.25.0-insiders.20260623-012b5a8"
65
+ "@univerjs/core": "0.25.1",
66
+ "@univerjs/sheets": "0.25.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "rxjs": "^7.8.2",
70
70
  "typescript": "^6.0.3",
71
- "vitest": "^4.1.9",
72
- "@univerjs-infra/shared": "0.25.0",
73
- "@univerjs/network": "0.25.0-insiders.20260623-012b5a8",
74
- "@univerjs/engine-render": "0.25.0-insiders.20260623-012b5a8",
75
- "@univerjs/engine-formula": "0.25.0-insiders.20260623-012b5a8"
71
+ "vitest": "^4.1.7",
72
+ "@univerjs/engine-formula": "0.25.1",
73
+ "@univerjs-infra/shared": "0.25.1",
74
+ "@univerjs/engine-render": "0.25.1",
75
+ "@univerjs/network": "0.25.1"
76
76
  },
77
77
  "scripts": {
78
78
  "test": "vitest run",