@univerjs/preset-sheets-note 0.15.4 → 0.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/umd/index.js +3 -3
  2. package/package.json +5 -5
package/lib/umd/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  // @univerjs/sheets-note/index
2
- (function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverSheetsNote={},d.UniverCore,d.UniverSheets,d.rxjs))})(this,(function(d,r,l,v){"use strict";var F=Object.defineProperty;var K=(d,r,l)=>r in d?F(d,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[r]=l;var m=(d,r,l)=>K(d,typeof r!="symbol"?r+"":r,l);class p extends r.Disposable{constructor(){super(...arguments);m(this,"_noteMatrix",new Map);m(this,"_change$",new v.Subject);m(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(s,t){let e=this._noteMatrix.get(s);e||(e=new Map,this._noteMatrix.set(s,e));let n=e.get(t);return n||(n=new r.ObjectMatrix,e.set(t,n)),n}getSheetShowNotes$(s,t){return this._change$.pipe(v.filter(({unitId:e,sheetId:n})=>e===s&&n===t),v.map(()=>{const e=this._ensureNoteMatrix(s,t),n=[];return e.forValue((i,h,c)=>{c.show&&n.push({loc:{row:i,col:h,unitId:s,subUnitId:t},note:c})}),n}))}getCellNoteChange$(s,t,e,n){return this._change$.pipe(v.filter(({unitId:i,sheetId:h,row:c,col:u})=>i===s&&h===t&&c===e&&u===n),v.map(({note:i})=>i))}updateNote(s,t,e,n,i,h){const c=this._ensureNoteMatrix(s,t),u=c.getValue(e,n);c.setValue(e,n,i),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"update",note:i,oldNote:u,silent:h})}removeNote(s,t,e,n,i){const h=this._ensureNoteMatrix(s,t),c=h.getValue(e,n);h.realDeleteValue(e,n),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(s,t,e,n,i){const h=this._ensureNoteMatrix(s,t),c=h.getValue(e,n);if(c){c.show=!c.show;const u={...c,show:c.show};h.setValue(e,n,u),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"update",note:u,oldNote:c,silent:i})}}updateNotePosition(s,t,e,n,i,h,c){const u=this._ensureNoteMatrix(s,t),g=u.getValue(e,n);g&&(u.realDeleteValue(e,n),u.setValue(i,h,g),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"ref",newPosition:{row:i,col:h},note:g,silent:c}))}getNote(s,t,e,n){return this._ensureNoteMatrix(s,t).getValue(e,n)}getUnitNotes(s){return this._noteMatrix.get(s)}getSheetNotes(s,t){const e=this._noteMatrix.get(s);if(e)return e.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(s){this._noteMatrix.delete(s)}}const _={id:"sheet.mutation.update-note",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,note:i,silent:h}=o;return a.get(p).updateNote(s,t,e,n,i,h),!0}},S={id:"sheet.mutation.remove-note",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,silent:i}=o;return a.get(p).removeNote(s,t,e,n,i),!0}},y={id:"sheet.mutation.toggle-note-popup",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,silent:i}=o;return a.get(p).toggleNotePopup(s,t,e,n,i),!0}},f={id:"sheet.mutation.update-note-position",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,newPosition:i,silent:h}=o;return a.get(p).updateNotePosition(s,t,e,n,i.row,i.col,h),!0}},R={id:"sheet.command.delete-note",type:r.CommandType.COMMAND,handler:(a,o)=>{const s=a.get(r.IUniverInstanceService),t=l.getSheetCommandTarget(s);if(!t)return!1;const n=a.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:i,actualRow:h}=n.primary;return a.get(r.ICommandService).executeCommand(S.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},P={id:"sheet.command.toggle-note-popup",type:r.CommandType.COMMAND,handler:(a,o)=>{const s=a.get(r.IUniverInstanceService),t=l.getSheetCommandTarget(s);if(!t)return!1;const n=a.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:i,actualRow:h}=n.primary;return a.get(r.ICommandService).executeCommand(y.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},w={id:"sheet.command.update-note",type:r.CommandType.COMMAND,handler:(a,o)=>a.get(r.ICommandService).syncExecuteCommand(_.id,o)},T="SHEET_NOTE_PLUGIN";var $=Object.getOwnPropertyDescriptor,j=(a,o,s,t)=>{for(var e=t>1?void 0:t?$(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},M=(a,o)=>(s,t)=>o(s,t,a);d.SheetsNoteResourceController=class extends r.Disposable{constructor(o,s,t,e){super(),this._resourceManagerService=o,this._univerInstanceService=s,this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const o=t=>{const e=this._sheetsNoteModel.getUnitNotes(t);if(!e)return"";const n={};return e.forEach((i,h)=>{const c={};i.forValue((u,g,N)=>{c[u]||(c[u]={}),c[u][g]=N}),Object.keys(c).length>0&&(n[h]=c)}),JSON.stringify(n)},s=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:T,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>s(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,e)=>{Object.entries(e).forEach(([n,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([u,g])=>{this._sheetsNoteModel.updateNote(t,n,Number(h),Number(u),g)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var s;if(o.id===l.RemoveSheetCommand.id){const t=o.params,e=t.unitId||this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=t.subUnitId||((s=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:s.getSheetId());if(!e||!n)return{redos:[],undos:[]};const i=this._sheetsNoteModel.getSheetNotes(e,n);if(!i)return{redos:[],undos:[]};const h=[],c=[];return i.forValue((u,g,N)=>{h.push({id:S.id,params:{unitId:e,sheetId:n,row:u,col:g}}),c.push({id:_.id,params:{unitId:e,sheetId:n,row:u,col:g,note:N}})}),{redos:h,undos:c}}else if(o.id===l.CopySheetCommand.id){const t=o.params,{unitId:e,subUnitId:n,targetSubUnitId:i}=t;if(!e||!n||!i)return{redos:[],undos:[]};const h=this._sheetsNoteModel.getSheetNotes(e,n);if(!h)return{redos:[],undos:[]};const c=[],u=[];return h.forValue((g,N,z)=>{c.push({id:_.id,params:{unitId:e,sheetId:i,row:g,col:N,note:z}}),u.push({id:S.id,params:{unitId:e,sheetId:i,row:g,col:N}})}),{redos:c,undos:u}}return{redos:[],undos:[]}}}))}},d.SheetsNoteResourceController=j([M(0,r.IResourceManagerService),M(1,r.IUniverInstanceService),M(2,r.Inject(l.SheetInterceptorService)),M(3,r.Inject(p))],d.SheetsNoteResourceController);const D="sheets-note.config",O={};var x=Object.getOwnPropertyDescriptor,V=(a,o,s,t)=>{for(var e=t>1?void 0:t?x(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},C=(a,o)=>(s,t)=>o(s,t,a);let I=class extends r.Disposable{constructor(o,s,t,e){super();m(this,"_disposableMap",new Map);m(this,"_watcherMap",new Map);m(this,"_handleRangeChange",(o,s,t,e,n,i,h)=>i?{redos:[{id:f.id,params:{unitId:o,sheetId:s,row:e,col:n,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:f.id,params:{unitId:o,sheetId:s,row:i.startRow,col:i.startColumn,newPosition:{row:e,col:n},note:t,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:s,row:e,col:n}}],undos:[{id:_.id,params:{unitId:o,sheetId:s,row:e,col:n,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=s,this._selectionManagerService=t,this._commandService=e,this._initData(),this._initRefRange()}_getIdWithUnitId(o,s,t,e){return`${o}-${s}-${t}-${e}`}_register(o,s,t,e,n){const i={startColumn:n,endColumn:n,startRow:e,endRow:e};this._disposableMap.set(this._getIdWithUnitId(o,s,e,n),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),u=Array.isArray(c)?c[0]:c;return u&&u.startColumn===i.startColumn&&u.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,s,t,e,n,u,!1)},o,s))}_watch(o,s,t,e,n){const i={startColumn:n,endColumn:n,startRow:e,endRow:e};this._watcherMap.set(this._getIdWithUnitId(o,s,e,n),this._refRangeService.watchRange(o,s,i,(h,c)=>{const{redos:u}=this._handleRangeChange(o,s,t,h.startRow,h.startColumn,c,!0);r.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,s,t,e){var i;const n=this._getIdWithUnitId(o,s,t,e);(i=this._watcherMap.get(n))==null||i.dispose(),this._watcherMap.delete(n)}_unregister(o,s,t,e){var i;const n=this._getIdWithUnitId(o,s,t,e);(i=this._disposableMap.get(n))==null||i.dispose(),this._disposableMap.delete(n)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[s,t]of o)for(const[e,n]of t)n.forValue((i,h,c)=>(c&&(this._register(s,e,c,i,h),this._watch(s,e,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:s,sheetId:t,row:e,col:n,note:i}=o,h=this._getIdWithUnitId(s,t,e,n);i?this._disposableMap.has(h)||(this._register(s,t,i,e,n),this._watch(s,t,i,e,n)):(this._unregister(s,t,e,n),this._unwatch(s,t,e,n));break}case"ref":{const{unitId:s,sheetId:t,row:e,col:n,newPosition:i,note:h,silent:c}=o;this._unregister(s,t,e,n),c||(this._unwatch(s,t,e,n),this._watch(s,t,h,i.row,i.col)),this._register(s,t,h,i.row,i.col);break}}}))}};I=V([C(0,r.Inject(l.RefRangeService)),C(1,r.Inject(p)),C(2,r.Inject(l.SheetsSelectionsService)),C(3,r.ICommandService)],I);var A=Object.getOwnPropertyDescriptor,W=(a,o,s,t)=>{for(var e=t>1?void 0:t?A(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},L=(a,o)=>(s,t)=>o(s,t,a);let U=class extends r.Disposable{constructor(a){super(),this._commandService=a,this._initialize()}_initialize(){[f,y,_,S,R,P,w].forEach(a=>{this.disposeWithMe(this._commandService.registerCommand(a))})}};U=W([L(0,r.ICommandService)],U);var H=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(a,o,s)=>o in a?H(a,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[o]=s,G=(a,o,s,t)=>{for(var e=t>1?void 0:t?J(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},b=(a,o)=>(s,t)=>o(s,t,a),E=(a,o,s)=>q(a,typeof o!="symbol"?o+"":o,s);d.UniverSheetsNotePlugin=class extends r.Plugin{constructor(o=O,s,t){super(),this._config=o,this._configService=s,this._injector=t;const{...e}=r.merge({},O,this._config);this._configService.setConfig(D,e)}onStarting(){[[p],[U],[d.SheetsNoteResourceController],[I]].forEach(o=>{this._injector.add(o)}),r.touchDependencies(this._injector,[[p],[U],[d.SheetsNoteResourceController]])}onReady(){r.touchDependencies(this._injector,[[I]])}},E(d.UniverSheetsNotePlugin,"pluginName",T),E(d.UniverSheetsNotePlugin,"type",r.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsNotePlugin=G([r.DependentOn(l.UniverSheetsPlugin),b(1,r.IConfigService),b(2,r.Inject(r.Injector))],d.UniverSheetsNotePlugin),d.RemoveNoteMutation=S,d.SheetDeleteNoteCommand=R,d.SheetToggleNotePopupCommand=P,d.SheetUpdateNoteCommand=w,d.SheetsNoteModel=p,d.ToggleNotePopupMutation=y,d.UpdateNoteMutation=_,d.UpdateNotePositionMutation=f,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
2
+ (function(u,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],c):(u=typeof globalThis<"u"?globalThis:u||self,c(u.UniverSheetsNote={},u.UniverCore,u.UniverSheets,u.rxjs))})(this,(function(u,c,g,M){"use strict";var Q=Object.defineProperty;var X=(u,c,g)=>c in u?Q(u,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):u[c]=g;var v=(u,c,g)=>X(u,typeof c!="symbol"?c+"":c,g);class m extends c.Disposable{constructor(){super(...arguments);v(this,"_notesMap",new Map);v(this,"_change$",new M.Subject);v(this,"change$",this._change$.asObservable())}_ensureNotesMap(t,e){let n=this._notesMap.get(t);n||(n=new Map,this._notesMap.set(t,n));let o=n.get(e);return o||(o=new Map,n.set(e,o)),o}_getNoteByPosition(t,e,n,o){const s=this._ensureNotesMap(t,e);for(const[r,d]of s)if(d.row===n&&d.col===o)return d}_getNoteById(t,e,n){return this._ensureNotesMap(t,e).get(n)}_getNoteByParams(t,e,n){const{noteId:o,row:s,col:r}=n;return o?this._getNoteById(t,e,o):s!==void 0&&r!==void 0?this._getNoteByPosition(t,e,s,r):null}getSheetShowNotes$(t,e){return this._change$.pipe(M.filter(({unitId:n,subUnitId:o})=>n===t&&o===e),M.map(()=>{const n=this._ensureNotesMap(t,e),o=[];for(const[s,r]of n)r.show&&o.push({loc:{row:r.row,col:r.col,unitId:t,subUnitId:e},note:r});return o}))}getCellNoteChange$(t,e,n,o){return this._change$.pipe(M.filter(({unitId:s,subUnitId:r,oldNote:d})=>s!==t||r!==e||!d?!1:d.row===n&&d.col===o),M.map(s=>s))}updateNote(t,e,n,o,s,r){const d=this._getNoteByParams(t,e,{noteId:s==null?void 0:s.id,row:n,col:o}),h=this._ensureNotesMap(t,e),l={...s,id:(d==null?void 0:d.id)||s.id||c.generateRandomId(6),row:n,col:o};h.set(l.id,l),this._change$.next({unitId:t,subUnitId:e,oldNote:d,type:"update",newNote:l,silent:r})}removeNote(t,e,n){const{noteId:o,row:s,col:r,silent:d}=n,h=this._getNoteByParams(t,e,{noteId:o,row:s,col:r});if(!h)return;this._ensureNotesMap(t,e).delete(h.id),this._change$.next({unitId:t,subUnitId:e,oldNote:h,type:"update",newNote:null,silent:d})}toggleNotePopup(t,e,n){const{noteId:o,row:s,col:r,silent:d}=n,h=this._getNoteByParams(t,e,{noteId:o,row:s,col:r});if(!h)return;const l=this._ensureNotesMap(t,e),p={...h,show:!h.show};l.set(p.id,p),this._change$.next({unitId:t,subUnitId:e,oldNote:h,type:"update",newNote:p,silent:d})}updateNotePosition(t,e,n){const{noteId:o,row:s,col:r,newRow:d,newCol:h,silent:l}=n,p=this._getNoteByParams(t,e,{noteId:o,row:s,col:r});if(!p)return;const _=this._ensureNotesMap(t,e),N={...p,row:d,col:h};_.set(N.id,N),this._change$.next({unitId:t,subUnitId:e,oldNote:p,type:"ref",newNote:N,silent:l})}getNote(t,e,n){return this._getNoteByParams(t,e,n)}getNotes(){return this._notesMap}getUnitNotes(t){return this._notesMap.get(t)}getSheetNotes(t,e){const n=this._notesMap.get(t);if(n)return n.get(e)}deleteUnitNotes(t){this._notesMap.delete(t)}}const S={id:"sheet.mutation.update-note",type:c.CommandType.MUTATION,handler:(a,i)=>{const{unitId:t,sheetId:e,row:n,col:o,note:s,silent:r}=i;return a.get(m).updateNote(t,e,n,o,s,r),!0}},f={id:"sheet.mutation.remove-note",type:c.CommandType.MUTATION,handler:(a,i)=>{const{unitId:t,sheetId:e,noteId:n,row:o,col:s,silent:r}=i;return a.get(m).removeNote(t,e,{noteId:n,row:o,col:s,silent:r}),!0}},I={id:"sheet.mutation.toggle-note-popup",type:c.CommandType.MUTATION,handler:(a,i)=>{const{unitId:t,sheetId:e,noteId:n,row:o,col:s,silent:r}=i;return a.get(m).toggleNotePopup(t,e,{noteId:n,row:o,col:s,silent:r}),!0}},w={id:"sheet.mutation.update-note-position",type:c.CommandType.MUTATION,handler:(a,i)=>{const{unitId:t,sheetId:e,noteId:n,row:o,col:s,newPosition:r,silent:d}=i;return a.get(m).updateNotePosition(t,e,{noteId:n,row:o,col:s,newRow:r.row,newCol:r.col,silent:d}),!0}},T={id:"sheet.command.delete-note",type:c.CommandType.COMMAND,handler:a=>{const i=g.getSheetCommandTarget(a.get(c.IUniverInstanceService));if(!i)return!1;const e=a.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const n=a.get(m),{unitId:o,subUnitId:s}=i,{actualColumn:r,actualRow:d}=e.primary,h=n.getNote(o,s,{row:d,col:r});if(!h)return!1;const l=a.get(c.ICommandService),p=a.get(c.IUndoRedoService),_={id:f.id,params:{unitId:o,sheetId:s,noteId:h.id}},N={id:S.id,params:{unitId:o,sheetId:s,row:d,col:r,note:{...h}}};return l.syncExecuteCommand(_.id,_.params)?(p.pushUndoRedo({unitID:o,redoMutations:[_],undoMutations:[N]}),!0):!1}},E={id:"sheet.command.toggle-note-popup",type:c.CommandType.COMMAND,handler:a=>{const i=g.getSheetCommandTarget(a.get(c.IUniverInstanceService));if(!i)return!1;const e=a.get(g.SheetsSelectionsService).getCurrentLastSelection();if(!(e!=null&&e.primary))return!1;const n=a.get(m),{unitId:o,subUnitId:s}=i,{actualColumn:r,actualRow:d}=e.primary,h=n.getNote(o,s,{row:d,col:r});if(!h)return!1;const l=a.get(c.ICommandService),p=a.get(c.IUndoRedoService),_={id:I.id,params:{unitId:o,sheetId:s,noteId:h.id}},N={id:I.id,params:{unitId:o,sheetId:s,noteId:h.id}};return l.syncExecuteCommand(_.id,_.params)?(p.pushUndoRedo({unitID:o,redoMutations:[_],undoMutations:[N]}),!0):!1}},O={id:"sheet.command.update-note",type:c.CommandType.COMMAND,handler:(a,i)=>{const t=g.getSheetCommandTarget(a.get(c.IUniverInstanceService),i);if(!t)return!1;const e=a.get(c.ICommandService),n=a.get(c.IUndoRedoService),o=a.get(m),{unitId:s,subUnitId:r}=t,{row:d,col:h,note:l}=i,p=o.getNote(s,r,{noteId:l.id,row:d,col:h}),_={id:S.id,params:{unitId:s,sheetId:r,row:d,col:h,note:l}},N=[];if(p){const P={id:S.id,params:{unitId:s,sheetId:r,row:d,col:h,note:{...p}}};N.push(P)}else{const P={id:f.id,params:{unitId:s,sheetId:r,row:d,col:h}};N.push(P)}return e.syncExecuteCommand(_.id,_.params)?(n.pushUndoRedo({unitID:s,redoMutations:[_],undoMutations:N}),!0):!1}},b="SHEET_NOTE_PLUGIN";var W=Object.getOwnPropertyDescriptor,B=(a,i,t,e)=>{for(var n=e>1?void 0:e?W(i,t):i,o=a.length-1,s;o>=0;o--)(s=a[o])&&(n=s(n)||n);return n},C=(a,i)=>(t,e)=>i(t,e,a);u.SheetsNoteResourceController=class extends c.Disposable{constructor(i,t,e,n){super(),this._resourceManagerService=i,this._univerInstanceService=t,this._sheetInterceptorService=e,this._sheetsNoteModel=n,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const i=e=>{const n=this._sheetsNoteModel.getUnitNotes(e);if(!n)return"";const o={};return n.forEach((s,r)=>{const d={};s.forEach(h=>{const{row:l,col:p}=h;d[l]||(d[l]={}),d[l][p]=h}),Object.keys(d).length>0&&(o[r]=d)}),JSON.stringify(o)},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:b,businesses:[c.UniverInstanceType.UNIVER_SHEET],toJson:e=>i(e),parseJson:e=>t(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,n)=>{Object.entries(n).forEach(([o,s])=>{Object.entries(s).forEach(([r,d])=>{Object.entries(d).forEach(([h,l])=>{this._sheetsNoteModel.updateNote(e,o,Number(r),Number(h),l)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===g.RemoveSheetCommand.id){const e=i.params,n=e.unitId||this._univerInstanceService.getCurrentUnitOfType(c.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=e.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(c.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!n||!o)return{redos:[],undos:[]};const s=this._sheetsNoteModel.getSheetNotes(n,o);if(!s)return{redos:[],undos:[]};const r=[],d=[];return s.forEach(h=>{r.push({id:f.id,params:{unitId:n,sheetId:o,noteId:h.id,row:h.row,col:h.col}}),d.push({id:S.id,params:{unitId:n,sheetId:o,row:h.row,col:h.col,note:h}})}),{redos:r,undos:d}}else if(i.id===g.CopySheetCommand.id){const e=i.params,{unitId:n,subUnitId:o,targetSubUnitId:s}=e;if(!n||!o||!s)return{redos:[],undos:[]};const r=this._sheetsNoteModel.getSheetNotes(n,o);if(!r)return{redos:[],undos:[]};const d=[],h=[];return r.forEach(l=>{const p={...l,id:c.generateRandomId(6)};d.push({id:S.id,params:{unitId:n,sheetId:s,row:p.row,col:p.col,note:p}}),h.push({id:f.id,params:{unitId:n,sheetId:s,noteId:p.id,row:p.row,col:p.col}})}),{redos:d,undos:h}}return{redos:[],undos:[]}}}))}},u.SheetsNoteResourceController=B([C(0,c.IResourceManagerService),C(1,c.IUniverInstanceService),C(2,c.Inject(g.SheetInterceptorService)),C(3,c.Inject(m))],u.SheetsNoteResourceController);const L="sheets-note.config",D={};var H=Object.getOwnPropertyDescriptor,J=(a,i,t,e)=>{for(var n=e>1?void 0:e?H(i,t):i,o=a.length-1,s;o>=0;o--)(s=a[o])&&(n=s(n)||n);return n},R=(a,i)=>(t,e)=>i(t,e,a);let y=class extends c.Disposable{constructor(i,t,e,n){super();v(this,"_disposableMap",new Map);v(this,"_watcherMap",new Map);v(this,"_handleRangeChange",(i,t,e,n,o,s,r)=>s?{redos:[{id:w.id,params:{unitId:i,sheetId:t,noteId:e.id,newPosition:{row:s.startRow,col:s.startColumn},silent:r}}],undos:[{id:w.id,params:{unitId:i,sheetId:t,noteId:e.id,newPosition:{row:n,col:o},note:e,silent:r}}]}:{redos:[{id:f.id,params:{unitId:i,sheetId:t,noteId:e.id}}],undos:[{id:S.id,params:{unitId:i,sheetId:t,row:n,col:o,note:e}}]});this._refRangeService=i,this._sheetsNoteModel=t,this._selectionManagerService=e,this._commandService=n,this._initData(),this._initRefRange()}_getIdWithUnitId(i,t,e,n){return`${i}-${t}-${e}-${n}`}_register(i,t,e,n,o){const s={startColumn:o,endColumn:o,startRow:n,endRow:n};this._disposableMap.set(this._getIdWithUnitId(i,t,n,o),this._refRangeService.registerRefRange(s,r=>{const d=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,r,{selectionManagerService:this._selectionManagerService}),h=Array.isArray(d)?d[0]:d;return h&&h.startColumn===s.startColumn&&h.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(i,t,e,n,o,h,!1)},i,t))}_watch(i,t,e,n,o){const s={startColumn:o,endColumn:o,startRow:n,endRow:n};this._watcherMap.set(this._getIdWithUnitId(i,t,n,o),this._refRangeService.watchRange(i,t,s,(r,d)=>{const{redos:h}=this._handleRangeChange(i,t,e,r.startRow,r.startColumn,d,!0);c.sequenceExecuteAsync(h,this._commandService,{onlyLocal:!0})},!0))}_unwatch(i,t,e,n){var s;const o=this._getIdWithUnitId(i,t,e,n);(s=this._watcherMap.get(o))==null||s.dispose(),this._watcherMap.delete(o)}_unregister(i,t,e,n){var s;const o=this._getIdWithUnitId(i,t,e,n);(s=this._disposableMap.get(o))==null||s.dispose(),this._disposableMap.delete(o)}_initData(){const i=this._sheetsNoteModel.getNotes();for(const[t,e]of i)for(const[n,o]of e)o.forEach(s=>{this._register(t,n,s,s.row,s.col),this._watch(t,n,s,s.row,s.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(i=>{switch(i.type){case"update":{const{unitId:t,subUnitId:e,oldNote:n,newNote:o}=i,s=o?o.row:n.row,r=o?o.col:n.col,d=this._getIdWithUnitId(t,e,s,r);o?this._disposableMap.has(d)||(this._register(t,e,o,s,r),this._watch(t,e,o,s,r)):(this._unregister(t,e,s,r),this._unwatch(t,e,s,r));break}case"ref":{const{unitId:t,subUnitId:e,oldNote:n,newNote:o,silent:s}=i,{row:r,col:d}=n,{row:h,col:l}=o;this._unregister(t,e,r,d),s||(this._unwatch(t,e,r,d),this._watch(t,e,o,h,l)),this._register(t,e,o,h,l);break}}}))}};y=J([R(0,c.Inject(g.RefRangeService)),R(1,c.Inject(m)),R(2,c.Inject(g.SheetsSelectionsService)),R(3,c.ICommandService)],y);var q=Object.getOwnPropertyDescriptor,G=(a,i,t,e)=>{for(var n=e>1?void 0:e?q(i,t):i,o=a.length-1,s;o>=0;o--)(s=a[o])&&(n=s(n)||n);return n},V=(a,i)=>(t,e)=>i(t,e,a);let U=class extends c.Disposable{constructor(a){super(),this._commandService=a,this._initialize()}_initialize(){[w,I,S,f,T,E,O].forEach(a=>{this.disposeWithMe(this._commandService.registerCommand(a))})}};U=G([V(0,c.ICommandService)],U);var z=Object.defineProperty,F=Object.getOwnPropertyDescriptor,K=(a,i,t)=>i in a?z(a,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[i]=t,Y=(a,i,t,e)=>{for(var n=e>1?void 0:e?F(i,t):i,o=a.length-1,s;o>=0;o--)(s=a[o])&&(n=s(n)||n);return n},$=(a,i)=>(t,e)=>i(t,e,a),j=(a,i,t)=>K(a,typeof i!="symbol"?i+"":i,t);u.UniverSheetsNotePlugin=class extends c.Plugin{constructor(i=D,t,e){super(),this._config=i,this._configService=t,this._injector=e;const{...n}=c.merge({},D,this._config);this._configService.setConfig(L,n)}onStarting(){[[m],[U],[u.SheetsNoteResourceController],[y]].forEach(i=>{this._injector.add(i)}),c.touchDependencies(this._injector,[[m],[U],[u.SheetsNoteResourceController]])}onReady(){c.touchDependencies(this._injector,[[y]])}},j(u.UniverSheetsNotePlugin,"pluginName",b),j(u.UniverSheetsNotePlugin,"type",c.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=Y([c.DependentOn(g.UniverSheetsPlugin),$(1,c.IConfigService),$(2,c.Inject(c.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=f,u.SheetDeleteNoteCommand=T,u.SheetToggleNotePopupCommand=E,u.SheetUpdateNoteCommand=O,u.SheetsNoteModel=m,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=S,u.UpdateNotePositionMutation=w,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
3
3
 
4
4
 
5
5
  // @univerjs/sheets-note/facade
6
- (function(u,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],f):(u=typeof globalThis<"u"?globalThis:u||self,f(u.UniverSheetsNoteFacade={},u.UniverCoreFacade,u.UniverSheetsNote,u.UniverSheetsFacade,u.UniverCore))})(this,(function(u,f,l,v,N){"use strict";class E{get SheetNoteAdd(){return"SheetNoteAdd"}get SheetNoteDelete(){return"SheetNoteDelete"}get SheetNoteUpdate(){return"SheetNoteUpdate"}get SheetNoteShow(){return"SheetNoteShow"}get SheetNoteHide(){return"SheetNoteHide"}get BeforeSheetNoteAdd(){return"BeforeSheetNoteAdd"}get BeforeSheetNoteDelete(){return"BeforeSheetNoteDelete"}get BeforeSheetNoteUpdate(){return"BeforeSheetNoteUpdate"}get BeforeSheetNoteShow(){return"BeforeSheetNoteShow"}get BeforeSheetNoteHide(){return"BeforeSheetNoteHide"}}f.FEventName.extend(E);class m extends v.FRange{createOrUpdateNote(S){return this._commandService.syncExecuteCommand(l.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:S}),this}deleteNote(){return this._commandService.syncExecuteCommand(l.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(l.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}v.FRange.extend(m);class p extends f.FUniver{_initialize(S){const a=S.get(N.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:t,sheetId:o,row:i,col:n,note:r}=e,s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;this.fireEvent(this.Event.SheetNoteAdd,{workbook:d,worksheet:c,row:i,col:n,note:r})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:t,sheetId:o,row:i,col:n,oldNote:r}=e,s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;this.fireEvent(this.Event.SheetNoteDelete,{workbook:d,worksheet:c,row:i,col:n,oldNote:r})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:t,sheetId:o,row:i,col:n,note:r,oldNote:s}=e,d=this.getSheetTarget(t,o);if(!d)return;const{workbook:c,worksheet:g}=d;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:c,worksheet:g,row:i,col:n,note:r,oldNote:s})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:t,sheetId:o,row:i,col:n}=e,r=this.getSheetTarget(t,o);if(!r)return;const{workbook:s,worksheet:d}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:d,row:i,col:n})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>S.get(l.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:t,sheetId:o,row:i,col:n}=e,r=this.getSheetTarget(t,o);if(!r)return;const{workbook:s,worksheet:d}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:d,row:i,col:n})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetUpdateNoteCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n,note:r}=h.params;if(e.getNote(t,o,i,n))return;const d=this.getSheetTarget(t,o);if(!d)return;const{workbook:c,worksheet:g}=d;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:c,worksheet:g,row:i,col:n,note:r}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetDeleteNoteCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n}=h.params,r=e.getNote(t,o,i,n);if(!r)return;const s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:d,worksheet:c,row:i,col:n,oldNote:r}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetUpdateNoteCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n,note:r}=h.params,s=e.getNote(t,o,i,n);if(!s)return;const d=this.getSheetTarget(t,o);if(!d)return;const{workbook:c,worksheet:g}=d;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:c,worksheet:g,row:i,col:n,note:r,oldNote:s}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetToggleNotePopupCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n}=h.params,r=e.getNote(t,o,i,n);if(r!=null&&r.show)return;const s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:d,worksheet:c,row:i,col:n}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>a.beforeCommandExecuted(h=>{if(h.id===l.SheetToggleNotePopupCommand.id){const e=S.get(l.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:n}=h.params,r=e.getNote(t,o,i,n);if(!(r!=null&&r.show))return;const s=this.getSheetTarget(t,o);if(!s)return;const{workbook:d,worksheet:c}=s;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:d,worksheet:c,row:i,col:n}))throw new N.CanceledError}})))}}f.FUniver.extend(p);class k extends v.FWorksheet{getNotes(){const a=this._injector.get(l.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),h=[];return a==null||a.forValue((e,t,o)=>{h.push({...o,row:e,col:t})}),h}}v.FWorksheet.extend(k),u.FSheetNoteEvent=E,u.FSheetsNoteRangeMixin=m,u.FSheetsNoteWorksheet=k,u.FUniverSheetNoteMixin=p,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
6
+ (function(S,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core","@univerjs/sheets"],f):(S=typeof globalThis<"u"?globalThis:S||self,f(S.UniverSheetsNoteFacade={},S.UniverCoreFacade,S.UniverSheetsNote,S.UniverSheetsFacade,S.UniverCore,S.UniverSheets))})(this,(function(S,f,s,w,N,m){"use strict";class p{get SheetNoteAdd(){return"SheetNoteAdd"}get SheetNoteDelete(){return"SheetNoteDelete"}get SheetNoteUpdate(){return"SheetNoteUpdate"}get SheetNoteShow(){return"SheetNoteShow"}get SheetNoteHide(){return"SheetNoteHide"}get BeforeSheetNoteAdd(){return"BeforeSheetNoteAdd"}get BeforeSheetNoteDelete(){return"BeforeSheetNoteDelete"}get BeforeSheetNoteUpdate(){return"BeforeSheetNoteUpdate"}get BeforeSheetNoteShow(){return"BeforeSheetNoteShow"}get BeforeSheetNoteHide(){return"BeforeSheetNoteHide"}}f.FEventName.extend(p);class I extends w.FRange{createOrUpdateNote(d){return this._commandService.syncExecuteCommand(s.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:d}),this}deleteNote(){return this._commandService.syncExecuteCommand(s.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(s.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),{row:this.getRow(),col:this.getColumn()})}}w.FRange.extend(I);class U extends f.FUniver{_initialize(d){const g=d.get(N.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>d.get(s.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.newNote){const{unitId:n,subUnitId:r,newNote:t}=e,o=this.getSheetTarget(n,r);if(!o)return;const{workbook:c,worksheet:i}=o;this.fireEvent(this.Event.SheetNoteAdd,{workbook:c,worksheet:i,row:t.row,col:t.col,note:t})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>d.get(s.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.newNote){const{unitId:n,subUnitId:r,oldNote:t}=e,o=this.getSheetTarget(n,r);if(!o)return;const{workbook:c,worksheet:i}=o;this.fireEvent(this.Event.SheetNoteDelete,{workbook:c,worksheet:i,row:t.row,col:t.col,oldNote:t})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>d.get(s.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.newNote){const{unitId:n,subUnitId:r,oldNote:t,newNote:o}=e,c=this.getSheetTarget(n,r);if(!c)return;const{workbook:i,worksheet:l}=c;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:i,worksheet:l,row:o.row,col:o.col,note:o,oldNote:t})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>d.get(s.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.newNote&&!e.oldNote.show&&e.newNote.show){const{unitId:n,subUnitId:r,newNote:t}=e,o=this.getSheetTarget(n,r);if(!o)return;const{workbook:c,worksheet:i}=o;this.fireEvent(this.Event.SheetNoteShow,{workbook:c,worksheet:i,row:t.row,col:t.col})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>d.get(s.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.newNote&&e.oldNote.show&&!e.newNote.show){const{unitId:n,subUnitId:r,newNote:t}=e,o=this.getSheetTarget(n,r);if(!o)return;const{workbook:c,worksheet:i}=o;this.fireEvent(this.Event.SheetNoteHide,{workbook:c,worksheet:i,row:t.row,col:t.col})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>g.beforeCommandExecuted(h=>{if(h.id===s.SheetUpdateNoteCommand.id){const{unitId:e,sheetId:n,row:r,col:t,note:o}=h.params,c=this.getSheetTarget(e,n);if(!c||d.get(s.SheetsNoteModel).getNote(e,n,{noteId:o.id,row:r,col:t}))return;const{workbook:u,worksheet:a}=c;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:u,worksheet:a,row:r,col:t,note:o}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>g.beforeCommandExecuted(h=>{if(h.id===s.SheetDeleteNoteCommand.id){const{unitId:e,sheetId:n,row:r,col:t}=h.params,o=this.getSheetTarget(e,n);if(!o||r===void 0||t===void 0)return;const i=d.get(s.SheetsNoteModel).getNote(e,n,{row:r,col:t});if(!i)return;const{workbook:l,worksheet:u}=o;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:l,worksheet:u,row:r,col:t,oldNote:i}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>g.beforeCommandExecuted(h=>{if(h.id===s.SheetUpdateNoteCommand.id){const{unitId:e,sheetId:n,row:r,col:t,note:o}=h.params,c=this.getSheetTarget(e,n);if(!c)return;const l=d.get(s.SheetsNoteModel).getNote(e,n,{row:r,col:t});if(!l)return;const{workbook:u,worksheet:a}=c;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:u,worksheet:a,row:r,col:t,note:o,oldNote:l}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>g.beforeCommandExecuted(h=>{if(h.id===s.SheetToggleNotePopupCommand.id){const e=m.getSheetCommandTarget(d.get(N.IUniverInstanceService));if(!e)return;const{unitId:n,subUnitId:r}=e,t=this.getUniverSheet(n);if(!t)return;const o=t.getSheetBySheetId(r);if(!o)return;const i=d.get(m.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return;const l=d.get(s.SheetsNoteModel),{actualColumn:u,actualRow:a}=i.primary,v=l.getNote(n,r,{row:a,col:u});if(!v||v.show)return;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:t,worksheet:o,row:a,col:u}))throw new N.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>g.beforeCommandExecuted(h=>{if(h.id===s.SheetToggleNotePopupCommand.id){const e=m.getSheetCommandTarget(d.get(N.IUniverInstanceService));if(!e)return;const{unitId:n,subUnitId:r}=e,t=this.getUniverSheet(n);if(!t)return;const o=t.getSheetBySheetId(r);if(!o)return;const i=d.get(m.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return;const l=d.get(s.SheetsNoteModel),{actualColumn:u,actualRow:a}=i.primary,v=l.getNote(n,r,{row:a,col:u});if(!v||!v.show)return;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:t,worksheet:o,row:a,col:u}))throw new N.CanceledError}})))}}f.FUniver.extend(U);class k extends w.FWorksheet{getNotes(){const g=this._injector.get(s.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId());return g?Array.from(g.values()).map(h=>({...h})):[]}}w.FWorksheet.extend(k),S.FSheetNoteEvent=p,S.FSheetsNoteRangeMixin=I,S.FSheetsNoteWorksheet=k,S.FUniverSheetNoteMixin=U,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
7
7
 
8
8
 
9
9
  // @univerjs/sheets-note-ui/index
10
- (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("react/jsx-runtime"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-note","rxjs","@univerjs/sheets-ui","rxjs/operators","@univerjs/ui","react","react/jsx-runtime","@univerjs/design"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsNoteUi={},c.UniverCore,c.UniverEngineRender,c.UniverSheets,c.UniverSheetsNote,c.rxjs,c.UniverSheetsUi,c.rxjs.operators,c.UniverUi,c.React,c.React,c.UniverDesign))})(this,(function(c,a,P,m,f,I,M,X,v,C,ee,Z){"use strict";var Te=Object.defineProperty;var Ue=(c,a,P)=>a in c?Te(c,a,{enumerable:!0,configurable:!0,writable:!0,value:P}):c[a]=P;var b=(c,a,P)=>Ue(c,typeof a!="symbol"?a+"":a,P);var te=Object.getOwnPropertyDescriptor,ie=(n,e,t,i)=>{for(var r=i>1?void 0:i?te(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},T=(n,e)=>(t,i)=>e(t,i,n);c.SheetsCellContentController=class extends a.Disposable{constructor(e,t,i,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=i,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,t,i)=>{const{row:r,col:o,unitId:s,subUnitId:u}=t;return this._sheetsNoteModel.getNote(s,u,r,o)&&((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:"#FFBD37",size:6}}),i(e)},priority:100}))}_initSkeletonChange(){const e=()=>{var o;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const i=t.getUnitId(),r=this._renderManagerService.getRenderById(i);(o=r==null?void 0:r.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(I.debounceTime(16)).subscribe(()=>{e()}))}},c.SheetsCellContentController=ie([T(0,a.Inject(m.SheetInterceptorService)),T(1,a.Inject(f.SheetsNoteModel)),T(2,P.IRenderManagerService),T(3,a.IUniverInstanceService)],c.SheetsCellContentController);const R="SHEET_NOTE_COMPONENT";var ne=Object.getOwnPropertyDescriptor,re=(n,e,t,i)=>{for(var r=i>1?void 0:i?ne(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},k=(n,e)=>(t,i)=>e(t,i,n);c.SheetsNotePopupService=class extends a.Disposable{constructor(t,i){super();b(this,"_lastPopup",null);b(this,"_activePopup");b(this,"_activePopup$",new I.BehaviorSubject(null));b(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=t,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(t,i){var h;const{row:r,col:o,unitId:s,subUnitId:u}=t;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&u===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=t,this._activePopup$.next(t);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=t,this._activePopup$.next(t);const l=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:u,row:r,col:o},{componentKey:R,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:t},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const p=new a.DisposableCollection;p.add(l),p.add({dispose:()=>{i==null||i()}}),this._lastPopup=p}hidePopup(t){this._activePopup&&(!t&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsNotePopupService=re([k(0,v.IZenZoneService),k(1,a.Inject(M.CellPopupManagerService))],c.SheetsNotePopupService);var oe=Object.getOwnPropertyDescriptor,se=(n,e,t,i)=>{for(var r=i>1?void 0:i?oe(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},y=(n,e)=>(t,i)=>e(t,i,n);c.SheetsNotePopupController=class extends a.Disposable{constructor(t,i,r,o,s,u){super();b(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=t,this._sheetsNoteModel=i,this._sheetSelectionService=r,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=u,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(t,i,r){var S,w,N;const o=(S=t[0])==null?void 0:S.range,s=this._renderManagerService.getRenderById(i),u=(w=s==null?void 0:s.with(M.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:w.skeleton;if(!u||!o)return;const l=u.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((N=o.rangeType)!=null?N:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((l.isMerged||l.isMergedMainCell)&&a.Rectangle.equals(l.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const h=l.actualRow,d=l.actualColumn,_=this._sheetsNoteModel.getNote(i,r,h,d);_!=null&&_.show||(_?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:r,row:h,col:d}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(t,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(X.debounceTime(100)).subscribe(t=>{if(!(t!=null&&t.location))return;const{unitId:i,subUnitId:r,row:o,col:s}=t.location,u=this._sheetsNoteModel.getNote(i,r,o,s);u!=null&&u.show||(u?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:r,row:o,col:s,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},c.SheetsNotePopupController=se([y(0,a.Inject(c.SheetsNotePopupService)),y(1,a.Inject(f.SheetsNoteModel)),y(2,a.Inject(m.SheetsSelectionsService)),y(3,M.IEditorBridgeService),y(4,P.IRenderManagerService),y(5,a.Inject(M.HoverManagerService))],c.SheetsNotePopupController);const A="sheets-note-ui.config",B={};var ae=Object.getOwnPropertyDescriptor,ce=(n,e,t,i)=>{for(var r=i>1?void 0:i?ae(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},U=(n,e)=>(t,i)=>e(t,i,n);let $=class extends a.Disposable{constructor(e,t,i,r){super();b(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=e,this._univerInstanceService=t,this._cellPopupManagerService=i,this._sheetsNotePopupService=r,this._initNoteChangeListener()}_showPopup(e,t,i,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:i,col:r},{componentKey:R,direction:"horizontal",extraProps:{location:{unitId:e,subUnitId:t,row:i,col:r}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((e,t,i)=>{i.dispose()})}_initSheet(e,t){var o;this._noteMatrix.forValue((s,u,l)=>{l.dispose()}),this._noteMatrix=new a.ObjectMatrix;const r=(s,u,l,p,h)=>{const d=this._noteMatrix,_=d.getValue(l,p);if(h!=null&&h.show){if(!_){const S=this._showPopup(s,u,l,p);S&&d.setValue(l,p,S)}}else _&&(_.dispose(),d.realDeleteValue(l,p))};return(o=this._sheetsNoteModel.getSheetNotes(e,t))==null||o.forValue((s,u,l)=>{r(e,t,s,u,l)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==e||s.sheetId!==t))switch(s.type){case"ref":{const{unitId:u,sheetId:l,row:p,col:h,newPosition:d,note:_}=s,S=this._noteMatrix;if(!_.show)return;const w=S.getValue(p,h);w&&(w.dispose(),S.realDeleteValue(p,h));const N=this._showPopup(u,l,d.row,d.col);N&&S.setValue(d.row,d.col,N);break}case"update":{const{unitId:u,sheetId:l,row:p,col:h,note:d}=s;r(u,l,p,h,d);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(I.switchMap(e=>{var t;return(t=e==null?void 0:e.activeSheet$)!=null?t:I.of(null)})).subscribe(e=>{if(e){const t=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{t.unsubscribe()}}else this._noteMatrix.forValue((t,i,r)=>{r.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};$=ce([U(0,a.Inject(f.SheetsNoteModel)),U(1,a.Inject(a.IUniverInstanceService)),U(2,a.Inject(M.CellPopupManagerService)),U(3,a.Inject(c.SheetsNotePopupService))],$);function O({ref:n,...e}){const{icon:t,id:i,className:r,extend:o,...s}=e,u=`univerjs-icon univerjs-icon-${i} ${r||""}`.trim(),l=C.useRef(`_${pe()}`);return W(t,`${i}`,{defIds:t.defIds,idSuffix:l.current},{ref:n,className:u,...s},o)}function W(n,e,t,i,r){return C.createElement(n.tag,{key:e,...ue(n,t,r),...i},(le(n,t).children||[]).map((o,s)=>W(o,`${e}-${n.tag}-${s}`,t,void 0,r)))}function ue(n,e,t){const i={...n.attrs};t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),n.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(([o,s])=>{o==="mask"&&typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:r}=e;return!r||r.length===0||(n.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(([o,s])=>{typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),i}function le(n,e){var i;const{defIds:t}=e;return!t||t.length===0?n:n.tag==="defs"&&((i=n.children)!=null&&i.length)?{...n,children:n.children.map(r=>typeof r.attrs.id=="string"&&t&&t.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+e.idSuffix}}:r)}:n}function pe(){return Math.random().toString(36).substring(2,8)}O.displayName="UniverIcon";const he={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},F=C.forwardRef(function(e,t){return C.createElement(O,Object.assign({},e,{id:"add-note-icon",ref:t,icon:he}))});F.displayName="AddNoteIcon";const de={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"}}]},q=C.forwardRef(function(e,t){return C.createElement(O,Object.assign({},e,{id:"delete-note-icon",ref:t,icon:de}))});q.displayName="DeleteNoteIcon";const ve={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},z=C.forwardRef(function(e,t){return C.createElement(O,Object.assign({},e,{id:"hide-note-icon",ref:t,icon:ve}))});z.displayName="HideNoteIcon";const j={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(n,e)=>{const t=n.get(m.SheetsSelectionsService),i=n.get(c.SheetsNotePopupService),o=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),u=t.getCurrentLastSelection();if(!(u!=null&&u.primary))return!1;const{primary:l}=u;return i.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:e==null?void 0:e.trigger}),!0}},G=n=>{var N;const{popup:e}=n,t=v.useDependency(f.SheetsNoteModel),i=v.useDependency(a.LocaleService),r=v.useDependency(P.IRenderManagerService),o=v.useConfigValue(A),s=(N=e.extraProps)==null?void 0:N.location;if(!s)return console.error("Popup extraProps or location is undefined."),null;const u=C.useRef(null),l=r.getRenderById(s.unitId),[p,h]=C.useState(null);C.useEffect(()=>{var J,Q;const{unitId:g,subUnitId:E,row:D,col:be}=s,{width:ye=160,height:Ee=72}=(J=o==null?void 0:o.defaultNoteSize)!=null?J:{},V=(Q=t.getNote(g,E,D,be))!=null?Q:{width:ye,height:Ee,note:""};u.current&&(h(V),u.current.style.width=`${V.width}px`,u.current.style.height=`${V.height}px`)},[s,u]);const d=v.useDependency(a.ICommandService),_=v.useDebounceFn(g=>{s&&(g.note?d.executeCommand(f.SheetUpdateNoteCommand.id,{unitId:s.unitId,sheetId:s.subUnitId,row:s.row,col:s.col,note:g}):d.executeCommand(f.SheetDeleteNoteCommand.id,{unitId:s.unitId,sheetId:s.subUnitId,row:s.row,col:s.col}))}),S=C.useCallback(g=>{if(!p)return;const E={...p,note:g};h(E),_(E)},[p]),w=C.useCallback((g,E)=>{if(!p)return;const D={...p,width:g,height:E};h(D),_(D)},[p]);return ee.jsx(Z.Textarea,{ref:u,"data-u-comp":"note-textarea",className:Z.clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),value:p==null?void 0:p.note,placeholder:i.t("note.placeholder"),onResize:w,onValueChange:S,onWheel:g=>{document.activeElement!==u.current&&l.engine.getCanvasElement().dispatchEvent(new WheelEvent(g.type,g.nativeEvent))}})};function L(n){const e=n.get(m.SheetsSelectionsService),t=n.get(a.IUniverInstanceService);return e.selectionMoveEnd$.pipe(I.map(()=>{const i=e.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const r=m.getSheetCommandTarget(t);if(!r)return!1;const{actualColumn:o,actualRow:s}=i.primary;return!!n.get(f.SheetsNoteModel).getNote(r.unitId,r.subUnitId,s,o)}))}function Ce(n){return{id:j.id,type:v.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:I.combineLatest([v.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),L(n)]).pipe(I.map(([e,t])=>e||t)),disabled$:M.getCurrentRangeDisable$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission]}),commandId:j.id}}function _e(n){return{id:f.SheetDeleteNoteCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:L(n).pipe(I.map(e=>!e)),disabled$:M.getCurrentRangeDisable$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission]})}}function fe(n){return{id:f.SheetToggleNotePopupCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:L(n).pipe(I.map(e=>!e))}}const Se={[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{order:0,[j.id]:{order:0,menuItemFactory:Ce},[f.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:_e},[f.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:fe}}}};var ge=Object.getOwnPropertyDescriptor,me=(n,e,t,i)=>{for(var r=i>1?void 0:i?ge(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},x=(n,e)=>(t,i)=>e(t,i,n);let H=class extends a.Disposable{constructor(n,e,t){super(),this._componentManager=n,this._menuManagerService=e,this._commandService=t,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[R,G],["AddNoteIcon",F],["DeleteNoteIcon",q],["HideNoteIcon",z]].forEach(([n,e])=>{this.disposeWithMe(this._componentManager.register(n,e))})}_initMenu(){this._menuManagerService.mergeMenu(Se)}_initCommands(){this._commandService.registerCommand(j)}};H=me([x(0,a.Inject(v.ComponentManager)),x(1,a.Inject(v.IMenuManagerService)),x(2,a.ICommandService)],H);var Ie=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Ne=(n,e,t)=>e in n?Ie(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Me=(n,e,t,i)=>{for(var r=i>1?void 0:i?Pe(e,t):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},K=(n,e)=>(t,i)=>e(t,i,n),Y=(n,e,t)=>Ne(n,typeof e!="symbol"?e+"":e,t);const we="SHEET_NOTE_UI_PLUGIN";c.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(e=B,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{menu:r,...o}=a.merge({},B,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(A,o)}onStarting(){[[c.SheetsNotePopupService],[c.SheetsCellContentController],[c.SheetsNotePopupController],[H],[$]].forEach(e=>{this._injector.add(e)})}onReady(){a.touchDependencies(this._injector,[[H],[c.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[c.SheetsNotePopupController],[$]])}},Y(c.UniverSheetsNoteUIPlugin,"pluginName",we),Y(c.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsNoteUIPlugin=Me([a.DependentOn(f.UniverSheetsNotePlugin),K(1,a.Inject(a.Injector)),K(2,a.IConfigService)],c.UniverSheetsNoteUIPlugin),c.SheetsNote=G,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
10
+ (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("react/jsx-runtime"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-note","rxjs","@univerjs/sheets-ui","rxjs/operators","@univerjs/ui","react","react/jsx-runtime","@univerjs/design"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsNoteUi={},c.UniverCore,c.UniverEngineRender,c.UniverSheets,c.UniverSheetsNote,c.rxjs,c.UniverSheetsUi,c.rxjs.operators,c.UniverUi,c.React,c.React,c.UniverDesign))})(this,(function(c,a,y,N,I,b,E,ce,f,S,ue,W){"use strict";var He=Object.defineProperty;var Re=(c,a,y)=>a in c?He(c,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[a]=y;var $=(c,a,y)=>Re(c,typeof a!="symbol"?a+"":a,y);var le=Object.getOwnPropertyDescriptor,pe=(r,t,e,i)=>{for(var n=i>1?void 0:i?le(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},D=(r,t)=>(e,i)=>t(e,i,r);c.SheetsCellContentController=class extends a.Disposable{constructor(t,e,i,n){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._renderManagerService=i,this._univerInstanceService=n,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(t,e,i)=>{const{row:n,col:o,unitId:s,subUnitId:l}=e;return this._sheetsNoteModel.getNote(s,l,{row:n,col:o})&&((!t||t===e.rawData)&&(t={...e.rawData}),t.markers={...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}),i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const i=e.getUnitId(),n=this._renderManagerService.getRenderById(i);(o=n==null?void 0:n.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(b.debounceTime(16)).subscribe(()=>{t()}))}},c.SheetsCellContentController=pe([D(0,a.Inject(N.SheetInterceptorService)),D(1,a.Inject(I.SheetsNoteModel)),D(2,y.IRenderManagerService),D(3,a.IUniverInstanceService)],c.SheetsCellContentController);const k="SHEET_NOTE_COMPONENT";var he=Object.getOwnPropertyDescriptor,de=(r,t,e,i)=>{for(var n=i>1?void 0:i?he(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},F=(r,t)=>(e,i)=>t(e,i,r);c.SheetsNotePopupService=class extends a.Disposable{constructor(e,i){super();$(this,"_lastPopup",null);$(this,"_activePopup");$(this,"_activePopup$",new b.BehaviorSubject(null));$(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(e,i){var p;const{row:n,col:o,unitId:s,subUnitId:l}=e;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&l===((p=this.activePopup)==null?void 0:p.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=e,this._activePopup$.next(e);const u=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:l,row:n,col:o},{componentKey:k,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:e},priority:3});if(!u)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(u),d.add({dispose:()=>{i==null||i()}}),this._lastPopup=d}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsNotePopupService=de([F(0,f.IZenZoneService),F(1,a.Inject(E.CellPopupManagerService))],c.SheetsNotePopupService);var ve=Object.getOwnPropertyDescriptor,Ce=(r,t,e,i)=>{for(var n=i>1?void 0:i?ve(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},O=(r,t)=>(e,i)=>t(e,i,r);c.SheetsNotePopupController=class extends a.Disposable{constructor(e,i,n,o,s,l){super();$(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=e,this._sheetsNoteModel=i,this._sheetSelectionService=n,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=l,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,i,n){var g,M,w;const o=(g=e[0])==null?void 0:g.range,s=this._renderManagerService.getRenderById(i),l=(M=s==null?void 0:s.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:M.skeleton;if(!l||!o)return;const u=l.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((w=o.rangeType)!=null?w:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&a.Rectangle.equals(u.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const p=u.actualRow,h=u.actualColumn,C=this._sheetsNoteModel.getNote(i,n,{row:p,col:h});C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:C.id,row:p,col:h}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(e,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ce.debounceTime(100)).subscribe(e=>{var C;if(!(e!=null&&e.location))return;const{unitId:i,subUnitId:n,row:o,col:s}=e.location,l=this._renderManagerService.getRenderById(i),u=(C=l==null?void 0:l.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:C.skeleton;let d=o,p=s,h=this._sheetsNoteModel.getNote(i,n,{row:d,col:p});if(!h&&u){const g=u.getCellWithCoordByIndex(o,s),{startRow:M,endRow:w,startColumn:U,endColumn:v}=g.mergeInfo;if(M!==w||U!==v){const _=this._sheetsNoteModel.getSheetNotes(i,n);if(_){for(const[T,m]of _)if(m.row>=M&&m.row<=w&&m.col>=U&&m.col<=v){h=m,d=m.row,p=m.col;break}}}}h!=null&&h.show||(h?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:h.id,row:d,col:p,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;const{unitId:i,subUnitId:n,noteId:o,row:s,col:l}=this._sheetsNotePopupService.activePopup,{oldNote:u,newNote:d}=e;d===null&&e.unitId===i&&e.subUnitId===n&&(u!=null&&u.id&&u.id===o||(u==null?void 0:u.row)===s&&u.col===l)&&this._sheetsNotePopupService.hidePopup(!0)}))}},c.SheetsNotePopupController=Ce([O(0,a.Inject(c.SheetsNotePopupService)),O(1,a.Inject(I.SheetsNoteModel)),O(2,a.Inject(N.SheetsSelectionsService)),O(3,E.IEditorBridgeService),O(4,y.IRenderManagerService),O(5,a.Inject(E.HoverManagerService))],c.SheetsNotePopupController);const q="sheets-note-ui.config",z={};var fe=Object.getOwnPropertyDescriptor,_e=(r,t,e,i)=>{for(var n=i>1?void 0:i?fe(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},H=(r,t)=>(e,i)=>t(e,i,r);let R=class extends a.Disposable{constructor(t,e,i,n){super();$(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=e,this._cellPopupManagerService=i,this._sheetsNotePopupService=n,this._initNoteChangeListener()}_showPopup(t,e,i,n){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:e,row:i,col:n},{componentKey:k,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:e,row:i,col:n}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((t,e,i)=>{i.dispose()})}_initSheet(t,e){var o;this._noteMatrix.forValue((s,l,u)=>{u.dispose()}),this._noteMatrix=new a.ObjectMatrix;const n=(s,l,u,d,p)=>{const h=this._noteMatrix,C=h.getValue(u,d);if(p!=null&&p.show){if(!C){const g=this._showPopup(s,l,u,d);g&&h.setValue(u,d,g)}}else C&&(C.dispose(),h.realDeleteValue(u,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,e))==null||o.forEach(s=>{n(t,e,s.row,s.col,s)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==t||s.subUnitId!==e))switch(s.type){case"ref":{const{unitId:l,subUnitId:u,oldNote:d,newNote:p}=s;if(!p.show)return;const h=this._noteMatrix,{row:C,col:g}=d,{row:M,col:w}=p,U=h.getValue(C,g);U&&(U.dispose(),h.realDeleteValue(C,g));const v=this._showPopup(l,u,M,w);v&&h.setValue(M,w,v);break}case"update":{const{unitId:l,subUnitId:u,oldNote:d,newNote:p}=s,h=p?p.row:d.row,C=p?p.col:d.col;n(l,u,h,C,p);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(b.switchMap(t=>{var e;return(e=t==null?void 0:t.activeSheet$)!=null?e:b.of(null)})).subscribe(t=>{if(t){const e=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{e.unsubscribe()}}else this._noteMatrix.forValue((e,i,n)=>{n.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};R=_e([H(0,a.Inject(I.SheetsNoteModel)),H(1,a.Inject(a.IUniverInstanceService)),H(2,a.Inject(E.CellPopupManagerService)),H(3,a.Inject(c.SheetsNotePopupService))],R);function L({ref:r,...t}){const{icon:e,id:i,className:n,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${n||""}`.trim(),u=S.useRef(`_${me()}`);return G(e,`${i}`,{defIds:e.defIds,idSuffix:u.current},{ref:r,className:l,...s},o)}function G(r,t,e,i,n){return S.createElement(r.tag,{key:t,...Se(r,e,n),...i},(ge(r,e).children||[]).map((o,s)=>G(o,`${t}-${r.tag}-${s}`,e,void 0,n)))}function Se(r,t,e){const i={...r.attrs};e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(([o,s])=>{o==="mask"&&typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:n}=t;return!n||n.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(([o,s])=>{typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),i}function ge(r,t){var i;const{defIds:e}=t;return!e||e.length===0?r:r.tag==="defs"&&((i=r.children)!=null&&i.length)?{...r,children:r.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+t.idSuffix}}:n)}:r}function me(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";const Ie={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},K=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"add-note-icon",ref:e,icon:Ie}))});K.displayName="AddNoteIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"}}]},Y=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"delete-note-icon",ref:e,icon:Pe}))});Y.displayName="DeleteNoteIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},J=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"hide-note-icon",ref:e,icon:Ne}))});J.displayName="HideNoteIcon";const x={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(r,t)=>{var d;const e=r.get(N.SheetsSelectionsService),i=r.get(c.SheetsNotePopupService),o=r.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),l=e.getCurrentLastSelection();if(!(l!=null&&l.primary))return!1;const{primary:u}=l;return i.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:(d=t==null?void 0:t.trigger)!=null?d:"add-note"}),!0}},Q=r=>{var U;const{popup:t}=r,e=f.useDependency(I.SheetsNoteModel),i=f.useDependency(a.LocaleService),n=f.useDependency(y.IRenderManagerService),o=f.useDependency(c.SheetsNotePopupService),s=f.useConfigValue(q),l=(U=t.extraProps)==null?void 0:U.location;if(!l)return console.error("Popup extraProps or location is undefined."),null;const u=S.useRef(null),d=n.getRenderById(l.unitId),[p,h]=S.useState(null);S.useEffect(()=>{var te,ie,ne,re,oe,se;const{unitId:v,subUnitId:_,row:T,col:m}=l,P=e.getNote(v,_,{row:T,col:m}),B=(ne=(ie=P==null?void 0:P.width)!=null?ie:(te=s==null?void 0:s.defaultNoteSize)==null?void 0:te.width)!=null?ne:160,j=(se=(oe=P==null?void 0:P.height)!=null?oe:(re=s==null?void 0:s.defaultNoteSize)==null?void 0:re.height)!=null?se:72;if(P)h(P);else{const ae={width:B,height:j,note:""};h(ae),g(ae)}u.current&&(u.current.style.width=`${B}px`,u.current.style.height=`${j}px`)},[l,u]),S.useEffect(()=>{if(!l||l.temp||!l.trigger||!u.current)return;const v=requestAnimationFrame(()=>{var _;(_=u.current)==null||_.focus()});return()=>cancelAnimationFrame(v)},[l]);const C=f.useDependency(a.ICommandService),g=f.useDebounceFn(v=>{if(!l)return;const{unitId:_,subUnitId:T,row:m,col:P}=l;if(!C.syncExecuteCommand(I.SheetUpdateNoteCommand.id,{unitId:_,sheetId:T,row:m,col:P,note:v})){const j=e.getNote(_,T,{noteId:v.id,row:m,col:P});j?h(j):o.hidePopup(!0)}}),M=S.useCallback(v=>{if(!p||v===p.note)return;const _={...p,note:v};h(_),g(_)},[p]),w=S.useCallback((v,_)=>{if(!p||v===p.width&&_===p.height)return;const T={...p,width:v,height:_};h(T),g(T)},[p]);return ue.jsx(W.Textarea,{ref:u,"data-u-comp":"note-textarea",className:W.clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),value:p==null?void 0:p.note,placeholder:i.t("note.placeholder"),onResize:w,onValueChange:M,onWheel:v=>{document.activeElement!==u.current&&d.engine.getCanvasElement().dispatchEvent(new WheelEvent(v.type,v.nativeEvent))}})};function Z(r){const t=r.get(N.SheetsSelectionsService),e=r.get(a.IUniverInstanceService);return t.selectionMoveEnd$.pipe(b.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const n=N.getSheetCommandTarget(e);if(!n)return!1;const{actualColumn:o,actualRow:s}=i.primary;return!!r.get(I.SheetsNoteModel).getNote(n.unitId,n.subUnitId,{row:s,col:o})}))}function Me(r){return{id:x.id,type:f.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:b.combineLatest([f.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),Z(r)]).pipe(b.map(([t,e])=>t||e)),disabled$:E.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:x.id}}function we(r){return{id:I.SheetDeleteNoteCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:Z(r).pipe(b.map(t=>!t)),disabled$:E.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function be(r){return{id:I.SheetToggleNotePopupCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:Z(r).pipe(b.map(t=>!t))}}const ye={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:0,[x.id]:{order:0,menuItemFactory:Me},[I.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:we},[I.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:be}}}};var Ee=Object.getOwnPropertyDescriptor,Ue=(r,t,e,i)=>{for(var n=i>1?void 0:i?Ee(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},A=(r,t)=>(e,i)=>t(e,i,r);let V=class extends a.Disposable{constructor(r,t,e){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=e,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[k,Q],["AddNoteIcon",K],["DeleteNoteIcon",Y],["HideNoteIcon",J]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}_initMenu(){this._menuManagerService.mergeMenu(ye)}_initCommands(){this._commandService.registerCommand(x)}};V=Ue([A(0,a.Inject(f.ComponentManager)),A(1,a.Inject(f.IMenuManagerService)),A(2,a.ICommandService)],V);var Te=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Oe=(r,t,e)=>t in r?Te(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,je=(r,t,e,i)=>{for(var n=i>1?void 0:i?$e(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},X=(r,t)=>(e,i)=>t(e,i,r),ee=(r,t,e)=>Oe(r,typeof t!="symbol"?t+"":t,e);const De="SHEET_NOTE_UI_PLUGIN";c.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(t=z,e,i){super(),this._config=t,this._injector=e,this._configService=i;const{menu:n,...o}=a.merge({},z,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(q,o)}onStarting(){[[c.SheetsNotePopupService],[c.SheetsCellContentController],[c.SheetsNotePopupController],[V],[R]].forEach(t=>{this._injector.add(t)})}onReady(){a.touchDependencies(this._injector,[[V],[c.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[c.SheetsNotePopupController],[R]])}},ee(c.UniverSheetsNoteUIPlugin,"pluginName",De),ee(c.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsNoteUIPlugin=je([a.DependentOn(I.UniverSheetsNotePlugin),X(1,a.Inject(a.Injector)),X(2,a.IConfigService)],c.UniverSheetsNoteUIPlugin),c.SheetsNote=Q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
11
11
 
12
12
 
13
13
  // index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-note",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,16 +58,16 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/sheets-note": "0.15.4",
62
- "@univerjs/sheets-note-ui": "0.15.4"
61
+ "@univerjs/sheets-note": "0.15.5",
62
+ "@univerjs/sheets-note-ui": "0.15.5"
63
63
  },
64
64
  "devDependencies": {
65
- "@univerjs/core": "0.15.4",
65
+ "@univerjs/core": "0.15.5",
66
66
  "react": "18.3.1",
67
67
  "react-dom": "18.3.1",
68
68
  "rxjs": "7.8.2",
69
69
  "typescript": "^5.9.3",
70
- "@univerjs-infra/shared": "0.15.4"
70
+ "@univerjs-infra/shared": "0.15.5"
71
71
  },
72
72
  "scripts": {
73
73
  "prebuild:preset": "tsx prepare.ts",