@univerjs/preset-sheets-note 0.10.12 → 0.10.14-nightly.202511031023

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 +2 -2
  2. package/package.json +5 -5
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @univerjs/sheets-note/index
2
- (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverSheetsNote={},u.UniverCore,u.UniverSheets,u.rxjs))})(this,(function(u,a,l,p){"use strict";var z=Object.defineProperty;var F=(u,a,l)=>a in u?z(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var _=(u,a,l)=>F(u,typeof a!="symbol"?a+"":a,l);class g extends a.Disposable{constructor(){super(...arguments);_(this,"_noteMatrix",new Map);_(this,"_change$",new p.Subject);_(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(n,e){let t=this._noteMatrix.get(n);t||(t=new Map,this._noteMatrix.set(n,t));let s=t.get(e);return s||(s=new a.ObjectMatrix,t.set(e,s)),s}getSheetShowNotes$(n,e){return this._change$.pipe(p.filter(({unitId:t,sheetId:s})=>t===n&&s===e),p.map(()=>{const t=this._ensureNoteMatrix(n,e),s=[];return t.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:n,subUnitId:e},note:c})}),s}))}getCellNoteChange$(n,e,t,s){return this._change$.pipe(p.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===n&&h===e&&c===t&&d===s),p.map(({note:i})=>i))}updateNote(n,e,t,s,i,h){const c=this._ensureNoteMatrix(n,e),d=c.getValue(t,s);c.setValue(t,s,i),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);h.realDeleteValue(t,s),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(t,s,d),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(n,e,t,s,i,h,c){const d=this._ensureNoteMatrix(n,e),m=d.getValue(t,s);m&&(d.realDeleteValue(t,s),d.setValue(i,h,m),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"ref",newPosition:{row:i,col:h},note:m,silent:c}))}getNote(n,e,t,s){return this._ensureNoteMatrix(n,e).getValue(t,s)}getUnitNotes(n){return this._noteMatrix.get(n)}getSheetNotes(n,e){const t=this._noteMatrix.get(n);if(t)return t.get(e)}getNotes(){return this._noteMatrix}deleteUnitNotes(n){this._noteMatrix.delete(n)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,note:i,silent:h}=o;return r.get(g).updateNote(n,e,t,s,i,h),!0}},S={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).removeNote(n,e,t,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).toggleNotePopup(n,e,t,s,i),!0}},v={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,silent:h}=o;return r.get(g).updateNotePosition(n,e,t,s,i.row,i.col,h),!0}},P={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(S.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},y={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(I.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},R={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,o)=>r.get(a.ICommandService).syncExecuteCommand(N.id,o)},U="SHEET_NOTE_PLUGIN";var $=Object.getOwnPropertyDescriptor,D=(r,o,n,e)=>{for(var t=e>1?void 0:e?$(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},w=(r,o)=>(n,e)=>o(n,e,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,n,e){super(),this._resourceManagerService=o,this._univerInstanceService=n,this._sheetsNoteModel=e,this._initSnapshot()}_initSnapshot(){const o=e=>{const t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return"";const s={};return t.forEach((i,h)=>{const c={};i.forValue((d,m,H)=>{c[d]||(c[d]={}),c[d][m]=H}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>o(e),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,m])=>{this._sheetsNoteModel.updateNote(e,s,Number(h),Number(d),m)})})})}}))}},u.SheetsNoteResourceController=D([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(g))],u.SheetsNoteResourceController);const j="sheets-note.config",O={};var E=Object.getOwnPropertyDescriptor,x=(r,o,n,e)=>{for(var t=e>1?void 0:e?E(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},f=(r,o)=>(n,e)=>o(n,e,r);let M=class extends a.Disposable{constructor(o,n,e,t){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(o,n,e,t,s,i,h)=>i?{redos:[{id:v.id,params:{unitId:o,sheetId:n,row:t,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:v.id,params:{unitId:o,sheetId:n,row:i.startRow,col:i.startColumn,newPosition:{row:t,col:s},note:e,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:n,row:t,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:n,row:t,col:s,note:e}}]});this._refRangeService=o,this._sheetsNoteModel=n,this._selectionManagerService=e,this._commandService=t,this._initData(),this._initRefRange()}_getIdWithUnitId(o,n,e,t){return`${o}-${n}-${e}-${t}`}_register(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._disposableMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===i.startColumn&&d.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,n,e,t,s,d,!1)},o,n))}_watch(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._watcherMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.watchRange(o,n,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,n,e,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[n,e]of o)for(const[t,s]of e)s.forValue((i,h,c)=>(c&&(this._register(n,t,c,i,h),this._watch(n,t,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:n,sheetId:e,row:t,col:s,note:i}=o,h=this._getIdWithUnitId(n,e,t,s);i?this._disposableMap.has(h)||(this._register(n,e,i,t,s),this._watch(n,e,i,t,s)):(this._unregister(n,e,t,s),this._unwatch(n,e,t,s));break}case"ref":{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(n,e,t,s),c||(this._unwatch(n,e,t,s),this._watch(n,e,h,i.row,i.col)),this._register(n,e,h,i.row,i.col);break}}}))}};M=x([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(g)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var V=Object.getOwnPropertyDescriptor,A=(r,o,n,e)=>{for(var t=e>1?void 0:e?V(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},W=(r,o)=>(n,e)=>o(n,e,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[v,I,N,S,P,y,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=A([W(0,a.ICommandService)],C);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(r,o,n)=>o in r?L(r,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[o]=n,G=(r,o,n,e)=>{for(var t=e>1?void 0:e?J(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},T=(r,o)=>(n,e)=>o(n,e,r),b=(r,o,n)=>q(r,typeof o!="symbol"?o+"":o,n);u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o=O,n,e){super(),this._config=o,this._configService=n,this._injector=e;const{...t}=a.merge({},O,this._config);this._configService.setConfig(j,t)}onStarting(){[[g],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[g],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},b(u.UniverSheetsNotePlugin,"pluginName",U),b(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=G([a.DependentOn(l.UniverSheetsPlugin),T(1,a.IConfigService),T(2,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=S,u.SheetDeleteNoteCommand=P,u.SheetToggleNotePopupCommand=y,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=g,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=v,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
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"})}));
3
3
 
4
4
 
5
5
  // @univerjs/sheets-note/facade
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  // @univerjs/sheets-note-ui/index
10
- (function(u,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/jsx-runtime"),require("@univerjs/design"),require("react")):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/jsx-runtime","@univerjs/design","react"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverSheetsNoteUi={},u.UniverCore,u.UniverEngineRender,u.UniverSheets,u.UniverSheetsNote,u.rxjs,u.UniverSheetsUi,u.rxjs.operators,u.UniverUi,u.React,u.UniverDesign,u.React))})(this,(function(u,a,N,P,_,I,w,ee,v,te,Z,f){"use strict";var Ue=Object.defineProperty;var je=(u,a,N)=>a in u?Ue(u,a,{enumerable:!0,configurable:!0,writable:!0,value:N}):u[a]=N;var b=(u,a,N)=>je(u,typeof a!="symbol"?a+"":a,N);var ne=Object.getOwnPropertyDescriptor,ie=(i,e,t,n)=>{for(var r=n>1?void 0:n?ne(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=s(r)||r);return r},T=(i,e)=>(t,n)=>e(t,n,i);u.SheetsCellContentController=class extends a.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=n,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const{row:r,col:o,unitId:s,subUnitId:c}=t;return this._sheetsNoteModel.getNote(s,c,r,o)&&((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:"#FFBD37",size:6}}),n(e)},priority:100}))}_initSkeletonChange(){const e=()=>{var o;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),r=this._renderManagerService.getRenderById(n);(o=r==null?void 0:r.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(I.debounceTime(16)).subscribe(()=>{e()}))}},u.SheetsCellContentController=ie([T(0,a.Inject(P.SheetInterceptorService)),T(1,a.Inject(_.SheetsNoteModel)),T(2,N.IRenderManagerService),T(3,a.IUniverInstanceService)],u.SheetsCellContentController);const x="SHEET_NOTE_COMPONENT";var re=Object.getOwnPropertyDescriptor,oe=(i,e,t,n)=>{for(var r=n>1?void 0:n?re(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=s(r)||r);return r},B=(i,e)=>(t,n)=>e(t,n,i);u.SheetsNotePopupService=class extends a.Disposable{constructor(t,n){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=n,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,n){var h;const{row:r,col:o,unitId:s,subUnitId:c}=t;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&c===((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:c,row:r,col:o},{componentKey:x,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:()=>{n==null||n()}}),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))}},u.SheetsNotePopupService=oe([B(0,v.IZenZoneService),B(1,a.Inject(w.CellPopupManagerService))],u.SheetsNotePopupService);var se=Object.getOwnPropertyDescriptor,ae=(i,e,t,n)=>{for(var r=n>1?void 0:n?se(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=s(r)||r);return r},E=(i,e)=>(t,n)=>e(t,n,i);u.SheetsNotePopupController=class extends a.Disposable{constructor(t,n,r,o,s,c){super();b(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=t,this._sheetsNoteModel=n,this._sheetSelectionService=r,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(t,n,r){var S,y,M;const o=(S=t[0])==null?void 0:S.range,s=this._renderManagerService.getRenderById(n),c=(y=s==null?void 0:s.with(w.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:y.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((M=o.rangeType)!=null?M: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,C=this._sheetsNoteModel.getNote(n,r,h,d);C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,row:h,col:d}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchingSheet)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ee.debounceTime(100)).subscribe(t=>{if(!(t!=null&&t.location))return;const{unitId:n,subUnitId:r,row:o,col:s}=t.location,c=this._sheetsNoteModel.getNote(n,r,o,s);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,row:o,col:s,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=ae([E(0,a.Inject(u.SheetsNotePopupService)),E(1,a.Inject(_.SheetsNoteModel)),E(2,a.Inject(P.SheetsSelectionsService)),E(3,w.IEditorBridgeService),E(4,N.IRenderManagerService),E(5,a.Inject(w.HoverManagerService))],u.SheetsNotePopupController);const A="sheets-note-ui.config",W={};var ue=Object.getOwnPropertyDescriptor,ce=(i,e,t,n)=>{for(var r=n>1?void 0:n?ue(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=s(r)||r);return r},U=(i,e)=>(t,n)=>e(t,n,i);let j=class extends a.Disposable{constructor(e,t,n,r){super();b(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=e,this._univerInstanceService=t,this._cellPopupManagerService=n,this._sheetsNotePopupService=r,this._initNoteChangeListener()}_showPopup(e,t,n,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:n,col:r},{componentKey:x,direction:"horizontal",extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((e,t,n)=>{n.dispose()})}_initSheet(e,t){var o;this._noteMatrix.forValue((s,c,l)=>{l.dispose()}),this._noteMatrix=new a.ObjectMatrix;const r=(s,c,l,p,h)=>{const d=this._noteMatrix,C=d.getValue(l,p);if(h!=null&&h.show){if(!C){const S=this._showPopup(s,c,l,p);S&&d.setValue(l,p,S)}}else C&&(C.dispose(),d.realDeleteValue(l,p))};return(o=this._sheetsNoteModel.getSheetNotes(e,t))==null||o.forValue((s,c,l)=>{r(e,t,s,c,l)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==e||s.sheetId!==t))switch(s.type){case"ref":{const{unitId:c,sheetId:l,row:p,col:h,newPosition:d,note:C}=s,S=this._noteMatrix;if(!C.show)return;const y=S.getValue(p,h);y&&(y.dispose(),S.realDeleteValue(p,h));const M=this._showPopup(c,l,d.row,d.col);M&&S.setValue(d.row,d.col,M);break}case"update":{const{unitId:c,sheetId:l,row:p,col:h,note:d}=s;r(c,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,n,r)=>{r.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};j=ce([U(0,a.Inject(_.SheetsNoteModel)),U(1,a.Inject(a.IUniverInstanceService)),U(2,a.Inject(w.CellPopupManagerService)),U(3,a.Inject(u.SheetsNotePopupService))],j);var g=function(){return g=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},g.apply(this,arguments)},le=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},H=f.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=le(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=f.useRef("_".concat(de()));return F(t,"".concat(n),{defIds:t.defIds,idSuffix:l.current},g({ref:e,className:c},s),o)});function F(i,e,t,n,r){return f.createElement(i.tag,g(g({key:e},pe(i,t,r)),n),(he(i,t).children||[]).map(function(o,s){return F(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function pe(i,e,t){var n=g({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),i.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];s==="mask"&&typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function he(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?g(g({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?g(g({},r),{attrs:g(g({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function de(){return Math.random().toString(36).substring(2,8)}H.displayName="UniverIcon";var 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:"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"}}]},q=f.forwardRef(function(i,e){return f.createElement(H,Object.assign({},i,{id:"add-note-icon",ref:e,icon:ve}))});q.displayName="AddNoteIcon";var fe={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"}}]},z=f.forwardRef(function(i,e){return f.createElement(H,Object.assign({},i,{id:"delete-note-icon",ref:e,icon:fe}))});z.displayName="DeleteNoteIcon";var Ce={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"}}]},G=f.forwardRef(function(i,e){return f.createElement(H,Object.assign({},i,{id:"hide-note-icon",ref:e,icon:Ce}))});G.displayName="HideNoteIcon";const D={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(P.SheetsSelectionsService),n=i.get(u.SheetsNotePopupService),o=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),c=t.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:l}=c;return n.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:e==null?void 0:e.trigger}),!0}},K=i=>{var M;const{popup:e}=i,t=v.useDependency(_.SheetsNoteModel),n=v.useDependency(a.LocaleService),r=v.useDependency(N.IRenderManagerService),o=v.useConfigValue(A),s=(M=e.extraProps)==null?void 0:M.location;if(!s)return console.error("Popup extraProps or location is undefined."),null;const c=f.useRef(null),l=r.getRenderById(s.unitId),[p,h]=f.useState(null);f.useEffect(()=>{var Q,X;const{unitId:m,subUnitId:O,row:R,col:Ee}=s,{width:Oe=160,height:Te=72}=(Q=o==null?void 0:o.defaultNoteSize)!=null?Q:{},k=(X=t.getNote(m,O,R,Ee))!=null?X:{width:Oe,height:Te,note:""};c.current&&(h(k),c.current.style.width=`${k.width}px`,c.current.style.height=`${k.height}px`)},[s,c]);const d=v.useDependency(a.ICommandService),C=v.useDebounceFn(m=>{s&&(m.note?d.executeCommand(_.SheetUpdateNoteCommand.id,{unitId:s.unitId,sheetId:s.subUnitId,row:s.row,col:s.col,note:m}):d.executeCommand(_.SheetDeleteNoteCommand.id,{unitId:s.unitId,sheetId:s.subUnitId,row:s.row,col:s.col}))}),S=f.useCallback(m=>{if(!p)return;const O={...p,note:m};h(O),C(O)},[p]),y=f.useCallback((m,O)=>{if(!p)return;const R={...p,width:m,height:O};h(R),C(R)},[p]);return te.jsx(Z.Textarea,{ref:c,"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:n.t("note.placeholder"),onResize:y,onValueChange:S,onWheel:m=>{document.activeElement!==c.current&&l.engine.getCanvasElement().dispatchEvent(new WheelEvent(m.type,m.nativeEvent))}})};function L(i){const e=i.get(P.SheetsSelectionsService),t=i.get(a.IUniverInstanceService);return e.selectionMoveEnd$.pipe(I.map(()=>{const n=e.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const r=P.getSheetCommandTarget(t);if(!r)return!1;const{actualColumn:o,actualRow:s}=n.primary;return!!i.get(_.SheetsNoteModel).getNote(r.unitId,r.subUnitId,s,o)}))}function _e(i){return{id:D.id,type:v.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:I.combineLatest([v.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),L(i)]).pipe(I.map(([e,t])=>e||t)),disabled$:w.getCurrentRangeDisable$(i,{workbookTypes:[P.WorkbookEditablePermission],worksheetTypes:[P.WorksheetEditPermission]}),commandId:D.id}}function ge(i){return{id:_.SheetDeleteNoteCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:L(i).pipe(I.map(e=>!e)),disabled$:w.getCurrentRangeDisable$(i,{workbookTypes:[P.WorkbookEditablePermission],worksheetTypes:[P.WorksheetEditPermission]})}}function Se(i){return{id:_.SheetToggleNotePopupCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:L(i).pipe(I.map(e=>!e))}}const me={[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{order:0,[D.id]:{order:0,menuItemFactory:_e},[_.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:ge},[_.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};var Pe=Object.getOwnPropertyDescriptor,Ie=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pe(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=s(r)||r);return r},V=(i,e)=>(t,n)=>e(t,n,i);let $=class extends a.Disposable{constructor(i,e,t){super(),this._componentManager=i,this._menuManagerService=e,this._commandService=t,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[x,K],["AddNoteIcon",q],["DeleteNoteIcon",z],["HideNoteIcon",G]].forEach(([i,e])=>{this.disposeWithMe(this._componentManager.register(i,e))})}_initMenu(){this._menuManagerService.mergeMenu(me)}_initCommands(){this._commandService.registerCommand(D)}};$=Ie([V(0,a.Inject(v.ComponentManager)),V(1,a.Inject(v.IMenuManagerService)),V(2,a.ICommandService)],$);var Ne=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(i,e,t)=>e in i?Ne(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ye=(i,e,t,n)=>{for(var r=n>1?void 0:n?Me(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=s(r)||r);return r},Y=(i,e)=>(t,n)=>e(t,n,i),J=(i,e,t)=>we(i,typeof e!="symbol"?e+"":e,t);const be="SHEET_NOTE_UI_PLUGIN";u.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(e=W,t,n){super(),this._config=e,this._injector=t,this._configService=n;const{menu:r,...o}=a.merge({},W,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(A,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[$],[j]].forEach(e=>{this._injector.add(e)})}onReady(){a.touchDependencies(this._injector,[[$],[u.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[u.SheetsNotePopupController],[j]])}},J(u.UniverSheetsNoteUIPlugin,"pluginName",be),J(u.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=ye([a.DependentOn(_.UniverSheetsNotePlugin),Y(1,a.Inject(a.Injector)),Y(2,a.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=K,Object.defineProperty(u,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,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"})}));
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.10.12",
3
+ "version": "0.10.14-nightly.202511031023",
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.10.12",
62
- "@univerjs/sheets-note-ui": "0.10.12"
61
+ "@univerjs/sheets-note": "0.10.14-nightly.202511031023",
62
+ "@univerjs/sheets-note-ui": "0.10.14-nightly.202511031023"
63
63
  },
64
64
  "devDependencies": {
65
- "@univerjs/core": "0.10.12",
65
+ "@univerjs/core": "0.10.14-nightly.202511031023",
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.10.12"
70
+ "@univerjs-infra/shared": "0.10.14"
71
71
  },
72
72
  "scripts": {
73
73
  "prebuild:preset": "tsx prepare.ts",