@univerjs/preset-sheets-note 0.8.2 → 0.8.3-nightly.202506271607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";const e=require("@univerjs/core"),r=require("@univerjs/sheets-note-ui/locale/ko-KR"),s=e.merge({},r);module.exports=s;
@@ -0,0 +1,9 @@
1
+ import { merge as e } from "@univerjs/core";
2
+ import o from "@univerjs/sheets-note-ui/locale/ko-KR";
3
+ const m = e(
4
+ {},
5
+ o
6
+ );
7
+ export {
8
+ m as default
9
+ };
@@ -0,0 +1,9 @@
1
+ import { merge as e } from "@univerjs/core";
2
+ import o from "@univerjs/sheets-note-ui/locale/ko-KR";
3
+ const m = e(
4
+ {},
5
+ o
6
+ );
7
+ export {
8
+ m as default
9
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
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);const P="SHEET_NOTE_PLUGIN",$="sheets-note.config",y={};class g extends a.Disposable{constructor(){super(...arguments);_(this,"_noteMatrix",new Map);_(this,"_change$",new p.Subject);_(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(n,e){let t=this._noteMatrix.get(n);t||(t=new Map,this._noteMatrix.set(n,t));let s=t.get(e);return s||(s=new a.ObjectMatrix,t.set(e,s)),s}getSheetShowNotes$(n,e){return this._change$.pipe(p.filter(({unitId:t,sheetId:s})=>t===n&&s===e),p.map(()=>{const t=this._ensureNoteMatrix(n,e),s=[];return t.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:n,subUnitId:e},note:c})}),s}))}getCellNoteChange$(n,e,t,s){return this._change$.pipe(p.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===n&&h===e&&c===t&&d===s),p.map(({note:i})=>i))}updateNote(n,e,t,s,i,h){const c=this._ensureNoteMatrix(n,e),d=c.getValue(t,s);c.setValue(t,s,i),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);h.realDeleteValue(t,s),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(t,s,d),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(n,e,t,s,i,h,c){const d=this._ensureNoteMatrix(n,e),m=d.getValue(t,s);m&&(d.realDeleteValue(t,s),d.setValue(i,h,m),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"ref",newPosition:{row:i,col:h},note:m,silent:c}))}getNote(n,e,t,s){return this._ensureNoteMatrix(n,e).getValue(t,s)}getUnitNotes(n){return this._noteMatrix.get(n)}getSheetNotes(n,e){const t=this._noteMatrix.get(n);if(t)return t.get(e)}getNotes(){return this._noteMatrix}deleteUnitNotes(n){this._noteMatrix.delete(n)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,note:i,silent:h}=o;return r.get(g).updateNote(n,e,t,s,i,h),!0}},S={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).removeNote(n,e,t,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).toggleNotePopup(n,e,t,s,i),!0}},v={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,silent:h}=o;return r.get(g).updateNotePosition(n,e,t,s,i.row,i.col,h),!0}};var D=Object.getOwnPropertyDescriptor,j=(r,o,n,e)=>{for(var t=e>1?void 0:e?D(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},f=(r,o)=>(n,e)=>o(n,e,r);let M=class extends a.Disposable{constructor(o,n,e,t){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(o,n,e,t,s,i,h)=>i?{redos:[{id:v.id,params:{unitId:o,sheetId:n,row:t,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:v.id,params:{unitId:o,sheetId:n,row:i.startRow,col:i.startColumn,newPosition:{row:t,col:s},note:e,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:n,row:t,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:n,row:t,col:s,note:e}}]});this._refRangeService=o,this._sheetsNoteModel=n,this._selectionManagerService=e,this._commandService=t,this._initData(),this._initRefRange()}_getIdWithUnitId(o,n,e,t){return`${o}-${n}-${e}-${t}`}_register(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._disposableMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===i.startColumn&&d.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,n,e,t,s,d,!1)},o,n))}_watch(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._watcherMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.watchRange(o,n,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,n,e,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[n,e]of o)for(const[t,s]of e)s.forValue((i,h,c)=>(c&&(this._register(n,t,c,i,h),this._watch(n,t,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:n,sheetId:e,row:t,col:s,note:i}=o,h=this._getIdWithUnitId(n,e,t,s);i?this._disposableMap.has(h)||(this._register(n,e,i,t,s),this._watch(n,e,i,t,s)):(this._unregister(n,e,t,s),this._unwatch(n,e,t,s));break}case"ref":{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(n,e,t,s),c||(this._unwatch(n,e,t,s),this._watch(n,e,h,i.row,i.col)),this._register(n,e,h,i.row,i.col);break}}}))}};M=j([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(g)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var E=Object.getOwnPropertyDescriptor,x=(r,o,n,e)=>{for(var t=e>1?void 0:e?E(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},w=(r,o)=>(n,e)=>o(n,e,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,n,e){super(),this._resourceManagerService=o,this._univerInstanceService=n,this._sheetsNoteModel=e,this._initSnapshot()}_initSnapshot(){const o=e=>{const t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return"";const s={};return t.forEach((i,h)=>{const c={};i.forValue((d,m,H)=>{c[d]||(c[d]={}),c[d][m]=H}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:P,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>o(e),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,m])=>{this._sheetsNoteModel.updateNote(e,s,Number(h),Number(d),m)})})})}}))}},u.SheetsNoteResourceController=x([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(g))],u.SheetsNoteResourceController);const R={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(S.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},U={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(I.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},O={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,o)=>r.get(a.ICommandService).syncExecuteCommand(N.id,o)};var V=Object.getOwnPropertyDescriptor,A=(r,o,n,e)=>{for(var t=e>1?void 0:e?V(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},W=(r,o)=>(n,e)=>o(n,e,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[v,I,N,S,R,U,O].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=A([W(0,a.ICommandService)],C);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(r,o,n)=>o in r?L(r,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[o]=n,G=(r,o,n,e)=>{for(var t=e>1?void 0:e?J(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},T=(r,o)=>(n,e)=>o(n,e,r),b=(r,o,n)=>q(r,typeof o!="symbol"?o+"":o,n);u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o=y,n,e){super(),this._config=o,this._configService=n,this._injector=e;const{...t}=a.merge({},y,this._config);this._configService.setConfig($,t)}onStarting(){[[g],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[g],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},b(u.UniverSheetsNotePlugin,"pluginName",P),b(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=G([a.DependentOn(l.UniverSheetsPlugin),T(1,a.IConfigService),T(2,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=S,u.SheetDeleteNoteCommand=R,u.SheetToggleNotePopupCommand=U,u.SheetUpdateNoteCommand=O,u.SheetsNoteModel=g,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=v,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
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"})});
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,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-note"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs/operators"),require("react/jsx-runtime"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-note","@univerjs/engine-render","@univerjs/sheets","rxjs","@univerjs/sheets-ui","@univerjs/ui","rxjs/operators","react/jsx-runtime","@univerjs/design","react"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.UniverSheetsNoteUi={},u.UniverCore,u.UniverSheetsNote,u.UniverEngineRender,u.UniverSheets,u.rxjs,u.UniverSheetsUi,u.UniverUi,u.rxjs.operators,u.React,u.UniverDesign,u.React))})(this,function(u,s,d,x,I,P,w,C,ee,te,R,g){"use strict";var Ee=Object.defineProperty;var Oe=(u,s,d)=>s in u?Ee(u,s,{enumerable:!0,configurable:!0,writable:!0,value:d}):u[s]=d;var y=(u,s,d)=>Oe(u,typeof s!="symbol"?s+"":s,d);const Z="sheets-note-ui.config",B={};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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},U=(i,e)=>(t,n)=>e(t,n,i);u.SheetsCellContentController=class extends s.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(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const{row:r,col:o,unitId:a,subUnitId:c}=t;return this._sheetsNoteModel.getNote(a,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(s.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(P.debounceTime(16)).subscribe(()=>{e()}))}},u.SheetsCellContentController=ie([U(0,s.Inject(I.SheetInterceptorService)),U(1,s.Inject(d.SheetsNoteModel)),U(2,x.IRenderManagerService),U(3,s.IUniverInstanceService)],u.SheetsCellContentController);const L="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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},A=(i,e)=>(t,n)=>e(t,n,i);u.SheetsNotePopupService=class extends s.Disposable{constructor(t,n){super();y(this,"_lastPopup",null);y(this,"_activePopup");y(this,"_activePopup$",new P.BehaviorSubject(null));y(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()}))}showPopup(t,n){var v;const{row:r,col:o,unitId:a,subUnitId:c}=t;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((v=this.activePopup)==null?void 0:v.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:a,subUnitId:c,row:r,col:o},{componentKey:L,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:t},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(l),h.add({dispose:()=>{n==null||n()}}),this._lastPopup=h}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([A(0,C.IZenZoneService),A(1,s.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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},T=(i,e)=>(t,n)=>e(t,n,i);let j=class extends s.Disposable{constructor(e,t,n,r){super();y(this,"_noteMatrix",new s.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:L,direction:"horizontal",extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}_initSheet(e,t){var o;this._noteMatrix.forValue((a,c,l)=>{l.dispose()}),this._noteMatrix=new s.ObjectMatrix;const r=(a,c,l,h,v)=>{const f=this._noteMatrix,_=f.getValue(l,h);if(v!=null&&v.show){if(!_){const m=this._showPopup(a,c,l,h);m&&f.setValue(l,h,m)}}else _&&(_.dispose(),f.realDeleteValue(l,h))};return(o=this._sheetsNoteModel.getSheetNotes(e,t))==null||o.forValue((a,c,l)=>{r(e,t,a,c,l)}),this._sheetsNoteModel.change$.subscribe(a=>{if(!(a.unitId!==e||a.sheetId!==t))switch(a.type){case"ref":{const{unitId:c,sheetId:l,row:h,col:v,newPosition:f,note:_}=a,m=this._noteMatrix;if(!_.show)return;const M=m.getValue(h,v);M&&(M.dispose(),m.realDeleteValue(h,v));const p=this._showPopup(c,l,f.row,f.col);p&&m.setValue(f.row,f.col,p);break}case"update":{const{unitId:c,sheetId:l,row:h,col:v,note:f}=a;r(c,l,h,v,f);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(P.switchMap(e=>{var t;return(t=e==null?void 0:e.activeSheet$)!=null?t:P.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 s.ObjectMatrix}))}};j=ae([T(0,s.Inject(d.SheetsNoteModel)),T(1,s.Inject(s.IUniverInstanceService)),T(2,s.Inject(w.CellPopupManagerService)),T(3,s.Inject(u.SheetsNotePopupService))],j);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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},E=(i,e)=>(t,n)=>e(t,n,i);u.SheetsNotePopupController=class extends s.Disposable{constructor(t,n,r,o,a,c){super();y(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=t,this._sheetsNoteModel=n,this._sheetSelectionService=r,this._editorBridgeService=o,this._renderManagerService=a,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(t,n,r){var m,M,p;const o=(m=t[0])==null?void 0:m.range,a=this._renderManagerService.getRenderById(n),c=(M=a==null?void 0:a.with(w.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:M.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((p=o.rangeType)!=null?p:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((l.isMerged||l.isMergedMainCell)&&s.Rectangle.equals(l.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const v=l.actualRow,f=l.actualColumn,_=this._sheetsNoteModel.getNote(n,r,v,f);_!=null&&_.show||(_?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,row:v,col:f}):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:a}=t.location,c=this._sheetsNoteModel.getNote(n,r,o,a);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,row:o,col:a,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=ce([E(0,s.Inject(u.SheetsNotePopupService)),E(1,s.Inject(d.SheetsNoteModel)),E(2,s.Inject(I.SheetsSelectionsService)),E(3,w.IEditorBridgeService),E(4,x.IRenderManagerService),E(5,s.Inject(w.HoverManagerService))],u.SheetsNotePopupController);var S=function(){return S=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},S.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=g.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,a=le(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=g.useRef("_".concat(de()));return W(t,"".concat(n),{defIds:t.defIds,idSuffix:l.current},S({ref:e,className:c},a),o)});function W(i,e,t,n,r){return g.createElement(i.tag,S(S({key:e},pe(i,t,r)),n),(he(i,t).children||[]).map(function(o,a){return W(o,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function pe(i,e,t){var n=S({},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 a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(n[a]=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 a=o[0],c=o[1];typeof c=="string"&&(n[a]=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)?S(S({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?S(S({},r),{attrs:S(S({},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"}}]},F=g.forwardRef(function(i,e){return g.createElement(H,Object.assign({},i,{id:"add-note-icon",ref:e,icon:ve}))});F.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"}}]},q=g.forwardRef(function(i,e){return g.createElement(H,Object.assign({},i,{id:"delete-note-icon",ref:e,icon:fe}))});q.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"}}]},z=g.forwardRef(function(i,e){return g.createElement(H,Object.assign({},i,{id:"hide-note-icon",ref:e,icon:Ce}))});z.displayName="HideNoteIcon";const D={id:"sheet.operation.add-note-popup",type:s.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(I.SheetsSelectionsService),n=i.get(u.SheetsNotePopupService),o=i.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const a=o.getActiveSheet(),c=t.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:l}=c;return n.showPopup({unitId:o.getUnitId(),subUnitId:a.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:e==null?void 0:e.trigger}),!0}},G=i=>{var M;const e=C.useDependency(d.SheetsNoteModel),t=C.useDependency(s.LocaleService),n=C.useDependency(x.IRenderManagerService),r=C.useConfigValue(Z),o=(M=i.popup.extraProps)==null?void 0:M.location;if(!o)return console.error("Popup extraProps or location is undefined."),null;const a=n.getRenderById(o.unitId),[c,l]=g.useState(()=>{var b,O;const p={width:((b=r==null?void 0:r.defaultNoteSize)==null?void 0:b.width)||216,height:((O=r==null?void 0:r.defaultNoteSize)==null?void 0:O.height)||92,note:""};return e.getNote(o.unitId,o.subUnitId,o.row,o.col)||p}),h=g.useRef(null),v=C.useDependency(s.ICommandService),f=g.useMemo(()=>o?e.getCellNoteChange$(o.unitId,o.subUnitId,o.row,o.col):P.of(null),[o]),_=C.useDebounceFn(p=>{o&&(p.note?v.executeCommand(d.SheetUpdateNoteCommand.id,{unitId:o.unitId,sheetId:o.subUnitId,row:o.row,col:o.col,note:p}):v.executeCommand(d.SheetDeleteNoteCommand.id,{unitId:o.unitId,sheetId:o.subUnitId,row:o.row,col:o.col}))});g.useEffect(()=>{var p;o&&(e.getNote(o.unitId,o.subUnitId,o.row,o.col)||(p=h.current)==null||p.focus())},[o,e]),g.useEffect(()=>{const p=f.subscribe(()=>{if(!o)return;const N=e.getNote(o.unitId,o.subUnitId,o.row,o.col);N&&l(N)});return()=>p.unsubscribe()},[f]),g.useEffect(()=>{const p=h.current;if(!p)return;const N=new ResizeObserver(b=>{const O=b[0];if(!O)return;const{width:J,height:Q}=O.contentRect;if(J===0&&Q===0)return;const X={...c,width:J,height:Q};l(X),_(X)});return N.observe(p),()=>{N.unobserve(p),N.disconnect()}},[c.note]);const m=p=>{const N=p.target.value,b={...c,note:N};l(b),_(b)};return te.jsx("textarea",{onWheel:p=>{document.activeElement!==h.current&&a.engine.getCanvasElement().dispatchEvent(new WheelEvent(p.type,p.nativeEvent))},ref:h,"data-u-comp":"note-textarea",className:R.clsx("univer-resize-both univer-ml-px univer-rounded-md univer-bg-white univer-p-2 univer-text-gray-900 univer-shadow focus:univer-outline-none dark:!univer-bg-gray-800 dark:!univer-text-white",R.borderClassName,R.scrollbarClassName),style:{width:c.width,height:c.height},value:c.note,placeholder:t.t("note.placeholder"),onChange:m})};function V(i){const e=i.get(I.SheetsSelectionsService),t=i.get(s.IUniverInstanceService);return e.selectionMoveEnd$.pipe(P.map(()=>{const n=e.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const r=I.getSheetCommandTarget(t);if(!r)return!1;const{actualColumn:o,actualRow:a}=n.primary;return!!i.get(d.SheetsNoteModel).getNote(r.unitId,r.subUnitId,a,o)}))}function ge(i){return{id:D.id,type:C.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:P.combineLatest([C.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),V(i)]).pipe(P.map(([e,t])=>e||t)),disabled$:w.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission]}),commandId:D.id}}function _e(i){return{id:d.SheetDeleteNoteCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:V(i).pipe(P.map(e=>!e)),disabled$:w.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission]})}}function Se(i){return{id:d.SheetToggleNotePopupCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:V(i).pipe(P.map(e=>!e))}}const me={[C.ContextMenuPosition.MAIN_AREA]:{[C.ContextMenuGroup.OTHERS]:{order:0,[D.id]:{order:0,menuItemFactory:ge},[d.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:_e},[d.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};var Ie=Object.getOwnPropertyDescriptor,Pe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ie(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},k=(i,e)=>(t,n)=>e(t,n,i);let $=class extends s.Disposable{constructor(i,e,t){super(),this._componentManager=i,this._menuManagerService=e,this._commandService=t,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[L,G],["AddNoteIcon",F],["DeleteNoteIcon",q],["HideNoteIcon",z]].forEach(([i,e])=>{this.disposeWithMe(this._componentManager.register(i,e))})}_initMenu(){this._menuManagerService.mergeMenu(me)}_initCommands(){this._commandService.registerCommand(D)}};$=Pe([k(0,s.Inject(C.ComponentManager)),k(1,s.Inject(C.IMenuManagerService)),k(2,s.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,be=(i,e,t,n)=>{for(var r=n>1?void 0:n?Me(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},K=(i,e)=>(t,n)=>e(t,n,i),Y=(i,e,t)=>we(i,typeof e!="symbol"?e+"":e,t);const ye="SHEET_NOTE_UI_PLUGIN";u.UniverSheetsNoteUIPlugin=class extends s.Plugin{constructor(e=B,t,n){super(),this._config=e,this._injector=t,this._configService=n;const{menu:r,...o}=s.merge({},B,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Z,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[$],[j]].forEach(e=>{this._injector.add(e)})}onReady(){s.touchDependencies(this._injector,[[$],[u.SheetsCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[u.SheetsNotePopupController],[j]])}},Y(u.UniverSheetsNoteUIPlugin,"pluginName",ye),Y(u.UniverSheetsNoteUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=be([s.DependentOn(d.UniverSheetsNotePlugin),K(1,s.Inject(s.Injector)),K(2,s.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=G,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
10
+ (function(u,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(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,s,M,I,_,P,b,ee,f,te,R,C){"use strict";var Ee=Object.defineProperty;var Oe=(u,s,M)=>s in u?Ee(u,s,{enumerable:!0,configurable:!0,writable:!0,value:M}):u[s]=M;var E=(u,s,M)=>Oe(u,typeof s!="symbol"?s+"":s,M);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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},T=(i,e)=>(t,n)=>e(t,n,i);u.SheetsCellContentController=class extends s.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(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const{row:r,col:o,unitId:a,subUnitId:c}=t;return this._sheetsNoteModel.getNote(a,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(s.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(P.debounceTime(16)).subscribe(()=>{e()}))}},u.SheetsCellContentController=ie([T(0,s.Inject(I.SheetInterceptorService)),T(1,s.Inject(_.SheetsNoteModel)),T(2,M.IRenderManagerService),T(3,s.IUniverInstanceService)],u.SheetsCellContentController);const L="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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},Z=(i,e)=>(t,n)=>e(t,n,i);u.SheetsNotePopupService=class extends s.Disposable{constructor(t,n){super();E(this,"_lastPopup",null);E(this,"_activePopup");E(this,"_activePopup$",new P.BehaviorSubject(null));E(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()}))}showPopup(t,n){var d;const{row:r,col:o,unitId:a,subUnitId:c}=t;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((d=this.activePopup)==null?void 0:d.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:a,subUnitId:c,row:r,col:o},{componentKey:L,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:t},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(l),h.add({dispose:()=>{n==null||n()}}),this._lastPopup=h}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([Z(0,f.IZenZoneService),Z(1,s.Inject(b.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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},O=(i,e)=>(t,n)=>e(t,n,i);u.SheetsNotePopupController=class extends s.Disposable{constructor(t,n,r,o,a,c){super();E(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=t,this._sheetsNoteModel=n,this._sheetSelectionService=r,this._editorBridgeService=o,this._renderManagerService=a,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(t,n,r){var m,w,p;const o=(m=t[0])==null?void 0:m.range,a=this._renderManagerService.getRenderById(n),c=(w=a==null?void 0:a.with(b.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:w.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((p=o.rangeType)!=null?p:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((l.isMerged||l.isMergedMainCell)&&s.Rectangle.equals(l.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const d=l.actualRow,v=l.actualColumn,g=this._sheetsNoteModel.getNote(n,r,d,v);g!=null&&g.show||(g?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,row:d,col:v}):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:a}=t.location,c=this._sheetsNoteModel.getNote(n,r,o,a);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,row:o,col:a,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=ae([O(0,s.Inject(u.SheetsNotePopupService)),O(1,s.Inject(_.SheetsNoteModel)),O(2,s.Inject(I.SheetsSelectionsService)),O(3,b.IEditorBridgeService),O(4,M.IRenderManagerService),O(5,s.Inject(b.HoverManagerService))],u.SheetsNotePopupController);const B="sheets-note-ui.config",A={};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,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},j=(i,e)=>(t,n)=>e(t,n,i);let H=class extends s.Disposable{constructor(e,t,n,r){super();E(this,"_noteMatrix",new s.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:L,direction:"horizontal",extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}_initSheet(e,t){var o;this._noteMatrix.forValue((a,c,l)=>{l.dispose()}),this._noteMatrix=new s.ObjectMatrix;const r=(a,c,l,h,d)=>{const v=this._noteMatrix,g=v.getValue(l,h);if(d!=null&&d.show){if(!g){const m=this._showPopup(a,c,l,h);m&&v.setValue(l,h,m)}}else g&&(g.dispose(),v.realDeleteValue(l,h))};return(o=this._sheetsNoteModel.getSheetNotes(e,t))==null||o.forValue((a,c,l)=>{r(e,t,a,c,l)}),this._sheetsNoteModel.change$.subscribe(a=>{if(!(a.unitId!==e||a.sheetId!==t))switch(a.type){case"ref":{const{unitId:c,sheetId:l,row:h,col:d,newPosition:v,note:g}=a,m=this._noteMatrix;if(!g.show)return;const w=m.getValue(h,d);w&&(w.dispose(),m.realDeleteValue(h,d));const p=this._showPopup(c,l,v.row,v.col);p&&m.setValue(v.row,v.col,p);break}case"update":{const{unitId:c,sheetId:l,row:h,col:d,note:v}=a;r(c,l,h,d,v);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(P.switchMap(e=>{var t;return(t=e==null?void 0:e.activeSheet$)!=null?t:P.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 s.ObjectMatrix}))}};H=ce([j(0,s.Inject(_.SheetsNoteModel)),j(1,s.Inject(s.IUniverInstanceService)),j(2,s.Inject(b.CellPopupManagerService)),j(3,s.Inject(u.SheetsNotePopupService))],H);var S=function(){return S=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},S.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},D=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,a=le(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=C.useRef("_".concat(de()));return W(t,"".concat(n),{defIds:t.defIds,idSuffix:l.current},S({ref:e,className:c},a),o)});function W(i,e,t,n,r){return C.createElement(i.tag,S(S({key:e},pe(i,t,r)),n),(he(i,t).children||[]).map(function(o,a){return W(o,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function pe(i,e,t){var n=S({},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 a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(n[a]=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 a=o[0],c=o[1];typeof c=="string"&&(n[a]=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)?S(S({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function de(){return Math.random().toString(36).substring(2,8)}D.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"}}]},F=C.forwardRef(function(i,e){return C.createElement(D,Object.assign({},i,{id:"add-note-icon",ref:e,icon:ve}))});F.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"}}]},q=C.forwardRef(function(i,e){return C.createElement(D,Object.assign({},i,{id:"delete-note-icon",ref:e,icon:fe}))});q.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"}}]},z=C.forwardRef(function(i,e){return C.createElement(D,Object.assign({},i,{id:"hide-note-icon",ref:e,icon:Ce}))});z.displayName="HideNoteIcon";const $={id:"sheet.operation.add-note-popup",type:s.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(I.SheetsSelectionsService),n=i.get(u.SheetsNotePopupService),o=i.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const a=o.getActiveSheet(),c=t.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:l}=c;return n.showPopup({unitId:o.getUnitId(),subUnitId:a.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:e==null?void 0:e.trigger}),!0}},G=i=>{var w;const e=f.useDependency(_.SheetsNoteModel),t=f.useDependency(s.LocaleService),n=f.useDependency(M.IRenderManagerService),r=f.useConfigValue(B),o=(w=i.popup.extraProps)==null?void 0:w.location;if(!o)return console.error("Popup extraProps or location is undefined."),null;const a=n.getRenderById(o.unitId),[c,l]=C.useState(()=>{var y,U;const p={width:((y=r==null?void 0:r.defaultNoteSize)==null?void 0:y.width)||216,height:((U=r==null?void 0:r.defaultNoteSize)==null?void 0:U.height)||92,note:""};return e.getNote(o.unitId,o.subUnitId,o.row,o.col)||p}),h=C.useRef(null),d=f.useDependency(s.ICommandService),v=C.useMemo(()=>o?e.getCellNoteChange$(o.unitId,o.subUnitId,o.row,o.col):P.of(null),[o]),g=f.useDebounceFn(p=>{o&&(p.note?d.executeCommand(_.SheetUpdateNoteCommand.id,{unitId:o.unitId,sheetId:o.subUnitId,row:o.row,col:o.col,note:p}):d.executeCommand(_.SheetDeleteNoteCommand.id,{unitId:o.unitId,sheetId:o.subUnitId,row:o.row,col:o.col}))});C.useEffect(()=>{var p;o&&(e.getNote(o.unitId,o.subUnitId,o.row,o.col)||(p=h.current)==null||p.focus())},[o,e]),C.useEffect(()=>{const p=v.subscribe(()=>{if(!o)return;const N=e.getNote(o.unitId,o.subUnitId,o.row,o.col);N&&l(N)});return()=>p.unsubscribe()},[v]),C.useEffect(()=>{const p=h.current;if(!p)return;const N=new ResizeObserver(y=>{const U=y[0];if(!U)return;const{width:J,height:Q}=U.contentRect;if(J===0&&Q===0)return;const X={...c,width:J,height:Q};l(X),g(X)});return N.observe(p),()=>{N.unobserve(p),N.disconnect()}},[c.note]);const m=p=>{const N=p.target.value,y={...c,note:N};l(y),g(y)};return te.jsx("textarea",{onWheel:p=>{document.activeElement!==h.current&&a.engine.getCanvasElement().dispatchEvent(new WheelEvent(p.type,p.nativeEvent))},ref:h,"data-u-comp":"note-textarea",className:R.clsx("univer-resize-both univer-ml-px univer-rounded-md univer-bg-white univer-p-2 univer-text-gray-900 univer-shadow focus:univer-outline-none dark:!univer-bg-gray-800 dark:!univer-text-white",R.borderClassName,R.scrollbarClassName),style:{width:c.width,height:c.height},value:c.note,placeholder:t.t("note.placeholder"),onChange:m})};function V(i){const e=i.get(I.SheetsSelectionsService),t=i.get(s.IUniverInstanceService);return e.selectionMoveEnd$.pipe(P.map(()=>{const n=e.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const r=I.getSheetCommandTarget(t);if(!r)return!1;const{actualColumn:o,actualRow:a}=n.primary;return!!i.get(_.SheetsNoteModel).getNote(r.unitId,r.subUnitId,a,o)}))}function ge(i){return{id:$.id,type:f.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:P.combineLatest([f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),V(i)]).pipe(P.map(([e,t])=>e||t)),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission]}),commandId:$.id}}function _e(i){return{id:_.SheetDeleteNoteCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:V(i).pipe(P.map(e=>!e)),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission]})}}function Se(i){return{id:_.SheetToggleNotePopupCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:V(i).pipe(P.map(e=>!e))}}const me={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:0,[$.id]:{order:0,menuItemFactory:ge},[_.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:_e},[_.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};var Ie=Object.getOwnPropertyDescriptor,Pe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ie(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},k=(i,e)=>(t,n)=>e(t,n,i);let x=class extends s.Disposable{constructor(i,e,t){super(),this._componentManager=i,this._menuManagerService=e,this._commandService=t,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[L,G],["AddNoteIcon",F],["DeleteNoteIcon",q],["HideNoteIcon",z]].forEach(([i,e])=>{this.disposeWithMe(this._componentManager.register(i,e))})}_initMenu(){this._menuManagerService.mergeMenu(me)}_initCommands(){this._commandService.registerCommand($)}};x=Pe([k(0,s.Inject(f.ComponentManager)),k(1,s.Inject(f.IMenuManagerService)),k(2,s.ICommandService)],x);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,be=(i,e,t,n)=>{for(var r=n>1?void 0:n?Me(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=a(r)||r);return r},K=(i,e)=>(t,n)=>e(t,n,i),Y=(i,e,t)=>we(i,typeof e!="symbol"?e+"":e,t);const ye="SHEET_NOTE_UI_PLUGIN";u.UniverSheetsNoteUIPlugin=class extends s.Plugin{constructor(e=A,t,n){super(),this._config=e,this._injector=t,this._configService=n;const{menu:r,...o}=s.merge({},A,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(B,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[x],[H]].forEach(e=>{this._injector.add(e)})}onReady(){s.touchDependencies(this._injector,[[x],[u.SheetsCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[u.SheetsNotePopupController],[H]])}},Y(u.UniverSheetsNoteUIPlugin,"pluginName",ye),Y(u.UniverSheetsNoteUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=be([s.DependentOn(_.UniverSheetsNotePlugin),K(1,s.Inject(s.Injector)),K(2,s.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=G,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
11
11
 
12
12
 
13
13
  // index
@@ -0,0 +1,6 @@
1
+ // @univerjs/sheets-note-ui/locale/ko-KR
2
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsNoteUiKoKR=t())})(this,function(){"use strict";return{rightClick:{addNote:"노트 추가",deleteNote:"노트 삭제",toggleNote:"노트 표시/숨기기"},note:{placeholder:"여기에 입력"}}});
3
+
4
+
5
+ // locale/ko-KR
6
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/sheets-note-ui/locale/ko-KR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/sheets-note-ui/locale/ko-KR"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsNoteKoKR=i(e.UniverCore,e.UniverSheetsNoteUiKoKR))})(this,function(e,i){"use strict";return e.merge({},i)});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-note",
3
- "version": "0.8.2",
3
+ "version": "0.8.3-nightly.202506271607",
4
4
  "private": false,
5
5
  "description": "",
6
- "author": "DreamNum <developer@univer.ai>",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
9
9
  "type": "opencollective",
@@ -18,7 +18,8 @@
18
18
  "url": "https://github.com/dream-num/univer-presets/issues"
19
19
  },
20
20
  "keywords": [
21
- "univer"
21
+ "univer",
22
+ "univer-preset"
22
23
  ],
23
24
  "sideEffects": [
24
25
  "*.css"
@@ -57,16 +58,16 @@
57
58
  "rxjs": ">=7.0.0"
58
59
  },
59
60
  "dependencies": {
60
- "@univerjs/sheets-note": "0.8.2",
61
- "@univerjs/sheets-note-ui": "0.8.2"
61
+ "@univerjs/sheets-note": "0.8.3-nightly.202506271607",
62
+ "@univerjs/sheets-note-ui": "0.8.3-nightly.202506271607"
62
63
  },
63
64
  "devDependencies": {
64
- "@univerjs/core": "0.8.2",
65
+ "@univerjs/core": "0.8.3-nightly.202506271607",
65
66
  "react": "18.3.1",
66
67
  "react-dom": "18.3.1",
67
68
  "rxjs": "7.8.2",
68
69
  "typescript": "^5.8.3",
69
- "@univerjs-infra/shared": "0.8.2"
70
+ "@univerjs-infra/shared": "0.8.3"
70
71
  },
71
72
  "scripts": {
72
73
  "prebuild:preset": "tsx prepare.ts",