@univerjs/sheets-note-ui 0.15.5 → 0.16.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 +1 -1
- package/lib/es/index.js +89 -88
- package/lib/index.js +89 -88
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ce=Object.defineProperty;var ae=(o,t,e)=>t in o?ce(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var U=(o,t,e)=>ae(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),k=require("@univerjs/engine-render"),M=require("@univerjs/sheets"),N=require("@univerjs/sheets-note"),w=require("rxjs"),E=require("@univerjs/sheets-ui"),ue=require("rxjs/operators"),_=require("@univerjs/ui"),f=require("react"),le=require("react/jsx-runtime"),Y=require("@univerjs/design");var pe=Object.getOwnPropertyDescriptor,he=(o,t,e,i)=>{for(var n=i>1?void 0:i?pe(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},T=(o,t)=>(e,i)=>t(e,i,o);exports.SheetsCellContentController=class extends c.Disposable{constructor(t,e,i,n){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._renderManagerService=i,this._univerInstanceService=n,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(M.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(t,e,i)=>{const{row:n,col:r,unitId:s,subUnitId:u}=e;return this._sheetsNoteModel.getNote(s,u,{row:n,col:r})&&((!t||t===e.rawData)&&(t={...e.rawData}),t.markers={...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}),i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var r;const e=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return;const i=e.getUnitId(),n=this._renderManagerService.getRenderById(i);(r=n==null?void 0:n.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(w.debounceTime(16)).subscribe(()=>{t()}))}};exports.SheetsCellContentController=he([T(0,c.Inject(M.SheetInterceptorService)),T(1,c.Inject(N.SheetsNoteModel)),T(2,k.IRenderManagerService),T(3,c.IUniverInstanceService)],exports.SheetsCellContentController);const Z="SHEET_NOTE_COMPONENT";var de=Object.getOwnPropertyDescriptor,Ce=(o,t,e,i)=>{for(var n=i>1?void 0:i?de(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},J=(o,t)=>(e,i)=>t(e,i,o);exports.SheetsNotePopupService=class extends c.Disposable{constructor(e,i){super();U(this,"_lastPopup",null);U(this,"_activePopup");U(this,"_activePopup$",new w.BehaviorSubject(null));U(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(e,i){var l;const{row:n,col:r,unitId:s,subUnitId:u}=e;if(this._activePopup&&n===this._activePopup.row&&r===this._activePopup.col&&s===this._activePopup.unitId&&u===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=e,this._activePopup$.next(e);const a=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:u,row:n,col:r},{componentKey:Z,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:e},priority:3});if(!a)throw new Error("[SheetsNotePopupService]: cannot show popup!");const h=new c.DisposableCollection;h.add(a),h.add({dispose:()=>{i==null||i()}}),this._lastPopup=h}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsNotePopupService=Ce([J(0,_.IZenZoneService),J(1,c.Inject(E.CellPopupManagerService))],exports.SheetsNotePopupService);var ve=Object.getOwnPropertyDescriptor,_e=(o,t,e,i)=>{for(var n=i>1?void 0:i?ve(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},$=(o,t)=>(e,i)=>t(e,i,o);exports.SheetsNotePopupController=class extends c.Disposable{constructor(e,i,n,r,s,u){super();U(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=e,this._sheetsNoteModel=i,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=s,this._hoverManagerService=u,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,i,n){var g,I,P;const r=(g=e[0])==null?void 0:g.range,s=this._renderManagerService.getRenderById(i),u=(I=s==null?void 0:s.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:I.skeleton;if(!u||!r)return;const a=u.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((P=r.rangeType)!=null?P:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._sheetsNotePopupService.hidePopup();return}const l=a.actualRow,p=a.actualColumn,C=this._sheetsNoteModel.getNote(i,n,{row:l,col:p});C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:C.id,row:l,col:p}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(e,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ue.debounceTime(100)).subscribe(e=>{var C;if(!(e!=null&&e.location))return;const{unitId:i,subUnitId:n,row:r,col:s}=e.location,u=this._renderManagerService.getRenderById(i),a=(C=u==null?void 0:u.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:C.skeleton;let h=r,l=s,p=this._sheetsNoteModel.getNote(i,n,{row:h,col:l});if(!p&&a){const g=a.getCellWithCoordByIndex(r,s),{startRow:I,endRow:P,startColumn:b,endColumn:d}=g.mergeInfo;if(I!==P||b!==d){const v=this._sheetsNoteModel.getSheetNotes(i,n);if(v){for(const[y,S]of v)if(S.row>=I&&S.row<=P&&S.col>=b&&S.col<=d){p=S,h=S.row,l=S.col;break}}}}p!=null&&p.show||(p?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:p.id,row:h,col:l,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;const{unitId:i,subUnitId:n,noteId:r,row:s,col:u}=this._sheetsNotePopupService.activePopup,{oldNote:a,newNote:h}=e;h===null&&e.unitId===i&&e.subUnitId===n&&(a!=null&&a.id&&a.id===r||(a==null?void 0:a.row)===s&&a.col===u)&&this._sheetsNotePopupService.hidePopup(!0)}))}};exports.SheetsNotePopupController=_e([$(0,c.Inject(exports.SheetsNotePopupService)),$(1,c.Inject(N.SheetsNoteModel)),$(2,c.Inject(M.SheetsSelectionsService)),$(3,E.IEditorBridgeService),$(4,k.IRenderManagerService),$(5,c.Inject(E.HoverManagerService))],exports.SheetsNotePopupController);const ee="sheets-note-ui.config",Q={};var ge=Object.getOwnPropertyDescriptor,fe=(o,t,e,i)=>{for(var n=i>1?void 0:i?ge(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},O=(o,t)=>(e,i)=>t(e,i,o);let H=class extends c.Disposable{constructor(t,e,i,n){super();U(this,"_noteMatrix",new c.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=e,this._cellPopupManagerService=i,this._sheetsNotePopupService=n,this._initNoteChangeListener()}_showPopup(t,e,i,n){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:e,row:i,col:n},{componentKey:Z,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:e,row:i,col:n}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((t,e,i)=>{i.dispose()})}_initSheet(t,e){var r;this._noteMatrix.forValue((s,u,a)=>{a.dispose()}),this._noteMatrix=new c.ObjectMatrix;const n=(s,u,a,h,l)=>{const p=this._noteMatrix,C=p.getValue(a,h);if(l!=null&&l.show){if(!C){const g=this._showPopup(s,u,a,h);g&&p.setValue(a,h,g)}}else C&&(C.dispose(),p.realDeleteValue(a,h))};return(r=this._sheetsNoteModel.getSheetNotes(t,e))==null||r.forEach(s=>{n(t,e,s.row,s.col,s)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==t||s.subUnitId!==e))switch(s.type){case"ref":{const{unitId:u,subUnitId:a,oldNote:h,newNote:l}=s;if(!l.show)return;const p=this._noteMatrix,{row:C,col:g}=h,{row:I,col:P}=l,b=p.getValue(C,g);b&&(b.dispose(),p.realDeleteValue(C,g));const d=this._showPopup(u,a,I,P);d&&p.setValue(I,P,d);break}case"update":{const{unitId:u,subUnitId:a,oldNote:h,newNote:l}=s,p=l?l.row:h.row,C=l?l.col:h.col;n(u,a,p,C,l);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(w.switchMap(t=>{var e;return(e=t==null?void 0:t.activeSheet$)!=null?e:w.of(null)})).subscribe(t=>{if(t){const e=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{e.unsubscribe()}}else this._noteMatrix.forValue((e,i,n)=>{n.dispose()}),this._noteMatrix=new c.ObjectMatrix}))}};H=fe([O(0,c.Inject(N.SheetsNoteModel)),O(1,c.Inject(c.IUniverInstanceService)),O(2,c.Inject(E.CellPopupManagerService)),O(3,c.Inject(exports.SheetsNotePopupService))],H);function L({ref:o,...t}){const{icon:e,id:i,className:n,extend:r,...s}=t,u=`univerjs-icon univerjs-icon-${i} ${n||""}`.trim(),a=f.useRef(`_${Ne()}`);return te(e,`${i}`,{defIds:e.defIds,idSuffix:a.current},{ref:o,className:u,...s},r)}function te(o,t,e,i,n){return f.createElement(o.tag,{key:t,...Se(o,e,n),...i},(me(o,e).children||[]).map((r,s)=>te(r,`${t}-${o.tag}-${s}`,e,void 0,n)))}function Se(o,t,e){const i={...o.attrs};e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1),o.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(([r,s])=>{r==="mask"&&typeof s=="string"&&(i[r]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:n}=t;return!n||n.length===0||(o.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(([r,s])=>{typeof s=="string"&&(i[r]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),i}function me(o,t){var i;const{defIds:e}=t;return!e||e.length===0?o:o.tag==="defs"&&((i=o.children)!=null&&i.length)?{...o,children:o.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+t.idSuffix}}:n)}:o}function Ne(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";const Ie={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},ie=f.forwardRef(function(t,e){return f.createElement(L,Object.assign({},t,{id:"add-note-icon",ref:e,icon:Ie}))});ie.displayName="AddNoteIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"}}]},oe=f.forwardRef(function(t,e){return f.createElement(L,Object.assign({},t,{id:"delete-note-icon",ref:e,icon:Pe}))});oe.displayName="DeleteNoteIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},ne=f.forwardRef(function(t,e){return f.createElement(L,Object.assign({},t,{id:"hide-note-icon",ref:e,icon:Me}))});ne.displayName="HideNoteIcon";const D={id:"sheet.operation.add-note-popup",type:c.CommandType.OPERATION,handler:async(o,t)=>{var h;const e=o.get(M.SheetsSelectionsService),i=o.get(exports.SheetsNotePopupService),r=o.get(c.IUniverInstanceService).getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!r)return!1;const s=r.getActiveSheet(),u=e.getCurrentLastSelection();if(!(u!=null&&u.primary))return!1;const{primary:a}=u;return i.showPopup({unitId:r.getUnitId(),subUnitId:s.getSheetId(),row:a.actualRow,col:a.actualColumn,temp:!1,trigger:(h=t==null?void 0:t.trigger)!=null?h:"add-note"}),!0}},re=o=>{var b;const{popup:t}=o,e=_.useDependency(N.SheetsNoteModel),i=_.useDependency(c.LocaleService),n=_.useDependency(k.IRenderManagerService),r=_.useDependency(exports.SheetsNotePopupService),s=_.useConfigValue(ee),u=(b=t.extraProps)==null?void 0:b.location;if(!u)return console.error("Popup extraProps or location is undefined."),null;const a=f.useRef(null),h=n.getRenderById(u.unitId),[l,p]=f.useState(null);f.useEffect(()=>{var B,W,F,q,z,G;const{unitId:d,subUnitId:v,row:y,col:S}=u,m=e.getNote(d,v,{row:y,col:S}),j=(F=(W=m==null?void 0:m.width)!=null?W:(B=s==null?void 0:s.defaultNoteSize)==null?void 0:B.width)!=null?F:160,x=(G=(z=m==null?void 0:m.height)!=null?z:(q=s==null?void 0:s.defaultNoteSize)==null?void 0:q.height)!=null?G:72;if(m)p(m);else{const K={width:j,height:x,note:""};p(K),g(K)}a.current&&(a.current.style.width=`${j}px`,a.current.style.height=`${x}px`)},[u,a]),f.useEffect(()=>{if(!u||u.temp||!u.trigger||!a.current)return;const d=requestAnimationFrame(()=>{var v;(v=a.current)==null||v.focus()});return()=>cancelAnimationFrame(d)},[u]);const C=_.useDependency(c.ICommandService),g=_.useDebounceFn(d=>{if(!u)return;const{unitId:v,subUnitId:y,row:S,col:m}=u;if(!C.syncExecuteCommand(N.SheetUpdateNoteCommand.id,{unitId:v,sheetId:y,row:S,col:m,note:d})){const x=e.getNote(v,y,{noteId:d.id,row:S,col:m});x?p(x):r.hidePopup(!0)}}),I=f.useCallback(d=>{if(!l||d===l.note)return;const v={...l,note:d};p(v),g(v)},[l]),P=f.useCallback((d,v)=>{if(!l||d===l.width&&v===l.height)return;const y={...l,width:d,height:v};p(y),g(y)},[l]);return le.jsx(Y.Textarea,{ref:a,"data-u-comp":"note-textarea",className:Y.clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),value:l==null?void 0:l.note,placeholder:i.t("note.placeholder"),onResize:P,onValueChange:I,onWheel:d=>{document.activeElement!==a.current&&h.engine.getCanvasElement().dispatchEvent(new WheelEvent(d.type,d.nativeEvent))}})};function A(o){const t=o.get(M.SheetsSelectionsService),e=o.get(c.IUniverInstanceService);return t.selectionMoveEnd$.pipe(w.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const n=M.getSheetCommandTarget(e);if(!n)return!1;const{actualColumn:r,actualRow:s}=i.primary;return!!o.get(N.SheetsNoteModel).getNote(n.unitId,n.subUnitId,{row:s,col:r})}))}function we(o){return{id:D.id,type:_.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:w.combineLatest([_.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),A(o)]).pipe(w.map(([t,e])=>t||e)),disabled$:E.getCurrentRangeDisable$(o,{workbookTypes:[M.WorkbookEditablePermission],worksheetTypes:[M.WorksheetEditPermission]}),commandId:D.id}}function be(o){return{id:N.SheetDeleteNoteCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:A(o).pipe(w.map(t=>!t)),disabled$:E.getCurrentRangeDisable$(o,{workbookTypes:[M.WorkbookEditablePermission],worksheetTypes:[M.WorksheetEditPermission]})}}function ye(o){return{id:N.SheetToggleNotePopupCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:A(o).pipe(w.map(t=>!t))}}const Ee={[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.OTHERS]:{order:0,[D.id]:{order:0,menuItemFactory:we},[N.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:be},[N.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:ye}}}};var Ue=Object.getOwnPropertyDescriptor,$e=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ue(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},V=(o,t)=>(e,i)=>t(e,i,o);let R=class extends c.Disposable{constructor(o,t,e){super(),this._componentManager=o,this._menuManagerService=t,this._commandService=e,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[Z,re],["AddNoteIcon",ie],["DeleteNoteIcon",oe],["HideNoteIcon",ne]].forEach(([o,t])=>{this.disposeWithMe(this._componentManager.register(o,t))})}_initMenu(){this._menuManagerService.mergeMenu(Ee)}_initCommands(){this._commandService.registerCommand(D)}};R=$e([V(0,c.Inject(_.ComponentManager)),V(1,c.Inject(_.IMenuManagerService)),V(2,c.ICommandService)],R);var xe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Oe=(o,t,e)=>t in o?xe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,He=(o,t,e,i)=>{for(var n=i>1?void 0:i?Te(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},X=(o,t)=>(e,i)=>t(e,i,o),se=(o,t,e)=>Oe(o,typeof t!="symbol"?t+"":t,e);const De="SHEET_NOTE_UI_PLUGIN";exports.UniverSheetsNoteUIPlugin=class extends c.Plugin{constructor(t=Q,e,i){super(),this._config=t,this._injector=e,this._configService=i;const{menu:n,...r}=c.merge({},Q,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(ee,r)}onStarting(){[[exports.SheetsNotePopupService],[exports.SheetsCellContentController],[exports.SheetsNotePopupController],[R],[H]].forEach(t=>{this._injector.add(t)})}onReady(){c.touchDependencies(this._injector,[[R],[exports.SheetsCellContentController]])}onRendered(){c.touchDependencies(this._injector,[[exports.SheetsNotePopupController],[H]])}};se(exports.UniverSheetsNoteUIPlugin,"pluginName",De);se(exports.UniverSheetsNoteUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNoteUIPlugin=He([c.DependentOn(N.UniverSheetsNotePlugin),X(1,c.Inject(c.Injector)),X(2,c.IConfigService)],exports.UniverSheetsNoteUIPlugin);exports.SheetsNote=re;
|
|
1
|
+
"use strict";var ce=Object.defineProperty;var ae=(o,t,e)=>t in o?ce(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var U=(o,t,e)=>ae(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),k=require("@univerjs/engine-render"),M=require("@univerjs/sheets"),N=require("@univerjs/sheets-note"),w=require("rxjs"),E=require("@univerjs/sheets-ui"),ue=require("rxjs/operators"),_=require("@univerjs/ui"),f=require("react"),le=require("react/jsx-runtime"),Y=require("@univerjs/design");var pe=Object.getOwnPropertyDescriptor,he=(o,t,e,i)=>{for(var n=i>1?void 0:i?pe(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},T=(o,t)=>(e,i)=>t(e,i,o);exports.SheetsCellContentController=class extends c.Disposable{constructor(t,e,i,n){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._renderManagerService=i,this._univerInstanceService=n,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(M.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(t,e,i)=>{const{row:n,col:r,unitId:s,subUnitId:u}=e;return this._sheetsNoteModel.getNote(s,u,{row:n,col:r})&&((!t||t===e.rawData)&&(t={...e.rawData}),t.markers={...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}),i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var r;const e=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return;const i=e.getUnitId(),n=this._renderManagerService.getRenderById(i);(r=n==null?void 0:n.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(w.debounceTime(16)).subscribe(()=>{t()}))}};exports.SheetsCellContentController=he([T(0,c.Inject(M.SheetInterceptorService)),T(1,c.Inject(N.SheetsNoteModel)),T(2,k.IRenderManagerService),T(3,c.IUniverInstanceService)],exports.SheetsCellContentController);const Z="SHEET_NOTE_COMPONENT";var de=Object.getOwnPropertyDescriptor,Ce=(o,t,e,i)=>{for(var n=i>1?void 0:i?de(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},J=(o,t)=>(e,i)=>t(e,i,o);exports.SheetsNotePopupService=class extends c.Disposable{constructor(e,i){super();U(this,"_lastPopup",null);U(this,"_activePopup");U(this,"_activePopup$",new w.BehaviorSubject(null));U(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(e,i){var l;const{row:n,col:r,unitId:s,subUnitId:u}=e;if(this._activePopup&&n===this._activePopup.row&&r===this._activePopup.col&&s===this._activePopup.unitId&&u===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=e,this._activePopup$.next(e);const a=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:u,row:n,col:r},{componentKey:Z,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:e},priority:3});if(!a)throw new Error("[SheetsNotePopupService]: cannot show popup!");const h=new c.DisposableCollection;h.add(a),h.add({dispose:()=>{i==null||i()}}),this._lastPopup=h}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsNotePopupService=Ce([J(0,_.IZenZoneService),J(1,c.Inject(E.CellPopupManagerService))],exports.SheetsNotePopupService);var ve=Object.getOwnPropertyDescriptor,_e=(o,t,e,i)=>{for(var n=i>1?void 0:i?ve(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},$=(o,t)=>(e,i)=>t(e,i,o);exports.SheetsNotePopupController=class extends c.Disposable{constructor(e,i,n,r,s,u){super();U(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=e,this._sheetsNoteModel=i,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=s,this._hoverManagerService=u,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,i,n){var g,I,P;const r=(g=e[0])==null?void 0:g.range,s=this._renderManagerService.getRenderById(i),u=(I=s==null?void 0:s.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:I.skeleton;if(!u||!r)return;const a=u.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((P=r.rangeType)!=null?P:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._sheetsNotePopupService.hidePopup();return}const l=a.actualRow,p=a.actualColumn,C=this._sheetsNoteModel.getNote(i,n,{row:l,col:p});C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:C.id,row:l,col:p}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(e,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ue.debounceTime(100)).subscribe(e=>{var C;if(!(e!=null&&e.location))return;const{unitId:i,subUnitId:n,row:r,col:s}=e.location,u=this._renderManagerService.getRenderById(i),a=(C=u==null?void 0:u.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:C.skeleton;let h=r,l=s,p=this._sheetsNoteModel.getNote(i,n,{row:h,col:l});if(!p&&a){const g=a.getCellWithCoordByIndex(r,s),{startRow:I,endRow:P,startColumn:b,endColumn:d}=g.mergeInfo;if(I!==P||b!==d){const v=this._sheetsNoteModel.getSheetNotes(i,n);if(v){for(const[y,S]of v)if(S.row>=I&&S.row<=P&&S.col>=b&&S.col<=d){p=S,h=S.row,l=S.col;break}}}}p!=null&&p.show||(p?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:p.id,row:h,col:l,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;const{unitId:i,subUnitId:n,noteId:r,row:s,col:u}=this._sheetsNotePopupService.activePopup,{oldNote:a,newNote:h}=e;h===null&&e.unitId===i&&e.subUnitId===n&&(a!=null&&a.id&&a.id===r||(a==null?void 0:a.row)===s&&a.col===u)&&this._sheetsNotePopupService.hidePopup(!0)}))}};exports.SheetsNotePopupController=_e([$(0,c.Inject(exports.SheetsNotePopupService)),$(1,c.Inject(N.SheetsNoteModel)),$(2,c.Inject(M.SheetsSelectionsService)),$(3,E.IEditorBridgeService),$(4,k.IRenderManagerService),$(5,c.Inject(E.HoverManagerService))],exports.SheetsNotePopupController);const ee="sheets-note-ui.config",Q={};var ge=Object.getOwnPropertyDescriptor,fe=(o,t,e,i)=>{for(var n=i>1?void 0:i?ge(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},O=(o,t)=>(e,i)=>t(e,i,o);let H=class extends c.Disposable{constructor(t,e,i,n){super();U(this,"_noteMatrix",new c.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=e,this._cellPopupManagerService=i,this._sheetsNotePopupService=n,this._initNoteChangeListener()}_showPopup(t,e,i,n){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:e,row:i,col:n},{componentKey:Z,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:e,row:i,col:n}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((t,e,i)=>{i.dispose()})}_initSheet(t,e){var r;this._noteMatrix.forValue((s,u,a)=>{a.dispose()}),this._noteMatrix=new c.ObjectMatrix;const n=(s,u,a,h,l)=>{const p=this._noteMatrix,C=p.getValue(a,h);if(l!=null&&l.show){if(!C){const g=this._showPopup(s,u,a,h);g&&p.setValue(a,h,g)}}else C&&(C.dispose(),p.realDeleteValue(a,h))};return(r=this._sheetsNoteModel.getSheetNotes(t,e))==null||r.forEach(s=>{n(t,e,s.row,s.col,s)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==t||s.subUnitId!==e))switch(s.type){case"ref":{const{unitId:u,subUnitId:a,oldNote:h,newNote:l}=s;if(!l.show)return;const p=this._noteMatrix,{row:C,col:g}=h,{row:I,col:P}=l,b=p.getValue(C,g);b&&(b.dispose(),p.realDeleteValue(C,g));const d=this._showPopup(u,a,I,P);d&&p.setValue(I,P,d);break}case"update":{const{unitId:u,subUnitId:a,oldNote:h,newNote:l}=s,p=l?l.row:h.row,C=l?l.col:h.col;n(u,a,p,C,l);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(w.switchMap(t=>{var e;return(e=t==null?void 0:t.activeSheet$)!=null?e:w.of(null)})).subscribe(t=>{if(t){const e=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{e.unsubscribe()}}else this._noteMatrix.forValue((e,i,n)=>{n.dispose()}),this._noteMatrix=new c.ObjectMatrix}))}};H=fe([O(0,c.Inject(N.SheetsNoteModel)),O(1,c.Inject(c.IUniverInstanceService)),O(2,c.Inject(E.CellPopupManagerService)),O(3,c.Inject(exports.SheetsNotePopupService))],H);function L({ref:o,...t}){const{icon:e,id:i,className:n,extend:r,...s}=t,u=`univerjs-icon univerjs-icon-${i} ${n||""}`.trim(),a=f.useRef(`_${Ne()}`);return te(e,`${i}`,{defIds:e.defIds,idSuffix:a.current},{ref:o,className:u,...s},r)}function te(o,t,e,i,n){return f.createElement(o.tag,{key:t,...Se(o,e,n),...i},(me(o,e).children||[]).map((r,s)=>te(r,`${t}-${o.tag}-${s}`,e,void 0,n)))}function Se(o,t,e){const i={...o.attrs};e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1),o.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(([r,s])=>{r==="mask"&&typeof s=="string"&&(i[r]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:n}=t;return!n||n.length===0||(o.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(([r,s])=>{typeof s=="string"&&(i[r]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),i}function me(o,t){var i;const{defIds:e}=t;return!e||e.length===0?o:o.tag==="defs"&&((i=o.children)!=null&&i.length)?{...o,children:o.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+t.idSuffix}}:n)}:o}function Ne(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";const Ie={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},ie=f.forwardRef(function(t,e){return f.createElement(L,Object.assign({},t,{id:"add-note-icon",ref:e,icon:Ie}))});ie.displayName="AddNoteIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"}}]},oe=f.forwardRef(function(t,e){return f.createElement(L,Object.assign({},t,{id:"delete-note-icon",ref:e,icon:Pe}))});oe.displayName="DeleteNoteIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},ne=f.forwardRef(function(t,e){return f.createElement(L,Object.assign({},t,{id:"hide-note-icon",ref:e,icon:Me}))});ne.displayName="HideNoteIcon";const D={id:"sheet.operation.add-note-popup",type:c.CommandType.OPERATION,handler:async(o,t)=>{var h;const e=o.get(M.SheetsSelectionsService),i=o.get(exports.SheetsNotePopupService),r=o.get(c.IUniverInstanceService).getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!r)return!1;const s=r.getActiveSheet(),u=e.getCurrentLastSelection();if(!(u!=null&&u.primary))return!1;const{primary:a}=u;return i.showPopup({unitId:r.getUnitId(),subUnitId:s.getSheetId(),row:a.actualRow,col:a.actualColumn,temp:!1,trigger:(h=t==null?void 0:t.trigger)!=null?h:"add-note"}),!0}},re=o=>{var b;const{popup:t}=o,e=_.useDependency(N.SheetsNoteModel),i=_.useDependency(c.LocaleService),n=_.useDependency(k.IRenderManagerService),r=_.useDependency(exports.SheetsNotePopupService),s=_.useConfigValue(ee),u=(b=t.extraProps)==null?void 0:b.location;if(!u)return console.error("Popup extraProps or location is undefined."),null;const a=f.useRef(null),h=n.getRenderById(u.unitId),[l,p]=f.useState(null);f.useEffect(()=>{var B,W,F,q,z,G;const{unitId:d,subUnitId:v,row:y,col:S}=u,m=e.getNote(d,v,{row:y,col:S}),j=(F=(W=m==null?void 0:m.width)!=null?W:(B=s==null?void 0:s.defaultNoteSize)==null?void 0:B.width)!=null?F:160,x=(G=(z=m==null?void 0:m.height)!=null?z:(q=s==null?void 0:s.defaultNoteSize)==null?void 0:q.height)!=null?G:72;if(m)p(m);else{const K={id:c.generateRandomId(6),width:j,height:x,note:""};p(K),g(K)}a.current&&(a.current.style.width=`${j}px`,a.current.style.height=`${x}px`)},[u,a]),f.useEffect(()=>{if(!u||u.temp||!u.trigger||!a.current)return;const d=requestAnimationFrame(()=>{var v;(v=a.current)==null||v.focus()});return()=>cancelAnimationFrame(d)},[u]);const C=_.useDependency(c.ICommandService),g=_.useDebounceFn(d=>{if(!u)return;const{unitId:v,subUnitId:y,row:S,col:m}=u;if(!C.syncExecuteCommand(N.SheetUpdateNoteCommand.id,{unitId:v,sheetId:y,row:S,col:m,note:d})){const x=e.getNote(v,y,{noteId:d.id,row:S,col:m});x?p(x):r.hidePopup(!0)}}),I=f.useCallback(d=>{if(!l||d===l.note)return;const v={...l,note:d};p(v),g(v)},[l]),P=f.useCallback((d,v)=>{if(!l||d===l.width&&v===l.height)return;const y={...l,width:d,height:v};p(y),g(y)},[l]);return le.jsx(Y.Textarea,{ref:a,"data-u-comp":"note-textarea",className:Y.clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),value:l==null?void 0:l.note,placeholder:i.t("note.placeholder"),onResize:P,onValueChange:I,onWheel:d=>{document.activeElement!==a.current&&h.engine.getCanvasElement().dispatchEvent(new WheelEvent(d.type,d.nativeEvent))}})};function A(o){const t=o.get(M.SheetsSelectionsService),e=o.get(c.IUniverInstanceService);return t.selectionMoveEnd$.pipe(w.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const n=M.getSheetCommandTarget(e);if(!n)return!1;const{actualColumn:r,actualRow:s}=i.primary;return!!o.get(N.SheetsNoteModel).getNote(n.unitId,n.subUnitId,{row:s,col:r})}))}function we(o){return{id:D.id,type:_.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:w.combineLatest([_.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),A(o)]).pipe(w.map(([t,e])=>t||e)),disabled$:E.getCurrentRangeDisable$(o,{workbookTypes:[M.WorkbookEditablePermission],worksheetTypes:[M.WorksheetEditPermission]}),commandId:D.id}}function be(o){return{id:N.SheetDeleteNoteCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:A(o).pipe(w.map(t=>!t)),disabled$:E.getCurrentRangeDisable$(o,{workbookTypes:[M.WorkbookEditablePermission],worksheetTypes:[M.WorksheetEditPermission]})}}function ye(o){return{id:N.SheetToggleNotePopupCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:A(o).pipe(w.map(t=>!t))}}const Ee={[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.OTHERS]:{order:0,[D.id]:{order:0,menuItemFactory:we},[N.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:be},[N.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:ye}}}};var Ue=Object.getOwnPropertyDescriptor,$e=(o,t,e,i)=>{for(var n=i>1?void 0:i?Ue(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},V=(o,t)=>(e,i)=>t(e,i,o);let R=class extends c.Disposable{constructor(o,t,e){super(),this._componentManager=o,this._menuManagerService=t,this._commandService=e,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[Z,re],["AddNoteIcon",ie],["DeleteNoteIcon",oe],["HideNoteIcon",ne]].forEach(([o,t])=>{this.disposeWithMe(this._componentManager.register(o,t))})}_initMenu(){this._menuManagerService.mergeMenu(Ee)}_initCommands(){this._commandService.registerCommand(D)}};R=$e([V(0,c.Inject(_.ComponentManager)),V(1,c.Inject(_.IMenuManagerService)),V(2,c.ICommandService)],R);var xe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Oe=(o,t,e)=>t in o?xe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,He=(o,t,e,i)=>{for(var n=i>1?void 0:i?Te(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(n=s(n)||n);return n},X=(o,t)=>(e,i)=>t(e,i,o),se=(o,t,e)=>Oe(o,typeof t!="symbol"?t+"":t,e);const De="SHEET_NOTE_UI_PLUGIN";exports.UniverSheetsNoteUIPlugin=class extends c.Plugin{constructor(t=Q,e,i){super(),this._config=t,this._injector=e,this._configService=i;const{menu:n,...r}=c.merge({},Q,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(ee,r)}onStarting(){[[exports.SheetsNotePopupService],[exports.SheetsCellContentController],[exports.SheetsNotePopupController],[R],[H]].forEach(t=>{this._injector.add(t)})}onReady(){c.touchDependencies(this._injector,[[R],[exports.SheetsCellContentController]])}onRendered(){c.touchDependencies(this._injector,[[exports.SheetsNotePopupController],[H]])}};se(exports.UniverSheetsNoteUIPlugin,"pluginName",De);se(exports.UniverSheetsNoteUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNoteUIPlugin=He([c.DependentOn(N.UniverSheetsNotePlugin),X(1,c.Inject(c.Injector)),X(2,c.IConfigService)],exports.UniverSheetsNoteUIPlugin);exports.SheetsNote=re;
|
package/lib/es/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var Ee = Object.defineProperty;
|
|
2
2
|
var ye = (i, e, t) => e in i ? Ee(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var P = (i, e, t) => ye(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { Inject as g, IUniverInstanceService as Z, Disposable as E, InterceptorEffectEnum as $e, UniverInstanceType as y, DisposableCollection as xe, RANGE_TYPE as ne, Rectangle as He, ObjectMatrix as F, CommandType as Oe, LocaleService as Te, ICommandService as de, DependentOn as
|
|
4
|
+
import { Inject as g, IUniverInstanceService as Z, Disposable as E, InterceptorEffectEnum as $e, UniverInstanceType as y, DisposableCollection as xe, RANGE_TYPE as ne, Rectangle as He, ObjectMatrix as F, CommandType as Oe, LocaleService as Te, generateRandomId as Le, ICommandService as de, DependentOn as Re, Injector as Ue, IConfigService as De, Plugin as Ve, merge as Ze, touchDependencies as se } from "@univerjs/core";
|
|
5
5
|
import { IRenderManagerService as z } from "@univerjs/engine-render";
|
|
6
|
-
import { SheetInterceptorService as
|
|
7
|
-
import { SheetsNoteModel as $, SheetUpdateNoteCommand as
|
|
8
|
-
import { debounceTime as
|
|
9
|
-
import { CellPopupManagerService as ve, IEditorBridgeService as
|
|
10
|
-
import { debounceTime as
|
|
11
|
-
import { IZenZoneService as
|
|
12
|
-
import { useRef as Se, createElement as j, forwardRef as q, useState as
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { Textarea as
|
|
15
|
-
var
|
|
16
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
6
|
+
import { SheetInterceptorService as ke, INTERCEPTOR_POINT as je, SheetsSelectionsService as G, WorksheetEditPermission as _e, WorkbookEditablePermission as fe, getSheetCommandTarget as Be } from "@univerjs/sheets";
|
|
7
|
+
import { SheetsNoteModel as $, SheetUpdateNoteCommand as Ae, SheetToggleNotePopupCommand as Ce, SheetDeleteNoteCommand as ge, UniverSheetsNotePlugin as Fe } from "@univerjs/sheets-note";
|
|
8
|
+
import { debounceTime as We, BehaviorSubject as ze, switchMap as Ge, of as Ke, map as k, combineLatest as qe } from "rxjs";
|
|
9
|
+
import { CellPopupManagerService as ve, IEditorBridgeService as Ye, HoverManagerService as Je, SheetSkeletonManagerService as ce, getCurrentRangeDisable$ as me } from "@univerjs/sheets-ui";
|
|
10
|
+
import { debounceTime as Qe } from "rxjs/operators";
|
|
11
|
+
import { IZenZoneService as Xe, useDependency as b, useConfigValue as et, useDebounceFn as tt, MenuItemType as K, getMenuHiddenObservable as it, ContextMenuPosition as ot, ContextMenuGroup as rt, ComponentManager as nt, IMenuManagerService as st } from "@univerjs/ui";
|
|
12
|
+
import { useRef as Se, createElement as j, forwardRef as q, useState as ct, useEffect as ae, useCallback as ue } from "react";
|
|
13
|
+
import { jsx as at } from "react/jsx-runtime";
|
|
14
|
+
import { Textarea as ut, clsx as lt } from "@univerjs/design";
|
|
15
|
+
var pt = Object.getOwnPropertyDescriptor, ht = (i, e, t, o) => {
|
|
16
|
+
for (var r = o > 1 ? void 0 : o ? pt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
17
17
|
(n = i[s]) && (r = n(r) || r);
|
|
18
18
|
return r;
|
|
19
19
|
}, H = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -24,7 +24,7 @@ let T = class extends E {
|
|
|
24
24
|
_initViewModelIntercept() {
|
|
25
25
|
this.disposeWithMe(
|
|
26
26
|
this._sheetInterceptorService.intercept(
|
|
27
|
-
|
|
27
|
+
je.CELL_CONTENT,
|
|
28
28
|
{
|
|
29
29
|
effect: $e.Style,
|
|
30
30
|
handler: (i, e, t) => {
|
|
@@ -50,20 +50,20 @@ let T = class extends E {
|
|
|
50
50
|
const t = e.getUnitId(), o = this._renderManagerService.getRenderById(t);
|
|
51
51
|
(r = o == null ? void 0 : o.mainComponent) == null || r.makeForceDirty();
|
|
52
52
|
};
|
|
53
|
-
this.disposeWithMe(this._sheetsNoteModel.change$.pipe(
|
|
53
|
+
this.disposeWithMe(this._sheetsNoteModel.change$.pipe(We(16)).subscribe(() => {
|
|
54
54
|
i();
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
T =
|
|
59
|
-
H(0, g(
|
|
58
|
+
T = ht([
|
|
59
|
+
H(0, g(ke)),
|
|
60
60
|
H(1, g($)),
|
|
61
61
|
H(2, z),
|
|
62
62
|
H(3, Z)
|
|
63
63
|
], T);
|
|
64
64
|
const Y = "SHEET_NOTE_COMPONENT";
|
|
65
|
-
var
|
|
66
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
65
|
+
var dt = Object.getOwnPropertyDescriptor, _t = (i, e, t, o) => {
|
|
66
|
+
for (var r = o > 1 ? void 0 : o ? dt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
67
67
|
(n = i[s]) && (r = n(r) || r);
|
|
68
68
|
return r;
|
|
69
69
|
}, le = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -72,7 +72,7 @@ let I = class extends E {
|
|
|
72
72
|
super();
|
|
73
73
|
P(this, "_lastPopup", null);
|
|
74
74
|
P(this, "_activePopup");
|
|
75
|
-
P(this, "_activePopup$", new
|
|
75
|
+
P(this, "_activePopup$", new ze(null));
|
|
76
76
|
P(this, "activePopup$", this._activePopup$.asObservable());
|
|
77
77
|
this._zenZoneService = e, this._cellPopupManagerService = t, this._initZenVisible(), this.disposeWithMe(() => {
|
|
78
78
|
this._activePopup$.complete();
|
|
@@ -137,12 +137,12 @@ let I = class extends E {
|
|
|
137
137
|
}, this._activePopup$.next(this._activePopup));
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
I =
|
|
141
|
-
le(0,
|
|
140
|
+
I = _t([
|
|
141
|
+
le(0, Xe),
|
|
142
142
|
le(1, g(ve))
|
|
143
143
|
], I);
|
|
144
|
-
var
|
|
145
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
144
|
+
var ft = Object.getOwnPropertyDescriptor, Ct = (i, e, t, o) => {
|
|
145
|
+
for (var r = o > 1 ? void 0 : o ? ft(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
146
146
|
(n = i[s]) && (r = n(r) || r);
|
|
147
147
|
return r;
|
|
148
148
|
}, w = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -190,7 +190,7 @@ let L = class extends E {
|
|
|
190
190
|
}
|
|
191
191
|
_initHoverEvent() {
|
|
192
192
|
this.disposeWithMe(
|
|
193
|
-
this._hoverManagerService.currentCell$.pipe(
|
|
193
|
+
this._hoverManagerService.currentCell$.pipe(Qe(100)).subscribe((e) => {
|
|
194
194
|
var p;
|
|
195
195
|
if (!(e != null && e.location)) return;
|
|
196
196
|
const { unitId: t, subUnitId: o, row: r, col: s } = e.location, n = this._renderManagerService.getRenderById(t), c = (p = n == null ? void 0 : n.with(ce).getSkeletonParam(o)) == null ? void 0 : p.skeleton;
|
|
@@ -229,21 +229,21 @@ let L = class extends E {
|
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
|
-
L =
|
|
232
|
+
L = Ct([
|
|
233
233
|
w(0, g(I)),
|
|
234
234
|
w(1, g($)),
|
|
235
235
|
w(2, g(G)),
|
|
236
|
-
w(3,
|
|
236
|
+
w(3, Ye),
|
|
237
237
|
w(4, z),
|
|
238
|
-
w(5, g(
|
|
238
|
+
w(5, g(Je))
|
|
239
239
|
], L);
|
|
240
240
|
const Ne = "sheets-note-ui.config", pe = {};
|
|
241
|
-
var
|
|
242
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
241
|
+
var gt = Object.getOwnPropertyDescriptor, vt = (i, e, t, o) => {
|
|
242
|
+
for (var r = o > 1 ? void 0 : o ? gt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
243
243
|
(n = i[s]) && (r = n(r) || r);
|
|
244
244
|
return r;
|
|
245
245
|
}, O = (i, e) => (t, o) => e(t, o, i);
|
|
246
|
-
let
|
|
246
|
+
let R = class extends E {
|
|
247
247
|
constructor(e, t, o, r) {
|
|
248
248
|
super();
|
|
249
249
|
P(this, "_noteMatrix", new F());
|
|
@@ -317,9 +317,9 @@ let U = class extends E {
|
|
|
317
317
|
_initNoteChangeListener() {
|
|
318
318
|
this.disposeWithMe(
|
|
319
319
|
this._univerInstanceService.getCurrentTypeOfUnit$(y.UNIVER_SHEET).pipe(
|
|
320
|
-
|
|
320
|
+
Ge((e) => {
|
|
321
321
|
var t;
|
|
322
|
-
return (t = e == null ? void 0 : e.activeSheet$) != null ? t :
|
|
322
|
+
return (t = e == null ? void 0 : e.activeSheet$) != null ? t : Ke(null);
|
|
323
323
|
})
|
|
324
324
|
).subscribe((e) => {
|
|
325
325
|
if (e) {
|
|
@@ -335,14 +335,14 @@ let U = class extends E {
|
|
|
335
335
|
);
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
|
-
|
|
338
|
+
R = vt([
|
|
339
339
|
O(0, g($)),
|
|
340
340
|
O(1, g(Z)),
|
|
341
341
|
O(2, g(ve)),
|
|
342
342
|
O(3, g(I))
|
|
343
|
-
],
|
|
343
|
+
], R);
|
|
344
344
|
function B({ ref: i, ...e }) {
|
|
345
|
-
const { icon: t, id: o, className: r, extend: s, ...n } = e, c = `univerjs-icon univerjs-icon-${o} ${r || ""}`.trim(), u = Se(`_${
|
|
345
|
+
const { icon: t, id: o, className: r, extend: s, ...n } = e, c = `univerjs-icon univerjs-icon-${o} ${r || ""}`.trim(), u = Se(`_${Nt()}`);
|
|
346
346
|
return Pe(t, `${o}`, {
|
|
347
347
|
defIds: t.defIds,
|
|
348
348
|
idSuffix: u.current
|
|
@@ -355,11 +355,11 @@ function B({ ref: i, ...e }) {
|
|
|
355
355
|
function Pe(i, e, t, o, r) {
|
|
356
356
|
return j(i.tag, {
|
|
357
357
|
key: e,
|
|
358
|
-
...
|
|
358
|
+
...mt(i, t, r),
|
|
359
359
|
...o
|
|
360
|
-
}, (
|
|
360
|
+
}, (St(i, t).children || []).map((s, n) => Pe(s, `${e}-${i.tag}-${n}`, t, void 0, r)));
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function mt(i, e, t) {
|
|
363
363
|
const o = { ...i.attrs };
|
|
364
364
|
t != null && t.colorChannel1 && o.fill === "colorChannel1" && (o.fill = t.colorChannel1), i.tag === "mask" && o.id && (o.id = o.id + e.idSuffix), Object.entries(o).forEach(([s, n]) => {
|
|
365
365
|
s === "mask" && typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
@@ -369,7 +369,7 @@ function vt(i, e, t) {
|
|
|
369
369
|
typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
370
370
|
})), o;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function St(i, e) {
|
|
373
373
|
var o;
|
|
374
374
|
const { defIds: t } = e;
|
|
375
375
|
return !t || t.length === 0 ? i : i.tag === "defs" && ((o = i.children) != null && o.length) ? {
|
|
@@ -383,11 +383,11 @@ function mt(i, e) {
|
|
|
383
383
|
} : r)
|
|
384
384
|
} : i;
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function Nt() {
|
|
387
387
|
return Math.random().toString(36).substring(2, 8);
|
|
388
388
|
}
|
|
389
389
|
B.displayName = "UniverIcon";
|
|
390
|
-
const
|
|
390
|
+
const Pt = {
|
|
391
391
|
tag: "svg",
|
|
392
392
|
attrs: {
|
|
393
393
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -444,11 +444,11 @@ const Nt = {
|
|
|
444
444
|
return j(B, Object.assign({}, e, {
|
|
445
445
|
id: "add-note-icon",
|
|
446
446
|
ref: t,
|
|
447
|
-
icon:
|
|
447
|
+
icon: Pt
|
|
448
448
|
}));
|
|
449
449
|
});
|
|
450
450
|
Ie.displayName = "AddNoteIcon";
|
|
451
|
-
const
|
|
451
|
+
const It = {
|
|
452
452
|
tag: "svg",
|
|
453
453
|
attrs: {
|
|
454
454
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -498,11 +498,11 @@ const Pt = {
|
|
|
498
498
|
return j(B, Object.assign({}, e, {
|
|
499
499
|
id: "delete-note-icon",
|
|
500
500
|
ref: t,
|
|
501
|
-
icon:
|
|
501
|
+
icon: It
|
|
502
502
|
}));
|
|
503
503
|
});
|
|
504
504
|
we.displayName = "DeleteNoteIcon";
|
|
505
|
-
const
|
|
505
|
+
const wt = {
|
|
506
506
|
tag: "svg",
|
|
507
507
|
attrs: {
|
|
508
508
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -559,11 +559,11 @@ const It = {
|
|
|
559
559
|
return j(B, Object.assign({}, e, {
|
|
560
560
|
id: "hide-note-icon",
|
|
561
561
|
ref: t,
|
|
562
|
-
icon:
|
|
562
|
+
icon: wt
|
|
563
563
|
}));
|
|
564
564
|
});
|
|
565
565
|
Me.displayName = "HideNoteIcon";
|
|
566
|
-
const
|
|
566
|
+
const U = {
|
|
567
567
|
id: "sheet.operation.add-note-popup",
|
|
568
568
|
type: Oe.OPERATION,
|
|
569
569
|
handler: async (i, e) => {
|
|
@@ -584,12 +584,12 @@ const R = {
|
|
|
584
584
|
trigger: (l = e == null ? void 0 : e.trigger) != null ? l : "add-note"
|
|
585
585
|
}), !0;
|
|
586
586
|
}
|
|
587
|
-
},
|
|
587
|
+
}, Mt = (i) => {
|
|
588
588
|
var S;
|
|
589
|
-
const { popup: e } = i, t = b($), o = b(Te), r = b(z), s = b(I), n =
|
|
589
|
+
const { popup: e } = i, t = b($), o = b(Te), r = b(z), s = b(I), n = et(Ne), c = (S = e.extraProps) == null ? void 0 : S.location;
|
|
590
590
|
if (!c)
|
|
591
591
|
return console.error("Popup extraProps or location is undefined."), null;
|
|
592
|
-
const u = Se(null), l = r.getRenderById(c.unitId), [a, p] =
|
|
592
|
+
const u = Se(null), l = r.getRenderById(c.unitId), [a, p] = ct(null);
|
|
593
593
|
ae(() => {
|
|
594
594
|
var Q, X, ee, te, ie, oe;
|
|
595
595
|
const { unitId: h, subUnitId: C, row: f, col: x } = c, v = t.getNote(h, C, { row: f, col: x }), A = (ee = (X = v == null ? void 0 : v.width) != null ? X : (Q = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : Q.width) != null ? ee : 160, M = (oe = (ie = v == null ? void 0 : v.height) != null ? ie : (te = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : te.height) != null ? oe : 72;
|
|
@@ -597,6 +597,7 @@ const R = {
|
|
|
597
597
|
p(v);
|
|
598
598
|
else {
|
|
599
599
|
const re = {
|
|
600
|
+
id: Le(6),
|
|
600
601
|
width: A,
|
|
601
602
|
height: M,
|
|
602
603
|
note: ""
|
|
@@ -612,10 +613,10 @@ const R = {
|
|
|
612
613
|
});
|
|
613
614
|
return () => cancelAnimationFrame(h);
|
|
614
615
|
}, [c]);
|
|
615
|
-
const d = b(de), _ =
|
|
616
|
+
const d = b(de), _ = tt((h) => {
|
|
616
617
|
if (!c) return;
|
|
617
618
|
const { unitId: C, subUnitId: f, row: x, col: v } = c;
|
|
618
|
-
if (!d.syncExecuteCommand(
|
|
619
|
+
if (!d.syncExecuteCommand(Ae.id, {
|
|
619
620
|
unitId: C,
|
|
620
621
|
sheetId: f,
|
|
621
622
|
row: x,
|
|
@@ -634,12 +635,12 @@ const R = {
|
|
|
634
635
|
const f = { ...a, width: h, height: C };
|
|
635
636
|
p(f), _(f);
|
|
636
637
|
}, [a]);
|
|
637
|
-
return /* @__PURE__ */
|
|
638
|
-
|
|
638
|
+
return /* @__PURE__ */ at(
|
|
639
|
+
ut,
|
|
639
640
|
{
|
|
640
641
|
ref: u,
|
|
641
642
|
"data-u-comp": "note-textarea",
|
|
642
|
-
className:
|
|
643
|
+
className: lt("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
|
|
643
644
|
value: a == null ? void 0 : a.note,
|
|
644
645
|
placeholder: o.t("note.placeholder"),
|
|
645
646
|
onResize: N,
|
|
@@ -655,24 +656,24 @@ function J(i) {
|
|
|
655
656
|
return e.selectionMoveEnd$.pipe(k(() => {
|
|
656
657
|
const o = e.getCurrentLastSelection();
|
|
657
658
|
if (!(o != null && o.primary)) return !1;
|
|
658
|
-
const r =
|
|
659
|
+
const r = Be(t);
|
|
659
660
|
if (!r) return !1;
|
|
660
661
|
const { actualColumn: s, actualRow: n } = o.primary;
|
|
661
662
|
return !!i.get($).getNote(r.unitId, r.subUnitId, { row: n, col: s });
|
|
662
663
|
}));
|
|
663
664
|
}
|
|
664
|
-
function
|
|
665
|
+
function bt(i) {
|
|
665
666
|
return {
|
|
666
|
-
id:
|
|
667
|
+
id: U.id,
|
|
667
668
|
type: K.BUTTON,
|
|
668
669
|
title: "rightClick.addNote",
|
|
669
670
|
icon: "AddNoteIcon",
|
|
670
|
-
hidden$:
|
|
671
|
+
hidden$: qe([it(i, y.UNIVER_SHEET), J(i)]).pipe(k(([e, t]) => e || t)),
|
|
671
672
|
disabled$: me(i, { workbookTypes: [fe], worksheetTypes: [_e] }),
|
|
672
|
-
commandId:
|
|
673
|
+
commandId: U.id
|
|
673
674
|
};
|
|
674
675
|
}
|
|
675
|
-
function
|
|
676
|
+
function Et(i) {
|
|
676
677
|
return {
|
|
677
678
|
id: ge.id,
|
|
678
679
|
type: K.BUTTON,
|
|
@@ -682,7 +683,7 @@ function bt(i) {
|
|
|
682
683
|
disabled$: me(i, { workbookTypes: [fe], worksheetTypes: [_e] })
|
|
683
684
|
};
|
|
684
685
|
}
|
|
685
|
-
function
|
|
686
|
+
function yt(i) {
|
|
686
687
|
return {
|
|
687
688
|
id: Ce.id,
|
|
688
689
|
type: K.BUTTON,
|
|
@@ -691,27 +692,27 @@ function Et(i) {
|
|
|
691
692
|
hidden$: J(i).pipe(k((e) => !e))
|
|
692
693
|
};
|
|
693
694
|
}
|
|
694
|
-
const
|
|
695
|
-
[
|
|
696
|
-
[
|
|
695
|
+
const $t = {
|
|
696
|
+
[ot.MAIN_AREA]: {
|
|
697
|
+
[rt.OTHERS]: {
|
|
697
698
|
order: 0,
|
|
698
|
-
[
|
|
699
|
+
[U.id]: {
|
|
699
700
|
order: 0,
|
|
700
|
-
menuItemFactory:
|
|
701
|
+
menuItemFactory: bt
|
|
701
702
|
},
|
|
702
703
|
[ge.id]: {
|
|
703
704
|
order: 0,
|
|
704
|
-
menuItemFactory:
|
|
705
|
+
menuItemFactory: Et
|
|
705
706
|
},
|
|
706
707
|
[Ce.id]: {
|
|
707
708
|
order: 0,
|
|
708
|
-
menuItemFactory:
|
|
709
|
+
menuItemFactory: yt
|
|
709
710
|
}
|
|
710
711
|
}
|
|
711
712
|
}
|
|
712
713
|
};
|
|
713
|
-
var
|
|
714
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
714
|
+
var xt = Object.getOwnPropertyDescriptor, Ht = (i, e, t, o) => {
|
|
715
|
+
for (var r = o > 1 ? void 0 : o ? xt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
715
716
|
(n = i[s]) && (r = n(r) || r);
|
|
716
717
|
return r;
|
|
717
718
|
}, W = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -721,7 +722,7 @@ let D = class extends E {
|
|
|
721
722
|
}
|
|
722
723
|
_initComponents() {
|
|
723
724
|
[
|
|
724
|
-
[Y,
|
|
725
|
+
[Y, Mt],
|
|
725
726
|
["AddNoteIcon", Ie],
|
|
726
727
|
["DeleteNoteIcon", we],
|
|
727
728
|
["HideNoteIcon", Me]
|
|
@@ -732,27 +733,27 @@ let D = class extends E {
|
|
|
732
733
|
});
|
|
733
734
|
}
|
|
734
735
|
_initMenu() {
|
|
735
|
-
this._menuManagerService.mergeMenu(
|
|
736
|
+
this._menuManagerService.mergeMenu($t);
|
|
736
737
|
}
|
|
737
738
|
_initCommands() {
|
|
738
|
-
this._commandService.registerCommand(
|
|
739
|
+
this._commandService.registerCommand(U);
|
|
739
740
|
}
|
|
740
741
|
};
|
|
741
|
-
D =
|
|
742
|
-
W(0, g(
|
|
743
|
-
W(1, g(
|
|
742
|
+
D = Ht([
|
|
743
|
+
W(0, g(nt)),
|
|
744
|
+
W(1, g(st)),
|
|
744
745
|
W(2, de)
|
|
745
746
|
], D);
|
|
746
|
-
var
|
|
747
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
747
|
+
var Ot = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, Lt = (i, e, t) => e in i ? Ot(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Rt = (i, e, t, o) => {
|
|
748
|
+
for (var r = o > 1 ? void 0 : o ? Tt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
748
749
|
(n = i[s]) && (r = n(r) || r);
|
|
749
750
|
return r;
|
|
750
|
-
}, he = (i, e) => (t, o) => e(t, o, i), be = (i, e, t) =>
|
|
751
|
+
}, he = (i, e) => (t, o) => e(t, o, i), be = (i, e, t) => Lt(i, typeof e != "symbol" ? e + "" : e, t);
|
|
751
752
|
const Ut = "SHEET_NOTE_UI_PLUGIN";
|
|
752
|
-
let V = class extends
|
|
753
|
+
let V = class extends Ve {
|
|
753
754
|
constructor(i = pe, e, t) {
|
|
754
755
|
super(), this._config = i, this._injector = e, this._configService = t;
|
|
755
|
-
const { menu: o, ...r } =
|
|
756
|
+
const { menu: o, ...r } = Ze(
|
|
756
757
|
{},
|
|
757
758
|
pe,
|
|
758
759
|
this._config
|
|
@@ -765,7 +766,7 @@ let V = class extends De {
|
|
|
765
766
|
[T],
|
|
766
767
|
[L],
|
|
767
768
|
[D],
|
|
768
|
-
[
|
|
769
|
+
[R]
|
|
769
770
|
].forEach((i) => {
|
|
770
771
|
this._injector.add(i);
|
|
771
772
|
});
|
|
@@ -779,20 +780,20 @@ let V = class extends De {
|
|
|
779
780
|
onRendered() {
|
|
780
781
|
se(this._injector, [
|
|
781
782
|
[L],
|
|
782
|
-
[
|
|
783
|
+
[R]
|
|
783
784
|
]);
|
|
784
785
|
}
|
|
785
786
|
};
|
|
786
787
|
be(V, "pluginName", Ut);
|
|
787
788
|
be(V, "type", y.UNIVER_SHEET);
|
|
788
|
-
V =
|
|
789
|
-
|
|
789
|
+
V = Rt([
|
|
790
|
+
Re(Fe),
|
|
790
791
|
he(1, g(Ue)),
|
|
791
|
-
he(2,
|
|
792
|
+
he(2, De)
|
|
792
793
|
], V);
|
|
793
794
|
export {
|
|
794
795
|
T as SheetsCellContentController,
|
|
795
|
-
|
|
796
|
+
Mt as SheetsNote,
|
|
796
797
|
L as SheetsNotePopupController,
|
|
797
798
|
I as SheetsNotePopupService,
|
|
798
799
|
V as UniverSheetsNoteUIPlugin
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var Ee = Object.defineProperty;
|
|
2
2
|
var ye = (i, e, t) => e in i ? Ee(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var P = (i, e, t) => ye(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { Inject as g, IUniverInstanceService as Z, Disposable as E, InterceptorEffectEnum as $e, UniverInstanceType as y, DisposableCollection as xe, RANGE_TYPE as ne, Rectangle as He, ObjectMatrix as F, CommandType as Oe, LocaleService as Te, ICommandService as de, DependentOn as
|
|
4
|
+
import { Inject as g, IUniverInstanceService as Z, Disposable as E, InterceptorEffectEnum as $e, UniverInstanceType as y, DisposableCollection as xe, RANGE_TYPE as ne, Rectangle as He, ObjectMatrix as F, CommandType as Oe, LocaleService as Te, generateRandomId as Le, ICommandService as de, DependentOn as Re, Injector as Ue, IConfigService as De, Plugin as Ve, merge as Ze, touchDependencies as se } from "@univerjs/core";
|
|
5
5
|
import { IRenderManagerService as z } from "@univerjs/engine-render";
|
|
6
|
-
import { SheetInterceptorService as
|
|
7
|
-
import { SheetsNoteModel as $, SheetUpdateNoteCommand as
|
|
8
|
-
import { debounceTime as
|
|
9
|
-
import { CellPopupManagerService as ve, IEditorBridgeService as
|
|
10
|
-
import { debounceTime as
|
|
11
|
-
import { IZenZoneService as
|
|
12
|
-
import { useRef as Se, createElement as j, forwardRef as q, useState as
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { Textarea as
|
|
15
|
-
var
|
|
16
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
6
|
+
import { SheetInterceptorService as ke, INTERCEPTOR_POINT as je, SheetsSelectionsService as G, WorksheetEditPermission as _e, WorkbookEditablePermission as fe, getSheetCommandTarget as Be } from "@univerjs/sheets";
|
|
7
|
+
import { SheetsNoteModel as $, SheetUpdateNoteCommand as Ae, SheetToggleNotePopupCommand as Ce, SheetDeleteNoteCommand as ge, UniverSheetsNotePlugin as Fe } from "@univerjs/sheets-note";
|
|
8
|
+
import { debounceTime as We, BehaviorSubject as ze, switchMap as Ge, of as Ke, map as k, combineLatest as qe } from "rxjs";
|
|
9
|
+
import { CellPopupManagerService as ve, IEditorBridgeService as Ye, HoverManagerService as Je, SheetSkeletonManagerService as ce, getCurrentRangeDisable$ as me } from "@univerjs/sheets-ui";
|
|
10
|
+
import { debounceTime as Qe } from "rxjs/operators";
|
|
11
|
+
import { IZenZoneService as Xe, useDependency as b, useConfigValue as et, useDebounceFn as tt, MenuItemType as K, getMenuHiddenObservable as it, ContextMenuPosition as ot, ContextMenuGroup as rt, ComponentManager as nt, IMenuManagerService as st } from "@univerjs/ui";
|
|
12
|
+
import { useRef as Se, createElement as j, forwardRef as q, useState as ct, useEffect as ae, useCallback as ue } from "react";
|
|
13
|
+
import { jsx as at } from "react/jsx-runtime";
|
|
14
|
+
import { Textarea as ut, clsx as lt } from "@univerjs/design";
|
|
15
|
+
var pt = Object.getOwnPropertyDescriptor, ht = (i, e, t, o) => {
|
|
16
|
+
for (var r = o > 1 ? void 0 : o ? pt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
17
17
|
(n = i[s]) && (r = n(r) || r);
|
|
18
18
|
return r;
|
|
19
19
|
}, H = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -24,7 +24,7 @@ let T = class extends E {
|
|
|
24
24
|
_initViewModelIntercept() {
|
|
25
25
|
this.disposeWithMe(
|
|
26
26
|
this._sheetInterceptorService.intercept(
|
|
27
|
-
|
|
27
|
+
je.CELL_CONTENT,
|
|
28
28
|
{
|
|
29
29
|
effect: $e.Style,
|
|
30
30
|
handler: (i, e, t) => {
|
|
@@ -50,20 +50,20 @@ let T = class extends E {
|
|
|
50
50
|
const t = e.getUnitId(), o = this._renderManagerService.getRenderById(t);
|
|
51
51
|
(r = o == null ? void 0 : o.mainComponent) == null || r.makeForceDirty();
|
|
52
52
|
};
|
|
53
|
-
this.disposeWithMe(this._sheetsNoteModel.change$.pipe(
|
|
53
|
+
this.disposeWithMe(this._sheetsNoteModel.change$.pipe(We(16)).subscribe(() => {
|
|
54
54
|
i();
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
T =
|
|
59
|
-
H(0, g(
|
|
58
|
+
T = ht([
|
|
59
|
+
H(0, g(ke)),
|
|
60
60
|
H(1, g($)),
|
|
61
61
|
H(2, z),
|
|
62
62
|
H(3, Z)
|
|
63
63
|
], T);
|
|
64
64
|
const Y = "SHEET_NOTE_COMPONENT";
|
|
65
|
-
var
|
|
66
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
65
|
+
var dt = Object.getOwnPropertyDescriptor, _t = (i, e, t, o) => {
|
|
66
|
+
for (var r = o > 1 ? void 0 : o ? dt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
67
67
|
(n = i[s]) && (r = n(r) || r);
|
|
68
68
|
return r;
|
|
69
69
|
}, le = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -72,7 +72,7 @@ let I = class extends E {
|
|
|
72
72
|
super();
|
|
73
73
|
P(this, "_lastPopup", null);
|
|
74
74
|
P(this, "_activePopup");
|
|
75
|
-
P(this, "_activePopup$", new
|
|
75
|
+
P(this, "_activePopup$", new ze(null));
|
|
76
76
|
P(this, "activePopup$", this._activePopup$.asObservable());
|
|
77
77
|
this._zenZoneService = e, this._cellPopupManagerService = t, this._initZenVisible(), this.disposeWithMe(() => {
|
|
78
78
|
this._activePopup$.complete();
|
|
@@ -137,12 +137,12 @@ let I = class extends E {
|
|
|
137
137
|
}, this._activePopup$.next(this._activePopup));
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
I =
|
|
141
|
-
le(0,
|
|
140
|
+
I = _t([
|
|
141
|
+
le(0, Xe),
|
|
142
142
|
le(1, g(ve))
|
|
143
143
|
], I);
|
|
144
|
-
var
|
|
145
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
144
|
+
var ft = Object.getOwnPropertyDescriptor, Ct = (i, e, t, o) => {
|
|
145
|
+
for (var r = o > 1 ? void 0 : o ? ft(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
146
146
|
(n = i[s]) && (r = n(r) || r);
|
|
147
147
|
return r;
|
|
148
148
|
}, w = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -190,7 +190,7 @@ let L = class extends E {
|
|
|
190
190
|
}
|
|
191
191
|
_initHoverEvent() {
|
|
192
192
|
this.disposeWithMe(
|
|
193
|
-
this._hoverManagerService.currentCell$.pipe(
|
|
193
|
+
this._hoverManagerService.currentCell$.pipe(Qe(100)).subscribe((e) => {
|
|
194
194
|
var p;
|
|
195
195
|
if (!(e != null && e.location)) return;
|
|
196
196
|
const { unitId: t, subUnitId: o, row: r, col: s } = e.location, n = this._renderManagerService.getRenderById(t), c = (p = n == null ? void 0 : n.with(ce).getSkeletonParam(o)) == null ? void 0 : p.skeleton;
|
|
@@ -229,21 +229,21 @@ let L = class extends E {
|
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
|
-
L =
|
|
232
|
+
L = Ct([
|
|
233
233
|
w(0, g(I)),
|
|
234
234
|
w(1, g($)),
|
|
235
235
|
w(2, g(G)),
|
|
236
|
-
w(3,
|
|
236
|
+
w(3, Ye),
|
|
237
237
|
w(4, z),
|
|
238
|
-
w(5, g(
|
|
238
|
+
w(5, g(Je))
|
|
239
239
|
], L);
|
|
240
240
|
const Ne = "sheets-note-ui.config", pe = {};
|
|
241
|
-
var
|
|
242
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
241
|
+
var gt = Object.getOwnPropertyDescriptor, vt = (i, e, t, o) => {
|
|
242
|
+
for (var r = o > 1 ? void 0 : o ? gt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
243
243
|
(n = i[s]) && (r = n(r) || r);
|
|
244
244
|
return r;
|
|
245
245
|
}, O = (i, e) => (t, o) => e(t, o, i);
|
|
246
|
-
let
|
|
246
|
+
let R = class extends E {
|
|
247
247
|
constructor(e, t, o, r) {
|
|
248
248
|
super();
|
|
249
249
|
P(this, "_noteMatrix", new F());
|
|
@@ -317,9 +317,9 @@ let U = class extends E {
|
|
|
317
317
|
_initNoteChangeListener() {
|
|
318
318
|
this.disposeWithMe(
|
|
319
319
|
this._univerInstanceService.getCurrentTypeOfUnit$(y.UNIVER_SHEET).pipe(
|
|
320
|
-
|
|
320
|
+
Ge((e) => {
|
|
321
321
|
var t;
|
|
322
|
-
return (t = e == null ? void 0 : e.activeSheet$) != null ? t :
|
|
322
|
+
return (t = e == null ? void 0 : e.activeSheet$) != null ? t : Ke(null);
|
|
323
323
|
})
|
|
324
324
|
).subscribe((e) => {
|
|
325
325
|
if (e) {
|
|
@@ -335,14 +335,14 @@ let U = class extends E {
|
|
|
335
335
|
);
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
|
-
|
|
338
|
+
R = vt([
|
|
339
339
|
O(0, g($)),
|
|
340
340
|
O(1, g(Z)),
|
|
341
341
|
O(2, g(ve)),
|
|
342
342
|
O(3, g(I))
|
|
343
|
-
],
|
|
343
|
+
], R);
|
|
344
344
|
function B({ ref: i, ...e }) {
|
|
345
|
-
const { icon: t, id: o, className: r, extend: s, ...n } = e, c = `univerjs-icon univerjs-icon-${o} ${r || ""}`.trim(), u = Se(`_${
|
|
345
|
+
const { icon: t, id: o, className: r, extend: s, ...n } = e, c = `univerjs-icon univerjs-icon-${o} ${r || ""}`.trim(), u = Se(`_${Nt()}`);
|
|
346
346
|
return Pe(t, `${o}`, {
|
|
347
347
|
defIds: t.defIds,
|
|
348
348
|
idSuffix: u.current
|
|
@@ -355,11 +355,11 @@ function B({ ref: i, ...e }) {
|
|
|
355
355
|
function Pe(i, e, t, o, r) {
|
|
356
356
|
return j(i.tag, {
|
|
357
357
|
key: e,
|
|
358
|
-
...
|
|
358
|
+
...mt(i, t, r),
|
|
359
359
|
...o
|
|
360
|
-
}, (
|
|
360
|
+
}, (St(i, t).children || []).map((s, n) => Pe(s, `${e}-${i.tag}-${n}`, t, void 0, r)));
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function mt(i, e, t) {
|
|
363
363
|
const o = { ...i.attrs };
|
|
364
364
|
t != null && t.colorChannel1 && o.fill === "colorChannel1" && (o.fill = t.colorChannel1), i.tag === "mask" && o.id && (o.id = o.id + e.idSuffix), Object.entries(o).forEach(([s, n]) => {
|
|
365
365
|
s === "mask" && typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
@@ -369,7 +369,7 @@ function vt(i, e, t) {
|
|
|
369
369
|
typeof n == "string" && (o[s] = n.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
|
|
370
370
|
})), o;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function St(i, e) {
|
|
373
373
|
var o;
|
|
374
374
|
const { defIds: t } = e;
|
|
375
375
|
return !t || t.length === 0 ? i : i.tag === "defs" && ((o = i.children) != null && o.length) ? {
|
|
@@ -383,11 +383,11 @@ function mt(i, e) {
|
|
|
383
383
|
} : r)
|
|
384
384
|
} : i;
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function Nt() {
|
|
387
387
|
return Math.random().toString(36).substring(2, 8);
|
|
388
388
|
}
|
|
389
389
|
B.displayName = "UniverIcon";
|
|
390
|
-
const
|
|
390
|
+
const Pt = {
|
|
391
391
|
tag: "svg",
|
|
392
392
|
attrs: {
|
|
393
393
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -444,11 +444,11 @@ const Nt = {
|
|
|
444
444
|
return j(B, Object.assign({}, e, {
|
|
445
445
|
id: "add-note-icon",
|
|
446
446
|
ref: t,
|
|
447
|
-
icon:
|
|
447
|
+
icon: Pt
|
|
448
448
|
}));
|
|
449
449
|
});
|
|
450
450
|
Ie.displayName = "AddNoteIcon";
|
|
451
|
-
const
|
|
451
|
+
const It = {
|
|
452
452
|
tag: "svg",
|
|
453
453
|
attrs: {
|
|
454
454
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -498,11 +498,11 @@ const Pt = {
|
|
|
498
498
|
return j(B, Object.assign({}, e, {
|
|
499
499
|
id: "delete-note-icon",
|
|
500
500
|
ref: t,
|
|
501
|
-
icon:
|
|
501
|
+
icon: It
|
|
502
502
|
}));
|
|
503
503
|
});
|
|
504
504
|
we.displayName = "DeleteNoteIcon";
|
|
505
|
-
const
|
|
505
|
+
const wt = {
|
|
506
506
|
tag: "svg",
|
|
507
507
|
attrs: {
|
|
508
508
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -559,11 +559,11 @@ const It = {
|
|
|
559
559
|
return j(B, Object.assign({}, e, {
|
|
560
560
|
id: "hide-note-icon",
|
|
561
561
|
ref: t,
|
|
562
|
-
icon:
|
|
562
|
+
icon: wt
|
|
563
563
|
}));
|
|
564
564
|
});
|
|
565
565
|
Me.displayName = "HideNoteIcon";
|
|
566
|
-
const
|
|
566
|
+
const U = {
|
|
567
567
|
id: "sheet.operation.add-note-popup",
|
|
568
568
|
type: Oe.OPERATION,
|
|
569
569
|
handler: async (i, e) => {
|
|
@@ -584,12 +584,12 @@ const R = {
|
|
|
584
584
|
trigger: (l = e == null ? void 0 : e.trigger) != null ? l : "add-note"
|
|
585
585
|
}), !0;
|
|
586
586
|
}
|
|
587
|
-
},
|
|
587
|
+
}, Mt = (i) => {
|
|
588
588
|
var S;
|
|
589
|
-
const { popup: e } = i, t = b($), o = b(Te), r = b(z), s = b(I), n =
|
|
589
|
+
const { popup: e } = i, t = b($), o = b(Te), r = b(z), s = b(I), n = et(Ne), c = (S = e.extraProps) == null ? void 0 : S.location;
|
|
590
590
|
if (!c)
|
|
591
591
|
return console.error("Popup extraProps or location is undefined."), null;
|
|
592
|
-
const u = Se(null), l = r.getRenderById(c.unitId), [a, p] =
|
|
592
|
+
const u = Se(null), l = r.getRenderById(c.unitId), [a, p] = ct(null);
|
|
593
593
|
ae(() => {
|
|
594
594
|
var Q, X, ee, te, ie, oe;
|
|
595
595
|
const { unitId: h, subUnitId: C, row: f, col: x } = c, v = t.getNote(h, C, { row: f, col: x }), A = (ee = (X = v == null ? void 0 : v.width) != null ? X : (Q = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : Q.width) != null ? ee : 160, M = (oe = (ie = v == null ? void 0 : v.height) != null ? ie : (te = n == null ? void 0 : n.defaultNoteSize) == null ? void 0 : te.height) != null ? oe : 72;
|
|
@@ -597,6 +597,7 @@ const R = {
|
|
|
597
597
|
p(v);
|
|
598
598
|
else {
|
|
599
599
|
const re = {
|
|
600
|
+
id: Le(6),
|
|
600
601
|
width: A,
|
|
601
602
|
height: M,
|
|
602
603
|
note: ""
|
|
@@ -612,10 +613,10 @@ const R = {
|
|
|
612
613
|
});
|
|
613
614
|
return () => cancelAnimationFrame(h);
|
|
614
615
|
}, [c]);
|
|
615
|
-
const d = b(de), _ =
|
|
616
|
+
const d = b(de), _ = tt((h) => {
|
|
616
617
|
if (!c) return;
|
|
617
618
|
const { unitId: C, subUnitId: f, row: x, col: v } = c;
|
|
618
|
-
if (!d.syncExecuteCommand(
|
|
619
|
+
if (!d.syncExecuteCommand(Ae.id, {
|
|
619
620
|
unitId: C,
|
|
620
621
|
sheetId: f,
|
|
621
622
|
row: x,
|
|
@@ -634,12 +635,12 @@ const R = {
|
|
|
634
635
|
const f = { ...a, width: h, height: C };
|
|
635
636
|
p(f), _(f);
|
|
636
637
|
}, [a]);
|
|
637
|
-
return /* @__PURE__ */
|
|
638
|
-
|
|
638
|
+
return /* @__PURE__ */ at(
|
|
639
|
+
ut,
|
|
639
640
|
{
|
|
640
641
|
ref: u,
|
|
641
642
|
"data-u-comp": "note-textarea",
|
|
642
|
-
className:
|
|
643
|
+
className: lt("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),
|
|
643
644
|
value: a == null ? void 0 : a.note,
|
|
644
645
|
placeholder: o.t("note.placeholder"),
|
|
645
646
|
onResize: N,
|
|
@@ -655,24 +656,24 @@ function J(i) {
|
|
|
655
656
|
return e.selectionMoveEnd$.pipe(k(() => {
|
|
656
657
|
const o = e.getCurrentLastSelection();
|
|
657
658
|
if (!(o != null && o.primary)) return !1;
|
|
658
|
-
const r =
|
|
659
|
+
const r = Be(t);
|
|
659
660
|
if (!r) return !1;
|
|
660
661
|
const { actualColumn: s, actualRow: n } = o.primary;
|
|
661
662
|
return !!i.get($).getNote(r.unitId, r.subUnitId, { row: n, col: s });
|
|
662
663
|
}));
|
|
663
664
|
}
|
|
664
|
-
function
|
|
665
|
+
function bt(i) {
|
|
665
666
|
return {
|
|
666
|
-
id:
|
|
667
|
+
id: U.id,
|
|
667
668
|
type: K.BUTTON,
|
|
668
669
|
title: "rightClick.addNote",
|
|
669
670
|
icon: "AddNoteIcon",
|
|
670
|
-
hidden$:
|
|
671
|
+
hidden$: qe([it(i, y.UNIVER_SHEET), J(i)]).pipe(k(([e, t]) => e || t)),
|
|
671
672
|
disabled$: me(i, { workbookTypes: [fe], worksheetTypes: [_e] }),
|
|
672
|
-
commandId:
|
|
673
|
+
commandId: U.id
|
|
673
674
|
};
|
|
674
675
|
}
|
|
675
|
-
function
|
|
676
|
+
function Et(i) {
|
|
676
677
|
return {
|
|
677
678
|
id: ge.id,
|
|
678
679
|
type: K.BUTTON,
|
|
@@ -682,7 +683,7 @@ function bt(i) {
|
|
|
682
683
|
disabled$: me(i, { workbookTypes: [fe], worksheetTypes: [_e] })
|
|
683
684
|
};
|
|
684
685
|
}
|
|
685
|
-
function
|
|
686
|
+
function yt(i) {
|
|
686
687
|
return {
|
|
687
688
|
id: Ce.id,
|
|
688
689
|
type: K.BUTTON,
|
|
@@ -691,27 +692,27 @@ function Et(i) {
|
|
|
691
692
|
hidden$: J(i).pipe(k((e) => !e))
|
|
692
693
|
};
|
|
693
694
|
}
|
|
694
|
-
const
|
|
695
|
-
[
|
|
696
|
-
[
|
|
695
|
+
const $t = {
|
|
696
|
+
[ot.MAIN_AREA]: {
|
|
697
|
+
[rt.OTHERS]: {
|
|
697
698
|
order: 0,
|
|
698
|
-
[
|
|
699
|
+
[U.id]: {
|
|
699
700
|
order: 0,
|
|
700
|
-
menuItemFactory:
|
|
701
|
+
menuItemFactory: bt
|
|
701
702
|
},
|
|
702
703
|
[ge.id]: {
|
|
703
704
|
order: 0,
|
|
704
|
-
menuItemFactory:
|
|
705
|
+
menuItemFactory: Et
|
|
705
706
|
},
|
|
706
707
|
[Ce.id]: {
|
|
707
708
|
order: 0,
|
|
708
|
-
menuItemFactory:
|
|
709
|
+
menuItemFactory: yt
|
|
709
710
|
}
|
|
710
711
|
}
|
|
711
712
|
}
|
|
712
713
|
};
|
|
713
|
-
var
|
|
714
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
714
|
+
var xt = Object.getOwnPropertyDescriptor, Ht = (i, e, t, o) => {
|
|
715
|
+
for (var r = o > 1 ? void 0 : o ? xt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
715
716
|
(n = i[s]) && (r = n(r) || r);
|
|
716
717
|
return r;
|
|
717
718
|
}, W = (i, e) => (t, o) => e(t, o, i);
|
|
@@ -721,7 +722,7 @@ let D = class extends E {
|
|
|
721
722
|
}
|
|
722
723
|
_initComponents() {
|
|
723
724
|
[
|
|
724
|
-
[Y,
|
|
725
|
+
[Y, Mt],
|
|
725
726
|
["AddNoteIcon", Ie],
|
|
726
727
|
["DeleteNoteIcon", we],
|
|
727
728
|
["HideNoteIcon", Me]
|
|
@@ -732,27 +733,27 @@ let D = class extends E {
|
|
|
732
733
|
});
|
|
733
734
|
}
|
|
734
735
|
_initMenu() {
|
|
735
|
-
this._menuManagerService.mergeMenu(
|
|
736
|
+
this._menuManagerService.mergeMenu($t);
|
|
736
737
|
}
|
|
737
738
|
_initCommands() {
|
|
738
|
-
this._commandService.registerCommand(
|
|
739
|
+
this._commandService.registerCommand(U);
|
|
739
740
|
}
|
|
740
741
|
};
|
|
741
|
-
D =
|
|
742
|
-
W(0, g(
|
|
743
|
-
W(1, g(
|
|
742
|
+
D = Ht([
|
|
743
|
+
W(0, g(nt)),
|
|
744
|
+
W(1, g(st)),
|
|
744
745
|
W(2, de)
|
|
745
746
|
], D);
|
|
746
|
-
var
|
|
747
|
-
for (var r = o > 1 ? void 0 : o ?
|
|
747
|
+
var Ot = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, Lt = (i, e, t) => e in i ? Ot(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Rt = (i, e, t, o) => {
|
|
748
|
+
for (var r = o > 1 ? void 0 : o ? Tt(e, t) : e, s = i.length - 1, n; s >= 0; s--)
|
|
748
749
|
(n = i[s]) && (r = n(r) || r);
|
|
749
750
|
return r;
|
|
750
|
-
}, he = (i, e) => (t, o) => e(t, o, i), be = (i, e, t) =>
|
|
751
|
+
}, he = (i, e) => (t, o) => e(t, o, i), be = (i, e, t) => Lt(i, typeof e != "symbol" ? e + "" : e, t);
|
|
751
752
|
const Ut = "SHEET_NOTE_UI_PLUGIN";
|
|
752
|
-
let V = class extends
|
|
753
|
+
let V = class extends Ve {
|
|
753
754
|
constructor(i = pe, e, t) {
|
|
754
755
|
super(), this._config = i, this._injector = e, this._configService = t;
|
|
755
|
-
const { menu: o, ...r } =
|
|
756
|
+
const { menu: o, ...r } = Ze(
|
|
756
757
|
{},
|
|
757
758
|
pe,
|
|
758
759
|
this._config
|
|
@@ -765,7 +766,7 @@ let V = class extends De {
|
|
|
765
766
|
[T],
|
|
766
767
|
[L],
|
|
767
768
|
[D],
|
|
768
|
-
[
|
|
769
|
+
[R]
|
|
769
770
|
].forEach((i) => {
|
|
770
771
|
this._injector.add(i);
|
|
771
772
|
});
|
|
@@ -779,20 +780,20 @@ let V = class extends De {
|
|
|
779
780
|
onRendered() {
|
|
780
781
|
se(this._injector, [
|
|
781
782
|
[L],
|
|
782
|
-
[
|
|
783
|
+
[R]
|
|
783
784
|
]);
|
|
784
785
|
}
|
|
785
786
|
};
|
|
786
787
|
be(V, "pluginName", Ut);
|
|
787
788
|
be(V, "type", y.UNIVER_SHEET);
|
|
788
|
-
V =
|
|
789
|
-
|
|
789
|
+
V = Rt([
|
|
790
|
+
Re(Fe),
|
|
790
791
|
he(1, g(Ue)),
|
|
791
|
-
he(2,
|
|
792
|
+
he(2, De)
|
|
792
793
|
], V);
|
|
793
794
|
export {
|
|
794
795
|
T as SheetsCellContentController,
|
|
795
|
-
|
|
796
|
+
Mt as SheetsNote,
|
|
796
797
|
L as SheetsNotePopupController,
|
|
797
798
|
I as SheetsNotePopupService,
|
|
798
799
|
V as UniverSheetsNoteUIPlugin
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("react/jsx-runtime"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-note","rxjs","@univerjs/sheets-ui","rxjs/operators","@univerjs/ui","react","react/jsx-runtime","@univerjs/design"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsNoteUi={},c.UniverCore,c.UniverEngineRender,c.UniverSheets,c.UniverSheetsNote,c.rxjs,c.UniverSheetsUi,c.rxjs.operators,c.UniverUi,c.React,c.React,c.UniverDesign))})(this,(function(c,a,y,N,I,b,E,ce,f,S,ue,W){"use strict";var He=Object.defineProperty;var Re=(c,a,y)=>a in c?He(c,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[a]=y;var $=(c,a,y)=>Re(c,typeof a!="symbol"?a+"":a,y);var le=Object.getOwnPropertyDescriptor,pe=(r,t,e,i)=>{for(var n=i>1?void 0:i?le(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},D=(r,t)=>(e,i)=>t(e,i,r);c.SheetsCellContentController=class extends a.Disposable{constructor(t,e,i,n){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._renderManagerService=i,this._univerInstanceService=n,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(t,e,i)=>{const{row:n,col:o,unitId:s,subUnitId:l}=e;return this._sheetsNoteModel.getNote(s,l,{row:n,col:o})&&((!t||t===e.rawData)&&(t={...e.rawData}),t.markers={...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}),i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const i=e.getUnitId(),n=this._renderManagerService.getRenderById(i);(o=n==null?void 0:n.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(b.debounceTime(16)).subscribe(()=>{t()}))}},c.SheetsCellContentController=pe([D(0,a.Inject(N.SheetInterceptorService)),D(1,a.Inject(I.SheetsNoteModel)),D(2,y.IRenderManagerService),D(3,a.IUniverInstanceService)],c.SheetsCellContentController);const k="SHEET_NOTE_COMPONENT";var he=Object.getOwnPropertyDescriptor,de=(r,t,e,i)=>{for(var n=i>1?void 0:i?he(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},F=(r,t)=>(e,i)=>t(e,i,r);c.SheetsNotePopupService=class extends a.Disposable{constructor(e,i){super();$(this,"_lastPopup",null);$(this,"_activePopup");$(this,"_activePopup$",new b.BehaviorSubject(null));$(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(e,i){var p;const{row:n,col:o,unitId:s,subUnitId:l}=e;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&l===((p=this.activePopup)==null?void 0:p.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=e,this._activePopup$.next(e);const u=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:l,row:n,col:o},{componentKey:k,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:e},priority:3});if(!u)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(u),d.add({dispose:()=>{i==null||i()}}),this._lastPopup=d}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsNotePopupService=de([F(0,f.IZenZoneService),F(1,a.Inject(E.CellPopupManagerService))],c.SheetsNotePopupService);var ve=Object.getOwnPropertyDescriptor,Ce=(r,t,e,i)=>{for(var n=i>1?void 0:i?ve(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},O=(r,t)=>(e,i)=>t(e,i,r);c.SheetsNotePopupController=class extends a.Disposable{constructor(e,i,n,o,s,l){super();$(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=e,this._sheetsNoteModel=i,this._sheetSelectionService=n,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=l,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,i,n){var g,M,w;const o=(g=e[0])==null?void 0:g.range,s=this._renderManagerService.getRenderById(i),l=(M=s==null?void 0:s.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:M.skeleton;if(!l||!o)return;const u=l.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((w=o.rangeType)!=null?w:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&a.Rectangle.equals(u.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const p=u.actualRow,h=u.actualColumn,C=this._sheetsNoteModel.getNote(i,n,{row:p,col:h});C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:C.id,row:p,col:h}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(e,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ce.debounceTime(100)).subscribe(e=>{var C;if(!(e!=null&&e.location))return;const{unitId:i,subUnitId:n,row:o,col:s}=e.location,l=this._renderManagerService.getRenderById(i),u=(C=l==null?void 0:l.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:C.skeleton;let d=o,p=s,h=this._sheetsNoteModel.getNote(i,n,{row:d,col:p});if(!h&&u){const g=u.getCellWithCoordByIndex(o,s),{startRow:M,endRow:w,startColumn:U,endColumn:v}=g.mergeInfo;if(M!==w||U!==v){const _=this._sheetsNoteModel.getSheetNotes(i,n);if(_){for(const[T,m]of _)if(m.row>=M&&m.row<=w&&m.col>=U&&m.col<=v){h=m,d=m.row,p=m.col;break}}}}h!=null&&h.show||(h?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:h.id,row:d,col:p,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;const{unitId:i,subUnitId:n,noteId:o,row:s,col:l}=this._sheetsNotePopupService.activePopup,{oldNote:u,newNote:d}=e;d===null&&e.unitId===i&&e.subUnitId===n&&(u!=null&&u.id&&u.id===o||(u==null?void 0:u.row)===s&&u.col===l)&&this._sheetsNotePopupService.hidePopup(!0)}))}},c.SheetsNotePopupController=Ce([O(0,a.Inject(c.SheetsNotePopupService)),O(1,a.Inject(I.SheetsNoteModel)),O(2,a.Inject(N.SheetsSelectionsService)),O(3,E.IEditorBridgeService),O(4,y.IRenderManagerService),O(5,a.Inject(E.HoverManagerService))],c.SheetsNotePopupController);const q="sheets-note-ui.config",z={};var fe=Object.getOwnPropertyDescriptor,_e=(r,t,e,i)=>{for(var n=i>1?void 0:i?fe(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},H=(r,t)=>(e,i)=>t(e,i,r);let R=class extends a.Disposable{constructor(t,e,i,n){super();$(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=e,this._cellPopupManagerService=i,this._sheetsNotePopupService=n,this._initNoteChangeListener()}_showPopup(t,e,i,n){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:e,row:i,col:n},{componentKey:k,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:e,row:i,col:n}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((t,e,i)=>{i.dispose()})}_initSheet(t,e){var o;this._noteMatrix.forValue((s,l,u)=>{u.dispose()}),this._noteMatrix=new a.ObjectMatrix;const n=(s,l,u,d,p)=>{const h=this._noteMatrix,C=h.getValue(u,d);if(p!=null&&p.show){if(!C){const g=this._showPopup(s,l,u,d);g&&h.setValue(u,d,g)}}else C&&(C.dispose(),h.realDeleteValue(u,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,e))==null||o.forEach(s=>{n(t,e,s.row,s.col,s)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==t||s.subUnitId!==e))switch(s.type){case"ref":{const{unitId:l,subUnitId:u,oldNote:d,newNote:p}=s;if(!p.show)return;const h=this._noteMatrix,{row:C,col:g}=d,{row:M,col:w}=p,U=h.getValue(C,g);U&&(U.dispose(),h.realDeleteValue(C,g));const v=this._showPopup(l,u,M,w);v&&h.setValue(M,w,v);break}case"update":{const{unitId:l,subUnitId:u,oldNote:d,newNote:p}=s,h=p?p.row:d.row,C=p?p.col:d.col;n(l,u,h,C,p);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(b.switchMap(t=>{var e;return(e=t==null?void 0:t.activeSheet$)!=null?e:b.of(null)})).subscribe(t=>{if(t){const e=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{e.unsubscribe()}}else this._noteMatrix.forValue((e,i,n)=>{n.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};R=_e([H(0,a.Inject(I.SheetsNoteModel)),H(1,a.Inject(a.IUniverInstanceService)),H(2,a.Inject(E.CellPopupManagerService)),H(3,a.Inject(c.SheetsNotePopupService))],R);function L({ref:r,...t}){const{icon:e,id:i,className:n,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${n||""}`.trim(),u=S.useRef(`_${me()}`);return G(e,`${i}`,{defIds:e.defIds,idSuffix:u.current},{ref:r,className:l,...s},o)}function G(r,t,e,i,n){return S.createElement(r.tag,{key:t,...Se(r,e,n),...i},(ge(r,e).children||[]).map((o,s)=>G(o,`${t}-${r.tag}-${s}`,e,void 0,n)))}function Se(r,t,e){const i={...r.attrs};e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(([o,s])=>{o==="mask"&&typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:n}=t;return!n||n.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(([o,s])=>{typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),i}function ge(r,t){var i;const{defIds:e}=t;return!e||e.length===0?r:r.tag==="defs"&&((i=r.children)!=null&&i.length)?{...r,children:r.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+t.idSuffix}}:n)}:r}function me(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";const Ie={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},K=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"add-note-icon",ref:e,icon:Ie}))});K.displayName="AddNoteIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"}}]},Y=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"delete-note-icon",ref:e,icon:Pe}))});Y.displayName="DeleteNoteIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},J=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"hide-note-icon",ref:e,icon:Ne}))});J.displayName="HideNoteIcon";const x={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(r,t)=>{var d;const e=r.get(N.SheetsSelectionsService),i=r.get(c.SheetsNotePopupService),o=r.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),l=e.getCurrentLastSelection();if(!(l!=null&&l.primary))return!1;const{primary:u}=l;return i.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:(d=t==null?void 0:t.trigger)!=null?d:"add-note"}),!0}},Q=r=>{var U;const{popup:t}=r,e=f.useDependency(I.SheetsNoteModel),i=f.useDependency(a.LocaleService),n=f.useDependency(y.IRenderManagerService),o=f.useDependency(c.SheetsNotePopupService),s=f.useConfigValue(q),l=(U=t.extraProps)==null?void 0:U.location;if(!l)return console.error("Popup extraProps or location is undefined."),null;const u=S.useRef(null),d=n.getRenderById(l.unitId),[p,h]=S.useState(null);S.useEffect(()=>{var te,ie,ne,re,oe,se;const{unitId:v,subUnitId:_,row:T,col:m}=l,P=e.getNote(v,_,{row:T,col:m}),B=(ne=(ie=P==null?void 0:P.width)!=null?ie:(te=s==null?void 0:s.defaultNoteSize)==null?void 0:te.width)!=null?ne:160,j=(se=(oe=P==null?void 0:P.height)!=null?oe:(re=s==null?void 0:s.defaultNoteSize)==null?void 0:re.height)!=null?se:72;if(P)h(P);else{const ae={width:B,height:j,note:""};h(ae),g(ae)}u.current&&(u.current.style.width=`${B}px`,u.current.style.height=`${j}px`)},[l,u]),S.useEffect(()=>{if(!l||l.temp||!l.trigger||!u.current)return;const v=requestAnimationFrame(()=>{var _;(_=u.current)==null||_.focus()});return()=>cancelAnimationFrame(v)},[l]);const C=f.useDependency(a.ICommandService),g=f.useDebounceFn(v=>{if(!l)return;const{unitId:_,subUnitId:T,row:m,col:P}=l;if(!C.syncExecuteCommand(I.SheetUpdateNoteCommand.id,{unitId:_,sheetId:T,row:m,col:P,note:v})){const j=e.getNote(_,T,{noteId:v.id,row:m,col:P});j?h(j):o.hidePopup(!0)}}),M=S.useCallback(v=>{if(!p||v===p.note)return;const _={...p,note:v};h(_),g(_)},[p]),w=S.useCallback((v,_)=>{if(!p||v===p.width&&_===p.height)return;const T={...p,width:v,height:_};h(T),g(T)},[p]);return ue.jsx(W.Textarea,{ref:u,"data-u-comp":"note-textarea",className:W.clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),value:p==null?void 0:p.note,placeholder:i.t("note.placeholder"),onResize:w,onValueChange:M,onWheel:v=>{document.activeElement!==u.current&&d.engine.getCanvasElement().dispatchEvent(new WheelEvent(v.type,v.nativeEvent))}})};function Z(r){const t=r.get(N.SheetsSelectionsService),e=r.get(a.IUniverInstanceService);return t.selectionMoveEnd$.pipe(b.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const n=N.getSheetCommandTarget(e);if(!n)return!1;const{actualColumn:o,actualRow:s}=i.primary;return!!r.get(I.SheetsNoteModel).getNote(n.unitId,n.subUnitId,{row:s,col:o})}))}function Me(r){return{id:x.id,type:f.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:b.combineLatest([f.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),Z(r)]).pipe(b.map(([t,e])=>t||e)),disabled$:E.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:x.id}}function we(r){return{id:I.SheetDeleteNoteCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:Z(r).pipe(b.map(t=>!t)),disabled$:E.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function be(r){return{id:I.SheetToggleNotePopupCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:Z(r).pipe(b.map(t=>!t))}}const ye={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:0,[x.id]:{order:0,menuItemFactory:Me},[I.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:we},[I.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:be}}}};var Ee=Object.getOwnPropertyDescriptor,Ue=(r,t,e,i)=>{for(var n=i>1?void 0:i?Ee(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},A=(r,t)=>(e,i)=>t(e,i,r);let V=class extends a.Disposable{constructor(r,t,e){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=e,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[k,Q],["AddNoteIcon",K],["DeleteNoteIcon",Y],["HideNoteIcon",J]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}_initMenu(){this._menuManagerService.mergeMenu(ye)}_initCommands(){this._commandService.registerCommand(x)}};V=Ue([A(0,a.Inject(f.ComponentManager)),A(1,a.Inject(f.IMenuManagerService)),A(2,a.ICommandService)],V);var Te=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Oe=(r,t,e)=>t in r?Te(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,je=(r,t,e,i)=>{for(var n=i>1?void 0:i?$e(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},X=(r,t)=>(e,i)=>t(e,i,r),ee=(r,t,e)=>Oe(r,typeof t!="symbol"?t+"":t,e);const De="SHEET_NOTE_UI_PLUGIN";c.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(t=z,e,i){super(),this._config=t,this._injector=e,this._configService=i;const{menu:n,...o}=a.merge({},z,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(q,o)}onStarting(){[[c.SheetsNotePopupService],[c.SheetsCellContentController],[c.SheetsNotePopupController],[V],[R]].forEach(t=>{this._injector.add(t)})}onReady(){a.touchDependencies(this._injector,[[V],[c.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[c.SheetsNotePopupController],[R]])}},ee(c.UniverSheetsNoteUIPlugin,"pluginName",De),ee(c.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsNoteUIPlugin=je([a.DependentOn(I.UniverSheetsNotePlugin),X(1,a.Inject(a.Injector)),X(2,a.IConfigService)],c.UniverSheetsNoteUIPlugin),c.SheetsNote=Q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("react/jsx-runtime"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-note","rxjs","@univerjs/sheets-ui","rxjs/operators","@univerjs/ui","react","react/jsx-runtime","@univerjs/design"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsNoteUi={},c.UniverCore,c.UniverEngineRender,c.UniverSheets,c.UniverSheetsNote,c.rxjs,c.UniverSheetsUi,c.rxjs.operators,c.UniverUi,c.React,c.React,c.UniverDesign))})(this,(function(c,a,y,N,I,b,E,ce,f,S,ue,W){"use strict";var He=Object.defineProperty;var Re=(c,a,y)=>a in c?He(c,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[a]=y;var $=(c,a,y)=>Re(c,typeof a!="symbol"?a+"":a,y);var le=Object.getOwnPropertyDescriptor,pe=(r,t,e,i)=>{for(var n=i>1?void 0:i?le(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},D=(r,t)=>(e,i)=>t(e,i,r);c.SheetsCellContentController=class extends a.Disposable{constructor(t,e,i,n){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._renderManagerService=i,this._univerInstanceService=n,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(t,e,i)=>{const{row:n,col:o,unitId:s,subUnitId:l}=e;return this._sheetsNoteModel.getNote(s,l,{row:n,col:o})&&((!t||t===e.rawData)&&(t={...e.rawData}),t.markers={...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}),i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const i=e.getUnitId(),n=this._renderManagerService.getRenderById(i);(o=n==null?void 0:n.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(b.debounceTime(16)).subscribe(()=>{t()}))}},c.SheetsCellContentController=pe([D(0,a.Inject(N.SheetInterceptorService)),D(1,a.Inject(I.SheetsNoteModel)),D(2,y.IRenderManagerService),D(3,a.IUniverInstanceService)],c.SheetsCellContentController);const k="SHEET_NOTE_COMPONENT";var he=Object.getOwnPropertyDescriptor,de=(r,t,e,i)=>{for(var n=i>1?void 0:i?he(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},F=(r,t)=>(e,i)=>t(e,i,r);c.SheetsNotePopupService=class extends a.Disposable{constructor(e,i){super();$(this,"_lastPopup",null);$(this,"_activePopup");$(this,"_activePopup$",new b.BehaviorSubject(null));$(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(e,i){var p;const{row:n,col:o,unitId:s,subUnitId:l}=e;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&l===((p=this.activePopup)==null?void 0:p.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=e,this._activePopup$.next(e);const u=this._cellPopupManagerService.showPopup({unitId:s,subUnitId:l,row:n,col:o},{componentKey:k,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:e},priority:3});if(!u)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(u),d.add({dispose:()=>{i==null||i()}}),this._lastPopup=d}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsNotePopupService=de([F(0,f.IZenZoneService),F(1,a.Inject(E.CellPopupManagerService))],c.SheetsNotePopupService);var ve=Object.getOwnPropertyDescriptor,Ce=(r,t,e,i)=>{for(var n=i>1?void 0:i?ve(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},O=(r,t)=>(e,i)=>t(e,i,r);c.SheetsNotePopupController=class extends a.Disposable{constructor(e,i,n,o,s,l){super();$(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=e,this._sheetsNoteModel=i,this._sheetSelectionService=n,this._editorBridgeService=o,this._renderManagerService=s,this._hoverManagerService=l,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,i,n){var g,M,w;const o=(g=e[0])==null?void 0:g.range,s=this._renderManagerService.getRenderById(i),l=(M=s==null?void 0:s.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:M.skeleton;if(!l||!o)return;const u=l.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((w=o.rangeType)!=null?w:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&a.Rectangle.equals(u.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const p=u.actualRow,h=u.actualColumn,C=this._sheetsNoteModel.getNote(i,n,{row:p,col:h});C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:C.id,row:p,col:h}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(e,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ce.debounceTime(100)).subscribe(e=>{var C;if(!(e!=null&&e.location))return;const{unitId:i,subUnitId:n,row:o,col:s}=e.location,l=this._renderManagerService.getRenderById(i),u=(C=l==null?void 0:l.with(E.SheetSkeletonManagerService).getSkeletonParam(n))==null?void 0:C.skeleton;let d=o,p=s,h=this._sheetsNoteModel.getNote(i,n,{row:d,col:p});if(!h&&u){const g=u.getCellWithCoordByIndex(o,s),{startRow:M,endRow:w,startColumn:U,endColumn:v}=g.mergeInfo;if(M!==w||U!==v){const _=this._sheetsNoteModel.getSheetNotes(i,n);if(_){for(const[T,m]of _)if(m.row>=M&&m.row<=w&&m.col>=U&&m.col<=v){h=m,d=m.row,p=m.col;break}}}}h!=null&&h.show||(h?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:n,noteId:h.id,row:d,col:p,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;const{unitId:i,subUnitId:n,noteId:o,row:s,col:l}=this._sheetsNotePopupService.activePopup,{oldNote:u,newNote:d}=e;d===null&&e.unitId===i&&e.subUnitId===n&&(u!=null&&u.id&&u.id===o||(u==null?void 0:u.row)===s&&u.col===l)&&this._sheetsNotePopupService.hidePopup(!0)}))}},c.SheetsNotePopupController=Ce([O(0,a.Inject(c.SheetsNotePopupService)),O(1,a.Inject(I.SheetsNoteModel)),O(2,a.Inject(N.SheetsSelectionsService)),O(3,E.IEditorBridgeService),O(4,y.IRenderManagerService),O(5,a.Inject(E.HoverManagerService))],c.SheetsNotePopupController);const q="sheets-note-ui.config",z={};var fe=Object.getOwnPropertyDescriptor,_e=(r,t,e,i)=>{for(var n=i>1?void 0:i?fe(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},H=(r,t)=>(e,i)=>t(e,i,r);let R=class extends a.Disposable{constructor(t,e,i,n){super();$(this,"_noteMatrix",new a.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=e,this._cellPopupManagerService=i,this._sheetsNotePopupService=n,this._initNoteChangeListener()}_showPopup(t,e,i,n){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:e,row:i,col:n},{componentKey:k,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:e,row:i,col:n}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((t,e,i)=>{i.dispose()})}_initSheet(t,e){var o;this._noteMatrix.forValue((s,l,u)=>{u.dispose()}),this._noteMatrix=new a.ObjectMatrix;const n=(s,l,u,d,p)=>{const h=this._noteMatrix,C=h.getValue(u,d);if(p!=null&&p.show){if(!C){const g=this._showPopup(s,l,u,d);g&&h.setValue(u,d,g)}}else C&&(C.dispose(),h.realDeleteValue(u,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,e))==null||o.forEach(s=>{n(t,e,s.row,s.col,s)}),this._sheetsNoteModel.change$.subscribe(s=>{if(!(s.unitId!==t||s.subUnitId!==e))switch(s.type){case"ref":{const{unitId:l,subUnitId:u,oldNote:d,newNote:p}=s;if(!p.show)return;const h=this._noteMatrix,{row:C,col:g}=d,{row:M,col:w}=p,U=h.getValue(C,g);U&&(U.dispose(),h.realDeleteValue(C,g));const v=this._showPopup(l,u,M,w);v&&h.setValue(M,w,v);break}case"update":{const{unitId:l,subUnitId:u,oldNote:d,newNote:p}=s,h=p?p.row:d.row,C=p?p.col:d.col;n(l,u,h,C,p);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(b.switchMap(t=>{var e;return(e=t==null?void 0:t.activeSheet$)!=null?e:b.of(null)})).subscribe(t=>{if(t){const e=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{e.unsubscribe()}}else this._noteMatrix.forValue((e,i,n)=>{n.dispose()}),this._noteMatrix=new a.ObjectMatrix}))}};R=_e([H(0,a.Inject(I.SheetsNoteModel)),H(1,a.Inject(a.IUniverInstanceService)),H(2,a.Inject(E.CellPopupManagerService)),H(3,a.Inject(c.SheetsNotePopupService))],R);function L({ref:r,...t}){const{icon:e,id:i,className:n,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${n||""}`.trim(),u=S.useRef(`_${me()}`);return G(e,`${i}`,{defIds:e.defIds,idSuffix:u.current},{ref:r,className:l,...s},o)}function G(r,t,e,i,n){return S.createElement(r.tag,{key:t,...Se(r,e,n),...i},(ge(r,e).children||[]).map((o,s)=>G(o,`${t}-${r.tag}-${s}`,e,void 0,n)))}function Se(r,t,e){const i={...r.attrs};e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(([o,s])=>{o==="mask"&&typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:n}=t;return!n||n.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(([o,s])=>{typeof s=="string"&&(i[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),i}function ge(r,t){var i;const{defIds:e}=t;return!e||e.length===0?r:r.tag==="defs"&&((i=r.children)!=null&&i.length)?{...r,children:r.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+t.idSuffix}}:n)}:r}function me(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";const Ie={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},K=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"add-note-icon",ref:e,icon:Ie}))});K.displayName="AddNoteIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z"}}]},Y=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"delete-note-icon",ref:e,icon:Pe}))});Y.displayName="DeleteNoteIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},J=S.forwardRef(function(t,e){return S.createElement(L,Object.assign({},t,{id:"hide-note-icon",ref:e,icon:Ne}))});J.displayName="HideNoteIcon";const x={id:"sheet.operation.add-note-popup",type:a.CommandType.OPERATION,handler:async(r,t)=>{var d;const e=r.get(N.SheetsSelectionsService),i=r.get(c.SheetsNotePopupService),o=r.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const s=o.getActiveSheet(),l=e.getCurrentLastSelection();if(!(l!=null&&l.primary))return!1;const{primary:u}=l;return i.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:u.actualRow,col:u.actualColumn,temp:!1,trigger:(d=t==null?void 0:t.trigger)!=null?d:"add-note"}),!0}},Q=r=>{var U;const{popup:t}=r,e=f.useDependency(I.SheetsNoteModel),i=f.useDependency(a.LocaleService),n=f.useDependency(y.IRenderManagerService),o=f.useDependency(c.SheetsNotePopupService),s=f.useConfigValue(q),l=(U=t.extraProps)==null?void 0:U.location;if(!l)return console.error("Popup extraProps or location is undefined."),null;const u=S.useRef(null),d=n.getRenderById(l.unitId),[p,h]=S.useState(null);S.useEffect(()=>{var te,ie,ne,re,oe,se;const{unitId:v,subUnitId:_,row:T,col:m}=l,P=e.getNote(v,_,{row:T,col:m}),B=(ne=(ie=P==null?void 0:P.width)!=null?ie:(te=s==null?void 0:s.defaultNoteSize)==null?void 0:te.width)!=null?ne:160,j=(se=(oe=P==null?void 0:P.height)!=null?oe:(re=s==null?void 0:s.defaultNoteSize)==null?void 0:re.height)!=null?se:72;if(P)h(P);else{const ae={id:a.generateRandomId(6),width:B,height:j,note:""};h(ae),g(ae)}u.current&&(u.current.style.width=`${B}px`,u.current.style.height=`${j}px`)},[l,u]),S.useEffect(()=>{if(!l||l.temp||!l.trigger||!u.current)return;const v=requestAnimationFrame(()=>{var _;(_=u.current)==null||_.focus()});return()=>cancelAnimationFrame(v)},[l]);const C=f.useDependency(a.ICommandService),g=f.useDebounceFn(v=>{if(!l)return;const{unitId:_,subUnitId:T,row:m,col:P}=l;if(!C.syncExecuteCommand(I.SheetUpdateNoteCommand.id,{unitId:_,sheetId:T,row:m,col:P,note:v})){const j=e.getNote(_,T,{noteId:v.id,row:m,col:P});j?h(j):o.hidePopup(!0)}}),M=S.useCallback(v=>{if(!p||v===p.note)return;const _={...p,note:v};h(_),g(_)},[p]),w=S.useCallback((v,_)=>{if(!p||v===p.width&&_===p.height)return;const T={...p,width:v,height:_};h(T),g(T)},[p]);return ue.jsx(W.Textarea,{ref:u,"data-u-comp":"note-textarea",className:W.clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-white !univer-text-sm univer-shadow dark:!univer-bg-gray-800"),value:p==null?void 0:p.note,placeholder:i.t("note.placeholder"),onResize:w,onValueChange:M,onWheel:v=>{document.activeElement!==u.current&&d.engine.getCanvasElement().dispatchEvent(new WheelEvent(v.type,v.nativeEvent))}})};function Z(r){const t=r.get(N.SheetsSelectionsService),e=r.get(a.IUniverInstanceService);return t.selectionMoveEnd$.pipe(b.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const n=N.getSheetCommandTarget(e);if(!n)return!1;const{actualColumn:o,actualRow:s}=i.primary;return!!r.get(I.SheetsNoteModel).getNote(n.unitId,n.subUnitId,{row:s,col:o})}))}function Me(r){return{id:x.id,type:f.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteIcon",hidden$:b.combineLatest([f.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),Z(r)]).pipe(b.map(([t,e])=>t||e)),disabled$:E.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:x.id}}function we(r){return{id:I.SheetDeleteNoteCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteIcon",hidden$:Z(r).pipe(b.map(t=>!t)),disabled$:E.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function be(r){return{id:I.SheetToggleNotePopupCommand.id,type:f.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteIcon",hidden$:Z(r).pipe(b.map(t=>!t))}}const ye={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{order:0,[x.id]:{order:0,menuItemFactory:Me},[I.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:we},[I.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:be}}}};var Ee=Object.getOwnPropertyDescriptor,Ue=(r,t,e,i)=>{for(var n=i>1?void 0:i?Ee(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},A=(r,t)=>(e,i)=>t(e,i,r);let V=class extends a.Disposable{constructor(r,t,e){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=e,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[k,Q],["AddNoteIcon",K],["DeleteNoteIcon",Y],["HideNoteIcon",J]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}_initMenu(){this._menuManagerService.mergeMenu(ye)}_initCommands(){this._commandService.registerCommand(x)}};V=Ue([A(0,a.Inject(f.ComponentManager)),A(1,a.Inject(f.IMenuManagerService)),A(2,a.ICommandService)],V);var Te=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Oe=(r,t,e)=>t in r?Te(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,je=(r,t,e,i)=>{for(var n=i>1?void 0:i?$e(t,e):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(n=s(n)||n);return n},X=(r,t)=>(e,i)=>t(e,i,r),ee=(r,t,e)=>Oe(r,typeof t!="symbol"?t+"":t,e);const De="SHEET_NOTE_UI_PLUGIN";c.UniverSheetsNoteUIPlugin=class extends a.Plugin{constructor(t=z,e,i){super(),this._config=t,this._injector=e,this._configService=i;const{menu:n,...o}=a.merge({},z,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(q,o)}onStarting(){[[c.SheetsNotePopupService],[c.SheetsCellContentController],[c.SheetsNotePopupController],[V],[R]].forEach(t=>{this._injector.add(t)})}onReady(){a.touchDependencies(this._injector,[[V],[c.SheetsCellContentController]])}onRendered(){a.touchDependencies(this._injector,[[c.SheetsNotePopupController],[R]])}},ee(c.UniverSheetsNoteUIPlugin,"pluginName",De),ee(c.UniverSheetsNoteUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsNoteUIPlugin=je([a.DependentOn(I.UniverSheetsNotePlugin),X(1,a.Inject(a.Injector)),X(2,a.IConfigService)],c.UniverSheetsNoteUIPlugin),c.SheetsNote=Q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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": "^1.1.1",
|
|
54
54
|
"rxjs": "^7.8.2",
|
|
55
|
-
"@univerjs/core": "0.
|
|
56
|
-
"@univerjs/design": "0.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/sheets-ui": "0.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
55
|
+
"@univerjs/core": "0.16.0",
|
|
56
|
+
"@univerjs/design": "0.16.0",
|
|
57
|
+
"@univerjs/engine-render": "0.16.0",
|
|
58
|
+
"@univerjs/sheets-note": "0.16.0",
|
|
59
|
+
"@univerjs/sheets-ui": "0.16.0",
|
|
60
|
+
"@univerjs/ui": "0.16.0",
|
|
61
|
+
"@univerjs/sheets": "0.16.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"postcss": "^8.5.6",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
69
|
"vite": "^7.3.1",
|
|
70
70
|
"vitest": "^4.0.18",
|
|
71
|
-
"@univerjs-infra/shared": "0.
|
|
71
|
+
"@univerjs-infra/shared": "0.16.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"test": "vitest run",
|