@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 +1 -1
- package/lib/es/facade.js +225 -204
- package/lib/facade.js +225 -204
- package/lib/umd/facade.js +1 -1
- package/package.json +5 -5
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { UpdateNoteMutation as
|
|
3
|
-
import { FRange as E, FWorksheet as
|
|
4
|
-
import { ICommandService as
|
|
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
|
-
|
|
37
|
+
k.extend(x);
|
|
38
38
|
class U extends E {
|
|
39
|
-
createOrUpdateNote(
|
|
39
|
+
createOrUpdateNote(c) {
|
|
40
40
|
return this._commandService.syncExecuteCommand(
|
|
41
|
-
|
|
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:
|
|
47
|
+
note: c
|
|
48
48
|
}
|
|
49
49
|
), this;
|
|
50
50
|
}
|
|
51
51
|
deleteNote() {
|
|
52
52
|
return this._commandService.syncExecuteCommand(
|
|
53
|
-
|
|
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(
|
|
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
|
|
67
|
+
class C extends m {
|
|
68
68
|
// eslint-disable-next-line max-lines-per-function
|
|
69
|
-
_initialize(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
workbook:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
col: s
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
257
|
-
class
|
|
277
|
+
m.extend(C);
|
|
278
|
+
class M extends v {
|
|
258
279
|
getNotes() {
|
|
259
|
-
const a = this._injector.get(
|
|
260
|
-
return a == null || a.forValue((
|
|
261
|
-
|
|
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:
|
|
284
|
+
row: e,
|
|
264
285
|
col: t
|
|
265
286
|
});
|
|
266
|
-
}),
|
|
287
|
+
}), h;
|
|
267
288
|
}
|
|
268
289
|
}
|
|
269
|
-
|
|
290
|
+
v.extend(M);
|
|
270
291
|
export {
|
|
271
292
|
x as FSheetNoteEvent,
|
|
272
293
|
U as FSheetsNoteRangeMixin,
|
|
273
|
-
|
|
294
|
+
M as FSheetsNoteWorksheet,
|
|
274
295
|
C as FUniverSheetNoteMixin
|
|
275
296
|
};
|
package/lib/facade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FEventName as
|
|
2
|
-
import { UpdateNoteMutation as
|
|
3
|
-
import { FRange as E, FWorksheet as
|
|
4
|
-
import { ICommandService as
|
|
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
|
-
|
|
37
|
+
k.extend(x);
|
|
38
38
|
class U extends E {
|
|
39
|
-
createOrUpdateNote(
|
|
39
|
+
createOrUpdateNote(c) {
|
|
40
40
|
return this._commandService.syncExecuteCommand(
|
|
41
|
-
|
|
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:
|
|
47
|
+
note: c
|
|
48
48
|
}
|
|
49
49
|
), this;
|
|
50
50
|
}
|
|
51
51
|
deleteNote() {
|
|
52
52
|
return this._commandService.syncExecuteCommand(
|
|
53
|
-
|
|
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(
|
|
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
|
|
67
|
+
class C extends m {
|
|
68
68
|
// eslint-disable-next-line max-lines-per-function
|
|
69
|
-
_initialize(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
workbook:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
col: s
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
257
|
-
class
|
|
277
|
+
m.extend(C);
|
|
278
|
+
class M extends v {
|
|
258
279
|
getNotes() {
|
|
259
|
-
const a = this._injector.get(
|
|
260
|
-
return a == null || a.forValue((
|
|
261
|
-
|
|
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:
|
|
284
|
+
row: e,
|
|
264
285
|
col: t
|
|
265
286
|
});
|
|
266
|
-
}),
|
|
287
|
+
}), h;
|
|
267
288
|
}
|
|
268
289
|
}
|
|
269
|
-
|
|
290
|
+
v.extend(M);
|
|
270
291
|
export {
|
|
271
292
|
x as FSheetNoteEvent,
|
|
272
293
|
U as FSheetsNoteRangeMixin,
|
|
273
|
-
|
|
294
|
+
M as FSheetsNoteWorksheet,
|
|
274
295
|
C as FUniverSheetNoteMixin
|
|
275
296
|
};
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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
|
+
"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/
|
|
60
|
-
"@univerjs/
|
|
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.
|
|
67
|
-
"@univerjs-infra/shared": "0.15.
|
|
66
|
+
"vitest": "^4.0.18",
|
|
67
|
+
"@univerjs-infra/shared": "0.15.4"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"test": "vitest run",
|