@univerjs/sheets-note 0.10.4 → 0.10.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/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.UniverSheetsNoteFacade={},l.UniverCoreFacade,l.UniverSheetsNote,l.UniverSheetsFacade,l.UniverCore))})(this,function(l,m,h,f,g){"use strict";class w{get SheetNoteAdd(){return"SheetNoteAdd"}get SheetNoteDelete(){return"SheetNoteDelete"}get SheetNoteUpdate(){return"SheetNoteUpdate"}get SheetNoteShow(){return"SheetNoteShow"}get SheetNoteHide(){return"SheetNoteHide"}get BeforeSheetNoteAdd(){return"BeforeSheetNoteAdd"}get BeforeSheetNoteDelete(){return"BeforeSheetNoteDelete"}get BeforeSheetNoteUpdate(){return"BeforeSheetNoteUpdate"}get BeforeSheetNoteShow(){return"BeforeSheetNoteShow"}get BeforeSheetNoteHide(){return"BeforeSheetNoteHide"}}m.FEventName.extend(w);class E extends f.FRange{createOrUpdateNote(c){return this._commandService.syncExecuteCommand(h.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:c}),this}deleteNote(){return this._commandService.syncExecuteCommand(h.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(h.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}f.FRange.extend(E);class I extends m.FUniver{_initialize(c){this.registerEventHandler(this.Event.SheetNoteAdd,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:S,worksheet:a,row:o,col:i,note:r})}})),this.registerEventHandler(this.Event.SheetNoteDelete,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:S,worksheet:a,row:o,col:i,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteUpdate,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:a,row:o,col:i,note:r,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteShow,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.SheetNoteHide,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params;if(d.getNote(t,o,i,r))return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:a,worksheet:v,row:i,col:r,note:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetDeleteNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!s)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:S,worksheet:a,row:i,col:r,oldNote:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params,n=d.getNote(t,o,i,r);if(!n)return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:a,worksheet:v,row:i,col:r,note:s,oldNote:n}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(s!=null&&s.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!(s!=null&&s.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}}))}}m.FUniver.extend(I);class k extends f.FWorksheet{getNotes(){const u=this._injector.get(h.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),e=[];return u==null||u.forValue((d,t,o)=>{e.push({...o,row:d,col:t})}),e}}f.FWorksheet.extend(k),l.FSheetNoteEvent=w,l.FSheetsNoteRangeMixin=E,l.FSheetsNoteWorksheet=k,l.FUniverSheetNoteMixin=I,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.UniverSheetsNoteFacade={},l.UniverCoreFacade,l.UniverSheetsNote,l.UniverSheetsFacade,l.UniverCore))})(this,(function(l,m,h,f,g){"use strict";class w{get SheetNoteAdd(){return"SheetNoteAdd"}get SheetNoteDelete(){return"SheetNoteDelete"}get SheetNoteUpdate(){return"SheetNoteUpdate"}get SheetNoteShow(){return"SheetNoteShow"}get SheetNoteHide(){return"SheetNoteHide"}get BeforeSheetNoteAdd(){return"BeforeSheetNoteAdd"}get BeforeSheetNoteDelete(){return"BeforeSheetNoteDelete"}get BeforeSheetNoteUpdate(){return"BeforeSheetNoteUpdate"}get BeforeSheetNoteShow(){return"BeforeSheetNoteShow"}get BeforeSheetNoteHide(){return"BeforeSheetNoteHide"}}m.FEventName.extend(w);class E extends f.FRange{createOrUpdateNote(c){return this._commandService.syncExecuteCommand(h.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:c}),this}deleteNote(){return this._commandService.syncExecuteCommand(h.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(h.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}f.FRange.extend(E);class I extends m.FUniver{_initialize(c){this.registerEventHandler(this.Event.SheetNoteAdd,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:S,worksheet:a,row:o,col:i,note:r})}})),this.registerEventHandler(this.Event.SheetNoteDelete,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:S,worksheet:a,row:o,col:i,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteUpdate,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:a,row:o,col:i,note:r,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteShow,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.SheetNoteHide,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params;if(d.getNote(t,o,i,r))return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:a,worksheet:v,row:i,col:r,note:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetDeleteNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!s)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:S,worksheet:a,row:i,col:r,oldNote:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params,n=d.getNote(t,o,i,r);if(!n)return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:a,worksheet:v,row:i,col:r,note:s,oldNote:n}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(s!=null&&s.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!(s!=null&&s.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}}))}}m.FUniver.extend(I);class k extends f.FWorksheet{getNotes(){const u=this._injector.get(h.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),e=[];return u==null||u.forValue((d,t,o)=>{e.push({...o,row:d,col:t})}),e}}f.FWorksheet.extend(k),l.FSheetNoteEvent=w,l.FSheetsNoteRangeMixin=E,l.FSheetsNoteWorksheet=k,l.FUniverSheetNoteMixin=I,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverSheetsNote={},u.UniverCore,u.UniverSheets,u.rxjs))})(this,function(u,a,l,p){"use strict";var z=Object.defineProperty;var F=(u,a,l)=>a in u?z(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var _=(u,a,l)=>F(u,typeof a!="symbol"?a+"":a,l);class g extends a.Disposable{constructor(){super(...arguments);_(this,"_noteMatrix",new Map);_(this,"_change$",new p.Subject);_(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(n,e){let t=this._noteMatrix.get(n);t||(t=new Map,this._noteMatrix.set(n,t));let s=t.get(e);return s||(s=new a.ObjectMatrix,t.set(e,s)),s}getSheetShowNotes$(n,e){return this._change$.pipe(p.filter(({unitId:t,sheetId:s})=>t===n&&s===e),p.map(()=>{const t=this._ensureNoteMatrix(n,e),s=[];return t.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:n,subUnitId:e},note:c})}),s}))}getCellNoteChange$(n,e,t,s){return this._change$.pipe(p.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===n&&h===e&&c===t&&d===s),p.map(({note:i})=>i))}updateNote(n,e,t,s,i,h){const c=this._ensureNoteMatrix(n,e),d=c.getValue(t,s);c.setValue(t,s,i),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);h.realDeleteValue(t,s),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(t,s,d),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(n,e,t,s,i,h,c){const d=this._ensureNoteMatrix(n,e),m=d.getValue(t,s);m&&(d.realDeleteValue(t,s),d.setValue(i,h,m),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"ref",newPosition:{row:i,col:h},note:m,silent:c}))}getNote(n,e,t,s){return this._ensureNoteMatrix(n,e).getValue(t,s)}getUnitNotes(n){return this._noteMatrix.get(n)}getSheetNotes(n,e){const t=this._noteMatrix.get(n);if(t)return t.get(e)}getNotes(){return this._noteMatrix}deleteUnitNotes(n){this._noteMatrix.delete(n)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,note:i,silent:h}=o;return r.get(g).updateNote(n,e,t,s,i,h),!0}},S={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).removeNote(n,e,t,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).toggleNotePopup(n,e,t,s,i),!0}},v={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,silent:h}=o;return r.get(g).updateNotePosition(n,e,t,s,i.row,i.col,h),!0}},P={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(S.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},y={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(I.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},R={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,o)=>r.get(a.ICommandService).syncExecuteCommand(N.id,o)},U="SHEET_NOTE_PLUGIN";var $=Object.getOwnPropertyDescriptor,D=(r,o,n,e)=>{for(var t=e>1?void 0:e?$(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},w=(r,o)=>(n,e)=>o(n,e,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,n,e){super(),this._resourceManagerService=o,this._univerInstanceService=n,this._sheetsNoteModel=e,this._initSnapshot()}_initSnapshot(){const o=e=>{const t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return"";const s={};return t.forEach((i,h)=>{const c={};i.forValue((d,m,H)=>{c[d]||(c[d]={}),c[d][m]=H}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>o(e),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,m])=>{this._sheetsNoteModel.updateNote(e,s,Number(h),Number(d),m)})})})}}))}},u.SheetsNoteResourceController=D([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(g))],u.SheetsNoteResourceController);const j="sheets-note.config",O={};var E=Object.getOwnPropertyDescriptor,x=(r,o,n,e)=>{for(var t=e>1?void 0:e?E(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},f=(r,o)=>(n,e)=>o(n,e,r);let M=class extends a.Disposable{constructor(o,n,e,t){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(o,n,e,t,s,i,h)=>i?{redos:[{id:v.id,params:{unitId:o,sheetId:n,row:t,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:v.id,params:{unitId:o,sheetId:n,row:i.startRow,col:i.startColumn,newPosition:{row:t,col:s},note:e,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:n,row:t,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:n,row:t,col:s,note:e}}]});this._refRangeService=o,this._sheetsNoteModel=n,this._selectionManagerService=e,this._commandService=t,this._initData(),this._initRefRange()}_getIdWithUnitId(o,n,e,t){return`${o}-${n}-${e}-${t}`}_register(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._disposableMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===i.startColumn&&d.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,n,e,t,s,d,!1)},o,n))}_watch(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._watcherMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.watchRange(o,n,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,n,e,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[n,e]of o)for(const[t,s]of e)s.forValue((i,h,c)=>(c&&(this._register(n,t,c,i,h),this._watch(n,t,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:n,sheetId:e,row:t,col:s,note:i}=o,h=this._getIdWithUnitId(n,e,t,s);i?this._disposableMap.has(h)||(this._register(n,e,i,t,s),this._watch(n,e,i,t,s)):(this._unregister(n,e,t,s),this._unwatch(n,e,t,s));break}case"ref":{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(n,e,t,s),c||(this._unwatch(n,e,t,s),this._watch(n,e,h,i.row,i.col)),this._register(n,e,h,i.row,i.col);break}}}))}};M=x([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(g)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var V=Object.getOwnPropertyDescriptor,A=(r,o,n,e)=>{for(var t=e>1?void 0:e?V(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},W=(r,o)=>(n,e)=>o(n,e,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[v,I,N,S,P,y,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=A([W(0,a.ICommandService)],C);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(r,o,n)=>o in r?L(r,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[o]=n,G=(r,o,n,e)=>{for(var t=e>1?void 0:e?J(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},T=(r,o)=>(n,e)=>o(n,e,r),b=(r,o,n)=>q(r,typeof o!="symbol"?o+"":o,n);u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o=O,n,e){super(),this._config=o,this._configService=n,this._injector=e;const{...t}=a.merge({},O,this._config);this._configService.setConfig(j,t)}onStarting(){[[g],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[g],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},b(u.UniverSheetsNotePlugin,"pluginName",U),b(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=G([a.DependentOn(l.UniverSheetsPlugin),T(1,a.IConfigService),T(2,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=S,u.SheetDeleteNoteCommand=P,u.SheetToggleNotePopupCommand=y,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=g,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=v,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverSheetsNote={},u.UniverCore,u.UniverSheets,u.rxjs))})(this,(function(u,a,l,p){"use strict";var z=Object.defineProperty;var F=(u,a,l)=>a in u?z(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var _=(u,a,l)=>F(u,typeof a!="symbol"?a+"":a,l);class g extends a.Disposable{constructor(){super(...arguments);_(this,"_noteMatrix",new Map);_(this,"_change$",new p.Subject);_(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(n,e){let t=this._noteMatrix.get(n);t||(t=new Map,this._noteMatrix.set(n,t));let s=t.get(e);return s||(s=new a.ObjectMatrix,t.set(e,s)),s}getSheetShowNotes$(n,e){return this._change$.pipe(p.filter(({unitId:t,sheetId:s})=>t===n&&s===e),p.map(()=>{const t=this._ensureNoteMatrix(n,e),s=[];return t.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:n,subUnitId:e},note:c})}),s}))}getCellNoteChange$(n,e,t,s){return this._change$.pipe(p.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===n&&h===e&&c===t&&d===s),p.map(({note:i})=>i))}updateNote(n,e,t,s,i,h){const c=this._ensureNoteMatrix(n,e),d=c.getValue(t,s);c.setValue(t,s,i),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);h.realDeleteValue(t,s),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(t,s,d),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(n,e,t,s,i,h,c){const d=this._ensureNoteMatrix(n,e),m=d.getValue(t,s);m&&(d.realDeleteValue(t,s),d.setValue(i,h,m),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"ref",newPosition:{row:i,col:h},note:m,silent:c}))}getNote(n,e,t,s){return this._ensureNoteMatrix(n,e).getValue(t,s)}getUnitNotes(n){return this._noteMatrix.get(n)}getSheetNotes(n,e){const t=this._noteMatrix.get(n);if(t)return t.get(e)}getNotes(){return this._noteMatrix}deleteUnitNotes(n){this._noteMatrix.delete(n)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,note:i,silent:h}=o;return r.get(g).updateNote(n,e,t,s,i,h),!0}},S={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).removeNote(n,e,t,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).toggleNotePopup(n,e,t,s,i),!0}},v={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,silent:h}=o;return r.get(g).updateNotePosition(n,e,t,s,i.row,i.col,h),!0}},P={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(S.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},y={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(I.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},R={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,o)=>r.get(a.ICommandService).syncExecuteCommand(N.id,o)},U="SHEET_NOTE_PLUGIN";var $=Object.getOwnPropertyDescriptor,D=(r,o,n,e)=>{for(var t=e>1?void 0:e?$(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},w=(r,o)=>(n,e)=>o(n,e,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,n,e){super(),this._resourceManagerService=o,this._univerInstanceService=n,this._sheetsNoteModel=e,this._initSnapshot()}_initSnapshot(){const o=e=>{const t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return"";const s={};return t.forEach((i,h)=>{const c={};i.forValue((d,m,H)=>{c[d]||(c[d]={}),c[d][m]=H}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>o(e),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,m])=>{this._sheetsNoteModel.updateNote(e,s,Number(h),Number(d),m)})})})}}))}},u.SheetsNoteResourceController=D([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(g))],u.SheetsNoteResourceController);const j="sheets-note.config",O={};var E=Object.getOwnPropertyDescriptor,x=(r,o,n,e)=>{for(var t=e>1?void 0:e?E(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},f=(r,o)=>(n,e)=>o(n,e,r);let M=class extends a.Disposable{constructor(o,n,e,t){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(o,n,e,t,s,i,h)=>i?{redos:[{id:v.id,params:{unitId:o,sheetId:n,row:t,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:v.id,params:{unitId:o,sheetId:n,row:i.startRow,col:i.startColumn,newPosition:{row:t,col:s},note:e,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:n,row:t,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:n,row:t,col:s,note:e}}]});this._refRangeService=o,this._sheetsNoteModel=n,this._selectionManagerService=e,this._commandService=t,this._initData(),this._initRefRange()}_getIdWithUnitId(o,n,e,t){return`${o}-${n}-${e}-${t}`}_register(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._disposableMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===i.startColumn&&d.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,n,e,t,s,d,!1)},o,n))}_watch(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._watcherMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.watchRange(o,n,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,n,e,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[n,e]of o)for(const[t,s]of e)s.forValue((i,h,c)=>(c&&(this._register(n,t,c,i,h),this._watch(n,t,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:n,sheetId:e,row:t,col:s,note:i}=o,h=this._getIdWithUnitId(n,e,t,s);i?this._disposableMap.has(h)||(this._register(n,e,i,t,s),this._watch(n,e,i,t,s)):(this._unregister(n,e,t,s),this._unwatch(n,e,t,s));break}case"ref":{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(n,e,t,s),c||(this._unwatch(n,e,t,s),this._watch(n,e,h,i.row,i.col)),this._register(n,e,h,i.row,i.col);break}}}))}};M=x([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(g)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var V=Object.getOwnPropertyDescriptor,A=(r,o,n,e)=>{for(var t=e>1?void 0:e?V(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},W=(r,o)=>(n,e)=>o(n,e,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[v,I,N,S,P,y,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=A([W(0,a.ICommandService)],C);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(r,o,n)=>o in r?L(r,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[o]=n,G=(r,o,n,e)=>{for(var t=e>1?void 0:e?J(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},T=(r,o)=>(n,e)=>o(n,e,r),b=(r,o,n)=>q(r,typeof o!="symbol"?o+"":o,n);u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o=O,n,e){super(),this._config=o,this._configService=n,this._injector=e;const{...t}=a.merge({},O,this._config);this._configService.setConfig(j,t)}onStarting(){[[g],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[g],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},b(u.UniverSheetsNotePlugin,"pluginName",U),b(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=G([a.DependentOn(l.UniverSheetsPlugin),T(1,a.IConfigService),T(2,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=S,u.SheetDeleteNoteCommand=P,u.SheetToggleNotePopupCommand=y,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=g,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=v,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-note",
3
- "version": "0.10.4",
3
+ "version": "0.10.5",
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/core": "0.10.4",
60
- "@univerjs/sheets": "0.10.4"
59
+ "@univerjs/sheets": "0.10.5",
60
+ "@univerjs/core": "0.10.5"
61
61
  },
62
62
  "devDependencies": {
63
63
  "rxjs": "^7.8.2",
64
- "typescript": "^5.8.3",
65
- "vite": "^7.0.6",
64
+ "typescript": "^5.9.2",
65
+ "vite": "^7.1.3",
66
66
  "vitest": "^3.2.4",
67
- "@univerjs-infra/shared": "0.10.4"
67
+ "@univerjs-infra/shared": "0.10.5"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",