@univerjs/sheets-thread-comment-ui 0.5.5-nightly.202501211606 → 0.5.5-nightly.202501221606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -9
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +6 -35
- package/lib/types/views/sheets-thread-comment-cell/index.d.ts +16 -2
- package/lib/types/views/sheets-thread-comment-panel/index.d.ts +16 -2
- package/lib/umd/index.js +1 -9
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";var Se=Object.defineProperty;var _e=(o,t,n)=>t in o?Se(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>_e(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),w=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),H=require("rxjs"),ae=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),me="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var u;const{row:r,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((u=this.activePopup)==null?void 0:u.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:me,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.DisposableCollection;d.add(m),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ge([oe(0,c.Inject(w.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(P.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const a=C.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:d,unitId:u,subUnitId:h}=a,l={workbook:m,worksheet:d,unitId:u,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(u,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:u,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},Pe="sheets-thread-comment.config",ie={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let F=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([L(0,c.Inject(C.SheetInterceptorService)),L(1,c.Inject($.SheetsThreadCommentModel)),L(2,c.IUniverInstanceService),L(3,ae.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends c.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(r.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:u,subUnitId:h}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===u&&s===h)){const p=[];c.Range.foreach(d,(b,v)=>{const y=this._sheetsThreadCommentModel.getAllByLocation(u,h,b,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?y.forEach(I=>{p.push(I)}):y.forEach(({children:I,...O})=>{O.parentId||p.push(O)})});const f=[],T=[],N=[],V=[],J=b=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:u,subUnitId:h,commentId:b.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Re(b.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:_.AddCommentMutation.id,params:{unitId:u,subUnitId:h,comment:b,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return p.forEach(b=>{J(b)}),{redos:[...f,...N],undos:[...V,...T]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,c.Inject(w.ISheetClipboardService)),K(1,c.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},B=(o,t)=>(n,e)=>t(n,e,o);let G=class extends c.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,r,a);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:a,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([B(0,c.Inject(w.HoverManagerService)),B(1,c.Inject(exports.SheetsThreadCommentPopupService)),B(2,c.Inject($.SheetsThreadCommentModel)),B(3,c.Inject(C.SheetPermissionCheckController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends c.Disposable{constructor(t,n,e,r,i,s,a,m,d,u){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=u,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(w.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const a=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=a.actualRow,u=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,d,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,d,u);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,a=this._sheetsThreadCommentModel.getComment(e,r,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(a.ref),{row:l,column:p}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const T=1;if(await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-T,0),endRow:h.row+T,startColumn:Math.max(h.column-T,0),endColumn:h.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),u=(p=d==null?void 0:d.getMergedCell(a,m))!=null?p:{startColumn:m,endColumn:m,startRow:a,endRow:a},h=this._markSelectionService.addShape({range:u,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(P.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(C.SheetPermissionCheckController)),E(6,w.IMarkSelectionService),E(7,c.Inject(C.SheetsSelectionsService)),E(8,w.IEditorBridgeService),E(9,ae.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),a=Array.from(s.values()).filter(l=>!l.parentId),m=a.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=a.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:d?l:void 0},sync:!d}}));return{redos:u,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,c.Inject(C.SheetInterceptorService)),W(1,c.IUniverInstanceService),W(2,c.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var M=function(){return M=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},M.apply(this,arguments)},ke=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},ue=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=ke(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Be()));return de(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},M({ref:t,className:a},s),i)});function de(o,t,n,e,r){return R.createElement(o.tag,M(M({key:t},He(o,n,r)),e),(Le(o,n).children||[]).map(function(i,s){return de(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function He(o,t,n){var e=M({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],a=i[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Le(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?M(M({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?M(M({},r),{attrs:M(M({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Be(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=R.forwardRef(function(o,t){return R.createElement(ue,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});he.displayName="CommentSingle";var Q={exports:{}},k={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var se;function Fe(){if(se)return k;se=1;var o=R,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(a,m,d){var u,h={},l=null,p=null;d!==void 0&&(l=""+d),m.key!==void 0&&(l=""+m.key),m.ref!==void 0&&(p=m.ref);for(u in m)e.call(m,u)&&!i.hasOwnProperty(u)&&(h[u]=m[u]);if(a&&a.defaultProps)for(u in m=a.defaultProps,m)h[u]===void 0&&(h[u]=m[u]);return{$$typeof:t,type:a,key:l,ref:p,props:h,_owner:r.current}}return k.Fragment=n,k.jsx=s,k.jsxs=s,k}var ce;function qe(){return ce||(ce=1,Q.exports=Fe()),Q.exports}var le=qe();const Ge=()=>{const o=c.useDependency(c.IUniverInstanceService),t=c.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=c.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:a,trigger:m}=n,d=e.getByLocation(s,a,r,i),u=`${c.Tools.chatAtABC(i)}${r+1}`,h=()=>{t.hidePopup()},l=p=>{var f,T,N;return(N=(T=(f=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(p))==null?void 0:T.getName())!=null?N:""};return le.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:u,onClose:h,getSubUnitName:l,autoFocus:m==="context-menu"})},Ze=()=>{var b;const o=c.useDependency(w.IMarkSelectionService),t=c.useDependency(c.IUniverInstanceService),n=c.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=c.useDependency(c.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(H.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),a=S.useObservable(s,(b=e.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(),d=c.useDependency(P.ThreadCommentPanelService),u=S.useObservable(d.activeCommentId$),h=S.useObservable(d.panelVisible$,d.panelVisible),l=R.useCallback(v=>{const y=e.getSheets(),I={};y.forEach((U,g)=>{I[U.getSheetId()]=g});const O=U=>U.map(g=>{var re;const j=x.singleReferenceToGrid(g.ref),Ce=[(re=I[g.subUnitId])!=null?re:0,j.row,j.column];return{...g,p:Ce}}).sort((g,j)=>g.p[0]===j.p[0]?g.p[1]===j.p[1]?g.p[2]-j.p[2]:g.p[1]-j.p[1]:g.p[0]-j.p[0]);return[...O(v.filter(U=>!U.resolved)),...O(v.filter(U=>U.resolved))]},[e]),p=R.useCallback(v=>{var y;if(v.unitId===r&&v.subUnitId===a&&!v.resolved){const{row:I,column:O}=x.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),g=(y=U==null?void 0:U.getMergedCell(I,O))!=null?y:{startColumn:O,endColumn:O,startRow:I,endRow:I};if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:g,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,a,r]),f=v=>{var y,I;return(I=(y=e.getSheetBySheetId(v))==null?void 0:y.getName())!=null?I:""},T=()=>{i.executeCommand(A.id)},N=v=>{u&&u.unitId===v.unitId&&u.subUnitId===v.subUnitId&&u.commentId===v.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=p(v))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},J=(v,y)=>{y&&n.hidePopup()};return R.useEffect(()=>{!h&&m.current&&o.removeShape(m.current)},[o,h]),le.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:f,onResolve:J,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},ze=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:te,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ye=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:te,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Je={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused},Ke={[S.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Ye}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ze}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Qe(t,n,r),r},X=(o,t)=>(n,e)=>t(n,e,o);let Y=class extends c.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Je)}_initMenu(){this._menuManagerService.mergeMenu(Ke)}_initComponent(){[[me,Ge],[P.THREAD_COMMENT_PANEL,Ze],[te,he]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};Y=et([X(0,S.IMenuManagerService),X(1,c.Inject(S.ComponentManager)),X(2,S.IShortcutService)],Y);var pe=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,t,n)=>t in o?pe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,rt=(o,t,n,e)=>{for(var r=e>1?void 0:e?tt(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&pe(t,n,r),r},ee=(o,t)=>(n,e)=>t(n,e,o),ve=(o,t,n)=>nt(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=ie,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=c.merge({},ie,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Pe,s)}onStarting(){[[Y],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(Y)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};ve(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ne);ve(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=rt([c.DependentOn(P.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,c.Inject(c.Injector)),ee(2,c.Inject(c.ICommandService)),ee(3,c.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ne;exports.ShowAddSheetCommentModalOperation=A;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),sheets=require("@univerjs/sheets"),sheetsThreadComment=require("@univerjs/sheets-thread-comment"),threadCommentUi=require("@univerjs/thread-comment-ui"),sheetsUi=require("@univerjs/sheets-ui"),ui=require("@univerjs/ui"),rxjs=require("rxjs"),engineRender=require("@univerjs/engine-render"),engineFormula=require("@univerjs/engine-formula"),threadComment=require("@univerjs/thread-comment"),jsxRuntime=require("react/jsx-runtime"),react=require("react"),SHEETS_THREAD_COMMENT_MODAL="univer.sheet.thread-comment-modal",COMMENT_SINGLE_ICON="comment-single",SHEETS_THREAD_COMMENT="SHEET_THREAD_COMMENT";var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7"),_a;exports.SheetsThreadCommentPopupService=(_a=class extends core.Disposable{constructor(_canvasPopupManagerService,_zenZoneService){super();__publicField(this,"_lastPopup",null);__publicField(this,"_activePopup");__publicField(this,"_activePopup$",new rxjs.BehaviorSubject(null));__publicField(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=_canvasPopupManagerService,this._zenZoneService=_zenZoneService,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible&&this.hidePopup()}))}showPopup(location,onHide){var _a9;const{row,col,unitId,subUnitId}=location;if(this._activePopup&&row===this._activePopup.row&&col===this._activePopup.col&&unitId===this._activePopup.unitId&&subUnitId===((_a9=this.activePopup)==null?void 0:_a9.subUnitId)){this._activePopup=location,this._activePopup$.next(location);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=location,this._activePopup$.next(location);const popupDisposable=this._canvasPopupManagerService.attachPopupToCell(row,col,{componentKey:SHEETS_THREAD_COMMENT_MODAL,onClickOutside:__name(()=>{this.hidePopup()},"onClickOutside"),direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!popupDisposable)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const disposableCollection=new core.DisposableCollection;disposableCollection.add(popupDisposable),disposableCollection.add({dispose:__name(()=>{onHide==null||onHide()},"dispose")}),this._lastPopup=disposableCollection}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))}},__name(_a,"SheetsThreadCommentPopupService"),_a);exports.SheetsThreadCommentPopupService=__decorateClass$7([__decorateParam$7(0,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$7(1,ui.IZenZoneService)],exports.SheetsThreadCommentPopupService);const ShowAddSheetCommentModalOperation={type:core.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(accessor){var _a9;const selectionManagerService=accessor.get(sheets.SheetsSelectionsService),univerInstanceService=accessor.get(core.IUniverInstanceService),sheetsThreadCommentPopupService=accessor.get(exports.SheetsThreadCommentPopupService),threadCommentPanelService=accessor.get(threadCommentUi.ThreadCommentPanelService),activeCell=(_a9=selectionManagerService.getCurrentLastSelection())==null?void 0:_a9.primary,model=accessor.get(sheetsThreadComment.SheetsThreadCommentModel);if(!activeCell)return!1;const result=sheets.getSheetCommandTarget(univerInstanceService);if(!result)return!1;const{workbook,worksheet,unitId,subUnitId}=result,location={workbook,worksheet,unitId,subUnitId,row:activeCell.startRow,col:activeCell.startColumn};sheetsThreadCommentPopupService.showPopup(location);const rootId=model.getByLocation(unitId,subUnitId,activeCell.startRow,activeCell.startColumn);return rootId&&threadCommentPanelService.setActiveComment({unitId,subUnitId,commentId:rootId,trigger:"context-menu"}),!0}},SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY="sheets-thread-comment.config",defaultPluginConfig={};var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6"),_a2;let SheetsThreadCommentRenderController=(_a2=class extends core.Disposable{constructor(_sheetInterceptorService,_sheetsThreadCommentModel,_univerInstanceService,_renderManagerService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._univerInstanceService=_univerInstanceService,this._renderManagerService=_renderManagerService,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{effect:core.InterceptorEffectEnum.Style,handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos;return this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)?next({...cell,markers:{...cell==null?void 0:cell.markers,tr:{color:"#FFBD37",size:6}}}):next(cell)},"handler"),priority:100}))}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a9;const workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId(),currentRender=this._renderManagerService.getRenderById(unitId);(_a9=currentRender==null?void 0:currentRender.mainComponent)==null||_a9.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(rxjs.debounceTime(16)).subscribe(()=>{markSkeletonDirty()}))}},__name(_a2,"SheetsThreadCommentRenderController"),_a2);SheetsThreadCommentRenderController=__decorateClass$6([__decorateParam$6(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$6(1,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$6(2,core.IUniverInstanceService),__decorateParam$6(3,engineRender.IRenderManagerService)],SheetsThreadCommentRenderController);var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const transformRef=__name((ref,source,target)=>{const refObj=engineFormula.singleReferenceToGrid(ref),offsetRow=target.row-source.row,offsetCol=target.column-source.column,targetRange={startColumn:refObj.column+offsetCol,startRow:refObj.row+offsetRow,endColumn:refObj.column+offsetCol,endRow:refObj.row+offsetRow};return engineFormula.serializeRange(targetRange)},"transformRef");var _a3;let SheetsThreadCommentCopyPasteController=(_a3=class extends core.Disposable{constructor(_sheetClipboardService,_sheetsThreadCommentModel,_threadCommentDataSourceService){super();__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:SHEETS_THREAD_COMMENT,onBeforeCopy:__name((unitId,subUnitId,range)=>{this._copyInfo={unitId,subUnitId,range}},"onBeforeCopy"),onPasteCells:__name((_pasteFrom,pasteTo,_data,payload)=>{const{unitId:targetUnitId,subUnitId:targetSubUnitId,range}=pasteTo,targetPos={row:range.rows[0],column:range.cols[0]};if(payload.copyType===sheetsUi.COPY_TYPE.CUT&&this._copyInfo){const{range:range2,unitId:sourceUnitId,subUnitId:sourceSubUnitId}=this._copyInfo,sourcePos={row:range2.startRow,column:range2.startColumn};if(!(targetUnitId===sourceUnitId&&targetSubUnitId===sourceSubUnitId)){const roots=[];core.Range.foreach(range2,(row,col)=>{const comments=this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId,sourceSubUnitId,row,col);this._threadCommentDataSourceService.syncUpdateMutationToColla?comments.forEach(comment=>{roots.push(comment)}):comments.forEach(({children,...comment})=>{comment.parentId||roots.push(comment)})});const sourceRedos=[],sourceUndos=[],targetRedos=[],targetUndos=[],handleCommentItem=__name(item=>{sourceRedos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,commentId:item.id}}),targetRedos.push({id:threadComment.AddCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,comment:{...item,ref:transformRef(item.ref,sourcePos,targetPos),unitId:targetUnitId,subUnitId:targetSubUnitId},sync:!0}}),sourceUndos.push({id:threadComment.AddCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,comment:item,sync:!0}}),targetUndos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,commentId:item.id}})},"handleCommentItem");return roots.forEach(root=>{handleCommentItem(root)}),{redos:[...sourceRedos,...targetRedos],undos:[...targetUndos,...sourceUndos]}}}return{redos:[],undos:[]}},"onPasteCells")}))}},__name(_a3,"SheetsThreadCommentCopyPasteController"),_a3);SheetsThreadCommentCopyPasteController=__decorateClass$5([__decorateParam$5(0,core.Inject(sheetsUi.ISheetClipboardService)),__decorateParam$5(1,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$5(2,threadComment.IThreadCommentDataSourceService)],SheetsThreadCommentCopyPasteController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4"),_a4;let SheetsThreadCommentHoverController=(_a4=class extends core.Disposable{constructor(_hoverManagerService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_sheetPermissionCheckController){super(),this._hoverManagerService=_hoverManagerService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._sheetPermissionCheckController=_sheetPermissionCheckController,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rxjs.debounceTime(100)).subscribe(cell=>{const currentPopup=this._sheetsThreadCommentPopupService.activePopup;if(cell&&(currentPopup&¤tPopup.temp||!currentPopup)){const{location}=cell,{unitId,subUnitId,row,col}=location,commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);if(commentId){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);comment&&!comment.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row,col,commentId,temp:!0})}else currentPopup&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},__name(_a4,"SheetsThreadCommentHoverController"),_a4);SheetsThreadCommentHoverController=__decorateClass$4([__decorateParam$4(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$4(1,core.Inject(exports.SheetsThreadCommentPopupService)),__decorateParam$4(2,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$4(3,core.Inject(sheets.SheetPermissionCheckController))],SheetsThreadCommentHoverController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a5;let SheetsThreadCommentPopupController=(_a5=class extends core.Disposable{constructor(_commandService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_threadCommentPanelService,_univerInstanceService,_sheetPermissionCheckController,_markSelectionService,_sheetSelectionService,_editorBridgeService,_renderManagerService){super();__publicField(this,"_isSwitchToCommenting",!1);__publicField(this,"_selectionShapeInfo",null);this._commandService=_commandService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._sheetPermissionCheckController=_sheetPermissionCheckController,this._markSelectionService=_markSelectionService,this._sheetSelectionService=_sheetSelectionService,this._editorBridgeService=_editorBridgeService,this._renderManagerService=_renderManagerService,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(selections,unitId,subUnitId){var _a9,_b,_c;const range=(_a9=selections[0])==null?void 0:_a9.range,render2=this._renderManagerService.getRenderById(unitId),skeleton=(_b=render2==null?void 0:render2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId))==null?void 0:_b.skeleton;if(!skeleton||!range)return;const actualCell=skeleton.getCellWithCoordByIndex(range.startRow,range.startColumn);if((((_c=range.rangeType)!=null?_c:core.RANGE_TYPE.NORMAL)!==core.RANGE_TYPE.NORMAL||range.endColumn-range.startColumn>0||range.endRow-range.startRow>0)&&!((actualCell.isMerged||actualCell.isMergedMainCell)&&core.Rectangle.equals(actualCell.mergeInfo,range))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const row=actualCell.actualRow,col=actualCell.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);commentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id,{unitId,subUnitId,commentId})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(selections=>{if(this._isSwitchToCommenting)return;const current=this._sheetSelectionService.currentSelectionParam;current&&this._handleSelectionChange(selections,current.unitId,current.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(visible=>{visible.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(commandInfo=>{if(commandInfo.id===threadComment.DeleteCommentMutation.id){const params=commandInfo.params,active=this._sheetsThreadCommentPopupService.activePopup;if(!active)return;const{unitId,subUnitId,commentId}=active;params.unitId===unitId&¶ms.subUnitId===subUnitId&¶ms.commentId===commentId&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async commentInfo=>{var _a9;if(commentInfo){const{unitId,subUnitId,commentId,trigger}=commentInfo,comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||comment.resolved)return;const currentUnit=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!currentUnit||currentUnit.getUnitId()!==unitId)return;this._isSwitchToCommenting=!0,((_a9=currentUnit.getActiveSheet())==null?void 0:_a9.getSheetId())!==subUnitId&&await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId}),this._isSwitchToCommenting=!1;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column:col}=location;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const GAP=1;if(await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(location.row-GAP,0),endRow:location.row+GAP,startColumn:Math.max(location.column-GAP,0),endColumn:location.column+GAP}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row:location.row,col:location.column,commentId:comment.id,trigger})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(rxjs.debounceTime(100)).subscribe(activeComment=>{var _a9,_b;if(!activeComment){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId,subUnitId,commentId}=activeComment;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment)return;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column}=location;if(Number.isNaN(row)||Number.isNaN(column))return null;const worksheet=(_a9=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a9.getSheetBySheetId(subUnitId),mergeInfo=(_b=worksheet==null?void 0:worksheet.getMergedCell(row,column))!=null?_b:{startColumn:column,endColumn:column,startRow:row,endRow:row},shapeId=this._markSelectionService.addShape({range:mergeInfo,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);shapeId&&(this._selectionShapeInfo={...activeComment,shapeId})}))}},__name(_a5,"SheetsThreadCommentPopupController"),_a5);SheetsThreadCommentPopupController=__decorateClass$3([__decorateParam$3(0,core.ICommandService),__decorateParam$3(1,core.Inject(exports.SheetsThreadCommentPopupService)),__decorateParam$3(2,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$3(3,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$3(4,core.IUniverInstanceService),__decorateParam$3(5,core.Inject(sheets.SheetPermissionCheckController)),__decorateParam$3(6,sheetsUi.IMarkSelectionService),__decorateParam$3(7,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$3(8,sheetsUi.IEditorBridgeService),__decorateParam$3(9,engineRender.IRenderManagerService)],SheetsThreadCommentPopupController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a6;let ThreadCommentRemoveSheetsController=(_a6=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_threadCommentModel,_threadCommentDataSourceService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a9;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a9=workbook.getActiveSheet())==null?void 0:_a9.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const commentMap=this._threadCommentModel.ensureMap(unitId,subUnitId),comments=Array.from(commentMap.values()).filter(comment=>!comment.parentId),ids=comments.map(comment=>comment.id),shouldSync=this._threadCommentDataSourceService.syncUpdateMutationToColla,redos=ids.map(id=>({id:threadComment.DeleteCommentMutation.id,params:{unitId,subUnitId,commentId:id}})),undos=comments.map(({children,...comment})=>({id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId,comment:{...comment,children:shouldSync?children:void 0},sync:!shouldSync}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_a6,"ThreadCommentRemoveSheetsController"),_a6);ThreadCommentRemoveSheetsController=__decorateClass$2([__decorateParam$2(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$2(1,core.IUniverInstanceService),__decorateParam$2(2,core.Inject(threadComment.ThreadCommentModel)),__decorateParam$2(3,threadComment.IThreadCommentDataSourceService)],ThreadCommentRemoveSheetsController);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=react.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=react.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return react.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a9){var key=_a9[0],value=_a9[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a9,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a9=node.children)===null||_a9===void 0)&&_a9.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CommentSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const SheetsThreadCommentCell=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports.SheetsThreadCommentPopupService),activePopup=ui.useObservable(sheetsThreadCommentPopupService.activePopup$),sheetThreadCommentModel=core.useDependency(sheetsThreadComment.SheetsThreadCommentModel);if(ui.useObservable(sheetThreadCommentModel.commentUpdate$),!activePopup)return null;const{row,col,unitId,subUnitId,trigger}=activePopup,rootId=sheetThreadCommentModel.getByLocation(unitId,subUnitId,row,col),ref=`${core.Tools.chatAtABC(col)}${row+1}`,onClose=__name(()=>{sheetsThreadCommentPopupService.hidePopup()},"onClose"),getSubUnitName=__name(id=>{var _a9,_b,_c;return(_c=(_b=(_a9=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a9.getSheetBySheetId(id))==null?void 0:_b.getName())!=null?_c:""},"getSubUnitName");return jsxRuntime.jsx(threadCommentUi.ThreadCommentTree,{onClick:__name(()=>{sheetsThreadCommentPopupService.persistPopup()},"onClick"),prefix:"cell",id:rootId,unitId,subUnitId,type:core.UniverInstanceType.UNIVER_SHEET,refStr:ref,onClose,getSubUnitName,autoFocus:trigger==="context-menu"})},"SheetsThreadCommentCell"),SheetsThreadCommentPanel=__name(()=>{var _a9;const markSelectionService=core.useDependency(sheetsUi.IMarkSelectionService),univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports.SheetsThreadCommentPopupService),workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),unitId=workbook.getUnitId(),commandService=core.useDependency(core.ICommandService),subUnitId$=react.useMemo(()=>workbook.activeSheet$.pipe(rxjs.map(i=>i==null?void 0:i.getSheetId())),[workbook.activeSheet$]),subUnitId=ui.useObservable(subUnitId$,(_a9=workbook.getActiveSheet())==null?void 0:_a9.getSheetId()),hoverShapeId=react.useRef(null),panelService=core.useDependency(threadCommentUi.ThreadCommentPanelService),activeCommentId=ui.useObservable(panelService.activeCommentId$),panelVisible=ui.useObservable(panelService.panelVisible$,panelService.panelVisible),sortComments=react.useCallback(comments=>{const worksheets=workbook.getSheets(),sheetIndex={};worksheets.forEach((sheet,i)=>{sheetIndex[sheet.getSheetId()]=i});const sort=__name(comments2=>comments2.map(comment=>{var _a10;const ref=engineFormula.singleReferenceToGrid(comment.ref),p=[(_a10=sheetIndex[comment.subUnitId])!=null?_a10:0,ref.row,ref.column];return{...comment,p}}).sort((pre,aft)=>pre.p[0]===aft.p[0]?pre.p[1]===aft.p[1]?pre.p[2]-aft.p[2]:pre.p[1]-aft.p[1]:pre.p[0]-aft.p[0]),"sort");return[...sort(comments.filter(comment=>!comment.resolved)),...sort(comments.filter(comment=>comment.resolved))]},[workbook]),showShape=react.useCallback(comment=>{var _a10;if(comment.unitId===unitId&&comment.subUnitId===subUnitId&&!comment.resolved){const{row,column}=engineFormula.singleReferenceToGrid(comment.ref),worksheet=workbook.getSheetBySheetId(comment.subUnitId),mergeInfo=(_a10=worksheet==null?void 0:worksheet.getMergedCell(row,column))!=null?_a10:{startColumn:column,endColumn:column,startRow:row,endRow:row};if(!Number.isNaN(row)&&!Number.isNaN(column))return markSelectionService.addShape({range:mergeInfo,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[markSelectionService,subUnitId,unitId]),getSubUnitName=__name(id=>{var _a10,_b;return(_b=(_a10=workbook.getSheetBySheetId(id))==null?void 0:_a10.getName())!=null?_b:""},"getSubUnitName"),handleAdd=__name(()=>{commandService.executeCommand(ShowAddSheetCommentModalOperation.id)},"handleAdd"),handleHover=__name(comment=>{activeCommentId&&activeCommentId.unitId===comment.unitId&&activeCommentId.subUnitId===comment.subUnitId&&activeCommentId.commentId===comment.id||(hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null),hoverShapeId.current=showShape(comment))},"handleHover"),handleLeave=__name(()=>{hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null)},"handleLeave"),handleResolve=__name((id,resolved)=>{resolved&&sheetsThreadCommentPopupService.hidePopup()},"handleResolve");return react.useEffect(()=>{!panelVisible&&hoverShapeId.current&&markSelectionService.removeShape(hoverShapeId.current)},[markSelectionService,panelVisible]),jsxRuntime.jsx(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_SHEET,onAdd:handleAdd,getSubUnitName,onResolve:handleResolve,sortComments,onItemEnter:handleHover,onItemLeave:handleLeave,onDeleteComment:__name(()=>(handleLeave(),!0),"onDeleteComment")})},"SheetsThreadCommentPanel"),threadCommentMenuFactory=__name(accessor=>({id:ShowAddSheetCommentModalOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,title:"sheetThreadComment.menu.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]})}),"threadCommentMenuFactory"),threadPanelMenuFactory=__name(accessor=>({id:threadCommentUi.ToggleSheetCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]}),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET)}),"threadPanelMenuFactory"),AddCommentShortcut={id:ShowAddSheetCommentModalOperation.id,binding:ui.KeyCode.M|ui.MetaKeys.CTRL_COMMAND|ui.MetaKeys.ALT,preconditions:sheetsUi.whenSheetEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[threadCommentUi.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:threadPanelMenuFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{[ShowAddSheetCommentModalOperation.id]:{order:0,menuItemFactory:threadCommentMenuFactory}}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a7;let SheetsThreadCommentController=(_a7=class extends core.Disposable{constructor(_menuManagerService,_componentManager,_shortcutService){super(),this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._shortcutService=_shortcutService,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(AddCommentShortcut)}_initMenu(){this._menuManagerService.mergeMenu(menuSchema)}_initComponent(){[[SHEETS_THREAD_COMMENT_MODAL,SheetsThreadCommentCell],[threadCommentUi.THREAD_COMMENT_PANEL,SheetsThreadCommentPanel],[COMMENT_SINGLE_ICON,CommentSingle]].forEach(([key,comp])=>{this._componentManager.register(key,comp)})}},__name(_a7,"SheetsThreadCommentController"),_a7);SheetsThreadCommentController=__decorateClass$1([__decorateParam$1(0,ui.IMenuManagerService),__decorateParam$1(1,core.Inject(ui.ComponentManager)),__decorateParam$1(2,ui.IShortcutService)],SheetsThreadCommentController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a8;exports.UniverSheetsThreadCommentUIPlugin=(_a8=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=core.merge({},defaultPluginConfig,this._config);menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsThreadCommentController],[SheetsThreadCommentRenderController],[SheetsThreadCommentCopyPasteController],[SheetsThreadCommentHoverController],[ThreadCommentRemoveSheetsController],[SheetsThreadCommentPopupController],[exports.SheetsThreadCommentPopupService]].forEach(dep=>{this._injector.add(dep)}),[ShowAddSheetCommentModalOperation].forEach(command=>{this._commandService.registerCommand(command)}),this._injector.get(SheetsThreadCommentController)}onReady(){this._injector.get(SheetsThreadCommentRenderController),this._injector.get(ThreadCommentRemoveSheetsController)}onRendered(){this._injector.get(SheetsThreadCommentCopyPasteController),this._injector.get(SheetsThreadCommentHoverController),this._injector.get(SheetsThreadCommentPopupController)}},__name(_a8,"UniverSheetsThreadCommentUIPlugin"),_a8);__publicField2(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",SHEETS_THREAD_COMMENT);__publicField2(exports.UniverSheetsThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin,sheetsThreadComment.UniverSheetsThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.ICommandService)),__decorateParam(3,core.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:__name(()=>threadCommentUi.UniverThreadCommentUIPlugin,"get")});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:__name(()=>threadComment.AddCommentCommand,"get")});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:__name(()=>threadComment.DeleteCommentCommand,"get")});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:__name(()=>threadComment.DeleteCommentTreeCommand,"get")});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:__name(()=>threadComment.IThreadCommentDataSourceService,"get")});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:__name(()=>threadComment.ResolveCommentCommand,"get")});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:__name(()=>threadComment.UpdateCommentCommand,"get")});exports.SHEETS_THREAD_COMMENT=SHEETS_THREAD_COMMENT;exports.ShowAddSheetCommentModalOperation=ShowAddSheetCommentModalOperation;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const enUS={sheetThreadComment:{menu:{addComment:"Add Comment",commentManagement:"Comment Management"}}};module.exports=enUS;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const faIR={sheetThreadComment:{menu:{addComment:"افزودن نظر",commentManagement:"مدیریت نظر"}}};module.exports=faIR;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const frFR={sheetThreadComment:{menu:{addComment:"Ajouter un commentaire",commentManagement:"Gestion des commentaires"}}};module.exports=frFR;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const ruRU={sheetThreadComment:{menu:{addComment:"Add Comment",commentManagement:"Comment Management"}}};module.exports=ruRU;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const viVN={sheetThreadComment:{menu:{addComment:"Thêm bình luận",commentManagement:"Quản lý bình luận"}}};module.exports=viVN;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const zhCN={sheetThreadComment:{menu:{addComment:"添加评论",commentManagement:"评论管理"}}};module.exports=zhCN;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const zhTW={sheetThreadComment:{menu:{addComment:"新增評論",commentManagement:"評論管理"}}};module.exports=zhTW;
|
package/lib/es/index.js
CHANGED
|
@@ -14,7 +14,8 @@ import { IRenderManagerService } from "@univerjs/engine-render";
|
|
|
14
14
|
import { singleReferenceToGrid, serializeRange } from "@univerjs/engine-formula";
|
|
15
15
|
import { IThreadCommentDataSourceService, DeleteCommentMutation, AddCommentMutation, ThreadCommentModel } from "@univerjs/thread-comment";
|
|
16
16
|
import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, IThreadCommentDataSourceService as IThreadCommentDataSourceService2, ResolveCommentCommand, UpdateCommentCommand } from "@univerjs/thread-comment";
|
|
17
|
-
import
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
import { forwardRef, useRef, createElement, useMemo, useCallback, useEffect } from "react";
|
|
18
19
|
const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal", COMMENT_SINGLE_ICON = "comment-single", SHEETS_THREAD_COMMENT = "SHEET_THREAD_COMMENT";
|
|
19
20
|
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
20
21
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -595,37 +596,6 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width:
|
|
|
595
596
|
}));
|
|
596
597
|
});
|
|
597
598
|
CommentSingle.displayName = "CommentSingle";
|
|
598
|
-
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
599
|
-
/**
|
|
600
|
-
* @license React
|
|
601
|
-
* react-jsx-runtime.production.min.js
|
|
602
|
-
*
|
|
603
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
604
|
-
*
|
|
605
|
-
* This source code is licensed under the MIT license found in the
|
|
606
|
-
* LICENSE file in the root directory of this source tree.
|
|
607
|
-
*/
|
|
608
|
-
var hasRequiredReactJsxRuntime_production_min;
|
|
609
|
-
function requireReactJsxRuntime_production_min() {
|
|
610
|
-
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
611
|
-
hasRequiredReactJsxRuntime_production_min = 1;
|
|
612
|
-
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
613
|
-
function q(c, a, g) {
|
|
614
|
-
var b, d = {}, e = null, h = null;
|
|
615
|
-
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
616
|
-
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
617
|
-
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
618
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
619
|
-
}
|
|
620
|
-
return __name(q, "q"), reactJsxRuntime_production_min.Fragment = l, reactJsxRuntime_production_min.jsx = q, reactJsxRuntime_production_min.jsxs = q, reactJsxRuntime_production_min;
|
|
621
|
-
}
|
|
622
|
-
__name(requireReactJsxRuntime_production_min, "requireReactJsxRuntime_production_min");
|
|
623
|
-
var hasRequiredJsxRuntime;
|
|
624
|
-
function requireJsxRuntime() {
|
|
625
|
-
return hasRequiredJsxRuntime || (hasRequiredJsxRuntime = 1, jsxRuntime.exports = requireReactJsxRuntime_production_min()), jsxRuntime.exports;
|
|
626
|
-
}
|
|
627
|
-
__name(requireJsxRuntime, "requireJsxRuntime");
|
|
628
|
-
var jsxRuntimeExports = requireJsxRuntime();
|
|
629
599
|
const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
|
|
630
600
|
const univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), activePopup = useObservable(sheetsThreadCommentPopupService.activePopup$), sheetThreadCommentModel = useDependency(SheetsThreadCommentModel);
|
|
631
601
|
if (useObservable(sheetThreadCommentModel.commentUpdate$), !activePopup)
|
|
@@ -636,7 +606,7 @@ const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
|
|
|
636
606
|
var _a9, _b, _c;
|
|
637
607
|
return (_c = (_b = (_a9 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a9.getSheetBySheetId(id)) == null ? void 0 : _b.getName()) != null ? _c : "";
|
|
638
608
|
}, "getSubUnitName");
|
|
639
|
-
return /* @__PURE__ */
|
|
609
|
+
return /* @__PURE__ */ jsx(
|
|
640
610
|
ThreadCommentTree,
|
|
641
611
|
{
|
|
642
612
|
onClick: /* @__PURE__ */ __name(() => {
|
|
@@ -655,7 +625,7 @@ const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
|
|
|
655
625
|
);
|
|
656
626
|
}, "SheetsThreadCommentCell"), SheetsThreadCommentPanel = /* @__PURE__ */ __name(() => {
|
|
657
627
|
var _a9;
|
|
658
|
-
const markSelectionService = useDependency(IMarkSelectionService), univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), commandService = useDependency(ICommandService), subUnitId$ = useMemo(() => workbook.activeSheet$.pipe(map((i) => i == null ? void 0 : i.getSheetId())), [workbook.activeSheet$]), subUnitId = useObservable(subUnitId$, (_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId()), hoverShapeId = useRef(), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), panelVisible = useObservable(panelService.panelVisible$, panelService.panelVisible), sortComments = useCallback((comments) => {
|
|
628
|
+
const markSelectionService = useDependency(IMarkSelectionService), univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), commandService = useDependency(ICommandService), subUnitId$ = useMemo(() => workbook.activeSheet$.pipe(map((i) => i == null ? void 0 : i.getSheetId())), [workbook.activeSheet$]), subUnitId = useObservable(subUnitId$, (_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId()), hoverShapeId = useRef(null), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), panelVisible = useObservable(panelService.panelVisible$, panelService.panelVisible), sortComments = useCallback((comments) => {
|
|
659
629
|
const worksheets = workbook.getSheets(), sheetIndex = {};
|
|
660
630
|
worksheets.forEach((sheet, i) => {
|
|
661
631
|
sheetIndex[sheet.getSheetId()] = i;
|
|
@@ -691,6 +661,7 @@ const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
|
|
|
691
661
|
primary: null
|
|
692
662
|
});
|
|
693
663
|
}
|
|
664
|
+
return null;
|
|
694
665
|
}, [markSelectionService, subUnitId, unitId]), getSubUnitName = /* @__PURE__ */ __name((id) => {
|
|
695
666
|
var _a10, _b;
|
|
696
667
|
return (_b = (_a10 = workbook.getSheetBySheetId(id)) == null ? void 0 : _a10.getName()) != null ? _b : "";
|
|
@@ -705,7 +676,7 @@ const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
|
|
|
705
676
|
}, "handleResolve");
|
|
706
677
|
return useEffect(() => {
|
|
707
678
|
!panelVisible && hoverShapeId.current && markSelectionService.removeShape(hoverShapeId.current);
|
|
708
|
-
}, [markSelectionService, panelVisible]), /* @__PURE__ */
|
|
679
|
+
}, [markSelectionService, panelVisible]), /* @__PURE__ */ jsx(
|
|
709
680
|
ThreadCommentPanel,
|
|
710
681
|
{
|
|
711
682
|
unitId,
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SheetsThreadCommentCell: () => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SheetsThreadCommentPanel: () => import("react/jsx-runtime").JSX.Element;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,9 +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")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,s,v,A,g,b,f,x,ie,k,C,E){"use strict";var rt=Object.defineProperty;var it=(d,s,v)=>s in d?rt(d,s,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[s]=v;var N=(d,s,v)=>it(d,typeof s!="symbol"?s+"":s,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ce=(i,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_e(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new x.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var m;const{row:r,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},d.SheetsThreadCommentPopupService=Ce([se(0,s.Inject(b.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const $={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var I;const t=i.get(v.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=a.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ae={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ge(t,n,r),r},B=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(x.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([B(0,s.Inject(v.SheetInterceptorService)),B(1,s.Inject(A.SheetsThreadCommentModel)),B(2,s.IUniverInstanceService),B(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=k.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return k.serializeRange(a)};let F=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===b.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&a===l)){const S=[];s.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(P=>{S.push(P)}):R.forEach(({children:P,...j})=>{j.parentId||S.push(j)})});const I=[],M=[],V=[],L=[],re=w=>{I.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),L.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...I,...V],undos:[...L,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,s.Inject(b.ISheetClipboardService)),X(1,s.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(x.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,s.Inject(b.HoverManagerService)),G(1,s.Inject(d.SheetsThreadCommentPopupService)),G(2,s.Inject(A.SheetsThreadCommentModel)),G(3,s.Inject(v.SheetPermissionCheckController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(t,n,e,r,o,a,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,I;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),a=(S=o==null?void 0:o.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!a||!r)return;const c=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((I=r.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=k.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(b.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(x.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=k.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,s.ICommandService),U(1,s.Inject(d.SheetsThreadCommentPopupService)),U(2,s.Inject(A.SheetsThreadCommentModel)),U(3,s.Inject(g.ThreadCommentPanelService)),U(4,s.IUniverInstanceService),U(5,s.Inject(v.SheetPermissionCheckController)),U(6,b.IMarkSelectionService),U(7,s.Inject(v.SheetsSelectionsService)),U(8,b.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),c=Array.from(a.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,s.Inject(v.SheetInterceptorService)),q(1,s.IUniverInstanceService),q(2,s.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},ke=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ce=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=ke(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(He()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ue(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},$e(i,n,r)),e),(xe(i,n).children||[]).map(function(o,a){return ue(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function $e(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function xe(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function He(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=E.forwardRef(function(i,t){return E.createElement(ce,Object.assign({},i,{id:"comment-single",ref:t,icon:Le}))});de.displayName="CommentSingle";var ee={exports:{}},H={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var me;function Be(){if(me)return H;me=1;var i=E,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,h){var m,l={},p=null,S=null;h!==void 0&&(p=""+h),u.key!==void 0&&(p=""+u.key),u.ref!==void 0&&(S=u.ref);for(m in u)e.call(u,m)&&!o.hasOwnProperty(m)&&(l[m]=u[m]);if(c&&c.defaultProps)for(m in u=c.defaultProps,u)l[m]===void 0&&(l[m]=u[m]);return{$$typeof:t,type:c,key:p,ref:S,props:l,_owner:r.current}}return H.Fragment=n,H.jsx=a,H.jsxs=a,H}var he;function We(){return he||(he=1,ee.exports=Be()),ee.exports}var le=We();const Fe=()=>{const i=s.useDependency(s.IUniverInstanceService),t=s.useDependency(d.SheetsThreadCommentPopupService),n=f.useObservable(t.activePopup$),e=s.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:a,subUnitId:c,trigger:u}=n,h=e.getByLocation(a,c,r,o),m=`${s.Tools.chatAtABC(o)}${r+1}`,l=()=>{t.hidePopup()},p=S=>{var I,M,V;return(V=(M=(I=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(S))==null?void 0:M.getName())!=null?V:""};return le.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:l,getSubUnitName:p,autoFocus:u==="context-menu"})},Ge=()=>{var w;const i=s.useDependency(b.IMarkSelectionService),t=s.useDependency(s.IUniverInstanceService),n=s.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=s.useDependency(s.ICommandService),a=E.useMemo(()=>e.activeSheet$.pipe(x.map(_=>_==null?void 0:_.getSheetId())),[e.activeSheet$]),c=f.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),h=s.useDependency(g.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),l=f.useObservable(h.panelVisible$,h.panelVisible),p=E.useCallback(_=>{const R=e.getSheets(),P={};R.forEach((O,T)=>{P[O.getSheetId()]=T});const j=O=>O.map(T=>{var Se;const D=k.singleReferenceToGrid(T.ref),nt=[(Se=P[T.subUnitId])!=null?Se:0,D.row,D.column];return{...T,p:nt}}).sort((T,D)=>T.p[0]===D.p[0]?T.p[1]===D.p[1]?T.p[2]-D.p[2]:T.p[1]-D.p[1]:T.p[0]-D.p[0]);return[...j(_.filter(O=>!O.resolved)),...j(_.filter(O=>O.resolved))]},[e]),S=E.useCallback(_=>{var R;if(_.unitId===r&&_.subUnitId===c&&!_.resolved){const{row:P,column:j}=k.singleReferenceToGrid(_.ref),O=e.getSheetBySheetId(_.subUnitId),T=(R=O==null?void 0:O.getMergedCell(P,j))!=null?R:{startColumn:j,endColumn:j,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(j))return i.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,c,r]),I=_=>{var R,P;return(P=(R=e.getSheetBySheetId(_))==null?void 0:R.getName())!=null?P:""},M=()=>{o.executeCommand($.id)},V=_=>{m&&m.unitId===_.unitId&&m.subUnitId===_.subUnitId&&m.commentId===_.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=S(_))},L=()=>{u.current&&(i.removeShape(u.current),u.current=null)},re=(_,R)=>{R&&n.hidePopup()};return E.useEffect(()=>{!l&&u.current&&i.removeShape(u.current)},[i,l]),le.jsx(g.ThreadCommentPanel,{unitId:r,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:I,onResolve:re,sortComments:p,onItemEnter:V,onItemLeave:L,onDeleteComment:()=>(L(),!0)})},Ze=i=>({id:$.id,type:f.MenuItemType.BUTTON,icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),ze=i=>({id:g.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET)}),qe={id:$.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:b.whenSheetEditorFocused},Ye={[f.RibbonStartGroup.OTHERS]:{[g.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:ze}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[$.id]:{order:0,menuItemFactory:Ze}}}};var Je=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Qe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Je(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);let J=class extends s.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(qe)}_initMenu(){this._menuManagerService.mergeMenu(Ye)}_initComponent(){[[oe,Fe],[g.THREAD_COMMENT_PANEL,Ge],[K,de]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};J=Qe([te(0,f.IMenuManagerService),te(1,s.Inject(f.ComponentManager)),te(2,f.IShortcutService)],J);var pe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(i,t,n)=>t in i?pe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,tt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&pe(t,n,r),r},ne=(i,t)=>(n,e)=>t(n,e,i),ve=(i,t,n)=>et(i,typeof t!="symbol"?t+"":t,n);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=ae,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...a}=s.merge({},ae,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ie,a)}onStarting(){[[J],[W],[F],[Z],[Y],[z],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[$].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(J)}onReady(){this._injector.get(W),this._injector.get(Y)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(z)}},ve(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),ve(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=tt([s.DependentOn(g.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),ne(1,s.Inject(s.Injector)),ne(2,s.Inject(s.ICommandService)),ne(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Q,d.ShowAddSheetCommentModalOperation=$,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(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"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsThreadCommentUi={},global.UniverCore,global.UniverSheets,global.UniverSheetsThreadComment,global.UniverThreadCommentUi,global.UniverSheetsUi,global.UniverUi,global.rxjs,global.UniverEngineRender,global.UniverEngineFormula,global.UniverThreadComment,global.React,global.React))})(this,function(exports2,core,sheets,sheetsThreadComment,threadCommentUi,sheetsUi,ui,rxjs,engineRender,engineFormula,threadComment,jsxRuntime,react){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g,_h;const SHEETS_THREAD_COMMENT_MODAL="univer.sheet.thread-comment-modal",COMMENT_SINGLE_ICON="comment-single",SHEETS_THREAD_COMMENT="SHEET_THREAD_COMMENT";var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7");exports2.SheetsThreadCommentPopupService=(_a=class extends core.Disposable{constructor(_canvasPopupManagerService,_zenZoneService){super();__publicField(this,"_lastPopup",null);__publicField(this,"_activePopup");__publicField(this,"_activePopup$",new rxjs.BehaviorSubject(null));__publicField(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=_canvasPopupManagerService,this._zenZoneService=_zenZoneService,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible&&this.hidePopup()}))}showPopup(location,onHide){var _a2;const{row,col,unitId,subUnitId}=location;if(this._activePopup&&row===this._activePopup.row&&col===this._activePopup.col&&unitId===this._activePopup.unitId&&subUnitId===((_a2=this.activePopup)==null?void 0:_a2.subUnitId)){this._activePopup=location,this._activePopup$.next(location);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=location,this._activePopup$.next(location);const popupDisposable=this._canvasPopupManagerService.attachPopupToCell(row,col,{componentKey:SHEETS_THREAD_COMMENT_MODAL,onClickOutside:__name(()=>{this.hidePopup()},"onClickOutside"),direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!popupDisposable)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const disposableCollection=new core.DisposableCollection;disposableCollection.add(popupDisposable),disposableCollection.add({dispose:__name(()=>{onHide==null||onHide()},"dispose")}),this._lastPopup=disposableCollection}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))}},__name(_a,"SheetsThreadCommentPopupService"),_a),exports2.SheetsThreadCommentPopupService=__decorateClass$7([__decorateParam$7(0,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$7(1,ui.IZenZoneService)],exports2.SheetsThreadCommentPopupService);const ShowAddSheetCommentModalOperation={type:core.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(accessor){var _a2;const selectionManagerService=accessor.get(sheets.SheetsSelectionsService),univerInstanceService=accessor.get(core.IUniverInstanceService),sheetsThreadCommentPopupService=accessor.get(exports2.SheetsThreadCommentPopupService),threadCommentPanelService=accessor.get(threadCommentUi.ThreadCommentPanelService),activeCell=(_a2=selectionManagerService.getCurrentLastSelection())==null?void 0:_a2.primary,model=accessor.get(sheetsThreadComment.SheetsThreadCommentModel);if(!activeCell)return!1;const result=sheets.getSheetCommandTarget(univerInstanceService);if(!result)return!1;const{workbook,worksheet,unitId,subUnitId}=result,location={workbook,worksheet,unitId,subUnitId,row:activeCell.startRow,col:activeCell.startColumn};sheetsThreadCommentPopupService.showPopup(location);const rootId=model.getByLocation(unitId,subUnitId,activeCell.startRow,activeCell.startColumn);return rootId&&threadCommentPanelService.setActiveComment({unitId,subUnitId,commentId:rootId,trigger:"context-menu"}),!0}},SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY="sheets-thread-comment.config",defaultPluginConfig={};var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");let SheetsThreadCommentRenderController=(_b=class extends core.Disposable{constructor(_sheetInterceptorService,_sheetsThreadCommentModel,_univerInstanceService,_renderManagerService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._univerInstanceService=_univerInstanceService,this._renderManagerService=_renderManagerService,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{effect:core.InterceptorEffectEnum.Style,handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos;return this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)?next({...cell,markers:{...cell==null?void 0:cell.markers,tr:{color:"#FFBD37",size:6}}}):next(cell)},"handler"),priority:100}))}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a2;const workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId(),currentRender=this._renderManagerService.getRenderById(unitId);(_a2=currentRender==null?void 0:currentRender.mainComponent)==null||_a2.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(rxjs.debounceTime(16)).subscribe(()=>{markSkeletonDirty()}))}},__name(_b,"SheetsThreadCommentRenderController"),_b);SheetsThreadCommentRenderController=__decorateClass$6([__decorateParam$6(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$6(1,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$6(2,core.IUniverInstanceService),__decorateParam$6(3,engineRender.IRenderManagerService)],SheetsThreadCommentRenderController);var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const transformRef=__name((ref,source,target)=>{const refObj=engineFormula.singleReferenceToGrid(ref),offsetRow=target.row-source.row,offsetCol=target.column-source.column,targetRange={startColumn:refObj.column+offsetCol,startRow:refObj.row+offsetRow,endColumn:refObj.column+offsetCol,endRow:refObj.row+offsetRow};return engineFormula.serializeRange(targetRange)},"transformRef");let SheetsThreadCommentCopyPasteController=(_c=class extends core.Disposable{constructor(_sheetClipboardService,_sheetsThreadCommentModel,_threadCommentDataSourceService){super();__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:SHEETS_THREAD_COMMENT,onBeforeCopy:__name((unitId,subUnitId,range)=>{this._copyInfo={unitId,subUnitId,range}},"onBeforeCopy"),onPasteCells:__name((_pasteFrom,pasteTo,_data,payload)=>{const{unitId:targetUnitId,subUnitId:targetSubUnitId,range}=pasteTo,targetPos={row:range.rows[0],column:range.cols[0]};if(payload.copyType===sheetsUi.COPY_TYPE.CUT&&this._copyInfo){const{range:range2,unitId:sourceUnitId,subUnitId:sourceSubUnitId}=this._copyInfo,sourcePos={row:range2.startRow,column:range2.startColumn};if(!(targetUnitId===sourceUnitId&&targetSubUnitId===sourceSubUnitId)){const roots=[];core.Range.foreach(range2,(row,col)=>{const comments=this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId,sourceSubUnitId,row,col);this._threadCommentDataSourceService.syncUpdateMutationToColla?comments.forEach(comment=>{roots.push(comment)}):comments.forEach(({children,...comment})=>{comment.parentId||roots.push(comment)})});const sourceRedos=[],sourceUndos=[],targetRedos=[],targetUndos=[],handleCommentItem=__name(item=>{sourceRedos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,commentId:item.id}}),targetRedos.push({id:threadComment.AddCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,comment:{...item,ref:transformRef(item.ref,sourcePos,targetPos),unitId:targetUnitId,subUnitId:targetSubUnitId},sync:!0}}),sourceUndos.push({id:threadComment.AddCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,comment:item,sync:!0}}),targetUndos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,commentId:item.id}})},"handleCommentItem");return roots.forEach(root=>{handleCommentItem(root)}),{redos:[...sourceRedos,...targetRedos],undos:[...targetUndos,...sourceUndos]}}}return{redos:[],undos:[]}},"onPasteCells")}))}},__name(_c,"SheetsThreadCommentCopyPasteController"),_c);SheetsThreadCommentCopyPasteController=__decorateClass$5([__decorateParam$5(0,core.Inject(sheetsUi.ISheetClipboardService)),__decorateParam$5(1,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$5(2,threadComment.IThreadCommentDataSourceService)],SheetsThreadCommentCopyPasteController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let SheetsThreadCommentHoverController=(_d=class extends core.Disposable{constructor(_hoverManagerService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_sheetPermissionCheckController){super(),this._hoverManagerService=_hoverManagerService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._sheetPermissionCheckController=_sheetPermissionCheckController,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rxjs.debounceTime(100)).subscribe(cell=>{const currentPopup=this._sheetsThreadCommentPopupService.activePopup;if(cell&&(currentPopup&¤tPopup.temp||!currentPopup)){const{location}=cell,{unitId,subUnitId,row,col}=location,commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);if(commentId){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);comment&&!comment.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row,col,commentId,temp:!0})}else currentPopup&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},__name(_d,"SheetsThreadCommentHoverController"),_d);SheetsThreadCommentHoverController=__decorateClass$4([__decorateParam$4(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$4(1,core.Inject(exports2.SheetsThreadCommentPopupService)),__decorateParam$4(2,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$4(3,core.Inject(sheets.SheetPermissionCheckController))],SheetsThreadCommentHoverController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let SheetsThreadCommentPopupController=(_e=class extends core.Disposable{constructor(_commandService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_threadCommentPanelService,_univerInstanceService,_sheetPermissionCheckController,_markSelectionService,_sheetSelectionService,_editorBridgeService,_renderManagerService){super();__publicField(this,"_isSwitchToCommenting",!1);__publicField(this,"_selectionShapeInfo",null);this._commandService=_commandService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._sheetPermissionCheckController=_sheetPermissionCheckController,this._markSelectionService=_markSelectionService,this._sheetSelectionService=_sheetSelectionService,this._editorBridgeService=_editorBridgeService,this._renderManagerService=_renderManagerService,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(selections,unitId,subUnitId){var _a2,_b2,_c2;const range=(_a2=selections[0])==null?void 0:_a2.range,render2=this._renderManagerService.getRenderById(unitId),skeleton=(_b2=render2==null?void 0:render2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId))==null?void 0:_b2.skeleton;if(!skeleton||!range)return;const actualCell=skeleton.getCellWithCoordByIndex(range.startRow,range.startColumn);if((((_c2=range.rangeType)!=null?_c2:core.RANGE_TYPE.NORMAL)!==core.RANGE_TYPE.NORMAL||range.endColumn-range.startColumn>0||range.endRow-range.startRow>0)&&!((actualCell.isMerged||actualCell.isMergedMainCell)&&core.Rectangle.equals(actualCell.mergeInfo,range))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const row=actualCell.actualRow,col=actualCell.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);commentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id,{unitId,subUnitId,commentId})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(selections=>{if(this._isSwitchToCommenting)return;const current=this._sheetSelectionService.currentSelectionParam;current&&this._handleSelectionChange(selections,current.unitId,current.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(visible=>{visible.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(commandInfo=>{if(commandInfo.id===threadComment.DeleteCommentMutation.id){const params=commandInfo.params,active=this._sheetsThreadCommentPopupService.activePopup;if(!active)return;const{unitId,subUnitId,commentId}=active;params.unitId===unitId&¶ms.subUnitId===subUnitId&¶ms.commentId===commentId&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async commentInfo=>{var _a2;if(commentInfo){const{unitId,subUnitId,commentId,trigger}=commentInfo,comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||comment.resolved)return;const currentUnit=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!currentUnit||currentUnit.getUnitId()!==unitId)return;this._isSwitchToCommenting=!0,((_a2=currentUnit.getActiveSheet())==null?void 0:_a2.getSheetId())!==subUnitId&&await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId}),this._isSwitchToCommenting=!1;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column:col}=location;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const GAP=1;if(await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(location.row-GAP,0),endRow:location.row+GAP,startColumn:Math.max(location.column-GAP,0),endColumn:location.column+GAP}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row:location.row,col:location.column,commentId:comment.id,trigger})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(rxjs.debounceTime(100)).subscribe(activeComment=>{var _a2,_b2;if(!activeComment){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId,subUnitId,commentId}=activeComment;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment)return;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column}=location;if(Number.isNaN(row)||Number.isNaN(column))return null;const worksheet=(_a2=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getSheetBySheetId(subUnitId),mergeInfo=(_b2=worksheet==null?void 0:worksheet.getMergedCell(row,column))!=null?_b2:{startColumn:column,endColumn:column,startRow:row,endRow:row},shapeId=this._markSelectionService.addShape({range:mergeInfo,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);shapeId&&(this._selectionShapeInfo={...activeComment,shapeId})}))}},__name(_e,"SheetsThreadCommentPopupController"),_e);SheetsThreadCommentPopupController=__decorateClass$3([__decorateParam$3(0,core.ICommandService),__decorateParam$3(1,core.Inject(exports2.SheetsThreadCommentPopupService)),__decorateParam$3(2,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam$3(3,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$3(4,core.IUniverInstanceService),__decorateParam$3(5,core.Inject(sheets.SheetPermissionCheckController)),__decorateParam$3(6,sheetsUi.IMarkSelectionService),__decorateParam$3(7,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$3(8,sheetsUi.IEditorBridgeService),__decorateParam$3(9,engineRender.IRenderManagerService)],SheetsThreadCommentPopupController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let ThreadCommentRemoveSheetsController=(_f=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_threadCommentModel,_threadCommentDataSourceService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a2;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const commentMap=this._threadCommentModel.ensureMap(unitId,subUnitId),comments=Array.from(commentMap.values()).filter(comment=>!comment.parentId),ids=comments.map(comment=>comment.id),shouldSync=this._threadCommentDataSourceService.syncUpdateMutationToColla,redos=ids.map(id=>({id:threadComment.DeleteCommentMutation.id,params:{unitId,subUnitId,commentId:id}})),undos=comments.map(({children,...comment})=>({id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId,comment:{...comment,children:shouldSync?children:void 0},sync:!shouldSync}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_f,"ThreadCommentRemoveSheetsController"),_f);ThreadCommentRemoveSheetsController=__decorateClass$2([__decorateParam$2(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$2(1,core.IUniverInstanceService),__decorateParam$2(2,core.Inject(threadComment.ThreadCommentModel)),__decorateParam$2(3,threadComment.IThreadCommentDataSourceService)],ThreadCommentRemoveSheetsController);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=react.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=react.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return react.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CommentSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const SheetsThreadCommentCell=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports2.SheetsThreadCommentPopupService),activePopup=ui.useObservable(sheetsThreadCommentPopupService.activePopup$),sheetThreadCommentModel=core.useDependency(sheetsThreadComment.SheetsThreadCommentModel);if(ui.useObservable(sheetThreadCommentModel.commentUpdate$),!activePopup)return null;const{row,col,unitId,subUnitId,trigger}=activePopup,rootId=sheetThreadCommentModel.getByLocation(unitId,subUnitId,row,col),ref=`${core.Tools.chatAtABC(col)}${row+1}`,onClose=__name(()=>{sheetsThreadCommentPopupService.hidePopup()},"onClose"),getSubUnitName=__name(id=>{var _a2,_b2,_c2;return(_c2=(_b2=(_a2=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getSheetBySheetId(id))==null?void 0:_b2.getName())!=null?_c2:""},"getSubUnitName");return jsxRuntime.jsx(threadCommentUi.ThreadCommentTree,{onClick:__name(()=>{sheetsThreadCommentPopupService.persistPopup()},"onClick"),prefix:"cell",id:rootId,unitId,subUnitId,type:core.UniverInstanceType.UNIVER_SHEET,refStr:ref,onClose,getSubUnitName,autoFocus:trigger==="context-menu"})},"SheetsThreadCommentCell"),SheetsThreadCommentPanel=__name(()=>{var _a2;const markSelectionService=core.useDependency(sheetsUi.IMarkSelectionService),univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports2.SheetsThreadCommentPopupService),workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),unitId=workbook.getUnitId(),commandService=core.useDependency(core.ICommandService),subUnitId$=react.useMemo(()=>workbook.activeSheet$.pipe(rxjs.map(i=>i==null?void 0:i.getSheetId())),[workbook.activeSheet$]),subUnitId=ui.useObservable(subUnitId$,(_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId()),hoverShapeId=react.useRef(null),panelService=core.useDependency(threadCommentUi.ThreadCommentPanelService),activeCommentId=ui.useObservable(panelService.activeCommentId$),panelVisible=ui.useObservable(panelService.panelVisible$,panelService.panelVisible),sortComments=react.useCallback(comments=>{const worksheets=workbook.getSheets(),sheetIndex={};worksheets.forEach((sheet,i)=>{sheetIndex[sheet.getSheetId()]=i});const sort=__name(comments2=>comments2.map(comment=>{var _a3;const ref=engineFormula.singleReferenceToGrid(comment.ref),p=[(_a3=sheetIndex[comment.subUnitId])!=null?_a3:0,ref.row,ref.column];return{...comment,p}}).sort((pre,aft)=>pre.p[0]===aft.p[0]?pre.p[1]===aft.p[1]?pre.p[2]-aft.p[2]:pre.p[1]-aft.p[1]:pre.p[0]-aft.p[0]),"sort");return[...sort(comments.filter(comment=>!comment.resolved)),...sort(comments.filter(comment=>comment.resolved))]},[workbook]),showShape=react.useCallback(comment=>{var _a3;if(comment.unitId===unitId&&comment.subUnitId===subUnitId&&!comment.resolved){const{row,column}=engineFormula.singleReferenceToGrid(comment.ref),worksheet=workbook.getSheetBySheetId(comment.subUnitId),mergeInfo=(_a3=worksheet==null?void 0:worksheet.getMergedCell(row,column))!=null?_a3:{startColumn:column,endColumn:column,startRow:row,endRow:row};if(!Number.isNaN(row)&&!Number.isNaN(column))return markSelectionService.addShape({range:mergeInfo,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[markSelectionService,subUnitId,unitId]),getSubUnitName=__name(id=>{var _a3,_b2;return(_b2=(_a3=workbook.getSheetBySheetId(id))==null?void 0:_a3.getName())!=null?_b2:""},"getSubUnitName"),handleAdd=__name(()=>{commandService.executeCommand(ShowAddSheetCommentModalOperation.id)},"handleAdd"),handleHover=__name(comment=>{activeCommentId&&activeCommentId.unitId===comment.unitId&&activeCommentId.subUnitId===comment.subUnitId&&activeCommentId.commentId===comment.id||(hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null),hoverShapeId.current=showShape(comment))},"handleHover"),handleLeave=__name(()=>{hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null)},"handleLeave"),handleResolve=__name((id,resolved)=>{resolved&&sheetsThreadCommentPopupService.hidePopup()},"handleResolve");return react.useEffect(()=>{!panelVisible&&hoverShapeId.current&&markSelectionService.removeShape(hoverShapeId.current)},[markSelectionService,panelVisible]),jsxRuntime.jsx(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_SHEET,onAdd:handleAdd,getSubUnitName,onResolve:handleResolve,sortComments,onItemEnter:handleHover,onItemLeave:handleLeave,onDeleteComment:__name(()=>(handleLeave(),!0),"onDeleteComment")})},"SheetsThreadCommentPanel"),threadCommentMenuFactory=__name(accessor=>({id:ShowAddSheetCommentModalOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,title:"sheetThreadComment.menu.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]})}),"threadCommentMenuFactory"),threadPanelMenuFactory=__name(accessor=>({id:threadCommentUi.ToggleSheetCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]}),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET)}),"threadPanelMenuFactory"),AddCommentShortcut={id:ShowAddSheetCommentModalOperation.id,binding:ui.KeyCode.M|ui.MetaKeys.CTRL_COMMAND|ui.MetaKeys.ALT,preconditions:sheetsUi.whenSheetEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[threadCommentUi.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:threadPanelMenuFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{[ShowAddSheetCommentModalOperation.id]:{order:0,menuItemFactory:threadCommentMenuFactory}}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let SheetsThreadCommentController=(_g=class extends core.Disposable{constructor(_menuManagerService,_componentManager,_shortcutService){super(),this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._shortcutService=_shortcutService,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(AddCommentShortcut)}_initMenu(){this._menuManagerService.mergeMenu(menuSchema)}_initComponent(){[[SHEETS_THREAD_COMMENT_MODAL,SheetsThreadCommentCell],[threadCommentUi.THREAD_COMMENT_PANEL,SheetsThreadCommentPanel],[COMMENT_SINGLE_ICON,CommentSingle]].forEach(([key,comp])=>{this._componentManager.register(key,comp)})}},__name(_g,"SheetsThreadCommentController"),_g);SheetsThreadCommentController=__decorateClass$1([__decorateParam$1(0,ui.IMenuManagerService),__decorateParam$1(1,core.Inject(ui.ComponentManager)),__decorateParam$1(2,ui.IShortcutService)],SheetsThreadCommentController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsThreadCommentUIPlugin=(_h=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=core.merge({},defaultPluginConfig,this._config);menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsThreadCommentController],[SheetsThreadCommentRenderController],[SheetsThreadCommentCopyPasteController],[SheetsThreadCommentHoverController],[ThreadCommentRemoveSheetsController],[SheetsThreadCommentPopupController],[exports2.SheetsThreadCommentPopupService]].forEach(dep=>{this._injector.add(dep)}),[ShowAddSheetCommentModalOperation].forEach(command=>{this._commandService.registerCommand(command)}),this._injector.get(SheetsThreadCommentController)}onReady(){this._injector.get(SheetsThreadCommentRenderController),this._injector.get(ThreadCommentRemoveSheetsController)}onRendered(){this._injector.get(SheetsThreadCommentCopyPasteController),this._injector.get(SheetsThreadCommentHoverController),this._injector.get(SheetsThreadCommentPopupController)}},__name(_h,"UniverSheetsThreadCommentUIPlugin"),_h),__publicField2(exports2.UniverSheetsThreadCommentUIPlugin,"pluginName",SHEETS_THREAD_COMMENT),__publicField2(exports2.UniverSheetsThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin,sheetsThreadComment.UniverSheetsThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.ICommandService)),__decorateParam(3,core.IConfigService)],exports2.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(exports2,"UniverThreadCommentUIPlugin",{enumerable:!0,get:__name(()=>threadCommentUi.UniverThreadCommentUIPlugin,"get")}),Object.defineProperty(exports2,"AddCommentCommand",{enumerable:!0,get:__name(()=>threadComment.AddCommentCommand,"get")}),Object.defineProperty(exports2,"DeleteCommentCommand",{enumerable:!0,get:__name(()=>threadComment.DeleteCommentCommand,"get")}),Object.defineProperty(exports2,"DeleteCommentTreeCommand",{enumerable:!0,get:__name(()=>threadComment.DeleteCommentTreeCommand,"get")}),Object.defineProperty(exports2,"IThreadCommentDataSourceService",{enumerable:!0,get:__name(()=>threadComment.IThreadCommentDataSourceService,"get")}),Object.defineProperty(exports2,"ResolveCommentCommand",{enumerable:!0,get:__name(()=>threadComment.ResolveCommentCommand,"get")}),Object.defineProperty(exports2,"UpdateCommentCommand",{enumerable:!0,get:__name(()=>threadComment.UpdateCommentCommand,"get")}),exports2.SHEETS_THREAD_COMMENT=SHEETS_THREAD_COMMENT,exports2.ShowAddSheetCommentModalOperation=ShowAddSheetCommentModalOperation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/lib/umd/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiEnUS=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"Add Comment",commentManagement:"Comment Management"}}}});
|
package/lib/umd/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiFaIR=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"افزودن نظر",commentManagement:"مدیریت نظر"}}}});
|
package/lib/umd/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiFrFR=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"Ajouter un commentaire",commentManagement:"Gestion des commentaires"}}}});
|
package/lib/umd/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiRuRU=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"Add Comment",commentManagement:"Comment Management"}}}});
|
package/lib/umd/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiViVN=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"Thêm bình luận",commentManagement:"Quản lý bình luận"}}}});
|
package/lib/umd/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiZhCN=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"添加评论",commentManagement:"评论管理"}}}});
|
package/lib/umd/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverSheetsThreadCommentUiZhTW=factory())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"新增評論",commentManagement:"評論管理"}}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment-ui",
|
|
3
|
-
"version": "0.5.5-nightly.
|
|
3
|
+
"version": "0.5.5-nightly.202501221606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,21 +48,21 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"react": "
|
|
51
|
+
"react": ">=16.9.0 || >=17 || >=18 || >=19",
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.2.12",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/thread-comment
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/ui": "0.5.5-nightly.
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/core": "0.5.5-nightly.202501221606",
|
|
58
|
+
"@univerjs/engine-render": "0.5.5-nightly.202501221606",
|
|
59
|
+
"@univerjs/sheets": "0.5.5-nightly.202501221606",
|
|
60
|
+
"@univerjs/engine-formula": "0.5.5-nightly.202501221606",
|
|
61
|
+
"@univerjs/sheets-thread-comment": "0.5.5-nightly.202501221606",
|
|
62
|
+
"@univerjs/thread-comment": "0.5.5-nightly.202501221606",
|
|
63
|
+
"@univerjs/sheets-ui": "0.5.5-nightly.202501221606",
|
|
64
|
+
"@univerjs/thread-comment-ui": "0.5.5-nightly.202501221606",
|
|
65
|
+
"@univerjs/ui": "0.5.5-nightly.202501221606"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"postcss": "^8.4.49",
|