@univerjs/sheets-note 0.7.0 → 0.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/es/facade.js +2 -2
- package/lib/facade.js +2 -2
- package/lib/types/facade/f-event.d.ts +70 -35
- package/lib/types/facade/f-range.d.ts +30 -18
- package/lib/types/facade/f-worksheet.d.ts +14 -1
- 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 f=require("@univerjs/core/facade"),
|
|
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.FSheetsNoteRange=w;exports.FSheetsNoteWorksheet=I;exports.FUniverSheetNoteMixin=E;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FEventName as I, FUniver as v } from "@univerjs/core/facade";
|
|
2
|
-
import { UpdateNoteMutation as b,
|
|
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
3
|
import { FRange as E, FWorksheet as k } from "@univerjs/sheets/facade";
|
|
4
4
|
import { ICommandService as u, CanceledError as N } from "@univerjs/core";
|
|
5
5
|
class U {
|
|
@@ -49,7 +49,7 @@ class x extends E {
|
|
|
49
49
|
), this;
|
|
50
50
|
}
|
|
51
51
|
deleteNote() {
|
|
52
|
-
return this.
|
|
52
|
+
return this._commandService.syncExecuteCommand(
|
|
53
53
|
B.id,
|
|
54
54
|
{
|
|
55
55
|
unitId: this.getUnitId(),
|
package/lib/facade.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FEventName as I, FUniver as v } from "@univerjs/core/facade";
|
|
2
|
-
import { UpdateNoteMutation as b,
|
|
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
3
|
import { FRange as E, FWorksheet as k } from "@univerjs/sheets/facade";
|
|
4
4
|
import { ICommandService as u, CanceledError as N } from "@univerjs/core";
|
|
5
5
|
class U {
|
|
@@ -49,7 +49,7 @@ class x extends E {
|
|
|
49
49
|
), this;
|
|
50
50
|
}
|
|
51
51
|
deleteNote() {
|
|
52
|
-
return this.
|
|
52
|
+
return this._commandService.syncExecuteCommand(
|
|
53
53
|
B.id,
|
|
54
54
|
{
|
|
55
55
|
unitId: this.getUnitId(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISheetNote } from '@univerjs/sheets-note';
|
|
2
2
|
import { FWorkbook, FWorksheet } from '@univerjs/sheets/facade';
|
|
3
|
-
export interface
|
|
3
|
+
export interface ISheetNoteAddEventParams {
|
|
4
4
|
workbook: FWorkbook;
|
|
5
5
|
worksheet: FWorksheet;
|
|
6
6
|
row: number;
|
|
@@ -8,7 +8,7 @@ export interface ISheetNoteAddEventParmas {
|
|
|
8
8
|
note: ISheetNote;
|
|
9
9
|
cancel?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface ISheetNoteDeleteEventParams {
|
|
12
12
|
workbook: FWorkbook;
|
|
13
13
|
worksheet: FWorksheet;
|
|
14
14
|
row: number;
|
|
@@ -16,7 +16,7 @@ export interface ISheetNoteDeleteEventParmas {
|
|
|
16
16
|
oldNote: ISheetNote;
|
|
17
17
|
cancel?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
19
|
+
export interface ISheetNoteUpdateEventParams {
|
|
20
20
|
workbook: FWorkbook;
|
|
21
21
|
worksheet: FWorksheet;
|
|
22
22
|
row: number;
|
|
@@ -25,14 +25,14 @@ export interface ISheetNoteUpdateEventParmas {
|
|
|
25
25
|
oldNote: ISheetNote;
|
|
26
26
|
cancel?: boolean;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
28
|
+
export interface ISheetNoteShowEventParams {
|
|
29
29
|
workbook: FWorkbook;
|
|
30
30
|
worksheet: FWorksheet;
|
|
31
31
|
row: number;
|
|
32
32
|
col: number;
|
|
33
33
|
cancel?: boolean;
|
|
34
34
|
}
|
|
35
|
-
export interface
|
|
35
|
+
export interface ISheetNoteHideEventParams {
|
|
36
36
|
workbook: FWorkbook;
|
|
37
37
|
worksheet: FWorksheet;
|
|
38
38
|
row: number;
|
|
@@ -43,16 +43,16 @@ export interface ISheetNoteHideEventParmas {
|
|
|
43
43
|
* @ignore
|
|
44
44
|
*/
|
|
45
45
|
export interface ISheetsNoteEventParamConfig {
|
|
46
|
-
SheetNoteAdd:
|
|
47
|
-
SheetNoteDelete:
|
|
48
|
-
SheetNoteUpdate:
|
|
49
|
-
SheetNoteShow:
|
|
50
|
-
SheetNoteHide:
|
|
51
|
-
BeforeSheetNoteAdd:
|
|
52
|
-
BeforeSheetNoteDelete:
|
|
53
|
-
BeforeSheetNoteUpdate:
|
|
54
|
-
BeforeSheetNoteShow:
|
|
55
|
-
BeforeSheetNoteHide:
|
|
46
|
+
SheetNoteAdd: ISheetNoteAddEventParams;
|
|
47
|
+
SheetNoteDelete: ISheetNoteDeleteEventParams;
|
|
48
|
+
SheetNoteUpdate: ISheetNoteUpdateEventParams;
|
|
49
|
+
SheetNoteShow: ISheetNoteShowEventParams;
|
|
50
|
+
SheetNoteHide: ISheetNoteHideEventParams;
|
|
51
|
+
BeforeSheetNoteAdd: ISheetNoteAddEventParams;
|
|
52
|
+
BeforeSheetNoteDelete: ISheetNoteDeleteEventParams;
|
|
53
|
+
BeforeSheetNoteUpdate: ISheetNoteUpdateEventParams;
|
|
54
|
+
BeforeSheetNoteShow: ISheetNoteShowEventParams;
|
|
55
|
+
BeforeSheetNoteHide: ISheetNoteHideEventParams;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* @ignore
|
|
@@ -60,121 +60,156 @@ export interface ISheetsNoteEventParamConfig {
|
|
|
60
60
|
interface ISheetNoteEvent {
|
|
61
61
|
/**
|
|
62
62
|
* Event fired when a note is added
|
|
63
|
-
* @see {@link
|
|
63
|
+
* @see {@link ISheetNoteAddEventParams}
|
|
64
64
|
* @example
|
|
65
65
|
* ```ts
|
|
66
66
|
* const disposable = univerAPI.addEvent(univerAPI.Event.SheetNoteAdd, (params) => {
|
|
67
67
|
* const { workbook, worksheet, row, col, note } = params;
|
|
68
68
|
* console.log(params);
|
|
69
69
|
* });
|
|
70
|
+
*
|
|
71
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
70
72
|
* ```
|
|
71
73
|
*/
|
|
72
74
|
SheetNoteAdd: 'SheetNoteAdd';
|
|
73
75
|
/**
|
|
74
76
|
* Event fired when a note is deleted
|
|
75
|
-
* @see {@link
|
|
77
|
+
* @see {@link ISheetNoteDeleteEventParams}
|
|
76
78
|
* @example
|
|
77
79
|
* ```ts
|
|
78
80
|
* const disposable = univerAPI.addEvent(univerAPI.Event.SheetNoteDelete, (params) => {
|
|
79
81
|
* const { workbook, worksheet, row, col, oldNote } = params;
|
|
80
82
|
* console.log(params);
|
|
81
83
|
* });
|
|
84
|
+
*
|
|
85
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
82
86
|
* ```
|
|
83
87
|
*/
|
|
84
88
|
SheetNoteDelete: 'SheetNoteDelete';
|
|
85
89
|
/**
|
|
86
90
|
* Event fired when a note is updated
|
|
87
|
-
* @see {@link
|
|
91
|
+
* @see {@link ISheetNoteUpdateEventParams}
|
|
88
92
|
* @example
|
|
89
93
|
* ```ts
|
|
90
94
|
* const disposable = univerAPI.addEvent(univerAPI.Event.SheetNoteUpdate, (params) => {
|
|
91
95
|
* const { workbook, worksheet, row, col, note, oldNote } = params;
|
|
92
96
|
* console.log(params);
|
|
93
97
|
* });
|
|
98
|
+
*
|
|
99
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
94
100
|
* ```
|
|
95
101
|
*/
|
|
96
102
|
SheetNoteUpdate: 'SheetNoteUpdate';
|
|
97
103
|
/**
|
|
98
104
|
* Event fired when a note is shown
|
|
99
|
-
* @see {@link
|
|
105
|
+
* @see {@link ISheetNoteShowEventParams}
|
|
100
106
|
* @example
|
|
101
107
|
* ```ts
|
|
102
108
|
* const disposable = univerAPI.addEvent(univerAPI.Event.SheetNoteShow, (params) => {
|
|
103
109
|
* const { workbook, worksheet, row, col } = params;
|
|
104
110
|
* console.log(params);
|
|
105
111
|
* });
|
|
112
|
+
*
|
|
113
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
106
114
|
* ```
|
|
107
115
|
*/
|
|
108
116
|
SheetNoteShow: 'SheetNoteShow';
|
|
109
117
|
/**
|
|
110
118
|
* Event fired when a note is hidden
|
|
111
|
-
* @see {@link
|
|
119
|
+
* @see {@link ISheetNoteHideEventParams}
|
|
112
120
|
* @example
|
|
113
121
|
* ```ts
|
|
114
122
|
* const disposable = univerAPI.addEvent(univerAPI.Event.SheetNoteHide, (params) => {
|
|
115
123
|
* const { workbook, worksheet, row, col } = params;
|
|
116
124
|
* console.log(params);
|
|
117
125
|
* });
|
|
126
|
+
*
|
|
127
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
118
128
|
* ```
|
|
119
129
|
*/
|
|
120
130
|
SheetNoteHide: 'SheetNoteHide';
|
|
121
131
|
/**
|
|
122
132
|
* Event fired before a note is added
|
|
123
|
-
* @see {@link
|
|
133
|
+
* @see {@link ISheetNoteAddEventParams}
|
|
124
134
|
* @example
|
|
125
135
|
* ```ts
|
|
126
136
|
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetNoteAdd, (params) => {
|
|
127
137
|
* const { workbook, worksheet, row, col, note } = params;
|
|
128
138
|
* console.log(params);
|
|
139
|
+
*
|
|
140
|
+
* // Cancel the note addition operation
|
|
141
|
+
* params.cancel = true;
|
|
129
142
|
* });
|
|
143
|
+
*
|
|
144
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
130
145
|
* ```
|
|
131
146
|
*/
|
|
132
147
|
BeforeSheetNoteAdd: 'BeforeSheetNoteAdd';
|
|
133
148
|
/**
|
|
134
149
|
* Event fired before a note is deleted
|
|
135
|
-
* @see {@link
|
|
150
|
+
* @see {@link ISheetNoteDeleteEventParams}
|
|
136
151
|
* @example
|
|
137
152
|
* ```ts
|
|
138
153
|
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetNoteDelete, (params) => {
|
|
139
154
|
* const { workbook, worksheet, row, col, oldNote } = params;
|
|
140
155
|
* console.log(params);
|
|
156
|
+
*
|
|
157
|
+
* // Cancel the note deletion operation
|
|
158
|
+
* params.cancel = true;
|
|
141
159
|
* });
|
|
160
|
+
*
|
|
161
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
142
162
|
* ```
|
|
143
163
|
*/
|
|
144
164
|
BeforeSheetNoteDelete: 'BeforeSheetNoteDelete';
|
|
145
165
|
/**
|
|
146
166
|
* Event fired before a note is updated
|
|
147
|
-
* @see {@link
|
|
167
|
+
* @see {@link ISheetNoteUpdateEventParams}
|
|
148
168
|
* @example
|
|
149
169
|
* ```ts
|
|
150
170
|
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetNoteUpdate, (params) => {
|
|
151
171
|
* const { workbook, worksheet, row, col, note, oldNote } = params;
|
|
152
172
|
* console.log(params);
|
|
173
|
+
*
|
|
174
|
+
* // Cancel the note update operation
|
|
175
|
+
* params.cancel = true;
|
|
153
176
|
* });
|
|
177
|
+
*
|
|
178
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
154
179
|
* ```
|
|
155
180
|
*/
|
|
156
181
|
BeforeSheetNoteUpdate: 'BeforeSheetNoteUpdate';
|
|
157
182
|
/**
|
|
158
183
|
* Event fired before a note is shown
|
|
159
|
-
* @see {@link
|
|
184
|
+
* @see {@link ISheetNoteShowEventParams}
|
|
160
185
|
* @example
|
|
161
186
|
* ```ts
|
|
162
187
|
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetNoteShow, (params) => {
|
|
163
188
|
* const { workbook, worksheet, row, col } = params;
|
|
164
189
|
* console.log(params);
|
|
190
|
+
*
|
|
191
|
+
* // Cancel the note show operation
|
|
192
|
+
* params.cancel = true;
|
|
165
193
|
* });
|
|
194
|
+
*
|
|
195
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
166
196
|
* ```
|
|
167
197
|
*/
|
|
168
198
|
BeforeSheetNoteShow: 'BeforeSheetNoteShow';
|
|
169
199
|
/**
|
|
170
200
|
* Event fired before a note is hidden
|
|
171
|
-
* @see {@link
|
|
201
|
+
* @see {@link ISheetNoteHideEventParams}
|
|
172
202
|
* @example
|
|
173
203
|
* ```ts
|
|
174
204
|
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeSheetNoteHide, (params) => {
|
|
175
205
|
* const { workbook, worksheet, row, col } = params;
|
|
176
206
|
* console.log(params);
|
|
207
|
+
*
|
|
208
|
+
* // Cancel the note hide operation
|
|
209
|
+
* params.cancel = true;
|
|
177
210
|
* });
|
|
211
|
+
*
|
|
212
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
178
213
|
* ```
|
|
179
214
|
*/
|
|
180
215
|
BeforeSheetNoteHide: 'BeforeSheetNoteHide';
|
|
@@ -198,16 +233,16 @@ export declare class FSheetNoteEvent implements ISheetNoteEvent {
|
|
|
198
233
|
* @ignore
|
|
199
234
|
*/
|
|
200
235
|
export interface ISheetNoteEventConfig {
|
|
201
|
-
SheetNoteAdd:
|
|
202
|
-
SheetNoteDelete:
|
|
203
|
-
SheetNoteUpdate:
|
|
204
|
-
SheetNoteShow:
|
|
205
|
-
SheetNoteHide:
|
|
206
|
-
BeforeSheetNoteAdd:
|
|
207
|
-
BeforeSheetNoteDelete:
|
|
208
|
-
BeforeSheetNoteUpdate:
|
|
209
|
-
BeforeSheetNoteShow:
|
|
210
|
-
BeforeSheetNoteHide:
|
|
236
|
+
SheetNoteAdd: ISheetNoteAddEventParams;
|
|
237
|
+
SheetNoteDelete: ISheetNoteDeleteEventParams;
|
|
238
|
+
SheetNoteUpdate: ISheetNoteUpdateEventParams;
|
|
239
|
+
SheetNoteShow: ISheetNoteShowEventParams;
|
|
240
|
+
SheetNoteHide: ISheetNoteHideEventParams;
|
|
241
|
+
BeforeSheetNoteAdd: ISheetNoteAddEventParams;
|
|
242
|
+
BeforeSheetNoteDelete: ISheetNoteDeleteEventParams;
|
|
243
|
+
BeforeSheetNoteUpdate: ISheetNoteUpdateEventParams;
|
|
244
|
+
BeforeSheetNoteShow: ISheetNoteShowEventParams;
|
|
245
|
+
BeforeSheetNoteHide: ISheetNoteHideEventParams;
|
|
211
246
|
}
|
|
212
247
|
declare module '@univerjs/core/facade' {
|
|
213
248
|
interface FEventName extends ISheetNoteEvent {
|
|
@@ -3,39 +3,51 @@ import { ISheetNote } from '@univerjs/sheets-note';
|
|
|
3
3
|
import { FRange } from '@univerjs/sheets/facade';
|
|
4
4
|
export interface IFSheetsNoteRange {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @returns {Nullable<ISheetNote>}
|
|
6
|
+
* Get the annotation of the top-left cell in the range
|
|
7
|
+
* @returns {Nullable<ISheetNote>} The annotation of the top-left cell in the range
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
|
-
* const fWorkbook = univerAPI.
|
|
11
|
-
* const fWorksheet = fWorkbook.
|
|
12
|
-
* const fRange = fWorksheet.getRange(
|
|
10
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
11
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
12
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
13
13
|
* const note = fRange.getNote();
|
|
14
|
+
* console.log(note);
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
16
17
|
getNote(): Nullable<ISheetNote>;
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {ISheetNote} note
|
|
20
|
-
* @returns {FRange}
|
|
19
|
+
* Create or update the annotation of the top-left cell in the range
|
|
20
|
+
* @param {ISheetNote} note The annotation to create or update
|
|
21
|
+
* @returns {FRange} This range for method chaining
|
|
21
22
|
* @example
|
|
22
23
|
* ```ts
|
|
23
|
-
* const fWorkbook = univerAPI.
|
|
24
|
-
* const fWorksheet = fWorkbook.
|
|
25
|
-
* const fRange = fWorksheet.getRange(
|
|
26
|
-
*
|
|
24
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
25
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
26
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
27
|
+
* fRange.createOrUpdateNote({
|
|
28
|
+
* note: 'This is a note',
|
|
29
|
+
* width: 160,
|
|
30
|
+
* height: 100,
|
|
31
|
+
* show: true,
|
|
32
|
+
* });
|
|
27
33
|
* ```
|
|
28
34
|
*/
|
|
29
35
|
createOrUpdateNote(note: ISheetNote): FRange;
|
|
30
36
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns {FRange}
|
|
37
|
+
* Delete the annotation of the top-left cell in the range
|
|
38
|
+
* @returns {FRange} This range for method chaining
|
|
33
39
|
* @example
|
|
34
40
|
* ```ts
|
|
35
|
-
* const fWorkbook = univerAPI.
|
|
36
|
-
* const fWorksheet = fWorkbook.
|
|
37
|
-
* const
|
|
38
|
-
*
|
|
41
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
42
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
43
|
+
* const notes = fWorksheet.getNotes();
|
|
44
|
+
* console.log(notes);
|
|
45
|
+
*
|
|
46
|
+
* if (notes.length > 0) {
|
|
47
|
+
* // Delete the first note
|
|
48
|
+
* const { row, col } = notes[0];
|
|
49
|
+
* fWorksheet.getRange(row, col).deleteNote();
|
|
50
|
+
* }
|
|
39
51
|
* ```
|
|
40
52
|
*/
|
|
41
53
|
deleteNote(): FRange;
|
|
@@ -6,7 +6,20 @@ export interface ISheetNoteInfo extends ISheetNote {
|
|
|
6
6
|
}
|
|
7
7
|
export interface IFSheetsNoteWorksheet {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Get all annotations in the worksheet
|
|
10
|
+
* @returns {ISheetNoteInfo[]} An array of all annotations in the worksheet
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
14
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
15
|
+
* const notes = fWorksheet.getNotes();
|
|
16
|
+
* console.log(notes);
|
|
17
|
+
*
|
|
18
|
+
* notes.forEach((item) => {
|
|
19
|
+
* const { row, col, note } = item;
|
|
20
|
+
* console.log(`Cell ${fWorksheet.getRange(row, col).getA1Notation()} has a note: ${note}`);
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
10
23
|
*/
|
|
11
24
|
getNotes(): ISheetNoteInfo[];
|
|
12
25
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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.FSheetsNoteRange=E,l.FSheetsNoteWorksheet=k,l.FUniverSheetNoteMixin=I,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.0",
|
|
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.8.0-beta.0",
|
|
60
|
+
"@univerjs/sheets": "0.8.0-beta.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"rxjs": "^7.8.2",
|
|
64
64
|
"typescript": "^5.8.3",
|
|
65
65
|
"vite": "^6.3.5",
|
|
66
|
-
"vitest": "^3.1.
|
|
67
|
-
"@univerjs-infra/shared": "0.
|
|
66
|
+
"vitest": "^3.1.4",
|
|
67
|
+
"@univerjs-infra/shared": "0.8.0-beta.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"test": "vitest run",
|