@univerjs/sheets-note 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@univerjs/core/facade"),c=require("@univerjs/sheets-note"),u=require("@univerjs/sheets/facade"),N=require("@univerjs/core");class v{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"}}f.FEventName.extend(v);class w extends u.FRange{createOrUpdateNote(h){return this._commandService.syncExecuteCommand(c.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:h}),this}deleteNote(){return this._commandService.syncExecuteCommand(c.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(c.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}u.FRange.extend(w);class E extends f.FUniver{_initialize(h){this.registerEventHandler(this.Event.SheetNoteAdd,()=>h.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:s,note:r,oldNote:i}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:l}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:S,worksheet:l,row:o,col:s,note:r})}})),this.registerEventHandler(this.Event.SheetNoteDelete,()=>h.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:d,sheetId:t,row:o,col:s,note:r,oldNote:i}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:l}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:S,worksheet:l,row:o,col:s,oldNote:i})}})),this.registerEventHandler(this.Event.SheetNoteUpdate,()=>h.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:s,note:r,oldNote:i}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:l}=n;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:l,row:o,col:s,note:r,oldNote:i})}})),this.registerEventHandler(this.Event.SheetNoteShow,()=>h.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:d,sheetId:t,row:o,col:s}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:i,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:i,worksheet:n,row:o,col:s})}})),this.registerEventHandler(this.Event.SheetNoteHide,()=>h.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:d,sheetId:t,row:o,col:s}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:i,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:i,worksheet:n,row:o,col:s})}})),this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>h.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===c.SheetUpdateNoteCommand.id){const d=h.get(c.SheetsNoteModel),{unitId:t,sheetId:o,row:s,col:r,note:i}=e.params;if(d.getNote(t,o,s,r))return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:l,worksheet:g}=S;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:l,worksheet:g,row:s,col:r,note:i}))throw new N.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>h.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===c.SheetDeleteNoteCommand.id){const d=h.get(c.SheetsNoteModel),{unitId:t,sheetId:o,row:s,col:r}=e.params,i=d.getNote(t,o,s,r);if(!i)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:l}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:S,worksheet:l,row:s,col:r,oldNote:i}))throw new N.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>h.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===c.SheetUpdateNoteCommand.id){const d=h.get(c.SheetsNoteModel),{unitId:t,sheetId:o,row:s,col:r,note:i}=e.params,n=d.getNote(t,o,s,r);if(!n)return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:l,worksheet:g}=S;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:l,worksheet:g,row:s,col:r,note:i,oldNote:n}))throw new N.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>h.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===c.SheetToggleNotePopupCommand.id){const d=h.get(c.SheetsNoteModel),{unitId:t,sheetId:o,row:s,col:r}=e.params,i=d.getNote(t,o,s,r);if(i!=null&&i.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:l}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:S,worksheet:l,row:s,col:r}))throw new N.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>h.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===c.SheetToggleNotePopupCommand.id){const d=h.get(c.SheetsNoteModel),{unitId:t,sheetId:o,row:s,col:r}=e.params,i=d.getNote(t,o,s,r);if(!(i!=null&&i.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:l}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:S,worksheet:l,row:s,col:r}))throw new N.CanceledError}}))}}f.FUniver.extend(E);class I extends u.FWorksheet{getNotes(){const a=this._injector.get(c.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),e=[];return a==null||a.forValue((d,t,o)=>{e.push({...o,row:d,col:t})}),e}}u.FWorksheet.extend(I);exports.FSheetNoteEvent=v;exports.FSheetsNoteRangeMixin=w;exports.FSheetsNoteWorksheet=I;exports.FUniverSheetNoteMixin=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@univerjs/core/facade"),l=require("@univerjs/sheets-note"),u=require("@univerjs/sheets/facade"),g=require("@univerjs/core");class E{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"}}w.FEventName.extend(E);class v extends u.FRange{createOrUpdateNote(c){return this._commandService.syncExecuteCommand(l.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:c}),this}deleteNote(){return this._commandService.syncExecuteCommand(l.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(l.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}u.FRange.extend(v);class m extends w.FUniver{_initialize(c){const N=c.get(g.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>c.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:t,sheetId:o,row:r,col:i,note:s}=e,n=this.getSheetTarget(t,o);if(!n)return;const{workbook:d,worksheet:S}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:d,worksheet:S,row:r,col:i,note:s})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>c.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:t,sheetId:o,row:r,col:i,oldNote:s}=e,n=this.getSheetTarget(t,o);if(!n)return;const{workbook:d,worksheet:S}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:d,worksheet:S,row:r,col:i,oldNote:s})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>c.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:t,sheetId:o,row:r,col:i,note:s,oldNote:n}=e,d=this.getSheetTarget(t,o);if(!d)return;const{workbook:S,worksheet:a}=d;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:a,row:r,col:i,note:s,oldNote:n})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>c.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:t,sheetId:o,row:r,col:i}=e,s=this.getSheetTarget(t,o);if(!s)return;const{workbook:n,worksheet:d}=s;this.fireEvent(this.Event.SheetNoteShow,{workbook:n,worksheet:d,row:r,col:i})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>c.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:t,sheetId:o,row:r,col:i}=e,s=this.getSheetTarget(t,o);if(!s)return;const{workbook:n,worksheet:d}=s;this.fireEvent(this.Event.SheetNoteHide,{workbook:n,worksheet:d,row:r,col:i})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>N.beforeCommandExecuted(h=>{if(h.id===l.SheetUpdateNoteCommand.id){const e=c.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:r,col:i,note:s}=h.params;if(e.getNote(t,o,r,i))return;const d=this.getSheetTarget(t,o);if(!d)return;const{workbook:S,worksheet:a}=d;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:S,worksheet:a,row:r,col:i,note:s}))throw new g.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>N.beforeCommandExecuted(h=>{if(h.id===l.SheetDeleteNoteCommand.id){const e=c.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:r,col:i}=h.params,s=e.getNote(t,o,r,i);if(!s)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:d,worksheet:S}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:d,worksheet:S,row:r,col:i,oldNote:s}))throw new g.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>N.beforeCommandExecuted(h=>{if(h.id===l.SheetUpdateNoteCommand.id){const e=c.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:r,col:i,note:s}=h.params,n=e.getNote(t,o,r,i);if(!n)return;const d=this.getSheetTarget(t,o);if(!d)return;const{workbook:S,worksheet:a}=d;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:S,worksheet:a,row:r,col:i,note:s,oldNote:n}))throw new g.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>N.beforeCommandExecuted(h=>{if(h.id===l.SheetToggleNotePopupCommand.id){const e=c.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:r,col:i}=h.params,s=e.getNote(t,o,r,i);if(s!=null&&s.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:d,worksheet:S}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:d,worksheet:S,row:r,col:i}))throw new g.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>N.beforeCommandExecuted(h=>{if(h.id===l.SheetToggleNotePopupCommand.id){const e=c.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:r,col:i}=h.params,s=e.getNote(t,o,r,i);if(!(s!=null&&s.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:d,worksheet:S}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:d,worksheet:S,row:r,col:i}))throw new g.CanceledError}})))}}w.FUniver.extend(m);class p extends u.FWorksheet{getNotes(){const N=this._injector.get(l.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),h=[];return N==null||N.forValue((e,t,o)=>{h.push({...o,row:e,col:t})}),h}}u.FWorksheet.extend(p);exports.FSheetNoteEvent=E;exports.FSheetsNoteRangeMixin=v;exports.FSheetsNoteWorksheet=p;exports.FUniverSheetNoteMixin=m;
package/lib/es/facade.js CHANGED
@@ -1,7 +1,7 @@
1
- import { FEventName as I, FUniver as v } from "@univerjs/core/facade";
2
- import { UpdateNoteMutation as b, RemoveNoteMutation as B, SheetsNoteModel as S, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as H, SheetToggleNotePopupCommand as w } from "@univerjs/sheets-note";
3
- import { FRange as E, FWorksheet as k } from "@univerjs/sheets/facade";
4
- import { ICommandService as u, CanceledError as N } from "@univerjs/core";
1
+ import { FEventName as k, FUniver as m } from "@univerjs/core/facade";
2
+ import { UpdateNoteMutation as I, RemoveNoteMutation as b, SheetsNoteModel as g, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as B, SheetToggleNotePopupCommand as w } from "@univerjs/sheets-note";
3
+ import { FRange as E, FWorksheet as v } from "@univerjs/sheets/facade";
4
+ import { ICommandService as H, CanceledError as N } from "@univerjs/core";
5
5
  class x {
6
6
  get SheetNoteAdd() {
7
7
  return "SheetNoteAdd";
@@ -34,23 +34,23 @@ class x {
34
34
  return "BeforeSheetNoteHide";
35
35
  }
36
36
  }
37
- I.extend(x);
37
+ k.extend(x);
38
38
  class U extends E {
39
- createOrUpdateNote(d) {
39
+ createOrUpdateNote(c) {
40
40
  return this._commandService.syncExecuteCommand(
41
- b.id,
41
+ I.id,
42
42
  {
43
43
  unitId: this.getUnitId(),
44
44
  sheetId: this.getSheetId(),
45
45
  row: this.getRow(),
46
46
  col: this.getColumn(),
47
- note: d
47
+ note: c
48
48
  }
49
49
  ), this;
50
50
  }
51
51
  deleteNote() {
52
52
  return this._commandService.syncExecuteCommand(
53
- B.id,
53
+ b.id,
54
54
  {
55
55
  unitId: this.getUnitId(),
56
56
  sheetId: this.getSheetId(),
@@ -60,216 +60,237 @@ class U extends E {
60
60
  ), this;
61
61
  }
62
62
  getNote() {
63
- return this._injector.get(S).getNote(this.getUnitId(), this.getSheetId(), this.getRow(), this.getColumn());
63
+ return this._injector.get(g).getNote(this.getUnitId(), this.getSheetId(), this.getRow(), this.getColumn());
64
64
  }
65
65
  }
66
66
  E.extend(U);
67
- class C extends v {
67
+ class C extends m {
68
68
  // eslint-disable-next-line max-lines-per-function
69
- _initialize(d) {
70
- this.registerEventHandler(
71
- this.Event.SheetNoteAdd,
72
- () => d.get(S).change$.subscribe((e) => {
73
- if (e.type === "update" && !e.oldNote && e.note) {
74
- const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
75
- if (!n)
76
- return;
77
- const { workbook: c, worksheet: l } = n;
78
- this.fireEvent(this.Event.SheetNoteAdd, {
79
- workbook: c,
80
- worksheet: l,
81
- row: o,
82
- col: s,
83
- note: r
84
- });
85
- }
86
- })
87
- ), this.registerEventHandler(
88
- this.Event.SheetNoteDelete,
89
- () => d.get(S).change$.subscribe((e) => {
90
- if (e.type === "update" && e.oldNote && !e.note) {
91
- const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
92
- if (!n)
93
- return;
94
- const { workbook: c, worksheet: l } = n;
95
- this.fireEvent(this.Event.SheetNoteDelete, {
96
- workbook: c,
97
- worksheet: l,
98
- row: o,
99
- col: s,
100
- oldNote: i
101
- });
102
- }
103
- })
104
- ), this.registerEventHandler(
105
- this.Event.SheetNoteUpdate,
106
- () => d.get(S).change$.subscribe((e) => {
107
- if (e.type === "update" && e.oldNote && e.note) {
108
- const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
109
- if (!n)
110
- return;
111
- const { workbook: c, worksheet: l } = n;
112
- this.fireEvent(this.Event.SheetNoteUpdate, {
113
- workbook: c,
114
- worksheet: l,
115
- row: o,
116
- col: s,
117
- note: r,
118
- oldNote: i
119
- });
120
- }
121
- })
122
- ), this.registerEventHandler(
123
- this.Event.SheetNoteShow,
124
- () => d.get(S).change$.subscribe((e) => {
125
- if (e.type === "update" && e.oldNote && e.note && !e.oldNote.show && e.note.show) {
126
- const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
127
- if (!r)
128
- return;
129
- const { workbook: i, worksheet: n } = r;
130
- this.fireEvent(this.Event.SheetNoteShow, {
131
- workbook: i,
132
- worksheet: n,
133
- row: o,
134
- col: s
135
- });
136
- }
137
- })
138
- ), this.registerEventHandler(
139
- this.Event.SheetNoteHide,
140
- () => d.get(S).change$.subscribe((e) => {
141
- if (e.type === "update" && e.oldNote && e.note && e.oldNote.show && !e.note.show) {
142
- const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
143
- if (!r)
144
- return;
145
- const { workbook: i, worksheet: n } = r;
146
- this.fireEvent(this.Event.SheetNoteHide, {
147
- workbook: i,
148
- worksheet: n,
149
- row: o,
150
- col: s
151
- });
152
- }
153
- })
154
- ), this.registerEventHandler(
155
- this.Event.BeforeSheetNoteAdd,
156
- () => d.get(u).beforeCommandExecuted((e) => {
157
- if (e.id === f.id) {
158
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params;
159
- if (h.getNote(t, o, s, r)) return;
160
- const c = this.getSheetTarget(t, o);
161
- if (!c)
162
- return;
163
- const { workbook: l, worksheet: g } = c;
164
- if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
165
- workbook: l,
166
- worksheet: g,
167
- row: s,
168
- col: r,
169
- note: i
170
- }))
171
- throw new N();
172
- }
173
- })
174
- ), this.registerEventHandler(
175
- this.Event.BeforeSheetNoteDelete,
176
- () => d.get(u).beforeCommandExecuted((e) => {
177
- if (e.id === H.id) {
178
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
179
- if (!i) return;
180
- const n = this.getSheetTarget(t, o);
181
- if (!n)
182
- return;
183
- const { workbook: c, worksheet: l } = n;
184
- if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
185
- workbook: c,
186
- worksheet: l,
187
- row: s,
188
- col: r,
189
- oldNote: i
190
- }))
191
- throw new N();
192
- }
193
- })
194
- ), this.registerEventHandler(
195
- this.Event.BeforeSheetNoteUpdate,
196
- () => d.get(u).beforeCommandExecuted((e) => {
197
- if (e.id === f.id) {
198
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params, n = h.getNote(t, o, s, r);
199
- if (!n) return;
200
- const c = this.getSheetTarget(t, o);
201
- if (!c)
202
- return;
203
- const { workbook: l, worksheet: g } = c;
204
- if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
205
- workbook: l,
206
- worksheet: g,
207
- row: s,
208
- col: r,
209
- note: i,
210
- oldNote: n
211
- }))
212
- throw new N();
213
- }
214
- })
215
- ), this.registerEventHandler(
216
- this.Event.BeforeSheetNoteShow,
217
- () => d.get(u).beforeCommandExecuted((e) => {
218
- if (e.id === w.id) {
219
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
220
- if (i != null && i.show) return;
221
- const n = this.getSheetTarget(t, o);
222
- if (!n)
223
- return;
224
- const { workbook: c, worksheet: l } = n;
225
- if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
226
- workbook: c,
227
- worksheet: l,
228
- row: s,
229
- col: r
230
- }))
231
- throw new N();
232
- }
233
- })
234
- ), this.registerEventHandler(
235
- this.Event.BeforeSheetNoteHide,
236
- () => d.get(u).beforeCommandExecuted((e) => {
237
- if (e.id === w.id) {
238
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
239
- if (!(i != null && i.show)) return;
240
- const n = this.getSheetTarget(t, o);
241
- if (!n)
242
- return;
243
- const { workbook: c, worksheet: l } = n;
244
- if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
245
- workbook: c,
246
- worksheet: l,
247
- row: s,
248
- col: r
249
- }))
250
- throw new N();
251
- }
252
- })
69
+ _initialize(c) {
70
+ const a = c.get(H);
71
+ this.disposeWithMe(
72
+ this.registerEventHandler(
73
+ this.Event.SheetNoteAdd,
74
+ () => c.get(g).change$.subscribe((e) => {
75
+ if (e.type === "update" && !e.oldNote && e.note) {
76
+ const { unitId: t, sheetId: o, row: r, col: i, note: s } = e, n = this.getSheetTarget(t, o);
77
+ if (!n)
78
+ return;
79
+ const { workbook: d, worksheet: l } = n;
80
+ this.fireEvent(this.Event.SheetNoteAdd, {
81
+ workbook: d,
82
+ worksheet: l,
83
+ row: r,
84
+ col: i,
85
+ note: s
86
+ });
87
+ }
88
+ })
89
+ )
90
+ ), this.disposeWithMe(
91
+ this.registerEventHandler(
92
+ this.Event.SheetNoteDelete,
93
+ () => c.get(g).change$.subscribe((e) => {
94
+ if (e.type === "update" && e.oldNote && !e.note) {
95
+ const { unitId: t, sheetId: o, row: r, col: i, oldNote: s } = e, n = this.getSheetTarget(t, o);
96
+ if (!n)
97
+ return;
98
+ const { workbook: d, worksheet: l } = n;
99
+ this.fireEvent(this.Event.SheetNoteDelete, {
100
+ workbook: d,
101
+ worksheet: l,
102
+ row: r,
103
+ col: i,
104
+ oldNote: s
105
+ });
106
+ }
107
+ })
108
+ )
109
+ ), this.disposeWithMe(
110
+ this.registerEventHandler(
111
+ this.Event.SheetNoteUpdate,
112
+ () => c.get(g).change$.subscribe((e) => {
113
+ if (e.type === "update" && e.oldNote && e.note) {
114
+ const { unitId: t, sheetId: o, row: r, col: i, note: s, oldNote: n } = e, d = this.getSheetTarget(t, o);
115
+ if (!d)
116
+ return;
117
+ const { workbook: l, worksheet: S } = d;
118
+ this.fireEvent(this.Event.SheetNoteUpdate, {
119
+ workbook: l,
120
+ worksheet: S,
121
+ row: r,
122
+ col: i,
123
+ note: s,
124
+ oldNote: n
125
+ });
126
+ }
127
+ })
128
+ )
129
+ ), this.disposeWithMe(
130
+ this.registerEventHandler(
131
+ this.Event.SheetNoteShow,
132
+ () => c.get(g).change$.subscribe((e) => {
133
+ if (e.type === "update" && e.oldNote && e.note && !e.oldNote.show && e.note.show) {
134
+ const { unitId: t, sheetId: o, row: r, col: i } = e, s = this.getSheetTarget(t, o);
135
+ if (!s)
136
+ return;
137
+ const { workbook: n, worksheet: d } = s;
138
+ this.fireEvent(this.Event.SheetNoteShow, {
139
+ workbook: n,
140
+ worksheet: d,
141
+ row: r,
142
+ col: i
143
+ });
144
+ }
145
+ })
146
+ )
147
+ ), this.disposeWithMe(
148
+ this.registerEventHandler(
149
+ this.Event.SheetNoteHide,
150
+ () => c.get(g).change$.subscribe((e) => {
151
+ if (e.type === "update" && e.oldNote && e.note && e.oldNote.show && !e.note.show) {
152
+ const { unitId: t, sheetId: o, row: r, col: i } = e, s = this.getSheetTarget(t, o);
153
+ if (!s)
154
+ return;
155
+ const { workbook: n, worksheet: d } = s;
156
+ this.fireEvent(this.Event.SheetNoteHide, {
157
+ workbook: n,
158
+ worksheet: d,
159
+ row: r,
160
+ col: i
161
+ });
162
+ }
163
+ })
164
+ )
165
+ ), this.disposeWithMe(
166
+ this.registerEventHandler(
167
+ this.Event.BeforeSheetNoteAdd,
168
+ () => a.beforeCommandExecuted((h) => {
169
+ if (h.id === f.id) {
170
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i, note: s } = h.params;
171
+ if (e.getNote(t, o, r, i)) return;
172
+ const d = this.getSheetTarget(t, o);
173
+ if (!d)
174
+ return;
175
+ const { workbook: l, worksheet: S } = d;
176
+ if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
177
+ workbook: l,
178
+ worksheet: S,
179
+ row: r,
180
+ col: i,
181
+ note: s
182
+ }))
183
+ throw new N();
184
+ }
185
+ })
186
+ )
187
+ ), this.disposeWithMe(
188
+ this.registerEventHandler(
189
+ this.Event.BeforeSheetNoteDelete,
190
+ () => a.beforeCommandExecuted((h) => {
191
+ if (h.id === B.id) {
192
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i } = h.params, s = e.getNote(t, o, r, i);
193
+ if (!s) return;
194
+ const n = this.getSheetTarget(t, o);
195
+ if (!n)
196
+ return;
197
+ const { workbook: d, worksheet: l } = n;
198
+ if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
199
+ workbook: d,
200
+ worksheet: l,
201
+ row: r,
202
+ col: i,
203
+ oldNote: s
204
+ }))
205
+ throw new N();
206
+ }
207
+ })
208
+ )
209
+ ), this.disposeWithMe(
210
+ this.registerEventHandler(
211
+ this.Event.BeforeSheetNoteUpdate,
212
+ () => a.beforeCommandExecuted((h) => {
213
+ if (h.id === f.id) {
214
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i, note: s } = h.params, n = e.getNote(t, o, r, i);
215
+ if (!n) return;
216
+ const d = this.getSheetTarget(t, o);
217
+ if (!d)
218
+ return;
219
+ const { workbook: l, worksheet: S } = d;
220
+ if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
221
+ workbook: l,
222
+ worksheet: S,
223
+ row: r,
224
+ col: i,
225
+ note: s,
226
+ oldNote: n
227
+ }))
228
+ throw new N();
229
+ }
230
+ })
231
+ )
232
+ ), this.disposeWithMe(
233
+ this.registerEventHandler(
234
+ this.Event.BeforeSheetNoteShow,
235
+ () => a.beforeCommandExecuted((h) => {
236
+ if (h.id === w.id) {
237
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i } = h.params, s = e.getNote(t, o, r, i);
238
+ if (s != null && s.show) return;
239
+ const n = this.getSheetTarget(t, o);
240
+ if (!n)
241
+ return;
242
+ const { workbook: d, worksheet: l } = n;
243
+ if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
244
+ workbook: d,
245
+ worksheet: l,
246
+ row: r,
247
+ col: i
248
+ }))
249
+ throw new N();
250
+ }
251
+ })
252
+ )
253
+ ), this.disposeWithMe(
254
+ this.registerEventHandler(
255
+ this.Event.BeforeSheetNoteHide,
256
+ () => a.beforeCommandExecuted((h) => {
257
+ if (h.id === w.id) {
258
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i } = h.params, s = e.getNote(t, o, r, i);
259
+ if (!(s != null && s.show)) return;
260
+ const n = this.getSheetTarget(t, o);
261
+ if (!n)
262
+ return;
263
+ const { workbook: d, worksheet: l } = n;
264
+ if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
265
+ workbook: d,
266
+ worksheet: l,
267
+ row: r,
268
+ col: i
269
+ }))
270
+ throw new N();
271
+ }
272
+ })
273
+ )
253
274
  );
254
275
  }
255
276
  }
256
- v.extend(C);
257
- class T extends k {
277
+ m.extend(C);
278
+ class M extends v {
258
279
  getNotes() {
259
- const a = this._injector.get(S).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId()), e = [];
260
- return a == null || a.forValue((h, t, o) => {
261
- e.push({
280
+ const a = this._injector.get(g).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId()), h = [];
281
+ return a == null || a.forValue((e, t, o) => {
282
+ h.push({
262
283
  ...o,
263
- row: h,
284
+ row: e,
264
285
  col: t
265
286
  });
266
- }), e;
287
+ }), h;
267
288
  }
268
289
  }
269
- k.extend(T);
290
+ v.extend(M);
270
291
  export {
271
292
  x as FSheetNoteEvent,
272
293
  U as FSheetsNoteRangeMixin,
273
- T as FSheetsNoteWorksheet,
294
+ M as FSheetsNoteWorksheet,
274
295
  C as FUniverSheetNoteMixin
275
296
  };
package/lib/facade.js CHANGED
@@ -1,7 +1,7 @@
1
- import { FEventName as I, FUniver as v } from "@univerjs/core/facade";
2
- import { UpdateNoteMutation as b, RemoveNoteMutation as B, SheetsNoteModel as S, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as H, SheetToggleNotePopupCommand as w } from "@univerjs/sheets-note";
3
- import { FRange as E, FWorksheet as k } from "@univerjs/sheets/facade";
4
- import { ICommandService as u, CanceledError as N } from "@univerjs/core";
1
+ import { FEventName as k, FUniver as m } from "@univerjs/core/facade";
2
+ import { UpdateNoteMutation as I, RemoveNoteMutation as b, SheetsNoteModel as g, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as B, SheetToggleNotePopupCommand as w } from "@univerjs/sheets-note";
3
+ import { FRange as E, FWorksheet as v } from "@univerjs/sheets/facade";
4
+ import { ICommandService as H, CanceledError as N } from "@univerjs/core";
5
5
  class x {
6
6
  get SheetNoteAdd() {
7
7
  return "SheetNoteAdd";
@@ -34,23 +34,23 @@ class x {
34
34
  return "BeforeSheetNoteHide";
35
35
  }
36
36
  }
37
- I.extend(x);
37
+ k.extend(x);
38
38
  class U extends E {
39
- createOrUpdateNote(d) {
39
+ createOrUpdateNote(c) {
40
40
  return this._commandService.syncExecuteCommand(
41
- b.id,
41
+ I.id,
42
42
  {
43
43
  unitId: this.getUnitId(),
44
44
  sheetId: this.getSheetId(),
45
45
  row: this.getRow(),
46
46
  col: this.getColumn(),
47
- note: d
47
+ note: c
48
48
  }
49
49
  ), this;
50
50
  }
51
51
  deleteNote() {
52
52
  return this._commandService.syncExecuteCommand(
53
- B.id,
53
+ b.id,
54
54
  {
55
55
  unitId: this.getUnitId(),
56
56
  sheetId: this.getSheetId(),
@@ -60,216 +60,237 @@ class U extends E {
60
60
  ), this;
61
61
  }
62
62
  getNote() {
63
- return this._injector.get(S).getNote(this.getUnitId(), this.getSheetId(), this.getRow(), this.getColumn());
63
+ return this._injector.get(g).getNote(this.getUnitId(), this.getSheetId(), this.getRow(), this.getColumn());
64
64
  }
65
65
  }
66
66
  E.extend(U);
67
- class C extends v {
67
+ class C extends m {
68
68
  // eslint-disable-next-line max-lines-per-function
69
- _initialize(d) {
70
- this.registerEventHandler(
71
- this.Event.SheetNoteAdd,
72
- () => d.get(S).change$.subscribe((e) => {
73
- if (e.type === "update" && !e.oldNote && e.note) {
74
- const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
75
- if (!n)
76
- return;
77
- const { workbook: c, worksheet: l } = n;
78
- this.fireEvent(this.Event.SheetNoteAdd, {
79
- workbook: c,
80
- worksheet: l,
81
- row: o,
82
- col: s,
83
- note: r
84
- });
85
- }
86
- })
87
- ), this.registerEventHandler(
88
- this.Event.SheetNoteDelete,
89
- () => d.get(S).change$.subscribe((e) => {
90
- if (e.type === "update" && e.oldNote && !e.note) {
91
- const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
92
- if (!n)
93
- return;
94
- const { workbook: c, worksheet: l } = n;
95
- this.fireEvent(this.Event.SheetNoteDelete, {
96
- workbook: c,
97
- worksheet: l,
98
- row: o,
99
- col: s,
100
- oldNote: i
101
- });
102
- }
103
- })
104
- ), this.registerEventHandler(
105
- this.Event.SheetNoteUpdate,
106
- () => d.get(S).change$.subscribe((e) => {
107
- if (e.type === "update" && e.oldNote && e.note) {
108
- const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
109
- if (!n)
110
- return;
111
- const { workbook: c, worksheet: l } = n;
112
- this.fireEvent(this.Event.SheetNoteUpdate, {
113
- workbook: c,
114
- worksheet: l,
115
- row: o,
116
- col: s,
117
- note: r,
118
- oldNote: i
119
- });
120
- }
121
- })
122
- ), this.registerEventHandler(
123
- this.Event.SheetNoteShow,
124
- () => d.get(S).change$.subscribe((e) => {
125
- if (e.type === "update" && e.oldNote && e.note && !e.oldNote.show && e.note.show) {
126
- const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
127
- if (!r)
128
- return;
129
- const { workbook: i, worksheet: n } = r;
130
- this.fireEvent(this.Event.SheetNoteShow, {
131
- workbook: i,
132
- worksheet: n,
133
- row: o,
134
- col: s
135
- });
136
- }
137
- })
138
- ), this.registerEventHandler(
139
- this.Event.SheetNoteHide,
140
- () => d.get(S).change$.subscribe((e) => {
141
- if (e.type === "update" && e.oldNote && e.note && e.oldNote.show && !e.note.show) {
142
- const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
143
- if (!r)
144
- return;
145
- const { workbook: i, worksheet: n } = r;
146
- this.fireEvent(this.Event.SheetNoteHide, {
147
- workbook: i,
148
- worksheet: n,
149
- row: o,
150
- col: s
151
- });
152
- }
153
- })
154
- ), this.registerEventHandler(
155
- this.Event.BeforeSheetNoteAdd,
156
- () => d.get(u).beforeCommandExecuted((e) => {
157
- if (e.id === f.id) {
158
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params;
159
- if (h.getNote(t, o, s, r)) return;
160
- const c = this.getSheetTarget(t, o);
161
- if (!c)
162
- return;
163
- const { workbook: l, worksheet: g } = c;
164
- if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
165
- workbook: l,
166
- worksheet: g,
167
- row: s,
168
- col: r,
169
- note: i
170
- }))
171
- throw new N();
172
- }
173
- })
174
- ), this.registerEventHandler(
175
- this.Event.BeforeSheetNoteDelete,
176
- () => d.get(u).beforeCommandExecuted((e) => {
177
- if (e.id === H.id) {
178
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
179
- if (!i) return;
180
- const n = this.getSheetTarget(t, o);
181
- if (!n)
182
- return;
183
- const { workbook: c, worksheet: l } = n;
184
- if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
185
- workbook: c,
186
- worksheet: l,
187
- row: s,
188
- col: r,
189
- oldNote: i
190
- }))
191
- throw new N();
192
- }
193
- })
194
- ), this.registerEventHandler(
195
- this.Event.BeforeSheetNoteUpdate,
196
- () => d.get(u).beforeCommandExecuted((e) => {
197
- if (e.id === f.id) {
198
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params, n = h.getNote(t, o, s, r);
199
- if (!n) return;
200
- const c = this.getSheetTarget(t, o);
201
- if (!c)
202
- return;
203
- const { workbook: l, worksheet: g } = c;
204
- if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
205
- workbook: l,
206
- worksheet: g,
207
- row: s,
208
- col: r,
209
- note: i,
210
- oldNote: n
211
- }))
212
- throw new N();
213
- }
214
- })
215
- ), this.registerEventHandler(
216
- this.Event.BeforeSheetNoteShow,
217
- () => d.get(u).beforeCommandExecuted((e) => {
218
- if (e.id === w.id) {
219
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
220
- if (i != null && i.show) return;
221
- const n = this.getSheetTarget(t, o);
222
- if (!n)
223
- return;
224
- const { workbook: c, worksheet: l } = n;
225
- if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
226
- workbook: c,
227
- worksheet: l,
228
- row: s,
229
- col: r
230
- }))
231
- throw new N();
232
- }
233
- })
234
- ), this.registerEventHandler(
235
- this.Event.BeforeSheetNoteHide,
236
- () => d.get(u).beforeCommandExecuted((e) => {
237
- if (e.id === w.id) {
238
- const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
239
- if (!(i != null && i.show)) return;
240
- const n = this.getSheetTarget(t, o);
241
- if (!n)
242
- return;
243
- const { workbook: c, worksheet: l } = n;
244
- if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
245
- workbook: c,
246
- worksheet: l,
247
- row: s,
248
- col: r
249
- }))
250
- throw new N();
251
- }
252
- })
69
+ _initialize(c) {
70
+ const a = c.get(H);
71
+ this.disposeWithMe(
72
+ this.registerEventHandler(
73
+ this.Event.SheetNoteAdd,
74
+ () => c.get(g).change$.subscribe((e) => {
75
+ if (e.type === "update" && !e.oldNote && e.note) {
76
+ const { unitId: t, sheetId: o, row: r, col: i, note: s } = e, n = this.getSheetTarget(t, o);
77
+ if (!n)
78
+ return;
79
+ const { workbook: d, worksheet: l } = n;
80
+ this.fireEvent(this.Event.SheetNoteAdd, {
81
+ workbook: d,
82
+ worksheet: l,
83
+ row: r,
84
+ col: i,
85
+ note: s
86
+ });
87
+ }
88
+ })
89
+ )
90
+ ), this.disposeWithMe(
91
+ this.registerEventHandler(
92
+ this.Event.SheetNoteDelete,
93
+ () => c.get(g).change$.subscribe((e) => {
94
+ if (e.type === "update" && e.oldNote && !e.note) {
95
+ const { unitId: t, sheetId: o, row: r, col: i, oldNote: s } = e, n = this.getSheetTarget(t, o);
96
+ if (!n)
97
+ return;
98
+ const { workbook: d, worksheet: l } = n;
99
+ this.fireEvent(this.Event.SheetNoteDelete, {
100
+ workbook: d,
101
+ worksheet: l,
102
+ row: r,
103
+ col: i,
104
+ oldNote: s
105
+ });
106
+ }
107
+ })
108
+ )
109
+ ), this.disposeWithMe(
110
+ this.registerEventHandler(
111
+ this.Event.SheetNoteUpdate,
112
+ () => c.get(g).change$.subscribe((e) => {
113
+ if (e.type === "update" && e.oldNote && e.note) {
114
+ const { unitId: t, sheetId: o, row: r, col: i, note: s, oldNote: n } = e, d = this.getSheetTarget(t, o);
115
+ if (!d)
116
+ return;
117
+ const { workbook: l, worksheet: S } = d;
118
+ this.fireEvent(this.Event.SheetNoteUpdate, {
119
+ workbook: l,
120
+ worksheet: S,
121
+ row: r,
122
+ col: i,
123
+ note: s,
124
+ oldNote: n
125
+ });
126
+ }
127
+ })
128
+ )
129
+ ), this.disposeWithMe(
130
+ this.registerEventHandler(
131
+ this.Event.SheetNoteShow,
132
+ () => c.get(g).change$.subscribe((e) => {
133
+ if (e.type === "update" && e.oldNote && e.note && !e.oldNote.show && e.note.show) {
134
+ const { unitId: t, sheetId: o, row: r, col: i } = e, s = this.getSheetTarget(t, o);
135
+ if (!s)
136
+ return;
137
+ const { workbook: n, worksheet: d } = s;
138
+ this.fireEvent(this.Event.SheetNoteShow, {
139
+ workbook: n,
140
+ worksheet: d,
141
+ row: r,
142
+ col: i
143
+ });
144
+ }
145
+ })
146
+ )
147
+ ), this.disposeWithMe(
148
+ this.registerEventHandler(
149
+ this.Event.SheetNoteHide,
150
+ () => c.get(g).change$.subscribe((e) => {
151
+ if (e.type === "update" && e.oldNote && e.note && e.oldNote.show && !e.note.show) {
152
+ const { unitId: t, sheetId: o, row: r, col: i } = e, s = this.getSheetTarget(t, o);
153
+ if (!s)
154
+ return;
155
+ const { workbook: n, worksheet: d } = s;
156
+ this.fireEvent(this.Event.SheetNoteHide, {
157
+ workbook: n,
158
+ worksheet: d,
159
+ row: r,
160
+ col: i
161
+ });
162
+ }
163
+ })
164
+ )
165
+ ), this.disposeWithMe(
166
+ this.registerEventHandler(
167
+ this.Event.BeforeSheetNoteAdd,
168
+ () => a.beforeCommandExecuted((h) => {
169
+ if (h.id === f.id) {
170
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i, note: s } = h.params;
171
+ if (e.getNote(t, o, r, i)) return;
172
+ const d = this.getSheetTarget(t, o);
173
+ if (!d)
174
+ return;
175
+ const { workbook: l, worksheet: S } = d;
176
+ if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
177
+ workbook: l,
178
+ worksheet: S,
179
+ row: r,
180
+ col: i,
181
+ note: s
182
+ }))
183
+ throw new N();
184
+ }
185
+ })
186
+ )
187
+ ), this.disposeWithMe(
188
+ this.registerEventHandler(
189
+ this.Event.BeforeSheetNoteDelete,
190
+ () => a.beforeCommandExecuted((h) => {
191
+ if (h.id === B.id) {
192
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i } = h.params, s = e.getNote(t, o, r, i);
193
+ if (!s) return;
194
+ const n = this.getSheetTarget(t, o);
195
+ if (!n)
196
+ return;
197
+ const { workbook: d, worksheet: l } = n;
198
+ if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
199
+ workbook: d,
200
+ worksheet: l,
201
+ row: r,
202
+ col: i,
203
+ oldNote: s
204
+ }))
205
+ throw new N();
206
+ }
207
+ })
208
+ )
209
+ ), this.disposeWithMe(
210
+ this.registerEventHandler(
211
+ this.Event.BeforeSheetNoteUpdate,
212
+ () => a.beforeCommandExecuted((h) => {
213
+ if (h.id === f.id) {
214
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i, note: s } = h.params, n = e.getNote(t, o, r, i);
215
+ if (!n) return;
216
+ const d = this.getSheetTarget(t, o);
217
+ if (!d)
218
+ return;
219
+ const { workbook: l, worksheet: S } = d;
220
+ if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
221
+ workbook: l,
222
+ worksheet: S,
223
+ row: r,
224
+ col: i,
225
+ note: s,
226
+ oldNote: n
227
+ }))
228
+ throw new N();
229
+ }
230
+ })
231
+ )
232
+ ), this.disposeWithMe(
233
+ this.registerEventHandler(
234
+ this.Event.BeforeSheetNoteShow,
235
+ () => a.beforeCommandExecuted((h) => {
236
+ if (h.id === w.id) {
237
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i } = h.params, s = e.getNote(t, o, r, i);
238
+ if (s != null && s.show) return;
239
+ const n = this.getSheetTarget(t, o);
240
+ if (!n)
241
+ return;
242
+ const { workbook: d, worksheet: l } = n;
243
+ if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
244
+ workbook: d,
245
+ worksheet: l,
246
+ row: r,
247
+ col: i
248
+ }))
249
+ throw new N();
250
+ }
251
+ })
252
+ )
253
+ ), this.disposeWithMe(
254
+ this.registerEventHandler(
255
+ this.Event.BeforeSheetNoteHide,
256
+ () => a.beforeCommandExecuted((h) => {
257
+ if (h.id === w.id) {
258
+ const e = c.get(g), { unitId: t, sheetId: o, row: r, col: i } = h.params, s = e.getNote(t, o, r, i);
259
+ if (!(s != null && s.show)) return;
260
+ const n = this.getSheetTarget(t, o);
261
+ if (!n)
262
+ return;
263
+ const { workbook: d, worksheet: l } = n;
264
+ if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
265
+ workbook: d,
266
+ worksheet: l,
267
+ row: r,
268
+ col: i
269
+ }))
270
+ throw new N();
271
+ }
272
+ })
273
+ )
253
274
  );
254
275
  }
255
276
  }
256
- v.extend(C);
257
- class T extends k {
277
+ m.extend(C);
278
+ class M extends v {
258
279
  getNotes() {
259
- const a = this._injector.get(S).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId()), e = [];
260
- return a == null || a.forValue((h, t, o) => {
261
- e.push({
280
+ const a = this._injector.get(g).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId()), h = [];
281
+ return a == null || a.forValue((e, t, o) => {
282
+ h.push({
262
283
  ...o,
263
- row: h,
284
+ row: e,
264
285
  col: t
265
286
  });
266
- }), e;
287
+ }), h;
267
288
  }
268
289
  }
269
- k.extend(T);
290
+ v.extend(M);
270
291
  export {
271
292
  x as FSheetNoteEvent,
272
293
  U as FSheetsNoteRangeMixin,
273
- T as FSheetsNoteWorksheet,
294
+ M as FSheetsNoteWorksheet,
274
295
  C as FUniverSheetNoteMixin
275
296
  };
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.UniverSheetsNoteFacade={},l.UniverCoreFacade,l.UniverSheetsNote,l.UniverSheetsFacade,l.UniverCore))})(this,(function(l,m,h,f,g){"use strict";class w{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"}}m.FEventName.extend(w);class E extends f.FRange{createOrUpdateNote(c){return this._commandService.syncExecuteCommand(h.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:c}),this}deleteNote(){return this._commandService.syncExecuteCommand(h.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(h.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}f.FRange.extend(E);class I extends m.FUniver{_initialize(c){this.registerEventHandler(this.Event.SheetNoteAdd,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:S,worksheet:a,row:o,col:i,note:r})}})),this.registerEventHandler(this.Event.SheetNoteDelete,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:S,worksheet:a,row:o,col:i,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteUpdate,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:a,row:o,col:i,note:r,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteShow,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.SheetNoteHide,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params;if(d.getNote(t,o,i,r))return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:a,worksheet:v,row:i,col:r,note:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetDeleteNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!s)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:S,worksheet:a,row:i,col:r,oldNote:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params,n=d.getNote(t,o,i,r);if(!n)return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:a,worksheet:v,row:i,col:r,note:s,oldNote:n}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(s!=null&&s.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!(s!=null&&s.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}}))}}m.FUniver.extend(I);class k extends f.FWorksheet{getNotes(){const u=this._injector.get(h.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),e=[];return u==null||u.forValue((d,t,o)=>{e.push({...o,row:d,col:t})}),e}}f.FWorksheet.extend(k),l.FSheetNoteEvent=w,l.FSheetsNoteRangeMixin=E,l.FSheetsNoteWorksheet=k,l.FUniverSheetNoteMixin=I,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(u,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],f):(u=typeof globalThis<"u"?globalThis:u||self,f(u.UniverSheetsNoteFacade={},u.UniverCoreFacade,u.UniverSheetsNote,u.UniverSheetsFacade,u.UniverCore))})(this,(function(u,f,l,v,N){"use strict";class E{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"}}f.FEventName.extend(E);class m extends v.FRange{createOrUpdateNote(S){return this._commandService.syncExecuteCommand(l.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:S}),this}deleteNote(){return this._commandService.syncExecuteCommand(l.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(l.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}v.FRange.extend(m);class p extends f.FUniver{_initialize(S){const a=S.get(N.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:t,sheetId:o,row:i,col:n,note:r}=e,s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;this.fireEvent(this.Event.SheetNoteAdd,{workbook:d,worksheet:c,row:i,col:n,note:r})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:t,sheetId:o,row:i,col:n,oldNote:r}=e,s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;this.fireEvent(this.Event.SheetNoteDelete,{workbook:d,worksheet:c,row:i,col:n,oldNote:r})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:t,sheetId:o,row:i,col:n,note:r,oldNote:s}=e,d=this.getSheetTarget(t,o);if(!d)return;const{workbook:c,worksheet:g}=d;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:c,worksheet:g,row:i,col:n,note:r,oldNote:s})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:t,sheetId:o,row:i,col:n}=e,r=this.getSheetTarget(t,o);if(!r)return;const{workbook:s,worksheet:d}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:d,row:i,col:n})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:t,sheetId:o,row:i,col:n}=e,r=this.getSheetTarget(t,o);if(!r)return;const{workbook:s,worksheet:d}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:d,row:i,col:n})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetUpdateNoteCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n,note:r}=h.params;if(e.getNote(t,o,i,n))return;const d=this.getSheetTarget(t,o);if(!d)return;const{workbook:c,worksheet:g}=d;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:c,worksheet:g,row:i,col:n,note:r}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetDeleteNoteCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n}=h.params,r=e.getNote(t,o,i,n);if(!r)return;const s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:d,worksheet:c,row:i,col:n,oldNote:r}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetUpdateNoteCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n,note:r}=h.params,s=e.getNote(t,o,i,n);if(!s)return;const d=this.getSheetTarget(t,o);if(!d)return;const{workbook:c,worksheet:g}=d;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:c,worksheet:g,row:i,col:n,note:r,oldNote:s}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetToggleNotePopupCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n}=h.params,r=e.getNote(t,o,i,n);if(r!=null&&r.show)return;const s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:d,worksheet:c,row:i,col:n}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetToggleNotePopupCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n}=h.params,r=e.getNote(t,o,i,n);if(!(r!=null&&r.show))return;const s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:d,worksheet:c,row:i,col:n}))throw new N.CanceledError}})))}}f.FUniver.extend(p);class k extends v.FWorksheet{getNotes(){const a=this._injector.get(l.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),h=[];return a==null||a.forValue((e,t,o)=>{h.push({...o,row:e,col:t})}),h}}v.FWorksheet.extend(k),u.FSheetNoteEvent=E,u.FSheetsNoteRangeMixin=m,u.FSheetsNoteWorksheet=k,u.FUniverSheetNoteMixin=p,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-note",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "private": false,
5
5
  "description": "Univer sheets note base plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,15 +56,15 @@
56
56
  "rxjs": ">=7.0.0"
57
57
  },
58
58
  "dependencies": {
59
- "@univerjs/sheets": "0.15.3",
60
- "@univerjs/core": "0.15.3"
59
+ "@univerjs/core": "0.15.4",
60
+ "@univerjs/sheets": "0.15.4"
61
61
  },
62
62
  "devDependencies": {
63
63
  "rxjs": "^7.8.2",
64
64
  "typescript": "^5.9.3",
65
65
  "vite": "^7.3.1",
66
- "vitest": "^4.0.16",
67
- "@univerjs-infra/shared": "0.15.3"
66
+ "vitest": "^4.0.18",
67
+ "@univerjs-infra/shared": "0.15.4"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",