@univerjs/sheets-note 0.16.0 → 0.16.1-insiders.20260311-074e8ca
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 +1 -1
- package/lib/es/index.js +118 -113
- package/lib/index.js +118 -113
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
- package/LICENSE +0 -176
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var A=(i,r,t)=>r in i?x(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t;var S=(i,r,t)=>A(i,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),g=require("@univerjs/sheets"),f=require("rxjs");class _ extends h.Disposable{constructor(){super(...arguments);S(this,"_notesMap",new Map);S(this,"_change$",new f.Subject);S(this,"change$",this._change$.asObservable())}_ensureNotesMap(t,e){let o=this._notesMap.get(t);o||(o=new Map,this._notesMap.set(t,o));let s=o.get(e);return s||(s=new Map,o.set(e,s)),s}_getNoteByPosition(t,e,o,s){const n=this._ensureNotesMap(t,e);for(const[a,c]of n)if(c.row===o&&c.col===s)return c}_getNoteById(t,e,o){return this._ensureNotesMap(t,e).get(o)}_getNoteByParams(t,e,o){const{noteId:s,row:n,col:a}=o;return s?this._getNoteById(t,e,s):n!==void 0&&a!==void 0?this._getNoteByPosition(t,e,n,a):null}getSheetShowNotes$(t,e){return this._change$.pipe(f.filter(({unitId:o,subUnitId:s})=>o===t&&s===e),f.map(()=>{const o=this._ensureNotesMap(t,e),s=[];for(const[n,a]of o)a.show&&s.push({loc:{row:a.row,col:a.col,unitId:t,subUnitId:e},note:a});return s}))}getCellNoteChange$(t,e,o,s){return this._change$.pipe(f.filter(({unitId:n,subUnitId:a,oldNote:c})=>n!==t||a!==e||!c?!1:c.row===o&&c.col===s),f.map(n=>n))}updateNote(t,e,o,s,n,a){const c=this._getNoteByParams(t,e,{noteId:n==null?void 0:n.id,row:o,col:s}),d=this._ensureNotesMap(t,e),u={...n,id:(c==null?void 0:c.id)||n.id||h.generateRandomId(6),row:o,col:s};d.set(u.id,u),this._change$.next({unitId:t,subUnitId:e,oldNote:c,type:"update",newNote:u,silent:a})}removeNote(t,e,o){const{noteId:s,row:n,col:a,silent:c}=o,d=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!d)return;this._ensureNotesMap(t,e).delete(d.id),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:null,silent:c})}toggleNotePopup(t,e,o){const{noteId:s,row:n,col:a,silent:c}=o,d=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!d)return;const u=this._ensureNotesMap(t,e),l={...d,show:!d.show};u.set(l.id,l),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:l,silent:c})}updateNotePosition(t,e,o){const{noteId:s,row:n,col:a,newRow:c,newCol:d,silent:u}=o,l=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!l)return;const p=this._ensureNotesMap(t,e),m={...l,row:c,col:d};p.set(m.id,m),this._change$.next({unitId:t,subUnitId:e,oldNote:l,type:"ref",newNote:m,silent:u})}getNote(t,e,o){return this._getNoteByParams(t,e,o)}getNotes(){return this._notesMap}getUnitNotes(t){return this._notesMap.get(t)}getSheetNotes(t,e){const o=this._notesMap.get(t);if(o)return o.get(e)}deleteUnitNotes(t){this._notesMap.delete(t)}}const N={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,row:o,col:s,note:n,silent:a}=r;return i.get(_).updateNote(t,e,o,s,n,a),!0}},M={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,silent:a}=r;return i.get(_).removeNote(t,e,{noteId:o,row:s,col:n,silent:a}),!0}},w={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,silent:a}=r;return i.get(_).toggleNotePopup(t,e,{noteId:o,row:s,col:n,silent:a}),!0}},C={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,newPosition:a,silent:c}=r;return i.get(_).updateNotePosition(t,e,{noteId:o,row:s,col:n,newRow:a.row,newCol:a.col,silent:c}),!0}},E={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:i=>{const r=g.getSheetCommandTarget(i.get(h.IUniverInstanceService));if(!r)return!1;const e=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const o=i.get(_),{unitId:s,subUnitId:n}=r,{actualColumn:a,actualRow:c}=e.primary,d=o.getNote(s,n,{row:c,col:a});if(!d)return!1;const u=i.get(h.ICommandService),l=i.get(h.IUndoRedoService),p={id:M.id,params:{unitId:s,sheetId:n,noteId:d.id}},m={id:N.id,params:{unitId:s,sheetId:n,row:c,col:a,note:{...d}}};return u.syncExecuteCommand(p.id,p.params)?(l.pushUndoRedo({unitID:s,redoMutations:[p],undoMutations:[m]}),!0):!1}},O={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:i=>{const r=g.getSheetCommandTarget(i.get(h.IUniverInstanceService));if(!r)return!1;const e=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const o=i.get(_),{unitId:s,subUnitId:n}=r,{actualColumn:a,actualRow:c}=e.primary,d=o.getNote(s,n,{row:c,col:a});if(!d)return!1;const u=i.get(h.ICommandService),l=i.get(h.IUndoRedoService),p={id:w.id,params:{unitId:s,sheetId:n,noteId:d.id}},m={id:w.id,params:{unitId:s,sheetId:n,noteId:d.id}};return u.syncExecuteCommand(p.id,p.params)?(l.pushUndoRedo({unitID:s,redoMutations:[p],undoMutations:[m]}),!0):!1}},D={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,r)=>{const t=g.getSheetCommandTarget(i.get(h.IUniverInstanceService),r);if(!t)return!1;const e=i.get(h.ICommandService),o=i.get(h.IUndoRedoService),s=i.get(_),{unitId:n,subUnitId:a}=t,{row:c,col:d,note:u}=r,l=s.getNote(n,a,{noteId:u.id,row:c,col:d}),p={id:N.id,params:{unitId:n,sheetId:a,row:c,col:d,note:u}},m=[];if(l){const U={id:N.id,params:{unitId:n,sheetId:a,row:c,col:d,note:{...l}}};m.push(U)}else{const U={id:M.id,params:{unitId:n,sheetId:a,row:c,col:d}};m.push(U)}return e.syncExecuteCommand(p.id,p.params)?(o.pushUndoRedo({unitID:n,redoMutations:[p],undoMutations:m}),!0):!1}},$="SHEET_NOTE_PLUGIN";var W=Object.getOwnPropertyDescriptor,B=(i,r,t,e)=>{for(var o=e>1?void 0:e?W(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},v=(i,r)=>(t,e)=>r(t,e,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(r,t,e,o){super(),this._resourceManagerService=r,this._univerInstanceService=t,this._sheetInterceptorService=e,this._sheetsNoteModel=o,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const r=e=>{const o=this._sheetsNoteModel.getUnitNotes(e);if(!o)return"";const s={};return o.forEach((n,a)=>{const c={};n.forEach(d=>{const{row:u,col:l}=d;c[u]||(c[u]={}),c[u][l]=d}),Object.keys(c).length>0&&(s[a]=c)}),JSON.stringify(s)},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:$,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,o)=>{Object.entries(o).forEach(([s,n])=>{Object.entries(n).forEach(([a,c])=>{Object.entries(c).forEach(([d,u])=>{this._sheetsNoteModel.updateNote(e,s,Number(a),Number(d),u)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===g.RemoveSheetCommand.id){const e=r.params,o=e.unitId||this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=e.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!o||!s)return{redos:[],undos:[]};const n=this._sheetsNoteModel.getSheetNotes(o,s);if(!n)return{redos:[],undos:[]};const a=[],c=[];return n.forEach(d=>{a.push({id:M.id,params:{unitId:o,sheetId:s,noteId:d.id,row:d.row,col:d.col}}),c.push({id:N.id,params:{unitId:o,sheetId:s,row:d.row,col:d.col,note:d}})}),{redos:a,undos:c}}else if(r.id===g.CopySheetCommand.id){const e=r.params,{unitId:o,subUnitId:s,targetSubUnitId:n}=e;if(!o||!s||!n)return{redos:[],undos:[]};const a=this._sheetsNoteModel.getSheetNotes(o,s);if(!a)return{redos:[],undos:[]};const c=[],d=[];return a.forEach(u=>{const l={...u,id:h.generateRandomId(6)};c.push({id:N.id,params:{unitId:o,sheetId:n,row:l.row,col:l.col,note:l}}),d.push({id:M.id,params:{unitId:o,sheetId:n,noteId:l.id,row:l.row,col:l.col}})}),{redos:c,undos:d}}return{redos:[],undos:[]}}}))}};exports.SheetsNoteResourceController=B([v(0,h.IResourceManagerService),v(1,h.IUniverInstanceService),v(2,h.Inject(g.SheetInterceptorService)),v(3,h.Inject(_))],exports.SheetsNoteResourceController);const L="sheets-note.config",T={};var H=Object.getOwnPropertyDescriptor,J=(i,r,t,e)=>{for(var o=e>1?void 0:e?H(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},I=(i,r)=>(t,e)=>r(t,e,i);let R=class extends h.Disposable{constructor(r,t,e,o){super();S(this,"_disposableMap",new Map);S(this,"_watcherMap",new Map);S(this,"_handleRangeChange",(r,t,e,o,s,n,a)=>n?{redos:[{id:C.id,params:{unitId:r,sheetId:t,noteId:e.id,newPosition:{row:n.startRow,col:n.startColumn},silent:a}}],undos:[{id:C.id,params:{unitId:r,sheetId:t,noteId:e.id,newPosition:{row:o,col:s},note:e,silent:a}}]}:{redos:[{id:M.id,params:{unitId:r,sheetId:t,noteId:e.id}}],undos:[{id:N.id,params:{unitId:r,sheetId:t,row:o,col:s,note:e}}]});this._refRangeService=r,this._sheetsNoteModel=t,this._selectionManagerService=e,this._commandService=o,this._initData(),this._initRefRange()}_getIdWithUnitId(r,t,e,o){return`${r}-${t}-${e}-${o}`}_register(r,t,e,o,s){const n={startColumn:s,endColumn:s,startRow:o,endRow:o};this._disposableMap.set(this._getIdWithUnitId(r,t,o,s),this._refRangeService.registerRefRange(n,a=>{const c=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(n,a,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===n.startColumn&&d.startRow===n.startRow?{undos:[],redos:[]}:this._handleRangeChange(r,t,e,o,s,d,!1)},r,t))}_watch(r,t,e,o,s){const n={startColumn:s,endColumn:s,startRow:o,endRow:o};this._watcherMap.set(this._getIdWithUnitId(r,t,o,s),this._refRangeService.watchRange(r,t,n,(a,c)=>{const{redos:d}=this._handleRangeChange(r,t,e,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(r,t,e,o){var n;const s=this._getIdWithUnitId(r,t,e,o);(n=this._watcherMap.get(s))==null||n.dispose(),this._watcherMap.delete(s)}_unregister(r,t,e,o){var n;const s=this._getIdWithUnitId(r,t,e,o);(n=this._disposableMap.get(s))==null||n.dispose(),this._disposableMap.delete(s)}_initData(){const r=this._sheetsNoteModel.getNotes();for(const[t,e]of r)for(const[o,s]of e)s.forEach(n=>{this._register(t,o,n,n.row,n.col),this._watch(t,o,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(r=>{switch(r.type){case"update":{const{unitId:t,subUnitId:e,oldNote:o,newNote:s}=r,n=s?s.row:o.row,a=s?s.col:o.col,c=this._getIdWithUnitId(t,e,n,a);s?this._disposableMap.has(c)||(this._register(t,e,s,n,a),this._watch(t,e,s,n,a)):(this._unregister(t,e,n,a),this._unwatch(t,e,n,a));break}case"ref":{const{unitId:t,subUnitId:e,oldNote:o,newNote:s,silent:n}=r,{row:a,col:c}=o,{row:d,col:u}=s;this._unregister(t,e,a,c),n||(this._unwatch(t,e,a,c),this._watch(t,e,s,d,u)),this._register(t,e,s,d,u);break}}}))}};R=J([I(0,h.Inject(g.RefRangeService)),I(1,h.Inject(_)),I(2,h.Inject(g.SheetsSelectionsService)),I(3,h.ICommandService)],R);var q=Object.getOwnPropertyDescriptor,G=(i,r,t,e)=>{for(var o=e>1?void 0:e?q(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},V=(i,r)=>(t,e)=>r(t,e,i);let y=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[C,w,N,M,E,O,D].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};y=G([V(0,h.ICommandService)],y);var z=Object.defineProperty,F=Object.getOwnPropertyDescriptor,K=(i,r,t)=>r in i?z(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t,Y=(i,r,t,e)=>{for(var o=e>1?void 0:e?F(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},b=(i,r)=>(t,e)=>r(t,e,i),j=(i,r,t)=>K(i,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(r=T,t,e){super(),this._config=r,this._configService=t,this._injector=e;const{...o}=h.merge({},T,this._config);this._configService.setConfig(L,o)}onStarting(){[[_],[y],[exports.SheetsNoteResourceController],[R]].forEach(r=>{this._injector.add(r)}),h.touchDependencies(this._injector,[[_],[y],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[R]])}};j(exports.UniverSheetsNotePlugin,"pluginName",$);j(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=Y([h.DependentOn(g.UniverSheetsPlugin),b(1,h.IConfigService),b(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=M;exports.SheetDeleteNoteCommand=E;exports.SheetToggleNotePopupCommand=O;exports.SheetUpdateNoteCommand=D;exports.SheetsNoteModel=_;exports.ToggleNotePopupMutation=w;exports.UpdateNoteMutation=N;exports.UpdateNotePositionMutation=C;
|
|
1
|
+
"use strict";var A=Object.defineProperty;var W=(i,r,t)=>r in i?A(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t;var S=(i,r,t)=>W(i,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),g=require("@univerjs/sheets"),M=require("rxjs");class _ extends h.Disposable{constructor(){super(...arguments);S(this,"_notesMap",new Map);S(this,"_change$",new M.Subject);S(this,"change$",this._change$.asObservable())}_ensureNotesMap(t,e){let o=this._notesMap.get(t);o||(o=new Map,this._notesMap.set(t,o));let s=o.get(e);return s||(s=new Map,o.set(e,s)),s}_getNoteByPosition(t,e,o,s){const n=this._ensureNotesMap(t,e);for(const[a,c]of n)if(c.row===o&&c.col===s)return c}_getNoteById(t,e,o){return this._ensureNotesMap(t,e).get(o)}_getNoteByParams(t,e,o){const{noteId:s,row:n,col:a}=o;return s?this._getNoteById(t,e,s):n!==void 0&&a!==void 0?this._getNoteByPosition(t,e,n,a):null}getSheetShowNotes$(t,e){return this._change$.pipe(M.filter(({unitId:o,subUnitId:s})=>o===t&&s===e),M.map(()=>{const o=this._ensureNotesMap(t,e),s=[];for(const[n,a]of o)a.show&&s.push({loc:{row:a.row,col:a.col,unitId:t,subUnitId:e},note:a});return s}))}getCellNoteChange$(t,e,o,s){return this._change$.pipe(M.filter(({unitId:n,subUnitId:a,oldNote:c})=>n!==t||a!==e||!c?!1:c.row===o&&c.col===s),M.map(n=>n))}updateNote(t,e,o,s,n,a){const c=this._getNoteByParams(t,e,{noteId:n==null?void 0:n.id,row:o,col:s}),d=this._ensureNotesMap(t,e),u={...n,id:(c==null?void 0:c.id)||n.id||h.generateRandomId(6),row:o,col:s};d.set(u.id,u),this._change$.next({unitId:t,subUnitId:e,oldNote:c,type:"update",newNote:u,silent:a})}removeNote(t,e,o){const{noteId:s,row:n,col:a,silent:c}=o,d=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!d)return;this._ensureNotesMap(t,e).delete(d.id),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:null,silent:c})}toggleNotePopup(t,e,o){const{noteId:s,row:n,col:a,silent:c}=o,d=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!d)return;const u=this._ensureNotesMap(t,e),l={...d,show:!d.show};u.set(l.id,l),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:l,silent:c})}updateNotePosition(t,e,o){const{noteId:s,row:n,col:a,newRow:c,newCol:d,silent:u}=o,l=this._getNoteByParams(t,e,{noteId:s,row:n,col:a});if(!l)return;const p=this._ensureNotesMap(t,e),m={...l,row:c,col:d};p.set(m.id,m),this._change$.next({unitId:t,subUnitId:e,oldNote:l,type:"ref",newNote:m,silent:u})}getNote(t,e,o){return this._getNoteByParams(t,e,o)}getNotes(){return this._notesMap}getUnitNotes(t){return this._notesMap.get(t)}getSheetNotes(t,e){const o=this._notesMap.get(t);if(o)return o.get(e)}deleteUnitNotes(t){this._notesMap.delete(t)}}const N={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,row:o,col:s,note:n,silent:a}=r;return i.get(_).updateNote(t,e,o,s,n,a),!0}},v={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,silent:a}=r;return i.get(_).removeNote(t,e,{noteId:o,row:s,col:n,silent:a}),!0}},w={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,silent:a}=r;return i.get(_).toggleNotePopup(t,e,{noteId:o,row:s,col:n,silent:a}),!0}},C={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,r)=>{const{unitId:t,sheetId:e,noteId:o,row:s,col:n,newPosition:a,silent:c}=r;return i.get(_).updateNotePosition(t,e,{noteId:o,row:s,col:n,newRow:a.row,newCol:a.col,silent:c}),!0}},O={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:i=>{const r=g.getSheetCommandTarget(i.get(h.IUniverInstanceService));if(!r)return!1;const e=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const o=i.get(_),{unitId:s,subUnitId:n}=r,{actualColumn:a,actualRow:c}=e.primary,d=o.getNote(s,n,{row:c,col:a});if(!d)return!1;const u=i.get(h.ICommandService),l=i.get(h.IUndoRedoService),p={id:v.id,params:{unitId:s,sheetId:n,noteId:d.id}},m={id:N.id,params:{unitId:s,sheetId:n,row:c,col:a,note:{...d}}};return u.syncExecuteCommand(p.id,p.params)?(l.pushUndoRedo({unitID:s,redoMutations:[p],undoMutations:[m]}),!0):!1}},D={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:i=>{const r=g.getSheetCommandTarget(i.get(h.IUniverInstanceService));if(!r)return!1;const e=i.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const o=i.get(_),{unitId:s,subUnitId:n}=r,{actualColumn:a,actualRow:c}=e.primary,d=o.getNote(s,n,{row:c,col:a});if(!d)return!1;const u=i.get(h.ICommandService),l=i.get(h.IUndoRedoService),p={id:w.id,params:{unitId:s,sheetId:n,noteId:d.id}},m={id:w.id,params:{unitId:s,sheetId:n,noteId:d.id}};return u.syncExecuteCommand(p.id,p.params)?(l.pushUndoRedo({unitID:s,redoMutations:[p],undoMutations:[m]}),!0):!1}},$={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,r)=>{const t=g.getSheetCommandTarget(i.get(h.IUniverInstanceService),r);if(!t)return!1;const e=i.get(h.ICommandService),o=i.get(h.IUndoRedoService),s=i.get(_),{unitId:n,subUnitId:a}=t,{row:c,col:d,note:u}=r,l=s.getNote(n,a,{noteId:u.id,row:c,col:d}),p={id:N.id,params:{unitId:n,sheetId:a,row:c,col:d,note:u}},m=[];if(l){const P={id:N.id,params:{unitId:n,sheetId:a,row:c,col:d,note:{...l}}};m.push(P)}else{const P={id:v.id,params:{unitId:n,sheetId:a,row:c,col:d}};m.push(P)}return e.syncExecuteCommand(p.id,p.params)?(o.pushUndoRedo({unitID:n,redoMutations:[p],undoMutations:m}),!0):!1}},j="SHEET_NOTE_PLUGIN";var B=Object.getOwnPropertyDescriptor,L=(i,r,t,e)=>{for(var o=e>1?void 0:e?B(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},f=(i,r)=>(t,e)=>r(t,e,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(r,t,e,o){super(),this._resourceManagerService=r,this._univerInstanceService=t,this._sheetInterceptorService=e,this._sheetsNoteModel=o,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const r=e=>{const o=this._sheetsNoteModel.getUnitNotes(e);if(!o)return"";const s={};return o.forEach((n,a)=>{const c={};n.forEach(d=>{const{row:u,col:l}=d;c[u]||(c[u]={}),c[u][l]=d}),Object.keys(c).length>0&&(s[a]=c)}),JSON.stringify(s)},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:j,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,o)=>{Object.entries(o).forEach(([s,n])=>{Object.entries(n).forEach(([a,c])=>{Object.entries(c).forEach(([d,u])=>{this._sheetsNoteModel.updateNote(e,s,Number(a),Number(d),u)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===g.RemoveSheetCommand.id){const e=r.params,o=e.unitId||this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=e.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!o||!s)return{redos:[],undos:[]};const n=this._sheetsNoteModel.getSheetNotes(o,s);if(!n)return{redos:[],undos:[]};const a=[],c=[];return n.forEach(d=>{a.push({id:v.id,params:{unitId:o,sheetId:s,noteId:d.id,row:d.row,col:d.col}}),c.push({id:N.id,params:{unitId:o,sheetId:s,row:d.row,col:d.col,note:d}})}),{redos:a,undos:c}}else if(r.id===g.CopySheetCommand.id){const e=r.params,{unitId:o,subUnitId:s,targetSubUnitId:n}=e;if(!o||!s||!n)return{redos:[],undos:[]};const a=this._sheetsNoteModel.getSheetNotes(o,s);if(!a)return{redos:[],undos:[]};const c=[],d=[];return a.forEach(u=>{const l={...u,id:h.generateRandomId(6)};c.push({id:N.id,params:{unitId:o,sheetId:n,row:l.row,col:l.col,note:l}}),d.push({id:v.id,params:{unitId:o,sheetId:n,noteId:l.id,row:l.row,col:l.col}})}),{redos:c,undos:d}}return{redos:[],undos:[]}}}))}};exports.SheetsNoteResourceController=L([f(0,h.IResourceManagerService),f(1,h.IUniverInstanceService),f(2,h.Inject(g.SheetInterceptorService)),f(3,h.Inject(_))],exports.SheetsNoteResourceController);const H="@univerjs/sheets-note",J="0.16.1-insiders.20260311-074e8ca",x={name:H,version:J},q="sheets-note.config",b={};var G=Object.getOwnPropertyDescriptor,V=(i,r,t,e)=>{for(var o=e>1?void 0:e?G(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},I=(i,r)=>(t,e)=>r(t,e,i);let R=class extends h.Disposable{constructor(r,t,e,o){super();S(this,"_disposableMap",new Map);S(this,"_watcherMap",new Map);S(this,"_handleRangeChange",(r,t,e,o,s,n,a)=>n?{redos:[{id:C.id,params:{unitId:r,sheetId:t,noteId:e.id,newPosition:{row:n.startRow,col:n.startColumn},silent:a}}],undos:[{id:C.id,params:{unitId:r,sheetId:t,noteId:e.id,newPosition:{row:o,col:s},note:e,silent:a}}]}:{redos:[{id:v.id,params:{unitId:r,sheetId:t,noteId:e.id}}],undos:[{id:N.id,params:{unitId:r,sheetId:t,row:o,col:s,note:e}}]});this._refRangeService=r,this._sheetsNoteModel=t,this._selectionManagerService=e,this._commandService=o,this._initData(),this._initRefRange()}_getIdWithUnitId(r,t,e,o){return`${r}-${t}-${e}-${o}`}_register(r,t,e,o,s){const n={startColumn:s,endColumn:s,startRow:o,endRow:o};this._disposableMap.set(this._getIdWithUnitId(r,t,o,s),this._refRangeService.registerRefRange(n,a=>{const c=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(n,a,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===n.startColumn&&d.startRow===n.startRow?{undos:[],redos:[]}:this._handleRangeChange(r,t,e,o,s,d,!1)},r,t))}_watch(r,t,e,o,s){const n={startColumn:s,endColumn:s,startRow:o,endRow:o};this._watcherMap.set(this._getIdWithUnitId(r,t,o,s),this._refRangeService.watchRange(r,t,n,(a,c)=>{const{redos:d}=this._handleRangeChange(r,t,e,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(r,t,e,o){var n;const s=this._getIdWithUnitId(r,t,e,o);(n=this._watcherMap.get(s))==null||n.dispose(),this._watcherMap.delete(s)}_unregister(r,t,e,o){var n;const s=this._getIdWithUnitId(r,t,e,o);(n=this._disposableMap.get(s))==null||n.dispose(),this._disposableMap.delete(s)}_initData(){const r=this._sheetsNoteModel.getNotes();for(const[t,e]of r)for(const[o,s]of e)s.forEach(n=>{this._register(t,o,n,n.row,n.col),this._watch(t,o,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(r=>{switch(r.type){case"update":{const{unitId:t,subUnitId:e,oldNote:o,newNote:s}=r,n=s?s.row:o.row,a=s?s.col:o.col,c=this._getIdWithUnitId(t,e,n,a);s?this._disposableMap.has(c)||(this._register(t,e,s,n,a),this._watch(t,e,s,n,a)):(this._unregister(t,e,n,a),this._unwatch(t,e,n,a));break}case"ref":{const{unitId:t,subUnitId:e,oldNote:o,newNote:s,silent:n}=r,{row:a,col:c}=o,{row:d,col:u}=s;this._unregister(t,e,a,c),n||(this._unwatch(t,e,a,c),this._watch(t,e,s,d,u)),this._register(t,e,s,d,u);break}}}))}};R=V([I(0,h.Inject(g.RefRangeService)),I(1,h.Inject(_)),I(2,h.Inject(g.SheetsSelectionsService)),I(3,h.ICommandService)],R);var z=Object.getOwnPropertyDescriptor,F=(i,r,t,e)=>{for(var o=e>1?void 0:e?z(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},K=(i,r)=>(t,e)=>r(t,e,i);let y=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[C,w,N,v,O,D,$].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};y=F([K(0,h.ICommandService)],y);var Y=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,X=(i,r,t)=>r in i?Y(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t,Z=(i,r,t,e)=>{for(var o=e>1?void 0:e?Q(r,t):r,s=i.length-1,n;s>=0;s--)(n=i[s])&&(o=n(o)||o);return o},E=(i,r)=>(t,e)=>r(t,e,i),U=(i,r,t)=>X(i,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(r=b,t,e){super(),this._config=r,this._configService=t,this._injector=e;const{...o}=h.merge({},b,this._config);this._configService.setConfig(q,o)}onStarting(){[[_],[y],[exports.SheetsNoteResourceController],[R]].forEach(r=>{this._injector.add(r)}),h.touchDependencies(this._injector,[[_],[y],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[R]])}};U(exports.UniverSheetsNotePlugin,"pluginName",j);U(exports.UniverSheetsNotePlugin,"packageName",x.name);U(exports.UniverSheetsNotePlugin,"version",x.version);U(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=Z([h.DependentOn(g.UniverSheetsPlugin),E(1,h.IConfigService),E(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=v;exports.SheetDeleteNoteCommand=O;exports.SheetToggleNotePopupCommand=D;exports.SheetUpdateNoteCommand=$;exports.SheetsNoteModel=_;exports.ToggleNotePopupMutation=w;exports.UpdateNoteMutation=N;exports.UpdateNotePositionMutation=C;
|
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var _ = (i, r, e) =>
|
|
4
|
-
import { Disposable as U, generateRandomId as
|
|
5
|
-
import { getSheetCommandTarget as
|
|
6
|
-
import { Subject as
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var q = (i, r, e) => r in i ? F(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
|
|
3
|
+
var _ = (i, r, e) => q(i, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { Disposable as U, generateRandomId as G, CommandType as N, IUniverInstanceService as E, ICommandService as v, IUndoRedoService as D, Inject as f, UniverInstanceType as C, IResourceManagerService as K, sequenceExecuteAsync as Y, DependentOn as Q, Injector as X, Plugin as Z, merge as k, touchDependencies as W, IConfigService as ee } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as j, SheetsSelectionsService as x, SheetInterceptorService as te, RemoveSheetCommand as se, CopySheetCommand as oe, RefRangeService as ne, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as re, UniverSheetsPlugin as ie } from "@univerjs/sheets";
|
|
6
|
+
import { Subject as ae, filter as B, map as L } from "rxjs";
|
|
7
7
|
class g extends U {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
_(this, "_notesMap", /* @__PURE__ */ new Map());
|
|
11
|
-
_(this, "_change$", new
|
|
11
|
+
_(this, "_change$", new ae());
|
|
12
12
|
_(this, "change$", this._change$.asObservable());
|
|
13
13
|
}
|
|
14
14
|
_ensureNotesMap(e, t) {
|
|
@@ -32,8 +32,8 @@ class g extends U {
|
|
|
32
32
|
}
|
|
33
33
|
getSheetShowNotes$(e, t) {
|
|
34
34
|
return this._change$.pipe(
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
B(({ unitId: s, subUnitId: o }) => s === e && o === t),
|
|
36
|
+
L(() => {
|
|
37
37
|
const s = this._ensureNotesMap(e, t), o = [];
|
|
38
38
|
for (const [n, a] of s)
|
|
39
39
|
a.show && o.push({ loc: { row: a.row, col: a.col, unitId: e, subUnitId: t }, note: a });
|
|
@@ -43,14 +43,14 @@ class g extends U {
|
|
|
43
43
|
}
|
|
44
44
|
getCellNoteChange$(e, t, s, o) {
|
|
45
45
|
return this._change$.pipe(
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
B(({ unitId: n, subUnitId: a, oldNote: c }) => n !== e || a !== t || !c ? !1 : c.row === s && c.col === o),
|
|
47
|
+
L((n) => n)
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
updateNote(e, t, s, o, n, a) {
|
|
51
51
|
const c = this._getNoteByParams(e, t, { noteId: n == null ? void 0 : n.id, row: s, col: o }), d = this._ensureNotesMap(e, t), h = {
|
|
52
52
|
...n,
|
|
53
|
-
id: (c == null ? void 0 : c.id) || n.id ||
|
|
53
|
+
id: (c == null ? void 0 : c.id) || n.id || G(6),
|
|
54
54
|
row: s,
|
|
55
55
|
col: o
|
|
56
56
|
};
|
|
@@ -94,45 +94,45 @@ class g extends U {
|
|
|
94
94
|
this._notesMap.delete(e);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
const
|
|
97
|
+
const m = {
|
|
98
98
|
id: "sheet.mutation.update-note",
|
|
99
|
-
type:
|
|
99
|
+
type: N.MUTATION,
|
|
100
100
|
handler: (i, r) => {
|
|
101
101
|
const { unitId: e, sheetId: t, row: s, col: o, note: n, silent: a } = r;
|
|
102
102
|
return i.get(g).updateNote(e, t, s, o, n, a), !0;
|
|
103
103
|
}
|
|
104
104
|
}, M = {
|
|
105
105
|
id: "sheet.mutation.remove-note",
|
|
106
|
-
type:
|
|
106
|
+
type: N.MUTATION,
|
|
107
107
|
handler: (i, r) => {
|
|
108
108
|
const { unitId: e, sheetId: t, noteId: s, row: o, col: n, silent: a } = r;
|
|
109
109
|
return i.get(g).removeNote(e, t, { noteId: s, row: o, col: n, silent: a }), !0;
|
|
110
110
|
}
|
|
111
|
-
},
|
|
111
|
+
}, $ = {
|
|
112
112
|
id: "sheet.mutation.toggle-note-popup",
|
|
113
|
-
type:
|
|
113
|
+
type: N.MUTATION,
|
|
114
114
|
handler: (i, r) => {
|
|
115
115
|
const { unitId: e, sheetId: t, noteId: s, row: o, col: n, silent: a } = r;
|
|
116
116
|
return i.get(g).toggleNotePopup(e, t, { noteId: s, row: o, col: n, silent: a }), !0;
|
|
117
117
|
}
|
|
118
|
-
},
|
|
118
|
+
}, T = {
|
|
119
119
|
id: "sheet.mutation.update-note-position",
|
|
120
|
-
type:
|
|
120
|
+
type: N.MUTATION,
|
|
121
121
|
handler: (i, r) => {
|
|
122
122
|
const { unitId: e, sheetId: t, noteId: s, row: o, col: n, newPosition: a, silent: c } = r;
|
|
123
123
|
return i.get(g).updateNotePosition(e, t, { noteId: s, row: o, col: n, newRow: a.row, newCol: a.col, silent: c }), !0;
|
|
124
124
|
}
|
|
125
|
-
},
|
|
125
|
+
}, ce = {
|
|
126
126
|
id: "sheet.command.delete-note",
|
|
127
|
-
type:
|
|
127
|
+
type: N.COMMAND,
|
|
128
128
|
handler: (i) => {
|
|
129
|
-
const r =
|
|
129
|
+
const r = j(i.get(E));
|
|
130
130
|
if (!r) return !1;
|
|
131
131
|
const t = i.get(x).getCurrentLastSelection();
|
|
132
132
|
if (!(t != null && t.primary)) return !1;
|
|
133
133
|
const s = i.get(g), { unitId: o, subUnitId: n } = r, { actualColumn: a, actualRow: c } = t.primary, d = s.getNote(o, n, { row: c, col: a });
|
|
134
134
|
if (!d) return !1;
|
|
135
|
-
const h = i.get(
|
|
135
|
+
const h = i.get(v), u = i.get(D), l = {
|
|
136
136
|
id: M.id,
|
|
137
137
|
params: {
|
|
138
138
|
unitId: o,
|
|
@@ -140,7 +140,7 @@ const N = {
|
|
|
140
140
|
noteId: d.id
|
|
141
141
|
}
|
|
142
142
|
}, p = {
|
|
143
|
-
id:
|
|
143
|
+
id: m.id,
|
|
144
144
|
params: {
|
|
145
145
|
unitId: o,
|
|
146
146
|
sheetId: n,
|
|
@@ -155,25 +155,25 @@ const N = {
|
|
|
155
155
|
undoMutations: [p]
|
|
156
156
|
}), !0) : !1;
|
|
157
157
|
}
|
|
158
|
-
},
|
|
158
|
+
}, de = {
|
|
159
159
|
id: "sheet.command.toggle-note-popup",
|
|
160
|
-
type:
|
|
160
|
+
type: N.COMMAND,
|
|
161
161
|
handler: (i) => {
|
|
162
|
-
const r =
|
|
162
|
+
const r = j(i.get(E));
|
|
163
163
|
if (!r) return !1;
|
|
164
164
|
const t = i.get(x).getCurrentLastSelection();
|
|
165
165
|
if (!(t != null && t.primary)) return !1;
|
|
166
166
|
const s = i.get(g), { unitId: o, subUnitId: n } = r, { actualColumn: a, actualRow: c } = t.primary, d = s.getNote(o, n, { row: c, col: a });
|
|
167
167
|
if (!d) return !1;
|
|
168
|
-
const h = i.get(
|
|
169
|
-
id:
|
|
168
|
+
const h = i.get(v), u = i.get(D), l = {
|
|
169
|
+
id: $.id,
|
|
170
170
|
params: {
|
|
171
171
|
unitId: o,
|
|
172
172
|
sheetId: n,
|
|
173
173
|
noteId: d.id
|
|
174
174
|
}
|
|
175
175
|
}, p = {
|
|
176
|
-
id:
|
|
176
|
+
id: $.id,
|
|
177
177
|
params: {
|
|
178
178
|
unitId: o,
|
|
179
179
|
sheetId: n,
|
|
@@ -186,14 +186,14 @@ const N = {
|
|
|
186
186
|
undoMutations: [p]
|
|
187
187
|
}), !0) : !1;
|
|
188
188
|
}
|
|
189
|
-
},
|
|
189
|
+
}, he = {
|
|
190
190
|
id: "sheet.command.update-note",
|
|
191
|
-
type:
|
|
191
|
+
type: N.COMMAND,
|
|
192
192
|
handler: (i, r) => {
|
|
193
|
-
const e =
|
|
193
|
+
const e = j(i.get(E), r);
|
|
194
194
|
if (!e) return !1;
|
|
195
|
-
const t = i.get(
|
|
196
|
-
id:
|
|
195
|
+
const t = i.get(v), s = i.get(D), o = i.get(g), { unitId: n, subUnitId: a } = e, { row: c, col: d, note: h } = r, u = o.getNote(n, a, { noteId: h.id, row: c, col: d }), l = {
|
|
196
|
+
id: m.id,
|
|
197
197
|
params: {
|
|
198
198
|
unitId: n,
|
|
199
199
|
sheetId: a,
|
|
@@ -203,8 +203,8 @@ const N = {
|
|
|
203
203
|
}
|
|
204
204
|
}, p = [];
|
|
205
205
|
if (u) {
|
|
206
|
-
const
|
|
207
|
-
id:
|
|
206
|
+
const b = {
|
|
207
|
+
id: m.id,
|
|
208
208
|
params: {
|
|
209
209
|
unitId: n,
|
|
210
210
|
sheetId: a,
|
|
@@ -213,9 +213,9 @@ const N = {
|
|
|
213
213
|
note: { ...u }
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
|
-
p.push(
|
|
216
|
+
p.push(b);
|
|
217
217
|
} else {
|
|
218
|
-
const
|
|
218
|
+
const b = {
|
|
219
219
|
id: M.id,
|
|
220
220
|
params: {
|
|
221
221
|
unitId: n,
|
|
@@ -224,7 +224,7 @@ const N = {
|
|
|
224
224
|
col: d
|
|
225
225
|
}
|
|
226
226
|
};
|
|
227
|
-
p.push(
|
|
227
|
+
p.push(b);
|
|
228
228
|
}
|
|
229
229
|
return t.syncExecuteCommand(l.id, l.params) ? (s.pushUndoRedo({
|
|
230
230
|
unitID: n,
|
|
@@ -232,13 +232,13 @@ const N = {
|
|
|
232
232
|
undoMutations: p
|
|
233
233
|
}), !0) : !1;
|
|
234
234
|
}
|
|
235
|
-
},
|
|
236
|
-
var
|
|
237
|
-
for (var s = t > 1 ? void 0 : t ?
|
|
235
|
+
}, V = "SHEET_NOTE_PLUGIN";
|
|
236
|
+
var ue = Object.getOwnPropertyDescriptor, le = (i, r, e, t) => {
|
|
237
|
+
for (var s = t > 1 ? void 0 : t ? ue(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
238
238
|
(n = i[o]) && (s = n(s) || s);
|
|
239
239
|
return s;
|
|
240
240
|
}, S = (i, r) => (e, t) => r(e, t, i);
|
|
241
|
-
let
|
|
241
|
+
let R = class extends U {
|
|
242
242
|
constructor(i, r, e, t) {
|
|
243
243
|
super(), this._resourceManagerService = i, this._univerInstanceService = r, this._sheetInterceptorService = e, this._sheetsNoteModel = t, this._initSnapshot(), this._initSheetChange();
|
|
244
244
|
}
|
|
@@ -266,8 +266,8 @@ let C = class extends U {
|
|
|
266
266
|
};
|
|
267
267
|
this.disposeWithMe(
|
|
268
268
|
this._resourceManagerService.registerPluginResource({
|
|
269
|
-
pluginName:
|
|
270
|
-
businesses: [
|
|
269
|
+
pluginName: V,
|
|
270
|
+
businesses: [C.UNIVER_SHEET],
|
|
271
271
|
toJson: (e) => i(e),
|
|
272
272
|
parseJson: (e) => r(e),
|
|
273
273
|
onUnLoad: (e) => {
|
|
@@ -298,8 +298,8 @@ let C = class extends U {
|
|
|
298
298
|
// eslint-disable-next-line max-lines-per-function
|
|
299
299
|
getMutations: (i) => {
|
|
300
300
|
var r;
|
|
301
|
-
if (i.id ===
|
|
302
|
-
const e = i.params, t = e.unitId || this._univerInstanceService.getCurrentUnitOfType(
|
|
301
|
+
if (i.id === se.id) {
|
|
302
|
+
const e = i.params, t = e.unitId || this._univerInstanceService.getCurrentUnitOfType(C.UNIVER_SHEET).getUnitId(), s = e.subUnitId || ((r = this._univerInstanceService.getCurrentUnitOfType(C.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : r.getSheetId());
|
|
303
303
|
if (!t || !s)
|
|
304
304
|
return { redos: [], undos: [] };
|
|
305
305
|
const o = this._sheetsNoteModel.getSheetNotes(t, s);
|
|
@@ -317,7 +317,7 @@ let C = class extends U {
|
|
|
317
317
|
col: c.col
|
|
318
318
|
}
|
|
319
319
|
}), a.push({
|
|
320
|
-
id:
|
|
320
|
+
id: m.id,
|
|
321
321
|
params: {
|
|
322
322
|
unitId: t,
|
|
323
323
|
sheetId: s,
|
|
@@ -327,7 +327,7 @@ let C = class extends U {
|
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
329
|
}), { redos: n, undos: a };
|
|
330
|
-
} else if (i.id ===
|
|
330
|
+
} else if (i.id === oe.id) {
|
|
331
331
|
const e = i.params, { unitId: t, subUnitId: s, targetSubUnitId: o } = e;
|
|
332
332
|
if (!t || !s || !o)
|
|
333
333
|
return { redos: [], undos: [] };
|
|
@@ -336,9 +336,9 @@ let C = class extends U {
|
|
|
336
336
|
return { redos: [], undos: [] };
|
|
337
337
|
const a = [], c = [];
|
|
338
338
|
return n.forEach((d) => {
|
|
339
|
-
const h = { ...d, id:
|
|
339
|
+
const h = { ...d, id: G(6) };
|
|
340
340
|
a.push({
|
|
341
|
-
id:
|
|
341
|
+
id: m.id,
|
|
342
342
|
params: {
|
|
343
343
|
unitId: t,
|
|
344
344
|
sheetId: o,
|
|
@@ -364,26 +364,29 @@ let C = class extends U {
|
|
|
364
364
|
);
|
|
365
365
|
}
|
|
366
366
|
};
|
|
367
|
-
|
|
368
|
-
S(0,
|
|
367
|
+
R = le([
|
|
368
|
+
S(0, K),
|
|
369
369
|
S(1, E),
|
|
370
|
-
S(2, f(
|
|
370
|
+
S(2, f(te)),
|
|
371
371
|
S(3, f(g))
|
|
372
|
-
],
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
372
|
+
], R);
|
|
373
|
+
const pe = "@univerjs/sheets-note", ge = "0.16.1-insiders.20260311-074e8ca", z = {
|
|
374
|
+
name: pe,
|
|
375
|
+
version: ge
|
|
376
|
+
}, _e = "sheets-note.config", H = {};
|
|
377
|
+
var me = Object.getOwnPropertyDescriptor, Ne = (i, r, e, t) => {
|
|
378
|
+
for (var s = t > 1 ? void 0 : t ? me(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
376
379
|
(n = i[o]) && (s = n(s) || s);
|
|
377
380
|
return s;
|
|
378
|
-
},
|
|
379
|
-
let
|
|
381
|
+
}, I = (i, r) => (e, t) => r(e, t, i);
|
|
382
|
+
let y = class extends U {
|
|
380
383
|
constructor(r, e, t, s) {
|
|
381
384
|
super();
|
|
382
385
|
_(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
383
386
|
_(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
384
387
|
_(this, "_handleRangeChange", (r, e, t, s, o, n, a) => n ? {
|
|
385
388
|
redos: [{
|
|
386
|
-
id:
|
|
389
|
+
id: T.id,
|
|
387
390
|
params: {
|
|
388
391
|
unitId: r,
|
|
389
392
|
sheetId: e,
|
|
@@ -396,7 +399,7 @@ let R = class extends U {
|
|
|
396
399
|
}
|
|
397
400
|
}],
|
|
398
401
|
undos: [{
|
|
399
|
-
id:
|
|
402
|
+
id: T.id,
|
|
400
403
|
params: {
|
|
401
404
|
unitId: r,
|
|
402
405
|
sheetId: e,
|
|
@@ -419,7 +422,7 @@ let R = class extends U {
|
|
|
419
422
|
}
|
|
420
423
|
}],
|
|
421
424
|
undos: [{
|
|
422
|
-
id:
|
|
425
|
+
id: m.id,
|
|
423
426
|
params: {
|
|
424
427
|
unitId: r,
|
|
425
428
|
sheetId: e,
|
|
@@ -444,7 +447,7 @@ let R = class extends U {
|
|
|
444
447
|
this._disposableMap.set(
|
|
445
448
|
this._getIdWithUnitId(r, e, s, o),
|
|
446
449
|
this._refRangeService.registerRefRange(n, (a) => {
|
|
447
|
-
const c =
|
|
450
|
+
const c = re(n, a, { selectionManagerService: this._selectionManagerService }), d = Array.isArray(c) ? c[0] : c;
|
|
448
451
|
return d && d.startColumn === n.startColumn && d.startRow === n.startRow ? {
|
|
449
452
|
undos: [],
|
|
450
453
|
redos: []
|
|
@@ -463,7 +466,7 @@ let R = class extends U {
|
|
|
463
466
|
this._getIdWithUnitId(r, e, s, o),
|
|
464
467
|
this._refRangeService.watchRange(r, e, n, (a, c) => {
|
|
465
468
|
const { redos: d } = this._handleRangeChange(r, e, t, a.startRow, a.startColumn, c, !0);
|
|
466
|
-
|
|
469
|
+
Y(d, this._commandService, { onlyLocal: !0 });
|
|
467
470
|
}, !0)
|
|
468
471
|
);
|
|
469
472
|
}
|
|
@@ -504,30 +507,30 @@ let R = class extends U {
|
|
|
504
507
|
);
|
|
505
508
|
}
|
|
506
509
|
};
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
],
|
|
513
|
-
var
|
|
514
|
-
for (var s = t > 1 ? void 0 : t ?
|
|
510
|
+
y = Ne([
|
|
511
|
+
I(0, f(ne)),
|
|
512
|
+
I(1, f(g)),
|
|
513
|
+
I(2, f(x)),
|
|
514
|
+
I(3, v)
|
|
515
|
+
], y);
|
|
516
|
+
var fe = Object.getOwnPropertyDescriptor, Me = (i, r, e, t) => {
|
|
517
|
+
for (var s = t > 1 ? void 0 : t ? fe(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
515
518
|
(n = i[o]) && (s = n(s) || s);
|
|
516
519
|
return s;
|
|
517
|
-
},
|
|
518
|
-
let
|
|
520
|
+
}, we = (i, r) => (e, t) => r(e, t, i);
|
|
521
|
+
let P = class extends U {
|
|
519
522
|
constructor(i) {
|
|
520
523
|
super(), this._commandService = i, this._initialize();
|
|
521
524
|
}
|
|
522
525
|
_initialize() {
|
|
523
526
|
[
|
|
527
|
+
T,
|
|
524
528
|
$,
|
|
525
|
-
|
|
526
|
-
N,
|
|
529
|
+
m,
|
|
527
530
|
M,
|
|
528
|
-
ae,
|
|
529
531
|
ce,
|
|
530
|
-
de
|
|
532
|
+
de,
|
|
533
|
+
he
|
|
531
534
|
].forEach((i) => {
|
|
532
535
|
this.disposeWithMe(
|
|
533
536
|
this._commandService.registerCommand(i)
|
|
@@ -535,60 +538,62 @@ let y = class extends U {
|
|
|
535
538
|
});
|
|
536
539
|
}
|
|
537
540
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
],
|
|
541
|
-
var
|
|
542
|
-
for (var s = t > 1 ? void 0 : t ?
|
|
541
|
+
P = Me([
|
|
542
|
+
we(0, v)
|
|
543
|
+
], P);
|
|
544
|
+
var ve = Object.defineProperty, Se = Object.getOwnPropertyDescriptor, Ie = (i, r, e) => r in i ? ve(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e, Ce = (i, r, e, t) => {
|
|
545
|
+
for (var s = t > 1 ? void 0 : t ? Se(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
543
546
|
(n = i[o]) && (s = n(s) || s);
|
|
544
547
|
return s;
|
|
545
|
-
},
|
|
546
|
-
let
|
|
547
|
-
constructor(i =
|
|
548
|
+
}, J = (i, r) => (e, t) => r(e, t, i), O = (i, r, e) => Ie(i, typeof r != "symbol" ? r + "" : r, e);
|
|
549
|
+
let w = class extends Z {
|
|
550
|
+
constructor(i = H, r, e) {
|
|
548
551
|
super(), this._config = i, this._configService = r, this._injector = e;
|
|
549
552
|
const { ...t } = k(
|
|
550
553
|
{},
|
|
551
|
-
|
|
554
|
+
H,
|
|
552
555
|
this._config
|
|
553
556
|
);
|
|
554
|
-
this._configService.setConfig(
|
|
557
|
+
this._configService.setConfig(_e, t);
|
|
555
558
|
}
|
|
556
559
|
onStarting() {
|
|
557
560
|
[
|
|
558
561
|
[g],
|
|
559
|
-
[
|
|
560
|
-
[
|
|
561
|
-
[
|
|
562
|
+
[P],
|
|
563
|
+
[R],
|
|
564
|
+
[y]
|
|
562
565
|
].forEach((i) => {
|
|
563
566
|
this._injector.add(i);
|
|
564
|
-
}),
|
|
567
|
+
}), W(this._injector, [
|
|
565
568
|
[g],
|
|
566
|
-
[
|
|
567
|
-
[
|
|
569
|
+
[P],
|
|
570
|
+
[R]
|
|
568
571
|
]);
|
|
569
572
|
}
|
|
570
573
|
onReady() {
|
|
571
|
-
|
|
572
|
-
[
|
|
574
|
+
W(this._injector, [
|
|
575
|
+
[y]
|
|
573
576
|
]);
|
|
574
577
|
}
|
|
575
578
|
};
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
579
|
+
O(w, "pluginName", V);
|
|
580
|
+
O(w, "packageName", z.name);
|
|
581
|
+
O(w, "version", z.version);
|
|
582
|
+
O(w, "type", C.UNIVER_SHEET);
|
|
583
|
+
w = Ce([
|
|
584
|
+
Q(ie),
|
|
585
|
+
J(1, ee),
|
|
586
|
+
J(2, f(X))
|
|
587
|
+
], w);
|
|
583
588
|
export {
|
|
584
589
|
M as RemoveNoteMutation,
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
590
|
+
ce as SheetDeleteNoteCommand,
|
|
591
|
+
de as SheetToggleNotePopupCommand,
|
|
592
|
+
he as SheetUpdateNoteCommand,
|
|
588
593
|
g as SheetsNoteModel,
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
+
R as SheetsNoteResourceController,
|
|
595
|
+
$ as ToggleNotePopupMutation,
|
|
596
|
+
w as UniverSheetsNotePlugin,
|
|
597
|
+
m as UpdateNoteMutation,
|
|
598
|
+
T as UpdateNotePositionMutation
|
|
594
599
|
};
|