@univerjs/sheets-thread-comment-ui 0.10.10 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var he=Object.defineProperty;var ue=(n,t,r)=>t in n?he(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var D=(n,t,r)=>ue(n,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),T=require("@univerjs/sheets-ui"),l=require("@univerjs/ui"),V=require("rxjs"),re=require("@univerjs/engine-render"),$=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),oe=require("react/jsx-runtime"),O=require("react"),ie="univer.sheet.thread-comment-modal",ee="SHEET_THREAD_COMMENT";var le=Object.getOwnPropertyDescriptor,pe=(n,t,r,e)=>{for(var o=e>1?void 0:e?le(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Y=(n,t)=>(r,e)=>t(r,e,n);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e,o){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new V.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var u;const{row:o,col:i,unitId:s,subUnitId:c}=r;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((u=this.activePopup)==null?void 0:u.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const m=this._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:c},{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.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=pe([Y(0,a.Inject(T.SheetCanvasPopManagerService)),Y(1,l.IZenZoneService),Y(2,a.Inject(T.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const x={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var g;const t=n.get(C.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),e=n.get(exports.SheetsThreadCommentPopupService),o=n.get(P.ThreadCommentPanelService),i=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=n.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(r);if(!c)return!1;const{workbook:m,worksheet:d,unitId:u,subUnitId:h}=c,p={workbook:m,worksheet:d,unitId:u,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(p);const S=s.getByLocation(u,h,i.startRow,i.startColumn);return S&&o.setActiveComment({unitId:u,subUnitId:h,commentId:S,trigger:"context-menu"}),!0}},ve="sheets-thread-comment.config",ne={};var Ce=Object.getOwnPropertyDescriptor,Se=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ce(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},H=(n,t)=>(r,e)=>t(r,e,n);let W=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:o,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,o)&&((!n||n===t.rawData)&&(n={...t.rawData}),n.markers={...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}),r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var o;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{n()}))}};W=Se([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject(N.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,re.IRenderManagerService)],W);var _e=Object.getOwnPropertyDescriptor,ge=(n,t,r,e)=>{for(var o=e>1?void 0:e?_e(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},J=(n,t)=>(r,e)=>t(r,e,n);const fe=(n,t,r)=>{const e=$.singleReferenceToGrid(n),o=r.row-t.row,i=r.column-t.column,s={startColumn:e.column+i,startRow:e.row+o,endColumn:e.column+i,endRow:e.row+o};return $.serializeRange(s)};let F=class extends a.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ee,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,o)=>{const{unitId:i,subUnitId:s,range:c}=r,m={row:c.rows[0],column:c.cols[0]};if(o.copyType===T.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:u,subUnitId:h}=this._copyInfo,p={row:d.startRow,column:d.startColumn};if(!(i===u&&s===h)){const S=[];a.Range.foreach(d,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(u,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(f=>{S.push(f)}):M.forEach(({children:f,...E})=>{E.parentId||S.push(E)})});const g=[],b=[],j=[],A=[],K=y=>{g.unshift({id:_.DeleteCommentMutation.id,params:{unitId:u,subUnitId:h,commentId:y.id}}),j.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:fe(y.ref,p,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:u,subUnitId:h,comment:y,sync:!0}}),A.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return S.forEach(y=>{K(y)}),{redos:[...g,...j],undos:[...A,...b]}}}return{redos:[],undos:[]}}}))}};F=ge([J(0,a.Inject(T.ISheetClipboardService)),J(1,a.Inject(N.SheetsThreadCommentModel)),J(2,_.IThreadCommentDataSourceService)],F);var Ie=Object.getOwnPropertyDescriptor,Pe=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ie(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},B=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends a.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:o,row:i,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(e,o,i,s);if(c){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,o,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:o,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Pe([B(0,a.Inject(T.HoverManagerService)),B(1,a.Inject(exports.SheetsThreadCommentPopupService)),B(2,a.Inject(N.SheetsThreadCommentModel)),B(3,a.Inject(C.SheetPermissionCheckController))],Z);var Te=Object.getOwnPropertyDescriptor,be=(n,t,r,e)=>{for(var o=e>1?void 0:e?Te(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},R=(n,t)=>(r,e)=>t(r,e,n);let q=class extends a.Disposable{constructor(t,r,e,o,i,s,c,m,d,u){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=u,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var p,S,g;const o=(p=t[0])==null?void 0:p.range,i=this._renderManagerService.getRenderById(r),s=(S=i==null?void 0:i.with(T.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:S.skeleton;if(!s||!o)return;const c=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((g=o.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=c.actualRow,u=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,d,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,d,u);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.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 r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:o,subUnitId:i,commentId:s}=e;r.unitId===o&&r.subUnitId===i&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:o,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,o,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=m.getActiveSheet())==null?void 0:r.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:o}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(c.ref),{row:p,column:S}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const b=1;if(await this._commandService.executeCommand(T.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:o,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:o}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(r,e,o);if(!i)return;const s=$.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(p=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),u=(S=d==null?void 0:d.getMergedCell(c,m))!=null?S:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:u,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};q=be([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(P.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(C.SheetPermissionCheckController)),R(6,T.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,T.IEditorBridgeService),R(9,re.IRenderManagerService)],q);var ye=Object.getOwnPropertyDescriptor,Me=(n,t,r,e)=>{for(var o=e>1?void 0:e?ye(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},L=(n,t)=>(r,e)=>t(r,e,n);let G=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===C.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const o=e.getUnitId(),i=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(o,i),c=Array.from(s.values()).filter(p=>!p.parentId),m=c.map(p=>p.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=m.map(p=>({id:_.DeleteCommentMutation.id,params:{unitId:o,subUnitId:i,commentId:p}})),h=c.map(({children:p,...S})=>({id:_.AddCommentMutation.id,params:{unitId:o,subUnitId:i,comment:{...S,children:d?p:void 0},sync:!d}}));return{redos:u,undos:h}}return{redos:[],undos:[]}}}))}};G=Me([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],G);var w=function(){return w=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},w.apply(this,arguments)},we=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,e=Object.getOwnPropertySymbols(n);o<e.length;o++)t.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(n,e[o])&&(r[e[o]]=n[e[o]]);return r},se=O.forwardRef(function(n,t){var r=n.icon,e=n.id,o=n.className,i=n.extend,s=we(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(o||"").trim(),m=O.useRef("_".concat(Re()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ae(n,t,r,e,o){return O.createElement(n.tag,w(w({key:t},Ue(n,r,o)),e),(Ee(n,r).children||[]).map(function(i,s){return ae(i,"".concat(t,"-").concat(n.tag,"-").concat(s),r,void 0,o)}))}function Ue(n,t,r){var e=w({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];s==="mask"&&typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(n.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 Ee(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?w(w({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&e&&e.includes(o.attrs.id)?w(w({},o),{attrs:w(w({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):n}function Re(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.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.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.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"}},{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"}}]},ce=O.forwardRef(function(n,t){return O.createElement(se,Object.assign({},n,{id:"comment-icon",ref:t,icon:Oe}))});ce.displayName="CommentIcon";const ke=()=>{const n=l.useDependency(a.IUniverInstanceService),t=l.useDependency(exports.SheetsThreadCommentPopupService),r=l.useObservable(t.activePopup$),e=l.useDependency(N.SheetsThreadCommentModel);if(l.useObservable(e.commentUpdate$),!r)return null;const{row:o,col:i,unitId:s,subUnitId:c,trigger:m}=r,d=e.getByLocation(s,c,o,i),u=`${a.Tools.chatAtABC(i)}${o+1}`,h=()=>{t.hidePopup()},p=S=>{var g,b,j;return(j=(b=(g=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:b.getName())!=null?j:""};return oe.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:u,onClose:h,getSubUnitName:p,autoFocus:m==="context-menu"})},De=()=>{var y;const n=l.useDependency(T.IMarkSelectionService),t=l.useDependency(a.IUniverInstanceService),r=l.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=e.getUnitId(),i=l.useDependency(a.ICommandService),s=O.useMemo(()=>e.activeSheet$.pipe(V.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=l.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(null),d=l.useDependency(P.ThreadCommentPanelService),u=l.useObservable(d.activeCommentId$),h=l.useObservable(d.panelVisible$,d.panelVisible),p=O.useCallback(v=>{const M=e.getSheets(),f={};M.forEach((U,I)=>{f[U.getSheetId()]=I});const E=U=>U.map(I=>{var te;const k=$.singleReferenceToGrid(I.ref),de=[(te=f[I.subUnitId])!=null?te:0,k.row,k.column];return{...I,p:de}}).sort((I,k)=>I.p[0]===k.p[0]?I.p[1]===k.p[1]?I.p[2]-k.p[2]:I.p[1]-k.p[1]:I.p[0]-k.p[0]);return[...E(v.filter(U=>!U.resolved)),...E(v.filter(U=>U.resolved))]},[e]),S=O.useCallback(v=>{var M;if(v.unitId===o&&v.subUnitId===c&&!v.resolved){const{row:f,column:E}=$.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),I=(M=U==null?void 0:U.getMergedCell(f,E))!=null?M:{startColumn:E,endColumn:E,startRow:f,endRow:f};if(!Number.isNaN(f)&&!Number.isNaN(E))return n.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,o]),g=v=>{var M,f;return(f=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?f:""},b=()=>{i.executeCommand(x.id)},j=v=>{u&&u.unitId===v.unitId&&u.subUnitId===v.subUnitId&&u.commentId===v.id||(m.current&&(n.removeShape(m.current),m.current=null),m.current=S(v))},A=()=>{m.current&&(n.removeShape(m.current),m.current=null)},K=(v,M)=>{M&&r.hidePopup()};return O.useEffect(()=>{!h&&m.current&&n.removeShape(m.current)},[n,h]),oe.jsx(P.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:g,onResolve:K,sortComments:p,onItemEnter:j,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},je=n=>({id:x.id,type:l.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ne=n=>({id:P.ToggleSheetCommentPanelOperation.id,type:l.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}),$e={id:x.id,binding:l.KeyCode.M|l.MetaKeys.CTRL_COMMAND|l.MetaKeys.ALT,preconditions:T.whenSheetEditorFocused},xe={[l.RibbonInsertGroup.MEDIA]:{[P.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:Ne}},[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:je}}}};var Ae=Object.getOwnPropertyDescriptor,Ve=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ae(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Q=(n,t)=>(r,e)=>t(r,e,n);let z=class extends a.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut($e)}_initMenu(){this._menuManagerService.mergeMenu(xe)}_initComponent(){[[ie,ke],[P.THREAD_COMMENT_PANEL,De],["CommentIcon",ce]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};z=Ve([Q(0,l.IMenuManagerService),Q(1,a.Inject(l.ComponentManager)),Q(2,l.IShortcutService)],z);var He=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Le=(n,t,r)=>t in n?He(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,We=(n,t,r,e)=>{for(var o=e>1?void 0:e?Be(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},X=(n,t)=>(r,e)=>t(r,e,n),me=(n,t,r)=>Le(n,typeof t!="symbol"?t+"":t,r);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=ne,r,e,o){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=o;const{menu:i,...s}=a.merge({},ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ve,s)}onStarting(){[[z],[W],[F],[Z],[G],[q],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[x].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(z)}onReady(){this._injector.get(W),this._injector.get(G)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(q)}};me(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ee);me(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=We([a.DependentOn(P.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.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=ee;exports.ShowAddSheetCommentModalOperation=x;
|
|
1
|
+
"use strict";var he=Object.defineProperty;var ue=(n,t,r)=>t in n?he(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var D=(n,t,r)=>ue(n,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),T=require("@univerjs/sheets-ui"),l=require("@univerjs/ui"),V=require("rxjs"),re=require("@univerjs/engine-render"),$=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),oe=require("react/jsx-runtime"),O=require("react"),ie="univer.sheet.thread-comment-modal",ee="SHEET_THREAD_COMMENT";var le=Object.getOwnPropertyDescriptor,pe=(n,t,r,e)=>{for(var o=e>1?void 0:e?le(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Y=(n,t)=>(r,e)=>t(r,e,n);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e,o){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new V.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(r,e){var u;const{row:o,col:i,unitId:s,subUnitId:c}=r;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((u=this.activePopup)==null?void 0:u.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const m=this._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:c},{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.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=pe([Y(0,a.Inject(T.SheetCanvasPopManagerService)),Y(1,l.IZenZoneService),Y(2,a.Inject(T.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const x={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var g;const t=n.get(C.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),e=n.get(exports.SheetsThreadCommentPopupService),o=n.get(P.ThreadCommentPanelService),i=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=n.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(r);if(!c)return!1;const{workbook:m,worksheet:d,unitId:u,subUnitId:h}=c,p={workbook:m,worksheet:d,unitId:u,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(p);const S=s.getByLocation(u,h,i.startRow,i.startColumn);return S&&o.setActiveComment({unitId:u,subUnitId:h,commentId:S,trigger:"context-menu"}),!0}},ve="sheets-thread-comment.config",ne={};var Ce=Object.getOwnPropertyDescriptor,Se=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ce(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},H=(n,t)=>(r,e)=>t(r,e,n);let W=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:o,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,o)&&((!n||n===t.rawData)&&(n={...t.rawData}),n.markers={...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}),r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var o;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{n()}))}};W=Se([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject(N.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,re.IRenderManagerService)],W);var _e=Object.getOwnPropertyDescriptor,ge=(n,t,r,e)=>{for(var o=e>1?void 0:e?_e(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},J=(n,t)=>(r,e)=>t(r,e,n);const fe=(n,t,r)=>{const e=$.singleReferenceToGrid(n),o=r.row-t.row,i=r.column-t.column,s={startColumn:e.column+i,startRow:e.row+o,endColumn:e.column+i,endRow:e.row+o};return $.serializeRange(s)};let F=class extends a.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ee,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,o)=>{const{unitId:i,subUnitId:s,range:c}=r,m={row:c.rows[0],column:c.cols[0]};if(o.copyType===T.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:u,subUnitId:h}=this._copyInfo,p={row:d.startRow,column:d.startColumn};if(!(i===u&&s===h)){const S=[];a.Range.foreach(d,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(u,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(f=>{S.push(f)}):M.forEach(({children:f,...E})=>{E.parentId||S.push(E)})});const g=[],b=[],j=[],A=[],K=y=>{g.unshift({id:_.DeleteCommentMutation.id,params:{unitId:u,subUnitId:h,commentId:y.id}}),j.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:fe(y.ref,p,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:u,subUnitId:h,comment:y,sync:!0}}),A.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return S.forEach(y=>{K(y)}),{redos:[...g,...j],undos:[...A,...b]}}}return{redos:[],undos:[]}}}))}};F=ge([J(0,a.Inject(T.ISheetClipboardService)),J(1,a.Inject(N.SheetsThreadCommentModel)),J(2,_.IThreadCommentDataSourceService)],F);var Ie=Object.getOwnPropertyDescriptor,Pe=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ie(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},B=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends a.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:o,row:i,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(e,o,i,s);if(c){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,o,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:o,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Pe([B(0,a.Inject(T.HoverManagerService)),B(1,a.Inject(exports.SheetsThreadCommentPopupService)),B(2,a.Inject(N.SheetsThreadCommentModel)),B(3,a.Inject(C.SheetPermissionCheckController))],Z);var Te=Object.getOwnPropertyDescriptor,be=(n,t,r,e)=>{for(var o=e>1?void 0:e?Te(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},R=(n,t)=>(r,e)=>t(r,e,n);let q=class extends a.Disposable{constructor(t,r,e,o,i,s,c,m,d,u){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=u,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var p,S,g;const o=(p=t[0])==null?void 0:p.range,i=this._renderManagerService.getRenderById(r),s=(S=i==null?void 0:i.with(T.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:S.skeleton;if(!s||!o)return;const c=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((g=o.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=c.actualRow,u=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,d,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,d,u);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.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 r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:o,subUnitId:i,commentId:s}=e;r.unitId===o&&r.subUnitId===i&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:o,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,o,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=m.getActiveSheet())==null?void 0:r.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:o}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(c.ref),{row:p,column:S}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const b=1;if(await this._commandService.executeCommand(T.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:o,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:o}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(r,e,o);if(!i)return;const s=$.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(p=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),u=(S=d==null?void 0:d.getMergedCell(c,m))!=null?S:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:u,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};q=be([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(P.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(C.SheetPermissionCheckController)),R(6,T.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,T.IEditorBridgeService),R(9,re.IRenderManagerService)],q);var ye=Object.getOwnPropertyDescriptor,Me=(n,t,r,e)=>{for(var o=e>1?void 0:e?ye(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},L=(n,t)=>(r,e)=>t(r,e,n);let G=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===C.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const o=e.getUnitId(),i=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(o,i),c=Array.from(s.values()).filter(p=>!p.parentId),m=c.map(p=>p.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=m.map(p=>({id:_.DeleteCommentMutation.id,params:{unitId:o,subUnitId:i,commentId:p}})),h=c.map(({children:p,...S})=>({id:_.AddCommentMutation.id,params:{unitId:o,subUnitId:i,comment:{...S,children:d?p:void 0},sync:!d}}));return{redos:u,undos:h}}return{redos:[],undos:[]}}}))}};G=Me([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],G);var w=function(){return w=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},w.apply(this,arguments)},we=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,e=Object.getOwnPropertySymbols(n);o<e.length;o++)t.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(n,e[o])&&(r[e[o]]=n[e[o]]);return r},se=O.forwardRef(function(n,t){var r=n.icon,e=n.id,o=n.className,i=n.extend,s=we(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(o||"").trim(),m=O.useRef("_".concat(Re()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ae(n,t,r,e,o){return O.createElement(n.tag,w(w({key:t},Ue(n,r,o)),e),(Ee(n,r).children||[]).map(function(i,s){return ae(i,"".concat(t,"-").concat(n.tag,"-").concat(s),r,void 0,o)}))}function Ue(n,t,r){var e=w({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];s==="mask"&&typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(n.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 Ee(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?w(w({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&e&&e.includes(o.attrs.id)?w(w({},o),{attrs:w(w({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):n}function Re(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.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.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.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"}},{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"}}]},ce=O.forwardRef(function(n,t){return O.createElement(se,Object.assign({},n,{id:"comment-icon",ref:t,icon:Oe}))});ce.displayName="CommentIcon";const ke=()=>{const n=l.useDependency(a.IUniverInstanceService),t=l.useDependency(exports.SheetsThreadCommentPopupService),r=l.useObservable(t.activePopup$),e=l.useDependency(N.SheetsThreadCommentModel);if(l.useObservable(e.commentUpdate$),!r)return null;const{row:o,col:i,unitId:s,subUnitId:c,trigger:m}=r,d=e.getByLocation(s,c,o,i),u=`${a.Tools.chatAtABC(i)}${o+1}`,h=()=>{t.hidePopup()},p=S=>{var g,b,j;return(j=(b=(g=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:b.getName())!=null?j:""};return oe.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:u,onClose:h,getSubUnitName:p,autoFocus:m==="context-menu"})},De=()=>{var y;const n=l.useDependency(T.IMarkSelectionService),t=l.useDependency(a.IUniverInstanceService),r=l.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=e.getUnitId(),i=l.useDependency(a.ICommandService),s=O.useMemo(()=>e.activeSheet$.pipe(V.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=l.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(null),d=l.useDependency(P.ThreadCommentPanelService),u=l.useObservable(d.activeCommentId$),h=l.useObservable(d.panelVisible$,d.panelVisible),p=O.useCallback(v=>{const M=e.getSheets(),f={};M.forEach((U,I)=>{f[U.getSheetId()]=I});const E=U=>U.map(I=>{var te;const k=$.singleReferenceToGrid(I.ref),de=[(te=f[I.subUnitId])!=null?te:0,k.row,k.column];return{...I,p:de}}).sort((I,k)=>I.p[0]===k.p[0]?I.p[1]===k.p[1]?I.p[2]-k.p[2]:I.p[1]-k.p[1]:I.p[0]-k.p[0]);return[...E(v.filter(U=>!U.resolved)),...E(v.filter(U=>U.resolved))]},[e]),S=O.useCallback(v=>{var M;if(v.unitId===o&&v.subUnitId===c&&!v.resolved){const{row:f,column:E}=$.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),I=(M=U==null?void 0:U.getMergedCell(f,E))!=null?M:{startColumn:E,endColumn:E,startRow:f,endRow:f};if(!Number.isNaN(f)&&!Number.isNaN(E))return n.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,o]),g=v=>{var M,f;return(f=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?f:""},b=()=>{i.executeCommand(x.id)},j=v=>{u&&u.unitId===v.unitId&&u.subUnitId===v.subUnitId&&u.commentId===v.id||(m.current&&(n.removeShape(m.current),m.current=null),m.current=S(v))},A=()=>{m.current&&(n.removeShape(m.current),m.current=null)},K=(v,M)=>{M&&r.hidePopup()};return O.useEffect(()=>{!h&&m.current&&n.removeShape(m.current)},[n,h]),oe.jsx(P.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:g,onResolve:K,sortComments:p,onItemEnter:j,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},je=n=>({id:x.id,type:l.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ne=n=>({id:P.ToggleSheetCommentPanelOperation.id,type:l.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}),$e={id:x.id,binding:l.KeyCode.M|l.MetaKeys.CTRL_COMMAND|l.MetaKeys.ALT,preconditions:T.whenSheetEditorFocused},xe={[l.RibbonInsertGroup.MEDIA]:{[P.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:Ne}},[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:je}}}};var Ae=Object.getOwnPropertyDescriptor,Ve=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ae(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Q=(n,t)=>(r,e)=>t(r,e,n);let z=class extends a.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut($e)}_initMenu(){this._menuManagerService.mergeMenu(xe)}_initComponent(){[[ie,ke],[P.THREAD_COMMENT_PANEL,De],["CommentIcon",ce]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};z=Ve([Q(0,l.IMenuManagerService),Q(1,a.Inject(l.ComponentManager)),Q(2,l.IShortcutService)],z);var He=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Le=(n,t,r)=>t in n?He(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,We=(n,t,r,e)=>{for(var o=e>1?void 0:e?Be(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},X=(n,t)=>(r,e)=>t(r,e,n),me=(n,t,r)=>Le(n,typeof t!="symbol"?t+"":t,r);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=ne,r,e,o){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=o;const{menu:i,...s}=a.merge({},ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ve,s)}onStarting(){[[z],[W],[F],[Z],[G],[q],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[x].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(z)}onReady(){this._injector.get(W),this._injector.get(G)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(q)}};me(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ee);me(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=We([a.DependentOn(P.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.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=ee;exports.ShowAddSheetCommentModalOperation=x;
|
package/lib/es/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export declare class SheetsThreadCommentPopupService extends Disposable {
|
|
|
18
18
|
get activePopup(): Nullable<IThreadCommentPopup>;
|
|
19
19
|
constructor(_canvasPopupManagerService: SheetCanvasPopManagerService, _zenZoneService: IZenZoneService, _cellPopupManagerService: CellPopupManagerService);
|
|
20
20
|
private _initZenVisible;
|
|
21
|
+
dispose(): void;
|
|
21
22
|
showPopup(location: IThreadCommentPopup, onHide?: () => void): void;
|
|
22
23
|
hidePopup(): void;
|
|
23
24
|
persistPopup(): void;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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/jsx-runtime"),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/jsx-runtime","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,d.React))})(this,(function(d,s,p,N,g,P,v,H,ne,A,f,re,R){"use strict";var xe=Object.defineProperty;var Fe=(d,s,p)=>s in d?xe(d,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[s]=p;var D=(d,s,p)=>Fe(d,typeof s!="symbol"?s+"":s,p);const ie="univer.sheet.thread-comment-modal",Y="SHEET_THREAD_COMMENT";var me=Object.getOwnPropertyDescriptor,he=(n,t,r,e)=>{for(var i=e>1?void 0:e?me(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},J=(n,t)=>(r,e)=>t(r,e,n);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(r,e,i){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:i,col:o,unitId:a,subUnitId:c}=r;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:a,subUnitId:c},{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}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=he([J(0,s.Inject(P.SheetCanvasPopManagerService)),J(1,v.IZenZoneService),J(2,s.Inject(P.CellPopupManagerService))],d.SheetsThreadCommentPopupService);const V={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var I;const t=n.get(p.SheetsSelectionsService),r=n.get(s.IUniverInstanceService),e=n.get(d.SheetsThreadCommentPopupService),i=n.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=n.get(N.SheetsThreadCommentModel);if(!o)return!1;const c=p.getSheetCommandTarget(r);if(!c)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=c,S={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(S);const _=a.getByLocation(l,h,o.startRow,o.startColumn);return _&&i.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},le="sheets-thread-comment.config",oe={};var pe=Object.getOwnPropertyDescriptor,ve=(n,t,r,e)=>{for(var i=e>1?void 0:e?pe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},L=(n,t)=>(r,e)=>t(r,e,n);let W=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:i,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,i)&&((!n||n===t.rawData)&&(n={...t.rawData}),n.markers={...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}),r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{n()}))}};W=ve([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject(N.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ne.IRenderManagerService)],W);var Se=Object.getOwnPropertyDescriptor,Ce=(n,t,r,e)=>{for(var i=e>1?void 0:e?Se(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Q=(n,t)=>(r,e)=>t(r,e,n);const _e=(n,t,r)=>{const e=A.singleReferenceToGrid(n),i=r.row-t.row,o=r.column-t.column,a={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return A.serializeRange(a)};let x=class extends s.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Y,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,i)=>{const{unitId:o,subUnitId:a,range:c}=r,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,S={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const _=[];s.Range.foreach(m,(w,C)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,C);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(T=>{_.push(T)}):E.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const I=[],M=[],$=[],B=[],te=w=>{I.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),$.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:_e(w.ref,S,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:f.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),B.unshift({id:f.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return _.forEach(w=>{te(w)}),{redos:[...I,...$],undos:[...B,...M]}}}return{redos:[],undos:[]}}}))}};x=Ce([Q(0,s.Inject(P.ISheetClipboardService)),Q(1,s.Inject(N.SheetsThreadCommentModel)),Q(2,f.IThreadCommentDataSourceService)],x);var fe=Object.getOwnPropertyDescriptor,Ie=(n,t,r,e)=>{for(var i=e>1?void 0:e?fe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},F=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends s.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:i,row:o,col:a}=r,c=this._sheetsThreadCommentModel.getByLocation(e,i,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const m=this._sheetsThreadCommentModel.getComment(e,i,c);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Ie([F(0,s.Inject(P.HoverManagerService)),F(1,s.Inject(d.SheetsThreadCommentPopupService)),F(2,s.Inject(N.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],Z);var ge=Object.getOwnPropertyDescriptor,Pe=(n,t,r,e)=>{for(var i=e>1?void 0:e?ge(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},O=(n,t)=>(r,e)=>t(r,e,n);let q=class extends s.Disposable{constructor(t,r,e,i,o,a,c,u,m,l){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var S,_,I;const i=(S=t[0])==null?void 0:S.range,o=this._renderManagerService.getRenderById(r),a=(_=o==null?void 0:o.with(P.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:_.skeleton;if(!a||!i)return;const c=a.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((I=i.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const m=c.actualRow,l=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:a}=e;r.unitId===i&&r.subUnitId===o&&r.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:i,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,i,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==i&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const h=A.singleReferenceToGrid(c.ref),{row:S,column:_}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:_,endRow:S,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:h.row,col:h.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var S,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,i);if(!o)return;const a=A.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const m=(S=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(c,u))!=null?_:{startColumn:u,endColumn:u,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};q=Pe([O(0,s.ICommandService),O(1,s.Inject(d.SheetsThreadCommentPopupService)),O(2,s.Inject(N.SheetsThreadCommentModel)),O(3,s.Inject(g.ThreadCommentPanelService)),O(4,s.IUniverInstanceService),O(5,s.Inject(p.SheetPermissionCheckController)),O(6,P.IMarkSelectionService),O(7,s.Inject(p.SheetsSelectionsService)),O(8,P.IEditorBridgeService),O(9,ne.IRenderManagerService)],q);var Te=Object.getOwnPropertyDescriptor,be=(n,t,r,e)=>{for(var i=e>1?void 0:e?Te(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},G=(n,t)=>(r,e)=>t(r,e,n);let z=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===p.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const i=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(i,o),c=Array.from(a.values()).filter(S=>!S.parentId),u=c.map(S=>S.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(S=>({id:f.DeleteCommentMutation.id,params:{unitId:i,subUnitId:o,commentId:S}})),h=c.map(({children:S,..._})=>({id:f.AddCommentMutation.id,params:{unitId:i,subUnitId:o,comment:{..._,children:m?S:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=be([G(0,s.Inject(p.SheetInterceptorService)),G(1,s.IUniverInstanceService),G(2,s.Inject(f.ThreadCommentModel)),G(3,f.IThreadCommentDataSourceService)],z);var y=function(){return y=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},y.apply(this,arguments)},ye=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,e=Object.getOwnPropertySymbols(n);i<e.length;i++)t.indexOf(e[i])<0&&Object.prototype.propertyIsEnumerable.call(n,e[i])&&(r[e[i]]=n[e[i]]);return r},se=R.forwardRef(function(n,t){var r=n.icon,e=n.id,i=n.className,o=n.extend,a=ye(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(i||"").trim(),u=R.useRef("_".concat(Ee()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ae(n,t,r,e,i){return R.createElement(n.tag,y(y({key:t},Me(n,r,i)),e),(we(n,r).children||[]).map(function(o,a){return ae(o,"".concat(t,"-").concat(n.tag,"-").concat(a),r,void 0,i)}))}function Me(n,t,r){var e=y({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(n.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 we(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?y(y({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&e&&e.includes(i.attrs.id)?y(y({},i),{attrs:y(y({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):n}function Ee(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Ue={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.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.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.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"}},{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"}}]},ce=R.forwardRef(function(n,t){return R.createElement(se,Object.assign({},n,{id:"comment-icon",ref:t,icon:Ue}))});ce.displayName="CommentIcon";const Re=()=>{const n=v.useDependency(s.IUniverInstanceService),t=v.useDependency(d.SheetsThreadCommentPopupService),r=v.useObservable(t.activePopup$),e=v.useDependency(N.SheetsThreadCommentModel);if(v.useObservable(e.commentUpdate$),!r)return null;const{row:i,col:o,unitId:a,subUnitId:c,trigger:u}=r,m=e.getByLocation(a,c,i,o),l=`${s.Tools.chatAtABC(o)}${i+1}`,h=()=>{t.hidePopup()},S=_=>{var I,M,$;return($=(M=(I=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(_))==null?void 0:M.getName())!=null?$:""};return re.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:S,autoFocus:u==="context-menu"})},Oe=()=>{var w;const n=v.useDependency(P.IMarkSelectionService),t=v.useDependency(s.IUniverInstanceService),r=v.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=v.useDependency(s.ICommandService),a=R.useMemo(()=>e.activeSheet$.pipe(H.map(C=>C==null?void 0:C.getSheetId())),[e.activeSheet$]),c=v.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=R.useRef(null),m=v.useDependency(g.ThreadCommentPanelService),l=v.useObservable(m.activeCommentId$),h=v.useObservable(m.panelVisible$,m.panelVisible),S=R.useCallback(C=>{const E=e.getSheets(),T={};E.forEach((U,b)=>{T[U.getSheetId()]=b});const j=U=>U.map(b=>{var ue;const k=A.singleReferenceToGrid(b.ref),We=[(ue=T[b.subUnitId])!=null?ue:0,k.row,k.column];return{...b,p:We}}).sort((b,k)=>b.p[0]===k.p[0]?b.p[1]===k.p[1]?b.p[2]-k.p[2]:b.p[1]-k.p[1]:b.p[0]-k.p[0]);return[...j(C.filter(U=>!U.resolved)),...j(C.filter(U=>U.resolved))]},[e]),_=R.useCallback(C=>{var E;if(C.unitId===i&&C.subUnitId===c&&!C.resolved){const{row:T,column:j}=A.singleReferenceToGrid(C.ref),U=e.getSheetBySheetId(C.subUnitId),b=(E=U==null?void 0:U.getMergedCell(T,j))!=null?E:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return n.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,i]),I=C=>{var E,T;return(T=(E=e.getSheetBySheetId(C))==null?void 0:E.getName())!=null?T:""},M=()=>{o.executeCommand(V.id)},$=C=>{l&&l.unitId===C.unitId&&l.subUnitId===C.subUnitId&&l.commentId===C.id||(u.current&&(n.removeShape(u.current),u.current=null),u.current=_(C))},B=()=>{u.current&&(n.removeShape(u.current),u.current=null)},te=(C,E)=>{E&&r.hidePopup()};return R.useEffect(()=>{!h&&u.current&&n.removeShape(u.current)},[n,h]),re.jsx(g.ThreadCommentPanel,{unitId:i,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:I,onResolve:te,sortComments:S,onItemEnter:$,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},je=n=>({id:V.id,type:v.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),ke=n=>({id:g.ToggleSheetCommentPanelOperation.id,type:v.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET)}),De={id:V.id,binding:v.KeyCode.M|v.MetaKeys.CTRL_COMMAND|v.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},Ne={[v.RibbonInsertGroup.MEDIA]:{[g.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:ke}},[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{[V.id]:{order:0,menuItemFactory:je}}}};var $e=Object.getOwnPropertyDescriptor,Ae=(n,t,r,e)=>{for(var i=e>1?void 0:e?$e(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},X=(n,t)=>(r,e)=>t(r,e,n);let K=class extends s.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(De)}_initMenu(){this._menuManagerService.mergeMenu(Ne)}_initComponent(){[[ie,Re],[g.THREAD_COMMENT_PANEL,Oe],["CommentIcon",ce]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};K=Ae([X(0,v.IMenuManagerService),X(1,s.Inject(v.ComponentManager)),X(2,v.IShortcutService)],K);var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Be=(n,t,r)=>t in n?Ve(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Le=(n,t,r,e)=>{for(var i=e>1?void 0:e?He(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},ee=(n,t)=>(r,e)=>t(r,e,n),de=(n,t,r)=>Be(n,typeof t!="symbol"?t+"":t,r);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=oe,r,e,i){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=i;const{menu:o,...a}=s.merge({},oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(le,a)}onStarting(){[[K],[W],[x],[Z],[z],[q],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(K)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(x),this._injector.get(Z),this._injector.get(q)}},de(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Y),de(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=Le([s.DependentOn(g.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),ee(1,s.Inject(s.Injector)),ee(2,s.Inject(s.ICommandService)),ee(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Y,d.ShowAddSheetCommentModalOperation=V,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
|
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/jsx-runtime"),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/jsx-runtime","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,d.React))})(this,(function(d,s,p,N,g,P,v,H,ne,A,f,re,R){"use strict";var xe=Object.defineProperty;var Fe=(d,s,p)=>s in d?xe(d,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[s]=p;var D=(d,s,p)=>Fe(d,typeof s!="symbol"?s+"":s,p);const ie="univer.sheet.thread-comment-modal",Y="SHEET_THREAD_COMMENT";var me=Object.getOwnPropertyDescriptor,he=(n,t,r,e)=>{for(var i=e>1?void 0:e?me(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},J=(n,t)=>(r,e)=>t(r,e,n);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(r,e,i){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(r,e){var l;const{row:i,col:o,unitId:a,subUnitId:c}=r;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:a,subUnitId:c},{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}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=he([J(0,s.Inject(P.SheetCanvasPopManagerService)),J(1,v.IZenZoneService),J(2,s.Inject(P.CellPopupManagerService))],d.SheetsThreadCommentPopupService);const V={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var I;const t=n.get(p.SheetsSelectionsService),r=n.get(s.IUniverInstanceService),e=n.get(d.SheetsThreadCommentPopupService),i=n.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=n.get(N.SheetsThreadCommentModel);if(!o)return!1;const c=p.getSheetCommandTarget(r);if(!c)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=c,S={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(S);const _=a.getByLocation(l,h,o.startRow,o.startColumn);return _&&i.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},le="sheets-thread-comment.config",oe={};var pe=Object.getOwnPropertyDescriptor,ve=(n,t,r,e)=>{for(var i=e>1?void 0:e?pe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},L=(n,t)=>(r,e)=>t(r,e,n);let W=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:i,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,i)&&((!n||n===t.rawData)&&(n={...t.rawData}),n.markers={...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}),r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{n()}))}};W=ve([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject(N.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ne.IRenderManagerService)],W);var Se=Object.getOwnPropertyDescriptor,Ce=(n,t,r,e)=>{for(var i=e>1?void 0:e?Se(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Q=(n,t)=>(r,e)=>t(r,e,n);const _e=(n,t,r)=>{const e=A.singleReferenceToGrid(n),i=r.row-t.row,o=r.column-t.column,a={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return A.serializeRange(a)};let x=class extends s.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Y,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,i)=>{const{unitId:o,subUnitId:a,range:c}=r,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,S={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const _=[];s.Range.foreach(m,(w,C)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,C);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(T=>{_.push(T)}):E.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const I=[],M=[],$=[],B=[],te=w=>{I.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),$.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:_e(w.ref,S,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:f.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),B.unshift({id:f.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return _.forEach(w=>{te(w)}),{redos:[...I,...$],undos:[...B,...M]}}}return{redos:[],undos:[]}}}))}};x=Ce([Q(0,s.Inject(P.ISheetClipboardService)),Q(1,s.Inject(N.SheetsThreadCommentModel)),Q(2,f.IThreadCommentDataSourceService)],x);var fe=Object.getOwnPropertyDescriptor,Ie=(n,t,r,e)=>{for(var i=e>1?void 0:e?fe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},F=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends s.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:i,row:o,col:a}=r,c=this._sheetsThreadCommentModel.getByLocation(e,i,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const m=this._sheetsThreadCommentModel.getComment(e,i,c);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Ie([F(0,s.Inject(P.HoverManagerService)),F(1,s.Inject(d.SheetsThreadCommentPopupService)),F(2,s.Inject(N.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],Z);var ge=Object.getOwnPropertyDescriptor,Pe=(n,t,r,e)=>{for(var i=e>1?void 0:e?ge(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},O=(n,t)=>(r,e)=>t(r,e,n);let q=class extends s.Disposable{constructor(t,r,e,i,o,a,c,u,m,l){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var S,_,I;const i=(S=t[0])==null?void 0:S.range,o=this._renderManagerService.getRenderById(r),a=(_=o==null?void 0:o.with(P.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:_.skeleton;if(!a||!i)return;const c=a.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((I=i.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const m=c.actualRow,l=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:a}=e;r.unitId===i&&r.subUnitId===o&&r.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:i,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,i,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==i&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const h=A.singleReferenceToGrid(c.ref),{row:S,column:_}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:_,endRow:S,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:h.row,col:h.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var S,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,i);if(!o)return;const a=A.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const m=(S=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(c,u))!=null?_:{startColumn:u,endColumn:u,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};q=Pe([O(0,s.ICommandService),O(1,s.Inject(d.SheetsThreadCommentPopupService)),O(2,s.Inject(N.SheetsThreadCommentModel)),O(3,s.Inject(g.ThreadCommentPanelService)),O(4,s.IUniverInstanceService),O(5,s.Inject(p.SheetPermissionCheckController)),O(6,P.IMarkSelectionService),O(7,s.Inject(p.SheetsSelectionsService)),O(8,P.IEditorBridgeService),O(9,ne.IRenderManagerService)],q);var Te=Object.getOwnPropertyDescriptor,be=(n,t,r,e)=>{for(var i=e>1?void 0:e?Te(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},G=(n,t)=>(r,e)=>t(r,e,n);let z=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===p.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const i=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(i,o),c=Array.from(a.values()).filter(S=>!S.parentId),u=c.map(S=>S.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(S=>({id:f.DeleteCommentMutation.id,params:{unitId:i,subUnitId:o,commentId:S}})),h=c.map(({children:S,..._})=>({id:f.AddCommentMutation.id,params:{unitId:i,subUnitId:o,comment:{..._,children:m?S:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=be([G(0,s.Inject(p.SheetInterceptorService)),G(1,s.IUniverInstanceService),G(2,s.Inject(f.ThreadCommentModel)),G(3,f.IThreadCommentDataSourceService)],z);var y=function(){return y=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},y.apply(this,arguments)},ye=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,e=Object.getOwnPropertySymbols(n);i<e.length;i++)t.indexOf(e[i])<0&&Object.prototype.propertyIsEnumerable.call(n,e[i])&&(r[e[i]]=n[e[i]]);return r},se=R.forwardRef(function(n,t){var r=n.icon,e=n.id,i=n.className,o=n.extend,a=ye(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(i||"").trim(),u=R.useRef("_".concat(Ee()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ae(n,t,r,e,i){return R.createElement(n.tag,y(y({key:t},Me(n,r,i)),e),(we(n,r).children||[]).map(function(o,a){return ae(o,"".concat(t,"-").concat(n.tag,"-").concat(a),r,void 0,i)}))}function Me(n,t,r){var e=y({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(n.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 we(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?y(y({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&e&&e.includes(i.attrs.id)?y(y({},i),{attrs:y(y({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):n}function Ee(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Ue={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.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.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.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"}},{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"}}]},ce=R.forwardRef(function(n,t){return R.createElement(se,Object.assign({},n,{id:"comment-icon",ref:t,icon:Ue}))});ce.displayName="CommentIcon";const Re=()=>{const n=v.useDependency(s.IUniverInstanceService),t=v.useDependency(d.SheetsThreadCommentPopupService),r=v.useObservable(t.activePopup$),e=v.useDependency(N.SheetsThreadCommentModel);if(v.useObservable(e.commentUpdate$),!r)return null;const{row:i,col:o,unitId:a,subUnitId:c,trigger:u}=r,m=e.getByLocation(a,c,i,o),l=`${s.Tools.chatAtABC(o)}${i+1}`,h=()=>{t.hidePopup()},S=_=>{var I,M,$;return($=(M=(I=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(_))==null?void 0:M.getName())!=null?$:""};return re.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:S,autoFocus:u==="context-menu"})},Oe=()=>{var w;const n=v.useDependency(P.IMarkSelectionService),t=v.useDependency(s.IUniverInstanceService),r=v.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=v.useDependency(s.ICommandService),a=R.useMemo(()=>e.activeSheet$.pipe(H.map(C=>C==null?void 0:C.getSheetId())),[e.activeSheet$]),c=v.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=R.useRef(null),m=v.useDependency(g.ThreadCommentPanelService),l=v.useObservable(m.activeCommentId$),h=v.useObservable(m.panelVisible$,m.panelVisible),S=R.useCallback(C=>{const E=e.getSheets(),T={};E.forEach((U,b)=>{T[U.getSheetId()]=b});const j=U=>U.map(b=>{var ue;const k=A.singleReferenceToGrid(b.ref),We=[(ue=T[b.subUnitId])!=null?ue:0,k.row,k.column];return{...b,p:We}}).sort((b,k)=>b.p[0]===k.p[0]?b.p[1]===k.p[1]?b.p[2]-k.p[2]:b.p[1]-k.p[1]:b.p[0]-k.p[0]);return[...j(C.filter(U=>!U.resolved)),...j(C.filter(U=>U.resolved))]},[e]),_=R.useCallback(C=>{var E;if(C.unitId===i&&C.subUnitId===c&&!C.resolved){const{row:T,column:j}=A.singleReferenceToGrid(C.ref),U=e.getSheetBySheetId(C.subUnitId),b=(E=U==null?void 0:U.getMergedCell(T,j))!=null?E:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return n.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,i]),I=C=>{var E,T;return(T=(E=e.getSheetBySheetId(C))==null?void 0:E.getName())!=null?T:""},M=()=>{o.executeCommand(V.id)},$=C=>{l&&l.unitId===C.unitId&&l.subUnitId===C.subUnitId&&l.commentId===C.id||(u.current&&(n.removeShape(u.current),u.current=null),u.current=_(C))},B=()=>{u.current&&(n.removeShape(u.current),u.current=null)},te=(C,E)=>{E&&r.hidePopup()};return R.useEffect(()=>{!h&&u.current&&n.removeShape(u.current)},[n,h]),re.jsx(g.ThreadCommentPanel,{unitId:i,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:I,onResolve:te,sortComments:S,onItemEnter:$,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},je=n=>({id:V.id,type:v.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),ke=n=>({id:g.ToggleSheetCommentPanelOperation.id,type:v.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET)}),De={id:V.id,binding:v.KeyCode.M|v.MetaKeys.CTRL_COMMAND|v.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},Ne={[v.RibbonInsertGroup.MEDIA]:{[g.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:ke}},[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{[V.id]:{order:0,menuItemFactory:je}}}};var $e=Object.getOwnPropertyDescriptor,Ae=(n,t,r,e)=>{for(var i=e>1?void 0:e?$e(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},X=(n,t)=>(r,e)=>t(r,e,n);let K=class extends s.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(De)}_initMenu(){this._menuManagerService.mergeMenu(Ne)}_initComponent(){[[ie,Re],[g.THREAD_COMMENT_PANEL,Oe],["CommentIcon",ce]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};K=Ae([X(0,v.IMenuManagerService),X(1,s.Inject(v.ComponentManager)),X(2,v.IShortcutService)],K);var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Be=(n,t,r)=>t in n?Ve(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Le=(n,t,r,e)=>{for(var i=e>1?void 0:e?He(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},ee=(n,t)=>(r,e)=>t(r,e,n),de=(n,t,r)=>Be(n,typeof t!="symbol"?t+"":t,r);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=oe,r,e,i){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=i;const{menu:o,...a}=s.merge({},oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(le,a)}onStarting(){[[K],[W],[x],[Z],[z],[q],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(K)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(x),this._injector.get(Z),this._injector.get(q)}},de(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Y),de(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=Le([s.DependentOn(g.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),ee(1,s.Inject(s.Injector)),ee(2,s.Inject(s.ICommandService)),ee(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Y,d.ShowAddSheetCommentModalOperation=V,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.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,26 +52,26 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.4.
|
|
56
|
-
"@univerjs/core": "0.10.
|
|
57
|
-
"@univerjs/engine-
|
|
58
|
-
"@univerjs/sheets": "0.10.
|
|
59
|
-
"@univerjs/sheets-thread-comment": "0.10.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/thread-comment": "0.10.
|
|
63
|
-
"@univerjs/thread-comment-ui": "0.10.
|
|
64
|
-
"@univerjs/ui": "0.10.
|
|
55
|
+
"@univerjs/icons": "^0.4.9",
|
|
56
|
+
"@univerjs/core": "0.10.11",
|
|
57
|
+
"@univerjs/engine-render": "0.10.11",
|
|
58
|
+
"@univerjs/sheets": "0.10.11",
|
|
59
|
+
"@univerjs/sheets-thread-comment": "0.10.11",
|
|
60
|
+
"@univerjs/sheets-ui": "0.10.11",
|
|
61
|
+
"@univerjs/engine-formula": "0.10.11",
|
|
62
|
+
"@univerjs/thread-comment": "0.10.11",
|
|
63
|
+
"@univerjs/thread-comment-ui": "0.10.11",
|
|
64
|
+
"@univerjs/ui": "0.10.11"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"postcss": "^8.5.6",
|
|
68
68
|
"react": "18.3.1",
|
|
69
69
|
"rxjs": "^7.8.2",
|
|
70
70
|
"tailwindcss": "3.4.17",
|
|
71
|
-
"typescript": "^5.9.
|
|
72
|
-
"vite": "^7.1.
|
|
71
|
+
"typescript": "^5.9.3",
|
|
72
|
+
"vite": "^7.1.10",
|
|
73
73
|
"vitest": "^3.2.4",
|
|
74
|
-
"@univerjs-infra/shared": "0.10.
|
|
74
|
+
"@univerjs-infra/shared": "0.10.11"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"test": "vitest run",
|