@univerjs/sheets-note 0.8.2-nightly.202506261607 → 0.8.3-nightly.202506271607

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/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var $=(i,o,e)=>o in i?b(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var p=(i,o,e)=>$(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),g=require("@univerjs/sheets"),m=require("rxjs"),R="SHEET_NOTE_PLUGIN",D="sheets-note.config",w={};class l extends h.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new m.Subject);p(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let s=this._noteMatrix.get(e);s||(s=new Map,this._noteMatrix.set(e,s));let n=s.get(t);return n||(n=new h.ObjectMatrix,s.set(t,n)),n}getSheetShowNotes$(e,t){return this._change$.pipe(m.filter(({unitId:s,sheetId:n})=>s===e&&n===t),m.map(()=>{const s=this._ensureNoteMatrix(e,t),n=[];return s.forValue((r,a,c)=>{c.show&&n.push({loc:{row:r,col:a,unitId:e,subUnitId:t},note:c})}),n}))}getCellNoteChange$(e,t,s,n){return this._change$.pipe(m.filter(({unitId:r,sheetId:a,row:c,col:u})=>r===e&&a===t&&c===s&&u===n),m.map(({note:r})=>r))}updateNote(e,t,s,n,r,a){const c=this._ensureNoteMatrix(e,t),u=c.getValue(s,n);c.setValue(s,n,r),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:r,oldNote:u,silent:a})}removeNote(e,t,s,n,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,n);a.realDeleteValue(s,n),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:null,oldNote:c,silent:r})}toggleNotePopup(e,t,s,n,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,n);if(c){c.show=!c.show;const u={...c,show:c.show};a.setValue(s,n,u),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:u,oldNote:c,silent:r})}}updateNotePosition(e,t,s,n,r,a,c){const u=this._ensureNoteMatrix(e,t),d=u.getValue(s,n);d&&(u.realDeleteValue(s,n),u.setValue(r,a,d),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"ref",newPosition:{row:r,col:a},note:d,silent:c}))}getNote(e,t,s,n){return this._ensureNoteMatrix(e,t).getValue(s,n)}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,o)=>{const{unitId:e,sheetId:t,row:s,col:n,note:r,silent:a}=o;return i.get(l).updateNote(e,t,s,n,r,a),!0}},f={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,silent:r}=o;return i.get(l).removeNote(e,t,s,n,r),!0}},I={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,silent:r}=o;return i.get(l).toggleNotePopup(e,t,s,n,r),!0}},N={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,newPosition:r,silent:a}=o;return i.get(l).updateNotePosition(e,t,s,n,r.row,r.col,a),!0}};var E=Object.getOwnPropertyDescriptor,j=(i,o,e,t)=>{for(var s=t>1?void 0:t?E(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},_=(i,o)=>(e,t)=>o(e,t,i);let S=class extends h.Disposable{constructor(o,e,t,s){super();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(this,"_handleRangeChange",(o,e,t,s,n,r,a)=>r?{redos:[{id:N.id,params:{unitId:o,sheetId:e,row:s,col:n,newPosition:{row:r.startRow,col:r.startColumn},silent:a}}],undos:[{id:N.id,params:{unitId:o,sheetId:e,row:r.startRow,col:r.startColumn,newPosition:{row:s,col:n},note:t,silent:a}}]}:{redos:[{id:f.id,params:{unitId:o,sheetId:e,row:s,col:n}}],undos:[{id:M.id,params:{unitId:o,sheetId:e,row:s,col:n,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(o,e,t,s){return`${o}-${e}-${t}-${s}`}_register(o,e,t,s,n){const r={startColumn:n,endColumn:n,startRow:s,endRow:s};this._disposableMap.set(this._getIdWithUnitId(o,e,s,n),this._refRangeService.registerRefRange(r,a=>{const c=g.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(o,e,t,s,n,u,!1)},o,e))}_watch(o,e,t,s,n){const r={startColumn:n,endColumn:n,startRow:s,endRow:s};this._watcherMap.set(this._getIdWithUnitId(o,e,s,n),this._refRangeService.watchRange(o,e,r,(a,c)=>{const{redos:u}=this._handleRangeChange(o,e,t,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,e,t,s){var r;const n=this._getIdWithUnitId(o,e,t,s);(r=this._watcherMap.get(n))==null||r.dispose(),this._watcherMap.delete(n)}_unregister(o,e,t,s){var r;const n=this._getIdWithUnitId(o,e,t,s);(r=this._disposableMap.get(n))==null||r.dispose(),this._disposableMap.delete(n)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[e,t]of o)for(const[s,n]of t)n.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(o=>{switch(o.type){case"update":{const{unitId:e,sheetId:t,row:s,col:n,note:r}=o,a=this._getIdWithUnitId(e,t,s,n);r?this._disposableMap.has(a)||(this._register(e,t,r,s,n),this._watch(e,t,r,s,n)):(this._unregister(e,t,s,n),this._unwatch(e,t,s,n));break}case"ref":{const{unitId:e,sheetId:t,row:s,col:n,newPosition:r,note:a,silent:c}=o;this._unregister(e,t,s,n),c||(this._unwatch(e,t,s,n),this._watch(e,t,a,r.row,r.col)),this._register(e,t,a,r.row,r.col);break}}}))}};S=j([_(0,h.Inject(g.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(g.SheetsSelectionsService)),_(3,h.ICommandService)],S);var V=Object.getOwnPropertyDescriptor,A=(i,o,e,t)=>{for(var s=t>1?void 0:t?V(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},C=(i,o)=>(e,t)=>o(e,t,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(o,e,t){super(),this._resourceManagerService=o,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const o=t=>{const s=this._sheetsNoteModel.getUnitNotes(t);if(!s)return"";const n={};return s.forEach((r,a)=>{const c={};r.forValue((u,d,T)=>{c[u]||(c[u]={}),c[u][d]=T}),Object.keys(c).length>0&&(n[a]=c)}),JSON.stringify(n)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:R,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,s)=>{Object.entries(s).forEach(([n,r])=>{Object.entries(r).forEach(([a,c])=>{Object.entries(c).forEach(([u,d])=>{this._sheetsNoteModel.updateNote(t,n,Number(a),Number(u),d)})})})}}))}};exports.SheetsNoteResourceController=A([C(0,h.IResourceManagerService),C(1,h.IUniverInstanceService),C(2,h.Inject(l))],exports.SheetsNoteResourceController);const y={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=g.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.primary;return i.get(h.ICommandService).executeCommand(f.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},x={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=g.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.primary;return i.get(h.ICommandService).executeCommand(I.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},U={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,o)=>i.get(h.ICommandService).syncExecuteCommand(M.id,o)};var W=Object.getOwnPropertyDescriptor,L=(i,o,e,t)=>{for(var s=t>1?void 0:t?W(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},J=(i,o)=>(e,t)=>o(e,t,i);let v=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[N,I,M,f,y,x,U].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};v=L([J(0,h.ICommandService)],v);var q=Object.defineProperty,G=Object.getOwnPropertyDescriptor,H=(i,o,e)=>o in i?q(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e,z=(i,o,e,t)=>{for(var s=t>1?void 0:t?G(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},P=(i,o)=>(e,t)=>o(e,t,i),O=(i,o,e)=>H(i,typeof o!="symbol"?o+"":o,e);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(o=w,e,t){super(),this._config=o,this._configService=e,this._injector=t;const{...s}=h.merge({},w,this._config);this._configService.setConfig(D,s)}onStarting(){[[l],[v],[exports.SheetsNoteResourceController],[S]].forEach(o=>{this._injector.add(o)}),h.touchDependencies(this._injector,[[l],[v],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[S]])}};O(exports.UniverSheetsNotePlugin,"pluginName",R);O(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=z([h.DependentOn(g.UniverSheetsPlugin),P(1,h.IConfigService),P(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=y;exports.SheetToggleNotePopupCommand=x;exports.SheetUpdateNoteCommand=U;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
1
+ "use strict";var b=Object.defineProperty;var $=(i,o,e)=>o in i?b(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var p=(i,o,e)=>$(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),g=require("@univerjs/sheets"),m=require("rxjs");class l extends h.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new m.Subject);p(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let s=this._noteMatrix.get(e);s||(s=new Map,this._noteMatrix.set(e,s));let n=s.get(t);return n||(n=new h.ObjectMatrix,s.set(t,n)),n}getSheetShowNotes$(e,t){return this._change$.pipe(m.filter(({unitId:s,sheetId:n})=>s===e&&n===t),m.map(()=>{const s=this._ensureNoteMatrix(e,t),n=[];return s.forValue((r,a,c)=>{c.show&&n.push({loc:{row:r,col:a,unitId:e,subUnitId:t},note:c})}),n}))}getCellNoteChange$(e,t,s,n){return this._change$.pipe(m.filter(({unitId:r,sheetId:a,row:c,col:u})=>r===e&&a===t&&c===s&&u===n),m.map(({note:r})=>r))}updateNote(e,t,s,n,r,a){const c=this._ensureNoteMatrix(e,t),u=c.getValue(s,n);c.setValue(s,n,r),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:r,oldNote:u,silent:a})}removeNote(e,t,s,n,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,n);a.realDeleteValue(s,n),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:null,oldNote:c,silent:r})}toggleNotePopup(e,t,s,n,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,n);if(c){c.show=!c.show;const u={...c,show:c.show};a.setValue(s,n,u),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:u,oldNote:c,silent:r})}}updateNotePosition(e,t,s,n,r,a,c){const u=this._ensureNoteMatrix(e,t),d=u.getValue(s,n);d&&(u.realDeleteValue(s,n),u.setValue(r,a,d),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"ref",newPosition:{row:r,col:a},note:d,silent:c}))}getNote(e,t,s,n){return this._ensureNoteMatrix(e,t).getValue(s,n)}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,o)=>{const{unitId:e,sheetId:t,row:s,col:n,note:r,silent:a}=o;return i.get(l).updateNote(e,t,s,n,r,a),!0}},f={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,silent:r}=o;return i.get(l).removeNote(e,t,s,n,r),!0}},I={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,silent:r}=o;return i.get(l).toggleNotePopup(e,t,s,n,r),!0}},N={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,newPosition:r,silent:a}=o;return i.get(l).updateNotePosition(e,t,s,n,r.row,r.col,a),!0}},R={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=g.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.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,o)=>{const e=i.get(h.IUniverInstanceService),t=g.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.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,o)=>i.get(h.ICommandService).syncExecuteCommand(M.id,o)},U="SHEET_NOTE_PLUGIN";var D=Object.getOwnPropertyDescriptor,E=(i,o,e,t)=>{for(var s=t>1?void 0:t?D(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},C=(i,o)=>(e,t)=>o(e,t,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(o,e,t){super(),this._resourceManagerService=o,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const o=t=>{const s=this._sheetsNoteModel.getUnitNotes(t);if(!s)return"";const n={};return s.forEach((r,a)=>{const c={};r.forValue((u,d,T)=>{c[u]||(c[u]={}),c[u][d]=T}),Object.keys(c).length>0&&(n[a]=c)}),JSON.stringify(n)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,s)=>{Object.entries(s).forEach(([n,r])=>{Object.entries(r).forEach(([a,c])=>{Object.entries(c).forEach(([u,d])=>{this._sheetsNoteModel.updateNote(t,n,Number(a),Number(u),d)})})})}}))}};exports.SheetsNoteResourceController=E([C(0,h.IResourceManagerService),C(1,h.IUniverInstanceService),C(2,h.Inject(l))],exports.SheetsNoteResourceController);const j="sheets-note.config",w={};var V=Object.getOwnPropertyDescriptor,A=(i,o,e,t)=>{for(var s=t>1?void 0:t?V(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},_=(i,o)=>(e,t)=>o(e,t,i);let S=class extends h.Disposable{constructor(o,e,t,s){super();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(this,"_handleRangeChange",(o,e,t,s,n,r,a)=>r?{redos:[{id:N.id,params:{unitId:o,sheetId:e,row:s,col:n,newPosition:{row:r.startRow,col:r.startColumn},silent:a}}],undos:[{id:N.id,params:{unitId:o,sheetId:e,row:r.startRow,col:r.startColumn,newPosition:{row:s,col:n},note:t,silent:a}}]}:{redos:[{id:f.id,params:{unitId:o,sheetId:e,row:s,col:n}}],undos:[{id:M.id,params:{unitId:o,sheetId:e,row:s,col:n,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(o,e,t,s){return`${o}-${e}-${t}-${s}`}_register(o,e,t,s,n){const r={startColumn:n,endColumn:n,startRow:s,endRow:s};this._disposableMap.set(this._getIdWithUnitId(o,e,s,n),this._refRangeService.registerRefRange(r,a=>{const c=g.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(o,e,t,s,n,u,!1)},o,e))}_watch(o,e,t,s,n){const r={startColumn:n,endColumn:n,startRow:s,endRow:s};this._watcherMap.set(this._getIdWithUnitId(o,e,s,n),this._refRangeService.watchRange(o,e,r,(a,c)=>{const{redos:u}=this._handleRangeChange(o,e,t,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,e,t,s){var r;const n=this._getIdWithUnitId(o,e,t,s);(r=this._watcherMap.get(n))==null||r.dispose(),this._watcherMap.delete(n)}_unregister(o,e,t,s){var r;const n=this._getIdWithUnitId(o,e,t,s);(r=this._disposableMap.get(n))==null||r.dispose(),this._disposableMap.delete(n)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[e,t]of o)for(const[s,n]of t)n.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(o=>{switch(o.type){case"update":{const{unitId:e,sheetId:t,row:s,col:n,note:r}=o,a=this._getIdWithUnitId(e,t,s,n);r?this._disposableMap.has(a)||(this._register(e,t,r,s,n),this._watch(e,t,r,s,n)):(this._unregister(e,t,s,n),this._unwatch(e,t,s,n));break}case"ref":{const{unitId:e,sheetId:t,row:s,col:n,newPosition:r,note:a,silent:c}=o;this._unregister(e,t,s,n),c||(this._unwatch(e,t,s,n),this._watch(e,t,a,r.row,r.col)),this._register(e,t,a,r.row,r.col);break}}}))}};S=A([_(0,h.Inject(g.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(g.SheetsSelectionsService)),_(3,h.ICommandService)],S);var W=Object.getOwnPropertyDescriptor,L=(i,o,e,t)=>{for(var s=t>1?void 0:t?W(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},J=(i,o)=>(e,t)=>o(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=L([J(0,h.ICommandService)],v);var q=Object.defineProperty,G=Object.getOwnPropertyDescriptor,H=(i,o,e)=>o in i?q(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e,z=(i,o,e,t)=>{for(var s=t>1?void 0:t?G(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},P=(i,o)=>(e,t)=>o(e,t,i),O=(i,o,e)=>H(i,typeof o!="symbol"?o+"":o,e);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(o=w,e,t){super(),this._config=o,this._configService=e,this._injector=t;const{...s}=h.merge({},w,this._config);this._configService.setConfig(j,s)}onStarting(){[[l],[v],[exports.SheetsNoteResourceController],[S]].forEach(o=>{this._injector.add(o)}),h.touchDependencies(this._injector,[[l],[v],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[S]])}};O(exports.UniverSheetsNotePlugin,"pluginName",U);O(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=z([h.DependentOn(g.UniverSheetsPlugin),P(1,h.IConfigService),P(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=R;exports.SheetToggleNotePopupCommand=y;exports.SheetUpdateNoteCommand=x;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
package/lib/es/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  var A = Object.defineProperty;
2
2
  var W = (i, o, e) => o in i ? A(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
3
  var d = (i, o, e) => W(i, typeof o != "symbol" ? o + "" : o, e);
4
- import { Disposable as S, ObjectMatrix as L, CommandType as l, Inject as g, ICommandService as p, sequenceExecuteAsync as J, IResourceManagerService as G, IUniverInstanceService as x, UniverInstanceType as U, DependentOn as H, IConfigService as z, Injector as F, Plugin as q, merge as K, touchDependencies as O } from "@univerjs/core";
5
- import { RefRangeService as Y, SheetsSelectionsService as I, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B, getSheetCommandTarget as D, UniverSheetsPlugin as Q } from "@univerjs/sheets";
4
+ import { Disposable as S, ObjectMatrix as L, CommandType as l, IUniverInstanceService as x, ICommandService as p, IResourceManagerService as J, Inject as g, UniverInstanceType as U, sequenceExecuteAsync as G, DependentOn as H, IConfigService as z, Injector as F, Plugin as q, merge as K, touchDependencies as O } from "@univerjs/core";
5
+ import { getSheetCommandTarget as D, SheetsSelectionsService as I, RefRangeService as Y, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B, UniverSheetsPlugin as Q } from "@univerjs/sheets";
6
6
  import { Subject as X, filter as y, map as $ } from "rxjs";
7
- const T = "SHEET_NOTE_PLUGIN", Z = "sheets-note.config", b = {};
8
7
  class u extends S {
9
8
  constructor() {
10
9
  super(...arguments);
@@ -105,7 +104,7 @@ const R = {
105
104
  const { unitId: e, sheetId: n, row: t, col: s, silent: r } = o;
106
105
  return i.get(u).removeNote(e, n, t, s, r), !0;
107
106
  }
108
- }, V = {
107
+ }, T = {
109
108
  id: "sheet.mutation.toggle-note-popup",
110
109
  type: l.MUTATION,
111
110
  handler: (i, o) => {
@@ -119,13 +118,113 @@ const R = {
119
118
  const { unitId: e, sheetId: n, row: t, col: s, newPosition: r, silent: a } = o;
120
119
  return i.get(u).updateNotePosition(e, n, t, s, r.row, r.col, a), !0;
121
120
  }
121
+ }, Z = {
122
+ id: "sheet.command.delete-note",
123
+ type: l.COMMAND,
124
+ handler: (i, o) => {
125
+ const e = i.get(x), n = D(e);
126
+ if (!n) return !1;
127
+ const s = i.get(I).getCurrentLastSelection();
128
+ if (!(s != null && s.primary)) return !1;
129
+ const { actualColumn: r, actualRow: a } = s.primary;
130
+ return i.get(p).executeCommand(P.id, {
131
+ unitId: n.unitId,
132
+ sheetId: n.subUnitId,
133
+ row: a,
134
+ col: r
135
+ });
136
+ }
137
+ }, k = {
138
+ id: "sheet.command.toggle-note-popup",
139
+ type: l.COMMAND,
140
+ handler: (i, o) => {
141
+ const e = i.get(x), n = D(e);
142
+ if (!n) return !1;
143
+ const s = i.get(I).getCurrentLastSelection();
144
+ if (!(s != null && s.primary)) return !1;
145
+ const { actualColumn: r, actualRow: a } = s.primary;
146
+ return i.get(p).executeCommand(T.id, {
147
+ unitId: n.unitId,
148
+ sheetId: n.subUnitId,
149
+ row: a,
150
+ col: r
151
+ });
152
+ }
153
+ }, ee = {
154
+ id: "sheet.command.update-note",
155
+ type: l.COMMAND,
156
+ handler: (i, o) => i.get(p).syncExecuteCommand(R.id, o)
157
+ }, V = "SHEET_NOTE_PLUGIN";
158
+ var te = Object.getOwnPropertyDescriptor, se = (i, o, e, n) => {
159
+ for (var t = n > 1 ? void 0 : n ? te(o, e) : o, s = i.length - 1, r; s >= 0; s--)
160
+ (r = i[s]) && (t = r(t) || t);
161
+ return t;
162
+ }, w = (i, o) => (e, n) => o(e, n, i);
163
+ let N = class extends S {
164
+ constructor(i, o, e) {
165
+ super(), this._resourceManagerService = i, this._univerInstanceService = o, this._sheetsNoteModel = e, this._initSnapshot();
166
+ }
167
+ _initSnapshot() {
168
+ const i = (e) => {
169
+ const n = this._sheetsNoteModel.getUnitNotes(e);
170
+ if (!n)
171
+ return "";
172
+ const t = {};
173
+ return n.forEach((s, r) => {
174
+ const a = {};
175
+ s.forValue((c, h, _) => {
176
+ a[c] || (a[c] = {}), a[c][h] = _;
177
+ }), Object.keys(a).length > 0 && (t[r] = a);
178
+ }), JSON.stringify(t);
179
+ }, o = (e) => {
180
+ if (!e)
181
+ return {};
182
+ try {
183
+ return JSON.parse(e);
184
+ } catch {
185
+ return {};
186
+ }
187
+ };
188
+ this.disposeWithMe(
189
+ this._resourceManagerService.registerPluginResource({
190
+ pluginName: V,
191
+ businesses: [U.UNIVER_SHEET],
192
+ toJson: (e) => i(e),
193
+ parseJson: (e) => o(e),
194
+ onUnLoad: (e) => {
195
+ this._sheetsNoteModel.deleteUnitNotes(e);
196
+ },
197
+ onLoad: (e, n) => {
198
+ Object.entries(n).forEach(([t, s]) => {
199
+ Object.entries(s).forEach(([r, a]) => {
200
+ Object.entries(a).forEach(([c, h]) => {
201
+ this._sheetsNoteModel.updateNote(
202
+ e,
203
+ t,
204
+ Number(r),
205
+ Number(c),
206
+ h
207
+ );
208
+ });
209
+ });
210
+ });
211
+ }
212
+ })
213
+ );
214
+ }
122
215
  };
123
- var k = Object.getOwnPropertyDescriptor, ee = (i, o, e, n) => {
124
- for (var t = n > 1 ? void 0 : n ? k(o, e) : o, s = i.length - 1, r; s >= 0; s--)
216
+ N = se([
217
+ w(0, J),
218
+ w(1, x),
219
+ w(2, g(u))
220
+ ], N);
221
+ const ne = "sheets-note.config", b = {};
222
+ var oe = Object.getOwnPropertyDescriptor, re = (i, o, e, n) => {
223
+ for (var t = n > 1 ? void 0 : n ? oe(o, e) : o, s = i.length - 1, r; s >= 0; s--)
125
224
  (r = i[s]) && (t = r(t) || t);
126
225
  return t;
127
226
  }, m = (i, o) => (e, n) => o(e, n, i);
128
- let N = class extends S {
227
+ let f = class extends S {
129
228
  constructor(o, e, n, t) {
130
229
  super();
131
230
  d(this, "_disposableMap", /* @__PURE__ */ new Map());
@@ -215,7 +314,7 @@ let N = class extends S {
215
314
  this._getIdWithUnitId(o, e, t, s),
216
315
  this._refRangeService.watchRange(o, e, r, (a, c) => {
217
316
  const { redos: h } = this._handleRangeChange(o, e, n, a.startRow, a.startColumn, c, !0);
218
- J(h, this._commandService, { onlyLocal: !0 });
317
+ G(h, this._commandService, { onlyLocal: !0 });
219
318
  }, !0)
220
319
  );
221
320
  }
@@ -254,112 +353,12 @@ let N = class extends S {
254
353
  );
255
354
  }
256
355
  };
257
- N = ee([
356
+ f = re([
258
357
  m(0, g(Y)),
259
358
  m(1, g(u)),
260
359
  m(2, g(I)),
261
360
  m(3, p)
262
- ], N);
263
- var te = Object.getOwnPropertyDescriptor, se = (i, o, e, n) => {
264
- for (var t = n > 1 ? void 0 : n ? te(o, e) : o, s = i.length - 1, r; s >= 0; s--)
265
- (r = i[s]) && (t = r(t) || t);
266
- return t;
267
- }, w = (i, o) => (e, n) => o(e, n, i);
268
- let f = class extends S {
269
- constructor(i, o, e) {
270
- super(), this._resourceManagerService = i, this._univerInstanceService = o, this._sheetsNoteModel = e, this._initSnapshot();
271
- }
272
- _initSnapshot() {
273
- const i = (e) => {
274
- const n = this._sheetsNoteModel.getUnitNotes(e);
275
- if (!n)
276
- return "";
277
- const t = {};
278
- return n.forEach((s, r) => {
279
- const a = {};
280
- s.forValue((c, h, _) => {
281
- a[c] || (a[c] = {}), a[c][h] = _;
282
- }), Object.keys(a).length > 0 && (t[r] = a);
283
- }), JSON.stringify(t);
284
- }, o = (e) => {
285
- if (!e)
286
- return {};
287
- try {
288
- return JSON.parse(e);
289
- } catch {
290
- return {};
291
- }
292
- };
293
- this.disposeWithMe(
294
- this._resourceManagerService.registerPluginResource({
295
- pluginName: T,
296
- businesses: [U.UNIVER_SHEET],
297
- toJson: (e) => i(e),
298
- parseJson: (e) => o(e),
299
- onUnLoad: (e) => {
300
- this._sheetsNoteModel.deleteUnitNotes(e);
301
- },
302
- onLoad: (e, n) => {
303
- Object.entries(n).forEach(([t, s]) => {
304
- Object.entries(s).forEach(([r, a]) => {
305
- Object.entries(a).forEach(([c, h]) => {
306
- this._sheetsNoteModel.updateNote(
307
- e,
308
- t,
309
- Number(r),
310
- Number(c),
311
- h
312
- );
313
- });
314
- });
315
- });
316
- }
317
- })
318
- );
319
- }
320
- };
321
- f = se([
322
- w(0, G),
323
- w(1, x),
324
- w(2, g(u))
325
361
  ], f);
326
- const ne = {
327
- id: "sheet.command.delete-note",
328
- type: l.COMMAND,
329
- handler: (i, o) => {
330
- const e = i.get(x), n = D(e);
331
- if (!n) return !1;
332
- const s = i.get(I).getCurrentLastSelection();
333
- if (!(s != null && s.primary)) return !1;
334
- const { actualColumn: r, actualRow: a } = s.primary;
335
- return i.get(p).executeCommand(P.id, {
336
- unitId: n.unitId,
337
- sheetId: n.subUnitId,
338
- row: a,
339
- col: r
340
- });
341
- }
342
- }, oe = {
343
- id: "sheet.command.toggle-note-popup",
344
- type: l.COMMAND,
345
- handler: (i, o) => {
346
- const e = i.get(x), n = D(e);
347
- if (!n) return !1;
348
- const s = i.get(I).getCurrentLastSelection();
349
- if (!(s != null && s.primary)) return !1;
350
- const { actualColumn: r, actualRow: a } = s.primary;
351
- return i.get(p).executeCommand(V.id, {
352
- unitId: n.unitId,
353
- sheetId: n.subUnitId,
354
- row: a,
355
- col: r
356
- });
357
- }
358
- }, re = {
359
- id: "sheet.command.update-note",
360
- type: l.COMMAND,
361
- handler: (i, o) => i.get(p).syncExecuteCommand(R.id, o)
362
- };
363
362
  var ie = Object.getOwnPropertyDescriptor, ae = (i, o, e, n) => {
364
363
  for (var t = n > 1 ? void 0 : n ? ie(o, e) : o, s = i.length - 1, r; s >= 0; s--)
365
364
  (r = i[s]) && (t = r(t) || t);
@@ -372,12 +371,12 @@ let M = class extends S {
372
371
  _initialize() {
373
372
  [
374
373
  C,
375
- V,
374
+ T,
376
375
  R,
377
376
  P,
378
- ne,
379
- oe,
380
- re
377
+ Z,
378
+ k,
379
+ ee
381
380
  ].forEach((i) => {
382
381
  this.disposeWithMe(
383
382
  this._commandService.registerCommand(i)
@@ -401,29 +400,29 @@ let v = class extends q {
401
400
  b,
402
401
  this._config
403
402
  );
404
- this._configService.setConfig(Z, n);
403
+ this._configService.setConfig(ne, n);
405
404
  }
406
405
  onStarting() {
407
406
  [
408
407
  [u],
409
408
  [M],
410
- [f],
411
- [N]
409
+ [N],
410
+ [f]
412
411
  ].forEach((i) => {
413
412
  this._injector.add(i);
414
413
  }), O(this._injector, [
415
414
  [u],
416
415
  [M],
417
- [f]
416
+ [N]
418
417
  ]);
419
418
  }
420
419
  onReady() {
421
420
  O(this._injector, [
422
- [N]
421
+ [f]
423
422
  ]);
424
423
  }
425
424
  };
426
- j(v, "pluginName", T);
425
+ j(v, "pluginName", V);
427
426
  j(v, "type", U.UNIVER_SHEET);
428
427
  v = le([
429
428
  H(Q),
@@ -432,12 +431,12 @@ v = le([
432
431
  ], v);
433
432
  export {
434
433
  P as RemoveNoteMutation,
435
- ne as SheetDeleteNoteCommand,
436
- oe as SheetToggleNotePopupCommand,
437
- re as SheetUpdateNoteCommand,
434
+ Z as SheetDeleteNoteCommand,
435
+ k as SheetToggleNotePopupCommand,
436
+ ee as SheetUpdateNoteCommand,
438
437
  u as SheetsNoteModel,
439
- f as SheetsNoteResourceController,
440
- V as ToggleNotePopupMutation,
438
+ N as SheetsNoteResourceController,
439
+ T as ToggleNotePopupMutation,
441
440
  v as UniverSheetsNotePlugin,
442
441
  R as UpdateNoteMutation,
443
442
  C as UpdateNotePositionMutation
package/lib/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  var A = Object.defineProperty;
2
2
  var W = (i, o, e) => o in i ? A(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
3
  var d = (i, o, e) => W(i, typeof o != "symbol" ? o + "" : o, e);
4
- import { Disposable as S, ObjectMatrix as L, CommandType as l, Inject as g, ICommandService as p, sequenceExecuteAsync as J, IResourceManagerService as G, IUniverInstanceService as x, UniverInstanceType as U, DependentOn as H, IConfigService as z, Injector as F, Plugin as q, merge as K, touchDependencies as O } from "@univerjs/core";
5
- import { RefRangeService as Y, SheetsSelectionsService as I, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B, getSheetCommandTarget as D, UniverSheetsPlugin as Q } from "@univerjs/sheets";
4
+ import { Disposable as S, ObjectMatrix as L, CommandType as l, IUniverInstanceService as x, ICommandService as p, IResourceManagerService as J, Inject as g, UniverInstanceType as U, sequenceExecuteAsync as G, DependentOn as H, IConfigService as z, Injector as F, Plugin as q, merge as K, touchDependencies as O } from "@univerjs/core";
5
+ import { getSheetCommandTarget as D, SheetsSelectionsService as I, RefRangeService as Y, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B, UniverSheetsPlugin as Q } from "@univerjs/sheets";
6
6
  import { Subject as X, filter as y, map as $ } from "rxjs";
7
- const T = "SHEET_NOTE_PLUGIN", Z = "sheets-note.config", b = {};
8
7
  class u extends S {
9
8
  constructor() {
10
9
  super(...arguments);
@@ -105,7 +104,7 @@ const R = {
105
104
  const { unitId: e, sheetId: n, row: t, col: s, silent: r } = o;
106
105
  return i.get(u).removeNote(e, n, t, s, r), !0;
107
106
  }
108
- }, V = {
107
+ }, T = {
109
108
  id: "sheet.mutation.toggle-note-popup",
110
109
  type: l.MUTATION,
111
110
  handler: (i, o) => {
@@ -119,13 +118,113 @@ const R = {
119
118
  const { unitId: e, sheetId: n, row: t, col: s, newPosition: r, silent: a } = o;
120
119
  return i.get(u).updateNotePosition(e, n, t, s, r.row, r.col, a), !0;
121
120
  }
121
+ }, Z = {
122
+ id: "sheet.command.delete-note",
123
+ type: l.COMMAND,
124
+ handler: (i, o) => {
125
+ const e = i.get(x), n = D(e);
126
+ if (!n) return !1;
127
+ const s = i.get(I).getCurrentLastSelection();
128
+ if (!(s != null && s.primary)) return !1;
129
+ const { actualColumn: r, actualRow: a } = s.primary;
130
+ return i.get(p).executeCommand(P.id, {
131
+ unitId: n.unitId,
132
+ sheetId: n.subUnitId,
133
+ row: a,
134
+ col: r
135
+ });
136
+ }
137
+ }, k = {
138
+ id: "sheet.command.toggle-note-popup",
139
+ type: l.COMMAND,
140
+ handler: (i, o) => {
141
+ const e = i.get(x), n = D(e);
142
+ if (!n) return !1;
143
+ const s = i.get(I).getCurrentLastSelection();
144
+ if (!(s != null && s.primary)) return !1;
145
+ const { actualColumn: r, actualRow: a } = s.primary;
146
+ return i.get(p).executeCommand(T.id, {
147
+ unitId: n.unitId,
148
+ sheetId: n.subUnitId,
149
+ row: a,
150
+ col: r
151
+ });
152
+ }
153
+ }, ee = {
154
+ id: "sheet.command.update-note",
155
+ type: l.COMMAND,
156
+ handler: (i, o) => i.get(p).syncExecuteCommand(R.id, o)
157
+ }, V = "SHEET_NOTE_PLUGIN";
158
+ var te = Object.getOwnPropertyDescriptor, se = (i, o, e, n) => {
159
+ for (var t = n > 1 ? void 0 : n ? te(o, e) : o, s = i.length - 1, r; s >= 0; s--)
160
+ (r = i[s]) && (t = r(t) || t);
161
+ return t;
162
+ }, w = (i, o) => (e, n) => o(e, n, i);
163
+ let N = class extends S {
164
+ constructor(i, o, e) {
165
+ super(), this._resourceManagerService = i, this._univerInstanceService = o, this._sheetsNoteModel = e, this._initSnapshot();
166
+ }
167
+ _initSnapshot() {
168
+ const i = (e) => {
169
+ const n = this._sheetsNoteModel.getUnitNotes(e);
170
+ if (!n)
171
+ return "";
172
+ const t = {};
173
+ return n.forEach((s, r) => {
174
+ const a = {};
175
+ s.forValue((c, h, _) => {
176
+ a[c] || (a[c] = {}), a[c][h] = _;
177
+ }), Object.keys(a).length > 0 && (t[r] = a);
178
+ }), JSON.stringify(t);
179
+ }, o = (e) => {
180
+ if (!e)
181
+ return {};
182
+ try {
183
+ return JSON.parse(e);
184
+ } catch {
185
+ return {};
186
+ }
187
+ };
188
+ this.disposeWithMe(
189
+ this._resourceManagerService.registerPluginResource({
190
+ pluginName: V,
191
+ businesses: [U.UNIVER_SHEET],
192
+ toJson: (e) => i(e),
193
+ parseJson: (e) => o(e),
194
+ onUnLoad: (e) => {
195
+ this._sheetsNoteModel.deleteUnitNotes(e);
196
+ },
197
+ onLoad: (e, n) => {
198
+ Object.entries(n).forEach(([t, s]) => {
199
+ Object.entries(s).forEach(([r, a]) => {
200
+ Object.entries(a).forEach(([c, h]) => {
201
+ this._sheetsNoteModel.updateNote(
202
+ e,
203
+ t,
204
+ Number(r),
205
+ Number(c),
206
+ h
207
+ );
208
+ });
209
+ });
210
+ });
211
+ }
212
+ })
213
+ );
214
+ }
122
215
  };
123
- var k = Object.getOwnPropertyDescriptor, ee = (i, o, e, n) => {
124
- for (var t = n > 1 ? void 0 : n ? k(o, e) : o, s = i.length - 1, r; s >= 0; s--)
216
+ N = se([
217
+ w(0, J),
218
+ w(1, x),
219
+ w(2, g(u))
220
+ ], N);
221
+ const ne = "sheets-note.config", b = {};
222
+ var oe = Object.getOwnPropertyDescriptor, re = (i, o, e, n) => {
223
+ for (var t = n > 1 ? void 0 : n ? oe(o, e) : o, s = i.length - 1, r; s >= 0; s--)
125
224
  (r = i[s]) && (t = r(t) || t);
126
225
  return t;
127
226
  }, m = (i, o) => (e, n) => o(e, n, i);
128
- let N = class extends S {
227
+ let f = class extends S {
129
228
  constructor(o, e, n, t) {
130
229
  super();
131
230
  d(this, "_disposableMap", /* @__PURE__ */ new Map());
@@ -215,7 +314,7 @@ let N = class extends S {
215
314
  this._getIdWithUnitId(o, e, t, s),
216
315
  this._refRangeService.watchRange(o, e, r, (a, c) => {
217
316
  const { redos: h } = this._handleRangeChange(o, e, n, a.startRow, a.startColumn, c, !0);
218
- J(h, this._commandService, { onlyLocal: !0 });
317
+ G(h, this._commandService, { onlyLocal: !0 });
219
318
  }, !0)
220
319
  );
221
320
  }
@@ -254,112 +353,12 @@ let N = class extends S {
254
353
  );
255
354
  }
256
355
  };
257
- N = ee([
356
+ f = re([
258
357
  m(0, g(Y)),
259
358
  m(1, g(u)),
260
359
  m(2, g(I)),
261
360
  m(3, p)
262
- ], N);
263
- var te = Object.getOwnPropertyDescriptor, se = (i, o, e, n) => {
264
- for (var t = n > 1 ? void 0 : n ? te(o, e) : o, s = i.length - 1, r; s >= 0; s--)
265
- (r = i[s]) && (t = r(t) || t);
266
- return t;
267
- }, w = (i, o) => (e, n) => o(e, n, i);
268
- let f = class extends S {
269
- constructor(i, o, e) {
270
- super(), this._resourceManagerService = i, this._univerInstanceService = o, this._sheetsNoteModel = e, this._initSnapshot();
271
- }
272
- _initSnapshot() {
273
- const i = (e) => {
274
- const n = this._sheetsNoteModel.getUnitNotes(e);
275
- if (!n)
276
- return "";
277
- const t = {};
278
- return n.forEach((s, r) => {
279
- const a = {};
280
- s.forValue((c, h, _) => {
281
- a[c] || (a[c] = {}), a[c][h] = _;
282
- }), Object.keys(a).length > 0 && (t[r] = a);
283
- }), JSON.stringify(t);
284
- }, o = (e) => {
285
- if (!e)
286
- return {};
287
- try {
288
- return JSON.parse(e);
289
- } catch {
290
- return {};
291
- }
292
- };
293
- this.disposeWithMe(
294
- this._resourceManagerService.registerPluginResource({
295
- pluginName: T,
296
- businesses: [U.UNIVER_SHEET],
297
- toJson: (e) => i(e),
298
- parseJson: (e) => o(e),
299
- onUnLoad: (e) => {
300
- this._sheetsNoteModel.deleteUnitNotes(e);
301
- },
302
- onLoad: (e, n) => {
303
- Object.entries(n).forEach(([t, s]) => {
304
- Object.entries(s).forEach(([r, a]) => {
305
- Object.entries(a).forEach(([c, h]) => {
306
- this._sheetsNoteModel.updateNote(
307
- e,
308
- t,
309
- Number(r),
310
- Number(c),
311
- h
312
- );
313
- });
314
- });
315
- });
316
- }
317
- })
318
- );
319
- }
320
- };
321
- f = se([
322
- w(0, G),
323
- w(1, x),
324
- w(2, g(u))
325
361
  ], f);
326
- const ne = {
327
- id: "sheet.command.delete-note",
328
- type: l.COMMAND,
329
- handler: (i, o) => {
330
- const e = i.get(x), n = D(e);
331
- if (!n) return !1;
332
- const s = i.get(I).getCurrentLastSelection();
333
- if (!(s != null && s.primary)) return !1;
334
- const { actualColumn: r, actualRow: a } = s.primary;
335
- return i.get(p).executeCommand(P.id, {
336
- unitId: n.unitId,
337
- sheetId: n.subUnitId,
338
- row: a,
339
- col: r
340
- });
341
- }
342
- }, oe = {
343
- id: "sheet.command.toggle-note-popup",
344
- type: l.COMMAND,
345
- handler: (i, o) => {
346
- const e = i.get(x), n = D(e);
347
- if (!n) return !1;
348
- const s = i.get(I).getCurrentLastSelection();
349
- if (!(s != null && s.primary)) return !1;
350
- const { actualColumn: r, actualRow: a } = s.primary;
351
- return i.get(p).executeCommand(V.id, {
352
- unitId: n.unitId,
353
- sheetId: n.subUnitId,
354
- row: a,
355
- col: r
356
- });
357
- }
358
- }, re = {
359
- id: "sheet.command.update-note",
360
- type: l.COMMAND,
361
- handler: (i, o) => i.get(p).syncExecuteCommand(R.id, o)
362
- };
363
362
  var ie = Object.getOwnPropertyDescriptor, ae = (i, o, e, n) => {
364
363
  for (var t = n > 1 ? void 0 : n ? ie(o, e) : o, s = i.length - 1, r; s >= 0; s--)
365
364
  (r = i[s]) && (t = r(t) || t);
@@ -372,12 +371,12 @@ let M = class extends S {
372
371
  _initialize() {
373
372
  [
374
373
  C,
375
- V,
374
+ T,
376
375
  R,
377
376
  P,
378
- ne,
379
- oe,
380
- re
377
+ Z,
378
+ k,
379
+ ee
381
380
  ].forEach((i) => {
382
381
  this.disposeWithMe(
383
382
  this._commandService.registerCommand(i)
@@ -401,29 +400,29 @@ let v = class extends q {
401
400
  b,
402
401
  this._config
403
402
  );
404
- this._configService.setConfig(Z, n);
403
+ this._configService.setConfig(ne, n);
405
404
  }
406
405
  onStarting() {
407
406
  [
408
407
  [u],
409
408
  [M],
410
- [f],
411
- [N]
409
+ [N],
410
+ [f]
412
411
  ].forEach((i) => {
413
412
  this._injector.add(i);
414
413
  }), O(this._injector, [
415
414
  [u],
416
415
  [M],
417
- [f]
416
+ [N]
418
417
  ]);
419
418
  }
420
419
  onReady() {
421
420
  O(this._injector, [
422
- [N]
421
+ [f]
423
422
  ]);
424
423
  }
425
424
  };
426
- j(v, "pluginName", T);
425
+ j(v, "pluginName", V);
427
426
  j(v, "type", U.UNIVER_SHEET);
428
427
  v = le([
429
428
  H(Q),
@@ -432,12 +431,12 @@ v = le([
432
431
  ], v);
433
432
  export {
434
433
  P as RemoveNoteMutation,
435
- ne as SheetDeleteNoteCommand,
436
- oe as SheetToggleNotePopupCommand,
437
- re as SheetUpdateNoteCommand,
434
+ Z as SheetDeleteNoteCommand,
435
+ k as SheetToggleNotePopupCommand,
436
+ ee as SheetUpdateNoteCommand,
438
437
  u as SheetsNoteModel,
439
- f as SheetsNoteResourceController,
440
- V as ToggleNotePopupMutation,
438
+ N as SheetsNoteResourceController,
439
+ T as ToggleNotePopupMutation,
441
440
  v as UniverSheetsNotePlugin,
442
441
  R as UpdateNoteMutation,
443
442
  C as UpdateNotePositionMutation
@@ -13,8 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { UniverSheetsNotePlugin } from './plugin';
17
- export * from './models/sheets-note.model';
18
- export * from './controllers/sheets-note-resource.controller';
19
- export * from './commands/mutations/note.mutation';
20
16
  export * from './commands/commands/note.command';
17
+ export * from './commands/mutations/note.mutation';
18
+ export type { IUniverSheetsNoteConfig } from './controllers/config.schema';
19
+ export * from './controllers/sheets-note-resource.controller';
20
+ export * from './models/sheets-note.model';
21
+ export { UniverSheetsNotePlugin } from './plugin';
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);const P="SHEET_NOTE_PLUGIN",$="sheets-note.config",y={};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}};var D=Object.getOwnPropertyDescriptor,j=(r,o,n,e)=>{for(var t=e>1?void 0:e?D(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=j([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(g)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);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},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:P,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=x([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(g))],u.SheetsNoteResourceController);const R={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})}},U={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})}},O={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,o)=>r.get(a.ICommandService).syncExecuteCommand(N.id,o)};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,R,U,O].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=y,n,e){super(),this._config=o,this._configService=n,this._injector=e;const{...t}=a.merge({},y,this._config);this._configService.setConfig($,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",P),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=R,u.SheetToggleNotePopupCommand=U,u.SheetUpdateNoteCommand=O,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.8.2-nightly.202506261607",
3
+ "version": "0.8.3-nightly.202506271607",
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.8.2-nightly.202506261607",
60
- "@univerjs/sheets": "0.8.2-nightly.202506261607"
59
+ "@univerjs/core": "0.8.3-nightly.202506271607",
60
+ "@univerjs/sheets": "0.8.3-nightly.202506271607"
61
61
  },
62
62
  "devDependencies": {
63
63
  "rxjs": "^7.8.2",
64
64
  "typescript": "^5.8.3",
65
65
  "vite": "^6.3.5",
66
66
  "vitest": "^3.2.4",
67
- "@univerjs-infra/shared": "0.8.2"
67
+ "@univerjs-infra/shared": "0.8.3"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",