@univerjs/sheets-note 0.8.2 → 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",
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",
60
- "@univerjs/sheets": "0.8.2"
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
- "vitest": "^3.1.4",
67
- "@univerjs-infra/shared": "0.8.2"
66
+ "vitest": "^3.2.4",
67
+ "@univerjs-infra/shared": "0.8.3"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS