@univerjs/sheets-note 0.7.0-nightly.202504301607

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/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @univerjs/sheets-note
2
+
3
+ | Package | Description | Version | License | Downloads | Continuous Integration | Coverage |
4
+ |---------|-------------|---------|----------|-----------|----------------------|----------|
5
+ | `@univerjs/sheets-note` | `UniverSheetsNote` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
6
+
7
+ ## Introduction
8
+
9
+ `@univerjs/sheets-note` core package for sheet note. For using, please refer to [@univerjs/sheets-note](../sheets-note/README.md)
10
+
11
+ ## Usage
12
+
13
+ ### Installation
14
+
15
+ ```shell
16
+ npm install @univerjs/sheets-note
17
+ ```
18
+
19
+ or
20
+
21
+ ```shell
22
+ pnpm add @univerjs/sheets-note
23
+ ```
24
+
25
+ [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-note?style=flat-square
26
+ [npm-version-link]: https://npmjs.com/package/@univerjs/sheets-note
27
+ [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-note?style=flat-square
28
+ [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-note?style=flat-square
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@univerjs/core/facade"),h=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(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._injector.get(h.SheetsNoteModel),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())}}u.FRange.extend(w);class E extends f.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: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,()=>c.get(h.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,()=>c.get(h.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,()=>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: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,()=>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: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,()=>c.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.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,()=>c.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetDeleteNoteCommand.id){const d=c.get(h.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,()=>c.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.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,()=>c.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.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,()=>c.get(N.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.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(h.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;
@@ -0,0 +1 @@
1
+ "use strict";var T=Object.defineProperty;var U=(i,n,e)=>n in i?T(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e;var g=(i,n,e)=>U(i,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),p=require("@univerjs/sheets"),m=require("rxjs");class l extends h.Disposable{constructor(){super(...arguments);g(this,"_noteMatrix",new Map);g(this,"_change$",new m.Subject);g(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let s=this._noteMatrix.get(e);s||(s=new Map,this._noteMatrix.set(e,s));let o=s.get(t);return o||(o=new h.ObjectMatrix,s.set(t,o)),o}getSheetShowNotes$(e,t){return this._change$.pipe(m.filter(({unitId:s,sheetId:o})=>s===e&&o===t),m.map(()=>{const s=this._ensureNoteMatrix(e,t),o=[];return s.forValue((r,a,c)=>{c.show&&o.push({loc:{row:r,col:a,unitId:e,subUnitId:t},note:c})}),o}))}getCellNoteChange$(e,t,s,o){return this._change$.pipe(m.filter(({unitId:r,sheetId:a,row:c,col:u})=>r===e&&a===t&&c===s&&u===o),m.map(({note:r})=>r))}updateNote(e,t,s,o,r,a){const c=this._ensureNoteMatrix(e,t),u=c.getValue(s,o);c.setValue(s,o,r),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"update",note:r,oldNote:u,silent:a})}removeNote(e,t,s,o,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,o);a.realDeleteValue(s,o),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"update",note:null,oldNote:c,silent:r})}toggleNotePopup(e,t,s,o,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,o);if(c){c.show=!c.show;const u={...c,show:c.show};a.setValue(s,o,u),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"update",note:u,oldNote:c,silent:r})}}updateNotePosition(e,t,s,o,r,a,c){const u=this._ensureNoteMatrix(e,t),d=u.getValue(s,o);d&&(u.realDeleteValue(s,o),u.setValue(r,a,d),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"ref",newPosition:{row:r,col:a},note:d,silent:c}))}getNote(e,t,s,o){return this._ensureNoteMatrix(e,t).getValue(s,o)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const s=this._noteMatrix.get(e);if(s)return s.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const M={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,note:r,silent:a}=n;return i.get(l).updateNote(e,t,s,o,r,a),!0}},f={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,silent:r}=n;return i.get(l).removeNote(e,t,s,o,r),!0}},I={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,silent:r}=n;return i.get(l).toggleNotePopup(e,t,s,o,r),!0}},N={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,newPosition:r,silent:a}=n;return i.get(l).updateNotePosition(e,t,s,o,r.row,r.col,a),!0}};var $=Object.getOwnPropertyDescriptor,D=(i,n,e,t)=>{for(var s=t>1?void 0:t?$(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},_=(i,n)=>(e,t)=>n(e,t,i);let S=class extends h.Disposable{constructor(n,e,t,s){super();g(this,"_disposableMap",new Map);g(this,"_watcherMap",new Map);g(this,"_handleRangeChange",(n,e,t,s,o,r,a)=>r?{redos:[{id:N.id,params:{unitId:n,sheetId:e,row:s,col:o,newPosition:{row:r.startRow,col:r.startColumn},silent:a}}],undos:[{id:N.id,params:{unitId:n,sheetId:e,row:r.startRow,col:r.startColumn,newPosition:{row:s,col:o},note:t,silent:a}}]}:{redos:[{id:f.id,params:{unitId:n,sheetId:e,row:s,col:o}}],undos:[{id:M.id,params:{unitId:n,sheetId:e,row:s,col:o,note:t}}]});this._refRangeService=n,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(n,e,t,s){return`${n}-${e}-${t}-${s}`}_register(n,e,t,s,o){const r={startColumn:o,endColumn:o,startRow:s,endRow:s};this._disposableMap.set(this._getIdWithUnitId(n,e,s,o),this._refRangeService.registerRefRange(r,a=>{const c=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(r,a,{selectionManagerService:this._selectionManagerService}),u=Array.isArray(c)?c[0]:c;return u&&u.startColumn===r.startColumn&&u.startRow===r.startRow?{undos:[],redos:[]}:this._handleRangeChange(n,e,t,s,o,u,!1)},n,e))}_watch(n,e,t,s,o){const r={startColumn:o,endColumn:o,startRow:s,endRow:s};this._watcherMap.set(this._getIdWithUnitId(n,e,s,o),this._refRangeService.watchRange(n,e,r,(a,c)=>{const{redos:u}=this._handleRangeChange(n,e,t,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(n,e,t,s){var r;const o=this._getIdWithUnitId(n,e,t,s);(r=this._watcherMap.get(o))==null||r.dispose(),this._watcherMap.delete(o)}_unregister(n,e,t,s){var r;const o=this._getIdWithUnitId(n,e,t,s);(r=this._disposableMap.get(o))==null||r.dispose(),this._disposableMap.delete(o)}_initData(){const n=this._sheetsNoteModel.getNotes();for(const[e,t]of n)for(const[s,o]of t)o.forValue((r,a,c)=>(c&&(this._register(e,s,c,r,a),this._watch(e,s,c,r,a)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(n=>{switch(n.type){case"update":{const{unitId:e,sheetId:t,row:s,col:o,note:r}=n,a=this._getIdWithUnitId(e,t,s,o);r?this._disposableMap.has(a)||(this._register(e,t,r,s,o),this._watch(e,t,r,s,o)):(this._unregister(e,t,s,o),this._unwatch(e,t,s,o));break}case"ref":{const{unitId:e,sheetId:t,row:s,col:o,newPosition:r,note:a,silent:c}=n;this._unregister(e,t,s,o),c||(this._unwatch(e,t,s,o),this._watch(e,t,a,r.row,r.col)),this._register(e,t,a,r.row,r.col);break}}}))}};S=D([_(0,h.Inject(p.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(p.SheetsSelectionsService)),_(3,h.ICommandService)],S);var j=Object.getOwnPropertyDescriptor,E=(i,n,e,t)=>{for(var s=t>1?void 0:t?j(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},C=(i,n)=>(e,t)=>n(e,t,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(n,e,t){super(),this._resourceManagerService=n,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const n=t=>{const s=this._sheetsNoteModel.getUnitNotes(t);if(!s)return"";const o={};return s.forEach((r,a)=>{const c={};r.forValue((u,d,b)=>{c[u]||(c[u]={}),c[u][d]=b}),Object.keys(c).length>0&&(o[a]=c)}),JSON.stringify(o)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:t=>n(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,s)=>{Object.entries(s).forEach(([o,r])=>{Object.entries(r).forEach(([a,c])=>{Object.entries(c).forEach(([u,d])=>{this._sheetsNoteModel.updateNote(t,o,Number(a),Number(u),d)})})})}}))}};exports.SheetsNoteResourceController=E([C(0,h.IResourceManagerService),C(1,h.IUniverInstanceService),C(2,h.Inject(l))],exports.SheetsNoteResourceController);const R={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const o=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!(o!=null&&o.primary))return!1;const{actualColumn:r,actualRow:a}=o.primary;return i.get(h.ICommandService).executeCommand(f.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},y={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const o=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!(o!=null&&o.primary))return!1;const{actualColumn:r,actualRow:a}=o.primary;return i.get(h.ICommandService).executeCommand(I.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},x={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,n)=>i.get(h.ICommandService).syncExecuteCommand(M.id,n)};var V=Object.getOwnPropertyDescriptor,A=(i,n,e,t)=>{for(var s=t>1?void 0:t?V(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},W=(i,n)=>(e,t)=>n(e,t,i);let v=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[N,I,M,f,R,y,x].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};v=A([W(0,h.ICommandService)],v);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(i,n,e)=>n in i?L(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,G=(i,n,e,t)=>{for(var s=t>1?void 0:t?J(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},P=(i,n)=>(e,t)=>n(e,t,i),O=(i,n,e)=>q(i,typeof n!="symbol"?n+"":n,e);const w="SHEET_NOTE_PLUGIN";exports.SheetsNotePlugin=class extends h.Plugin{constructor(n,e){super(),this._configService=n,this._injector=e}onStarting(){[[l],[v],[exports.SheetsNoteResourceController],[S]].forEach(n=>{this._injector.add(n)}),h.touchDependencies(this._injector,[[l],[v],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[S]])}};O(exports.SheetsNotePlugin,"pluginName",w);O(exports.SheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.SheetsNotePlugin=G([h.DependentOn(p.UniverSheetsPlugin),P(0,h.IConfigService),P(1,h.Inject(h.Injector))],exports.SheetsNotePlugin);exports.PLUGIN_NAME=w;exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=R;exports.SheetToggleNotePopupCommand=y;exports.SheetUpdateNoteCommand=x;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
@@ -0,0 +1,274 @@
1
+ import { FEventName as I, FUniver as v } from "@univerjs/core/facade";
2
+ import { UpdateNoteMutation as b, SheetsNoteModel as S, RemoveNoteMutation as B, 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";
5
+ class U {
6
+ get SheetNoteAdd() {
7
+ return "SheetNoteAdd";
8
+ }
9
+ get SheetNoteDelete() {
10
+ return "SheetNoteDelete";
11
+ }
12
+ get SheetNoteUpdate() {
13
+ return "SheetNoteUpdate";
14
+ }
15
+ get SheetNoteShow() {
16
+ return "SheetNoteShow";
17
+ }
18
+ get SheetNoteHide() {
19
+ return "SheetNoteHide";
20
+ }
21
+ get BeforeSheetNoteAdd() {
22
+ return "BeforeSheetNoteAdd";
23
+ }
24
+ get BeforeSheetNoteDelete() {
25
+ return "BeforeSheetNoteDelete";
26
+ }
27
+ get BeforeSheetNoteUpdate() {
28
+ return "BeforeSheetNoteUpdate";
29
+ }
30
+ get BeforeSheetNoteShow() {
31
+ return "BeforeSheetNoteShow";
32
+ }
33
+ get BeforeSheetNoteHide() {
34
+ return "BeforeSheetNoteHide";
35
+ }
36
+ }
37
+ I.extend(U);
38
+ class x extends E {
39
+ createOrUpdateNote(d) {
40
+ return this._commandService.syncExecuteCommand(
41
+ b.id,
42
+ {
43
+ unitId: this.getUnitId(),
44
+ sheetId: this.getSheetId(),
45
+ row: this.getRow(),
46
+ col: this.getColumn(),
47
+ note: d
48
+ }
49
+ ), this;
50
+ }
51
+ deleteNote() {
52
+ return this._injector.get(S), this._commandService.syncExecuteCommand(
53
+ B.id,
54
+ {
55
+ unitId: this.getUnitId(),
56
+ sheetId: this.getSheetId(),
57
+ row: this.getRow(),
58
+ col: this.getColumn()
59
+ }
60
+ ), this;
61
+ }
62
+ getNote() {
63
+ return this._injector.get(S).getNote(this.getUnitId(), this.getSheetId(), this.getRow(), this.getColumn());
64
+ }
65
+ }
66
+ E.extend(x);
67
+ class C extends v {
68
+ _initialize(d) {
69
+ this.registerEventHandler(
70
+ this.Event.SheetNoteAdd,
71
+ () => d.get(S).change$.subscribe((e) => {
72
+ if (e.type === "update" && !e.oldNote && e.note) {
73
+ const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
74
+ if (!n)
75
+ return;
76
+ const { workbook: c, worksheet: l } = n;
77
+ this.fireEvent(this.Event.SheetNoteAdd, {
78
+ workbook: c,
79
+ worksheet: l,
80
+ row: o,
81
+ col: s,
82
+ note: r
83
+ });
84
+ }
85
+ })
86
+ ), this.registerEventHandler(
87
+ this.Event.SheetNoteDelete,
88
+ () => d.get(S).change$.subscribe((e) => {
89
+ if (e.type === "update" && e.oldNote && !e.note) {
90
+ const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
91
+ if (!n)
92
+ return;
93
+ const { workbook: c, worksheet: l } = n;
94
+ this.fireEvent(this.Event.SheetNoteDelete, {
95
+ workbook: c,
96
+ worksheet: l,
97
+ row: o,
98
+ col: s,
99
+ oldNote: i
100
+ });
101
+ }
102
+ })
103
+ ), this.registerEventHandler(
104
+ this.Event.SheetNoteUpdate,
105
+ () => d.get(S).change$.subscribe((e) => {
106
+ if (e.type === "update" && e.oldNote && e.note) {
107
+ const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
108
+ if (!n)
109
+ return;
110
+ const { workbook: c, worksheet: l } = n;
111
+ this.fireEvent(this.Event.SheetNoteUpdate, {
112
+ workbook: c,
113
+ worksheet: l,
114
+ row: o,
115
+ col: s,
116
+ note: r,
117
+ oldNote: i
118
+ });
119
+ }
120
+ })
121
+ ), this.registerEventHandler(
122
+ this.Event.SheetNoteShow,
123
+ () => d.get(S).change$.subscribe((e) => {
124
+ if (e.type === "update" && e.oldNote && e.note && !e.oldNote.show && e.note.show) {
125
+ const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
126
+ if (!r)
127
+ return;
128
+ const { workbook: i, worksheet: n } = r;
129
+ this.fireEvent(this.Event.SheetNoteShow, {
130
+ workbook: i,
131
+ worksheet: n,
132
+ row: o,
133
+ col: s
134
+ });
135
+ }
136
+ })
137
+ ), this.registerEventHandler(
138
+ this.Event.SheetNoteHide,
139
+ () => d.get(S).change$.subscribe((e) => {
140
+ if (e.type === "update" && e.oldNote && e.note && e.oldNote.show && !e.note.show) {
141
+ const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
142
+ if (!r)
143
+ return;
144
+ const { workbook: i, worksheet: n } = r;
145
+ this.fireEvent(this.Event.SheetNoteHide, {
146
+ workbook: i,
147
+ worksheet: n,
148
+ row: o,
149
+ col: s
150
+ });
151
+ }
152
+ })
153
+ ), this.registerEventHandler(
154
+ this.Event.BeforeSheetNoteAdd,
155
+ () => d.get(u).beforeCommandExecuted((e) => {
156
+ if (e.id === f.id) {
157
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params;
158
+ if (h.getNote(t, o, s, r)) return;
159
+ const c = this.getSheetTarget(t, o);
160
+ if (!c)
161
+ return;
162
+ const { workbook: l, worksheet: g } = c;
163
+ if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
164
+ workbook: l,
165
+ worksheet: g,
166
+ row: s,
167
+ col: r,
168
+ note: i
169
+ }))
170
+ throw new N();
171
+ }
172
+ })
173
+ ), this.registerEventHandler(
174
+ this.Event.BeforeSheetNoteDelete,
175
+ () => d.get(u).beforeCommandExecuted((e) => {
176
+ if (e.id === H.id) {
177
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
178
+ if (!i) return;
179
+ const n = this.getSheetTarget(t, o);
180
+ if (!n)
181
+ return;
182
+ const { workbook: c, worksheet: l } = n;
183
+ if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
184
+ workbook: c,
185
+ worksheet: l,
186
+ row: s,
187
+ col: r,
188
+ oldNote: i
189
+ }))
190
+ throw new N();
191
+ }
192
+ })
193
+ ), this.registerEventHandler(
194
+ this.Event.BeforeSheetNoteUpdate,
195
+ () => d.get(u).beforeCommandExecuted((e) => {
196
+ if (e.id === f.id) {
197
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params, n = h.getNote(t, o, s, r);
198
+ if (!n) return;
199
+ const c = this.getSheetTarget(t, o);
200
+ if (!c)
201
+ return;
202
+ const { workbook: l, worksheet: g } = c;
203
+ if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
204
+ workbook: l,
205
+ worksheet: g,
206
+ row: s,
207
+ col: r,
208
+ note: i,
209
+ oldNote: n
210
+ }))
211
+ throw new N();
212
+ }
213
+ })
214
+ ), this.registerEventHandler(
215
+ this.Event.BeforeSheetNoteShow,
216
+ () => d.get(u).beforeCommandExecuted((e) => {
217
+ if (e.id === w.id) {
218
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
219
+ if (i != null && i.show) return;
220
+ const n = this.getSheetTarget(t, o);
221
+ if (!n)
222
+ return;
223
+ const { workbook: c, worksheet: l } = n;
224
+ if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
225
+ workbook: c,
226
+ worksheet: l,
227
+ row: s,
228
+ col: r
229
+ }))
230
+ throw new N();
231
+ }
232
+ })
233
+ ), this.registerEventHandler(
234
+ this.Event.BeforeSheetNoteHide,
235
+ () => d.get(u).beforeCommandExecuted((e) => {
236
+ if (e.id === w.id) {
237
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
238
+ if (!(i != null && i.show)) return;
239
+ const n = this.getSheetTarget(t, o);
240
+ if (!n)
241
+ return;
242
+ const { workbook: c, worksheet: l } = n;
243
+ if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
244
+ workbook: c,
245
+ worksheet: l,
246
+ row: s,
247
+ col: r
248
+ }))
249
+ throw new N();
250
+ }
251
+ })
252
+ );
253
+ }
254
+ }
255
+ v.extend(C);
256
+ class T extends k {
257
+ getNotes() {
258
+ const a = this._injector.get(S).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId()), e = [];
259
+ return a == null || a.forValue((h, t, o) => {
260
+ e.push({
261
+ ...o,
262
+ row: h,
263
+ col: t
264
+ });
265
+ }), e;
266
+ }
267
+ }
268
+ k.extend(T);
269
+ export {
270
+ U as FSheetNoteEvent,
271
+ x as FSheetsNoteRange,
272
+ T as FSheetsNoteWorksheet,
273
+ C as FUniverSheetNoteMixin
274
+ };