@univerjs/sheets-note-ui 0.7.0 → 0.8.0-beta.0

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";var J=Object.defineProperty;var Q=(r,e,i)=>e in r?J(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i;var I=(r,e,i)=>Q(r,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),m=require("@univerjs/sheets-note"),B=require("@univerjs/engine-render"),N=require("@univerjs/sheets"),P=require("rxjs"),M=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),X=require("rxjs/operators"),ee=require("react/jsx-runtime"),H=require("@univerjs/design"),g=require("react"),W="sheets-note-ui.config",k={};var te=Object.getOwnPropertyDescriptor,ie=(r,e,i,n)=>{for(var t=n>1?void 0:n?te(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},y=(r,e)=>(i,n)=>e(i,n,r);exports.SheetsCellContentController=class extends a.Disposable{constructor(e,i,n,t){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=i,this._renderManagerService=n,this._univerInstanceService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,i,n)=>{const{row:t,col:o,unitId:s,subUnitId:c}=i;return this._sheetsNoteModel.getNote(s,c,t,o)?n({...e,markers:{...e==null?void 0:e.markers,tr:{color:"#FFBD37",size:6}}}):n(e)},priority:100}))}_initSkeletonChange(){const e=()=>{var o;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),t=this._renderManagerService.getRenderById(n);(o=t==null?void 0:t.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(P.debounceTime(16)).subscribe(()=>{e()}))}};exports.SheetsCellContentController=ie([y(0,a.Inject(N.SheetInterceptorService)),y(1,a.Inject(m.SheetsNoteModel)),y(2,B.IRenderManagerService),y(3,a.IUniverInstanceService)],exports.SheetsCellContentController);const j="SHEET_NOTE_COMPONENT";var ne=Object.getOwnPropertyDescriptor,re=(r,e,i,n)=>{for(var t=n>1?void 0:n?ne(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},z=(r,e)=>(i,n)=>e(i,n,r);exports.SheetsNotePopupService=class extends a.Disposable{constructor(i,n){super();I(this,"_lastPopup",null);I(this,"_activePopup");I(this,"_activePopup$",new P.BehaviorSubject(null));I(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 h;const{row:t,col:o,unitId:s,subUnitId:c}=i;if(this._activePopup&&t===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.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 u=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:c,row:t,col:o},{componentKey:j,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:i},priority:3});if(!u)throw new Error("[SheetsNotePopupService]: cannot show popup!");const p=new a.DisposableCollection;p.add(u),p.add({dispose:()=>{n==null||n()}}),this._lastPopup=p}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))}};exports.SheetsNotePopupService=re([z(0,f.IZenZoneService),z(1,a.Inject(M.CellPopupManagerService))],exports.SheetsNotePopupService);var oe=Object.getOwnPropertyDescriptor,se=(r,e,i,n)=>{for(var t=n>1?void 0:n?oe(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},O=(r,e)=>(i,n)=>e(i,n,r);let E=class extends a.Disposable{constructor(e,i,n,t){super();I(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=e,this._univerInstanceService=i,this._cellPopupManagerService=n,this._sheetsNotePopupService=t,this._initNoteChangeListener()}_showPopup(e,i,n,t){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:i,row:n,col:t},{componentKey:j,direction:"horizontal",extraProps:{location:{unitId:e,subUnitId:i,row:n,col:t}},priority:3})}_initSheet(e,i){var o;this._noteMatrix.forValue((s,c,u)=>{u.dispose()}),this._noteMatrix=new a.ObjectMatrix;const t=(s,c,u,p,h)=>{const v=this._noteMatrix,_=v.getValue(u,p);if(h!=null&&h.show){if(!_){const l=this._showPopup(s,c,u,p);l&&v.setValue(u,p,l)}}else _&&(_.dispose(),v.realDeleteValue(u,p))};return(o=this._sheetsNoteModel.getSheetNotes(e,i))==null||o.forValue((s,c,u)=>{t(e,i,s,c,u)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==e||s.sheetId!==i))switch(s.type){case"ref":{const{unitId:c,sheetId:u,row:p,col:h,newPosition:v,note:_}=s,l=this._noteMatrix;if(!_.show)return;const d=l.getValue(p,h);d&&(d.dispose(),l.realDeleteValue(p,h));const S=this._showPopup(c,u,v.row,v.col);S&&l.setValue(v.row,v.col,S);break}case"update":{const{unitId:c,sheetId:u,row:p,col:h,note:v}=s;t(c,u,p,h,v);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(P.switchMap(e=>{var i;return(i=e==null?void 0:e.activeSheet$)!=null?i:P.of(null)})).subscribe(e=>{if(e){const i=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{i.unsubscribe()}}else this._noteMatrix.forValue((i,n,t)=>{t.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};E=se([O(0,a.Inject(m.SheetsNoteModel)),O(1,a.Inject(a.IUniverInstanceService)),O(2,a.Inject(M.CellPopupManagerService)),O(3,a.Inject(exports.SheetsNotePopupService))],E);var ae=Object.getOwnPropertyDescriptor,ce=(r,e,i,n)=>{for(var t=n>1?void 0:n?ae(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},b=(r,e)=>(i,n)=>e(i,n,r);exports.SheetsNotePopupController=class extends a.Disposable{constructor(i,n,t,o,s,c){super();I(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=i,this._sheetsNoteModel=n,this._sheetSelectionService=t,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(i,n,t){var l,d,S;const o=(l=i[0])==null?void 0:l.range,s=this._renderManagerService.getRenderById(n),c=(d=s==null?void 0:s.with(M.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:d.skeleton;if(!c||!o)return;const u=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((S=o.rangeType)!=null?S:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&a.Rectangle.equals(u.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const h=u.actualRow,v=u.actualColumn,_=this._sheetsNoteModel.getNote(n,t,h,v);_!=null&&_.show||(_?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:t,row:h,col:v}):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:t,row:o,col:s}=i.location,c=this._sheetsNoteModel.getNote(n,t,o,s);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:t,row:o,col:s,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}};exports.SheetsNotePopupController=ce([b(0,a.Inject(exports.SheetsNotePopupService)),b(1,a.Inject(m.SheetsNoteModel)),b(2,a.Inject(N.SheetsSelectionsService)),b(3,M.IEditorBridgeService),b(4,B.IRenderManagerService),b(5,a.Inject(M.HoverManagerService))],exports.SheetsNotePopupController);var C=function(){return C=Object.assign||function(r){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},C.apply(this,arguments)},ue=function(r,e){var i={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(i[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,n=Object.getOwnPropertySymbols(r);t<n.length;t++)e.indexOf(n[t])<0&&Object.prototype.propertyIsEnumerable.call(r,n[t])&&(i[n[t]]=r[n[t]]);return i},T=g.forwardRef(function(r,e){var i=r.icon,n=r.id,t=r.className,o=r.extend,s=ue(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(t||"").trim(),u=g.useRef("_".concat(he()));return F(i,"".concat(n),{defIds:i.defIds,idSuffix:u.current},C({ref:e,className:c},s),o)});function F(r,e,i,n,t){return g.createElement(r.tag,C(C({key:e},le(r,i,t)),n),(pe(r,i).children||[]).map(function(o,s){return F(o,"".concat(e,"-").concat(r.tag,"-").concat(s),i,void 0,t)}))}function le(r,e,i){var n=C({},r.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];s==="mask"&&typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var t=e.defIds;return!t||t.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function pe(r,e){var i,n=e.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((i=r.children)===null||i===void 0)&&i.length)?C(C({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&n&&n.indexOf(t.attrs.id)>-1?C(C({},t),{attrs:C(C({},t.attrs),{id:t.attrs.id+e.idSuffix})}):t})}):r}function he(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";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.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"}}]},q=g.forwardRef(function(r,e){return g.createElement(T,Object.assign({},r,{id:"add-note-single",ref:e,icon:de}))});q.displayName="AddNoteSingle";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.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"}}]},Z=g.forwardRef(function(r,e){return g.createElement(T,Object.assign({},r,{id:"delete-note-single",ref:e,icon:ve}))});Z.displayName="DeleteNoteSingle";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.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"}}]},G=g.forwardRef(function(r,e){return g.createElement(T,Object.assign({},r,{id:"hide-note-single",ref:e,icon:ge}))});G.displayName="HideNoteSingle";const x={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(r,e)=>{const i=r.get(N.SheetsSelectionsService),n=r.get(exports.SheetsNotePopupService),o=r.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),c=i.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:u}=c;return n.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:e==null?void 0:e.trigger}),!0}},K=r=>{var _;const e=f.useDependency(m.SheetsNoteModel),i=f.useDependency(a.LocaleService),n=f.useConfigValue(W),t=(_=r.popup.extraProps)==null?void 0:_.location;if(!t)return console.error("Popup extraProps or location is undefined."),null;const[o,s]=g.useState(()=>{var S,w;const l={width:((S=n==null?void 0:n.defaultNoteSize)==null?void 0:S.width)||216,height:((w=n==null?void 0:n.defaultNoteSize)==null?void 0:w.height)||92,note:""};return e.getNote(t.unitId,t.subUnitId,t.row,t.col)||l}),c=g.useRef(null),u=f.useDependency(a.ICommandService),p=g.useMemo(()=>t?e.getCellNoteChange$(t.unitId,t.subUnitId,t.row,t.col):P.of(null),[t]),h=f.useDebounceFn(l=>{t&&(l.note?u.executeCommand(m.SheetUpdateNoteCommand.id,{unitId:t.unitId,sheetId:t.subUnitId,row:t.row,col:t.col,note:l}):u.executeCommand(m.SheetDeleteNoteCommand.id,{unitId:t.unitId,sheetId:t.subUnitId,row:t.row,col:t.col}))});g.useEffect(()=>{var l;t&&(e.getNote(t.unitId,t.subUnitId,t.row,t.col)||(l=c.current)==null||l.focus())},[t,e]),g.useEffect(()=>{const l=p.subscribe(()=>{if(!t)return;const d=e.getNote(t.unitId,t.subUnitId,t.row,t.col);d&&s(d)});return()=>l.unsubscribe()},[p]),g.useEffect(()=>{const l=c.current;if(!l)return;const d=new ResizeObserver(S=>{const w=S[0];if(!w)return;const{width:R,height:L}=w.contentRect;if(R===0&&L===0)return;const V={...o,width:R,height:L};s(V),h(V)});return d.observe(l),()=>{d.unobserve(l),d.disconnect()}},[o.note]);const v=l=>{const d=l.target.value,S={...o,note:d};s(S),h(S)};return ee.jsx("textarea",{ref:c,"data-u-comp":"note-textarea",className:H.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",H.borderClassName,H.scrollbarClassName),style:{width:o.width,height:o.height},value:o.note,placeholder:i.t("note.placeholder"),onChange:v})};function D(r){const e=r.get(N.SheetsSelectionsService),i=r.get(a.IUniverInstanceService);return e.selectionMoveEnd$.pipe(P.map(()=>{const n=e.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const t=N.getSheetCommandTarget(i);if(!t)return!1;const{actualColumn:o,actualRow:s}=n.primary;return!!r.get(m.SheetsNoteModel).getNote(t.unitId,t.subUnitId,s,o)}))}function fe(r){return{id:x.id,type:f.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:P.combineLatest([f.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),D(r)]).pipe(P.map(([e,i])=>e||i)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:x.id}}function _e(r){return{id:m.SheetDeleteNoteCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteSingle",hidden$:D(r).pipe(P.map(e=>!e)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function Se(r){return{id:m.SheetToggleNotePopupCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:D(r).pipe(P.map(e=>!e))}}const Ce={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:0,[x.id]:{order:0,menuItemFactory:fe},[m.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:_e},[m.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};var me=Object.getOwnPropertyDescriptor,Ne=(r,e,i,n)=>{for(var t=n>1?void 0:n?me(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},$=(r,e)=>(i,n)=>e(i,n,r);let U=class extends a.Disposable{constructor(r,e,i){super(),this._componentManager=r,this._menuManagerService=e,this._commandService=i,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){this.disposeWithMe(this._componentManager.register(j,K)),this.disposeWithMe(this._componentManager.register("AddNoteSingle",q)),this.disposeWithMe(this._componentManager.register("DeleteNoteSingle",Z)),this.disposeWithMe(this._componentManager.register("HideNoteSingle",G))}_initMenu(){this._menuManagerService.mergeMenu(Ce)}_initCommands(){this._commandService.registerCommand(x)}};U=Ne([$(0,a.Inject(f.ComponentManager)),$(1,a.Inject(f.IMenuManagerService)),$(2,a.ICommandService)],U);var Pe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Me=(r,e,i)=>e in r?Pe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,be=(r,e,i,n)=>{for(var t=n>1?void 0:n?Ie(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},A=(r,e)=>(i,n)=>e(i,n,r),Y=(r,e,i)=>Me(r,typeof e!="symbol"?e+"":e,i);const we="SHEET_NOTE_UI_PLUGIN";exports.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(e=k,i,n){super(),this._config=e,this._injector=i,this._configService=n;const{menu:t,...o}=a.merge({},k,this._config);t&&this._configService.setConfig("menu",t,{merge:!0}),this._configService.setConfig(W,o)}onStarting(){[[exports.SheetsNotePopupService],[exports.SheetsCellContentController],[exports.SheetsNotePopupController],[U],[E]].forEach(e=>{this._injector.add(e)})}onReady(){a.touchDependencies(this._injector,[[U],[exports.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[exports.SheetsNotePopupController],[E]])}};Y(exports.UniverSheetsNoteUIPlugin,"pluginName",we);Y(exports.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNoteUIPlugin=be([a.DependentOn(m.UniverSheetsNotePlugin),A(1,a.Inject(a.Injector)),A(2,a.IConfigService)],exports.UniverSheetsNoteUIPlugin);exports.SheetsNote=K;
1
+ "use strict";var J=Object.defineProperty;var Q=(r,e,i)=>e in r?J(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i;var I=(r,e,i)=>Q(r,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),m=require("@univerjs/sheets-note"),B=require("@univerjs/engine-render"),N=require("@univerjs/sheets"),P=require("rxjs"),b=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),X=require("rxjs/operators"),ee=require("react/jsx-runtime"),H=require("@univerjs/design"),g=require("react"),F="sheets-note-ui.config",k={};var te=Object.getOwnPropertyDescriptor,ie=(r,e,i,n)=>{for(var t=n>1?void 0:n?te(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},y=(r,e)=>(i,n)=>e(i,n,r);exports.SheetsCellContentController=class extends a.Disposable{constructor(e,i,n,t){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=i,this._renderManagerService=n,this._univerInstanceService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,i,n)=>{const{row:t,col:o,unitId:s,subUnitId:c}=i;return this._sheetsNoteModel.getNote(s,c,t,o)?n({...e,markers:{...e==null?void 0:e.markers,tr:{color:"#FFBD37",size:6}}}):n(e)},priority:100}))}_initSkeletonChange(){const e=()=>{var o;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),t=this._renderManagerService.getRenderById(n);(o=t==null?void 0:t.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(P.debounceTime(16)).subscribe(()=>{e()}))}};exports.SheetsCellContentController=ie([y(0,a.Inject(N.SheetInterceptorService)),y(1,a.Inject(m.SheetsNoteModel)),y(2,B.IRenderManagerService),y(3,a.IUniverInstanceService)],exports.SheetsCellContentController);const j="SHEET_NOTE_COMPONENT";var ne=Object.getOwnPropertyDescriptor,re=(r,e,i,n)=>{for(var t=n>1?void 0:n?ne(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},z=(r,e)=>(i,n)=>e(i,n,r);exports.SheetsNotePopupService=class extends a.Disposable{constructor(i,n){super();I(this,"_lastPopup",null);I(this,"_activePopup");I(this,"_activePopup$",new P.BehaviorSubject(null));I(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 h;const{row:t,col:o,unitId:s,subUnitId:c}=i;if(this._activePopup&&t===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.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 u=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:c,row:t,col:o},{componentKey:j,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:i},priority:3});if(!u)throw new Error("[SheetsNotePopupService]: cannot show popup!");const p=new a.DisposableCollection;p.add(u),p.add({dispose:()=>{n==null||n()}}),this._lastPopup=p}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))}};exports.SheetsNotePopupService=re([z(0,f.IZenZoneService),z(1,a.Inject(b.CellPopupManagerService))],exports.SheetsNotePopupService);var oe=Object.getOwnPropertyDescriptor,se=(r,e,i,n)=>{for(var t=n>1?void 0:n?oe(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},E=(r,e)=>(i,n)=>e(i,n,r);let O=class extends a.Disposable{constructor(e,i,n,t){super();I(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=e,this._univerInstanceService=i,this._cellPopupManagerService=n,this._sheetsNotePopupService=t,this._initNoteChangeListener()}_showPopup(e,i,n,t){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:i,row:n,col:t},{componentKey:j,direction:"horizontal",extraProps:{location:{unitId:e,subUnitId:i,row:n,col:t}},priority:3})}_initSheet(e,i){var o;this._noteMatrix.forValue((s,c,u)=>{u.dispose()}),this._noteMatrix=new a.ObjectMatrix;const t=(s,c,u,p,h)=>{const v=this._noteMatrix,_=v.getValue(u,p);if(h!=null&&h.show){if(!_){const l=this._showPopup(s,c,u,p);l&&v.setValue(u,p,l)}}else _&&(_.dispose(),v.realDeleteValue(u,p))};return(o=this._sheetsNoteModel.getSheetNotes(e,i))==null||o.forValue((s,c,u)=>{t(e,i,s,c,u)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==e||s.sheetId!==i))switch(s.type){case"ref":{const{unitId:c,sheetId:u,row:p,col:h,newPosition:v,note:_}=s,l=this._noteMatrix;if(!_.show)return;const d=l.getValue(p,h);d&&(d.dispose(),l.realDeleteValue(p,h));const S=this._showPopup(c,u,v.row,v.col);S&&l.setValue(v.row,v.col,S);break}case"update":{const{unitId:c,sheetId:u,row:p,col:h,note:v}=s;t(c,u,p,h,v);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(P.switchMap(e=>{var i;return(i=e==null?void 0:e.activeSheet$)!=null?i:P.of(null)})).subscribe(e=>{if(e){const i=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{i.unsubscribe()}}else this._noteMatrix.forValue((i,n,t)=>{t.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};O=se([E(0,a.Inject(m.SheetsNoteModel)),E(1,a.Inject(a.IUniverInstanceService)),E(2,a.Inject(b.CellPopupManagerService)),E(3,a.Inject(exports.SheetsNotePopupService))],O);var ae=Object.getOwnPropertyDescriptor,ce=(r,e,i,n)=>{for(var t=n>1?void 0:n?ae(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},M=(r,e)=>(i,n)=>e(i,n,r);exports.SheetsNotePopupController=class extends a.Disposable{constructor(i,n,t,o,s,c){super();I(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=i,this._sheetsNoteModel=n,this._sheetSelectionService=t,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(i,n,t){var l,d,S;const o=(l=i[0])==null?void 0:l.range,s=this._renderManagerService.getRenderById(n),c=(d=s==null?void 0:s.with(b.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:d.skeleton;if(!c||!o)return;const u=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((S=o.rangeType)!=null?S:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&a.Rectangle.equals(u.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const h=u.actualRow,v=u.actualColumn,_=this._sheetsNoteModel.getNote(n,t,h,v);_!=null&&_.show||(_?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:t,row:h,col:v}):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:t,row:o,col:s}=i.location,c=this._sheetsNoteModel.getNote(n,t,o,s);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:t,row:o,col:s,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}};exports.SheetsNotePopupController=ce([M(0,a.Inject(exports.SheetsNotePopupService)),M(1,a.Inject(m.SheetsNoteModel)),M(2,a.Inject(N.SheetsSelectionsService)),M(3,b.IEditorBridgeService),M(4,B.IRenderManagerService),M(5,a.Inject(b.HoverManagerService))],exports.SheetsNotePopupController);var C=function(){return C=Object.assign||function(r){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}return r},C.apply(this,arguments)},ue=function(r,e){var i={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(i[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,n=Object.getOwnPropertySymbols(r);t<n.length;t++)e.indexOf(n[t])<0&&Object.prototype.propertyIsEnumerable.call(r,n[t])&&(i[n[t]]=r[n[t]]);return i},T=g.forwardRef(function(r,e){var i=r.icon,n=r.id,t=r.className,o=r.extend,s=ue(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(t||"").trim(),u=g.useRef("_".concat(he()));return W(i,"".concat(n),{defIds:i.defIds,idSuffix:u.current},C({ref:e,className:c},s),o)});function W(r,e,i,n,t){return g.createElement(r.tag,C(C({key:e},le(r,i,t)),n),(pe(r,i).children||[]).map(function(o,s){return W(o,"".concat(e,"-").concat(r.tag,"-").concat(s),i,void 0,t)}))}function le(r,e,i){var n=C({},r.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];s==="mask"&&typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var t=e.defIds;return!t||t.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function pe(r,e){var i,n=e.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((i=r.children)===null||i===void 0)&&i.length)?C(C({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&n&&n.indexOf(t.attrs.id)>-1?C(C({},t),{attrs:C(C({},t.attrs),{id:t.attrs.id+e.idSuffix})}):t})}):r}function he(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";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.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"}}]},q=g.forwardRef(function(r,e){return g.createElement(T,Object.assign({},r,{id:"add-note-single",ref:e,icon:de}))});q.displayName="AddNoteSingle";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.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"}}]},Z=g.forwardRef(function(r,e){return g.createElement(T,Object.assign({},r,{id:"delete-note-single",ref:e,icon:ve}))});Z.displayName="DeleteNoteSingle";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.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"}}]},G=g.forwardRef(function(r,e){return g.createElement(T,Object.assign({},r,{id:"hide-note-single",ref:e,icon:ge}))});G.displayName="HideNoteSingle";const x={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(r,e)=>{const i=r.get(N.SheetsSelectionsService),n=r.get(exports.SheetsNotePopupService),o=r.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),c=i.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:u}=c;return n.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:e==null?void 0:e.trigger}),!0}},K=r=>{var _;const e=f.useDependency(m.SheetsNoteModel),i=f.useDependency(a.LocaleService),n=f.useConfigValue(F),t=(_=r.popup.extraProps)==null?void 0:_.location;if(!t)return console.error("Popup extraProps or location is undefined."),null;const[o,s]=g.useState(()=>{var S,w;const l={width:((S=n==null?void 0:n.defaultNoteSize)==null?void 0:S.width)||216,height:((w=n==null?void 0:n.defaultNoteSize)==null?void 0:w.height)||92,note:""};return e.getNote(t.unitId,t.subUnitId,t.row,t.col)||l}),c=g.useRef(null),u=f.useDependency(a.ICommandService),p=g.useMemo(()=>t?e.getCellNoteChange$(t.unitId,t.subUnitId,t.row,t.col):P.of(null),[t]),h=f.useDebounceFn(l=>{t&&(l.note?u.executeCommand(m.SheetUpdateNoteCommand.id,{unitId:t.unitId,sheetId:t.subUnitId,row:t.row,col:t.col,note:l}):u.executeCommand(m.SheetDeleteNoteCommand.id,{unitId:t.unitId,sheetId:t.subUnitId,row:t.row,col:t.col}))});g.useEffect(()=>{var l;t&&(e.getNote(t.unitId,t.subUnitId,t.row,t.col)||(l=c.current)==null||l.focus())},[t,e]),g.useEffect(()=>{const l=p.subscribe(()=>{if(!t)return;const d=e.getNote(t.unitId,t.subUnitId,t.row,t.col);d&&s(d)});return()=>l.unsubscribe()},[p]),g.useEffect(()=>{const l=c.current;if(!l)return;const d=new ResizeObserver(S=>{const w=S[0];if(!w)return;const{width:R,height:L}=w.contentRect;if(R===0&&L===0)return;const V={...o,width:R,height:L};s(V),h(V)});return d.observe(l),()=>{d.unobserve(l),d.disconnect()}},[o.note]);const v=l=>{const d=l.target.value,S={...o,note:d};s(S),h(S)};return ee.jsx("textarea",{ref:c,"data-u-comp":"note-textarea",className:H.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",H.borderClassName,H.scrollbarClassName),style:{width:o.width,height:o.height},value:o.note,placeholder:i.t("note.placeholder"),onChange:v})};function D(r){const e=r.get(N.SheetsSelectionsService),i=r.get(a.IUniverInstanceService);return e.selectionMoveEnd$.pipe(P.map(()=>{const n=e.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const t=N.getSheetCommandTarget(i);if(!t)return!1;const{actualColumn:o,actualRow:s}=n.primary;return!!r.get(m.SheetsNoteModel).getNote(t.unitId,t.subUnitId,s,o)}))}function fe(r){return{id:x.id,type:f.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:P.combineLatest([f.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),D(r)]).pipe(P.map(([e,i])=>e||i)),disabled$:b.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:x.id}}function _e(r){return{id:m.SheetDeleteNoteCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteSingle",hidden$:D(r).pipe(P.map(e=>!e)),disabled$:b.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function Se(r){return{id:m.SheetToggleNotePopupCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:D(r).pipe(P.map(e=>!e))}}const Ce={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:0,[x.id]:{order:0,menuItemFactory:fe},[m.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:_e},[m.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};var me=Object.getOwnPropertyDescriptor,Ne=(r,e,i,n)=>{for(var t=n>1?void 0:n?me(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},$=(r,e)=>(i,n)=>e(i,n,r);let U=class extends a.Disposable{constructor(r,e,i){super(),this._componentManager=r,this._menuManagerService=e,this._commandService=i,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[j,K],["AddNoteSingle",q],["DeleteNoteSingle",Z],["HideNoteSingle",G]].forEach(([r,e])=>{this.disposeWithMe(this._componentManager.register(r,e))})}_initMenu(){this._menuManagerService.mergeMenu(Ce)}_initCommands(){this._commandService.registerCommand(x)}};U=Ne([$(0,a.Inject(f.ComponentManager)),$(1,a.Inject(f.IMenuManagerService)),$(2,a.ICommandService)],U);var Pe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,be=(r,e,i)=>e in r?Pe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,Me=(r,e,i,n)=>{for(var t=n>1?void 0:n?Ie(e,i):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=s(t)||t);return t},A=(r,e)=>(i,n)=>e(i,n,r),Y=(r,e,i)=>be(r,typeof e!="symbol"?e+"":e,i);const we="SHEET_NOTE_UI_PLUGIN";exports.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(e=k,i,n){super(),this._config=e,this._injector=i,this._configService=n;const{menu:t,...o}=a.merge({},k,this._config);t&&this._configService.setConfig("menu",t,{merge:!0}),this._configService.setConfig(F,o)}onStarting(){[[exports.SheetsNotePopupService],[exports.SheetsCellContentController],[exports.SheetsNotePopupController],[U],[O]].forEach(e=>{this._injector.add(e)})}onReady(){a.touchDependencies(this._injector,[[U],[exports.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[exports.SheetsNotePopupController],[O]])}};Y(exports.UniverSheetsNoteUIPlugin,"pluginName",we);Y(exports.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNoteUIPlugin=Me([a.DependentOn(m.UniverSheetsNotePlugin),A(1,a.Inject(a.Injector)),A(2,a.IConfigService)],exports.UniverSheetsNoteUIPlugin);exports.SheetsNote=K;
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
- var ge = Object.defineProperty;
2
- var _e = (i, e, n) => e in i ? ge(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
- var m = (i, e, n) => _e(i, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as v, IUniverInstanceService as $, Disposable as P, InterceptorEffectEnum as me, UniverInstanceType as M, DisposableCollection as Ce, ObjectMatrix as R, RANGE_TYPE as q, Rectangle as Se, CommandType as Ne, LocaleService as Pe, ICommandService as te, DependentOn as Me, Injector as be, IConfigService as Ie, Plugin as we, merge as ye, touchDependencies as J } from "@univerjs/core";
5
- import { SheetsNoteModel as b, SheetUpdateNoteCommand as Oe, SheetDeleteNoteCommand as B, SheetToggleNotePopupCommand as ie, UniverSheetsNotePlugin as xe } from "@univerjs/sheets-note";
1
+ var _e = Object.defineProperty;
2
+ var ge = (i, e, n) => e in i ? _e(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
+ var C = (i, e, n) => ge(i, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Inject as v, IUniverInstanceService as $, Disposable as P, InterceptorEffectEnum as Ce, UniverInstanceType as b, DisposableCollection as me, ObjectMatrix as R, RANGE_TYPE as q, Rectangle as Se, CommandType as Ne, LocaleService as Pe, ICommandService as te, DependentOn as be, Injector as Ie, IConfigService as Me, Plugin as we, merge as ye, touchDependencies as J } from "@univerjs/core";
5
+ import { SheetsNoteModel as I, SheetUpdateNoteCommand as Oe, SheetDeleteNoteCommand as B, SheetToggleNotePopupCommand as ie, UniverSheetsNotePlugin as xe } from "@univerjs/sheets-note";
6
6
  import { IRenderManagerService as re } from "@univerjs/engine-render";
7
7
  import { SheetInterceptorService as Ee, INTERCEPTOR_POINT as He, SheetsSelectionsService as A, WorksheetEditPermission as ne, WorkbookEditablePermission as oe, getSheetCommandTarget as Te } from "@univerjs/sheets";
8
8
  import { debounceTime as $e, BehaviorSubject as Ue, switchMap as Le, of as se, map as U, combineLatest as De } from "rxjs";
9
9
  import { CellPopupManagerService as ae, IEditorBridgeService as Ve, HoverManagerService as Re, SheetSkeletonManagerService as je, getCurrentRangeDisable$ as ce } from "@univerjs/sheets-ui";
10
- import { IZenZoneService as ze, useDependency as j, useConfigValue as ke, useDebounceFn as Be, MenuItemType as W, getMenuHiddenObservable as Ae, ContextMenuPosition as We, ContextMenuGroup as Fe, ComponentManager as Ze, IMenuManagerService as Ge } from "@univerjs/ui";
10
+ import { IZenZoneService as ze, useDependency as j, useConfigValue as ke, useDebounceFn as Be, MenuItemType as F, getMenuHiddenObservable as Ae, ContextMenuPosition as Fe, ContextMenuGroup as We, ComponentManager as Ze, IMenuManagerService as Ge } from "@univerjs/ui";
11
11
  import { debounceTime as Ke } from "rxjs/operators";
12
12
  import { jsx as Ye } from "react/jsx-runtime";
13
13
  import { clsx as qe, borderClassName as Je, scrollbarClassName as Qe } from "@univerjs/design";
@@ -17,7 +17,7 @@ var tt = Object.getOwnPropertyDescriptor, it = (i, e, n, r) => {
17
17
  for (var t = r > 1 ? void 0 : r ? tt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
18
18
  (s = i[o]) && (t = s(t) || t);
19
19
  return t;
20
- }, I = (i, e) => (n, r) => e(n, r, i);
20
+ }, M = (i, e) => (n, r) => e(n, r, i);
21
21
  let y = class extends P {
22
22
  constructor(i, e, n, r) {
23
23
  super(), this._sheetInterceptorService = i, this._sheetsNoteModel = e, this._renderManagerService = n, this._univerInstanceService = r, this._initViewModelIntercept(), this._initSkeletonChange();
@@ -27,7 +27,7 @@ let y = class extends P {
27
27
  this._sheetInterceptorService.intercept(
28
28
  He.CELL_CONTENT,
29
29
  {
30
- effect: me.Style,
30
+ effect: Ce.Style,
31
31
  handler: (i, e, n) => {
32
32
  const { row: r, col: t, unitId: o, subUnitId: s } = e;
33
33
  return this._sheetsNoteModel.getNote(o, s, r, t) ? n({
@@ -49,7 +49,7 @@ let y = class extends P {
49
49
  _initSkeletonChange() {
50
50
  const i = () => {
51
51
  var t;
52
- const e = this._univerInstanceService.getCurrentUnitForType(M.UNIVER_SHEET);
52
+ const e = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
53
53
  if (!e) return;
54
54
  const n = e.getUnitId(), r = this._renderManagerService.getRenderById(n);
55
55
  (t = r == null ? void 0 : r.mainComponent) == null || t.makeForceDirty();
@@ -60,12 +60,12 @@ let y = class extends P {
60
60
  }
61
61
  };
62
62
  y = it([
63
- I(0, v(Ee)),
64
- I(1, v(b)),
65
- I(2, re),
66
- I(3, $)
63
+ M(0, v(Ee)),
64
+ M(1, v(I)),
65
+ M(2, re),
66
+ M(3, $)
67
67
  ], y);
68
- const F = "SHEET_NOTE_COMPONENT";
68
+ const W = "SHEET_NOTE_COMPONENT";
69
69
  var rt = Object.getOwnPropertyDescriptor, nt = (i, e, n, r) => {
70
70
  for (var t = r > 1 ? void 0 : r ? rt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
71
71
  (s = i[o]) && (t = s(t) || t);
@@ -74,10 +74,10 @@ var rt = Object.getOwnPropertyDescriptor, nt = (i, e, n, r) => {
74
74
  let S = class extends P {
75
75
  constructor(e, n) {
76
76
  super();
77
- m(this, "_lastPopup", null);
78
- m(this, "_activePopup");
79
- m(this, "_activePopup$", new Ue(null));
80
- m(this, "activePopup$", this._activePopup$.asObservable());
77
+ C(this, "_lastPopup", null);
78
+ C(this, "_activePopup");
79
+ C(this, "_activePopup$", new Ue(null));
80
+ C(this, "activePopup$", this._activePopup$.asObservable());
81
81
  this._zenZoneService = e, this._cellPopupManagerService = n, this._initZenVisible(), this.disposeWithMe(() => {
82
82
  this._activePopup$.complete();
83
83
  });
@@ -108,7 +108,7 @@ let S = class extends P {
108
108
  col: t
109
109
  },
110
110
  {
111
- componentKey: F,
111
+ componentKey: W,
112
112
  onClickOutside: () => {
113
113
  this.hidePopup();
114
114
  },
@@ -121,7 +121,7 @@ let S = class extends P {
121
121
  );
122
122
  if (!a)
123
123
  throw new Error("[SheetsNotePopupService]: cannot show popup!");
124
- const c = new Ce();
124
+ const c = new me();
125
125
  c.add(a), c.add({
126
126
  dispose: () => {
127
127
  n == null || n();
@@ -150,7 +150,7 @@ var ot = Object.getOwnPropertyDescriptor, st = (i, e, n, r) => {
150
150
  let O = class extends P {
151
151
  constructor(e, n, r, t) {
152
152
  super();
153
- m(this, "_noteMatrix", new R());
153
+ C(this, "_noteMatrix", new R());
154
154
  this._sheetsNoteModel = e, this._univerInstanceService = n, this._cellPopupManagerService = r, this._sheetsNotePopupService = t, this._initNoteChangeListener();
155
155
  }
156
156
  _showPopup(e, n, r, t) {
@@ -162,7 +162,7 @@ let O = class extends P {
162
162
  col: t
163
163
  },
164
164
  {
165
- componentKey: F,
165
+ componentKey: W,
166
166
  direction: "horizontal",
167
167
  extraProps: {
168
168
  location: {
@@ -182,14 +182,14 @@ let O = class extends P {
182
182
  c.dispose();
183
183
  }), this._noteMatrix = new R();
184
184
  const t = (s, a, c, l, d) => {
185
- const p = this._noteMatrix, g = p.getValue(c, l);
185
+ const p = this._noteMatrix, _ = p.getValue(c, l);
186
186
  if (d != null && d.show) {
187
- if (!g) {
187
+ if (!_) {
188
188
  const u = this._showPopup(s, a, c, l);
189
189
  u && p.setValue(c, l, u);
190
190
  }
191
191
  } else
192
- g && (g.dispose(), p.realDeleteValue(c, l));
192
+ _ && (_.dispose(), p.realDeleteValue(c, l));
193
193
  };
194
194
  return (o = this._sheetsNoteModel.getSheetNotes(e, n)) == null || o.forValue((s, a, c) => {
195
195
  t(e, n, s, a, c);
@@ -197,12 +197,12 @@ let O = class extends P {
197
197
  if (!(s.unitId !== e || s.sheetId !== n))
198
198
  switch (s.type) {
199
199
  case "ref": {
200
- const { unitId: a, sheetId: c, row: l, col: d, newPosition: p, note: g } = s, u = this._noteMatrix;
201
- if (!g.show) return;
200
+ const { unitId: a, sheetId: c, row: l, col: d, newPosition: p, note: _ } = s, u = this._noteMatrix;
201
+ if (!_.show) return;
202
202
  const h = u.getValue(l, d);
203
203
  h && (h.dispose(), u.realDeleteValue(l, d));
204
- const _ = this._showPopup(a, c, p.row, p.col);
205
- _ && u.setValue(p.row, p.col, _);
204
+ const g = this._showPopup(a, c, p.row, p.col);
205
+ g && u.setValue(p.row, p.col, g);
206
206
  break;
207
207
  }
208
208
  case "update": {
@@ -215,7 +215,7 @@ let O = class extends P {
215
215
  }
216
216
  _initNoteChangeListener() {
217
217
  this.disposeWithMe(
218
- this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_SHEET).pipe(
218
+ this._univerInstanceService.getCurrentTypeOfUnit$(b.UNIVER_SHEET).pipe(
219
219
  Le((e) => {
220
220
  var n;
221
221
  return (n = e == null ? void 0 : e.activeSheet$) != null ? n : se(null);
@@ -235,7 +235,7 @@ let O = class extends P {
235
235
  }
236
236
  };
237
237
  O = st([
238
- w(0, v(b)),
238
+ w(0, v(I)),
239
239
  w(1, v($)),
240
240
  w(2, v(ae)),
241
241
  w(3, v(S))
@@ -244,16 +244,16 @@ var at = Object.getOwnPropertyDescriptor, ct = (i, e, n, r) => {
244
244
  for (var t = r > 1 ? void 0 : r ? at(e, n) : e, o = i.length - 1, s; o >= 0; o--)
245
245
  (s = i[o]) && (t = s(t) || t);
246
246
  return t;
247
- }, C = (i, e) => (n, r) => e(n, r, i);
247
+ }, m = (i, e) => (n, r) => e(n, r, i);
248
248
  let x = class extends P {
249
249
  constructor(e, n, r, t, o, s) {
250
250
  super();
251
- m(this, "_isSwitchingSheet", !1);
251
+ C(this, "_isSwitchingSheet", !1);
252
252
  this._sheetsNotePopupService = e, this._sheetsNoteModel = n, this._sheetSelectionService = r, this._editorBridgeService = t, this._renderManagerService = o, this._hoverManagerService = s, this._initSelectionUpdateListener(), this._initEditorBridge(), this._initHoverEvent();
253
253
  }
254
254
  _handleSelectionChange(e, n, r) {
255
- var g, u, h;
256
- const t = (g = e[0]) == null ? void 0 : g.range, o = this._renderManagerService.getRenderById(n), s = (u = o == null ? void 0 : o.with(je).getSkeletonParam(r)) == null ? void 0 : u.skeleton;
255
+ var _, u, h;
256
+ const t = (_ = e[0]) == null ? void 0 : _.range, o = this._renderManagerService.getRenderById(n), s = (u = o == null ? void 0 : o.with(je).getSkeletonParam(r)) == null ? void 0 : u.skeleton;
257
257
  if (!s || !t)
258
258
  return;
259
259
  const a = s.getCellWithCoordByIndex(t.startRow, t.startColumn);
@@ -303,12 +303,12 @@ let x = class extends P {
303
303
  }
304
304
  };
305
305
  x = ct([
306
- C(0, v(S)),
307
- C(1, v(b)),
308
- C(2, v(A)),
309
- C(3, Ve),
310
- C(4, re),
311
- C(5, v(Re))
306
+ m(0, v(S)),
307
+ m(1, v(I)),
308
+ m(2, v(A)),
309
+ m(3, Ve),
310
+ m(4, re),
311
+ m(5, v(Re))
312
312
  ], x);
313
313
  var f = function() {
314
314
  return f = Object.assign || function(i) {
@@ -384,7 +384,7 @@ const E = {
384
384
  id: "sheet.operation.add-note-popup",
385
385
  type: Ne.OPERATION,
386
386
  handler: async (i, e) => {
387
- const n = i.get(A), r = i.get(S), o = i.get($).getCurrentUnitForType(M.UNIVER_SHEET);
387
+ const n = i.get(A), r = i.get(S), o = i.get($).getCurrentUnitForType(b.UNIVER_SHEET);
388
388
  if (!o)
389
389
  return !1;
390
390
  const s = o.getActiveSheet(), a = n.getCurrentLastSelection();
@@ -400,14 +400,14 @@ const E = {
400
400
  trigger: e == null ? void 0 : e.trigger
401
401
  }), !0;
402
402
  }
403
- }, gt = (i) => {
404
- var g;
405
- const e = j(b), n = j(Pe), r = ke(le), t = (g = i.popup.extraProps) == null ? void 0 : g.location;
403
+ }, _t = (i) => {
404
+ var _;
405
+ const e = j(I), n = j(Pe), r = ke(le), t = (_ = i.popup.extraProps) == null ? void 0 : _.location;
406
406
  if (!t)
407
407
  return console.error("Popup extraProps or location is undefined."), null;
408
408
  const [o, s] = Xe(() => {
409
- var _, N;
410
- const u = { width: ((_ = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : _.width) || 216, height: ((N = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : N.height) || 92, note: "" };
409
+ var g, N;
410
+ const u = { width: ((g = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : g.width) || 216, height: ((N = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : N.height) || 92, note: "" };
411
411
  return e.getNote(t.unitId, t.subUnitId, t.row, t.col) || u;
412
412
  }), a = ue(null), c = j(te), l = et(() => t ? e.getCellNoteChange$(t.unitId, t.subUnitId, t.row, t.col) : se(null), [t]), d = Be((u) => {
413
413
  t && (u.note ? c.executeCommand(Oe.id, {
@@ -436,8 +436,8 @@ const E = {
436
436
  }, [l]), z(() => {
437
437
  const u = a.current;
438
438
  if (!u) return;
439
- const h = new ResizeObserver((_) => {
440
- const N = _[0];
439
+ const h = new ResizeObserver((g) => {
440
+ const N = g[0];
441
441
  if (!N) return;
442
442
  const { width: G, height: K } = N.contentRect;
443
443
  if (G === 0 && K === 0) return;
@@ -449,15 +449,15 @@ const E = {
449
449
  };
450
450
  }, [o.note]);
451
451
  const p = (u) => {
452
- const h = u.target.value, _ = { ...o, note: h };
453
- s(_), d(_);
452
+ const h = u.target.value, g = { ...o, note: h };
453
+ s(g), d(g);
454
454
  };
455
455
  return /* @__PURE__ */ Ye(
456
456
  "textarea",
457
457
  {
458
458
  ref: a,
459
459
  "data-u-comp": "note-textarea",
460
- className: qe("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", Je, Qe),
460
+ className: qe("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", Je, Qe),
461
461
  style: { width: o.width, height: o.height },
462
462
  value: o.note,
463
463
  placeholder: n.t("note.placeholder"),
@@ -473,54 +473,54 @@ function Z(i) {
473
473
  const t = Te(n);
474
474
  if (!t) return !1;
475
475
  const { actualColumn: o, actualRow: s } = r.primary;
476
- return !!i.get(b).getNote(t.unitId, t.subUnitId, s, o);
476
+ return !!i.get(I).getNote(t.unitId, t.subUnitId, s, o);
477
477
  }));
478
478
  }
479
- function _t(i) {
479
+ function gt(i) {
480
480
  return {
481
481
  id: E.id,
482
- type: W.BUTTON,
482
+ type: F.BUTTON,
483
483
  title: "rightClick.addNote",
484
484
  icon: "AddNoteSingle",
485
- hidden$: De([Ae(i, M.UNIVER_SHEET), Z(i)]).pipe(U(([e, n]) => e || n)),
485
+ hidden$: De([Ae(i, b.UNIVER_SHEET), Z(i)]).pipe(U(([e, n]) => e || n)),
486
486
  disabled$: ce(i, { workbookTypes: [oe], worksheetTypes: [ne] }),
487
487
  commandId: E.id
488
488
  };
489
489
  }
490
- function mt(i) {
490
+ function Ct(i) {
491
491
  return {
492
492
  id: B.id,
493
- type: W.BUTTON,
493
+ type: F.BUTTON,
494
494
  title: "rightClick.deleteNote",
495
495
  icon: "DeleteNoteSingle",
496
496
  hidden$: Z(i).pipe(U((e) => !e)),
497
497
  disabled$: ce(i, { workbookTypes: [oe], worksheetTypes: [ne] })
498
498
  };
499
499
  }
500
- function Ct(i) {
500
+ function mt(i) {
501
501
  return {
502
502
  id: ie.id,
503
- type: W.BUTTON,
503
+ type: F.BUTTON,
504
504
  title: "rightClick.toggleNote",
505
505
  icon: "HideNoteSingle",
506
506
  hidden$: Z(i).pipe(U((e) => !e))
507
507
  };
508
508
  }
509
509
  const St = {
510
- [We.MAIN_AREA]: {
511
- [Fe.OTHERS]: {
510
+ [Fe.MAIN_AREA]: {
511
+ [We.OTHERS]: {
512
512
  order: 0,
513
513
  [E.id]: {
514
514
  order: 0,
515
- menuItemFactory: _t
515
+ menuItemFactory: gt
516
516
  },
517
517
  [B.id]: {
518
518
  order: 0,
519
- menuItemFactory: mt
519
+ menuItemFactory: Ct
520
520
  },
521
521
  [ie.id]: {
522
522
  order: 0,
523
- menuItemFactory: Ct
523
+ menuItemFactory: mt
524
524
  }
525
525
  }
526
526
  }
@@ -535,7 +535,16 @@ let H = class extends P {
535
535
  super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._initComponents(), this._initMenu(), this._initCommands();
536
536
  }
537
537
  _initComponents() {
538
- this.disposeWithMe(this._componentManager.register(F, gt)), this.disposeWithMe(this._componentManager.register("AddNoteSingle", he)), this.disposeWithMe(this._componentManager.register("DeleteNoteSingle", de)), this.disposeWithMe(this._componentManager.register("HideNoteSingle", ve));
538
+ [
539
+ [W, _t],
540
+ ["AddNoteSingle", he],
541
+ ["DeleteNoteSingle", de],
542
+ ["HideNoteSingle", ve]
543
+ ].forEach(([i, e]) => {
544
+ this.disposeWithMe(
545
+ this._componentManager.register(i, e)
546
+ );
547
+ });
539
548
  }
540
549
  _initMenu() {
541
550
  this._menuManagerService.mergeMenu(St);
@@ -549,11 +558,11 @@ H = Pt([
549
558
  k(1, v(Ge)),
550
559
  k(2, te)
551
560
  ], H);
552
- var Mt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, It = (i, e, n) => e in i ? Mt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, wt = (i, e, n, r) => {
553
- for (var t = r > 1 ? void 0 : r ? bt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
561
+ var bt = Object.defineProperty, It = Object.getOwnPropertyDescriptor, Mt = (i, e, n) => e in i ? bt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, wt = (i, e, n, r) => {
562
+ for (var t = r > 1 ? void 0 : r ? It(e, n) : e, o = i.length - 1, s; o >= 0; o--)
554
563
  (s = i[o]) && (t = s(t) || t);
555
564
  return t;
556
- }, ee = (i, e) => (n, r) => e(n, r, i), fe = (i, e, n) => It(i, typeof e != "symbol" ? e + "" : e, n);
565
+ }, ee = (i, e) => (n, r) => e(n, r, i), fe = (i, e, n) => Mt(i, typeof e != "symbol" ? e + "" : e, n);
557
566
  const yt = "SHEET_NOTE_UI_PLUGIN";
558
567
  let T = class extends we {
559
568
  constructor(i = Q, e, n) {
@@ -590,15 +599,15 @@ let T = class extends we {
590
599
  }
591
600
  };
592
601
  fe(T, "pluginName", yt);
593
- fe(T, "type", M.UNIVER_SHEET);
602
+ fe(T, "type", b.UNIVER_SHEET);
594
603
  T = wt([
595
- Me(xe),
596
- ee(1, v(be)),
597
- ee(2, Ie)
604
+ be(xe),
605
+ ee(1, v(Ie)),
606
+ ee(2, Me)
598
607
  ], T);
599
608
  export {
600
609
  y as SheetsCellContentController,
601
- gt as SheetsNote,
610
+ _t as SheetsNote,
602
611
  x as SheetsNotePopupController,
603
612
  S as SheetsNotePopupService,
604
613
  T as UniverSheetsNoteUIPlugin
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
@@ -1,13 +1,13 @@
1
- var ge = Object.defineProperty;
2
- var _e = (i, e, n) => e in i ? ge(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
- var m = (i, e, n) => _e(i, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as v, IUniverInstanceService as $, Disposable as P, InterceptorEffectEnum as me, UniverInstanceType as M, DisposableCollection as Ce, ObjectMatrix as R, RANGE_TYPE as q, Rectangle as Se, CommandType as Ne, LocaleService as Pe, ICommandService as te, DependentOn as Me, Injector as be, IConfigService as Ie, Plugin as we, merge as ye, touchDependencies as J } from "@univerjs/core";
5
- import { SheetsNoteModel as b, SheetUpdateNoteCommand as Oe, SheetDeleteNoteCommand as B, SheetToggleNotePopupCommand as ie, UniverSheetsNotePlugin as xe } from "@univerjs/sheets-note";
1
+ var _e = Object.defineProperty;
2
+ var ge = (i, e, n) => e in i ? _e(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
+ var C = (i, e, n) => ge(i, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Inject as v, IUniverInstanceService as $, Disposable as P, InterceptorEffectEnum as Ce, UniverInstanceType as b, DisposableCollection as me, ObjectMatrix as R, RANGE_TYPE as q, Rectangle as Se, CommandType as Ne, LocaleService as Pe, ICommandService as te, DependentOn as be, Injector as Ie, IConfigService as Me, Plugin as we, merge as ye, touchDependencies as J } from "@univerjs/core";
5
+ import { SheetsNoteModel as I, SheetUpdateNoteCommand as Oe, SheetDeleteNoteCommand as B, SheetToggleNotePopupCommand as ie, UniverSheetsNotePlugin as xe } from "@univerjs/sheets-note";
6
6
  import { IRenderManagerService as re } from "@univerjs/engine-render";
7
7
  import { SheetInterceptorService as Ee, INTERCEPTOR_POINT as He, SheetsSelectionsService as A, WorksheetEditPermission as ne, WorkbookEditablePermission as oe, getSheetCommandTarget as Te } from "@univerjs/sheets";
8
8
  import { debounceTime as $e, BehaviorSubject as Ue, switchMap as Le, of as se, map as U, combineLatest as De } from "rxjs";
9
9
  import { CellPopupManagerService as ae, IEditorBridgeService as Ve, HoverManagerService as Re, SheetSkeletonManagerService as je, getCurrentRangeDisable$ as ce } from "@univerjs/sheets-ui";
10
- import { IZenZoneService as ze, useDependency as j, useConfigValue as ke, useDebounceFn as Be, MenuItemType as W, getMenuHiddenObservable as Ae, ContextMenuPosition as We, ContextMenuGroup as Fe, ComponentManager as Ze, IMenuManagerService as Ge } from "@univerjs/ui";
10
+ import { IZenZoneService as ze, useDependency as j, useConfigValue as ke, useDebounceFn as Be, MenuItemType as F, getMenuHiddenObservable as Ae, ContextMenuPosition as Fe, ContextMenuGroup as We, ComponentManager as Ze, IMenuManagerService as Ge } from "@univerjs/ui";
11
11
  import { debounceTime as Ke } from "rxjs/operators";
12
12
  import { jsx as Ye } from "react/jsx-runtime";
13
13
  import { clsx as qe, borderClassName as Je, scrollbarClassName as Qe } from "@univerjs/design";
@@ -17,7 +17,7 @@ var tt = Object.getOwnPropertyDescriptor, it = (i, e, n, r) => {
17
17
  for (var t = r > 1 ? void 0 : r ? tt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
18
18
  (s = i[o]) && (t = s(t) || t);
19
19
  return t;
20
- }, I = (i, e) => (n, r) => e(n, r, i);
20
+ }, M = (i, e) => (n, r) => e(n, r, i);
21
21
  let y = class extends P {
22
22
  constructor(i, e, n, r) {
23
23
  super(), this._sheetInterceptorService = i, this._sheetsNoteModel = e, this._renderManagerService = n, this._univerInstanceService = r, this._initViewModelIntercept(), this._initSkeletonChange();
@@ -27,7 +27,7 @@ let y = class extends P {
27
27
  this._sheetInterceptorService.intercept(
28
28
  He.CELL_CONTENT,
29
29
  {
30
- effect: me.Style,
30
+ effect: Ce.Style,
31
31
  handler: (i, e, n) => {
32
32
  const { row: r, col: t, unitId: o, subUnitId: s } = e;
33
33
  return this._sheetsNoteModel.getNote(o, s, r, t) ? n({
@@ -49,7 +49,7 @@ let y = class extends P {
49
49
  _initSkeletonChange() {
50
50
  const i = () => {
51
51
  var t;
52
- const e = this._univerInstanceService.getCurrentUnitForType(M.UNIVER_SHEET);
52
+ const e = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
53
53
  if (!e) return;
54
54
  const n = e.getUnitId(), r = this._renderManagerService.getRenderById(n);
55
55
  (t = r == null ? void 0 : r.mainComponent) == null || t.makeForceDirty();
@@ -60,12 +60,12 @@ let y = class extends P {
60
60
  }
61
61
  };
62
62
  y = it([
63
- I(0, v(Ee)),
64
- I(1, v(b)),
65
- I(2, re),
66
- I(3, $)
63
+ M(0, v(Ee)),
64
+ M(1, v(I)),
65
+ M(2, re),
66
+ M(3, $)
67
67
  ], y);
68
- const F = "SHEET_NOTE_COMPONENT";
68
+ const W = "SHEET_NOTE_COMPONENT";
69
69
  var rt = Object.getOwnPropertyDescriptor, nt = (i, e, n, r) => {
70
70
  for (var t = r > 1 ? void 0 : r ? rt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
71
71
  (s = i[o]) && (t = s(t) || t);
@@ -74,10 +74,10 @@ var rt = Object.getOwnPropertyDescriptor, nt = (i, e, n, r) => {
74
74
  let S = class extends P {
75
75
  constructor(e, n) {
76
76
  super();
77
- m(this, "_lastPopup", null);
78
- m(this, "_activePopup");
79
- m(this, "_activePopup$", new Ue(null));
80
- m(this, "activePopup$", this._activePopup$.asObservable());
77
+ C(this, "_lastPopup", null);
78
+ C(this, "_activePopup");
79
+ C(this, "_activePopup$", new Ue(null));
80
+ C(this, "activePopup$", this._activePopup$.asObservable());
81
81
  this._zenZoneService = e, this._cellPopupManagerService = n, this._initZenVisible(), this.disposeWithMe(() => {
82
82
  this._activePopup$.complete();
83
83
  });
@@ -108,7 +108,7 @@ let S = class extends P {
108
108
  col: t
109
109
  },
110
110
  {
111
- componentKey: F,
111
+ componentKey: W,
112
112
  onClickOutside: () => {
113
113
  this.hidePopup();
114
114
  },
@@ -121,7 +121,7 @@ let S = class extends P {
121
121
  );
122
122
  if (!a)
123
123
  throw new Error("[SheetsNotePopupService]: cannot show popup!");
124
- const c = new Ce();
124
+ const c = new me();
125
125
  c.add(a), c.add({
126
126
  dispose: () => {
127
127
  n == null || n();
@@ -150,7 +150,7 @@ var ot = Object.getOwnPropertyDescriptor, st = (i, e, n, r) => {
150
150
  let O = class extends P {
151
151
  constructor(e, n, r, t) {
152
152
  super();
153
- m(this, "_noteMatrix", new R());
153
+ C(this, "_noteMatrix", new R());
154
154
  this._sheetsNoteModel = e, this._univerInstanceService = n, this._cellPopupManagerService = r, this._sheetsNotePopupService = t, this._initNoteChangeListener();
155
155
  }
156
156
  _showPopup(e, n, r, t) {
@@ -162,7 +162,7 @@ let O = class extends P {
162
162
  col: t
163
163
  },
164
164
  {
165
- componentKey: F,
165
+ componentKey: W,
166
166
  direction: "horizontal",
167
167
  extraProps: {
168
168
  location: {
@@ -182,14 +182,14 @@ let O = class extends P {
182
182
  c.dispose();
183
183
  }), this._noteMatrix = new R();
184
184
  const t = (s, a, c, l, d) => {
185
- const p = this._noteMatrix, g = p.getValue(c, l);
185
+ const p = this._noteMatrix, _ = p.getValue(c, l);
186
186
  if (d != null && d.show) {
187
- if (!g) {
187
+ if (!_) {
188
188
  const u = this._showPopup(s, a, c, l);
189
189
  u && p.setValue(c, l, u);
190
190
  }
191
191
  } else
192
- g && (g.dispose(), p.realDeleteValue(c, l));
192
+ _ && (_.dispose(), p.realDeleteValue(c, l));
193
193
  };
194
194
  return (o = this._sheetsNoteModel.getSheetNotes(e, n)) == null || o.forValue((s, a, c) => {
195
195
  t(e, n, s, a, c);
@@ -197,12 +197,12 @@ let O = class extends P {
197
197
  if (!(s.unitId !== e || s.sheetId !== n))
198
198
  switch (s.type) {
199
199
  case "ref": {
200
- const { unitId: a, sheetId: c, row: l, col: d, newPosition: p, note: g } = s, u = this._noteMatrix;
201
- if (!g.show) return;
200
+ const { unitId: a, sheetId: c, row: l, col: d, newPosition: p, note: _ } = s, u = this._noteMatrix;
201
+ if (!_.show) return;
202
202
  const h = u.getValue(l, d);
203
203
  h && (h.dispose(), u.realDeleteValue(l, d));
204
- const _ = this._showPopup(a, c, p.row, p.col);
205
- _ && u.setValue(p.row, p.col, _);
204
+ const g = this._showPopup(a, c, p.row, p.col);
205
+ g && u.setValue(p.row, p.col, g);
206
206
  break;
207
207
  }
208
208
  case "update": {
@@ -215,7 +215,7 @@ let O = class extends P {
215
215
  }
216
216
  _initNoteChangeListener() {
217
217
  this.disposeWithMe(
218
- this._univerInstanceService.getCurrentTypeOfUnit$(M.UNIVER_SHEET).pipe(
218
+ this._univerInstanceService.getCurrentTypeOfUnit$(b.UNIVER_SHEET).pipe(
219
219
  Le((e) => {
220
220
  var n;
221
221
  return (n = e == null ? void 0 : e.activeSheet$) != null ? n : se(null);
@@ -235,7 +235,7 @@ let O = class extends P {
235
235
  }
236
236
  };
237
237
  O = st([
238
- w(0, v(b)),
238
+ w(0, v(I)),
239
239
  w(1, v($)),
240
240
  w(2, v(ae)),
241
241
  w(3, v(S))
@@ -244,16 +244,16 @@ var at = Object.getOwnPropertyDescriptor, ct = (i, e, n, r) => {
244
244
  for (var t = r > 1 ? void 0 : r ? at(e, n) : e, o = i.length - 1, s; o >= 0; o--)
245
245
  (s = i[o]) && (t = s(t) || t);
246
246
  return t;
247
- }, C = (i, e) => (n, r) => e(n, r, i);
247
+ }, m = (i, e) => (n, r) => e(n, r, i);
248
248
  let x = class extends P {
249
249
  constructor(e, n, r, t, o, s) {
250
250
  super();
251
- m(this, "_isSwitchingSheet", !1);
251
+ C(this, "_isSwitchingSheet", !1);
252
252
  this._sheetsNotePopupService = e, this._sheetsNoteModel = n, this._sheetSelectionService = r, this._editorBridgeService = t, this._renderManagerService = o, this._hoverManagerService = s, this._initSelectionUpdateListener(), this._initEditorBridge(), this._initHoverEvent();
253
253
  }
254
254
  _handleSelectionChange(e, n, r) {
255
- var g, u, h;
256
- const t = (g = e[0]) == null ? void 0 : g.range, o = this._renderManagerService.getRenderById(n), s = (u = o == null ? void 0 : o.with(je).getSkeletonParam(r)) == null ? void 0 : u.skeleton;
255
+ var _, u, h;
256
+ const t = (_ = e[0]) == null ? void 0 : _.range, o = this._renderManagerService.getRenderById(n), s = (u = o == null ? void 0 : o.with(je).getSkeletonParam(r)) == null ? void 0 : u.skeleton;
257
257
  if (!s || !t)
258
258
  return;
259
259
  const a = s.getCellWithCoordByIndex(t.startRow, t.startColumn);
@@ -303,12 +303,12 @@ let x = class extends P {
303
303
  }
304
304
  };
305
305
  x = ct([
306
- C(0, v(S)),
307
- C(1, v(b)),
308
- C(2, v(A)),
309
- C(3, Ve),
310
- C(4, re),
311
- C(5, v(Re))
306
+ m(0, v(S)),
307
+ m(1, v(I)),
308
+ m(2, v(A)),
309
+ m(3, Ve),
310
+ m(4, re),
311
+ m(5, v(Re))
312
312
  ], x);
313
313
  var f = function() {
314
314
  return f = Object.assign || function(i) {
@@ -384,7 +384,7 @@ const E = {
384
384
  id: "sheet.operation.add-note-popup",
385
385
  type: Ne.OPERATION,
386
386
  handler: async (i, e) => {
387
- const n = i.get(A), r = i.get(S), o = i.get($).getCurrentUnitForType(M.UNIVER_SHEET);
387
+ const n = i.get(A), r = i.get(S), o = i.get($).getCurrentUnitForType(b.UNIVER_SHEET);
388
388
  if (!o)
389
389
  return !1;
390
390
  const s = o.getActiveSheet(), a = n.getCurrentLastSelection();
@@ -400,14 +400,14 @@ const E = {
400
400
  trigger: e == null ? void 0 : e.trigger
401
401
  }), !0;
402
402
  }
403
- }, gt = (i) => {
404
- var g;
405
- const e = j(b), n = j(Pe), r = ke(le), t = (g = i.popup.extraProps) == null ? void 0 : g.location;
403
+ }, _t = (i) => {
404
+ var _;
405
+ const e = j(I), n = j(Pe), r = ke(le), t = (_ = i.popup.extraProps) == null ? void 0 : _.location;
406
406
  if (!t)
407
407
  return console.error("Popup extraProps or location is undefined."), null;
408
408
  const [o, s] = Xe(() => {
409
- var _, N;
410
- const u = { width: ((_ = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : _.width) || 216, height: ((N = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : N.height) || 92, note: "" };
409
+ var g, N;
410
+ const u = { width: ((g = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : g.width) || 216, height: ((N = r == null ? void 0 : r.defaultNoteSize) == null ? void 0 : N.height) || 92, note: "" };
411
411
  return e.getNote(t.unitId, t.subUnitId, t.row, t.col) || u;
412
412
  }), a = ue(null), c = j(te), l = et(() => t ? e.getCellNoteChange$(t.unitId, t.subUnitId, t.row, t.col) : se(null), [t]), d = Be((u) => {
413
413
  t && (u.note ? c.executeCommand(Oe.id, {
@@ -436,8 +436,8 @@ const E = {
436
436
  }, [l]), z(() => {
437
437
  const u = a.current;
438
438
  if (!u) return;
439
- const h = new ResizeObserver((_) => {
440
- const N = _[0];
439
+ const h = new ResizeObserver((g) => {
440
+ const N = g[0];
441
441
  if (!N) return;
442
442
  const { width: G, height: K } = N.contentRect;
443
443
  if (G === 0 && K === 0) return;
@@ -449,15 +449,15 @@ const E = {
449
449
  };
450
450
  }, [o.note]);
451
451
  const p = (u) => {
452
- const h = u.target.value, _ = { ...o, note: h };
453
- s(_), d(_);
452
+ const h = u.target.value, g = { ...o, note: h };
453
+ s(g), d(g);
454
454
  };
455
455
  return /* @__PURE__ */ Ye(
456
456
  "textarea",
457
457
  {
458
458
  ref: a,
459
459
  "data-u-comp": "note-textarea",
460
- className: qe("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", Je, Qe),
460
+ className: qe("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", Je, Qe),
461
461
  style: { width: o.width, height: o.height },
462
462
  value: o.note,
463
463
  placeholder: n.t("note.placeholder"),
@@ -473,54 +473,54 @@ function Z(i) {
473
473
  const t = Te(n);
474
474
  if (!t) return !1;
475
475
  const { actualColumn: o, actualRow: s } = r.primary;
476
- return !!i.get(b).getNote(t.unitId, t.subUnitId, s, o);
476
+ return !!i.get(I).getNote(t.unitId, t.subUnitId, s, o);
477
477
  }));
478
478
  }
479
- function _t(i) {
479
+ function gt(i) {
480
480
  return {
481
481
  id: E.id,
482
- type: W.BUTTON,
482
+ type: F.BUTTON,
483
483
  title: "rightClick.addNote",
484
484
  icon: "AddNoteSingle",
485
- hidden$: De([Ae(i, M.UNIVER_SHEET), Z(i)]).pipe(U(([e, n]) => e || n)),
485
+ hidden$: De([Ae(i, b.UNIVER_SHEET), Z(i)]).pipe(U(([e, n]) => e || n)),
486
486
  disabled$: ce(i, { workbookTypes: [oe], worksheetTypes: [ne] }),
487
487
  commandId: E.id
488
488
  };
489
489
  }
490
- function mt(i) {
490
+ function Ct(i) {
491
491
  return {
492
492
  id: B.id,
493
- type: W.BUTTON,
493
+ type: F.BUTTON,
494
494
  title: "rightClick.deleteNote",
495
495
  icon: "DeleteNoteSingle",
496
496
  hidden$: Z(i).pipe(U((e) => !e)),
497
497
  disabled$: ce(i, { workbookTypes: [oe], worksheetTypes: [ne] })
498
498
  };
499
499
  }
500
- function Ct(i) {
500
+ function mt(i) {
501
501
  return {
502
502
  id: ie.id,
503
- type: W.BUTTON,
503
+ type: F.BUTTON,
504
504
  title: "rightClick.toggleNote",
505
505
  icon: "HideNoteSingle",
506
506
  hidden$: Z(i).pipe(U((e) => !e))
507
507
  };
508
508
  }
509
509
  const St = {
510
- [We.MAIN_AREA]: {
511
- [Fe.OTHERS]: {
510
+ [Fe.MAIN_AREA]: {
511
+ [We.OTHERS]: {
512
512
  order: 0,
513
513
  [E.id]: {
514
514
  order: 0,
515
- menuItemFactory: _t
515
+ menuItemFactory: gt
516
516
  },
517
517
  [B.id]: {
518
518
  order: 0,
519
- menuItemFactory: mt
519
+ menuItemFactory: Ct
520
520
  },
521
521
  [ie.id]: {
522
522
  order: 0,
523
- menuItemFactory: Ct
523
+ menuItemFactory: mt
524
524
  }
525
525
  }
526
526
  }
@@ -535,7 +535,16 @@ let H = class extends P {
535
535
  super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._initComponents(), this._initMenu(), this._initCommands();
536
536
  }
537
537
  _initComponents() {
538
- this.disposeWithMe(this._componentManager.register(F, gt)), this.disposeWithMe(this._componentManager.register("AddNoteSingle", he)), this.disposeWithMe(this._componentManager.register("DeleteNoteSingle", de)), this.disposeWithMe(this._componentManager.register("HideNoteSingle", ve));
538
+ [
539
+ [W, _t],
540
+ ["AddNoteSingle", he],
541
+ ["DeleteNoteSingle", de],
542
+ ["HideNoteSingle", ve]
543
+ ].forEach(([i, e]) => {
544
+ this.disposeWithMe(
545
+ this._componentManager.register(i, e)
546
+ );
547
+ });
539
548
  }
540
549
  _initMenu() {
541
550
  this._menuManagerService.mergeMenu(St);
@@ -549,11 +558,11 @@ H = Pt([
549
558
  k(1, v(Ge)),
550
559
  k(2, te)
551
560
  ], H);
552
- var Mt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, It = (i, e, n) => e in i ? Mt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, wt = (i, e, n, r) => {
553
- for (var t = r > 1 ? void 0 : r ? bt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
561
+ var bt = Object.defineProperty, It = Object.getOwnPropertyDescriptor, Mt = (i, e, n) => e in i ? bt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, wt = (i, e, n, r) => {
562
+ for (var t = r > 1 ? void 0 : r ? It(e, n) : e, o = i.length - 1, s; o >= 0; o--)
554
563
  (s = i[o]) && (t = s(t) || t);
555
564
  return t;
556
- }, ee = (i, e) => (n, r) => e(n, r, i), fe = (i, e, n) => It(i, typeof e != "symbol" ? e + "" : e, n);
565
+ }, ee = (i, e) => (n, r) => e(n, r, i), fe = (i, e, n) => Mt(i, typeof e != "symbol" ? e + "" : e, n);
557
566
  const yt = "SHEET_NOTE_UI_PLUGIN";
558
567
  let T = class extends we {
559
568
  constructor(i = Q, e, n) {
@@ -590,15 +599,15 @@ let T = class extends we {
590
599
  }
591
600
  };
592
601
  fe(T, "pluginName", yt);
593
- fe(T, "type", M.UNIVER_SHEET);
602
+ fe(T, "type", b.UNIVER_SHEET);
594
603
  T = wt([
595
- Me(xe),
596
- ee(1, v(be)),
597
- ee(2, Ie)
604
+ be(xe),
605
+ ee(1, v(Ie)),
606
+ ee(2, Me)
598
607
  ], T);
599
608
  export {
600
609
  y as SheetsCellContentController,
601
- gt as SheetsNote,
610
+ _t as SheetsNote,
602
611
  x as SheetsNotePopupController,
603
612
  S as SheetsNotePopupService,
604
613
  T as UniverSheetsNoteUIPlugin
@@ -1,3 +1,26 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ declare const locale: {
17
+ rightClick: {
18
+ addNote: string;
19
+ deleteNote: string;
20
+ toggleNote: string;
21
+ };
22
+ note: {
23
+ placeholder: string;
24
+ };
25
+ };
3
26
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,26 +1,3 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- declare const locale: {
17
- rightClick: {
18
- addNote: string;
19
- deleteNote: string;
20
- toggleNote: string;
21
- };
22
- note: {
23
- placeholder: string;
24
- };
25
- };
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
26
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (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"})});
1
+ (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,_,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,i,n)=>{for(var e=n>1?void 0:n?ee(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},E=(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=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 ne=Object.getOwnPropertyDescriptor,ie=(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},z=(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=ie([z(0,_.IZenZoneService),z(1,s.Inject(M.CellPopupManagerService))],u.SheetsNotePopupService);var re=Object.getOwnPropertyDescriptor,oe=(r,t,i,n)=>{for(var e=n>1?void 0:n?re(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);let U=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 S=this._noteMatrix,C=S.getValue(l,d);if(v!=null&&v.show){if(!C){const p=this._showPopup(a,c,l,d);p&&S.setValue(l,d,p)}}else C&&(C.dispose(),S.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:S,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,S.row,S.col);m&&p.setValue(S.row,S.col,m);break}case"update":{const{unitId:c,sheetId:l,row:d,col:v,note:S}=a;e(c,l,d,v,S);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}))}};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,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},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,S=l.actualColumn,C=this._sheetsNoteModel.getNote(n,e,v,S);C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:e,row:v,col:S}):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(Q.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=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,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)},ue=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},T=g.forwardRef(function(r,t){var i=r.icon,n=r.id,e=r.className,o=r.extend,a=ue(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(e||"").trim(),l=g.useRef("_".concat(pe()));return A(i,"".concat(n),{defIds:i.defIds,idSuffix:l.current},P({ref:t,className:c},a),o)});function A(r,t,i,n,e){return g.createElement(r.tag,P(P({key:t},ce(r,i,e)),n),(le(r,i).children||[]).map(function(o,a){return A(o,"".concat(t,"-").concat(r.tag,"-").concat(a),i,void 0,e)}))}function ce(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 le(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 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"}}]},F=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"delete-note-single",ref:t,icon:de}))});F.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"}}]},W=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"hide-note-single",ref:t,icon:ve}))});W.displayName="HideNoteSingle";const j={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}},q=r=>{var C;const t=_.useDependency(h.SheetsNoteModel),i=_.useDependency(s.LocaleService),n=_.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=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=_.useDependency(s.ICommandService),d=g.useMemo(()=>e?t.getCellNoteChange$(e.unitId,e.subUnitId,e.row,e.col):I.of(null),[e]),v=_.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 S=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:i.t("note.placeholder"),onChange:S})};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 fe(r){return{id:j.id,type:_.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:I.combineLatest([_.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:j.id}}function ge(r){return{id:h.SheetDeleteNoteCommand.id,type:_.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 Se(r){return{id:h.SheetToggleNotePopupCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:x(r).pipe(I.map(t=>!t))}}const _e={[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.OTHERS]:{order:0,[j.id]:{order:0,menuItemFactory:fe},[h.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:ge},[h.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};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(){[[D,q],["AddNoteSingle",B],["DeleteNoteSingle",F],["HideNoteSingle",W]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}_initMenu(){this._menuManagerService.mergeMenu(_e)}_initCommands(){this._commandService.registerCommand(j)}};H=me([R(0,s.Inject(_.ComponentManager)),R(1,s.Inject(_.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},Z=(r,t)=>(i,n)=>t(i,n,r),G=(r,t,i)=>Ie(r,typeof t!="symbol"?t+"":t,i);const be="SHEET_NOTE_UI_PLUGIN";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(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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-note-ui",
3
- "version": "0.7.0",
3
+ "version": "0.8.0-beta.0",
4
4
  "private": false,
5
5
  "description": "Univer sheets note UI plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,13 +52,13 @@
52
52
  "dependencies": {
53
53
  "@univerjs/icons": "^0.3.24",
54
54
  "rxjs": "^7.8.2",
55
- "@univerjs/core": "0.7.0",
56
- "@univerjs/design": "0.7.0",
57
- "@univerjs/engine-render": "0.7.0",
58
- "@univerjs/sheets": "0.7.0",
59
- "@univerjs/sheets-ui": "0.7.0",
60
- "@univerjs/ui": "0.7.0",
61
- "@univerjs/sheets-note": "0.7.0"
55
+ "@univerjs/design": "0.8.0-beta.0",
56
+ "@univerjs/core": "0.8.0-beta.0",
57
+ "@univerjs/sheets": "0.8.0-beta.0",
58
+ "@univerjs/sheets-note": "0.8.0-beta.0",
59
+ "@univerjs/sheets-ui": "0.8.0-beta.0",
60
+ "@univerjs/engine-render": "0.8.0-beta.0",
61
+ "@univerjs/ui": "0.8.0-beta.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/react": "^18.0.15",
@@ -67,7 +67,7 @@
67
67
  "tailwindcss": "^3.4.17",
68
68
  "typescript": "^5.8.3",
69
69
  "vite": "^6.3.5",
70
- "vitest": "^3.1.3"
70
+ "vitest": "^3.1.4"
71
71
  },
72
72
  "scripts": {
73
73
  "test": "vitest run",