@univerjs/sheets-note 0.7.0-nightly.202505061607 → 0.7.0-nightly.202505081607

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 T=Object.defineProperty;var U=(i,n,e)=>n in i?T(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e;var g=(i,n,e)=>U(i,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),p=require("@univerjs/sheets"),m=require("rxjs");class l extends h.Disposable{constructor(){super(...arguments);g(this,"_noteMatrix",new Map);g(this,"_change$",new m.Subject);g(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let s=this._noteMatrix.get(e);s||(s=new Map,this._noteMatrix.set(e,s));let o=s.get(t);return o||(o=new h.ObjectMatrix,s.set(t,o)),o}getSheetShowNotes$(e,t){return this._change$.pipe(m.filter(({unitId:s,sheetId:o})=>s===e&&o===t),m.map(()=>{const s=this._ensureNoteMatrix(e,t),o=[];return s.forValue((r,a,c)=>{c.show&&o.push({loc:{row:r,col:a,unitId:e,subUnitId:t},note:c})}),o}))}getCellNoteChange$(e,t,s,o){return this._change$.pipe(m.filter(({unitId:r,sheetId:a,row:c,col:u})=>r===e&&a===t&&c===s&&u===o),m.map(({note:r})=>r))}updateNote(e,t,s,o,r,a){const c=this._ensureNoteMatrix(e,t),u=c.getValue(s,o);c.setValue(s,o,r),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"update",note:r,oldNote:u,silent:a})}removeNote(e,t,s,o,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,o);a.realDeleteValue(s,o),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"update",note:null,oldNote:c,silent:r})}toggleNotePopup(e,t,s,o,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,o);if(c){c.show=!c.show;const u={...c,show:c.show};a.setValue(s,o,u),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"update",note:u,oldNote:c,silent:r})}}updateNotePosition(e,t,s,o,r,a,c){const u=this._ensureNoteMatrix(e,t),d=u.getValue(s,o);d&&(u.realDeleteValue(s,o),u.setValue(r,a,d),this._change$.next({unitId:e,sheetId:t,row:s,col:o,type:"ref",newPosition:{row:r,col:a},note:d,silent:c}))}getNote(e,t,s,o){return this._ensureNoteMatrix(e,t).getValue(s,o)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const s=this._noteMatrix.get(e);if(s)return s.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const M={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,note:r,silent:a}=n;return i.get(l).updateNote(e,t,s,o,r,a),!0}},f={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,silent:r}=n;return i.get(l).removeNote(e,t,s,o,r),!0}},I={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,silent:r}=n;return i.get(l).toggleNotePopup(e,t,s,o,r),!0}},N={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,sheetId:t,row:s,col:o,newPosition:r,silent:a}=n;return i.get(l).updateNotePosition(e,t,s,o,r.row,r.col,a),!0}};var $=Object.getOwnPropertyDescriptor,D=(i,n,e,t)=>{for(var s=t>1?void 0:t?$(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},_=(i,n)=>(e,t)=>n(e,t,i);let S=class extends h.Disposable{constructor(n,e,t,s){super();g(this,"_disposableMap",new Map);g(this,"_watcherMap",new Map);g(this,"_handleRangeChange",(n,e,t,s,o,r,a)=>r?{redos:[{id:N.id,params:{unitId:n,sheetId:e,row:s,col:o,newPosition:{row:r.startRow,col:r.startColumn},silent:a}}],undos:[{id:N.id,params:{unitId:n,sheetId:e,row:r.startRow,col:r.startColumn,newPosition:{row:s,col:o},note:t,silent:a}}]}:{redos:[{id:f.id,params:{unitId:n,sheetId:e,row:s,col:o}}],undos:[{id:M.id,params:{unitId:n,sheetId:e,row:s,col:o,note:t}}]});this._refRangeService=n,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(n,e,t,s){return`${n}-${e}-${t}-${s}`}_register(n,e,t,s,o){const r={startColumn:o,endColumn:o,startRow:s,endRow:s};this._disposableMap.set(this._getIdWithUnitId(n,e,s,o),this._refRangeService.registerRefRange(r,a=>{const c=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(r,a,{selectionManagerService:this._selectionManagerService}),u=Array.isArray(c)?c[0]:c;return u&&u.startColumn===r.startColumn&&u.startRow===r.startRow?{undos:[],redos:[]}:this._handleRangeChange(n,e,t,s,o,u,!1)},n,e))}_watch(n,e,t,s,o){const r={startColumn:o,endColumn:o,startRow:s,endRow:s};this._watcherMap.set(this._getIdWithUnitId(n,e,s,o),this._refRangeService.watchRange(n,e,r,(a,c)=>{const{redos:u}=this._handleRangeChange(n,e,t,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(n,e,t,s){var r;const o=this._getIdWithUnitId(n,e,t,s);(r=this._watcherMap.get(o))==null||r.dispose(),this._watcherMap.delete(o)}_unregister(n,e,t,s){var r;const o=this._getIdWithUnitId(n,e,t,s);(r=this._disposableMap.get(o))==null||r.dispose(),this._disposableMap.delete(o)}_initData(){const n=this._sheetsNoteModel.getNotes();for(const[e,t]of n)for(const[s,o]of t)o.forValue((r,a,c)=>(c&&(this._register(e,s,c,r,a),this._watch(e,s,c,r,a)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(n=>{switch(n.type){case"update":{const{unitId:e,sheetId:t,row:s,col:o,note:r}=n,a=this._getIdWithUnitId(e,t,s,o);r?this._disposableMap.has(a)||(this._register(e,t,r,s,o),this._watch(e,t,r,s,o)):(this._unregister(e,t,s,o),this._unwatch(e,t,s,o));break}case"ref":{const{unitId:e,sheetId:t,row:s,col:o,newPosition:r,note:a,silent:c}=n;this._unregister(e,t,s,o),c||(this._unwatch(e,t,s,o),this._watch(e,t,a,r.row,r.col)),this._register(e,t,a,r.row,r.col);break}}}))}};S=D([_(0,h.Inject(p.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(p.SheetsSelectionsService)),_(3,h.ICommandService)],S);var j=Object.getOwnPropertyDescriptor,E=(i,n,e,t)=>{for(var s=t>1?void 0:t?j(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},C=(i,n)=>(e,t)=>n(e,t,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(n,e,t){super(),this._resourceManagerService=n,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const n=t=>{const s=this._sheetsNoteModel.getUnitNotes(t);if(!s)return"";const o={};return s.forEach((r,a)=>{const c={};r.forValue((u,d,b)=>{c[u]||(c[u]={}),c[u][d]=b}),Object.keys(c).length>0&&(o[a]=c)}),JSON.stringify(o)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:w,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:t=>n(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,s)=>{Object.entries(s).forEach(([o,r])=>{Object.entries(r).forEach(([a,c])=>{Object.entries(c).forEach(([u,d])=>{this._sheetsNoteModel.updateNote(t,o,Number(a),Number(u),d)})})})}}))}};exports.SheetsNoteResourceController=E([C(0,h.IResourceManagerService),C(1,h.IUniverInstanceService),C(2,h.Inject(l))],exports.SheetsNoteResourceController);const R={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const o=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!(o!=null&&o.primary))return!1;const{actualColumn:r,actualRow:a}=o.primary;return i.get(h.ICommandService).executeCommand(f.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},y={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const o=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!(o!=null&&o.primary))return!1;const{actualColumn:r,actualRow:a}=o.primary;return i.get(h.ICommandService).executeCommand(I.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},x={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,n)=>i.get(h.ICommandService).syncExecuteCommand(M.id,n)};var V=Object.getOwnPropertyDescriptor,A=(i,n,e,t)=>{for(var s=t>1?void 0:t?V(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},W=(i,n)=>(e,t)=>n(e,t,i);let v=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[N,I,M,f,R,y,x].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};v=A([W(0,h.ICommandService)],v);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(i,n,e)=>n in i?L(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,G=(i,n,e,t)=>{for(var s=t>1?void 0:t?J(n,e):n,o=i.length-1,r;o>=0;o--)(r=i[o])&&(s=r(s)||s);return s},P=(i,n)=>(e,t)=>n(e,t,i),O=(i,n,e)=>q(i,typeof n!="symbol"?n+"":n,e);const w="SHEET_NOTE_PLUGIN";exports.SheetsNotePlugin=class extends h.Plugin{constructor(n,e){super(),this._configService=n,this._injector=e}onStarting(){[[l],[v],[exports.SheetsNoteResourceController],[S]].forEach(n=>{this._injector.add(n)}),h.touchDependencies(this._injector,[[l],[v],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[S]])}};O(exports.SheetsNotePlugin,"pluginName",w);O(exports.SheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.SheetsNotePlugin=G([h.DependentOn(p.UniverSheetsPlugin),P(0,h.IConfigService),P(1,h.Inject(h.Injector))],exports.SheetsNotePlugin);exports.PLUGIN_NAME=w;exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=R;exports.SheetToggleNotePopupCommand=y;exports.SheetUpdateNoteCommand=x;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
1
+ "use strict";var b=Object.defineProperty;var T=(i,o,e)=>o in i?b(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var g=(i,o,e)=>T(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),p=require("@univerjs/sheets"),m=require("rxjs");class l extends h.Disposable{constructor(){super(...arguments);g(this,"_noteMatrix",new Map);g(this,"_change$",new m.Subject);g(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let s=this._noteMatrix.get(e);s||(s=new Map,this._noteMatrix.set(e,s));let 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 $=Object.getOwnPropertyDescriptor,D=(i,o,e,t)=>{for(var s=t>1?void 0:t?$(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();g(this,"_disposableMap",new Map);g(this,"_watcherMap",new Map);g(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=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(r,a,{selectionManagerService:this._selectionManagerService}),u=Array.isArray(c)?c[0]:c;return u&&u.startColumn===r.startColumn&&u.startRow===r.startRow?{undos:[],redos:[]}:this._handleRangeChange(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=D([_(0,h.Inject(p.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(p.SheetsSelectionsService)),_(3,h.ICommandService)],S);var j=Object.getOwnPropertyDescriptor,E=(i,o,e,t)=>{for(var s=t>1?void 0:t?j(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,O)=>{c[u]||(c[u]={}),c[u][d]=O}),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 P={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(p.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})}},R={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(p.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})}},y={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,o)=>i.get(h.ICommandService).syncExecuteCommand(M.id,o)};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},W=(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,P,R,y].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};v=A([W(0,h.ICommandService)],v);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(i,o,e)=>o in i?L(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e,H=(i,o,e,t)=>{for(var s=t>1?void 0:t?J(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},w=(i,o)=>(e,t)=>o(e,t,i),x=(i,o,e)=>q(i,typeof o!="symbol"?o+"":o,e);const U="SHEET_NOTE_PLUGIN";exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(o,e){super(),this._configService=o,this._injector=e}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]])}};x(exports.UniverSheetsNotePlugin,"pluginName",U);x(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=H([h.DependentOn(p.UniverSheetsPlugin),w(0,h.IConfigService),w(1,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=P;exports.SheetToggleNotePopupCommand=R;exports.SheetUpdateNoteCommand=y;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
package/lib/es/index.js CHANGED
@@ -425,15 +425,14 @@ v = he([
425
425
  b(1, _(G))
426
426
  ], v);
427
427
  export {
428
- V as PLUGIN_NAME,
429
428
  P as RemoveNoteMutation,
430
429
  ee as SheetDeleteNoteCommand,
431
430
  te as SheetToggleNotePopupCommand,
432
431
  se as SheetUpdateNoteCommand,
433
432
  u as SheetsNoteModel,
434
- v as SheetsNotePlugin,
435
433
  M as SheetsNoteResourceController,
436
434
  E as ToggleNotePopupMutation,
435
+ v as UniverSheetsNotePlugin,
437
436
  I as UpdateNoteMutation,
438
437
  C as UpdateNotePositionMutation
439
438
  };
package/lib/index.js CHANGED
@@ -425,15 +425,14 @@ v = he([
425
425
  b(1, _(G))
426
426
  ], v);
427
427
  export {
428
- V as PLUGIN_NAME,
429
428
  P as RemoveNoteMutation,
430
429
  ee as SheetDeleteNoteCommand,
431
430
  te as SheetToggleNotePopupCommand,
432
431
  se as SheetUpdateNoteCommand,
433
432
  u as SheetsNoteModel,
434
- v as SheetsNotePlugin,
435
433
  M as SheetsNoteResourceController,
436
434
  E as ToggleNotePopupMutation,
435
+ v as UniverSheetsNotePlugin,
437
436
  I as UpdateNoteMutation,
438
437
  C as UpdateNotePositionMutation
439
438
  };
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export * from './plugin';
16
+ export { UniverSheetsNotePlugin } from './plugin';
17
17
  export * from './models/sheets-note.model';
18
18
  export * from './controllers/sheets-note-resource.controller';
19
19
  export * from './commands/mutations/note.mutation';
@@ -1,6 +1,6 @@
1
1
  import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  export declare const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
3
- export declare class SheetsNotePlugin extends Plugin {
3
+ export declare class UniverSheetsNotePlugin extends Plugin {
4
4
  private readonly _configService;
5
5
  protected readonly _injector: Injector;
6
6
  static pluginName: string;
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,_){"use strict";var G=Object.defineProperty;var H=(u,a,l)=>a in u?G(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var p=(u,a,l)=>H(u,typeof a!="symbol"?a+"":a,l);class m extends a.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new _.Subject);p(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let n=this._noteMatrix.get(e);n||(n=new Map,this._noteMatrix.set(e,n));let s=n.get(t);return s||(s=new a.ObjectMatrix,n.set(t,s)),s}getSheetShowNotes$(e,t){return this._change$.pipe(_.filter(({unitId:n,sheetId:s})=>n===e&&s===t),_.map(()=>{const n=this._ensureNoteMatrix(e,t),s=[];return n.forValue((o,h,c)=>{c.show&&s.push({loc:{row:o,col:h,unitId:e,subUnitId:t},note:c})}),s}))}getCellNoteChange$(e,t,n,s){return this._change$.pipe(_.filter(({unitId:o,sheetId:h,row:c,col:d})=>o===e&&h===t&&c===n&&d===s),_.map(({note:o})=>o))}updateNote(e,t,n,s,o,h){const c=this._ensureNoteMatrix(e,t),d=c.getValue(n,s);c.setValue(n,s,o),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:o,oldNote:d,silent:h})}removeNote(e,t,n,s,o){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);h.realDeleteValue(n,s),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:null,oldNote:c,silent:o})}toggleNotePopup(e,t,n,s,o){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(n,s,d),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:d,oldNote:c,silent:o})}}updateNotePosition(e,t,n,s,o,h,c){const d=this._ensureNoteMatrix(e,t),g=d.getValue(n,s);g&&(d.realDeleteValue(n,s),d.setValue(o,h,g),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"ref",newPosition:{row:o,col:h},note:g,silent:c}))}getNote(e,t,n,s){return this._ensureNoteMatrix(e,t).getValue(n,s)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const n=this._noteMatrix.get(e);if(n)return n.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,i)=>{const{unitId:e,sheetId:t,row:n,col:s,note:o,silent:h}=i;return r.get(m).updateNote(e,t,n,s,o,h),!0}},S={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,i)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:o}=i;return r.get(m).removeNote(e,t,n,s,o),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,i)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:o}=i;return r.get(m).toggleNotePopup(e,t,n,s,o),!0}},v={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,i)=>{const{unitId:e,sheetId:t,row:n,col:s,newPosition:o,silent:h}=i;return r.get(m).updateNotePosition(e,t,n,s,o.row,o.col,h),!0}};var b=Object.getOwnPropertyDescriptor,$=(r,i,e,t)=>{for(var n=t>1?void 0:t?b(i,e):i,s=r.length-1,o;s>=0;s--)(o=r[s])&&(n=o(n)||n);return n},f=(r,i)=>(e,t)=>i(e,t,r);let M=class extends a.Disposable{constructor(i,e,t,n){super();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(this,"_handleRangeChange",(i,e,t,n,s,o,h)=>o?{redos:[{id:v.id,params:{unitId:i,sheetId:e,row:n,col:s,newPosition:{row:o.startRow,col:o.startColumn},silent:h}}],undos:[{id:v.id,params:{unitId:i,sheetId:e,row:o.startRow,col:o.startColumn,newPosition:{row:n,col:s},note:t,silent:h}}]}:{redos:[{id:S.id,params:{unitId:i,sheetId:e,row:n,col:s}}],undos:[{id:N.id,params:{unitId:i,sheetId:e,row:n,col:s,note:t}}]});this._refRangeService=i,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=n,this._initData(),this._initRefRange()}_getIdWithUnitId(i,e,t,n){return`${i}-${e}-${t}-${n}`}_register(i,e,t,n,s){const o={startColumn:s,endColumn:s,startRow:n,endRow:n};this._disposableMap.set(this._getIdWithUnitId(i,e,n,s),this._refRangeService.registerRefRange(o,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(o,h,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===o.startColumn&&d.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(i,e,t,n,s,d,!1)},i,e))}_watch(i,e,t,n,s){const o={startColumn:s,endColumn:s,startRow:n,endRow:n};this._watcherMap.set(this._getIdWithUnitId(i,e,n,s),this._refRangeService.watchRange(i,e,o,(h,c)=>{const{redos:d}=this._handleRangeChange(i,e,t,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(i,e,t,n){var o;const s=this._getIdWithUnitId(i,e,t,n);(o=this._watcherMap.get(s))==null||o.dispose(),this._watcherMap.delete(s)}_unregister(i,e,t,n){var o;const s=this._getIdWithUnitId(i,e,t,n);(o=this._disposableMap.get(s))==null||o.dispose(),this._disposableMap.delete(s)}_initData(){const i=this._sheetsNoteModel.getNotes();for(const[e,t]of i)for(const[n,s]of t)s.forValue((o,h,c)=>(c&&(this._register(e,n,c,o,h),this._watch(e,n,c,o,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(i=>{switch(i.type){case"update":{const{unitId:e,sheetId:t,row:n,col:s,note:o}=i,h=this._getIdWithUnitId(e,t,n,s);o?this._disposableMap.has(h)||(this._register(e,t,o,n,s),this._watch(e,t,o,n,s)):(this._unregister(e,t,n,s),this._unwatch(e,t,n,s));break}case"ref":{const{unitId:e,sheetId:t,row:n,col:s,newPosition:o,note:h,silent:c}=i;this._unregister(e,t,n,s),c||(this._unwatch(e,t,n,s),this._watch(e,t,h,o.row,o.col)),this._register(e,t,h,o.row,o.col);break}}}))}};M=$([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(m)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var D=Object.getOwnPropertyDescriptor,j=(r,i,e,t)=>{for(var n=t>1?void 0:t?D(i,e):i,s=r.length-1,o;s>=0;s--)(o=r[s])&&(n=o(n)||n);return n},w=(r,i)=>(e,t)=>i(e,t,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(i,e,t){super(),this._resourceManagerService=i,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const i=t=>{const n=this._sheetsNoteModel.getUnitNotes(t);if(!n)return"";const s={};return n.forEach((o,h)=>{const c={};o.forValue((d,g,q)=>{c[d]||(c[d]={}),c[d][g]=q}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:P,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:t=>i(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,n)=>{Object.entries(n).forEach(([s,o])=>{Object.entries(o).forEach(([h,c])=>{Object.entries(c).forEach(([d,g])=>{this._sheetsNoteModel.updateNote(t,s,Number(h),Number(d),g)})})})}}))}},u.SheetsNoteResourceController=j([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(m))],u.SheetsNoteResourceController);const y={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,i)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:o,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(S.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:o})}},R={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,i)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:o,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(I.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:o})}},O={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,i)=>r.get(a.ICommandService).syncExecuteCommand(N.id,i)};var x=Object.getOwnPropertyDescriptor,E=(r,i,e,t)=>{for(var n=t>1?void 0:t?x(i,e):i,s=r.length-1,o;s>=0;s--)(o=r[s])&&(n=o(n)||n);return n},V=(r,i)=>(e,t)=>i(e,t,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[v,I,N,S,y,R,O].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=E([V(0,a.ICommandService)],C);var A=Object.defineProperty,W=Object.getOwnPropertyDescriptor,L=(r,i,e)=>i in r?A(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,J=(r,i,e,t)=>{for(var n=t>1?void 0:t?W(i,e):i,s=r.length-1,o;s>=0;s--)(o=r[s])&&(n=o(n)||n);return n},U=(r,i)=>(e,t)=>i(e,t,r),T=(r,i,e)=>L(r,typeof i!="symbol"?i+"":i,e);const P="SHEET_NOTE_PLUGIN";u.SheetsNotePlugin=class extends a.Plugin{constructor(i,e){super(),this._configService=i,this._injector=e}onStarting(){[[m],[C],[u.SheetsNoteResourceController],[M]].forEach(i=>{this._injector.add(i)}),a.touchDependencies(this._injector,[[m],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},T(u.SheetsNotePlugin,"pluginName",P),T(u.SheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.SheetsNotePlugin=J([a.DependentOn(l.UniverSheetsPlugin),U(0,a.IConfigService),U(1,a.Inject(a.Injector))],u.SheetsNotePlugin),u.PLUGIN_NAME=P,u.RemoveNoteMutation=S,u.SheetDeleteNoteCommand=y,u.SheetToggleNotePopupCommand=R,u.SheetUpdateNoteCommand=O,u.SheetsNoteModel=m,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,_){"use strict";var H=Object.defineProperty;var z=(u,a,l)=>a in u?H(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var p=(u,a,l)=>z(u,typeof a!="symbol"?a+"":a,l);class m extends a.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new _.Subject);p(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let n=this._noteMatrix.get(e);n||(n=new Map,this._noteMatrix.set(e,n));let s=n.get(t);return s||(s=new a.ObjectMatrix,n.set(t,s)),s}getSheetShowNotes$(e,t){return this._change$.pipe(_.filter(({unitId:n,sheetId:s})=>n===e&&s===t),_.map(()=>{const n=this._ensureNoteMatrix(e,t),s=[];return n.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:e,subUnitId:t},note:c})}),s}))}getCellNoteChange$(e,t,n,s){return this._change$.pipe(_.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===e&&h===t&&c===n&&d===s),_.map(({note:i})=>i))}updateNote(e,t,n,s,i,h){const c=this._ensureNoteMatrix(e,t),d=c.getValue(n,s);c.setValue(n,s,i),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(e,t,n,s,i){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);h.realDeleteValue(n,s),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(e,t,n,s,i){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(n,s,d),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(e,t,n,s,i,h,c){const d=this._ensureNoteMatrix(e,t),g=d.getValue(n,s);g&&(d.realDeleteValue(n,s),d.setValue(i,h,g),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"ref",newPosition:{row:i,col:h},note:g,silent:c}))}getNote(e,t,n,s){return this._ensureNoteMatrix(e,t).getValue(n,s)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const n=this._noteMatrix.get(e);if(n)return n.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,note:i,silent:h}=o;return r.get(m).updateNote(e,t,n,s,i,h),!0}},v={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:i}=o;return r.get(m).removeNote(e,t,n,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:i}=o;return r.get(m).toggleNotePopup(e,t,n,s,i),!0}},S={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,newPosition:i,silent:h}=o;return r.get(m).updateNotePosition(e,t,n,s,i.row,i.col,h),!0}};var b=Object.getOwnPropertyDescriptor,$=(r,o,e,t)=>{for(var n=t>1?void 0:t?b(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},f=(r,o)=>(e,t)=>o(e,t,r);let M=class extends a.Disposable{constructor(o,e,t,n){super();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(this,"_handleRangeChange",(o,e,t,n,s,i,h)=>i?{redos:[{id:S.id,params:{unitId:o,sheetId:e,row:n,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:S.id,params:{unitId:o,sheetId:e,row:i.startRow,col:i.startColumn,newPosition:{row:n,col:s},note:t,silent:h}}]}:{redos:[{id:v.id,params:{unitId:o,sheetId:e,row:n,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:e,row:n,col:s,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=n,this._initData(),this._initRefRange()}_getIdWithUnitId(o,e,t,n){return`${o}-${e}-${t}-${n}`}_register(o,e,t,n,s){const i={startColumn:s,endColumn:s,startRow:n,endRow:n};this._disposableMap.set(this._getIdWithUnitId(o,e,n,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,e,t,n,s,d,!1)},o,e))}_watch(o,e,t,n,s){const i={startColumn:s,endColumn:s,startRow:n,endRow:n};this._watcherMap.set(this._getIdWithUnitId(o,e,n,s),this._refRangeService.watchRange(o,e,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,e,t,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,e,t,n){var i;const s=this._getIdWithUnitId(o,e,t,n);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,e,t,n){var i;const s=this._getIdWithUnitId(o,e,t,n);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[e,t]of o)for(const[n,s]of t)s.forValue((i,h,c)=>(c&&(this._register(e,n,c,i,h),this._watch(e,n,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:e,sheetId:t,row:n,col:s,note:i}=o,h=this._getIdWithUnitId(e,t,n,s);i?this._disposableMap.has(h)||(this._register(e,t,i,n,s),this._watch(e,t,i,n,s)):(this._unregister(e,t,n,s),this._unwatch(e,t,n,s));break}case"ref":{const{unitId:e,sheetId:t,row:n,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(e,t,n,s),c||(this._unwatch(e,t,n,s),this._watch(e,t,h,i.row,i.col)),this._register(e,t,h,i.row,i.col);break}}}))}};M=$([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(m)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var D=Object.getOwnPropertyDescriptor,j=(r,o,e,t)=>{for(var n=t>1?void 0:t?D(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},w=(r,o)=>(e,t)=>o(e,t,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,e,t){super(),this._resourceManagerService=o,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const o=t=>{const n=this._sheetsNoteModel.getUnitNotes(t);if(!n)return"";const s={};return n.forEach((i,h)=>{const c={};i.forValue((d,g,q)=>{c[d]||(c[d]={}),c[d][g]=q}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:T,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,n)=>{Object.entries(n).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,g])=>{this._sheetsNoteModel.updateNote(t,s,Number(h),Number(d),g)})})})}}))}},u.SheetsNoteResourceController=j([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(m))],u.SheetsNoteResourceController);const y={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)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(v.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},P={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)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:t.unitId,sheetId:t.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)};var x=Object.getOwnPropertyDescriptor,E=(r,o,e,t)=>{for(var n=t>1?void 0:t?x(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},V=(r,o)=>(e,t)=>o(e,t,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[S,I,N,v,y,P,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=E([V(0,a.ICommandService)],C);var A=Object.defineProperty,W=Object.getOwnPropertyDescriptor,L=(r,o,e)=>o in r?A(r,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[o]=e,J=(r,o,e,t)=>{for(var n=t>1?void 0:t?W(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},U=(r,o)=>(e,t)=>o(e,t,r),O=(r,o,e)=>L(r,typeof o!="symbol"?o+"":o,e);const T="SHEET_NOTE_PLUGIN";u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o,e){super(),this._configService=o,this._injector=e}onStarting(){[[m],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[m],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},O(u.UniverSheetsNotePlugin,"pluginName",T),O(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=J([a.DependentOn(l.UniverSheetsPlugin),U(0,a.IConfigService),U(1,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=v,u.SheetDeleteNoteCommand=y,u.SheetToggleNotePopupCommand=P,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=m,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=S,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.7.0-nightly.202505061607",
3
+ "version": "0.7.0-nightly.202505081607",
4
4
  "private": false,
5
5
  "description": "Univer sheets note base plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,8 +56,8 @@
56
56
  "rxjs": ">=7.0.0"
57
57
  },
58
58
  "dependencies": {
59
- "@univerjs/core": "0.7.0-nightly.202505061607",
60
- "@univerjs/sheets": "0.7.0-nightly.202505061607"
59
+ "@univerjs/core": "0.7.0-nightly.202505081607",
60
+ "@univerjs/sheets": "0.7.0-nightly.202505081607"
61
61
  },
62
62
  "devDependencies": {
63
63
  "rxjs": "^7.8.1",