@univerjs/sheets-note 0.15.4 → 0.15.5
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/cjs/index.js +1 -1
- package/lib/es/facade.js +134 -136
- package/lib/es/index.js +398 -317
- package/lib/facade.js +134 -136
- package/lib/index.js +398 -317
- package/lib/types/commands/mutations/note.mutation.d.ts +9 -6
- package/lib/types/facade/f-worksheet.d.ts +3 -7
- package/lib/types/models/sheets-note.model.d.ts +44 -23
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
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 m=require("@univerjs/core/facade"),c=require("@univerjs/sheets-note"),f=require("@univerjs/sheets/facade"),u=require("@univerjs/core"),w=require("@univerjs/sheets");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"}}m.FEventName.extend(E);class p extends f.FRange{createOrUpdateNote(i){return this._commandService.syncExecuteCommand(c.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:i}),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(),{row:this.getRow(),col:this.getColumn()})}}f.FRange.extend(p);class I extends m.FUniver{_initialize(i){const N=i.get(u.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>i.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.newNote){const{unitId:r,subUnitId:s,newNote:t}=e,o=this.getSheetTarget(r,s);if(!o)return;const{workbook:d,worksheet:n}=o;this.fireEvent(this.Event.SheetNoteAdd,{workbook:d,worksheet:n,row:t.row,col:t.col,note:t})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>i.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.newNote){const{unitId:r,subUnitId:s,oldNote:t}=e,o=this.getSheetTarget(r,s);if(!o)return;const{workbook:d,worksheet:n}=o;this.fireEvent(this.Event.SheetNoteDelete,{workbook:d,worksheet:n,row:t.row,col:t.col,oldNote:t})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>i.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.newNote){const{unitId:r,subUnitId:s,oldNote:t,newNote:o}=e,d=this.getSheetTarget(r,s);if(!d)return;const{workbook:n,worksheet:l}=d;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:n,worksheet:l,row:o.row,col:o.col,note:o,oldNote:t})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>i.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.newNote&&!e.oldNote.show&&e.newNote.show){const{unitId:r,subUnitId:s,newNote:t}=e,o=this.getSheetTarget(r,s);if(!o)return;const{workbook:d,worksheet:n}=o;this.fireEvent(this.Event.SheetNoteShow,{workbook:d,worksheet:n,row:t.row,col:t.col})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>i.get(c.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.newNote&&e.oldNote.show&&!e.newNote.show){const{unitId:r,subUnitId:s,newNote:t}=e,o=this.getSheetTarget(r,s);if(!o)return;const{workbook:d,worksheet:n}=o;this.fireEvent(this.Event.SheetNoteHide,{workbook:d,worksheet:n,row:t.row,col:t.col})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>N.beforeCommandExecuted(h=>{if(h.id===c.SheetUpdateNoteCommand.id){const{unitId:e,sheetId:r,row:s,col:t,note:o}=h.params,d=this.getSheetTarget(e,r);if(!d||i.get(c.SheetsNoteModel).getNote(e,r,{noteId:o.id,row:s,col:t}))return;const{workbook:S,worksheet:a}=d;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:S,worksheet:a,row:s,col:t,note:o}))throw new u.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>N.beforeCommandExecuted(h=>{if(h.id===c.SheetDeleteNoteCommand.id){const{unitId:e,sheetId:r,row:s,col:t}=h.params,o=this.getSheetTarget(e,r);if(!o||s===void 0||t===void 0)return;const n=i.get(c.SheetsNoteModel).getNote(e,r,{row:s,col:t});if(!n)return;const{workbook:l,worksheet:S}=o;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:l,worksheet:S,row:s,col:t,oldNote:n}))throw new u.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>N.beforeCommandExecuted(h=>{if(h.id===c.SheetUpdateNoteCommand.id){const{unitId:e,sheetId:r,row:s,col:t,note:o}=h.params,d=this.getSheetTarget(e,r);if(!d)return;const l=i.get(c.SheetsNoteModel).getNote(e,r,{row:s,col:t});if(!l)return;const{workbook:S,worksheet:a}=d;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:S,worksheet:a,row:s,col:t,note:o,oldNote:l}))throw new u.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>N.beforeCommandExecuted(h=>{if(h.id===c.SheetToggleNotePopupCommand.id){const e=w.getSheetCommandTarget(i.get(u.IUniverInstanceService));if(!e)return;const{unitId:r,subUnitId:s}=e,t=this.getUniverSheet(r);if(!t)return;const o=t.getSheetBySheetId(s);if(!o)return;const n=i.get(w.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return;const l=i.get(c.SheetsNoteModel),{actualColumn:S,actualRow:a}=n.primary,g=l.getNote(r,s,{row:a,col:S});if(!g||g.show)return;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:t,worksheet:o,row:a,col:S}))throw new u.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>N.beforeCommandExecuted(h=>{if(h.id===c.SheetToggleNotePopupCommand.id){const e=w.getSheetCommandTarget(i.get(u.IUniverInstanceService));if(!e)return;const{unitId:r,subUnitId:s}=e,t=this.getUniverSheet(r);if(!t)return;const o=t.getSheetBySheetId(s);if(!o)return;const n=i.get(w.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return;const l=i.get(c.SheetsNoteModel),{actualColumn:S,actualRow:a}=n.primary,g=l.getNote(r,s,{row:a,col:S});if(!g||!g.show)return;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:t,worksheet:o,row:a,col:S}))throw new u.CanceledError}})))}}m.FUniver.extend(I);class k extends f.FWorksheet{getNotes(){const N=this._injector.get(c.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId());return N?Array.from(N.values()).map(h=>({...h})):[]}}f.FWorksheet.extend(k);exports.FSheetNoteEvent=E;exports.FSheetsNoteRangeMixin=p;exports.FSheetsNoteWorksheet=k;exports.FUniverSheetNoteMixin=I;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var E=Object.defineProperty;var $=(i,o,t)=>o in i?E(i,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[o]=t;var g=(i,o,t)=>$(i,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),l=require("@univerjs/sheets"),N=require("rxjs");class p extends h.Disposable{constructor(){super(...arguments);g(this,"_noteMatrix",new Map);g(this,"_change$",new N.Subject);g(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(t,s){let e=this._noteMatrix.get(t);e||(e=new Map,this._noteMatrix.set(t,e));let n=e.get(s);return n||(n=new h.ObjectMatrix,e.set(s,n)),n}getSheetShowNotes$(t,s){return this._change$.pipe(N.filter(({unitId:e,sheetId:n})=>e===t&&n===s),N.map(()=>{const e=this._ensureNoteMatrix(t,s),n=[];return e.forValue((r,a,c)=>{c.show&&n.push({loc:{row:r,col:a,unitId:t,subUnitId:s},note:c})}),n}))}getCellNoteChange$(t,s,e,n){return this._change$.pipe(N.filter(({unitId:r,sheetId:a,row:c,col:d})=>r===t&&a===s&&c===e&&d===n),N.map(({note:r})=>r))}updateNote(t,s,e,n,r,a){const c=this._ensureNoteMatrix(t,s),d=c.getValue(e,n);c.setValue(e,n,r),this._change$.next({unitId:t,sheetId:s,row:e,col:n,type:"update",note:r,oldNote:d,silent:a})}removeNote(t,s,e,n,r){const a=this._ensureNoteMatrix(t,s),c=a.getValue(e,n);a.realDeleteValue(e,n),this._change$.next({unitId:t,sheetId:s,row:e,col:n,type:"update",note:null,oldNote:c,silent:r})}toggleNotePopup(t,s,e,n,r){const a=this._ensureNoteMatrix(t,s),c=a.getValue(e,n);if(c){c.show=!c.show;const d={...c,show:c.show};a.setValue(e,n,d),this._change$.next({unitId:t,sheetId:s,row:e,col:n,type:"update",note:d,oldNote:c,silent:r})}}updateNotePosition(t,s,e,n,r,a,c){const d=this._ensureNoteMatrix(t,s),u=d.getValue(e,n);u&&(d.realDeleteValue(e,n),d.setValue(r,a,u),this._change$.next({unitId:t,sheetId:s,row:e,col:n,type:"ref",newPosition:{row:r,col:a},note:u,silent:c}))}getNote(t,s,e,n){return this._ensureNoteMatrix(t,s).getValue(e,n)}getUnitNotes(t){return this._noteMatrix.get(t)}getSheetNotes(t,s){const e=this._noteMatrix.get(t);if(e)return e.get(s)}getNotes(){return this._noteMatrix}deleteUnitNotes(t){this._noteMatrix.delete(t)}}const _={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:t,sheetId:s,row:e,col:n,note:r,silent:a}=o;return i.get(p).updateNote(t,s,e,n,r,a),!0}},S={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:t,sheetId:s,row:e,col:n,silent:r}=o;return i.get(p).removeNote(t,s,e,n,r),!0}},y={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:t,sheetId:s,row:e,col:n,silent:r}=o;return i.get(p).toggleNotePopup(t,s,e,n,r),!0}},M={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:t,sheetId:s,row:e,col:n,newPosition:r,silent:a}=o;return i.get(p).updateNotePosition(t,s,e,n,r.row,r.col,a),!0}},P={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,o)=>{const t=i.get(h.IUniverInstanceService),s=l.getSheetCommandTarget(t);if(!s)return!1;const n=i.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.primary;return i.get(h.ICommandService).executeCommand(S.id,{unitId:s.unitId,sheetId:s.subUnitId,row:a,col:r})}},w={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,o)=>{const t=i.get(h.IUniverInstanceService),s=l.getSheetCommandTarget(t);if(!s)return!1;const n=i.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.primary;return i.get(h.ICommandService).executeCommand(y.id,{unitId:s.unitId,sheetId:s.subUnitId,row:a,col:r})}},x={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,o)=>i.get(h.ICommandService).syncExecuteCommand(_.id,o)},T="SHEET_NOTE_PLUGIN";var D=Object.getOwnPropertyDescriptor,j=(i,o,t,s)=>{for(var e=s>1?void 0:s?D(o,t):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(e=r(e)||e);return e},v=(i,o)=>(t,s)=>o(t,s,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(o,t,s,e){super(),this._resourceManagerService=o,this._univerInstanceService=t,this._sheetInterceptorService=s,this._sheetsNoteModel=e,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const o=s=>{const e=this._sheetsNoteModel.getUnitNotes(s);if(!e)return"";const n={};return e.forEach((r,a)=>{const c={};r.forValue((d,u,m)=>{c[d]||(c[d]={}),c[d][u]=m}),Object.keys(c).length>0&&(n[a]=c)}),JSON.stringify(n)},t=s=>{if(!s)return{};try{return JSON.parse(s)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:T,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:s=>o(s),parseJson:s=>t(s),onUnLoad:s=>{this._sheetsNoteModel.deleteUnitNotes(s)},onLoad:(s,e)=>{Object.entries(e).forEach(([n,r])=>{Object.entries(r).forEach(([a,c])=>{Object.entries(c).forEach(([d,u])=>{this._sheetsNoteModel.updateNote(s,n,Number(a),Number(d),u)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===l.RemoveSheetCommand.id){const s=o.params,e=s.unitId||this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=s.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!e||!n)return{redos:[],undos:[]};const r=this._sheetsNoteModel.getSheetNotes(e,n);if(!r)return{redos:[],undos:[]};const a=[],c=[];return r.forValue((d,u,m)=>{a.push({id:S.id,params:{unitId:e,sheetId:n,row:d,col:u}}),c.push({id:_.id,params:{unitId:e,sheetId:n,row:d,col:u,note:m}})}),{redos:a,undos:c}}else if(o.id===l.CopySheetCommand.id){const s=o.params,{unitId:e,subUnitId:n,targetSubUnitId:r}=s;if(!e||!n||!r)return{redos:[],undos:[]};const a=this._sheetsNoteModel.getSheetNotes(e,n);if(!a)return{redos:[],undos:[]};const c=[],d=[];return a.forValue((u,m,b)=>{c.push({id:_.id,params:{unitId:e,sheetId:r,row:u,col:m,note:b}}),d.push({id:S.id,params:{unitId:e,sheetId:r,row:u,col:m}})}),{redos:c,undos:d}}return{redos:[],undos:[]}}}))}};exports.SheetsNoteResourceController=j([v(0,h.IResourceManagerService),v(1,h.IUniverInstanceService),v(2,h.Inject(l.SheetInterceptorService)),v(3,h.Inject(p))],exports.SheetsNoteResourceController);const V="sheets-note.config",R={};var A=Object.getOwnPropertyDescriptor,W=(i,o,t,s)=>{for(var e=s>1?void 0:s?A(o,t):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(e=r(e)||e);return e},f=(i,o)=>(t,s)=>o(t,s,i);let C=class extends h.Disposable{constructor(o,t,s,e){super();g(this,"_disposableMap",new Map);g(this,"_watcherMap",new Map);g(this,"_handleRangeChange",(o,t,s,e,n,r,a)=>r?{redos:[{id:M.id,params:{unitId:o,sheetId:t,row:e,col:n,newPosition:{row:r.startRow,col:r.startColumn},silent:a}}],undos:[{id:M.id,params:{unitId:o,sheetId:t,row:r.startRow,col:r.startColumn,newPosition:{row:e,col:n},note:s,silent:a}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:t,row:e,col:n}}],undos:[{id:_.id,params:{unitId:o,sheetId:t,row:e,col:n,note:s}}]});this._refRangeService=o,this._sheetsNoteModel=t,this._selectionManagerService=s,this._commandService=e,this._initData(),this._initRefRange()}_getIdWithUnitId(o,t,s,e){return`${o}-${t}-${s}-${e}`}_register(o,t,s,e,n){const r={startColumn:n,endColumn:n,startRow:e,endRow:e};this._disposableMap.set(this._getIdWithUnitId(o,t,e,n),this._refRangeService.registerRefRange(r,a=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(r,a,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===r.startColumn&&d.startRow===r.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,t,s,e,n,d,!1)},o,t))}_watch(o,t,s,e,n){const r={startColumn:n,endColumn:n,startRow:e,endRow:e};this._watcherMap.set(this._getIdWithUnitId(o,t,e,n),this._refRangeService.watchRange(o,t,r,(a,c)=>{const{redos:d}=this._handleRangeChange(o,t,s,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,t,s,e){var r;const n=this._getIdWithUnitId(o,t,s,e);(r=this._watcherMap.get(n))==null||r.dispose(),this._watcherMap.delete(n)}_unregister(o,t,s,e){var r;const n=this._getIdWithUnitId(o,t,s,e);(r=this._disposableMap.get(n))==null||r.dispose(),this._disposableMap.delete(n)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[t,s]of o)for(const[e,n]of s)n.forValue((r,a,c)=>(c&&(this._register(t,e,c,r,a),this._watch(t,e,c,r,a)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:t,sheetId:s,row:e,col:n,note:r}=o,a=this._getIdWithUnitId(t,s,e,n);r?this._disposableMap.has(a)||(this._register(t,s,r,e,n),this._watch(t,s,r,e,n)):(this._unregister(t,s,e,n),this._unwatch(t,s,e,n));break}case"ref":{const{unitId:t,sheetId:s,row:e,col:n,newPosition:r,note:a,silent:c}=o;this._unregister(t,s,e,n),c||(this._unwatch(t,s,e,n),this._watch(t,s,a,r.row,r.col)),this._register(t,s,a,r.row,r.col);break}}}))}};C=W([f(0,h.Inject(l.RefRangeService)),f(1,h.Inject(p)),f(2,h.Inject(l.SheetsSelectionsService)),f(3,h.ICommandService)],C);var L=Object.getOwnPropertyDescriptor,H=(i,o,t,s)=>{for(var e=s>1?void 0:s?L(o,t):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(e=r(e)||e);return e},J=(i,o)=>(t,s)=>o(t,s,i);let I=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[M,y,_,S,P,w,x].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};I=H([J(0,h.ICommandService)],I);var q=Object.defineProperty,G=Object.getOwnPropertyDescriptor,z=(i,o,t)=>o in i?q(i,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[o]=t,F=(i,o,t,s)=>{for(var e=s>1?void 0:s?G(o,t):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(e=r(e)||e);return e},U=(i,o)=>(t,s)=>o(t,s,i),O=(i,o,t)=>z(i,typeof o!="symbol"?o+"":o,t);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(o=R,t,s){super(),this._config=o,this._configService=t,this._injector=s;const{...e}=h.merge({},R,this._config);this._configService.setConfig(V,e)}onStarting(){[[p],[I],[exports.SheetsNoteResourceController],[C]].forEach(o=>{this._injector.add(o)}),h.touchDependencies(this._injector,[[p],[I],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[C]])}};O(exports.UniverSheetsNotePlugin,"pluginName",T);O(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=F([h.DependentOn(l.UniverSheetsPlugin),U(1,h.IConfigService),U(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=S;exports.SheetDeleteNoteCommand=P;exports.SheetToggleNotePopupCommand=w;exports.SheetUpdateNoteCommand=x;exports.SheetsNoteModel=p;exports.ToggleNotePopupMutation=y;exports.UpdateNoteMutation=_;exports.UpdateNotePositionMutation=M;
|
|
1
|
+
"use strict";var x=Object.defineProperty;var A=(i,r,t)=>r in i?x(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t;var S=(i,r,t)=>A(i,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),g=require("@univerjs/sheets"),f=require("rxjs");class _ extends h.Disposable{constructor(){super(...arguments);S(this,"_notesMap",new Map);S(this,"_change$",new f.Subject);S(this,"change$",this._change$.asObservable())}_ensureNotesMap(t,e){let o=this._notesMap.get(t);o||(o=new Map,this._notesMap.set(t,o));let s=o.get(e);return s||(s=new Map,o.set(e,s)),s}_getNoteByPosition(t,e,o,s){const n=this._ensureNotesMap(t,e);for(const[a,c]of n)if(c.row===o&&c.col===s)return c}_getNoteById(t,e,o){return this._ensureNotesMap(t,e).get(o)}_getNoteByParams(t,e,o){const{noteId:s,row:n,col:a}=o;return s?this._getNoteById(t,e,s):n!==void 0&&a!==void 0?this._getNoteByPosition(t,e,n,a):null}getSheetShowNotes$(t,e){return this._change$.pipe(f.filter(({unitId:o,subUnitId:s})=>o===t&&s===e),f.map(()=>{const o=this._ensureNotesMap(t,e),s=[];for(const[n,a]of o)a.show&&s.push({loc:{row:a.row,col:a.col,unitId:t,subUnitId:e},note:a});return s}))}getCellNoteChange$(t,e,o,s){return this._change$.pipe(f.filter(({unitId:n,subUnitId:a,oldNote:c})=>n!==t||a!==e||!c?!1:c.row===o&&c.col===s),f.map(n=>n))}updateNote(t,e,o,s,n,a){const c=this._getNoteByParams(t,e,{noteId:n==null?void 0:n.id,row:o,col:s}),d=this._ensureNotesMap(t,e),u={...n,id:(c==null?void 0:c.id)||n.id||h.generateRandomId(6),row:o,col:s};d.set(u.id,u),this._change$.next({unitId:t,subUnitId:e,oldNote:c,type:"update",newNote:u,silent:a})}removeNote(t,e,o){const{noteId:s,row:n,col:a,silent:c}=o,d=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!d)return;this._ensureNotesMap(t,e).delete(d.id),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:null,silent:c})}toggleNotePopup(t,e,o){const{noteId:s,row:n,col:a,silent:c}=o,d=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!d)return;const u=this._ensureNotesMap(t,e),l={...d,show:!d.show};u.set(l.id,l),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:l,silent:c})}updateNotePosition(t,e,o){const{noteId:s,row:n,col:a,newRow:c,newCol:d,silent:u}=o,l=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!l)return;const p=this._ensureNotesMap(t,e),m={...l,row:c,col:d};p.set(m.id,m),this._change$.next({unitId:t,subUnitId:e,oldNote:l,type:"ref",newNote:m,silent:u})}getNote(t,e,o){return this._getNoteByParams(t,e,o)}getNotes(){return this._notesMap}getUnitNotes(t){return this._notesMap.get(t)}getSheetNotes(t,e){const o=this._notesMap.get(t);if(o)return o.get(e)}deleteUnitNotes(t){this._notesMap.delete(t)}}const N={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,row:o,col:s,note:n,silent:a}=r;return i.get(_).updateNote(t,e,o,s,n,a),!0}},M={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,silent:a}=r;return i.get(_).removeNote(t,e,{noteId:o,row:s,col:n,silent:a}),!0}},w={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,silent:a}=r;return i.get(_).toggleNotePopup(t,e,{noteId:o,row:s,col:n,silent:a}),!0}},C={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,newPosition:a,silent:c}=r;return i.get(_).updateNotePosition(t,e,{noteId:o,row:s,col:n,newRow:a.row,newCol:a.col,silent:c}),!0}},E={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:i=>{const r=g.getSheetCommandTarget(i.get(h.IUniverInstanceService));if(!r)return!1;const e=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const o=i.get(_),{unitId:s,subUnitId:n}=r,{actualColumn:a,actualRow:c}=e.primary,d=o.getNote(s,n,{row:c,col:a});if(!d)return!1;const u=i.get(h.ICommandService),l=i.get(h.IUndoRedoService),p={id:M.id,params:{unitId:s,sheetId:n,noteId:d.id}},m={id:N.id,params:{unitId:s,sheetId:n,row:c,col:a,note:{...d}}};return u.syncExecuteCommand(p.id,p.params)?(l.pushUndoRedo({unitID:s,redoMutations:[p],undoMutations:[m]}),!0):!1}},O={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:i=>{const r=g.getSheetCommandTarget(i.get(h.IUniverInstanceService));if(!r)return!1;const e=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const o=i.get(_),{unitId:s,subUnitId:n}=r,{actualColumn:a,actualRow:c}=e.primary,d=o.getNote(s,n,{row:c,col:a});if(!d)return!1;const u=i.get(h.ICommandService),l=i.get(h.IUndoRedoService),p={id:w.id,params:{unitId:s,sheetId:n,noteId:d.id}},m={id:w.id,params:{unitId:s,sheetId:n,noteId:d.id}};return u.syncExecuteCommand(p.id,p.params)?(l.pushUndoRedo({unitID:s,redoMutations:[p],undoMutations:[m]}),!0):!1}},D={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,r)=>{const t=g.getSheetCommandTarget(i.get(h.IUniverInstanceService),r);if(!t)return!1;const e=i.get(h.ICommandService),o=i.get(h.IUndoRedoService),s=i.get(_),{unitId:n,subUnitId:a}=t,{row:c,col:d,note:u}=r,l=s.getNote(n,a,{noteId:u.id,row:c,col:d}),p={id:N.id,params:{unitId:n,sheetId:a,row:c,col:d,note:u}},m=[];if(l){const U={id:N.id,params:{unitId:n,sheetId:a,row:c,col:d,note:{...l}}};m.push(U)}else{const U={id:M.id,params:{unitId:n,sheetId:a,row:c,col:d}};m.push(U)}return e.syncExecuteCommand(p.id,p.params)?(o.pushUndoRedo({unitID:n,redoMutations:[p],undoMutations:m}),!0):!1}},$="SHEET_NOTE_PLUGIN";var W=Object.getOwnPropertyDescriptor,B=(i,r,t,e)=>{for(var o=e>1?void 0:e?W(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},v=(i,r)=>(t,e)=>r(t,e,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(r,t,e,o){super(),this._resourceManagerService=r,this._univerInstanceService=t,this._sheetInterceptorService=e,this._sheetsNoteModel=o,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const r=e=>{const o=this._sheetsNoteModel.getUnitNotes(e);if(!o)return"";const s={};return o.forEach((n,a)=>{const c={};n.forEach(d=>{const{row:u,col:l}=d;c[u]||(c[u]={}),c[u][l]=d}),Object.keys(c).length>0&&(s[a]=c)}),JSON.stringify(s)},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:$,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,o)=>{Object.entries(o).forEach(([s,n])=>{Object.entries(n).forEach(([a,c])=>{Object.entries(c).forEach(([d,u])=>{this._sheetsNoteModel.updateNote(e,s,Number(a),Number(d),u)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===g.RemoveSheetCommand.id){const e=r.params,o=e.unitId||this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=e.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!o||!s)return{redos:[],undos:[]};const n=this._sheetsNoteModel.getSheetNotes(o,s);if(!n)return{redos:[],undos:[]};const a=[],c=[];return n.forEach(d=>{a.push({id:M.id,params:{unitId:o,sheetId:s,noteId:d.id,row:d.row,col:d.col}}),c.push({id:N.id,params:{unitId:o,sheetId:s,row:d.row,col:d.col,note:d}})}),{redos:a,undos:c}}else if(r.id===g.CopySheetCommand.id){const e=r.params,{unitId:o,subUnitId:s,targetSubUnitId:n}=e;if(!o||!s||!n)return{redos:[],undos:[]};const a=this._sheetsNoteModel.getSheetNotes(o,s);if(!a)return{redos:[],undos:[]};const c=[],d=[];return a.forEach(u=>{const l={...u,id:h.generateRandomId(6)};c.push({id:N.id,params:{unitId:o,sheetId:n,row:l.row,col:l.col,note:l}}),d.push({id:M.id,params:{unitId:o,sheetId:n,noteId:l.id,row:l.row,col:l.col}})}),{redos:c,undos:d}}return{redos:[],undos:[]}}}))}};exports.SheetsNoteResourceController=B([v(0,h.IResourceManagerService),v(1,h.IUniverInstanceService),v(2,h.Inject(g.SheetInterceptorService)),v(3,h.Inject(_))],exports.SheetsNoteResourceController);const L="sheets-note.config",T={};var H=Object.getOwnPropertyDescriptor,J=(i,r,t,e)=>{for(var o=e>1?void 0:e?H(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},I=(i,r)=>(t,e)=>r(t,e,i);let R=class extends h.Disposable{constructor(r,t,e,o){super();S(this,"_disposableMap",new Map);S(this,"_watcherMap",new Map);S(this,"_handleRangeChange",(r,t,e,o,s,n,a)=>n?{redos:[{id:C.id,params:{unitId:r,sheetId:t,noteId:e.id,newPosition:{row:n.startRow,col:n.startColumn},silent:a}}],undos:[{id:C.id,params:{unitId:r,sheetId:t,noteId:e.id,newPosition:{row:o,col:s},note:e,silent:a}}]}:{redos:[{id:M.id,params:{unitId:r,sheetId:t,noteId:e.id}}],undos:[{id:N.id,params:{unitId:r,sheetId:t,row:o,col:s,note:e}}]});this._refRangeService=r,this._sheetsNoteModel=t,this._selectionManagerService=e,this._commandService=o,this._initData(),this._initRefRange()}_getIdWithUnitId(r,t,e,o){return`${r}-${t}-${e}-${o}`}_register(r,t,e,o,s){const n={startColumn:s,endColumn:s,startRow:o,endRow:o};this._disposableMap.set(this._getIdWithUnitId(r,t,o,s),this._refRangeService.registerRefRange(n,a=>{const c=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(n,a,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===n.startColumn&&d.startRow===n.startRow?{undos:[],redos:[]}:this._handleRangeChange(r,t,e,o,s,d,!1)},r,t))}_watch(r,t,e,o,s){const n={startColumn:s,endColumn:s,startRow:o,endRow:o};this._watcherMap.set(this._getIdWithUnitId(r,t,o,s),this._refRangeService.watchRange(r,t,n,(a,c)=>{const{redos:d}=this._handleRangeChange(r,t,e,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(r,t,e,o){var n;const s=this._getIdWithUnitId(r,t,e,o);(n=this._watcherMap.get(s))==null||n.dispose(),this._watcherMap.delete(s)}_unregister(r,t,e,o){var n;const s=this._getIdWithUnitId(r,t,e,o);(n=this._disposableMap.get(s))==null||n.dispose(),this._disposableMap.delete(s)}_initData(){const r=this._sheetsNoteModel.getNotes();for(const[t,e]of r)for(const[o,s]of e)s.forEach(n=>{this._register(t,o,n,n.row,n.col),this._watch(t,o,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(r=>{switch(r.type){case"update":{const{unitId:t,subUnitId:e,oldNote:o,newNote:s}=r,n=s?s.row:o.row,a=s?s.col:o.col,c=this._getIdWithUnitId(t,e,n,a);s?this._disposableMap.has(c)||(this._register(t,e,s,n,a),this._watch(t,e,s,n,a)):(this._unregister(t,e,n,a),this._unwatch(t,e,n,a));break}case"ref":{const{unitId:t,subUnitId:e,oldNote:o,newNote:s,silent:n}=r,{row:a,col:c}=o,{row:d,col:u}=s;this._unregister(t,e,a,c),n||(this._unwatch(t,e,a,c),this._watch(t,e,s,d,u)),this._register(t,e,s,d,u);break}}}))}};R=J([I(0,h.Inject(g.RefRangeService)),I(1,h.Inject(_)),I(2,h.Inject(g.SheetsSelectionsService)),I(3,h.ICommandService)],R);var q=Object.getOwnPropertyDescriptor,G=(i,r,t,e)=>{for(var o=e>1?void 0:e?q(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},V=(i,r)=>(t,e)=>r(t,e,i);let y=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[C,w,N,M,E,O,D].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};y=G([V(0,h.ICommandService)],y);var z=Object.defineProperty,F=Object.getOwnPropertyDescriptor,K=(i,r,t)=>r in i?z(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t,Y=(i,r,t,e)=>{for(var o=e>1?void 0:e?F(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},b=(i,r)=>(t,e)=>r(t,e,i),j=(i,r,t)=>K(i,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(r=T,t,e){super(),this._config=r,this._configService=t,this._injector=e;const{...o}=h.merge({},T,this._config);this._configService.setConfig(L,o)}onStarting(){[[_],[y],[exports.SheetsNoteResourceController],[R]].forEach(r=>{this._injector.add(r)}),h.touchDependencies(this._injector,[[_],[y],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[R]])}};j(exports.UniverSheetsNotePlugin,"pluginName",$);j(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=Y([h.DependentOn(g.UniverSheetsPlugin),b(1,h.IConfigService),b(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=M;exports.SheetDeleteNoteCommand=E;exports.SheetToggleNotePopupCommand=O;exports.SheetUpdateNoteCommand=D;exports.SheetsNoteModel=_;exports.ToggleNotePopupMutation=w;exports.UpdateNoteMutation=N;exports.UpdateNotePositionMutation=C;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { FEventName as
|
|
2
|
-
import { UpdateNoteMutation as
|
|
3
|
-
import { FRange as
|
|
4
|
-
import { ICommandService as
|
|
5
|
-
|
|
1
|
+
import { FEventName as B, FUniver as I } from "@univerjs/core/facade";
|
|
2
|
+
import { UpdateNoteMutation as C, RemoveNoteMutation as H, SheetsNoteModel as c, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as x, SheetToggleNotePopupCommand as m } from "@univerjs/sheets-note";
|
|
3
|
+
import { FRange as k, FWorksheet as b } from "@univerjs/sheets/facade";
|
|
4
|
+
import { ICommandService as M, CanceledError as g, IUniverInstanceService as v } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as E, SheetsSelectionsService as p } from "@univerjs/sheets";
|
|
6
|
+
class y {
|
|
6
7
|
get SheetNoteAdd() {
|
|
7
8
|
return "SheetNoteAdd";
|
|
8
9
|
}
|
|
@@ -34,23 +35,23 @@ class x {
|
|
|
34
35
|
return "BeforeSheetNoteHide";
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
class
|
|
39
|
-
createOrUpdateNote(
|
|
38
|
+
B.extend(y);
|
|
39
|
+
class W extends k {
|
|
40
|
+
createOrUpdateNote(n) {
|
|
40
41
|
return this._commandService.syncExecuteCommand(
|
|
41
|
-
|
|
42
|
+
C.id,
|
|
42
43
|
{
|
|
43
44
|
unitId: this.getUnitId(),
|
|
44
45
|
sheetId: this.getSheetId(),
|
|
45
46
|
row: this.getRow(),
|
|
46
47
|
col: this.getColumn(),
|
|
47
|
-
note:
|
|
48
|
+
note: n
|
|
48
49
|
}
|
|
49
50
|
), this;
|
|
50
51
|
}
|
|
51
52
|
deleteNote() {
|
|
52
53
|
return this._commandService.syncExecuteCommand(
|
|
53
|
-
|
|
54
|
+
H.id,
|
|
54
55
|
{
|
|
55
56
|
unitId: this.getUnitId(),
|
|
56
57
|
sheetId: this.getSheetId(),
|
|
@@ -60,29 +61,29 @@ class U extends E {
|
|
|
60
61
|
), this;
|
|
61
62
|
}
|
|
62
63
|
getNote() {
|
|
63
|
-
return this._injector.get(
|
|
64
|
+
return this._injector.get(c).getNote(this.getUnitId(), this.getSheetId(), { row: this.getRow(), col: this.getColumn() });
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
class
|
|
67
|
+
k.extend(W);
|
|
68
|
+
class T extends I {
|
|
68
69
|
// eslint-disable-next-line max-lines-per-function
|
|
69
|
-
_initialize(
|
|
70
|
-
const a =
|
|
70
|
+
_initialize(n) {
|
|
71
|
+
const a = n.get(M);
|
|
71
72
|
this.disposeWithMe(
|
|
72
73
|
this.registerEventHandler(
|
|
73
74
|
this.Event.SheetNoteAdd,
|
|
74
|
-
() =>
|
|
75
|
-
if (e.type === "update" && !e.oldNote && e.
|
|
76
|
-
const { unitId:
|
|
77
|
-
if (!
|
|
75
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
76
|
+
if (e.type === "update" && !e.oldNote && e.newNote) {
|
|
77
|
+
const { unitId: s, subUnitId: r, newNote: t } = e, o = this.getSheetTarget(s, r);
|
|
78
|
+
if (!o)
|
|
78
79
|
return;
|
|
79
|
-
const { workbook: d, worksheet:
|
|
80
|
+
const { workbook: d, worksheet: i } = o;
|
|
80
81
|
this.fireEvent(this.Event.SheetNoteAdd, {
|
|
81
82
|
workbook: d,
|
|
82
|
-
worksheet:
|
|
83
|
-
row:
|
|
84
|
-
col:
|
|
85
|
-
note:
|
|
83
|
+
worksheet: i,
|
|
84
|
+
row: t.row,
|
|
85
|
+
col: t.col,
|
|
86
|
+
note: t
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
})
|
|
@@ -90,18 +91,18 @@ class C extends m {
|
|
|
90
91
|
), this.disposeWithMe(
|
|
91
92
|
this.registerEventHandler(
|
|
92
93
|
this.Event.SheetNoteDelete,
|
|
93
|
-
() =>
|
|
94
|
-
if (e.type === "update" && e.oldNote && !e.
|
|
95
|
-
const { unitId:
|
|
96
|
-
if (!
|
|
94
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
95
|
+
if (e.type === "update" && e.oldNote && !e.newNote) {
|
|
96
|
+
const { unitId: s, subUnitId: r, oldNote: t } = e, o = this.getSheetTarget(s, r);
|
|
97
|
+
if (!o)
|
|
97
98
|
return;
|
|
98
|
-
const { workbook: d, worksheet:
|
|
99
|
+
const { workbook: d, worksheet: i } = o;
|
|
99
100
|
this.fireEvent(this.Event.SheetNoteDelete, {
|
|
100
101
|
workbook: d,
|
|
101
|
-
worksheet:
|
|
102
|
-
row:
|
|
103
|
-
col:
|
|
104
|
-
oldNote:
|
|
102
|
+
worksheet: i,
|
|
103
|
+
row: t.row,
|
|
104
|
+
col: t.col,
|
|
105
|
+
oldNote: t
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
})
|
|
@@ -109,19 +110,19 @@ class C extends m {
|
|
|
109
110
|
), this.disposeWithMe(
|
|
110
111
|
this.registerEventHandler(
|
|
111
112
|
this.Event.SheetNoteUpdate,
|
|
112
|
-
() =>
|
|
113
|
-
if (e.type === "update" && e.oldNote && e.
|
|
114
|
-
const { unitId:
|
|
113
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
114
|
+
if (e.type === "update" && e.oldNote && e.newNote) {
|
|
115
|
+
const { unitId: s, subUnitId: r, oldNote: t, newNote: o } = e, d = this.getSheetTarget(s, r);
|
|
115
116
|
if (!d)
|
|
116
117
|
return;
|
|
117
|
-
const { workbook:
|
|
118
|
+
const { workbook: i, worksheet: l } = d;
|
|
118
119
|
this.fireEvent(this.Event.SheetNoteUpdate, {
|
|
119
|
-
workbook:
|
|
120
|
-
worksheet:
|
|
121
|
-
row:
|
|
122
|
-
col:
|
|
123
|
-
note:
|
|
124
|
-
oldNote:
|
|
120
|
+
workbook: i,
|
|
121
|
+
worksheet: l,
|
|
122
|
+
row: o.row,
|
|
123
|
+
col: o.col,
|
|
124
|
+
note: o,
|
|
125
|
+
oldNote: t
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
})
|
|
@@ -129,17 +130,17 @@ class C extends m {
|
|
|
129
130
|
), this.disposeWithMe(
|
|
130
131
|
this.registerEventHandler(
|
|
131
132
|
this.Event.SheetNoteShow,
|
|
132
|
-
() =>
|
|
133
|
-
if (e.type === "update" && e.oldNote && e.
|
|
134
|
-
const { unitId:
|
|
135
|
-
if (!
|
|
133
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
134
|
+
if (e.type === "update" && e.oldNote && e.newNote && !e.oldNote.show && e.newNote.show) {
|
|
135
|
+
const { unitId: s, subUnitId: r, newNote: t } = e, o = this.getSheetTarget(s, r);
|
|
136
|
+
if (!o)
|
|
136
137
|
return;
|
|
137
|
-
const { workbook:
|
|
138
|
+
const { workbook: d, worksheet: i } = o;
|
|
138
139
|
this.fireEvent(this.Event.SheetNoteShow, {
|
|
139
|
-
workbook:
|
|
140
|
-
worksheet:
|
|
141
|
-
row:
|
|
142
|
-
col:
|
|
140
|
+
workbook: d,
|
|
141
|
+
worksheet: i,
|
|
142
|
+
row: t.row,
|
|
143
|
+
col: t.col
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
})
|
|
@@ -147,17 +148,17 @@ class C extends m {
|
|
|
147
148
|
), this.disposeWithMe(
|
|
148
149
|
this.registerEventHandler(
|
|
149
150
|
this.Event.SheetNoteHide,
|
|
150
|
-
() =>
|
|
151
|
-
if (e.type === "update" && e.oldNote && e.
|
|
152
|
-
const { unitId:
|
|
153
|
-
if (!
|
|
151
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
152
|
+
if (e.type === "update" && e.oldNote && e.newNote && e.oldNote.show && !e.newNote.show) {
|
|
153
|
+
const { unitId: s, subUnitId: r, newNote: t } = e, o = this.getSheetTarget(s, r);
|
|
154
|
+
if (!o)
|
|
154
155
|
return;
|
|
155
|
-
const { workbook:
|
|
156
|
+
const { workbook: d, worksheet: i } = o;
|
|
156
157
|
this.fireEvent(this.Event.SheetNoteHide, {
|
|
157
|
-
workbook:
|
|
158
|
-
worksheet:
|
|
159
|
-
row:
|
|
160
|
-
col:
|
|
158
|
+
workbook: d,
|
|
159
|
+
worksheet: i,
|
|
160
|
+
row: t.row,
|
|
161
|
+
col: t.col
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
164
|
})
|
|
@@ -167,20 +168,17 @@ class C extends m {
|
|
|
167
168
|
this.Event.BeforeSheetNoteAdd,
|
|
168
169
|
() => a.beforeCommandExecuted((h) => {
|
|
169
170
|
if (h.id === f.id) {
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
if (!d)
|
|
174
|
-
return;
|
|
175
|
-
const { workbook: l, worksheet: S } = d;
|
|
171
|
+
const { unitId: e, sheetId: s, row: r, col: t, note: o } = h.params, d = this.getSheetTarget(e, s);
|
|
172
|
+
if (!d || n.get(c).getNote(e, s, { noteId: o.id, row: r, col: t })) return;
|
|
173
|
+
const { workbook: S, worksheet: u } = d;
|
|
176
174
|
if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
|
|
177
|
-
workbook:
|
|
178
|
-
worksheet:
|
|
175
|
+
workbook: S,
|
|
176
|
+
worksheet: u,
|
|
179
177
|
row: r,
|
|
180
|
-
col:
|
|
181
|
-
note:
|
|
178
|
+
col: t,
|
|
179
|
+
note: o
|
|
182
180
|
}))
|
|
183
|
-
throw new
|
|
181
|
+
throw new g();
|
|
184
182
|
}
|
|
185
183
|
})
|
|
186
184
|
)
|
|
@@ -188,21 +186,20 @@ class C extends m {
|
|
|
188
186
|
this.registerEventHandler(
|
|
189
187
|
this.Event.BeforeSheetNoteDelete,
|
|
190
188
|
() => a.beforeCommandExecuted((h) => {
|
|
191
|
-
if (h.id ===
|
|
192
|
-
const
|
|
193
|
-
if (!
|
|
194
|
-
const
|
|
195
|
-
if (!
|
|
196
|
-
|
|
197
|
-
const { workbook: d, worksheet: l } = n;
|
|
189
|
+
if (h.id === x.id) {
|
|
190
|
+
const { unitId: e, sheetId: s, row: r, col: t } = h.params, o = this.getSheetTarget(e, s);
|
|
191
|
+
if (!o || r === void 0 || t === void 0) return;
|
|
192
|
+
const i = n.get(c).getNote(e, s, { row: r, col: t });
|
|
193
|
+
if (!i) return;
|
|
194
|
+
const { workbook: l, worksheet: S } = o;
|
|
198
195
|
if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
|
|
199
|
-
workbook:
|
|
200
|
-
worksheet:
|
|
196
|
+
workbook: l,
|
|
197
|
+
worksheet: S,
|
|
201
198
|
row: r,
|
|
202
|
-
col:
|
|
203
|
-
oldNote:
|
|
199
|
+
col: t,
|
|
200
|
+
oldNote: i
|
|
204
201
|
}))
|
|
205
|
-
throw new
|
|
202
|
+
throw new g();
|
|
206
203
|
}
|
|
207
204
|
})
|
|
208
205
|
)
|
|
@@ -211,21 +208,20 @@ class C extends m {
|
|
|
211
208
|
this.Event.BeforeSheetNoteUpdate,
|
|
212
209
|
() => a.beforeCommandExecuted((h) => {
|
|
213
210
|
if (h.id === f.id) {
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
216
|
-
const
|
|
217
|
-
if (!
|
|
218
|
-
|
|
219
|
-
const { workbook: l, worksheet: S } = d;
|
|
211
|
+
const { unitId: e, sheetId: s, row: r, col: t, note: o } = h.params, d = this.getSheetTarget(e, s);
|
|
212
|
+
if (!d) return;
|
|
213
|
+
const l = n.get(c).getNote(e, s, { row: r, col: t });
|
|
214
|
+
if (!l) return;
|
|
215
|
+
const { workbook: S, worksheet: u } = d;
|
|
220
216
|
if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
|
|
221
|
-
workbook:
|
|
222
|
-
worksheet:
|
|
217
|
+
workbook: S,
|
|
218
|
+
worksheet: u,
|
|
223
219
|
row: r,
|
|
224
|
-
col:
|
|
225
|
-
note:
|
|
226
|
-
oldNote:
|
|
220
|
+
col: t,
|
|
221
|
+
note: o,
|
|
222
|
+
oldNote: l
|
|
227
223
|
}))
|
|
228
|
-
throw new
|
|
224
|
+
throw new g();
|
|
229
225
|
}
|
|
230
226
|
})
|
|
231
227
|
)
|
|
@@ -233,20 +229,24 @@ class C extends m {
|
|
|
233
229
|
this.registerEventHandler(
|
|
234
230
|
this.Event.BeforeSheetNoteShow,
|
|
235
231
|
() => a.beforeCommandExecuted((h) => {
|
|
236
|
-
if (h.id ===
|
|
237
|
-
const e =
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
if (!
|
|
241
|
-
|
|
242
|
-
|
|
232
|
+
if (h.id === m.id) {
|
|
233
|
+
const e = E(n.get(v));
|
|
234
|
+
if (!e) return;
|
|
235
|
+
const { unitId: s, subUnitId: r } = e, t = this.getUniverSheet(s);
|
|
236
|
+
if (!t) return;
|
|
237
|
+
const o = t.getSheetBySheetId(r);
|
|
238
|
+
if (!o) return;
|
|
239
|
+
const i = n.get(p).getCurrentLastSelection();
|
|
240
|
+
if (!(i != null && i.primary)) return;
|
|
241
|
+
const l = n.get(c), { actualColumn: S, actualRow: u } = i.primary, N = l.getNote(s, r, { row: u, col: S });
|
|
242
|
+
if (!N || N.show) return;
|
|
243
243
|
if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
|
|
244
|
-
workbook:
|
|
245
|
-
worksheet:
|
|
246
|
-
row:
|
|
247
|
-
col:
|
|
244
|
+
workbook: t,
|
|
245
|
+
worksheet: o,
|
|
246
|
+
row: u,
|
|
247
|
+
col: S
|
|
248
248
|
}))
|
|
249
|
-
throw new
|
|
249
|
+
throw new g();
|
|
250
250
|
}
|
|
251
251
|
})
|
|
252
252
|
)
|
|
@@ -254,43 +254,41 @@ class C extends m {
|
|
|
254
254
|
this.registerEventHandler(
|
|
255
255
|
this.Event.BeforeSheetNoteHide,
|
|
256
256
|
() => a.beforeCommandExecuted((h) => {
|
|
257
|
-
if (h.id ===
|
|
258
|
-
const e =
|
|
259
|
-
if (!
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
262
|
-
|
|
263
|
-
|
|
257
|
+
if (h.id === m.id) {
|
|
258
|
+
const e = E(n.get(v));
|
|
259
|
+
if (!e) return;
|
|
260
|
+
const { unitId: s, subUnitId: r } = e, t = this.getUniverSheet(s);
|
|
261
|
+
if (!t) return;
|
|
262
|
+
const o = t.getSheetBySheetId(r);
|
|
263
|
+
if (!o) return;
|
|
264
|
+
const i = n.get(p).getCurrentLastSelection();
|
|
265
|
+
if (!(i != null && i.primary)) return;
|
|
266
|
+
const l = n.get(c), { actualColumn: S, actualRow: u } = i.primary, N = l.getNote(s, r, { row: u, col: S });
|
|
267
|
+
if (!N || !N.show) return;
|
|
264
268
|
if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
|
|
265
|
-
workbook:
|
|
266
|
-
worksheet:
|
|
267
|
-
row:
|
|
268
|
-
col:
|
|
269
|
+
workbook: t,
|
|
270
|
+
worksheet: o,
|
|
271
|
+
row: u,
|
|
272
|
+
col: S
|
|
269
273
|
}))
|
|
270
|
-
throw new
|
|
274
|
+
throw new g();
|
|
271
275
|
}
|
|
272
276
|
})
|
|
273
277
|
)
|
|
274
278
|
);
|
|
275
279
|
}
|
|
276
280
|
}
|
|
277
|
-
|
|
278
|
-
class
|
|
281
|
+
I.extend(T);
|
|
282
|
+
class A extends b {
|
|
279
283
|
getNotes() {
|
|
280
|
-
const a = this._injector.get(
|
|
281
|
-
return a
|
|
282
|
-
h.push({
|
|
283
|
-
...o,
|
|
284
|
-
row: e,
|
|
285
|
-
col: t
|
|
286
|
-
});
|
|
287
|
-
}), h;
|
|
284
|
+
const a = this._injector.get(c).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId());
|
|
285
|
+
return a ? Array.from(a.values()).map((h) => ({ ...h })) : [];
|
|
288
286
|
}
|
|
289
287
|
}
|
|
290
|
-
|
|
288
|
+
b.extend(A);
|
|
291
289
|
export {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
y as FSheetNoteEvent,
|
|
291
|
+
W as FSheetsNoteRangeMixin,
|
|
292
|
+
A as FSheetsNoteWorksheet,
|
|
293
|
+
T as FUniverSheetNoteMixin
|
|
296
294
|
};
|