@univerjs/sheets-thread-comment-ui 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Se=Object.defineProperty;var _e=(o,t,n)=>t in o?Se(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>_e(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),T=require("@univerjs/thread-comment-ui"),I=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),ce=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),me="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new k.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,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,e){var d;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((d=this.activePopup)==null?void 0:d.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 m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:me,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(m),u.add({dispose:()=>{e==null||e()}}),this._lastPopup=u}hidePopup(){this._activePopup&&(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.SheetsThreadCommentPopupService=ge([oe(0,a.Inject(I.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(T.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:u,unitId:d,subUnitId:h}=c,l={workbook:m,worksheet:u,unitId:d,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(d,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:d,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},Pe="sheets-thread-comment.config",ie={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let F=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject($.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,ce.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:d,subUnitId:h}=this._copyInfo,l={row:u.startRow,column:u.startColumn};if(!(i===d&&s===h)){const p=[];a.Range.foreach(u,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(d,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{p.push(g)}):M.forEach(({children:g,...O})=>{O.parentId||p.push(O)})});const f=[],b=[],N=[],V=[],J=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:d,subUnitId:h,commentId:y.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Re(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:d,subUnitId:h,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return p.forEach(y=>{J(y)}),{redos:[...f,...N],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,a.Inject(I.ISheetClipboardService)),K(1,a.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let G=class extends a.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const u=this._sheetsThreadCommentModel.getComment(e,r,c);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([L(0,a.Inject(I.HoverManagerService)),L(1,a.Inject(exports.SheetsThreadCommentPopupService)),L(2,a.Inject($.SheetsThreadCommentModel)),L(3,a.Inject(I.SheetPermissionInterceptorBaseController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends a.Disposable{constructor(t,n,e,r,i,s,c,m,u,d){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=u,this._renderManagerService=d,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=c.actualRow,d=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,u,d);h&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(c.ref),{row:l,column:p}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const b=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-b,0),endRow:h.row+b,startColumn:Math.max(h.column-b,0),endColumn:h.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const u=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),d=(p=u==null?void 0:u.getMergedCell(c,m))!=null?p:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:d,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,a.ICommandService),E(1,a.Inject(exports.SheetsThreadCommentPopupService)),E(2,a.Inject($.SheetsThreadCommentModel)),E(3,a.Inject(T.ThreadCommentPanelService)),E(4,a.IUniverInstanceService),E(5,a.Inject(I.SheetPermissionInterceptorBaseController)),E(6,I.IMarkSelectionService),E(7,a.Inject(C.SheetsSelectionsService)),E(8,I.IEditorBridgeService),E(9,ce.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),u=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=c.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:u?l:void 0},sync:!u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,a.Inject(C.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,a.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var w=function(){return w=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},w.apply(this,arguments)},Be=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},de=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=Be(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Le()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ue(o,t,n,e,r){return R.createElement(o.tag,w(w({key:t},ke(o,n,r)),e),(He(o,n).children||[]).map(function(i,s){return ue(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function ke(o,t,n){var e=w({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function He(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Le(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=R.forwardRef(function(o,t){return R.createElement(de,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});he.displayName="CommentSingle";var Q={exports:{}},B={};/**
|
|
1
|
+
"use strict";var Se=Object.defineProperty;var _e=(o,t,n)=>t in o?Se(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>_e(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),w=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),H=require("rxjs"),ae=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),me="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,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,e){var u;const{row:r,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((u=this.activePopup)==null?void 0:u.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 m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:me,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.DisposableCollection;d.add(m),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(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.SheetsThreadCommentPopupService=ge([oe(0,c.Inject(w.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(P.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const a=C.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:d,unitId:u,subUnitId:h}=a,l={workbook:m,worksheet:d,unitId:u,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(u,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:u,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},Pe="sheets-thread-comment.config",ie={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let F=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([L(0,c.Inject(C.SheetInterceptorService)),L(1,c.Inject($.SheetsThreadCommentModel)),L(2,c.IUniverInstanceService),L(3,ae.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends c.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(r.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:u,subUnitId:h}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===u&&s===h)){const p=[];c.Range.foreach(d,(b,v)=>{const y=this._sheetsThreadCommentModel.getAllByLocation(u,h,b,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?y.forEach(I=>{p.push(I)}):y.forEach(({children:I,...O})=>{O.parentId||p.push(O)})});const f=[],T=[],N=[],V=[],J=b=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:u,subUnitId:h,commentId:b.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Re(b.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:_.AddCommentMutation.id,params:{unitId:u,subUnitId:h,comment:b,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return p.forEach(b=>{J(b)}),{redos:[...f,...N],undos:[...V,...T]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,c.Inject(w.ISheetClipboardService)),K(1,c.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},B=(o,t)=>(n,e)=>t(n,e,o);let G=class extends c.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,r,a);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:a,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([B(0,c.Inject(w.HoverManagerService)),B(1,c.Inject(exports.SheetsThreadCommentPopupService)),B(2,c.Inject($.SheetsThreadCommentModel)),B(3,c.Inject(C.SheetPermissionCheckController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends c.Disposable{constructor(t,n,e,r,i,s,a,m,d,u){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=u,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(w.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const a=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f: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._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=a.actualRow,u=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,d,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,d,u);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,a=this._sheetsThreadCommentModel.getComment(e,r,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(a.ref),{row:l,column:p}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const T=1;if(await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-T,0),endRow:h.row+T,startColumn:Math.max(h.column-T,0),endColumn:h.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),u=(p=d==null?void 0:d.getMergedCell(a,m))!=null?p:{startColumn:m,endColumn:m,startRow:a,endRow:a},h=this._markSelectionService.addShape({range:u,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(P.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(C.SheetPermissionCheckController)),E(6,w.IMarkSelectionService),E(7,c.Inject(C.SheetsSelectionsService)),E(8,w.IEditorBridgeService),E(9,ae.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),a=Array.from(s.values()).filter(l=>!l.parentId),m=a.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=a.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:d?l:void 0},sync:!d}}));return{redos:u,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,c.Inject(C.SheetInterceptorService)),W(1,c.IUniverInstanceService),W(2,c.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var M=function(){return M=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},M.apply(this,arguments)},ke=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},ue=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=ke(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Be()));return de(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},M({ref:t,className:a},s),i)});function de(o,t,n,e,r){return R.createElement(o.tag,M(M({key:t},He(o,n,r)),e),(Le(o,n).children||[]).map(function(i,s){return de(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function He(o,t,n){var e=M({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],a=i[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Le(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?M(M({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?M(M({},r),{attrs:M(M({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Be(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=R.forwardRef(function(o,t){return R.createElement(ue,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});he.displayName="CommentSingle";var Q={exports:{}},k={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var se;function Fe(){if(se)return
|
|
9
|
+
*/var se;function Fe(){if(se)return k;se=1;var o=R,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(a,m,d){var u,h={},l=null,p=null;d!==void 0&&(l=""+d),m.key!==void 0&&(l=""+m.key),m.ref!==void 0&&(p=m.ref);for(u in m)e.call(m,u)&&!i.hasOwnProperty(u)&&(h[u]=m[u]);if(a&&a.defaultProps)for(u in m=a.defaultProps,m)h[u]===void 0&&(h[u]=m[u]);return{$$typeof:t,type:a,key:l,ref:p,props:h,_owner:r.current}}return k.Fragment=n,k.jsx=s,k.jsxs=s,k}var ce;function qe(){return ce||(ce=1,Q.exports=Fe()),Q.exports}var le=qe();const Ge=()=>{const o=c.useDependency(c.IUniverInstanceService),t=c.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=c.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:a,trigger:m}=n,d=e.getByLocation(s,a,r,i),u=`${c.Tools.chatAtABC(i)}${r+1}`,h=()=>{t.hidePopup()},l=p=>{var f,T,N;return(N=(T=(f=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(p))==null?void 0:T.getName())!=null?N:""};return le.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:u,onClose:h,getSubUnitName:l,autoFocus:m==="context-menu"})},Ze=()=>{var b;const o=c.useDependency(w.IMarkSelectionService),t=c.useDependency(c.IUniverInstanceService),n=c.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=c.useDependency(c.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(H.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),a=S.useObservable(s,(b=e.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(),d=c.useDependency(P.ThreadCommentPanelService),u=S.useObservable(d.activeCommentId$),h=S.useObservable(d.panelVisible$,d.panelVisible),l=R.useCallback(v=>{const y=e.getSheets(),I={};y.forEach((U,g)=>{I[U.getSheetId()]=g});const O=U=>U.map(g=>{var re;const j=x.singleReferenceToGrid(g.ref),Ce=[(re=I[g.subUnitId])!=null?re:0,j.row,j.column];return{...g,p:Ce}}).sort((g,j)=>g.p[0]===j.p[0]?g.p[1]===j.p[1]?g.p[2]-j.p[2]:g.p[1]-j.p[1]:g.p[0]-j.p[0]);return[...O(v.filter(U=>!U.resolved)),...O(v.filter(U=>U.resolved))]},[e]),p=R.useCallback(v=>{var y;if(v.unitId===r&&v.subUnitId===a&&!v.resolved){const{row:I,column:O}=x.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),g=(y=U==null?void 0:U.getMergedCell(I,O))!=null?y:{startColumn:O,endColumn:O,startRow:I,endRow:I};if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:g,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,a,r]),f=v=>{var y,I;return(I=(y=e.getSheetBySheetId(v))==null?void 0:y.getName())!=null?I:""},T=()=>{i.executeCommand(A.id)},N=v=>{u&&u.unitId===v.unitId&&u.subUnitId===v.subUnitId&&u.commentId===v.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=p(v))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},J=(v,y)=>{y&&n.hidePopup()};return R.useEffect(()=>{!h&&m.current&&o.removeShape(m.current)},[o,h]),le.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:f,onResolve:J,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},ze=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:te,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ye=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:te,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Je={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused},Ke={[S.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Ye}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ze}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Qe(t,n,r),r},X=(o,t)=>(n,e)=>t(n,e,o);let Y=class extends c.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Je)}_initMenu(){this._menuManagerService.mergeMenu(Ke)}_initComponent(){[[me,Ge],[P.THREAD_COMMENT_PANEL,Ze],[te,he]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};Y=et([X(0,S.IMenuManagerService),X(1,c.Inject(S.ComponentManager)),X(2,S.IShortcutService)],Y);var pe=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,t,n)=>t in o?pe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,rt=(o,t,n,e)=>{for(var r=e>1?void 0:e?tt(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&pe(t,n,r),r},ee=(o,t)=>(n,e)=>t(n,e,o),ve=(o,t,n)=>nt(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=ie,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=c.merge({},ie,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Pe,s)}onStarting(){[[Y],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(Y)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};ve(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ne);ve(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=rt([c.DependentOn(P.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,c.Inject(c.Injector)),ee(2,c.Inject(c.ICommandService)),ee(3,c.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ne;exports.ShowAddSheetCommentModalOperation=A;
|
package/lib/es/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var ke = (o, e, n) => e in o ?
|
|
1
|
+
var Be = Object.defineProperty;
|
|
2
|
+
var ke = (o, e, n) => e in o ? Be(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
|
|
3
3
|
var E = (o, e, n) => ke(o, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { Inject as _, Disposable as $, DisposableCollection as Fe, CommandType as We, IUniverInstanceService as N, InterceptorEffectEnum as Ze, UniverInstanceType as b, Range as ze, ICommandService as
|
|
5
|
-
import { SheetsSelectionsService as Se, getSheetCommandTarget as et, SheetInterceptorService as ge, INTERCEPTOR_POINT as tt, WorkbookCommentPermission as K, WorksheetViewPermission as Q, RangeProtectionPermissionViewPoint as X, SetWorksheetActiveOperation as nt, RemoveSheetCommand as rt } from "@univerjs/sheets";
|
|
4
|
+
import { Inject as _, Disposable as $, DisposableCollection as Fe, CommandType as We, IUniverInstanceService as N, InterceptorEffectEnum as Ze, UniverInstanceType as b, Range as ze, ICommandService as ce, RANGE_TYPE as he, Rectangle as qe, useDependency as R, Tools as Ge, DependentOn as Je, Injector as Ye, Plugin as Ke, merge as Qe, IConfigService as Xe } from "@univerjs/core";
|
|
5
|
+
import { SheetsSelectionsService as Se, getSheetCommandTarget as et, SheetInterceptorService as ge, INTERCEPTOR_POINT as tt, SheetPermissionCheckController as Ie, WorkbookCommentPermission as K, WorksheetViewPermission as Q, RangeProtectionPermissionViewPoint as X, SetWorksheetActiveOperation as nt, RemoveSheetCommand as rt } from "@univerjs/sheets";
|
|
6
6
|
import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as ot } from "@univerjs/sheets-thread-comment";
|
|
7
|
-
import { ThreadCommentPanelService as
|
|
7
|
+
import { ThreadCommentPanelService as ae, SetActiveCommentOperation as te, ThreadCommentTree as it, ThreadCommentPanel as st, ToggleSheetCommentPanelOperation as Pe, THREAD_COMMENT_PANEL as ct, UniverThreadCommentUIPlugin as at } from "@univerjs/thread-comment-ui";
|
|
8
8
|
import { UniverThreadCommentUIPlugin as $n } from "@univerjs/thread-comment-ui";
|
|
9
|
-
import { SheetCanvasPopManagerService as
|
|
10
|
-
import { IZenZoneService as
|
|
11
|
-
import { BehaviorSubject as Mt, debounceTime as
|
|
9
|
+
import { SheetCanvasPopManagerService as ut, ISheetClipboardService as dt, COPY_TYPE as mt, HoverManagerService as ht, IMarkSelectionService as Te, IEditorBridgeService as lt, SheetSkeletonManagerService as pt, ScrollToRangeOperation as _t, whenSheetEditorFocused as ft, getCurrentRangeDisable$ as be } from "@univerjs/sheets-ui";
|
|
10
|
+
import { IZenZoneService as vt, useObservable as A, KeyCode as Ct, MetaKeys as le, MenuItemType as Me, getMenuHiddenObservable as we, RibbonStartGroup as St, ContextMenuPosition as gt, ContextMenuGroup as It, ComponentManager as Pt, IMenuManagerService as Tt, IShortcutService as bt } from "@univerjs/ui";
|
|
11
|
+
import { BehaviorSubject as Mt, debounceTime as ue, map as wt } from "rxjs";
|
|
12
12
|
import { IRenderManagerService as ye } from "@univerjs/engine-render";
|
|
13
13
|
import { singleReferenceToGrid as V, serializeRange as yt } from "@univerjs/engine-formula";
|
|
14
14
|
import { IThreadCommentDataSourceService as Ee, DeleteCommentMutation as F, AddCommentMutation as se, ThreadCommentModel as Et } from "@univerjs/thread-comment";
|
|
15
|
-
import { AddCommentCommand as xn, DeleteCommentCommand as Dn, DeleteCommentTreeCommand as jn, IThreadCommentDataSourceService as An, ResolveCommentCommand as Vn, UpdateCommentCommand as
|
|
15
|
+
import { AddCommentCommand as xn, DeleteCommentCommand as Dn, DeleteCommentTreeCommand as jn, IThreadCommentDataSourceService as An, ResolveCommentCommand as Vn, UpdateCommentCommand as Hn } from "@univerjs/thread-comment";
|
|
16
16
|
import Rt, { forwardRef as Re, useRef as Oe, createElement as Ue, useMemo as Ot, useCallback as pe, useEffect as Ut } from "react";
|
|
17
|
-
const $e = "univer.sheet.thread-comment-modal",
|
|
17
|
+
const $e = "univer.sheet.thread-comment-modal", de = "comment-single", Ne = "SHEET_THREAD_COMMENT";
|
|
18
18
|
var $t = Object.defineProperty, Nt = Object.getOwnPropertyDescriptor, xt = (o, e, n, t) => {
|
|
19
19
|
for (var r = t > 1 ? void 0 : t ? Nt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
20
20
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
@@ -40,16 +40,16 @@ let O = class extends $ {
|
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
42
|
showPopup(e, n) {
|
|
43
|
-
var
|
|
43
|
+
var m;
|
|
44
44
|
const { row: t, col: r, unitId: i, subUnitId: s } = e;
|
|
45
|
-
if (this._activePopup && t === this._activePopup.row && r === this._activePopup.col && i === this._activePopup.unitId && s === ((
|
|
45
|
+
if (this._activePopup && t === this._activePopup.row && r === this._activePopup.col && i === this._activePopup.unitId && s === ((m = this.activePopup) == null ? void 0 : m.subUnitId)) {
|
|
46
46
|
this._activePopup = e, this._activePopup$.next(e);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
|
|
50
50
|
return;
|
|
51
51
|
this._activePopup = e, this._activePopup$.next(e);
|
|
52
|
-
const
|
|
52
|
+
const c = this._canvasPopupManagerService.attachPopupToCell(
|
|
53
53
|
t,
|
|
54
54
|
r,
|
|
55
55
|
{
|
|
@@ -64,14 +64,14 @@ let O = class extends $ {
|
|
|
64
64
|
].filter(Boolean)
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
|
-
if (!
|
|
67
|
+
if (!c)
|
|
68
68
|
throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const a = new Fe();
|
|
70
|
+
a.add(c), a.add({
|
|
71
71
|
dispose: () => {
|
|
72
72
|
n == null || n();
|
|
73
73
|
}
|
|
74
|
-
}), this._lastPopup =
|
|
74
|
+
}), this._lastPopup = a;
|
|
75
75
|
}
|
|
76
76
|
hidePopup() {
|
|
77
77
|
this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
|
|
@@ -84,43 +84,43 @@ let O = class extends $ {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
O = xt([
|
|
87
|
-
_e(0, _(
|
|
88
|
-
_e(1,
|
|
87
|
+
_e(0, _(ut)),
|
|
88
|
+
_e(1, vt)
|
|
89
89
|
], O);
|
|
90
|
-
const
|
|
90
|
+
const H = {
|
|
91
91
|
type: We.OPERATION,
|
|
92
92
|
id: "sheets.operation.show-comment-modal",
|
|
93
93
|
handler(o) {
|
|
94
|
-
var
|
|
95
|
-
const e = o.get(Se), n = o.get(N), t = o.get(O), r = o.get(
|
|
94
|
+
var f;
|
|
95
|
+
const e = o.get(Se), n = o.get(N), t = o.get(O), r = o.get(ae), i = (f = e.getCurrentLastSelection()) == null ? void 0 : f.primary, s = o.get(x);
|
|
96
96
|
if (!i)
|
|
97
97
|
return !1;
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
98
|
+
const c = et(n);
|
|
99
|
+
if (!c)
|
|
100
100
|
return !1;
|
|
101
|
-
const { workbook:
|
|
102
|
-
workbook:
|
|
103
|
-
worksheet:
|
|
104
|
-
unitId:
|
|
105
|
-
subUnitId:
|
|
101
|
+
const { workbook: a, worksheet: m, unitId: u, subUnitId: d } = c, h = {
|
|
102
|
+
workbook: a,
|
|
103
|
+
worksheet: m,
|
|
104
|
+
unitId: u,
|
|
105
|
+
subUnitId: d,
|
|
106
106
|
row: i.startRow,
|
|
107
107
|
col: i.startColumn
|
|
108
108
|
};
|
|
109
109
|
t.showPopup(h);
|
|
110
|
-
const l = s.getByLocation(
|
|
110
|
+
const l = s.getByLocation(u, d, i.startRow, i.startColumn);
|
|
111
111
|
return l && r.setActiveComment({
|
|
112
|
-
unitId:
|
|
113
|
-
subUnitId:
|
|
112
|
+
unitId: u,
|
|
113
|
+
subUnitId: d,
|
|
114
114
|
commentId: l,
|
|
115
115
|
trigger: "context-menu"
|
|
116
116
|
}), !0;
|
|
117
117
|
}
|
|
118
|
-
}, Dt = "sheets-thread-comment.config",
|
|
118
|
+
}, Dt = "sheets-thread-comment.config", fe = {};
|
|
119
119
|
var jt = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Vt = (o, e, n, t) => {
|
|
120
120
|
for (var r = t > 1 ? void 0 : t ? At(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
121
121
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
122
122
|
return t && r && jt(e, n, r), r;
|
|
123
|
-
},
|
|
123
|
+
}, L = (o, e) => (n, t) => e(n, t, o);
|
|
124
124
|
let W = class extends $ {
|
|
125
125
|
constructor(o, e, n, t) {
|
|
126
126
|
super(), this._sheetInterceptorService = o, this._sheetsThreadCommentModel = e, this._univerInstanceService = n, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
|
|
@@ -157,21 +157,21 @@ let W = class extends $ {
|
|
|
157
157
|
const n = e.getUnitId(), t = this._renderManagerService.getRenderById(n);
|
|
158
158
|
(r = t == null ? void 0 : t.mainComponent) == null || r.makeForceDirty();
|
|
159
159
|
};
|
|
160
|
-
this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(
|
|
160
|
+
this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(ue(16)).subscribe(() => {
|
|
161
161
|
o();
|
|
162
162
|
}));
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
W = Vt([
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
L(0, _(ge)),
|
|
167
|
+
L(1, _(x)),
|
|
168
|
+
L(2, N),
|
|
169
|
+
L(3, ye)
|
|
170
170
|
], W);
|
|
171
|
-
var
|
|
172
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
171
|
+
var Ht = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Bt = (o, e, n, t) => {
|
|
172
|
+
for (var r = t > 1 ? void 0 : t ? Lt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
173
173
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
174
|
-
return t && r &&
|
|
174
|
+
return t && r && Ht(e, n, r), r;
|
|
175
175
|
}, ne = (o, e) => (n, t) => e(n, t, o);
|
|
176
176
|
const kt = (o, e, n) => {
|
|
177
177
|
const t = V(o), r = n.row - e.row, i = n.column - e.column, s = {
|
|
@@ -202,31 +202,31 @@ let Z = class extends $ {
|
|
|
202
202
|
},
|
|
203
203
|
// eslint-disable-next-line max-lines-per-function
|
|
204
204
|
onPasteCells: (e, n, t, r) => {
|
|
205
|
-
const { unitId: i, subUnitId: s, range:
|
|
206
|
-
row:
|
|
207
|
-
column:
|
|
205
|
+
const { unitId: i, subUnitId: s, range: c } = n, a = {
|
|
206
|
+
row: c.rows[0],
|
|
207
|
+
column: c.cols[0]
|
|
208
208
|
};
|
|
209
|
-
if (r.copyType ===
|
|
210
|
-
const { range:
|
|
211
|
-
row:
|
|
212
|
-
column:
|
|
209
|
+
if (r.copyType === mt.CUT && this._copyInfo) {
|
|
210
|
+
const { range: m, unitId: u, subUnitId: d } = this._copyInfo, h = {
|
|
211
|
+
row: m.startRow,
|
|
212
|
+
column: m.startColumn
|
|
213
213
|
};
|
|
214
|
-
if (!(i ===
|
|
214
|
+
if (!(i === u && s === d)) {
|
|
215
215
|
const l = [];
|
|
216
|
-
ze.foreach(
|
|
217
|
-
const I = this._sheetsThreadCommentModel.getAllByLocation(
|
|
218
|
-
this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((
|
|
219
|
-
l.push(
|
|
220
|
-
}) : I.forEach(({ children:
|
|
216
|
+
ze.foreach(m, (g, p) => {
|
|
217
|
+
const I = this._sheetsThreadCommentModel.getAllByLocation(u, d, g, p);
|
|
218
|
+
this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((v) => {
|
|
219
|
+
l.push(v);
|
|
220
|
+
}) : I.forEach(({ children: v, ...M }) => {
|
|
221
221
|
M.parentId || l.push(M);
|
|
222
222
|
});
|
|
223
223
|
});
|
|
224
|
-
const
|
|
225
|
-
|
|
224
|
+
const f = [], S = [], U = [], D = [], ee = (g) => {
|
|
225
|
+
f.unshift({
|
|
226
226
|
id: F.id,
|
|
227
227
|
params: {
|
|
228
|
-
unitId:
|
|
229
|
-
subUnitId:
|
|
228
|
+
unitId: u,
|
|
229
|
+
subUnitId: d,
|
|
230
230
|
commentId: g.id
|
|
231
231
|
}
|
|
232
232
|
}), U.push({
|
|
@@ -236,7 +236,7 @@ let Z = class extends $ {
|
|
|
236
236
|
subUnitId: s,
|
|
237
237
|
comment: {
|
|
238
238
|
...g,
|
|
239
|
-
ref: kt(g.ref, h,
|
|
239
|
+
ref: kt(g.ref, h, a),
|
|
240
240
|
unitId: i,
|
|
241
241
|
subUnitId: s
|
|
242
242
|
},
|
|
@@ -245,8 +245,8 @@ let Z = class extends $ {
|
|
|
245
245
|
}), S.push({
|
|
246
246
|
id: se.id,
|
|
247
247
|
params: {
|
|
248
|
-
unitId:
|
|
249
|
-
subUnitId:
|
|
248
|
+
unitId: u,
|
|
249
|
+
subUnitId: d,
|
|
250
250
|
comment: g,
|
|
251
251
|
sync: !0
|
|
252
252
|
}
|
|
@@ -262,7 +262,7 @@ let Z = class extends $ {
|
|
|
262
262
|
return l.forEach((g) => {
|
|
263
263
|
ee(g);
|
|
264
264
|
}), {
|
|
265
|
-
redos: [...
|
|
265
|
+
redos: [...f, ...U],
|
|
266
266
|
undos: [...D, ...S]
|
|
267
267
|
};
|
|
268
268
|
}
|
|
@@ -276,8 +276,8 @@ let Z = class extends $ {
|
|
|
276
276
|
);
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
|
-
Z =
|
|
280
|
-
ne(0, _(
|
|
279
|
+
Z = Bt([
|
|
280
|
+
ne(0, _(dt)),
|
|
281
281
|
ne(1, _(x)),
|
|
282
282
|
ne(2, Ee)
|
|
283
283
|
], Z);
|
|
@@ -285,31 +285,31 @@ var Ft = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Zt = (o, e
|
|
|
285
285
|
for (var r = t > 1 ? void 0 : t ? Wt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
286
286
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
287
287
|
return t && r && Ft(e, n, r), r;
|
|
288
|
-
},
|
|
288
|
+
}, B = (o, e) => (n, t) => e(n, t, o);
|
|
289
289
|
let z = class extends $ {
|
|
290
290
|
constructor(o, e, n, t) {
|
|
291
|
-
super(), this._hoverManagerService = o, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = n, this.
|
|
291
|
+
super(), this._hoverManagerService = o, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = n, this._sheetPermissionCheckController = t, this._initHoverEvent();
|
|
292
292
|
}
|
|
293
293
|
_initHoverEvent() {
|
|
294
294
|
this.disposeWithMe(
|
|
295
|
-
this._hoverManagerService.currentCell$.pipe(
|
|
295
|
+
this._hoverManagerService.currentCell$.pipe(ue(100)).subscribe((o) => {
|
|
296
296
|
const e = this._sheetsThreadCommentPopupService.activePopup;
|
|
297
297
|
if (o && (e && e.temp || !e)) {
|
|
298
|
-
const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n,
|
|
299
|
-
if (
|
|
300
|
-
if (!this.
|
|
298
|
+
const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, c = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
|
|
299
|
+
if (c) {
|
|
300
|
+
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
301
301
|
workbookTypes: [K],
|
|
302
302
|
worksheetTypes: [Q],
|
|
303
303
|
rangeTypes: [X]
|
|
304
304
|
}, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
|
|
305
305
|
return;
|
|
306
|
-
const
|
|
307
|
-
|
|
306
|
+
const m = this._sheetsThreadCommentModel.getComment(t, r, c);
|
|
307
|
+
m && !m.resolved && this._sheetsThreadCommentPopupService.showPopup({
|
|
308
308
|
unitId: t,
|
|
309
309
|
subUnitId: r,
|
|
310
310
|
row: i,
|
|
311
311
|
col: s,
|
|
312
|
-
commentId:
|
|
312
|
+
commentId: c,
|
|
313
313
|
temp: !0
|
|
314
314
|
});
|
|
315
315
|
} else
|
|
@@ -320,10 +320,10 @@ let z = class extends $ {
|
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
z = Zt([
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
B(0, _(ht)),
|
|
324
|
+
B(1, _(O)),
|
|
325
|
+
B(2, _(x)),
|
|
326
|
+
B(3, _(Ie))
|
|
327
327
|
], z);
|
|
328
328
|
var zt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, Gt = (o, e, n, t) => {
|
|
329
329
|
for (var r = t > 1 ? void 0 : t ? qt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -331,32 +331,32 @@ var zt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, Gt = (o, e
|
|
|
331
331
|
return t && r && zt(e, n, r), r;
|
|
332
332
|
}, w = (o, e) => (n, t) => e(n, t, o);
|
|
333
333
|
let q = class extends $ {
|
|
334
|
-
constructor(e, n, t, r, i, s,
|
|
334
|
+
constructor(e, n, t, r, i, s, c, a, m, u) {
|
|
335
335
|
super();
|
|
336
336
|
E(this, "_isSwitchToCommenting", !1);
|
|
337
337
|
E(this, "_selectionShapeInfo", null);
|
|
338
|
-
this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this.
|
|
338
|
+
this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this._sheetPermissionCheckController = s, this._markSelectionService = c, this._sheetSelectionService = a, this._editorBridgeService = m, this._renderManagerService = u, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
|
|
339
339
|
}
|
|
340
340
|
_handleSelectionChange(e, n, t) {
|
|
341
|
-
var h, l,
|
|
341
|
+
var h, l, f;
|
|
342
342
|
const r = (h = e[0]) == null ? void 0 : h.range, i = this._renderManagerService.getRenderById(n), s = (l = i == null ? void 0 : i.with(pt).getWorksheetSkeleton(t)) == null ? void 0 : l.skeleton;
|
|
343
343
|
if (!s || !r)
|
|
344
344
|
return;
|
|
345
|
-
const
|
|
346
|
-
if ((((
|
|
345
|
+
const c = s.getCellWithCoordByIndex(r.startRow, r.startColumn);
|
|
346
|
+
if ((((f = r.rangeType) != null ? f : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((c.isMerged || c.isMergedMainCell) && qe.equals(c.mergeInfo, r))) {
|
|
347
347
|
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
|
-
const
|
|
351
|
-
if (!this._sheetsThreadCommentModel.showCommentMarker(n, t,
|
|
350
|
+
const m = c.actualRow, u = c.actualColumn;
|
|
351
|
+
if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, m, u)) {
|
|
352
352
|
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
const
|
|
356
|
-
|
|
355
|
+
const d = this._sheetsThreadCommentModel.getByLocation(n, t, m, u);
|
|
356
|
+
d && this._commandService.executeCommand(te.id, {
|
|
357
357
|
unitId: n,
|
|
358
358
|
subUnitId: t,
|
|
359
|
-
commentId:
|
|
359
|
+
commentId: d
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
362
|
_initSelectionUpdateListener() {
|
|
@@ -391,18 +391,18 @@ let q = class extends $ {
|
|
|
391
391
|
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (e) => {
|
|
392
392
|
var n;
|
|
393
393
|
if (e) {
|
|
394
|
-
const { unitId: t, subUnitId: r, commentId: i, trigger: s } = e,
|
|
395
|
-
if (!
|
|
394
|
+
const { unitId: t, subUnitId: r, commentId: i, trigger: s } = e, c = this._sheetsThreadCommentModel.getComment(t, r, i);
|
|
395
|
+
if (!c || c.resolved)
|
|
396
396
|
return;
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
397
|
+
const a = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
|
|
398
|
+
if (!a || a.getUnitId() !== t)
|
|
399
399
|
return;
|
|
400
|
-
this._isSwitchToCommenting = !0, ((n =
|
|
400
|
+
this._isSwitchToCommenting = !0, ((n = a.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(nt.id, {
|
|
401
401
|
unitId: t,
|
|
402
402
|
subUnitId: r
|
|
403
403
|
}), this._isSwitchToCommenting = !1;
|
|
404
|
-
const
|
|
405
|
-
if (!this.
|
|
404
|
+
const d = V(c.ref), { row: h, column: l } = d;
|
|
405
|
+
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
406
406
|
workbookTypes: [K],
|
|
407
407
|
worksheetTypes: [Q],
|
|
408
408
|
rangeTypes: [X]
|
|
@@ -411,19 +411,19 @@ let q = class extends $ {
|
|
|
411
411
|
const S = 1;
|
|
412
412
|
if (await this._commandService.executeCommand(_t.id, {
|
|
413
413
|
range: {
|
|
414
|
-
startRow: Math.max(
|
|
415
|
-
endRow:
|
|
416
|
-
startColumn: Math.max(
|
|
417
|
-
endColumn:
|
|
414
|
+
startRow: Math.max(d.row - S, 0),
|
|
415
|
+
endRow: d.row + S,
|
|
416
|
+
startColumn: Math.max(d.column - S, 0),
|
|
417
|
+
endColumn: d.column + S
|
|
418
418
|
}
|
|
419
419
|
}), this._editorBridgeService.isVisible().visible)
|
|
420
420
|
return;
|
|
421
421
|
this._sheetsThreadCommentPopupService.showPopup({
|
|
422
422
|
unitId: t,
|
|
423
423
|
subUnitId: r,
|
|
424
|
-
row:
|
|
425
|
-
col:
|
|
426
|
-
commentId:
|
|
424
|
+
row: d.row,
|
|
425
|
+
col: d.column,
|
|
426
|
+
commentId: c.id,
|
|
427
427
|
trigger: s
|
|
428
428
|
});
|
|
429
429
|
} else
|
|
@@ -431,7 +431,7 @@ let q = class extends $ {
|
|
|
431
431
|
}));
|
|
432
432
|
}
|
|
433
433
|
_initMarkSelection() {
|
|
434
|
-
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(
|
|
434
|
+
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(ue(100)).subscribe((e) => {
|
|
435
435
|
var h, l;
|
|
436
436
|
if (!e) {
|
|
437
437
|
this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
|
|
@@ -442,17 +442,17 @@ let q = class extends $ {
|
|
|
442
442
|
const i = this._sheetsThreadCommentModel.getComment(n, t, r);
|
|
443
443
|
if (!i)
|
|
444
444
|
return;
|
|
445
|
-
const s = V(i.ref), { row:
|
|
446
|
-
if (Number.isNaN(
|
|
445
|
+
const s = V(i.ref), { row: c, column: a } = s;
|
|
446
|
+
if (Number.isNaN(c) || Number.isNaN(a))
|
|
447
447
|
return null;
|
|
448
|
-
const
|
|
449
|
-
startColumn:
|
|
450
|
-
endColumn:
|
|
451
|
-
startRow:
|
|
452
|
-
endRow:
|
|
453
|
-
},
|
|
448
|
+
const m = (h = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : h.getSheetBySheetId(t), u = (l = m == null ? void 0 : m.getMergedCell(c, a)) != null ? l : {
|
|
449
|
+
startColumn: a,
|
|
450
|
+
endColumn: a,
|
|
451
|
+
startRow: c,
|
|
452
|
+
endRow: c
|
|
453
|
+
}, d = this._markSelectionService.addShape(
|
|
454
454
|
{
|
|
455
|
-
range:
|
|
455
|
+
range: u,
|
|
456
456
|
style: {
|
|
457
457
|
// hasAutoFill: false,
|
|
458
458
|
fill: "rgb(255, 189, 55, 0.35)",
|
|
@@ -465,20 +465,20 @@ let q = class extends $ {
|
|
|
465
465
|
[],
|
|
466
466
|
-1
|
|
467
467
|
);
|
|
468
|
-
|
|
468
|
+
d && (this._selectionShapeInfo = {
|
|
469
469
|
...e,
|
|
470
|
-
shapeId:
|
|
470
|
+
shapeId: d
|
|
471
471
|
});
|
|
472
472
|
}));
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
q = Gt([
|
|
476
|
-
w(0,
|
|
476
|
+
w(0, ce),
|
|
477
477
|
w(1, _(O)),
|
|
478
478
|
w(2, _(x)),
|
|
479
|
-
w(3, _(
|
|
479
|
+
w(3, _(ae)),
|
|
480
480
|
w(4, N),
|
|
481
|
-
w(5, _(
|
|
481
|
+
w(5, _(Ie)),
|
|
482
482
|
w(6, Te),
|
|
483
483
|
w(7, _(Se)),
|
|
484
484
|
w(8, lt),
|
|
@@ -505,26 +505,26 @@ let G = class extends $ {
|
|
|
505
505
|
const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
|
|
506
506
|
if (!i)
|
|
507
507
|
return { redos: [], undos: [] };
|
|
508
|
-
const s = this._threadCommentModel.ensureMap(r, i),
|
|
508
|
+
const s = this._threadCommentModel.ensureMap(r, i), c = Array.from(s.values()).filter((h) => !h.parentId), a = c.map((h) => h.id), m = this._threadCommentDataSourceService.syncUpdateMutationToColla, u = a.map((h) => ({
|
|
509
509
|
id: F.id,
|
|
510
510
|
params: {
|
|
511
511
|
unitId: r,
|
|
512
512
|
subUnitId: i,
|
|
513
513
|
commentId: h
|
|
514
514
|
}
|
|
515
|
-
})),
|
|
515
|
+
})), d = c.map(({ children: h, ...l }) => ({
|
|
516
516
|
id: se.id,
|
|
517
517
|
params: {
|
|
518
518
|
unitId: r,
|
|
519
519
|
subUnitId: i,
|
|
520
520
|
comment: {
|
|
521
521
|
...l,
|
|
522
|
-
children:
|
|
522
|
+
children: m ? h : void 0
|
|
523
523
|
},
|
|
524
|
-
sync: !
|
|
524
|
+
sync: !m
|
|
525
525
|
}
|
|
526
526
|
}));
|
|
527
|
-
return { redos:
|
|
527
|
+
return { redos: u, undos: d };
|
|
528
528
|
}
|
|
529
529
|
return { redos: [], undos: [] };
|
|
530
530
|
}
|
|
@@ -554,8 +554,8 @@ var P = function() {
|
|
|
554
554
|
e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
|
|
555
555
|
return n;
|
|
556
556
|
}, xe = Re(function(o, e) {
|
|
557
|
-
var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Qt(o, ["icon", "id", "className", "extend"]),
|
|
558
|
-
return De(n, "".concat(t), { defIds: n.defIds, idSuffix:
|
|
557
|
+
var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Qt(o, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), a = Oe("_".concat(tn()));
|
|
558
|
+
return De(n, "".concat(t), { defIds: n.defIds, idSuffix: a.current }, P({ ref: e, className: c }, s), i);
|
|
559
559
|
});
|
|
560
560
|
function De(o, e, n, t, r) {
|
|
561
561
|
return Ue(o.tag, P(P({ key: e }, Xt(o, n, r)), t), (en(o, n).children || []).map(function(i, s) {
|
|
@@ -567,8 +567,8 @@ function Xt(o, e, n) {
|
|
|
567
567
|
n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
|
|
568
568
|
var r = e.defIds;
|
|
569
569
|
return !r || r.length === 0 || (o.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(i) {
|
|
570
|
-
var s = i[0],
|
|
571
|
-
typeof
|
|
570
|
+
var s = i[0], c = i[1];
|
|
571
|
+
typeof c == "string" && (t[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
572
572
|
})), t;
|
|
573
573
|
}
|
|
574
574
|
function en(o, e) {
|
|
@@ -599,17 +599,17 @@ var re = { exports: {} }, j = {};
|
|
|
599
599
|
* This source code is licensed under the MIT license found in the
|
|
600
600
|
* LICENSE file in the root directory of this source tree.
|
|
601
601
|
*/
|
|
602
|
-
var
|
|
602
|
+
var ve;
|
|
603
603
|
function rn() {
|
|
604
|
-
if (
|
|
605
|
-
|
|
604
|
+
if (ve) return j;
|
|
605
|
+
ve = 1;
|
|
606
606
|
var o = Rt, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
607
|
-
function s(
|
|
608
|
-
var
|
|
609
|
-
|
|
610
|
-
for (
|
|
611
|
-
if (
|
|
612
|
-
return { $$typeof: e, type:
|
|
607
|
+
function s(c, a, m) {
|
|
608
|
+
var u, d = {}, h = null, l = null;
|
|
609
|
+
m !== void 0 && (h = "" + m), a.key !== void 0 && (h = "" + a.key), a.ref !== void 0 && (l = a.ref);
|
|
610
|
+
for (u in a) t.call(a, u) && !i.hasOwnProperty(u) && (d[u] = a[u]);
|
|
611
|
+
if (c && c.defaultProps) for (u in a = c.defaultProps, a) d[u] === void 0 && (d[u] = a[u]);
|
|
612
|
+
return { $$typeof: e, type: c, key: h, ref: l, props: d, _owner: r.current };
|
|
613
613
|
}
|
|
614
614
|
return j.Fragment = n, j.jsx = s, j.jsxs = s, j;
|
|
615
615
|
}
|
|
@@ -622,11 +622,11 @@ const sn = () => {
|
|
|
622
622
|
const o = R(N), e = R(O), n = A(e.activePopup$), t = R(x);
|
|
623
623
|
if (A(t.commentUpdate$), !n)
|
|
624
624
|
return null;
|
|
625
|
-
const { row: r, col: i, unitId: s, subUnitId:
|
|
625
|
+
const { row: r, col: i, unitId: s, subUnitId: c, trigger: a } = n, m = t.getByLocation(s, c, r, i), u = `${Ge.chatAtABC(i)}${r + 1}`, d = () => {
|
|
626
626
|
e.hidePopup();
|
|
627
627
|
}, h = (l) => {
|
|
628
|
-
var
|
|
629
|
-
return (U = (S = (
|
|
628
|
+
var f, S, U;
|
|
629
|
+
return (U = (S = (f = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : f.getSheetBySheetId(l)) == null ? void 0 : S.getName()) != null ? U : "";
|
|
630
630
|
};
|
|
631
631
|
return /* @__PURE__ */ Ae.jsx(
|
|
632
632
|
it,
|
|
@@ -635,27 +635,27 @@ const sn = () => {
|
|
|
635
635
|
e.persistPopup();
|
|
636
636
|
},
|
|
637
637
|
prefix: "cell",
|
|
638
|
-
id:
|
|
638
|
+
id: m,
|
|
639
639
|
unitId: s,
|
|
640
|
-
subUnitId:
|
|
640
|
+
subUnitId: c,
|
|
641
641
|
type: b.UNIVER_SHEET,
|
|
642
|
-
refStr:
|
|
643
|
-
onClose:
|
|
642
|
+
refStr: u,
|
|
643
|
+
onClose: d,
|
|
644
644
|
getSubUnitName: h,
|
|
645
|
-
autoFocus:
|
|
645
|
+
autoFocus: a === "context-menu"
|
|
646
646
|
}
|
|
647
647
|
);
|
|
648
|
-
},
|
|
648
|
+
}, cn = () => {
|
|
649
649
|
var g;
|
|
650
|
-
const o = R(Te), e = R(N), n = R(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = R(
|
|
651
|
-
const I = t.getSheets(),
|
|
650
|
+
const o = R(Te), e = R(N), n = R(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = R(ce), s = Ot(() => t.activeSheet$.pipe(wt((p) => p == null ? void 0 : p.getSheetId())), [t.activeSheet$]), c = A(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), a = Oe(), m = R(ae), u = A(m.activeCommentId$), d = A(m.panelVisible$, m.panelVisible), h = pe((p) => {
|
|
651
|
+
const I = t.getSheets(), v = {};
|
|
652
652
|
I.forEach((T, C) => {
|
|
653
|
-
|
|
653
|
+
v[T.getSheetId()] = C;
|
|
654
654
|
});
|
|
655
655
|
const M = (T) => T.map((C) => {
|
|
656
|
-
var
|
|
657
|
-
const y = V(C.ref),
|
|
658
|
-
return { ...C, p:
|
|
656
|
+
var me;
|
|
657
|
+
const y = V(C.ref), Le = [(me = v[C.subUnitId]) != null ? me : 0, y.row, y.column];
|
|
658
|
+
return { ...C, p: Le };
|
|
659
659
|
}).sort((C, y) => C.p[0] === y.p[0] ? C.p[1] === y.p[1] ? C.p[2] - y.p[2] : C.p[1] - y.p[1] : C.p[0] - y.p[0]);
|
|
660
660
|
return [
|
|
661
661
|
...M(p.filter((T) => !T.resolved)),
|
|
@@ -663,14 +663,14 @@ const sn = () => {
|
|
|
663
663
|
];
|
|
664
664
|
}, [t]), l = pe((p) => {
|
|
665
665
|
var I;
|
|
666
|
-
if (p.unitId === r && p.subUnitId ===
|
|
667
|
-
const { row:
|
|
666
|
+
if (p.unitId === r && p.subUnitId === c && !p.resolved) {
|
|
667
|
+
const { row: v, column: M } = V(p.ref), T = t.getSheetBySheetId(p.subUnitId), C = (I = T == null ? void 0 : T.getMergedCell(v, M)) != null ? I : {
|
|
668
668
|
startColumn: M,
|
|
669
669
|
endColumn: M,
|
|
670
|
-
startRow:
|
|
671
|
-
endRow:
|
|
670
|
+
startRow: v,
|
|
671
|
+
endRow: v
|
|
672
672
|
};
|
|
673
|
-
if (!Number.isNaN(
|
|
673
|
+
if (!Number.isNaN(v) && !Number.isNaN(M))
|
|
674
674
|
return o.addShape({
|
|
675
675
|
range: C,
|
|
676
676
|
style: {
|
|
@@ -683,28 +683,28 @@ const sn = () => {
|
|
|
683
683
|
primary: null
|
|
684
684
|
});
|
|
685
685
|
}
|
|
686
|
-
}, [o,
|
|
687
|
-
var I,
|
|
688
|
-
return (
|
|
686
|
+
}, [o, c, r]), f = (p) => {
|
|
687
|
+
var I, v;
|
|
688
|
+
return (v = (I = t.getSheetBySheetId(p)) == null ? void 0 : I.getName()) != null ? v : "";
|
|
689
689
|
}, S = () => {
|
|
690
|
-
i.executeCommand(
|
|
690
|
+
i.executeCommand(H.id);
|
|
691
691
|
}, U = (p) => {
|
|
692
|
-
|
|
692
|
+
u && u.unitId === p.unitId && u.subUnitId === p.subUnitId && u.commentId === p.id || (a.current && (o.removeShape(a.current), a.current = null), a.current = l(p));
|
|
693
693
|
}, D = () => {
|
|
694
|
-
|
|
694
|
+
a.current && (o.removeShape(a.current), a.current = null);
|
|
695
695
|
}, ee = (p, I) => {
|
|
696
696
|
I && n.hidePopup();
|
|
697
697
|
};
|
|
698
698
|
return Ut(() => {
|
|
699
|
-
!
|
|
700
|
-
}, [o,
|
|
699
|
+
!d && a.current && o.removeShape(a.current);
|
|
700
|
+
}, [o, d]), /* @__PURE__ */ Ae.jsx(
|
|
701
701
|
st,
|
|
702
702
|
{
|
|
703
703
|
unitId: r,
|
|
704
704
|
subUnitId$: s,
|
|
705
705
|
type: b.UNIVER_SHEET,
|
|
706
706
|
onAdd: S,
|
|
707
|
-
getSubUnitName:
|
|
707
|
+
getSubUnitName: f,
|
|
708
708
|
onResolve: ee,
|
|
709
709
|
sortComments: h,
|
|
710
710
|
onItemEnter: U,
|
|
@@ -712,10 +712,10 @@ const sn = () => {
|
|
|
712
712
|
onDeleteComment: () => (D(), !0)
|
|
713
713
|
}
|
|
714
714
|
);
|
|
715
|
-
},
|
|
716
|
-
id:
|
|
715
|
+
}, an = (o) => ({
|
|
716
|
+
id: H.id,
|
|
717
717
|
type: Me.BUTTON,
|
|
718
|
-
icon:
|
|
718
|
+
icon: de,
|
|
719
719
|
title: "sheetThreadComment.menu.addComment",
|
|
720
720
|
hidden$: we(o, b.UNIVER_SHEET),
|
|
721
721
|
disabled$: be(o, {
|
|
@@ -723,10 +723,10 @@ const sn = () => {
|
|
|
723
723
|
worksheetTypes: [Q],
|
|
724
724
|
rangeTypes: [X]
|
|
725
725
|
})
|
|
726
|
-
}),
|
|
727
|
-
id:
|
|
726
|
+
}), un = (o) => ({
|
|
727
|
+
id: Pe.id,
|
|
728
728
|
type: Me.BUTTON,
|
|
729
|
-
icon:
|
|
729
|
+
icon: de,
|
|
730
730
|
tooltip: "sheetThreadComment.menu.commentManagement",
|
|
731
731
|
disabled$: be(o, {
|
|
732
732
|
workbookTypes: [K],
|
|
@@ -734,22 +734,22 @@ const sn = () => {
|
|
|
734
734
|
rangeTypes: [X]
|
|
735
735
|
}),
|
|
736
736
|
hidden$: we(o, b.UNIVER_SHEET)
|
|
737
|
-
}),
|
|
738
|
-
id:
|
|
737
|
+
}), dn = {
|
|
738
|
+
id: H.id,
|
|
739
739
|
binding: Ct.M | le.CTRL_COMMAND | le.ALT,
|
|
740
|
-
preconditions:
|
|
741
|
-
},
|
|
740
|
+
preconditions: ft
|
|
741
|
+
}, mn = {
|
|
742
742
|
[St.OTHERS]: {
|
|
743
|
-
[
|
|
743
|
+
[Pe.id]: {
|
|
744
744
|
order: 1,
|
|
745
|
-
menuItemFactory:
|
|
745
|
+
menuItemFactory: un
|
|
746
746
|
}
|
|
747
747
|
},
|
|
748
748
|
[gt.MAIN_AREA]: {
|
|
749
749
|
[It.OTHERS]: {
|
|
750
|
-
[
|
|
750
|
+
[H.id]: {
|
|
751
751
|
order: 0,
|
|
752
|
-
menuItemFactory:
|
|
752
|
+
menuItemFactory: an
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
}
|
|
@@ -764,16 +764,16 @@ let J = class extends $ {
|
|
|
764
764
|
super(), this._menuManagerService = o, this._componentManager = e, this._shortcutService = n, this._initMenu(), this._initShortcut(), this._initComponent();
|
|
765
765
|
}
|
|
766
766
|
_initShortcut() {
|
|
767
|
-
this._shortcutService.registerShortcut(
|
|
767
|
+
this._shortcutService.registerShortcut(dn);
|
|
768
768
|
}
|
|
769
769
|
_initMenu() {
|
|
770
|
-
this._menuManagerService.mergeMenu(
|
|
770
|
+
this._menuManagerService.mergeMenu(mn);
|
|
771
771
|
}
|
|
772
772
|
_initComponent() {
|
|
773
773
|
[
|
|
774
774
|
[$e, sn],
|
|
775
|
-
[
|
|
776
|
-
[
|
|
775
|
+
[ct, cn],
|
|
776
|
+
[de, je]
|
|
777
777
|
].forEach(([o, e]) => {
|
|
778
778
|
this._componentManager.register(o, e);
|
|
779
779
|
});
|
|
@@ -784,17 +784,17 @@ J = pn([
|
|
|
784
784
|
oe(1, _(Pt)),
|
|
785
785
|
oe(2, bt)
|
|
786
786
|
], J);
|
|
787
|
-
var Ve = Object.defineProperty, _n = Object.getOwnPropertyDescriptor,
|
|
787
|
+
var Ve = Object.defineProperty, _n = Object.getOwnPropertyDescriptor, fn = (o, e, n) => e in o ? Ve(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, vn = (o, e, n, t) => {
|
|
788
788
|
for (var r = t > 1 ? void 0 : t ? _n(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
789
789
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
790
790
|
return t && r && Ve(e, n, r), r;
|
|
791
|
-
}, ie = (o, e) => (n, t) => e(n, t, o),
|
|
791
|
+
}, ie = (o, e) => (n, t) => e(n, t, o), He = (o, e, n) => fn(o, typeof e != "symbol" ? e + "" : e, n);
|
|
792
792
|
let Y = class extends Ke {
|
|
793
|
-
constructor(o =
|
|
793
|
+
constructor(o = fe, e, n, t) {
|
|
794
794
|
super(), this._config = o, this._injector = e, this._commandService = n, this._configService = t;
|
|
795
795
|
const { menu: r, ...i } = Qe(
|
|
796
796
|
{},
|
|
797
|
-
|
|
797
|
+
fe,
|
|
798
798
|
this._config
|
|
799
799
|
);
|
|
800
800
|
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Dt, i);
|
|
@@ -810,7 +810,7 @@ let Y = class extends Ke {
|
|
|
810
810
|
[O]
|
|
811
811
|
].forEach((o) => {
|
|
812
812
|
this._injector.add(o);
|
|
813
|
-
}), [
|
|
813
|
+
}), [H].forEach((o) => {
|
|
814
814
|
this._commandService.registerCommand(o);
|
|
815
815
|
}), this._injector.get(J);
|
|
816
816
|
}
|
|
@@ -821,12 +821,12 @@ let Y = class extends Ke {
|
|
|
821
821
|
this._injector.get(Z), this._injector.get(z), this._injector.get(q);
|
|
822
822
|
}
|
|
823
823
|
};
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
Y =
|
|
827
|
-
Je(
|
|
824
|
+
He(Y, "pluginName", Ne);
|
|
825
|
+
He(Y, "type", b.UNIVER_SHEET);
|
|
826
|
+
Y = vn([
|
|
827
|
+
Je(at, ot),
|
|
828
828
|
ie(1, _(Ye)),
|
|
829
|
-
ie(2, _(
|
|
829
|
+
ie(2, _(ce)),
|
|
830
830
|
ie(3, Xe)
|
|
831
831
|
], Y);
|
|
832
832
|
export {
|
|
@@ -837,8 +837,8 @@ export {
|
|
|
837
837
|
Vn as ResolveCommentCommand,
|
|
838
838
|
Ne as SHEETS_THREAD_COMMENT,
|
|
839
839
|
O as SheetsThreadCommentPopupService,
|
|
840
|
-
|
|
840
|
+
H as ShowAddSheetCommentModalOperation,
|
|
841
841
|
Y as UniverSheetsThreadCommentUIPlugin,
|
|
842
842
|
$n as UniverThreadCommentUIPlugin,
|
|
843
|
-
|
|
843
|
+
Hn as UpdateCommentCommand
|
|
844
844
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Disposable } from '@univerjs/core';
|
|
2
|
+
import { SheetPermissionCheckController } from '@univerjs/sheets';
|
|
2
3
|
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
|
|
3
|
-
import { HoverManagerService
|
|
4
|
+
import { HoverManagerService } from '@univerjs/sheets-ui';
|
|
4
5
|
import { SheetsThreadCommentPopupService } from '../services/sheets-thread-comment-popup.service';
|
|
5
6
|
export declare class SheetsThreadCommentHoverController extends Disposable {
|
|
6
7
|
private readonly _hoverManagerService;
|
|
7
8
|
private readonly _sheetsThreadCommentPopupService;
|
|
8
9
|
private readonly _sheetsThreadCommentModel;
|
|
9
|
-
private readonly
|
|
10
|
-
constructor(_hoverManagerService: HoverManagerService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel,
|
|
10
|
+
private readonly _sheetPermissionCheckController;
|
|
11
|
+
constructor(_hoverManagerService: HoverManagerService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _sheetPermissionCheckController: SheetPermissionCheckController);
|
|
11
12
|
private _initHoverEvent;
|
|
12
13
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
3
|
-
import { SheetsSelectionsService } from '@univerjs/sheets';
|
|
3
|
+
import { SheetPermissionCheckController, SheetsSelectionsService } from '@univerjs/sheets';
|
|
4
4
|
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
|
|
5
|
-
import { IEditorBridgeService, IMarkSelectionService
|
|
5
|
+
import { IEditorBridgeService, IMarkSelectionService } from '@univerjs/sheets-ui';
|
|
6
6
|
import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
|
|
7
7
|
import { SheetsThreadCommentPopupService } from '../services/sheets-thread-comment-popup.service';
|
|
8
8
|
export declare class SheetsThreadCommentPopupController extends Disposable {
|
|
@@ -11,14 +11,14 @@ export declare class SheetsThreadCommentPopupController extends Disposable {
|
|
|
11
11
|
private readonly _sheetsThreadCommentModel;
|
|
12
12
|
private readonly _threadCommentPanelService;
|
|
13
13
|
private readonly _univerInstanceService;
|
|
14
|
-
private readonly
|
|
14
|
+
private readonly _sheetPermissionCheckController;
|
|
15
15
|
private readonly _markSelectionService;
|
|
16
16
|
private readonly _sheetSelectionService;
|
|
17
17
|
private readonly _editorBridgeService;
|
|
18
18
|
private readonly _renderManagerService;
|
|
19
19
|
private _isSwitchToCommenting;
|
|
20
20
|
private _selectionShapeInfo;
|
|
21
|
-
constructor(_commandService: ICommandService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentPanelService: ThreadCommentPanelService, _univerInstanceService: IUniverInstanceService,
|
|
21
|
+
constructor(_commandService: ICommandService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentPanelService: ThreadCommentPanelService, _univerInstanceService: IUniverInstanceService, _sheetPermissionCheckController: SheetPermissionCheckController, _markSelectionService: IMarkSelectionService, _sheetSelectionService: SheetsSelectionsService, _editorBridgeService: IEditorBridgeService, _renderManagerService: IRenderManagerService);
|
|
22
22
|
private _handleSelectionChange;
|
|
23
23
|
private _initSelectionUpdateListener;
|
|
24
24
|
private _initEditorBridge;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,s,v,A,P,I,f,k,ie,$,C,E){"use strict";var rt=Object.defineProperty;var it=(d,s,v)=>s in d?rt(d,s,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[s]=v;var N=(d,s,v)=>it(d,typeof s!="symbol"?s+"":s,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ce=(i,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_e(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,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,e){var m;const{row:r,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.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 u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(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))}},d.SheetsThreadCommentPopupService=Ce([se(0,s.Inject(I.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const B={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var g;const t=i.get(v.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(P.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,a=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=a.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ae={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ge(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([L(0,s.Inject(v.SheetInterceptorService)),L(1,s.Inject(A.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=$.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return $.serializeRange(a)};let F=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&a===l)){const S=[];s.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(T=>{S.push(T)}):R.forEach(({children:T,...j})=>{j.parentId||S.push(j)})});const g=[],M=[],V=[],H=[],re=w=>{g.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...g,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,s.Inject(I.ISheetClipboardService)),X(1,s.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,s.Inject(I.HoverManagerService)),G(1,s.Inject(d.SheetsThreadCommentPopupService)),G(2,s.Inject(A.SheetsThreadCommentModel)),G(3,s.Inject(I.SheetPermissionInterceptorBaseController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(t,n,e,r,o,a,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,g;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),a=(S=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!a||!r)return;const c=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((g=r.rangeType)!=null?g:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=$.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=$.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,s.ICommandService),U(1,s.Inject(d.SheetsThreadCommentPopupService)),U(2,s.Inject(A.SheetsThreadCommentModel)),U(3,s.Inject(P.ThreadCommentPanelService)),U(4,s.IUniverInstanceService),U(5,s.Inject(I.SheetPermissionInterceptorBaseController)),U(6,I.IMarkSelectionService),U(7,s.Inject(v.SheetsSelectionsService)),U(8,I.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),c=Array.from(a.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,s.Inject(v.SheetInterceptorService)),q(1,s.IUniverInstanceService),q(2,s.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},$e=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ce=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=$e(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(xe()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ue(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},Be(i,n,r)),e),(ke(i,n).children||[]).map(function(o,a){return ue(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function Be(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ke(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function xe(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=E.forwardRef(function(i,t){return E.createElement(ce,Object.assign({},i,{id:"comment-single",ref:t,icon:He}))});de.displayName="CommentSingle";var ee={exports:{}},x={};/**
|
|
1
|
+
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,s,v,A,g,b,f,x,ie,k,C,E){"use strict";var rt=Object.defineProperty;var it=(d,s,v)=>s in d?rt(d,s,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[s]=v;var N=(d,s,v)=>it(d,typeof s!="symbol"?s+"":s,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ce=(i,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_e(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new x.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,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,e){var m;const{row:r,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.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 u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(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))}},d.SheetsThreadCommentPopupService=Ce([se(0,s.Inject(b.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const $={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var I;const t=i.get(v.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=a.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ae={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ge(t,n,r),r},B=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(x.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([B(0,s.Inject(v.SheetInterceptorService)),B(1,s.Inject(A.SheetsThreadCommentModel)),B(2,s.IUniverInstanceService),B(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=k.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return k.serializeRange(a)};let F=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===b.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&a===l)){const S=[];s.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(P=>{S.push(P)}):R.forEach(({children:P,...j})=>{j.parentId||S.push(j)})});const I=[],M=[],V=[],L=[],re=w=>{I.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),L.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...I,...V],undos:[...L,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,s.Inject(b.ISheetClipboardService)),X(1,s.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(x.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,s.Inject(b.HoverManagerService)),G(1,s.Inject(d.SheetsThreadCommentPopupService)),G(2,s.Inject(A.SheetsThreadCommentModel)),G(3,s.Inject(v.SheetPermissionCheckController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(t,n,e,r,o,a,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,I;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),a=(S=o==null?void 0:o.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!a||!r)return;const c=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((I=r.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=k.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(b.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(x.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=k.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,s.ICommandService),U(1,s.Inject(d.SheetsThreadCommentPopupService)),U(2,s.Inject(A.SheetsThreadCommentModel)),U(3,s.Inject(g.ThreadCommentPanelService)),U(4,s.IUniverInstanceService),U(5,s.Inject(v.SheetPermissionCheckController)),U(6,b.IMarkSelectionService),U(7,s.Inject(v.SheetsSelectionsService)),U(8,b.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),c=Array.from(a.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,s.Inject(v.SheetInterceptorService)),q(1,s.IUniverInstanceService),q(2,s.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},ke=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ce=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=ke(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(He()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ue(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},$e(i,n,r)),e),(xe(i,n).children||[]).map(function(o,a){return ue(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function $e(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function xe(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function He(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=E.forwardRef(function(i,t){return E.createElement(ce,Object.assign({},i,{id:"comment-single",ref:t,icon:Le}))});de.displayName="CommentSingle";var ee={exports:{}},H={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var me;function
|
|
9
|
+
*/var me;function Be(){if(me)return H;me=1;var i=E,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,h){var m,l={},p=null,S=null;h!==void 0&&(p=""+h),u.key!==void 0&&(p=""+u.key),u.ref!==void 0&&(S=u.ref);for(m in u)e.call(u,m)&&!o.hasOwnProperty(m)&&(l[m]=u[m]);if(c&&c.defaultProps)for(m in u=c.defaultProps,u)l[m]===void 0&&(l[m]=u[m]);return{$$typeof:t,type:c,key:p,ref:S,props:l,_owner:r.current}}return H.Fragment=n,H.jsx=a,H.jsxs=a,H}var he;function We(){return he||(he=1,ee.exports=Be()),ee.exports}var le=We();const Fe=()=>{const i=s.useDependency(s.IUniverInstanceService),t=s.useDependency(d.SheetsThreadCommentPopupService),n=f.useObservable(t.activePopup$),e=s.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:a,subUnitId:c,trigger:u}=n,h=e.getByLocation(a,c,r,o),m=`${s.Tools.chatAtABC(o)}${r+1}`,l=()=>{t.hidePopup()},p=S=>{var I,M,V;return(V=(M=(I=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(S))==null?void 0:M.getName())!=null?V:""};return le.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:l,getSubUnitName:p,autoFocus:u==="context-menu"})},Ge=()=>{var w;const i=s.useDependency(b.IMarkSelectionService),t=s.useDependency(s.IUniverInstanceService),n=s.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=s.useDependency(s.ICommandService),a=E.useMemo(()=>e.activeSheet$.pipe(x.map(_=>_==null?void 0:_.getSheetId())),[e.activeSheet$]),c=f.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),h=s.useDependency(g.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),l=f.useObservable(h.panelVisible$,h.panelVisible),p=E.useCallback(_=>{const R=e.getSheets(),P={};R.forEach((O,T)=>{P[O.getSheetId()]=T});const j=O=>O.map(T=>{var Se;const D=k.singleReferenceToGrid(T.ref),nt=[(Se=P[T.subUnitId])!=null?Se:0,D.row,D.column];return{...T,p:nt}}).sort((T,D)=>T.p[0]===D.p[0]?T.p[1]===D.p[1]?T.p[2]-D.p[2]:T.p[1]-D.p[1]:T.p[0]-D.p[0]);return[...j(_.filter(O=>!O.resolved)),...j(_.filter(O=>O.resolved))]},[e]),S=E.useCallback(_=>{var R;if(_.unitId===r&&_.subUnitId===c&&!_.resolved){const{row:P,column:j}=k.singleReferenceToGrid(_.ref),O=e.getSheetBySheetId(_.subUnitId),T=(R=O==null?void 0:O.getMergedCell(P,j))!=null?R:{startColumn:j,endColumn:j,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(j))return i.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,c,r]),I=_=>{var R,P;return(P=(R=e.getSheetBySheetId(_))==null?void 0:R.getName())!=null?P:""},M=()=>{o.executeCommand($.id)},V=_=>{m&&m.unitId===_.unitId&&m.subUnitId===_.subUnitId&&m.commentId===_.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=S(_))},L=()=>{u.current&&(i.removeShape(u.current),u.current=null)},re=(_,R)=>{R&&n.hidePopup()};return E.useEffect(()=>{!l&&u.current&&i.removeShape(u.current)},[i,l]),le.jsx(g.ThreadCommentPanel,{unitId:r,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:I,onResolve:re,sortComments:p,onItemEnter:V,onItemLeave:L,onDeleteComment:()=>(L(),!0)})},Ze=i=>({id:$.id,type:f.MenuItemType.BUTTON,icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),ze=i=>({id:g.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET)}),qe={id:$.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:b.whenSheetEditorFocused},Ye={[f.RibbonStartGroup.OTHERS]:{[g.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:ze}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[$.id]:{order:0,menuItemFactory:Ze}}}};var Je=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Qe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Je(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);let J=class extends s.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(qe)}_initMenu(){this._menuManagerService.mergeMenu(Ye)}_initComponent(){[[oe,Fe],[g.THREAD_COMMENT_PANEL,Ge],[K,de]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};J=Qe([te(0,f.IMenuManagerService),te(1,s.Inject(f.ComponentManager)),te(2,f.IShortcutService)],J);var pe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(i,t,n)=>t in i?pe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,tt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&pe(t,n,r),r},ne=(i,t)=>(n,e)=>t(n,e,i),ve=(i,t,n)=>et(i,typeof t!="symbol"?t+"":t,n);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=ae,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...a}=s.merge({},ae,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ie,a)}onStarting(){[[J],[W],[F],[Z],[Y],[z],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[$].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(J)}onReady(){this._injector.get(W),this._injector.get(Y)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(z)}},ve(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),ve(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=tt([s.DependentOn(g.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),ne(1,s.Inject(s.Injector)),ne(2,s.Inject(s.ICommandService)),ne(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Q,d.ShowAddSheetCommentModalOperation=$,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment-ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,26 +52,27 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.2.
|
|
55
|
+
"@univerjs/icons": "^0.2.12",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/sheets-
|
|
62
|
-
"@univerjs/sheets-
|
|
63
|
-
"@univerjs/thread-comment": "0.5.
|
|
64
|
-
"@univerjs/thread-comment
|
|
65
|
-
"@univerjs/ui": "0.5.
|
|
57
|
+
"@univerjs/core": "0.5.4",
|
|
58
|
+
"@univerjs/engine-formula": "0.5.4",
|
|
59
|
+
"@univerjs/engine-render": "0.5.4",
|
|
60
|
+
"@univerjs/sheets": "0.5.4",
|
|
61
|
+
"@univerjs/sheets-ui": "0.5.4",
|
|
62
|
+
"@univerjs/sheets-thread-comment": "0.5.4",
|
|
63
|
+
"@univerjs/thread-comment-ui": "0.5.4",
|
|
64
|
+
"@univerjs/thread-comment": "0.5.4",
|
|
65
|
+
"@univerjs/ui": "0.5.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"postcss": "^8.4.49",
|
|
69
69
|
"react": "18.3.1",
|
|
70
70
|
"rxjs": "^7.8.1",
|
|
71
|
+
"tailwindcss": "^3.4.17",
|
|
71
72
|
"typescript": "^5.7.2",
|
|
72
|
-
"vite": "^6.0.
|
|
73
|
+
"vite": "^6.0.7",
|
|
73
74
|
"vitest": "^2.1.8",
|
|
74
|
-
"@univerjs-infra/shared": "0.5.
|
|
75
|
+
"@univerjs-infra/shared": "0.5.4"
|
|
75
76
|
},
|
|
76
77
|
"scripts": {
|
|
77
78
|
"test": "vitest run",
|