@univerjs/preset-sheets-note 0.7.0-nightly.202505121607 → 0.7.0-nightly.202505151607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/sheets-note"),r=require("@univerjs/sheets-note-ui"),o=require("@univerjs/sheets-note/facade");function n(){return{plugins:[t.UniverSheetsNotePlugin,r.UniverSheetsNoteUIPlugin].filter(e=>!!e)}}exports.UniverSheetsNotePreset=n;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});Object.keys(o).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/sheets-note"),r=require("@univerjs/sheets-note-ui");require("@univerjs/sheets-note/facade");function o(){return{plugins:[t.UniverSheetsNotePlugin,r.UniverSheetsNoteUIPlugin].filter(e=>!!e)}}exports.UniverSheetsNotePreset=o;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
package/lib/es/index.js CHANGED
@@ -2,8 +2,8 @@ import { UniverSheetsNotePlugin as r } from "@univerjs/sheets-note";
2
2
  export * from "@univerjs/sheets-note";
3
3
  import { UniverSheetsNoteUIPlugin as t } from "@univerjs/sheets-note-ui";
4
4
  export * from "@univerjs/sheets-note-ui";
5
- export * from "@univerjs/sheets-note/facade";
6
- function n() {
5
+ import "@univerjs/sheets-note/facade";
6
+ function m() {
7
7
  return {
8
8
  plugins: [
9
9
  r,
@@ -12,5 +12,5 @@ function n() {
12
12
  };
13
13
  }
14
14
  export {
15
- n as UniverSheetsNotePreset
15
+ m as UniverSheetsNotePreset
16
16
  };
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-ml-px{margin-left:1px}.univer-rounded-md{border-radius:6px}.univer-bg-white{background-color:var(--univer-white)}.univer-p-2{padding:8px}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-shadow{--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.focus\:univer-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.dark\:univer-bg-gray-800:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)}.dark\:univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)}
1
+ .univer-ml-px{margin-left:1px}.univer-rounded-md{border-radius:6px}.univer-bg-white{background-color:var(--univer-white)}.univer-p-2{padding:8px}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-shadow{--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.focus\:univer-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.dark\:\!univer-bg-gray-800:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}
package/lib/index.js CHANGED
@@ -2,8 +2,8 @@ import { UniverSheetsNotePlugin as r } from "@univerjs/sheets-note";
2
2
  export * from "@univerjs/sheets-note";
3
3
  import { UniverSheetsNoteUIPlugin as t } from "@univerjs/sheets-note-ui";
4
4
  export * from "@univerjs/sheets-note-ui";
5
- export * from "@univerjs/sheets-note/facade";
6
- function n() {
5
+ import "@univerjs/sheets-note/facade";
6
+ function m() {
7
7
  return {
8
8
  plugins: [
9
9
  r,
@@ -12,5 +12,5 @@ function n() {
12
12
  };
13
13
  }
14
14
  export {
15
- n as UniverSheetsNotePreset
15
+ m as UniverSheetsNotePreset
16
16
  };
@@ -1,4 +1,5 @@
1
1
  import { IPreset } from './types';
2
+ import '@univerjs/sheets-note/facade';
2
3
  import '@univerjs/sheets-note-ui/lib/index.css';
3
- export * from '@univerjs/sheets-note/facade';
4
+ export type * from '@univerjs/sheets-note/facade';
4
5
  export declare function UniverSheetsNotePreset(): IPreset;
package/lib/umd/index.js CHANGED
@@ -1,14 +1,14 @@
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,_){"use strict";var H=Object.defineProperty;var z=(u,a,l)=>a in u?H(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var p=(u,a,l)=>z(u,typeof a!="symbol"?a+"":a,l);class m extends a.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new _.Subject);p(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let n=this._noteMatrix.get(e);n||(n=new Map,this._noteMatrix.set(e,n));let s=n.get(t);return s||(s=new a.ObjectMatrix,n.set(t,s)),s}getSheetShowNotes$(e,t){return this._change$.pipe(_.filter(({unitId:n,sheetId:s})=>n===e&&s===t),_.map(()=>{const n=this._ensureNoteMatrix(e,t),s=[];return n.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:e,subUnitId:t},note:c})}),s}))}getCellNoteChange$(e,t,n,s){return this._change$.pipe(_.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===e&&h===t&&c===n&&d===s),_.map(({note:i})=>i))}updateNote(e,t,n,s,i,h){const c=this._ensureNoteMatrix(e,t),d=c.getValue(n,s);c.setValue(n,s,i),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(e,t,n,s,i){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);h.realDeleteValue(n,s),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(e,t,n,s,i){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(n,s,d),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(e,t,n,s,i,h,c){const d=this._ensureNoteMatrix(e,t),g=d.getValue(n,s);g&&(d.realDeleteValue(n,s),d.setValue(i,h,g),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"ref",newPosition:{row:i,col:h},note:g,silent:c}))}getNote(e,t,n,s){return this._ensureNoteMatrix(e,t).getValue(n,s)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const n=this._noteMatrix.get(e);if(n)return n.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,note:i,silent:h}=o;return r.get(m).updateNote(e,t,n,s,i,h),!0}},v={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:i}=o;return r.get(m).removeNote(e,t,n,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:i}=o;return r.get(m).toggleNotePopup(e,t,n,s,i),!0}},S={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,newPosition:i,silent:h}=o;return r.get(m).updateNotePosition(e,t,n,s,i.row,i.col,h),!0}};var b=Object.getOwnPropertyDescriptor,$=(r,o,e,t)=>{for(var n=t>1?void 0:t?b(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},f=(r,o)=>(e,t)=>o(e,t,r);let M=class extends a.Disposable{constructor(o,e,t,n){super();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(this,"_handleRangeChange",(o,e,t,n,s,i,h)=>i?{redos:[{id:S.id,params:{unitId:o,sheetId:e,row:n,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:S.id,params:{unitId:o,sheetId:e,row:i.startRow,col:i.startColumn,newPosition:{row:n,col:s},note:t,silent:h}}]}:{redos:[{id:v.id,params:{unitId:o,sheetId:e,row:n,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:e,row:n,col:s,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=n,this._initData(),this._initRefRange()}_getIdWithUnitId(o,e,t,n){return`${o}-${e}-${t}-${n}`}_register(o,e,t,n,s){const i={startColumn:s,endColumn:s,startRow:n,endRow:n};this._disposableMap.set(this._getIdWithUnitId(o,e,n,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,e,t,n,s,d,!1)},o,e))}_watch(o,e,t,n,s){const i={startColumn:s,endColumn:s,startRow:n,endRow:n};this._watcherMap.set(this._getIdWithUnitId(o,e,n,s),this._refRangeService.watchRange(o,e,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,e,t,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,e,t,n){var i;const s=this._getIdWithUnitId(o,e,t,n);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,e,t,n){var i;const s=this._getIdWithUnitId(o,e,t,n);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[e,t]of o)for(const[n,s]of t)s.forValue((i,h,c)=>(c&&(this._register(e,n,c,i,h),this._watch(e,n,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:e,sheetId:t,row:n,col:s,note:i}=o,h=this._getIdWithUnitId(e,t,n,s);i?this._disposableMap.has(h)||(this._register(e,t,i,n,s),this._watch(e,t,i,n,s)):(this._unregister(e,t,n,s),this._unwatch(e,t,n,s));break}case"ref":{const{unitId:e,sheetId:t,row:n,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(e,t,n,s),c||(this._unwatch(e,t,n,s),this._watch(e,t,h,i.row,i.col)),this._register(e,t,h,i.row,i.col);break}}}))}};M=$([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(m)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var D=Object.getOwnPropertyDescriptor,j=(r,o,e,t)=>{for(var n=t>1?void 0:t?D(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},w=(r,o)=>(e,t)=>o(e,t,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,e,t){super(),this._resourceManagerService=o,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const o=t=>{const n=this._sheetsNoteModel.getUnitNotes(t);if(!n)return"";const s={};return n.forEach((i,h)=>{const c={};i.forValue((d,g,q)=>{c[d]||(c[d]={}),c[d][g]=q}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:T,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,n)=>{Object.entries(n).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,g])=>{this._sheetsNoteModel.updateNote(t,s,Number(h),Number(d),g)})})})}}))}},u.SheetsNoteResourceController=j([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(m))],u.SheetsNoteResourceController);const y={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)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(v.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},P={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)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:t.unitId,sheetId:t.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)};var x=Object.getOwnPropertyDescriptor,E=(r,o,e,t)=>{for(var n=t>1?void 0:t?x(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},V=(r,o)=>(e,t)=>o(e,t,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[S,I,N,v,y,P,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=E([V(0,a.ICommandService)],C);var A=Object.defineProperty,W=Object.getOwnPropertyDescriptor,L=(r,o,e)=>o in r?A(r,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[o]=e,J=(r,o,e,t)=>{for(var n=t>1?void 0:t?W(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},U=(r,o)=>(e,t)=>o(e,t,r),O=(r,o,e)=>L(r,typeof o!="symbol"?o+"":o,e);const T="SHEET_NOTE_PLUGIN";u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o,e){super(),this._configService=o,this._injector=e}onStarting(){[[m],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[m],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},O(u.UniverSheetsNotePlugin,"pluginName",T),O(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=J([a.DependentOn(l.UniverSheetsPlugin),U(0,a.IConfigService),U(1,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=v,u.SheetDeleteNoteCommand=y,u.SheetToggleNotePopupCommand=P,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=m,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=S,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);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"})});
3
3
 
4
4
 
5
5
  // @univerjs/sheets-note/facade
6
- (function(a,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],m):(a=typeof globalThis<"u"?globalThis:a||self,m(a.UniverSheetsNoteFacade={},a.UniverCoreFacade,a.UniverSheetsNote,a.UniverSheetsFacade,a.UniverCore))})(this,function(a,m,h,f,g){"use strict";class w{get SheetNoteAdd(){return"SheetNoteAdd"}get SheetNoteDelete(){return"SheetNoteDelete"}get SheetNoteUpdate(){return"SheetNoteUpdate"}get SheetNoteShow(){return"SheetNoteShow"}get SheetNoteHide(){return"SheetNoteHide"}get BeforeSheetNoteAdd(){return"BeforeSheetNoteAdd"}get BeforeSheetNoteDelete(){return"BeforeSheetNoteDelete"}get BeforeSheetNoteUpdate(){return"BeforeSheetNoteUpdate"}get BeforeSheetNoteShow(){return"BeforeSheetNoteShow"}get BeforeSheetNoteHide(){return"BeforeSheetNoteHide"}}m.FEventName.extend(w);class E extends f.FRange{createOrUpdateNote(c){return this._commandService.syncExecuteCommand(h.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:c}),this}deleteNote(){return this._injector.get(h.SheetsNoteModel),this._commandService.syncExecuteCommand(h.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(h.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}f.FRange.extend(E);class I extends m.FUniver{_initialize(c){this.registerEventHandler(this.Event.SheetNoteAdd,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:l}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:S,worksheet:l,row:o,col:i,note:r})}})),this.registerEventHandler(this.Event.SheetNoteDelete,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:l}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:S,worksheet:l,row:o,col:i,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteUpdate,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:l}=n;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:l,row:o,col:i,note:r,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteShow,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.SheetNoteHide,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params;if(d.getNote(t,o,i,r))return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:l,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:l,worksheet:v,row:i,col:r,note:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetDeleteNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!s)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:l}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:S,worksheet:l,row:i,col:r,oldNote:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params,n=d.getNote(t,o,i,r);if(!n)return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:l,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:l,worksheet:v,row:i,col:r,note:s,oldNote:n}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(s!=null&&s.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:l}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:S,worksheet:l,row:i,col:r}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!(s!=null&&s.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:l}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:S,worksheet:l,row:i,col:r}))throw new g.CanceledError}}))}}m.FUniver.extend(I);class k extends f.FWorksheet{getNotes(){const u=this._injector.get(h.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),e=[];return u==null||u.forValue((d,t,o)=>{e.push({...o,row:d,col:t})}),e}}f.FWorksheet.extend(k),a.FSheetNoteEvent=w,a.FSheetsNoteRange=E,a.FSheetsNoteWorksheet=k,a.FUniverSheetNoteMixin=I,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
6
+ (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/sheets-note","@univerjs/sheets/facade","@univerjs/core"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.UniverSheetsNoteFacade={},l.UniverCoreFacade,l.UniverSheetsNote,l.UniverSheetsFacade,l.UniverCore))})(this,function(l,m,h,f,g){"use strict";class w{get SheetNoteAdd(){return"SheetNoteAdd"}get SheetNoteDelete(){return"SheetNoteDelete"}get SheetNoteUpdate(){return"SheetNoteUpdate"}get SheetNoteShow(){return"SheetNoteShow"}get SheetNoteHide(){return"SheetNoteHide"}get BeforeSheetNoteAdd(){return"BeforeSheetNoteAdd"}get BeforeSheetNoteDelete(){return"BeforeSheetNoteDelete"}get BeforeSheetNoteUpdate(){return"BeforeSheetNoteUpdate"}get BeforeSheetNoteShow(){return"BeforeSheetNoteShow"}get BeforeSheetNoteHide(){return"BeforeSheetNoteHide"}}m.FEventName.extend(w);class E extends f.FRange{createOrUpdateNote(c){return this._commandService.syncExecuteCommand(h.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:c}),this}deleteNote(){return this._commandService.syncExecuteCommand(h.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(h.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),this.getRow(),this.getColumn())}}f.FRange.extend(E);class I extends m.FUniver{_initialize(c){this.registerEventHandler(this.Event.SheetNoteAdd,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&!e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteAdd,{workbook:S,worksheet:a,row:o,col:i,note:r})}})),this.registerEventHandler(this.Event.SheetNoteDelete,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&!e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteDelete,{workbook:S,worksheet:a,row:o,col:i,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteUpdate,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note){const{unitId:d,sheetId:t,row:o,col:i,note:r,oldNote:s}=e,n=this.getSheetTarget(d,t);if(!n)return;const{workbook:S,worksheet:a}=n;this.fireEvent(this.Event.SheetNoteUpdate,{workbook:S,worksheet:a,row:o,col:i,note:r,oldNote:s})}})),this.registerEventHandler(this.Event.SheetNoteShow,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&!e.oldNote.show&&e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteShow,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.SheetNoteHide,()=>c.get(h.SheetsNoteModel).change$.subscribe(e=>{if(e.type==="update"&&e.oldNote&&e.note&&e.oldNote.show&&!e.note.show){const{unitId:d,sheetId:t,row:o,col:i}=e,r=this.getSheetTarget(d,t);if(!r)return;const{workbook:s,worksheet:n}=r;this.fireEvent(this.Event.SheetNoteHide,{workbook:s,worksheet:n,row:o,col:i})}})),this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params;if(d.getNote(t,o,i,r))return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteAdd,{workbook:a,worksheet:v,row:i,col:r,note:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetDeleteNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!s)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteDelete,{workbook:S,worksheet:a,row:i,col:r,oldNote:s}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetUpdateNoteCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r,note:s}=e.params,n=d.getNote(t,o,i,r);if(!n)return;const S=this.getSheetTarget(t,o);if(!S)return;const{workbook:a,worksheet:v}=S;if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,{workbook:a,worksheet:v,row:i,col:r,note:s,oldNote:n}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(s!=null&&s.show)return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteShow,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}})),this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>c.get(g.ICommandService).beforeCommandExecuted(e=>{if(e.id===h.SheetToggleNotePopupCommand.id){const d=c.get(h.SheetsNoteModel),{unitId:t,sheetId:o,row:i,col:r}=e.params,s=d.getNote(t,o,i,r);if(!(s!=null&&s.show))return;const n=this.getSheetTarget(t,o);if(!n)return;const{workbook:S,worksheet:a}=n;if(this.fireEvent(this.Event.BeforeSheetNoteHide,{workbook:S,worksheet:a,row:i,col:r}))throw new g.CanceledError}}))}}m.FUniver.extend(I);class k extends f.FWorksheet{getNotes(){const u=this._injector.get(h.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId()),e=[];return u==null||u.forValue((d,t,o)=>{e.push({...o,row:d,col:t})}),e}}f.FWorksheet.extend(k),l.FSheetNoteEvent=w,l.FSheetsNoteRange=E,l.FSheetsNoteWorksheet=k,l.FUniverSheetNoteMixin=I,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
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/ui"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),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/ui","@univerjs/sheets","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators","react/jsx-runtime","@univerjs/design","react"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.UniverSheetsNoteUi={},u.UniverCore,u.UniverSheetsNote,u.UniverUi,u.UniverSheets,u.UniverSheetsUi,u.rxjs,u.UniverEngineRender,u.rxjs.operators,u.React,u.UniverDesign,u.React))})(this,function(u,s,h,S,N,M,I,L,X,ee,$,g){"use strict";var we=Object.defineProperty;var ye=(u,s,h)=>s in u?we(u,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):u[s]=h;var b=(u,s,h)=>ye(u,typeof s!="symbol"?s+"":s,h);const D="SHEET_NOTE_COMPONENT";var te=Object.getOwnPropertyDescriptor,ne=(r,t,i,n)=>{for(var e=n>1?void 0:n?te(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},V=(r,t)=>(i,n)=>t(i,n,r);u.SheetsNotePopupService=class extends s.Disposable{constructor(i,n){super();b(this,"_lastPopup",null);b(this,"_activePopup");b(this,"_activePopup$",new I.BehaviorSubject(null));b(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=i,this._cellPopupManagerService=n,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(i=>{i&&this.hidePopup()}))}showPopup(i,n){var v;const{row:e,col:o,unitId:a,subUnitId:c}=i;if(this._activePopup&&e===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((v=this.activePopup)==null?void 0:v.subUnitId)){this._activePopup=i,this._activePopup$.next(i);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=i,this._activePopup$.next(i);const l=this._cellPopupManagerService.showPopup({unitId:a,subUnitId:c,row:e,col:o},{componentKey:D,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:i},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new s.DisposableCollection;d.add(l),d.add({dispose:()=>{n==null||n()}}),this._lastPopup=d}hidePopup(i){this._activePopup&&(!i&&!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=ne([V(0,S.IZenZoneService),V(1,s.Inject(M.CellPopupManagerService))],u.SheetsNotePopupService);const E={id:"sheet.operation.add-note-popup",type:s.CommandType.OPERATION,handler:async(r,t)=>{const i=r.get(N.SheetsSelectionsService),n=r.get(u.SheetsNotePopupService),o=r.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const a=o.getActiveSheet(),c=i.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:t==null?void 0:t.trigger}),!0}};function x(r){const t=r.get(N.SheetsSelectionsService),i=r.get(s.IUniverInstanceService);return t.selectionMoveEnd$.pipe(I.map(()=>{const n=t.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const e=N.getSheetCommandTarget(i);if(!e)return!1;const{actualColumn:o,actualRow:a}=n.primary;return!!r.get(h.SheetsNoteModel).getNote(e.unitId,e.subUnitId,a,o)}))}function ie(r){return{id:E.id,type:S.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:I.combineLatest([S.getMenuHiddenObservable(r,s.UniverInstanceType.UNIVER_SHEET),x(r)]).pipe(I.map(([t,i])=>t||i)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:E.id}}function re(r){return{id:h.SheetDeleteNoteCommand.id,type:S.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteSingle",hidden$:x(r).pipe(I.map(t=>!t)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function oe(r){return{id:h.SheetToggleNotePopupCommand.id,type:S.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:x(r).pipe(I.map(t=>!t))}}const k={[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{order:0,[E.id]:{order:0,menuItemFactory:ie},[h.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:re},[h.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:oe}}}};var se=Object.getOwnPropertyDescriptor,ae=(r,t,i,n)=>{for(var e=n>1?void 0:n?se(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},O=(r,t)=>(i,n)=>t(i,n,r);u.SheetsCellContentController=class extends s.Disposable{constructor(t,i,n,e){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=i,this._renderManagerService=n,this._univerInstanceService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(t,i,n)=>{const{row:e,col:o,unitId:a,subUnitId:c}=i;return this._sheetsNoteModel.getNote(a,c,e,o)?n({...t,markers:{...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}}):n(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const i=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),e=this._renderManagerService.getRenderById(n);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(I.debounceTime(16)).subscribe(()=>{t()}))}},u.SheetsCellContentController=ae([O(0,s.Inject(N.SheetInterceptorService)),O(1,s.Inject(h.SheetsNoteModel)),O(2,L.IRenderManagerService),O(3,s.IUniverInstanceService)],u.SheetsCellContentController);var ue=Object.getOwnPropertyDescriptor,ce=(r,t,i,n)=>{for(var e=n>1?void 0:n?ue(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},U=(r,t)=>(i,n)=>t(i,n,r);let T=class extends s.Disposable{constructor(t,i,n,e){super();b(this,"_noteMatrix",new s.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=i,this._cellPopupManagerService=n,this._sheetsNotePopupService=e,this._initNoteChangeListener()}_showPopup(t,i,n,e){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:i,row:n,col:e},{componentKey:D,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:i,row:n,col:e}},priority:3})}_initSheet(t,i){var o;this._noteMatrix.forValue((a,c,l)=>{l.dispose()}),this._noteMatrix=new s.ObjectMatrix;const e=(a,c,l,d,v)=>{const _=this._noteMatrix,C=_.getValue(l,d);if(v!=null&&v.show){if(!C){const p=this._showPopup(a,c,l,d);p&&_.setValue(l,d,p)}}else C&&(C.dispose(),_.realDeleteValue(l,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,i))==null||o.forValue((a,c,l)=>{e(t,i,a,c,l)}),this._sheetsNoteModel.change$.subscribe(a=>{if(!(a.unitId!==t||a.sheetId!==i))switch(a.type){case"ref":{const{unitId:c,sheetId:l,row:d,col:v,newPosition:_,note:C}=a,p=this._noteMatrix;if(!C.show)return;const f=p.getValue(d,v);f&&(f.dispose(),p.realDeleteValue(d,v));const m=this._showPopup(c,l,_.row,_.col);m&&p.setValue(_.row,_.col,m);break}case"update":{const{unitId:c,sheetId:l,row:d,col:v,note:_}=a;e(c,l,d,v,_);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(I.switchMap(t=>{var i;return(i=t==null?void 0:t.activeSheet$)!=null?i:I.of(null)})).subscribe(t=>{if(t){const i=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{i.unsubscribe()}}else this._noteMatrix.forValue((i,n,e)=>{e.dispose()}),this._noteMatrix=new s.ObjectMatrix}))}};T=ce([U(0,s.Inject(h.SheetsNoteModel)),U(1,s.Inject(s.IUniverInstanceService)),U(2,s.Inject(M.CellPopupManagerService)),U(3,s.Inject(u.SheetsNotePopupService))],T);var le=Object.getOwnPropertyDescriptor,pe=(r,t,i,n)=>{for(var e=n>1?void 0:n?le(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},w=(r,t)=>(i,n)=>t(i,n,r);u.SheetsNotePopupController=class extends s.Disposable{constructor(i,n,e,o,a,c){super();b(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=i,this._sheetsNoteModel=n,this._sheetSelectionService=e,this._editorBridgeService=o,this._renderManagerService=a,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(i,n,e){var p,f,m;const o=(p=i[0])==null?void 0:p.range,a=this._renderManagerService.getRenderById(n),c=(f=a==null?void 0:a.with(M.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:f.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((m=o.rangeType)!=null?m: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,_=l.actualColumn,C=this._sheetsNoteModel.getNote(n,e,v,_);C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:e,row:v,col:_}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(i=>{if(this._isSwitchingSheet)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(i,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(X.debounceTime(100)).subscribe(i=>{if(!(i!=null&&i.location))return;const{unitId:n,subUnitId:e,row:o,col:a}=i.location,c=this._sheetsNoteModel.getNote(n,e,o,a);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:e,row:o,col:a,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=pe([w(0,s.Inject(u.SheetsNotePopupService)),w(1,s.Inject(h.SheetsNoteModel)),w(2,s.Inject(N.SheetsSelectionsService)),w(3,M.IEditorBridgeService),w(4,L.IRenderManagerService),w(5,s.Inject(M.HoverManagerService))],u.SheetsNotePopupController);var P=function(){return P=Object.assign||function(r){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r},P.apply(this,arguments)},he=function(r,t){var i={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(i[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var e=0,n=Object.getOwnPropertySymbols(r);e<n.length;e++)t.indexOf(n[e])<0&&Object.prototype.propertyIsEnumerable.call(r,n[e])&&(i[n[e]]=r[n[e]]);return i},j=g.forwardRef(function(r,t){var i=r.icon,n=r.id,e=r.className,o=r.extend,a=he(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(e||"").trim(),l=g.useRef("_".concat(fe()));return z(i,"".concat(n),{defIds:i.defIds,idSuffix:l.current},P({ref:t,className:c},a),o)});function z(r,t,i,n,e){return g.createElement(r.tag,P(P({key:t},de(r,i,e)),n),(ve(r,i).children||[]).map(function(o,a){return z(o,"".concat(t,"-").concat(r.tag,"-").concat(a),i,void 0,e)}))}function de(r,t,i){var n=P({},r.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+t.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(t.idSuffix,")")))});var e=t.defIds;return!e||e.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.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(t.idSuffix,")")))})),n}function ve(r,t){var i,n=t.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((i=r.children)===null||i===void 0)&&i.length)?P(P({},r),{children:r.children.map(function(e){return typeof e.attrs.id=="string"&&n&&n.indexOf(e.attrs.id)>-1?P(P({},e),{attrs:P(P({},e.attrs),{id:e.attrs.id+t.idSuffix})}):e})}):r}function fe(){return Math.random().toString(36).substring(2,8)}j.displayName="UniverIcon";var ge={tag:"svg",attrs:{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.20363 10.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.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.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.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.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.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745 11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962 11.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"}}]},A=g.forwardRef(function(r,t){return g.createElement(j,Object.assign({},r,{id:"add-note-single",ref:t,icon:ge}))});A.displayName="AddNoteSingle";var _e={tag:"svg",attrs:{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.20363 10.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.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.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.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.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.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618 14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618 8.80985 11.9946 9.10762 11.6968 9.47489 11.6968z"}}]},B=g.forwardRef(function(r,t){return g.createElement(j,Object.assign({},r,{id:"delete-note-single",ref:t,icon:_e}))});B.displayName="DeleteNoteSingle";var Se={tag:"svg",attrs:{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.20363 10.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.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.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.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.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.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477 13.039 11.6659 12.5573 11.4614 12.0394 11.4614 11.5213 11.4614 11.0398 11.6666 10.6878 11.9487 10.3037 12.2565 10.2045 12.5399 10.2044 12.6147 10.2044 12.6893 10.3034 12.9737 10.6878 13.2817 11.0398 13.5636 11.5215 13.768 12.0394 13.768 12.5574 13.768 13.039 13.5635 13.3909 13.2817 13.7751 12.9739 13.8743 12.6897 13.8743 12.6147zM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198 13.6701 14.7627 12.9019 15.0981 12.0394 15.0981 11.1768 15.0981 10.4085 14.7627 9.85577 14.3198 9.33533 13.9027 8.87433 13.2769 8.87433 12.6147 8.8744 11.9526 9.33541 11.3276 9.85577 10.9106 10.4086 10.4676 11.1767 10.1313 12.0394 10.1313 12.9018 10.1313 13.6701 10.4668 14.223 10.9096 14.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"}}]},W=g.forwardRef(function(r,t){return g.createElement(j,Object.assign({},r,{id:"hide-note-single",ref:t,icon:Se}))});W.displayName="HideNoteSingle";const F=r=>{var C;const t=S.useDependency(h.SheetsNoteModel),i=S.useDependency(s.LocaleService),n=S.useConfigValue(G),e=(C=r.popup.extraProps)==null?void 0:C.location;if(!e)return console.error("Popup extraProps or location is undefined."),null;const[o,a]=g.useState(()=>{var m,y;const p={width:((m=n==null?void 0:n.defaultNoteSize)==null?void 0:m.width)||216,height:((y=n==null?void 0:n.defaultNoteSize)==null?void 0:y.height)||92,note:""};return t.getNote(e.unitId,e.subUnitId,e.row,e.col)||p}),c=g.useRef(null),l=S.useDependency(s.ICommandService),d=g.useMemo(()=>e?t.getCellNoteChange$(e.unitId,e.subUnitId,e.row,e.col):I.of(null),[e]),v=S.useDebounceFn(p=>{e&&(p.note?l.executeCommand(h.SheetUpdateNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col,note:p}):l.executeCommand(h.SheetDeleteNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col}))});g.useEffect(()=>{var p;e&&(t.getNote(e.unitId,e.subUnitId,e.row,e.col)||(p=c.current)==null||p.focus())},[e,t]),g.useEffect(()=>{const p=d.subscribe(()=>{if(!e)return;const f=t.getNote(e.unitId,e.subUnitId,e.row,e.col);f&&a(f)});return()=>p.unsubscribe()},[d]),g.useEffect(()=>{const p=c.current;if(!p)return;const f=new ResizeObserver(m=>{const y=m[0];if(!y)return;const{width:Y,height:J}=y.contentRect;if(Y===0&&J===0)return;const Q={...o,width:Y,height:J};a(Q),v(Q)});return f.observe(p),()=>{f.unobserve(p),f.disconnect()}},[o.note]);const _=p=>{const f=p.target.value,m={...o,note:f};a(m),v(m)};return ee.jsx("textarea",{ref:c,"data-u-comp":"note-textarea",className:$.clsx("univer-resize-both univer-ml-px univer-rounded-md univer-bg-white univer-p-2 univer-text-gray-900 univer-shadow dark:univer-bg-gray-800 dark:univer-text-white focus:univer-outline-none",$.borderClassName,$.scrollbarClassName),style:{width:o.width,height:o.height},value:o.note,placeholder:i.t("note.placeholder"),onChange:_})};var Ce=Object.getOwnPropertyDescriptor,me=(r,t,i,n)=>{for(var e=n>1?void 0:n?Ce(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},R=(r,t)=>(i,n)=>t(i,n,r);let H=class extends s.Disposable{constructor(r,t,i){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=i,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){this.disposeWithMe(this._componentManager.register(D,F)),this.disposeWithMe(this._componentManager.register("AddNoteSingle",A)),this.disposeWithMe(this._componentManager.register("DeleteNoteSingle",B)),this.disposeWithMe(this._componentManager.register("HideNoteSingle",W))}_initMenu(){this._menuManagerService.mergeMenu(k)}_initCommands(){this._commandService.registerCommand(E)}};H=me([R(0,s.Inject(S.ComponentManager)),R(1,s.Inject(S.IMenuManagerService)),R(2,s.ICommandService)],H);var Pe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ie=(r,t,i)=>t in r?Pe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,Me=(r,t,i,n)=>{for(var e=n>1?void 0:n?Ne(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},q=(r,t)=>(i,n)=>t(i,n,r),Z=(r,t,i)=>Ie(r,typeof t!="symbol"?t+"":t,i);const be="SHEET_NOTE_UI_PLUGIN",G="sheets-note-ui",K={menu:k};u.UniverSheetsNoteUIPlugin=class extends s.Plugin{constructor(t=K,i,n){super(),this._config=t,this._injector=i,this._configService=n;const{menu:e,...o}=s.merge({},K,this._config);e&&this._configService.setConfig("menu",e,{merge:!0}),this._configService.setConfig(G,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[H],[T]].forEach(t=>{this._injector.add(t)})}onReady(){s.touchDependencies(this._injector,[[H],[u.SheetsCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[u.SheetsNotePopupController],[T]])}},Z(u.UniverSheetsNoteUIPlugin,"pluginName",be),Z(u.UniverSheetsNoteUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=Me([s.DependentOn(h.UniverSheetsNotePlugin),q(1,s.Inject(s.Injector)),q(2,s.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=F,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
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,h,L,N,I,M,S,Q,X,$,g){"use strict";var we=Object.defineProperty;var ye=(u,s,h)=>s in u?we(u,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):u[s]=h;var b=(u,s,h)=>ye(u,typeof s!="symbol"?s+"":s,h);const V="sheets-note-ui.config",k={};var ee=Object.getOwnPropertyDescriptor,te=(r,t,n,i)=>{for(var e=i>1?void 0:i?ee(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},E=(r,t)=>(n,i)=>t(n,i,r);u.SheetsCellContentController=class extends s.Disposable{constructor(t,n,i,e){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=n,this._renderManagerService=i,this._univerInstanceService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(t,n,i)=>{const{row:e,col:o,unitId:a,subUnitId:c}=n;return this._sheetsNoteModel.getNote(a,c,e,o)?i({...t,markers:{...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}}):i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return;const i=n.getUnitId(),e=this._renderManagerService.getRenderById(i);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(I.debounceTime(16)).subscribe(()=>{t()}))}},u.SheetsCellContentController=te([E(0,s.Inject(N.SheetInterceptorService)),E(1,s.Inject(h.SheetsNoteModel)),E(2,L.IRenderManagerService),E(3,s.IUniverInstanceService)],u.SheetsCellContentController);const D="SHEET_NOTE_COMPONENT";var ie=Object.getOwnPropertyDescriptor,ne=(r,t,n,i)=>{for(var e=i>1?void 0:i?ie(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},z=(r,t)=>(n,i)=>t(n,i,r);u.SheetsNotePopupService=class extends s.Disposable{constructor(n,i){super();b(this,"_lastPopup",null);b(this,"_activePopup");b(this,"_activePopup$",new I.BehaviorSubject(null));b(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=n,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,i){var v;const{row:e,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&e===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((v=this.activePopup)==null?void 0:v.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const l=this._cellPopupManagerService.showPopup({unitId:a,subUnitId:c,row:e,col:o},{componentKey:D,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:n},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new s.DisposableCollection;d.add(l),d.add({dispose:()=>{i==null||i()}}),this._lastPopup=d}hidePopup(n){this._activePopup&&(!n&&!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=ne([z(0,S.IZenZoneService),z(1,s.Inject(M.CellPopupManagerService))],u.SheetsNotePopupService);var re=Object.getOwnPropertyDescriptor,oe=(r,t,n,i)=>{for(var e=i>1?void 0:i?re(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},O=(r,t)=>(n,i)=>t(n,i,r);let U=class extends s.Disposable{constructor(t,n,i,e){super();b(this,"_noteMatrix",new s.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=n,this._cellPopupManagerService=i,this._sheetsNotePopupService=e,this._initNoteChangeListener()}_showPopup(t,n,i,e){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:n,row:i,col:e},{componentKey:D,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:n,row:i,col:e}},priority:3})}_initSheet(t,n){var o;this._noteMatrix.forValue((a,c,l)=>{l.dispose()}),this._noteMatrix=new s.ObjectMatrix;const e=(a,c,l,d,v)=>{const _=this._noteMatrix,C=_.getValue(l,d);if(v!=null&&v.show){if(!C){const p=this._showPopup(a,c,l,d);p&&_.setValue(l,d,p)}}else C&&(C.dispose(),_.realDeleteValue(l,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,n))==null||o.forValue((a,c,l)=>{e(t,n,a,c,l)}),this._sheetsNoteModel.change$.subscribe(a=>{if(!(a.unitId!==t||a.sheetId!==n))switch(a.type){case"ref":{const{unitId:c,sheetId:l,row:d,col:v,newPosition:_,note:C}=a,p=this._noteMatrix;if(!C.show)return;const f=p.getValue(d,v);f&&(f.dispose(),p.realDeleteValue(d,v));const m=this._showPopup(c,l,_.row,_.col);m&&p.setValue(_.row,_.col,m);break}case"update":{const{unitId:c,sheetId:l,row:d,col:v,note:_}=a;e(c,l,d,v,_);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(I.switchMap(t=>{var n;return(n=t==null?void 0:t.activeSheet$)!=null?n:I.of(null)})).subscribe(t=>{if(t){const n=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{n.unsubscribe()}}else this._noteMatrix.forValue((n,i,e)=>{e.dispose()}),this._noteMatrix=new s.ObjectMatrix}))}};U=oe([O(0,s.Inject(h.SheetsNoteModel)),O(1,s.Inject(s.IUniverInstanceService)),O(2,s.Inject(M.CellPopupManagerService)),O(3,s.Inject(u.SheetsNotePopupService))],U);var se=Object.getOwnPropertyDescriptor,ae=(r,t,n,i)=>{for(var e=i>1?void 0:i?se(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},w=(r,t)=>(n,i)=>t(n,i,r);u.SheetsNotePopupController=class extends s.Disposable{constructor(n,i,e,o,a,c){super();b(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=n,this._sheetsNoteModel=i,this._sheetSelectionService=e,this._editorBridgeService=o,this._renderManagerService=a,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(n,i,e){var p,f,m;const o=(p=n[0])==null?void 0:p.range,a=this._renderManagerService.getRenderById(i),c=(f=a==null?void 0:a.with(M.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:f.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((m=o.rangeType)!=null?m: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,_=l.actualColumn,C=this._sheetsNoteModel.getNote(i,e,v,_);C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:e,row:v,col:_}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(n=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(n,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(n=>{n.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(Q.debounceTime(100)).subscribe(n=>{if(!(n!=null&&n.location))return;const{unitId:i,subUnitId:e,row:o,col:a}=n.location,c=this._sheetsNoteModel.getNote(i,e,o,a);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:e,row:o,col:a,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=ae([w(0,s.Inject(u.SheetsNotePopupService)),w(1,s.Inject(h.SheetsNoteModel)),w(2,s.Inject(N.SheetsSelectionsService)),w(3,M.IEditorBridgeService),w(4,L.IRenderManagerService),w(5,s.Inject(M.HoverManagerService))],u.SheetsNotePopupController);var P=function(){return P=Object.assign||function(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r},P.apply(this,arguments)},ue=function(r,t){var n={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(n[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var e=0,i=Object.getOwnPropertySymbols(r);e<i.length;e++)t.indexOf(i[e])<0&&Object.prototype.propertyIsEnumerable.call(r,i[e])&&(n[i[e]]=r[i[e]]);return n},T=g.forwardRef(function(r,t){var n=r.icon,i=r.id,e=r.className,o=r.extend,a=ue(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(e||"").trim(),l=g.useRef("_".concat(pe()));return A(n,"".concat(i),{defIds:n.defIds,idSuffix:l.current},P({ref:t,className:c},a),o)});function A(r,t,n,i,e){return g.createElement(r.tag,P(P({key:t},ce(r,n,e)),i),(le(r,n).children||[]).map(function(o,a){return A(o,"".concat(t,"-").concat(r.tag,"-").concat(a),n,void 0,e)}))}function ce(r,t,n){var i=P({},r.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var e=t.defIds;return!e||e.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),i}function le(r,t){var n,i=t.defIds;return!i||i.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?P(P({},r),{children:r.children.map(function(e){return typeof e.attrs.id=="string"&&i&&i.indexOf(e.attrs.id)>-1?P(P({},e),{attrs:P(P({},e.attrs),{id:e.attrs.id+t.idSuffix})}):e})}):r}function pe(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var he={tag:"svg",attrs:{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.20363 10.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.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.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.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.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.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745 11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962 11.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"}}]},B=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"add-note-single",ref:t,icon:he}))});B.displayName="AddNoteSingle";var de={tag:"svg",attrs:{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.20363 10.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.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.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.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.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.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618 14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618 8.80985 11.9946 9.10762 11.6968 9.47489 11.6968z"}}]},W=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"delete-note-single",ref:t,icon:de}))});W.displayName="DeleteNoteSingle";var ve={tag:"svg",attrs:{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.20363 10.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.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.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.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.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.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477 13.039 11.6659 12.5573 11.4614 12.0394 11.4614 11.5213 11.4614 11.0398 11.6666 10.6878 11.9487 10.3037 12.2565 10.2045 12.5399 10.2044 12.6147 10.2044 12.6893 10.3034 12.9737 10.6878 13.2817 11.0398 13.5636 11.5215 13.768 12.0394 13.768 12.5574 13.768 13.039 13.5635 13.3909 13.2817 13.7751 12.9739 13.8743 12.6897 13.8743 12.6147zM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198 13.6701 14.7627 12.9019 15.0981 12.0394 15.0981 11.1768 15.0981 10.4085 14.7627 9.85577 14.3198 9.33533 13.9027 8.87433 13.2769 8.87433 12.6147 8.8744 11.9526 9.33541 11.3276 9.85577 10.9106 10.4086 10.4676 11.1767 10.1313 12.0394 10.1313 12.9018 10.1313 13.6701 10.4668 14.223 10.9096 14.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"}}]},F=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"hide-note-single",ref:t,icon:ve}))});F.displayName="HideNoteSingle";const j={id:"sheet.operation.add-note-popup",type:s.CommandType.OPERATION,handler:async(r,t)=>{const n=r.get(N.SheetsSelectionsService),i=r.get(u.SheetsNotePopupService),o=r.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const a=o.getActiveSheet(),c=n.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:l}=c;return i.showPopup({unitId:o.getUnitId(),subUnitId:a.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:t==null?void 0:t.trigger}),!0}},q=r=>{var C;const t=S.useDependency(h.SheetsNoteModel),n=S.useDependency(s.LocaleService),i=S.useConfigValue(V),e=(C=r.popup.extraProps)==null?void 0:C.location;if(!e)return console.error("Popup extraProps or location is undefined."),null;const[o,a]=g.useState(()=>{var m,y;const p={width:((m=i==null?void 0:i.defaultNoteSize)==null?void 0:m.width)||216,height:((y=i==null?void 0:i.defaultNoteSize)==null?void 0:y.height)||92,note:""};return t.getNote(e.unitId,e.subUnitId,e.row,e.col)||p}),c=g.useRef(null),l=S.useDependency(s.ICommandService),d=g.useMemo(()=>e?t.getCellNoteChange$(e.unitId,e.subUnitId,e.row,e.col):I.of(null),[e]),v=S.useDebounceFn(p=>{e&&(p.note?l.executeCommand(h.SheetUpdateNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col,note:p}):l.executeCommand(h.SheetDeleteNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col}))});g.useEffect(()=>{var p;e&&(t.getNote(e.unitId,e.subUnitId,e.row,e.col)||(p=c.current)==null||p.focus())},[e,t]),g.useEffect(()=>{const p=d.subscribe(()=>{if(!e)return;const f=t.getNote(e.unitId,e.subUnitId,e.row,e.col);f&&a(f)});return()=>p.unsubscribe()},[d]),g.useEffect(()=>{const p=c.current;if(!p)return;const f=new ResizeObserver(m=>{const y=m[0];if(!y)return;const{width:K,height:Y}=y.contentRect;if(K===0&&Y===0)return;const J={...o,width:K,height:Y};a(J),v(J)});return f.observe(p),()=>{f.unobserve(p),f.disconnect()}},[o.note]);const _=p=>{const f=p.target.value,m={...o,note:f};a(m),v(m)};return X.jsx("textarea",{ref:c,"data-u-comp":"note-textarea",className:$.clsx("univer-resize-both univer-ml-px univer-rounded-md univer-bg-white univer-p-2 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-800 dark:!univer-text-white focus:univer-outline-none",$.borderClassName,$.scrollbarClassName),style:{width:o.width,height:o.height},value:o.note,placeholder:n.t("note.placeholder"),onChange:_})};function x(r){const t=r.get(N.SheetsSelectionsService),n=r.get(s.IUniverInstanceService);return t.selectionMoveEnd$.pipe(I.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const e=N.getSheetCommandTarget(n);if(!e)return!1;const{actualColumn:o,actualRow:a}=i.primary;return!!r.get(h.SheetsNoteModel).getNote(e.unitId,e.subUnitId,a,o)}))}function fe(r){return{id:j.id,type:S.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:I.combineLatest([S.getMenuHiddenObservable(r,s.UniverInstanceType.UNIVER_SHEET),x(r)]).pipe(I.map(([t,n])=>t||n)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:j.id}}function ge(r){return{id:h.SheetDeleteNoteCommand.id,type:S.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteSingle",hidden$:x(r).pipe(I.map(t=>!t)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function _e(r){return{id:h.SheetToggleNotePopupCommand.id,type:S.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:x(r).pipe(I.map(t=>!t))}}const Se={[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{order:0,[j.id]:{order:0,menuItemFactory:fe},[h.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:ge},[h.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:_e}}}};var Ce=Object.getOwnPropertyDescriptor,me=(r,t,n,i)=>{for(var e=i>1?void 0:i?Ce(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},R=(r,t)=>(n,i)=>t(n,i,r);let H=class extends s.Disposable{constructor(r,t,n){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=n,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){this.disposeWithMe(this._componentManager.register(D,q)),this.disposeWithMe(this._componentManager.register("AddNoteSingle",B)),this.disposeWithMe(this._componentManager.register("DeleteNoteSingle",W)),this.disposeWithMe(this._componentManager.register("HideNoteSingle",F))}_initMenu(){this._menuManagerService.mergeMenu(Se)}_initCommands(){this._commandService.registerCommand(j)}};H=me([R(0,s.Inject(S.ComponentManager)),R(1,s.Inject(S.IMenuManagerService)),R(2,s.ICommandService)],H);var Pe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ie=(r,t,n)=>t in r?Pe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,Me=(r,t,n,i)=>{for(var e=i>1?void 0:i?Ne(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},Z=(r,t)=>(n,i)=>t(n,i,r),G=(r,t,n)=>Ie(r,typeof t!="symbol"?t+"":t,n);const be="SHEET_NOTE_UI_PLUGIN";u.UniverSheetsNoteUIPlugin=class extends s.Plugin{constructor(t=k,n,i){super(),this._config=t,this._injector=n,this._configService=i;const{menu:e,...o}=s.merge({},k,this._config);e&&this._configService.setConfig("menu",e,{merge:!0}),this._configService.setConfig(V,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[H],[U]].forEach(t=>{this._injector.add(t)})}onReady(){s.touchDependencies(this._injector,[[H],[u.SheetsCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[u.SheetsNotePopupController],[U]])}},G(u.UniverSheetsNoteUIPlugin,"pluginName",be),G(u.UniverSheetsNoteUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=Me([s.DependentOn(h.UniverSheetsNotePlugin),Z(1,s.Inject(s.Injector)),Z(2,s.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=q,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
11
11
 
12
12
 
13
13
  // index
14
- (function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/sheets-note"),require("@univerjs/sheets-note-ui"),require("@univerjs/sheets-note/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-note","@univerjs/sheets-note-ui","@univerjs/sheets-note/facade"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.UniverPresetSheetsNote={},e.UniverSheetsNote,e.UniverSheetsNoteUi,e.UniverSheetsNoteFacade))})(this,function(e,n,s,i){"use strict";function r(){return{plugins:[n.UniverSheetsNotePlugin,s.UniverSheetsNoteUIPlugin].filter(t=>!!t)}}e.UniverSheetsNotePreset=r,Object.keys(i).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:()=>i[t]})}),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
14
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/sheets-note"),require("@univerjs/sheets-note-ui"),require("@univerjs/sheets-note/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-note","@univerjs/sheets-note-ui","@univerjs/sheets-note/facade"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.UniverPresetSheetsNote={},e.UniverSheetsNote,e.UniverSheetsNoteUi))})(this,function(e,t,n){"use strict";function i(){return{plugins:[t.UniverSheetsNotePlugin,n.UniverSheetsNoteUIPlugin].filter(s=>!!s)}}e.UniverSheetsNotePreset=i,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-note",
3
- "version": "0.7.0-nightly.202505121607",
3
+ "version": "0.7.0-nightly.202505151607",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,16 +57,16 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-note": "0.7.0-nightly.202505121607",
61
- "@univerjs/sheets-note-ui": "0.7.0-nightly.202505121607",
62
- "rxjs": ">=7.0.0"
60
+ "@univerjs/sheets-note": "0.7.0-nightly.202505151607",
61
+ "@univerjs/sheets-note-ui": "0.7.0-nightly.202505151607"
63
62
  },
64
63
  "devDependencies": {
65
- "@univerjs/core": "0.7.0-nightly.202505121607",
64
+ "@univerjs/core": "0.7.0-nightly.202505151607",
66
65
  "react": "18.3.1",
67
66
  "react-dom": "18.3.1",
67
+ "rxjs": "7.8.2",
68
68
  "typescript": "^5.8.3",
69
- "@univerjs-infra/shared": "0.7.0-beta.1"
69
+ "@univerjs-infra/shared": "0.7.0"
70
70
  },
71
71
  "scripts": {
72
72
  "prebuild:preset": "tsx prepare.ts",