@univerjs/preset-sheets-note 0.7.0-nightly.202505211607 → 0.7.0-nightly.202505231607
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/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/umd/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// @univerjs/sheets-note-ui/index
|
|
10
|
-
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-note"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs/operators"),require("react/jsx-runtime"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-note","@univerjs/engine-render","@univerjs/sheets","rxjs","@univerjs/sheets-ui","@univerjs/ui","rxjs/operators","react/jsx-runtime","@univerjs/design","react"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.UniverSheetsNoteUi={},u.UniverCore,u.UniverSheetsNote,u.UniverEngineRender,u.UniverSheets,u.rxjs,u.UniverSheetsUi,u.UniverUi,u.rxjs.operators,u.React,u.UniverDesign,u.React))})(this,function(u,s,h,L,N,I,M,S,Q,X,$,g){"use strict";var we=Object.defineProperty;var ye=(u,s,h)=>s in u?we(u,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):u[s]=h;var b=(u,s,h)=>ye(u,typeof s!="symbol"?s+"":s,h);const V="sheets-note-ui.config",k={};var ee=Object.getOwnPropertyDescriptor,te=(r,t,n,i)=>{for(var e=i>1?void 0:i?ee(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},E=(r,t)=>(n,i)=>t(n,i,r);u.SheetsCellContentController=class extends s.Disposable{constructor(t,n,i,e){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=n,this._renderManagerService=i,this._univerInstanceService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(t,n,i)=>{const{row:e,col:o,unitId:a,subUnitId:c}=n;return this._sheetsNoteModel.getNote(a,c,e,o)?i({...t,markers:{...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}}):i(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return;const i=n.getUnitId(),e=this._renderManagerService.getRenderById(i);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(I.debounceTime(16)).subscribe(()=>{t()}))}},u.SheetsCellContentController=te([E(0,s.Inject(N.SheetInterceptorService)),E(1,s.Inject(h.SheetsNoteModel)),E(2,L.IRenderManagerService),E(3,s.IUniverInstanceService)],u.SheetsCellContentController);const D="SHEET_NOTE_COMPONENT";var ie=Object.getOwnPropertyDescriptor,ne=(r,t,n,i)=>{for(var e=i>1?void 0:i?ie(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},z=(r,t)=>(n,i)=>t(n,i,r);u.SheetsNotePopupService=class extends s.Disposable{constructor(n,i){super();b(this,"_lastPopup",null);b(this,"_activePopup");b(this,"_activePopup$",new I.BehaviorSubject(null));b(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=n,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,i){var v;const{row:e,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&e===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((v=this.activePopup)==null?void 0:v.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const l=this._cellPopupManagerService.showPopup({unitId:a,subUnitId:c,row:e,col:o},{componentKey:D,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:n},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new s.DisposableCollection;d.add(l),d.add({dispose:()=>{i==null||i()}}),this._lastPopup=d}hidePopup(n){this._activePopup&&(!n&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},u.SheetsNotePopupService=ne([z(0,S.IZenZoneService),z(1,s.Inject(M.CellPopupManagerService))],u.SheetsNotePopupService);var re=Object.getOwnPropertyDescriptor,oe=(r,t,n,i)=>{for(var e=i>1?void 0:i?re(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},O=(r,t)=>(n,i)=>t(n,i,r);let U=class extends s.Disposable{constructor(t,n,i,e){super();b(this,"_noteMatrix",new s.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=n,this._cellPopupManagerService=i,this._sheetsNotePopupService=e,this._initNoteChangeListener()}_showPopup(t,n,i,e){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:n,row:i,col:e},{componentKey:D,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:n,row:i,col:e}},priority:3})}_initSheet(t,n){var o;this._noteMatrix.forValue((a,c,l)=>{l.dispose()}),this._noteMatrix=new s.ObjectMatrix;const e=(a,c,l,d,v)=>{const _=this._noteMatrix,C=_.getValue(l,d);if(v!=null&&v.show){if(!C){const p=this._showPopup(a,c,l,d);p&&_.setValue(l,d,p)}}else C&&(C.dispose(),_.realDeleteValue(l,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,n))==null||o.forValue((a,c,l)=>{e(t,n,a,c,l)}),this._sheetsNoteModel.change$.subscribe(a=>{if(!(a.unitId!==t||a.sheetId!==n))switch(a.type){case"ref":{const{unitId:c,sheetId:l,row:d,col:v,newPosition:_,note:C}=a,p=this._noteMatrix;if(!C.show)return;const f=p.getValue(d,v);f&&(f.dispose(),p.realDeleteValue(d,v));const m=this._showPopup(c,l,_.row,_.col);m&&p.setValue(_.row,_.col,m);break}case"update":{const{unitId:c,sheetId:l,row:d,col:v,note:_}=a;e(c,l,d,v,_);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(I.switchMap(t=>{var n;return(n=t==null?void 0:t.activeSheet$)!=null?n:I.of(null)})).subscribe(t=>{if(t){const n=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{n.unsubscribe()}}else this._noteMatrix.forValue((n,i,e)=>{e.dispose()}),this._noteMatrix=new s.ObjectMatrix}))}};U=oe([O(0,s.Inject(h.SheetsNoteModel)),O(1,s.Inject(s.IUniverInstanceService)),O(2,s.Inject(M.CellPopupManagerService)),O(3,s.Inject(u.SheetsNotePopupService))],U);var se=Object.getOwnPropertyDescriptor,ae=(r,t,n,i)=>{for(var e=i>1?void 0:i?se(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},w=(r,t)=>(n,i)=>t(n,i,r);u.SheetsNotePopupController=class extends s.Disposable{constructor(n,i,e,o,a,c){super();b(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=n,this._sheetsNoteModel=i,this._sheetSelectionService=e,this._editorBridgeService=o,this._renderManagerService=a,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(n,i,e){var p,f,m;const o=(p=n[0])==null?void 0:p.range,a=this._renderManagerService.getRenderById(i),c=(f=a==null?void 0:a.with(M.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:f.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((m=o.rangeType)!=null?m:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((l.isMerged||l.isMergedMainCell)&&s.Rectangle.equals(l.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const v=l.actualRow,_=l.actualColumn,C=this._sheetsNoteModel.getNote(i,e,v,_);C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:e,row:v,col:_}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(n=>{if(this._isSwitchingSheet)return;const i=this._sheetSelectionService.currentSelectionParam;i&&this._handleSelectionChange(n,i.unitId,i.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(n=>{n.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(Q.debounceTime(100)).subscribe(n=>{if(!(n!=null&&n.location))return;const{unitId:i,subUnitId:e,row:o,col:a}=n.location,c=this._sheetsNoteModel.getNote(i,e,o,a);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:i,subUnitId:e,row:o,col:a,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=ae([w(0,s.Inject(u.SheetsNotePopupService)),w(1,s.Inject(h.SheetsNoteModel)),w(2,s.Inject(N.SheetsSelectionsService)),w(3,M.IEditorBridgeService),w(4,L.IRenderManagerService),w(5,s.Inject(M.HoverManagerService))],u.SheetsNotePopupController);var P=function(){return P=Object.assign||function(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r},P.apply(this,arguments)},ue=function(r,t){var n={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(n[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var e=0,i=Object.getOwnPropertySymbols(r);e<i.length;e++)t.indexOf(i[e])<0&&Object.prototype.propertyIsEnumerable.call(r,i[e])&&(n[i[e]]=r[i[e]]);return n},T=g.forwardRef(function(r,t){var n=r.icon,i=r.id,e=r.className,o=r.extend,a=ue(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(e||"").trim(),l=g.useRef("_".concat(pe()));return A(n,"".concat(i),{defIds:n.defIds,idSuffix:l.current},P({ref:t,className:c},a),o)});function A(r,t,n,i,e){return g.createElement(r.tag,P(P({key:t},ce(r,n,e)),i),(le(r,n).children||[]).map(function(o,a){return A(o,"".concat(t,"-").concat(r.tag,"-").concat(a),n,void 0,e)}))}function ce(r,t,n){var i=P({},r.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+t.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var e=t.defIds;return!e||e.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),i}function le(r,t){var n,i=t.defIds;return!i||i.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?P(P({},r),{children:r.children.map(function(e){return typeof e.attrs.id=="string"&&i&&i.indexOf(e.attrs.id)>-1?P(P({},e),{attrs:P(P({},e.attrs),{id:e.attrs.id+t.idSuffix})}):e})}):r}function pe(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var he={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363 10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745 11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962 11.1791 15.0962 10.8814 14.7983 10.8813 14.4312z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},B=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"add-note-single",ref:t,icon:he}))});B.displayName="AddNoteSingle";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363 10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618 14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618 8.80985 11.9946 9.10762 11.6968 9.47489 11.6968z"}}]},W=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"delete-note-single",ref:t,icon:de}))});W.displayName="DeleteNoteSingle";var ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363 10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477 13.039 11.6659 12.5573 11.4614 12.0394 11.4614 11.5213 11.4614 11.0398 11.6666 10.6878 11.9487 10.3037 12.2565 10.2045 12.5399 10.2044 12.6147 10.2044 12.6893 10.3034 12.9737 10.6878 13.2817 11.0398 13.5636 11.5215 13.768 12.0394 13.768 12.5574 13.768 13.039 13.5635 13.3909 13.2817 13.7751 12.9739 13.8743 12.6897 13.8743 12.6147zM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198 13.6701 14.7627 12.9019 15.0981 12.0394 15.0981 11.1768 15.0981 10.4085 14.7627 9.85577 14.3198 9.33533 13.9027 8.87433 13.2769 8.87433 12.6147 8.8744 11.9526 9.33541 11.3276 9.85577 10.9106 10.4086 10.4676 11.1767 10.1313 12.0394 10.1313 12.9018 10.1313 13.6701 10.4668 14.223 10.9096 14.7435 11.3267 15.2043 11.9523 15.2044 12.6147z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},F=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"hide-note-single",ref:t,icon:ve}))});F.displayName="HideNoteSingle";const j={id:"sheet.operation.add-note-popup",type:s.CommandType.OPERATION,handler:async(r,t)=>{const n=r.get(N.SheetsSelectionsService),i=r.get(u.SheetsNotePopupService),o=r.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const a=o.getActiveSheet(),c=n.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:l}=c;return i.showPopup({unitId:o.getUnitId(),subUnitId:a.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:t==null?void 0:t.trigger}),!0}},q=r=>{var C;const t=S.useDependency(h.SheetsNoteModel),n=S.useDependency(s.LocaleService),i=S.useConfigValue(V),e=(C=r.popup.extraProps)==null?void 0:C.location;if(!e)return console.error("Popup extraProps or location is undefined."),null;const[o,a]=g.useState(()=>{var m,y;const p={width:((m=i==null?void 0:i.defaultNoteSize)==null?void 0:m.width)||216,height:((y=i==null?void 0:i.defaultNoteSize)==null?void 0:y.height)||92,note:""};return t.getNote(e.unitId,e.subUnitId,e.row,e.col)||p}),c=g.useRef(null),l=S.useDependency(s.ICommandService),d=g.useMemo(()=>e?t.getCellNoteChange$(e.unitId,e.subUnitId,e.row,e.col):I.of(null),[e]),v=S.useDebounceFn(p=>{e&&(p.note?l.executeCommand(h.SheetUpdateNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col,note:p}):l.executeCommand(h.SheetDeleteNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col}))});g.useEffect(()=>{var p;e&&(t.getNote(e.unitId,e.subUnitId,e.row,e.col)||(p=c.current)==null||p.focus())},[e,t]),g.useEffect(()=>{const p=d.subscribe(()=>{if(!e)return;const f=t.getNote(e.unitId,e.subUnitId,e.row,e.col);f&&a(f)});return()=>p.unsubscribe()},[d]),g.useEffect(()=>{const p=c.current;if(!p)return;const f=new ResizeObserver(m=>{const y=m[0];if(!y)return;const{width:K,height:Y}=y.contentRect;if(K===0&&Y===0)return;const J={...o,width:K,height:Y};a(J),v(J)});return f.observe(p),()=>{f.unobserve(p),f.disconnect()}},[o.note]);const _=p=>{const f=p.target.value,m={...o,note:f};a(m),v(m)};return X.jsx("textarea",{ref:c,"data-u-comp":"note-textarea",className:$.clsx("univer-resize-both univer-ml-px univer-rounded-md univer-bg-white univer-p-2 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-800 dark:!univer-text-white focus:univer-outline-none",$.borderClassName,$.scrollbarClassName),style:{width:o.width,height:o.height},value:o.note,placeholder:n.t("note.placeholder"),onChange:_})};function x(r){const t=r.get(N.SheetsSelectionsService),n=r.get(s.IUniverInstanceService);return t.selectionMoveEnd$.pipe(I.map(()=>{const i=t.getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;const e=N.getSheetCommandTarget(n);if(!e)return!1;const{actualColumn:o,actualRow:a}=i.primary;return!!r.get(h.SheetsNoteModel).getNote(e.unitId,e.subUnitId,a,o)}))}function fe(r){return{id:j.id,type:S.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:I.combineLatest([S.getMenuHiddenObservable(r,s.UniverInstanceType.UNIVER_SHEET),x(r)]).pipe(I.map(([t,n])=>t||n)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:j.id}}function ge(r){return{id:h.SheetDeleteNoteCommand.id,type:S.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteSingle",hidden$:x(r).pipe(I.map(t=>!t)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function _e(r){return{id:h.SheetToggleNotePopupCommand.id,type:S.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:x(r).pipe(I.map(t=>!t))}}const Se={[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{order:0,[j.id]:{order:0,menuItemFactory:fe},[h.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:ge},[h.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:_e}}}};var Ce=Object.getOwnPropertyDescriptor,me=(r,t,n,i)=>{for(var e=i>1?void 0:i?Ce(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},R=(r,t)=>(n,i)=>t(n,i,r);let H=class extends s.Disposable{constructor(r,t,n){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=n,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){this.disposeWithMe(this._componentManager.register(D,q)),this.disposeWithMe(this._componentManager.register("AddNoteSingle",B)),this.disposeWithMe(this._componentManager.register("DeleteNoteSingle",W)),this.disposeWithMe(this._componentManager.register("HideNoteSingle",F))}_initMenu(){this._menuManagerService.mergeMenu(Se)}_initCommands(){this._commandService.registerCommand(j)}};H=me([R(0,s.Inject(S.ComponentManager)),R(1,s.Inject(S.IMenuManagerService)),R(2,s.ICommandService)],H);var Pe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ie=(r,t,n)=>t in r?Pe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,Me=(r,t,n,i)=>{for(var e=i>1?void 0:i?Ne(t,n):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},Z=(r,t)=>(n,i)=>t(n,i,r),G=(r,t,n)=>Ie(r,typeof t!="symbol"?t+"":t,n);const be="SHEET_NOTE_UI_PLUGIN";u.UniverSheetsNoteUIPlugin=class extends s.Plugin{constructor(t=k,n,i){super(),this._config=t,this._injector=n,this._configService=i;const{menu:e,...o}=s.merge({},k,this._config);e&&this._configService.setConfig("menu",e,{merge:!0}),this._configService.setConfig(V,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[H],[U]].forEach(t=>{this._injector.add(t)})}onReady(){s.touchDependencies(this._injector,[[H],[u.SheetsCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[u.SheetsNotePopupController],[U]])}},G(u.UniverSheetsNoteUIPlugin,"pluginName",be),G(u.UniverSheetsNoteUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=Me([s.DependentOn(h.UniverSheetsNotePlugin),Z(1,s.Inject(s.Injector)),Z(2,s.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=q,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
10
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-note"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs/operators"),require("react/jsx-runtime"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-note","@univerjs/engine-render","@univerjs/sheets","rxjs","@univerjs/sheets-ui","@univerjs/ui","rxjs/operators","react/jsx-runtime","@univerjs/design","react"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.UniverSheetsNoteUi={},u.UniverCore,u.UniverSheetsNote,u.UniverEngineRender,u.UniverSheets,u.rxjs,u.UniverSheetsUi,u.UniverUi,u.rxjs.operators,u.React,u.UniverDesign,u.React))})(this,function(u,s,h,L,N,I,M,_,Q,X,$,g){"use strict";var we=Object.defineProperty;var ye=(u,s,h)=>s in u?we(u,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):u[s]=h;var b=(u,s,h)=>ye(u,typeof s!="symbol"?s+"":s,h);const V="sheets-note-ui.config",k={};var ee=Object.getOwnPropertyDescriptor,te=(r,t,i,n)=>{for(var e=n>1?void 0:n?ee(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},E=(r,t)=>(i,n)=>t(i,n,r);u.SheetsCellContentController=class extends s.Disposable{constructor(t,i,n,e){super(),this._sheetInterceptorService=t,this._sheetsNoteModel=i,this._renderManagerService=n,this._univerInstanceService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(t,i,n)=>{const{row:e,col:o,unitId:a,subUnitId:c}=i;return this._sheetsNoteModel.getNote(a,c,e,o)?n({...t,markers:{...t==null?void 0:t.markers,tr:{color:"#FFBD37",size:6}}}):n(t)},priority:100}))}_initSkeletonChange(){const t=()=>{var o;const i=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),e=this._renderManagerService.getRenderById(n);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe(I.debounceTime(16)).subscribe(()=>{t()}))}},u.SheetsCellContentController=te([E(0,s.Inject(N.SheetInterceptorService)),E(1,s.Inject(h.SheetsNoteModel)),E(2,L.IRenderManagerService),E(3,s.IUniverInstanceService)],u.SheetsCellContentController);const D="SHEET_NOTE_COMPONENT";var ne=Object.getOwnPropertyDescriptor,ie=(r,t,i,n)=>{for(var e=n>1?void 0:n?ne(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},z=(r,t)=>(i,n)=>t(i,n,r);u.SheetsNotePopupService=class extends s.Disposable{constructor(i,n){super();b(this,"_lastPopup",null);b(this,"_activePopup");b(this,"_activePopup$",new I.BehaviorSubject(null));b(this,"activePopup$",this._activePopup$.asObservable());this._zenZoneService=i,this._cellPopupManagerService=n,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(i=>{i&&this.hidePopup()}))}showPopup(i,n){var v;const{row:e,col:o,unitId:a,subUnitId:c}=i;if(this._activePopup&&e===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((v=this.activePopup)==null?void 0:v.subUnitId)){this._activePopup=i,this._activePopup$.next(i);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=i,this._activePopup$.next(i);const l=this._cellPopupManagerService.showPopup({unitId:a,subUnitId:c,row:e,col:o},{componentKey:D,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",extraProps:{location:i},priority:3});if(!l)throw new Error("[SheetsNotePopupService]: cannot show popup!");const d=new s.DisposableCollection;d.add(l),d.add({dispose:()=>{n==null||n()}}),this._lastPopup=d}hidePopup(i){this._activePopup&&(!i&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},u.SheetsNotePopupService=ie([z(0,_.IZenZoneService),z(1,s.Inject(M.CellPopupManagerService))],u.SheetsNotePopupService);var re=Object.getOwnPropertyDescriptor,oe=(r,t,i,n)=>{for(var e=n>1?void 0:n?re(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},O=(r,t)=>(i,n)=>t(i,n,r);let U=class extends s.Disposable{constructor(t,i,n,e){super();b(this,"_noteMatrix",new s.ObjectMatrix);this._sheetsNoteModel=t,this._univerInstanceService=i,this._cellPopupManagerService=n,this._sheetsNotePopupService=e,this._initNoteChangeListener()}_showPopup(t,i,n,e){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:t,subUnitId:i,row:n,col:e},{componentKey:D,direction:"horizontal",extraProps:{location:{unitId:t,subUnitId:i,row:n,col:e}},priority:3})}_initSheet(t,i){var o;this._noteMatrix.forValue((a,c,l)=>{l.dispose()}),this._noteMatrix=new s.ObjectMatrix;const e=(a,c,l,d,v)=>{const S=this._noteMatrix,C=S.getValue(l,d);if(v!=null&&v.show){if(!C){const p=this._showPopup(a,c,l,d);p&&S.setValue(l,d,p)}}else C&&(C.dispose(),S.realDeleteValue(l,d))};return(o=this._sheetsNoteModel.getSheetNotes(t,i))==null||o.forValue((a,c,l)=>{e(t,i,a,c,l)}),this._sheetsNoteModel.change$.subscribe(a=>{if(!(a.unitId!==t||a.sheetId!==i))switch(a.type){case"ref":{const{unitId:c,sheetId:l,row:d,col:v,newPosition:S,note:C}=a,p=this._noteMatrix;if(!C.show)return;const f=p.getValue(d,v);f&&(f.dispose(),p.realDeleteValue(d,v));const m=this._showPopup(c,l,S.row,S.col);m&&p.setValue(S.row,S.col,m);break}case"update":{const{unitId:c,sheetId:l,row:d,col:v,note:S}=a;e(c,l,d,v,S);break}}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(I.switchMap(t=>{var i;return(i=t==null?void 0:t.activeSheet$)!=null?i:I.of(null)})).subscribe(t=>{if(t){const i=this._initSheet(t.getUnitId(),t.getSheetId());return()=>{i.unsubscribe()}}else this._noteMatrix.forValue((i,n,e)=>{e.dispose()}),this._noteMatrix=new s.ObjectMatrix}))}};U=oe([O(0,s.Inject(h.SheetsNoteModel)),O(1,s.Inject(s.IUniverInstanceService)),O(2,s.Inject(M.CellPopupManagerService)),O(3,s.Inject(u.SheetsNotePopupService))],U);var se=Object.getOwnPropertyDescriptor,ae=(r,t,i,n)=>{for(var e=n>1?void 0:n?se(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},w=(r,t)=>(i,n)=>t(i,n,r);u.SheetsNotePopupController=class extends s.Disposable{constructor(i,n,e,o,a,c){super();b(this,"_isSwitchingSheet",!1);this._sheetsNotePopupService=i,this._sheetsNoteModel=n,this._sheetSelectionService=e,this._editorBridgeService=o,this._renderManagerService=a,this._hoverManagerService=c,this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent()}_handleSelectionChange(i,n,e){var p,f,m;const o=(p=i[0])==null?void 0:p.range,a=this._renderManagerService.getRenderById(n),c=(f=a==null?void 0:a.with(M.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:f.skeleton;if(!c||!o)return;const l=c.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((m=o.rangeType)!=null?m:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((l.isMerged||l.isMergedMainCell)&&s.Rectangle.equals(l.mergeInfo,o))){this._sheetsNotePopupService.hidePopup();return}const v=l.actualRow,S=l.actualColumn,C=this._sheetsNoteModel.getNote(n,e,v,S);C!=null&&C.show||(C?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:e,row:v,col:S}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(i=>{if(this._isSwitchingSheet)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(i,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(Q.debounceTime(100)).subscribe(i=>{if(!(i!=null&&i.location))return;const{unitId:n,subUnitId:e,row:o,col:a}=i.location,c=this._sheetsNoteModel.getNote(n,e,o,a);c!=null&&c.show||(c?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:e,row:o,col:a,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}},u.SheetsNotePopupController=ae([w(0,s.Inject(u.SheetsNotePopupService)),w(1,s.Inject(h.SheetsNoteModel)),w(2,s.Inject(N.SheetsSelectionsService)),w(3,M.IEditorBridgeService),w(4,L.IRenderManagerService),w(5,s.Inject(M.HoverManagerService))],u.SheetsNotePopupController);var P=function(){return P=Object.assign||function(r){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r},P.apply(this,arguments)},ue=function(r,t){var i={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(i[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var e=0,n=Object.getOwnPropertySymbols(r);e<n.length;e++)t.indexOf(n[e])<0&&Object.prototype.propertyIsEnumerable.call(r,n[e])&&(i[n[e]]=r[n[e]]);return i},T=g.forwardRef(function(r,t){var i=r.icon,n=r.id,e=r.className,o=r.extend,a=ue(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(e||"").trim(),l=g.useRef("_".concat(pe()));return A(i,"".concat(n),{defIds:i.defIds,idSuffix:l.current},P({ref:t,className:c},a),o)});function A(r,t,i,n,e){return g.createElement(r.tag,P(P({key:t},ce(r,i,e)),n),(le(r,i).children||[]).map(function(o,a){return A(o,"".concat(t,"-").concat(r.tag,"-").concat(a),i,void 0,e)}))}function ce(r,t,i){var n=P({},r.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(n[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var e=t.defIds;return!e||e.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(n[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function le(r,t){var i,n=t.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((i=r.children)===null||i===void 0)&&i.length)?P(P({},r),{children:r.children.map(function(e){return typeof e.attrs.id=="string"&&n&&n.indexOf(e.attrs.id)>-1?P(P({},e),{attrs:P(P({},e.attrs),{id:e.attrs.id+t.idSuffix})}):e})}):r}function pe(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var he={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363 10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745 11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962 11.1791 15.0962 10.8814 14.7983 10.8813 14.4312z"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z"}}]},B=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"add-note-single",ref:t,icon:he}))});B.displayName="AddNoteSingle";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363 10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618 14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618 8.80985 11.9946 9.10762 11.6968 9.47489 11.6968z"}}]},F=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"delete-note-single",ref:t,icon:de}))});F.displayName="DeleteNoteSingle";var ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363 10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363 5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463zM8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001 8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001 5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307zM6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964 7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964 5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319zM13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477 13.039 11.6659 12.5573 11.4614 12.0394 11.4614 11.5213 11.4614 11.0398 11.6666 10.6878 11.9487 10.3037 12.2565 10.2045 12.5399 10.2044 12.6147 10.2044 12.6893 10.3034 12.9737 10.6878 13.2817 11.0398 13.5636 11.5215 13.768 12.0394 13.768 12.5574 13.768 13.039 13.5635 13.3909 13.2817 13.7751 12.9739 13.8743 12.6897 13.8743 12.6147zM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198 13.6701 14.7627 12.9019 15.0981 12.0394 15.0981 11.1768 15.0981 10.4085 14.7627 9.85577 14.3198 9.33533 13.9027 8.87433 13.2769 8.87433 12.6147 8.8744 11.9526 9.33541 11.3276 9.85577 10.9106 10.4086 10.4676 11.1767 10.1313 12.0394 10.1313 12.9018 10.1313 13.6701 10.4668 14.223 10.9096 14.7435 11.3267 15.2043 11.9523 15.2044 12.6147z"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z"}}]},W=g.forwardRef(function(r,t){return g.createElement(T,Object.assign({},r,{id:"hide-note-single",ref:t,icon:ve}))});W.displayName="HideNoteSingle";const j={id:"sheet.operation.add-note-popup",type:s.CommandType.OPERATION,handler:async(r,t)=>{const i=r.get(N.SheetsSelectionsService),n=r.get(u.SheetsNotePopupService),o=r.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;const a=o.getActiveSheet(),c=i.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;const{primary:l}=c;return n.showPopup({unitId:o.getUnitId(),subUnitId:a.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:t==null?void 0:t.trigger}),!0}},q=r=>{var C;const t=_.useDependency(h.SheetsNoteModel),i=_.useDependency(s.LocaleService),n=_.useConfigValue(V),e=(C=r.popup.extraProps)==null?void 0:C.location;if(!e)return console.error("Popup extraProps or location is undefined."),null;const[o,a]=g.useState(()=>{var m,y;const p={width:((m=n==null?void 0:n.defaultNoteSize)==null?void 0:m.width)||216,height:((y=n==null?void 0:n.defaultNoteSize)==null?void 0:y.height)||92,note:""};return t.getNote(e.unitId,e.subUnitId,e.row,e.col)||p}),c=g.useRef(null),l=_.useDependency(s.ICommandService),d=g.useMemo(()=>e?t.getCellNoteChange$(e.unitId,e.subUnitId,e.row,e.col):I.of(null),[e]),v=_.useDebounceFn(p=>{e&&(p.note?l.executeCommand(h.SheetUpdateNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col,note:p}):l.executeCommand(h.SheetDeleteNoteCommand.id,{unitId:e.unitId,sheetId:e.subUnitId,row:e.row,col:e.col}))});g.useEffect(()=>{var p;e&&(t.getNote(e.unitId,e.subUnitId,e.row,e.col)||(p=c.current)==null||p.focus())},[e,t]),g.useEffect(()=>{const p=d.subscribe(()=>{if(!e)return;const f=t.getNote(e.unitId,e.subUnitId,e.row,e.col);f&&a(f)});return()=>p.unsubscribe()},[d]),g.useEffect(()=>{const p=c.current;if(!p)return;const f=new ResizeObserver(m=>{const y=m[0];if(!y)return;const{width:K,height:Y}=y.contentRect;if(K===0&&Y===0)return;const J={...o,width:K,height:Y};a(J),v(J)});return f.observe(p),()=>{f.unobserve(p),f.disconnect()}},[o.note]);const S=p=>{const f=p.target.value,m={...o,note:f};a(m),v(m)};return X.jsx("textarea",{ref:c,"data-u-comp":"note-textarea",className:$.clsx("univer-resize-both univer-ml-px univer-rounded-md univer-bg-white univer-p-2 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-800 dark:!univer-text-white focus:univer-outline-none",$.borderClassName,$.scrollbarClassName),style:{width:o.width,height:o.height},value:o.note,placeholder:i.t("note.placeholder"),onChange:S})};function x(r){const t=r.get(N.SheetsSelectionsService),i=r.get(s.IUniverInstanceService);return t.selectionMoveEnd$.pipe(I.map(()=>{const n=t.getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const e=N.getSheetCommandTarget(i);if(!e)return!1;const{actualColumn:o,actualRow:a}=n.primary;return!!r.get(h.SheetsNoteModel).getNote(e.unitId,e.subUnitId,a,o)}))}function fe(r){return{id:j.id,type:_.MenuItemType.BUTTON,title:"rightClick.addNote",icon:"AddNoteSingle",hidden$:I.combineLatest([_.getMenuHiddenObservable(r,s.UniverInstanceType.UNIVER_SHEET),x(r)]).pipe(I.map(([t,i])=>t||i)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]}),commandId:j.id}}function ge(r){return{id:h.SheetDeleteNoteCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.deleteNote",icon:"DeleteNoteSingle",hidden$:x(r).pipe(I.map(t=>!t)),disabled$:M.getCurrentRangeDisable$(r,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission]})}}function Se(r){return{id:h.SheetToggleNotePopupCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.toggleNote",icon:"HideNoteSingle",hidden$:x(r).pipe(I.map(t=>!t))}}const _e={[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.OTHERS]:{order:0,[j.id]:{order:0,menuItemFactory:fe},[h.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:ge},[h.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:Se}}}};var Ce=Object.getOwnPropertyDescriptor,me=(r,t,i,n)=>{for(var e=n>1?void 0:n?Ce(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},R=(r,t)=>(i,n)=>t(i,n,r);let H=class extends s.Disposable{constructor(r,t,i){super(),this._componentManager=r,this._menuManagerService=t,this._commandService=i,this._initComponents(),this._initMenu(),this._initCommands()}_initComponents(){[[D,q],["AddNoteSingle",B],["DeleteNoteSingle",F],["HideNoteSingle",W]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}_initMenu(){this._menuManagerService.mergeMenu(_e)}_initCommands(){this._commandService.registerCommand(j)}};H=me([R(0,s.Inject(_.ComponentManager)),R(1,s.Inject(_.IMenuManagerService)),R(2,s.ICommandService)],H);var Pe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ie=(r,t,i)=>t in r?Pe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,Me=(r,t,i,n)=>{for(var e=n>1?void 0:n?Ne(t,i):t,o=r.length-1,a;o>=0;o--)(a=r[o])&&(e=a(e)||e);return e},Z=(r,t)=>(i,n)=>t(i,n,r),G=(r,t,i)=>Ie(r,typeof t!="symbol"?t+"":t,i);const be="SHEET_NOTE_UI_PLUGIN";u.UniverSheetsNoteUIPlugin=class extends s.Plugin{constructor(t=k,i,n){super(),this._config=t,this._injector=i,this._configService=n;const{menu:e,...o}=s.merge({},k,this._config);e&&this._configService.setConfig("menu",e,{merge:!0}),this._configService.setConfig(V,o)}onStarting(){[[u.SheetsNotePopupService],[u.SheetsCellContentController],[u.SheetsNotePopupController],[H],[U]].forEach(t=>{this._injector.add(t)})}onReady(){s.touchDependencies(this._injector,[[H],[u.SheetsCellContentController]])}onRendered(){s.touchDependencies(this._injector,[[u.SheetsNotePopupController],[U]])}},G(u.UniverSheetsNoteUIPlugin,"pluginName",be),G(u.UniverSheetsNoteUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNoteUIPlugin=Me([s.DependentOn(h.UniverSheetsNotePlugin),Z(1,s.Inject(s.Injector)),Z(2,s.IConfigService)],u.UniverSheetsNoteUIPlugin),u.SheetsNote=q,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-note",
|
|
3
|
-
"version": "0.7.0-nightly.
|
|
3
|
+
"version": "0.7.0-nightly.202505231607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/sheets-note": "0.7.0-nightly.
|
|
61
|
-
"@univerjs/sheets-note-ui": "0.7.0-nightly.
|
|
60
|
+
"@univerjs/sheets-note": "0.7.0-nightly.202505231607",
|
|
61
|
+
"@univerjs/sheets-note-ui": "0.7.0-nightly.202505231607"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@univerjs/core": "0.7.0-nightly.
|
|
64
|
+
"@univerjs/core": "0.7.0-nightly.202505231607",
|
|
65
65
|
"react": "18.3.1",
|
|
66
66
|
"react-dom": "18.3.1",
|
|
67
67
|
"rxjs": "7.8.2",
|