@univerjs/sheets-thread-comment 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +34 -36
- package/lib/types/controllers/menu.d.ts +1 -1
- package/lib/types/controllers/sheets-thread-comment.controller.d.ts +1 -2
- package/lib/types/index.d.ts +2 -2
- package/lib/types/plugin.d.ts +1 -2
- package/lib/umd/index.js +1 -1
- package/package.json +18 -20
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var se=Object.defineProperty;var ae=(o,r,t)=>r in o?se(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t;var E=(o,r,t)=>ae(o,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@wendellhu/redi"),a=require("@univerjs/core"),M=require("@univerjs/thread-comment-ui"),f=require("@univerjs/ui"),S=require("@univerjs/sheets"),V=require("@univerjs/engine-formula"),U=require("@univerjs/thread-comment"),I=require("@univerjs/sheets-ui"),$=require("@univerjs/sheets-thread-comment-base"),N=require("@wendellhu/redi/react-bindings"),b=require("react"),Z=require("rxjs"),ce=require("@univerjs/engine-render");var y=function(){return y=Object.assign||function(o){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o[n]=r[n])}return o},y.apply(this,arguments)},me=function(o,r){var t={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(t[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(o);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(o,e[n])&&(t[e[n]]=o[e[n]]);return t},Q=b.forwardRef(function(o,r){var t=o.icon,e=o.id,n=o.className,i=o.extend,s=me(o,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=b.useRef("_".concat(ue()));return ee(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},y({ref:r,className:m},s),i)});function ee(o,r,t,e,n){return b.createElement(o.tag,y(y({key:r},he(o,t,n)),e),(de(o,t).children||[]).map(function(i,s){return ee(i,"".concat(r,"-").concat(o.tag,"-").concat(s),t,void 0,n)}))}function he(o,r,t){var e=y({},o.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var n=r.defIds;return!n||n.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],m=i[1];typeof m=="string"&&(e[s]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function de(o,r){var t,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((t=o.children)===null||t===void 0)&&t.length)?y(y({},o),{children:o.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?y(y({},n),{attrs:y(y({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):o}function ue(){return Math.random().toString(36).substring(2,8)}Q.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"}}]},te=b.forwardRef(function(o,r){return b.createElement(Q,Object.assign({},o,{id:"comment-single",ref:r,icon:le}))});te.displayName="CommentSingle";const ne="univer.sheet.thread-comment-modal",G="comment-single",K="SHEET_THREAD_COMMENT";var pe=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,Ce=(o,r,t,e)=>{for(var n=e>1?void 0:e?ve(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&pe(r,t,n),n},X=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(t,e){super();E(this,"_lastPopup",null);E(this,"_activePopup");E(this,"_activePopup$",new Z.BehaviorSubject(null));E(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=t,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this.hidePopup()}))}showPopup(t,e){var h;const{row:n,col:i,unitId:s,subUnitId:m}=t;if(this._activePopup&&n===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&m===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=t,this._activePopup$.next(t);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=t,this._activePopup$.next(t);const c=this._canvasPopupManagerService.attachPopupToCell(n,i,{componentKey:ne,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!c)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(c),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=Ce([X(0,l.Inject(I.SheetCanvasPopManagerService)),X(1,f.IZenZoneService)],exports.SheetsThreadCommentPopupService);const Se=()=>{const o=N.useDependency(a.IUniverInstanceService),r=N.useDependency(exports.SheetsThreadCommentPopupService),t=f.useObservable(r.activePopup$),e=N.useDependency($.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!t)return null;const{row:n,col:i,unitId:s,subUnitId:m,trigger:c}=t,d=e.getByLocation(s,m,n,i),h=`${a.Tools.chatAtABC(i)}${n+1}`,v=()=>{r.hidePopup()},p=C=>{var _,j,g;return(g=(j=(_=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getSheetBySheetId(C))==null?void 0:j.getName())!=null?g:""};return b.createElement(M.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:m,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:v,getSubUnitName:p,autoFocus:c==="context-menu"})},H={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var _;const r=o.get(S.SheetsSelectionsService),t=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),n=o.get(M.ThreadCommentPanelService),i=(_=r.getCurrentLastSelection())==null?void 0:_.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const m=S.getSheetCommandTarget(t);if(!m)return!1;const{workbook:c,worksheet:d,unitId:h,subUnitId:v}=m,p={workbook:c,worksheet:d,unitId:h,subUnitId:v,row:i.startRow,col:i.startColumn};e.showPopup(p);const C=s.getByLocation(h,v,i.startRow,i.startColumn);return C&&n.setActiveComment({unitId:h,subUnitId:v,commentId:C,trigger:"context-menu"}),!0}},fe=()=>{var k;const o=N.useDependency(I.IMarkSelectionService),r=N.useDependency(a.IUniverInstanceService),t=N.useDependency(exports.SheetsThreadCommentPopupService),e=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),i=N.useDependency(a.ICommandService),s=b.useMemo(()=>e.activeSheet$.pipe(Z.map(u=>u==null?void 0:u.getSheetId())),[e.activeSheet$]),m=f.useObservable(s,(k=e.getActiveSheet())==null?void 0:k.getSheetId()),c=b.useRef(),d=N.useDependency(M.ThreadCommentPanelService),h=f.useObservable(d.activeCommentId$),v=f.useObservable(d.panelVisible$,d.panelVisible),p=b.useCallback(u=>{const T=e.getSheets(),P={};T.forEach((R,w)=>{P[R.getSheetId()]=w});const x=R=>R.map(w=>{var Y;const D=V.singleReferenceToGrid(w.ref),ie=[(Y=P[w.subUnitId])!=null?Y:0,D.row,D.column];return{...w,p:ie}}).sort((w,D)=>w.p[0]===D.p[0]?w.p[1]===D.p[1]?w.p[2]-D.p[2]:w.p[1]-D.p[1]:w.p[0]-D.p[0]);return[...x(u.filter(R=>!R.resolved)),...x(u.filter(R=>R.resolved))]},[e]),C=b.useCallback(u=>{if(u.unitId===n&&u.subUnitId===m&&!u.resolved){const{row:T,column:P}=V.singleReferenceToGrid(u.ref);if(!Number.isNaN(T)&&!Number.isNaN(P))return o.addShape({range:{startColumn:P,endColumn:P,startRow:T,endRow:T},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,m,n]),_=u=>{var T,P;return(P=(T=e.getSheetBySheetId(u))==null?void 0:T.getName())!=null?P:""},j=()=>{i.executeCommand(H.id)},g=u=>{h&&h.unitId===u.unitId&&h.subUnitId===u.subUnitId&&h.commentId===u.id||(c.current&&(o.removeShape(c.current),c.current=null),c.current=C(u))},A=()=>{c.current&&(o.removeShape(c.current),c.current=null)},L=(u,T)=>{T&&t.hidePopup()};return b.useEffect(()=>{!v&&c.current&&o.removeShape(c.current)},[o,v]),b.createElement(M.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:j,getSubUnitName:_,onResolve:L,sortComments:p,onItemEnter:g,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},_e=o=>({id:H.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:G,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]})}),Ie=o=>({id:M.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:G,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),ge={id:H.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused};var Te=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,be=(o,r,t,e)=>{for(var n=e>1?void 0:e?Pe(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Te(r,t,n),n},O=(o,r)=>(t,e)=>r(t,e,o);const ye={};exports.SheetsThreadCommentController=class extends a.Disposable{constructor(t,e,n,i,s,m,c,d,h,v,p,C){super();E(this,"_isSwitchToCommenting",!1);E(this,"_selectionShapeInfo",null);this._config=t,this._menuService=e,this._injector=n,this._componentManager=i,this._commandService=s,this._sheetsThreadCommentPopupService=m,this._sheetsThreadCommentModel=c,this._threadCommentPanelService=d,this._shortcutService=h,this._univerInstanceService=v,this._sheetPermissionInterceptorBaseController=p,this._markSelectionService=C,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(ge)}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===S.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const e=t.params,{unitId:n,subUnitId:i,selections:s,type:m}=e;if((m===S.SelectionMoveType.MOVE_END||m===void 0)&&s[0].primary){const c=s[0].range;if(c.endColumn-c.startColumn>0||c.endRow-c.startRow>0)return;const d=s[0].primary.actualRow,h=s[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,i,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(M.SetActiveCommentOperation.id);return}const v=this._sheetsThreadCommentModel.getByLocation(n,i,d,h);v&&this._commandService.executeCommand(M.SetActiveCommentOperation.id,{unitId:n,subUnitId:i,commentId:v})}}if(t.id===U.DeleteCommentMutation.id){const e=t.params,n=this._sheetsThreadCommentPopupService.activePopup;if(!n)return;const{unitId:i,subUnitId:s,commentId:m}=n;e.unitId===i&&e.subUnitId===s&&e.commentId===m&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:t={}}=this._config;[_e,Ie].forEach(e=>{this._menuService.addMenuItem(e(this._injector),t)})}_initComponent(){[[ne,Se],[M.THREAD_COMMENT_PANEL,fe],[G,te]].forEach(([t,e])=>{this._componentManager.register(t,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var e;if(t){const{unitId:n,subUnitId:i,commentId:s,trigger:m}=t,c=this._sheetsThreadCommentModel.getComment(n,i,s);if(!c||c.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==n)return;this._isSwitchToCommenting=!0,((e=d.getActiveSheet())==null?void 0:e.getSheetId())!==i&&await this._commandService.executeCommand(S.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:i}),this._isSwitchToCommenting=!1;const p=V.singleReferenceToGrid(c.ref),{row:C,column:_}=p;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]},[{startRow:C,startColumn:_,endRow:C,endColumn:_}]))return;const g=1;await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-g,0),endRow:p.row+g,startColumn:Math.max(p.column-g,0),endColumn:p.column+g}}),this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:p.row,col:p.column,commentId:c.id,trigger:m})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(t=>{if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:n,commentId:i}=t;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===n&&this._selectionShapeInfo.commentId===i)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const s=this._sheetsThreadCommentModel.getComment(e,n,i);if(!s)return;const m=V.singleReferenceToGrid(s.ref),{row:c,column:d}=m;if(Number.isNaN(c)||Number.isNaN(d))return;const h=this._markSelectionService.addShape({range:{startColumn:d,endColumn:d,startRow:c,endRow:c},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};exports.SheetsThreadCommentController=be([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetsThreadCommentController),O(1,f.IMenuService),O(2,l.Inject(l.Injector)),O(3,l.Inject(f.ComponentManager)),O(4,a.ICommandService),O(5,l.Inject(exports.SheetsThreadCommentPopupService)),O(6,l.Inject($.SheetsThreadCommentModel)),O(7,l.Inject(M.ThreadCommentPanelService)),O(8,f.IShortcutService),O(9,a.IUniverInstanceService),O(10,l.Inject(I.SheetPermissionInterceptorBaseController)),O(11,I.IMarkSelectionService)],exports.SheetsThreadCommentController);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(o,r,t,e)=>{for(var n=e>1?void 0:e?we(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Me(r,t,n),n},B=(o,r)=>(t,e)=>r(t,e,o);let q=class extends a.Disposable{constructor(o,r,t,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=t,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,t)=>{const{row:e,col:n,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,n)?t({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):t(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const t=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const n=this._renderManagerService.getRenderById(t),i=n==null?void 0:n.with(I.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),n&&n.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(Z.debounceTime(16)).subscribe(r=>{o()}))}};q=Oe([a.OnLifecycle(a.LifecycleStages.Ready,q),B(0,l.Inject(S.SheetInterceptorService)),B(1,l.Inject($.SheetsThreadCommentModel)),B(2,a.IUniverInstanceService),B(3,ce.IRenderManagerService)],q);var Ue=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ee=(o,r,t,e)=>{for(var n=e>1?void 0:e?Re(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ue(r,t,n),n},z=(o,r)=>(t,e)=>r(t,e,o);const je=(o,r,t)=>{const e=V.singleReferenceToGrid(o),n=t.row-r.row,i=t.column-r.column,s={startColumn:e.column+i,startRow:e.row+n,endColumn:e.column+i,endRow:e.row+n};return V.serializeRange(s)};exports.SheetsThreadCommentCopyPasteController=class extends a.Disposable{constructor(t,e,n){super();E(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=n,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:K,onBeforeCopy:(t,e,n)=>{this._copyInfo={unitId:t,subUnitId:e,range:n}},onPasteCells:(t,e,n,i)=>{const{unitId:s,subUnitId:m,range:c}=e,d={row:c.rows[0],column:c.cols[0]};if(i.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:v,subUnitId:p}=this._copyInfo,C={row:h.startRow,column:h.startColumn};if(!(s===v&&m===p)){const _=[];a.Range.foreach(h,(u,T)=>{const P=this._sheetsThreadCommentModel.getAllByLocation(v,p,u,T);this._threadCommentDataSourceService.syncUpdateMutationToColla?P.forEach(x=>{_.push(x)}):P.forEach(({children:x,...R})=>{R.parentId||_.push(R)})});const j=[],g=[],A=[],L=[],k=u=>{j.unshift({id:U.DeleteCommentMutation.id,params:{unitId:v,subUnitId:p,commentId:u.id}}),A.push({id:U.AddCommentMutation.id,params:{unitId:s,subUnitId:m,comment:{...u,ref:je(u.ref,C,d),unitId:s,subUnitId:m},sync:!0}}),g.push({id:U.AddCommentMutation.id,params:{unitId:v,subUnitId:p,comment:u,sync:!0}}),L.unshift({id:U.DeleteCommentMutation.id,params:{unitId:s,subUnitId:m,commentId:u.id}})};return _.forEach(u=>{k(u)}),{redos:[...j,...A],undos:[...L,...g]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=Ee([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),z(0,l.Inject(I.ISheetClipboardService)),z(1,l.Inject($.SheetsThreadCommentModel)),z(2,U.IThreadCommentDataSourceService)],exports.SheetsThreadCommentCopyPasteController);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,r,t,e)=>{for(var n=e>1?void 0:e?Ne(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&De(r,t,n),n},F=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentHoverController=class extends a.Disposable{constructor(r,t,e,n){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=n,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(Z.debounceTime(100)).subscribe(r=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(r&&(t&&t.temp||!t)){const{location:e}=r,{unitId:n,subUnitId:i,row:s,col:m}=e,c=this._sheetsThreadCommentModel.getByLocation(n,i,s,m);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:m,endRow:s,endColumn:m}]))return;const h=this._sheetsThreadCommentModel.getComment(n,i,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:s,col:m,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=$e([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),F(0,l.Inject(I.HoverManagerService)),F(1,l.Inject(exports.SheetsThreadCommentPopupService)),F(2,l.Inject($.SheetsThreadCommentModel)),F(3,l.Inject(I.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentHoverController);var Ve=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(o,r,t,e)=>{for(var n=e>1?void 0:e?Ae(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ve(r,t,n),n},W=(o,r)=>(t,e)=>r(t,e,o);exports.ThreadCommentRemoveSheetsController=class extends a.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===S.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:m}=this._threadCommentModel.ensureMap(i,s),c=Array.from(Object.values(m)).filter(C=>!C.parentId),d=c.map(C=>C.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,v=d.map(C=>({id:U.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:C}})),p=c.map(({children:C,..._})=>({id:U.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{..._,children:h?C:void 0},sync:!h}}));return{redos:v,undos:p}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=xe([a.OnLifecycle(a.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),W(0,l.Inject(S.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,l.Inject(U.ThreadCommentModel)),W(3,U.IThreadCommentDataSourceService)],exports.ThreadCommentRemoveSheetsController);var re=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Le=(o,r,t)=>r in o?re(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,ke=(o,r,t,e)=>{for(var n=e>1?void 0:e?He(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&re(r,t,n),n},J=(o,r)=>(t,e)=>r(t,e,o),oe=(o,r,t)=>Le(o,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsThreadCommentPlugin=class extends a.Plugin{constructor(t={},e,n){super();E(this,"_pluginConfig");this._injector=e,this._commandService=n,this._pluginConfig=a.Tools.deepMerge({},ye,t)}onStarting(t){[[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[q],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(e=>{t.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}};oe(exports.UniverSheetsThreadCommentPlugin,"pluginName",K);oe(exports.UniverSheetsThreadCommentPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=ke([a.DependentOn(M.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentBasePlugin),J(1,l.Inject(l.Injector)),J(2,l.Inject(a.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>l.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>l.Injector});Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>a.ICommandService});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>a.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>a.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>M.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>M.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>U.IThreadCommentDataSourceService});Object.defineProperty(exports,"SheetsThreadCommentModel",{enumerable:!0,get:()=>$.SheetsThreadCommentModel});exports.SHEETS_THREAD_COMMENT=K;exports.ShowAddSheetCommentModalOperation=H;
|
|
1
|
+
"use strict";var oe=Object.defineProperty;var ie=(o,r,t)=>r in o?oe(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t;var R=(o,r,t)=>ie(o,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),y=require("@univerjs/thread-comment-ui"),S=require("@univerjs/ui"),C=require("@univerjs/sheets"),N=require("@univerjs/engine-formula"),O=require("@univerjs/thread-comment"),_=require("@univerjs/sheets-ui"),D=require("@univerjs/sheets-thread-comment-base"),P=require("react"),W=require("rxjs"),se=require("@univerjs/engine-render");var b=function(){return b=Object.assign||function(o){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o[n]=r[n])}return o},b.apply(this,arguments)},ae=function(o,r){var t={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(t[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(o);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(o,e[n])&&(t[e[n]]=o[e[n]]);return t},X=P.forwardRef(function(o,r){var t=o.icon,e=o.id,n=o.className,i=o.extend,s=ae(o,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=P.useRef("_".concat(he()));return J(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},b({ref:r,className:m},s),i)});function J(o,r,t,e,n){return P.createElement(o.tag,b(b({key:r},ce(o,t,n)),e),(me(o,t).children||[]).map(function(i,s){return J(i,"".concat(r,"-").concat(o.tag,"-").concat(s),t,void 0,n)}))}function ce(o,r,t){var e=b({},o.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var n=r.defIds;return!n||n.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],m=i[1];typeof m=="string"&&(e[s]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function me(o,r){var t,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((t=o.children)===null||t===void 0)&&t.length)?b(b({},o),{children:o.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?b(b({},n),{attrs:b(b({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):o}function he(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var de={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"}}]},Q=P.forwardRef(function(o,r){return P.createElement(X,Object.assign({},o,{id:"comment-single",ref:r,icon:de}))});Q.displayName="CommentSingle";const ee="univer.sheet.thread-comment-modal",Z="comment-single",z="SHEET_THREAD_COMMENT";var ue=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(o,r,t,e)=>{for(var n=e>1?void 0:e?le(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&ue(r,t,n),n},K=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(t,e){super();R(this,"_lastPopup",null);R(this,"_activePopup");R(this,"_activePopup$",new W.BehaviorSubject(null));R(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=t,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this.hidePopup()}))}showPopup(t,e){var h;const{row:n,col:i,unitId:s,subUnitId:m}=t;if(this._activePopup&&n===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&m===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=t,this._activePopup$.next(t);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=t,this._activePopup$.next(t);const c=this._canvasPopupManagerService.attachPopupToCell(n,i,{componentKey:ee,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!c)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(c),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=pe([K(0,a.Inject(_.SheetCanvasPopManagerService)),K(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const ve=()=>{const o=a.useDependency(a.IUniverInstanceService),r=a.useDependency(exports.SheetsThreadCommentPopupService),t=S.useObservable(r.activePopup$),e=a.useDependency(D.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!t)return null;const{row:n,col:i,unitId:s,subUnitId:m,trigger:c}=t,d=e.getByLocation(s,m,n,i),h=`${a.Tools.chatAtABC(i)}${n+1}`,p=()=>{r.hidePopup()},l=v=>{var f,E,I;return(I=(E=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:E.getName())!=null?I:""};return P.createElement(y.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:m,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:p,getSubUnitName:l,autoFocus:c==="context-menu"})},A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const r=o.get(C.SheetsSelectionsService),t=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),n=o.get(y.ThreadCommentPanelService),i=(f=r.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(D.SheetsThreadCommentModel);if(!i)return!1;const m=C.getSheetCommandTarget(t);if(!m)return!1;const{workbook:c,worksheet:d,unitId:h,subUnitId:p}=m,l={workbook:c,worksheet:d,unitId:h,subUnitId:p,row:i.startRow,col:i.startColumn};e.showPopup(l);const v=s.getByLocation(h,p,i.startRow,i.startColumn);return v&&n.setActiveComment({unitId:h,subUnitId:p,commentId:v,trigger:"context-menu"}),!0}},Ce=()=>{var H;const o=a.useDependency(_.IMarkSelectionService),r=a.useDependency(a.IUniverInstanceService),t=a.useDependency(exports.SheetsThreadCommentPopupService),e=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),i=a.useDependency(a.ICommandService),s=P.useMemo(()=>e.activeSheet$.pipe(W.map(u=>u==null?void 0:u.getSheetId())),[e.activeSheet$]),m=S.useObservable(s,(H=e.getActiveSheet())==null?void 0:H.getSheetId()),c=P.useRef(),d=a.useDependency(y.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),p=S.useObservable(d.panelVisible$,d.panelVisible),l=P.useCallback(u=>{const g=e.getSheets(),T={};g.forEach((U,M)=>{T[U.getSheetId()]=M});const V=U=>U.map(M=>{var G;const j=N.singleReferenceToGrid(M.ref),re=[(G=T[M.subUnitId])!=null?G:0,j.row,j.column];return{...M,p:re}}).sort((M,j)=>M.p[0]===j.p[0]?M.p[1]===j.p[1]?M.p[2]-j.p[2]:M.p[1]-j.p[1]:M.p[0]-j.p[0]);return[...V(u.filter(U=>!U.resolved)),...V(u.filter(U=>U.resolved))]},[e]),v=P.useCallback(u=>{if(u.unitId===n&&u.subUnitId===m&&!u.resolved){const{row:g,column:T}=N.singleReferenceToGrid(u.ref);if(!Number.isNaN(g)&&!Number.isNaN(T))return o.addShape({range:{startColumn:T,endColumn:T,startRow:g,endRow:g},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,m,n]),f=u=>{var g,T;return(T=(g=e.getSheetBySheetId(u))==null?void 0:g.getName())!=null?T:""},E=()=>{i.executeCommand(A.id)},I=u=>{h&&h.unitId===u.unitId&&h.subUnitId===u.subUnitId&&h.commentId===u.id||(c.current&&(o.removeShape(c.current),c.current=null),c.current=v(u))},$=()=>{c.current&&(o.removeShape(c.current),c.current=null)},x=(u,g)=>{g&&t.hidePopup()};return P.useEffect(()=>{!p&&c.current&&o.removeShape(c.current)},[o,p]),P.createElement(y.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:f,onResolve:x,sortComments:l,onItemEnter:I,onItemLeave:$,onDeleteComment:()=>($(),!0)})},Se=o=>({id:A.id,type:S.MenuItemType.BUTTON,positions:[S.MenuPosition.CONTEXT_MENU],icon:Z,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),fe=o=>({id:y.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:Z,tooltip:"sheetThreadComment.menu.commentManagement",positions:S.MenuPosition.TOOLBAR_START,group:S.MenuGroup.TOOLBAR_OTHERS,disabled$:_.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),_e={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:_.whenSheetEditorFocused};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Te=(o,r,t,e)=>{for(var n=e>1?void 0:e?ge(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ie(r,t,n),n},w=(o,r)=>(t,e)=>r(t,e,o);const Pe={};exports.SheetsThreadCommentController=class extends a.Disposable{constructor(t,e,n,i,s,m,c,d,h,p,l,v){super();R(this,"_isSwitchToCommenting",!1);R(this,"_selectionShapeInfo",null);this._config=t,this._menuService=e,this._injector=n,this._componentManager=i,this._commandService=s,this._sheetsThreadCommentPopupService=m,this._sheetsThreadCommentModel=c,this._threadCommentPanelService=d,this._shortcutService=h,this._univerInstanceService=p,this._sheetPermissionInterceptorBaseController=l,this._markSelectionService=v,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(_e)}_initCommandListener(){this._commandService.onCommandExecuted(t=>{var e;if(t.id===C.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const n=t.params,{unitId:i,subUnitId:s,selections:m,type:c}=n;if((c===C.SelectionMoveType.MOVE_END||c===void 0)&&((e=m[0])!=null&&e.primary)){const d=m[0].range;if(d.endColumn-d.startColumn>0||d.endRow-d.startRow>0)return;const h=m[0].primary.actualRow,p=m[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(i,s,h,p)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(y.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(i,s,h,p);l&&this._commandService.executeCommand(y.SetActiveCommentOperation.id,{unitId:i,subUnitId:s,commentId:l})}}if(t.id===O.DeleteCommentMutation.id){const n=t.params,i=this._sheetsThreadCommentPopupService.activePopup;if(!i)return;const{unitId:s,subUnitId:m,commentId:c}=i;n.unitId===s&&n.subUnitId===m&&n.commentId===c&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:t={}}=this._config;[Se,fe].forEach(e=>{this._menuService.addMenuItem(e(this._injector),t)})}_initComponent(){[[ee,ve],[y.THREAD_COMMENT_PANEL,Ce],[Z,Q]].forEach(([t,e])=>{this._componentManager.register(t,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var e;if(t){const{unitId:n,subUnitId:i,commentId:s,trigger:m}=t,c=this._sheetsThreadCommentModel.getComment(n,i,s);if(!c||c.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==n)return;this._isSwitchToCommenting=!0,((e=d.getActiveSheet())==null?void 0:e.getSheetId())!==i&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:i}),this._isSwitchToCommenting=!1;const l=N.singleReferenceToGrid(c.ref),{row:v,column:f}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:f,endRow:v,endColumn:f}]))return;const I=1;await this._commandService.executeCommand(_.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-I,0),endRow:l.row+I,startColumn:Math.max(l.column-I,0),endColumn:l.column+I}}),this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:l.row,col:l.column,commentId:c.id,trigger:m})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(t=>{if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:n,commentId:i}=t;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===n&&this._selectionShapeInfo.commentId===i)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const s=this._sheetsThreadCommentModel.getComment(e,n,i);if(!s)return;const m=N.singleReferenceToGrid(s.ref),{row:c,column:d}=m;if(Number.isNaN(c)||Number.isNaN(d))return;const h=this._markSelectionService.addShape({range:{startColumn:d,endColumn:d,startRow:c,endRow:c},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};exports.SheetsThreadCommentController=Te([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetsThreadCommentController),w(1,S.IMenuService),w(2,a.Inject(a.Injector)),w(3,a.Inject(S.ComponentManager)),w(4,a.ICommandService),w(5,a.Inject(exports.SheetsThreadCommentPopupService)),w(6,a.Inject(D.SheetsThreadCommentModel)),w(7,a.Inject(y.ThreadCommentPanelService)),w(8,S.IShortcutService),w(9,a.IUniverInstanceService),w(10,a.Inject(_.SheetPermissionInterceptorBaseController)),w(11,_.IMarkSelectionService)],exports.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(o,r,t,e)=>{for(var n=e>1?void 0:e?ye(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&be(r,t,n),n},L=(o,r)=>(t,e)=>r(t,e,o);let F=class extends a.Disposable{constructor(o,r,t,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=t,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,t)=>{const{row:e,col:n,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,n)?t({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):t(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const t=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const n=this._renderManagerService.getRenderById(t),i=n==null?void 0:n.with(_.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),n&&n.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(W.debounceTime(16)).subscribe(r=>{o()}))}};F=Me([a.OnLifecycle(a.LifecycleStages.Ready,F),L(0,a.Inject(C.SheetInterceptorService)),L(1,a.Inject(D.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,se.IRenderManagerService)],F);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(o,r,t,e)=>{for(var n=e>1?void 0:e?Oe(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&we(r,t,n),n},q=(o,r)=>(t,e)=>r(t,e,o);const Re=(o,r,t)=>{const e=N.singleReferenceToGrid(o),n=t.row-r.row,i=t.column-r.column,s={startColumn:e.column+i,startRow:e.row+n,endColumn:e.column+i,endRow:e.row+n};return N.serializeRange(s)};exports.SheetsThreadCommentCopyPasteController=class extends a.Disposable{constructor(t,e,n){super();R(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=n,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:z,onBeforeCopy:(t,e,n)=>{this._copyInfo={unitId:t,subUnitId:e,range:n}},onPasteCells:(t,e,n,i)=>{const{unitId:s,subUnitId:m,range:c}=e,d={row:c.rows[0],column:c.cols[0]};if(i.copyType===_.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:p,subUnitId:l}=this._copyInfo,v={row:h.startRow,column:h.startColumn};if(!(s===p&&m===l)){const f=[];a.Range.foreach(h,(u,g)=>{const T=this._sheetsThreadCommentModel.getAllByLocation(p,l,u,g);this._threadCommentDataSourceService.syncUpdateMutationToColla?T.forEach(V=>{f.push(V)}):T.forEach(({children:V,...U})=>{U.parentId||f.push(U)})});const E=[],I=[],$=[],x=[],H=u=>{E.unshift({id:O.DeleteCommentMutation.id,params:{unitId:p,subUnitId:l,commentId:u.id}}),$.push({id:O.AddCommentMutation.id,params:{unitId:s,subUnitId:m,comment:{...u,ref:Re(u.ref,v,d),unitId:s,subUnitId:m},sync:!0}}),I.push({id:O.AddCommentMutation.id,params:{unitId:p,subUnitId:l,comment:u,sync:!0}}),x.unshift({id:O.DeleteCommentMutation.id,params:{unitId:s,subUnitId:m,commentId:u.id}})};return f.forEach(u=>{H(u)}),{redos:[...E,...$],undos:[...x,...I]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=Ue([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),q(0,a.Inject(_.ISheetClipboardService)),q(1,a.Inject(D.SheetsThreadCommentModel)),q(2,O.IThreadCommentDataSourceService)],exports.SheetsThreadCommentCopyPasteController);var Ee=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(o,r,t,e)=>{for(var n=e>1?void 0:e?je(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ee(r,t,n),n},k=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentHoverController=class extends a.Disposable{constructor(r,t,e,n){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=n,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(W.debounceTime(100)).subscribe(r=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(r&&(t&&t.temp||!t)){const{location:e}=r,{unitId:n,subUnitId:i,row:s,col:m}=e,c=this._sheetsThreadCommentModel.getByLocation(n,i,s,m);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:m,endRow:s,endColumn:m}]))return;const h=this._sheetsThreadCommentModel.getComment(n,i,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:s,col:m,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=De([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),k(0,a.Inject(_.HoverManagerService)),k(1,a.Inject(exports.SheetsThreadCommentPopupService)),k(2,a.Inject(D.SheetsThreadCommentModel)),k(3,a.Inject(_.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentHoverController);var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(o,r,t,e)=>{for(var n=e>1?void 0:e?$e(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ne(r,t,n),n},B=(o,r)=>(t,e)=>r(t,e,o);exports.ThreadCommentRemoveSheetsController=class extends a.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===C.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:m}=this._threadCommentModel.ensureMap(i,s),c=Array.from(Object.values(m)).filter(v=>!v.parentId),d=c.map(v=>v.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,p=d.map(v=>({id:O.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:v}})),l=c.map(({children:v,...f})=>({id:O.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...f,children:h?v:void 0},sync:!h}}));return{redos:p,undos:l}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=Ve([a.OnLifecycle(a.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),B(0,a.Inject(C.SheetInterceptorService)),B(1,a.IUniverInstanceService),B(2,a.Inject(O.ThreadCommentModel)),B(3,O.IThreadCommentDataSourceService)],exports.ThreadCommentRemoveSheetsController);var te=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(o,r,t)=>r in o?te(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,He=(o,r,t,e)=>{for(var n=e>1?void 0:e?Ae(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&te(r,t,n),n},Y=(o,r)=>(t,e)=>r(t,e,o),ne=(o,r,t)=>xe(o,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsThreadCommentPlugin=class extends a.Plugin{constructor(t={},e,n){super();R(this,"_pluginConfig");this._injector=e,this._commandService=n,this._pluginConfig=a.Tools.deepMerge({},Pe,t)}onStarting(t){[[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[F],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(e=>{t.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)})}};ne(exports.UniverSheetsThreadCommentPlugin,"pluginName",z);ne(exports.UniverSheetsThreadCommentPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=He([a.DependentOn(y.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),Y(1,a.Inject(a.Injector)),Y(2,a.Inject(a.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>a.ICommandService});Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>a.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>a.Injector});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>a.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>a.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>y.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>y.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>O.IThreadCommentDataSourceService});Object.defineProperty(exports,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel});exports.SHEETS_THREAD_COMMENT=z;exports.ShowAddSheetCommentModalOperation=A;
|
package/lib/es/index.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
var xe = Object.defineProperty;
|
|
2
2
|
var Ve = (o, e, n) => e in o ? xe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
|
|
3
3
|
var w = (o, e, n) => Ve(o, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { Inject as l,
|
|
5
|
-
import { Inject as
|
|
6
|
-
import { Disposable as R, DisposableCollection as Ae, IUniverInstanceService as N, Tools as pe, UniverInstanceType as b, CommandType as je, ICommandService as re, OnLifecycle as B, LifecycleStages as H, Range as Be, DependentOn as He, Plugin as Le } from "@univerjs/core";
|
|
7
|
-
import { ICommandService as In, Plugin as gn, UniverInstanceType as Pn } from "@univerjs/core";
|
|
4
|
+
import { Inject as l, Disposable as R, DisposableCollection as Ae, useDependency as y, IUniverInstanceService as N, Tools as me, UniverInstanceType as b, CommandType as je, ICommandService as re, OnLifecycle as B, LifecycleStages as H, Injector as pe, Range as Be, DependentOn as He, Plugin as Le } from "@univerjs/core";
|
|
5
|
+
import { ICommandService as vn, Inject as _n, Injector as fn, Plugin as Cn, UniverInstanceType as Sn } from "@univerjs/core";
|
|
8
6
|
import { ThreadCommentTree as ke, ThreadCommentPanelService as oe, ThreadCommentPanel as Fe, ToggleSheetCommentPanelOperation as We, SetActiveCommentOperation as ae, THREAD_COMMENT_PANEL as Ze, UniverThreadCommentUIPlugin as ze } from "@univerjs/thread-comment-ui";
|
|
9
|
-
import { IThreadCommentMentionDataService as
|
|
7
|
+
import { IThreadCommentMentionDataService as gn, UniverThreadCommentUIPlugin as Pn } from "@univerjs/thread-comment-ui";
|
|
10
8
|
import { IZenZoneService as Ge, useObservable as V, KeyCode as Ke, MetaKeys as ce, MenuItemType as le, MenuPosition as ve, getMenuHiddenObservable as _e, MenuGroup as Ye, ComponentManager as qe, IMenuService as Xe, IShortcutService as Je } from "@univerjs/ui";
|
|
11
9
|
import { SheetsSelectionsService as Qe, getSheetCommandTarget as et, WorkbookCommentPermission as q, WorksheetViewPermission as X, RangeProtectionPermissionViewPoint as J, SetSelectionsOperation as tt, SelectionMoveType as nt, SetWorksheetActiveOperation as rt, SheetInterceptorService as fe, INTERCEPTOR_POINT as ot, RemoveSheetCommand as it } from "@univerjs/sheets";
|
|
12
10
|
import { singleReferenceToGrid as j, serializeRange as st } from "@univerjs/engine-formula";
|
|
13
11
|
import { DeleteCommentMutation as K, IThreadCommentDataSourceService as Ce, AddCommentMutation as ne, ThreadCommentModel as at } from "@univerjs/thread-comment";
|
|
14
|
-
import { IThreadCommentDataSourceService as
|
|
12
|
+
import { IThreadCommentDataSourceService as bn } from "@univerjs/thread-comment";
|
|
15
13
|
import { SheetCanvasPopManagerService as ct, IMarkSelectionService as Se, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as Ie, SheetPermissionInterceptorBaseController as ge, ScrollToRangeOperation as dt, SheetSkeletonManagerService as ht, ISheetClipboardService as mt, COPY_TYPE as pt, HoverManagerService as lt } from "@univerjs/sheets-ui";
|
|
16
14
|
import { SheetsThreadCommentModel as $, UniverSheetsThreadCommentBasePlugin as vt } from "@univerjs/sheets-thread-comment-base";
|
|
17
|
-
import { SheetsThreadCommentModel as
|
|
18
|
-
import { useDependency as y } from "@wendellhu/redi/react-bindings";
|
|
15
|
+
import { SheetsThreadCommentModel as Mn } from "@univerjs/sheets-thread-comment-base";
|
|
19
16
|
import Pe, { forwardRef as Te, useRef as be, createElement as we, useMemo as _t, useCallback as ue, useEffect as ft } from "react";
|
|
20
17
|
import { BehaviorSubject as Ct, map as St, debounceTime as Me } from "rxjs";
|
|
21
18
|
import { IRenderManagerService as It } from "@univerjs/engine-render";
|
|
@@ -147,7 +144,7 @@ const Et = () => {
|
|
|
147
144
|
const o = y(N), e = y(O), n = V(e.activePopup$), t = y($);
|
|
148
145
|
if (V(t.commentUpdate$), !n)
|
|
149
146
|
return null;
|
|
150
|
-
const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, u = t.getByLocation(s, a, r, i), h = `${
|
|
147
|
+
const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, u = t.getByLocation(s, a, r, i), h = `${me.chatAtABC(i)}${r + 1}`, d = () => {
|
|
151
148
|
e.hidePopup();
|
|
152
149
|
}, p = (v) => {
|
|
153
150
|
var g, f, E;
|
|
@@ -312,33 +309,34 @@ let A = class extends R {
|
|
|
312
309
|
}
|
|
313
310
|
_initCommandListener() {
|
|
314
311
|
this._commandService.onCommandExecuted((e) => {
|
|
312
|
+
var n;
|
|
315
313
|
if (e.id === tt.id) {
|
|
316
314
|
if (this._isSwitchToCommenting)
|
|
317
315
|
return;
|
|
318
|
-
const
|
|
319
|
-
if ((
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
316
|
+
const t = e.params, { unitId: r, subUnitId: i, selections: s, type: a } = t;
|
|
317
|
+
if ((a === nt.MOVE_END || a === void 0) && ((n = s[0]) != null && n.primary)) {
|
|
318
|
+
const c = s[0].range;
|
|
319
|
+
if (c.endColumn - c.startColumn > 0 || c.endRow - c.startRow > 0)
|
|
322
320
|
return;
|
|
323
|
-
const
|
|
324
|
-
if (!this._sheetsThreadCommentModel.showCommentMarker(
|
|
321
|
+
const u = s[0].primary.actualRow, h = s[0].primary.actualColumn;
|
|
322
|
+
if (!this._sheetsThreadCommentModel.showCommentMarker(r, i, u, h)) {
|
|
325
323
|
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ae.id);
|
|
326
324
|
return;
|
|
327
325
|
}
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
unitId:
|
|
331
|
-
subUnitId:
|
|
332
|
-
commentId:
|
|
326
|
+
const d = this._sheetsThreadCommentModel.getByLocation(r, i, u, h);
|
|
327
|
+
d && this._commandService.executeCommand(ae.id, {
|
|
328
|
+
unitId: r,
|
|
329
|
+
subUnitId: i,
|
|
330
|
+
commentId: d
|
|
333
331
|
});
|
|
334
332
|
}
|
|
335
333
|
}
|
|
336
334
|
if (e.id === K.id) {
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
335
|
+
const t = e.params, r = this._sheetsThreadCommentPopupService.activePopup;
|
|
336
|
+
if (!r)
|
|
339
337
|
return;
|
|
340
|
-
const { unitId:
|
|
341
|
-
|
|
338
|
+
const { unitId: i, subUnitId: s, commentId: a } = r;
|
|
339
|
+
t.unitId === i && t.subUnitId === s && t.commentId === a && this._sheetsThreadCommentPopupService.hidePopup();
|
|
342
340
|
}
|
|
343
341
|
});
|
|
344
342
|
}
|
|
@@ -445,7 +443,7 @@ let A = class extends R {
|
|
|
445
443
|
A = Vt([
|
|
446
444
|
B(H.Starting, A),
|
|
447
445
|
T(1, Xe),
|
|
448
|
-
T(2, l(
|
|
446
|
+
T(2, l(pe)),
|
|
449
447
|
T(3, l(qe)),
|
|
450
448
|
T(4, re),
|
|
451
449
|
T(5, l(O)),
|
|
@@ -736,7 +734,7 @@ let Y = class extends Le {
|
|
|
736
734
|
constructor(e = {}, n, t) {
|
|
737
735
|
super();
|
|
738
736
|
w(this, "_pluginConfig");
|
|
739
|
-
this._injector = n, this._commandService = t, this._pluginConfig =
|
|
737
|
+
this._injector = n, this._commandService = t, this._pluginConfig = me.deepMerge({}, At, e);
|
|
740
738
|
}
|
|
741
739
|
onStarting(e) {
|
|
742
740
|
[
|
|
@@ -762,25 +760,25 @@ $e(Y, "pluginName", Re);
|
|
|
762
760
|
$e(Y, "type", b.UNIVER_SHEET);
|
|
763
761
|
Y = Qt([
|
|
764
762
|
He(ze, vt),
|
|
765
|
-
he(1, l(
|
|
763
|
+
he(1, l(pe)),
|
|
766
764
|
he(2, l(re))
|
|
767
765
|
], Y);
|
|
768
766
|
export {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
767
|
+
vn as ICommandService,
|
|
768
|
+
bn as IThreadCommentDataSourceService,
|
|
769
|
+
gn as IThreadCommentMentionDataService,
|
|
770
|
+
_n as Inject,
|
|
771
|
+
fn as Injector,
|
|
772
|
+
Cn as Plugin,
|
|
775
773
|
Re as SHEETS_THREAD_COMMENT,
|
|
776
774
|
A as SheetsThreadCommentController,
|
|
777
775
|
Z as SheetsThreadCommentCopyPasteController,
|
|
778
776
|
z as SheetsThreadCommentHoverController,
|
|
779
|
-
|
|
777
|
+
Mn as SheetsThreadCommentModel,
|
|
780
778
|
O as SheetsThreadCommentPopupService,
|
|
781
779
|
Q as ShowAddSheetCommentModalOperation,
|
|
782
780
|
G as ThreadCommentRemoveSheetsController,
|
|
783
|
-
|
|
781
|
+
Sn as UniverInstanceType,
|
|
784
782
|
Y as UniverSheetsThreadCommentPlugin,
|
|
785
|
-
|
|
783
|
+
Pn as UniverThreadCommentUIPlugin
|
|
786
784
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IMenuItem, IShortcutItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
|
|
2
|
-
import { IAccessor } from '@
|
|
2
|
+
import { IAccessor } from '@univerjs/core';
|
|
3
3
|
|
|
4
4
|
export declare const threadCommentMenuFactory: (accessor: IAccessor) => IMenuItem;
|
|
5
5
|
export declare const threadPanelMenuFactory: (accessor: IAccessor) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DependencyOverride, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
1
|
+
import { DependencyOverride, Disposable, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
|
|
3
|
-
import { Injector } from '@wendellhu/redi';
|
|
4
3
|
import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
|
|
5
4
|
import { IMarkSelectionService, SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
|
|
6
5
|
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export type { Dependency } from '@
|
|
17
|
-
export { Inject, Injector } from '@
|
|
16
|
+
export type { Dependency } from '@univerjs/core';
|
|
17
|
+
export { Inject, Injector } from '@univerjs/core';
|
|
18
18
|
export { ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
19
19
|
export { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
|
|
20
20
|
export { SheetsThreadCommentController } from './controllers/sheets-thread-comment.controller';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Injector } from '@
|
|
2
|
-
import { ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
1
|
+
import { ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
2
|
import { IUniverSheetsThreadCommentConfig } from './controllers/sheets-thread-comment.controller';
|
|
4
3
|
|
|
5
4
|
export declare class UniverSheetsThreadCommentPlugin extends Plugin {
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@wendellhu/redi"),require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-thread-comment-base"),require("@wendellhu/redi/react-bindings"),require("react"),require("rxjs"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@wendellhu/redi","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/ui","@univerjs/sheets","@univerjs/engine-formula","@univerjs/thread-comment","@univerjs/sheets-ui","@univerjs/sheets-thread-comment-base","@wendellhu/redi/react-bindings","react","rxjs","@univerjs/engine-render"],d):(a=typeof globalThis<"u"?globalThis:a||self,d(a.UniverSheetsThreadComment={},a["@wendellhu/redi"],a.UniverCore,a.UniverThreadCommentUi,a.UniverUi,a.UniverSheets,a.UniverEngineFormula,a.UniverThreadComment,a.UniverSheetsUi,a.UniverSheetsThreadCommentBase,a["@wendellhu/redi/react-bindings"],a.React,a.rxjs,a.UniverEngineRender))})(this,function(a,d,c,T,_,S,A,O,P,D,N,g,W,se){"use strict";var We=Object.defineProperty;var Fe=(a,d,c)=>d in a?We(a,d,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[d]=c;var R=(a,d,c)=>Fe(a,typeof d!="symbol"?d+"":d,c);var b=function(){return b=Object.assign||function(r){for(var o,n=1,e=arguments.length;n<e;n++){o=arguments[n];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(r[t]=o[t])}return r},b.apply(this,arguments)},ae=function(r,o){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&o.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)o.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(n[e[t]]=r[e[t]]);return n},J=g.forwardRef(function(r,o){var n=r.icon,e=r.id,t=r.className,i=r.extend,s=ae(r,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),u=g.useRef("_".concat(me()));return Q(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},b({ref:o,className:m},s),i)});function Q(r,o,n,e,t){return g.createElement(r.tag,b(b({key:o},ce(r,n,t)),e),(ue(r,n).children||[]).map(function(i,s){return Q(i,"".concat(o,"-").concat(r.tag,"-").concat(s),n,void 0,t)}))}function ce(r,o,n){var e=b({},r.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=o.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+o.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],m=i[1];typeof m=="string"&&(e[s]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(o.idSuffix,")")))})),e}function ue(r,o){var n,e=o.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?b(b({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?b(b({},t),{attrs:b(b({},t.attrs),{id:t.attrs.id+o.idSuffix})}):t})}):r}function me(){return Math.random().toString(36).substring(2,8)}J.displayName="UniverIcon";var de={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"}}]},x=g.forwardRef(function(r,o){return g.createElement(J,Object.assign({},r,{id:"comment-single",ref:o,icon:de}))});x.displayName="CommentSingle";const ee="univer.sheet.thread-comment-modal",K="comment-single",Y="SHEET_THREAD_COMMENT";var he=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(r,o,n,e)=>{for(var t=e>1?void 0:e?le(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&he(o,n,t),t},te=(r,o)=>(n,e)=>o(n,e,r);a.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();R(this,"_lastPopup",null);R(this,"_activePopup");R(this,"_activePopup$",new W.BehaviorSubject(null));R(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 h;const{row:t,col:i,unitId:s,subUnitId:m}=n;if(this._activePopup&&t===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&m===((h=this.activePopup)==null?void 0:h.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(t,i,{componentKey:ee,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 l=new c.DisposableCollection;l.add(u),l.add({dispose:()=>{e==null||e()}}),this._lastPopup=l}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))}},a.SheetsThreadCommentPopupService=pe([te(0,d.Inject(P.SheetCanvasPopManagerService)),te(1,_.IZenZoneService)],a.SheetsThreadCommentPopupService);const ve=()=>{const r=N.useDependency(c.IUniverInstanceService),o=N.useDependency(a.SheetsThreadCommentPopupService),n=_.useObservable(o.activePopup$),e=N.useDependency(D.SheetsThreadCommentModel);if(_.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:i,unitId:s,subUnitId:m,trigger:u}=n,l=e.getByLocation(s,m,t,i),h=`${c.Tools.chatAtABC(i)}${t+1}`,C=()=>{o.hidePopup()},v=f=>{var I,$,y;return(y=($=(I=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(f))==null?void 0:$.getName())!=null?y:""};return g.createElement(T.ThreadCommentTree,{onClick:()=>{o.persistPopup()},prefix:"cell",id:l,unitId:s,subUnitId:m,type:c.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:C,getSubUnitName:v,autoFocus:u==="context-menu"})},H={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var I;const o=r.get(S.SheetsSelectionsService),n=r.get(c.IUniverInstanceService),e=r.get(a.SheetsThreadCommentPopupService),t=r.get(T.ThreadCommentPanelService),i=(I=o.getCurrentLastSelection())==null?void 0:I.primary,s=r.get(D.SheetsThreadCommentModel);if(!i)return!1;const m=S.getSheetCommandTarget(n);if(!m)return!1;const{workbook:u,worksheet:l,unitId:h,subUnitId:C}=m,v={workbook:u,worksheet:l,unitId:h,subUnitId:C,row:i.startRow,col:i.startColumn};e.showPopup(v);const f=s.getByLocation(h,C,i.startRow,i.startColumn);return f&&t.setActiveComment({unitId:h,subUnitId:C,commentId:f,trigger:"context-menu"}),!0}},Se=()=>{var G;const r=N.useDependency(P.IMarkSelectionService),o=N.useDependency(c.IUniverInstanceService),n=N.useDependency(a.SheetsThreadCommentPopupService),e=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),t=e.getUnitId(),i=N.useDependency(c.ICommandService),s=g.useMemo(()=>e.activeSheet$.pipe(W.map(p=>p==null?void 0:p.getSheetId())),[e.activeSheet$]),m=_.useObservable(s,(G=e.getActiveSheet())==null?void 0:G.getSheetId()),u=g.useRef(),l=N.useDependency(T.ThreadCommentPanelService),h=_.useObservable(l.activeCommentId$),C=_.useObservable(l.panelVisible$,l.panelVisible),v=g.useCallback(p=>{const M=e.getSheets(),w={};M.forEach((j,E)=>{w[j.getSheetId()]=E});const k=j=>j.map(E=>{var ie;const V=A.singleReferenceToGrid(E.ref),ke=[(ie=w[E.subUnitId])!=null?ie:0,V.row,V.column];return{...E,p:ke}}).sort((E,V)=>E.p[0]===V.p[0]?E.p[1]===V.p[1]?E.p[2]-V.p[2]:E.p[1]-V.p[1]:E.p[0]-V.p[0]);return[...k(p.filter(j=>!j.resolved)),...k(p.filter(j=>j.resolved))]},[e]),f=g.useCallback(p=>{if(p.unitId===t&&p.subUnitId===m&&!p.resolved){const{row:M,column:w}=A.singleReferenceToGrid(p.ref);if(!Number.isNaN(M)&&!Number.isNaN(w))return r.addShape({range:{startColumn:w,endColumn:w,startRow:M,endRow:M},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[r,m,t]),I=p=>{var M,w;return(w=(M=e.getSheetBySheetId(p))==null?void 0:M.getName())!=null?w:""},$=()=>{i.executeCommand(H.id)},y=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(u.current&&(r.removeShape(u.current),u.current=null),u.current=f(p))},L=()=>{u.current&&(r.removeShape(u.current),u.current=null)},z=(p,M)=>{M&&n.hidePopup()};return g.useEffect(()=>{!C&&u.current&&r.removeShape(u.current)},[r,C]),g.createElement(T.ThreadCommentPanel,{unitId:t,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:$,getSubUnitName:I,onResolve:z,sortComments:v,onItemEnter:y,onItemLeave:L,onDeleteComment:()=>(L(),!0)})},Ce=r=>({id:H.id,type:_.MenuItemType.BUTTON,positions:[_.MenuPosition.CONTEXT_MENU],icon:K,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]})}),fe=r=>({id:T.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",positions:_.MenuPosition.TOOLBAR_START,group:_.MenuGroup.TOOLBAR_OTHERS,disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET)}),_e={id:H.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused};var Ie=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(r,o,n,e)=>{for(var t=e>1?void 0:e?Pe(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&Ie(o,n,t),t},U=(r,o)=>(n,e)=>o(n,e,r);const ge={};a.SheetsThreadCommentController=class extends c.Disposable{constructor(n,e,t,i,s,m,u,l,h,C,v,f){super();R(this,"_isSwitchToCommenting",!1);R(this,"_selectionShapeInfo",null);this._config=n,this._menuService=e,this._injector=t,this._componentManager=i,this._commandService=s,this._sheetsThreadCommentPopupService=m,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=l,this._shortcutService=h,this._univerInstanceService=C,this._sheetPermissionInterceptorBaseController=v,this._markSelectionService=f,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(_e)}_initCommandListener(){this._commandService.onCommandExecuted(n=>{if(n.id===S.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const e=n.params,{unitId:t,subUnitId:i,selections:s,type:m}=e;if((m===S.SelectionMoveType.MOVE_END||m===void 0)&&s[0].primary){const u=s[0].range;if(u.endColumn-u.startColumn>0||u.endRow-u.startRow>0)return;const l=s[0].primary.actualRow,h=s[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(t,i,l,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const C=this._sheetsThreadCommentModel.getByLocation(t,i,l,h);C&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:t,subUnitId:i,commentId:C})}}if(n.id===O.DeleteCommentMutation.id){const e=n.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:i,subUnitId:s,commentId:m}=t;e.unitId===i&&e.subUnitId===s&&e.commentId===m&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:n={}}=this._config;[Ce,fe].forEach(e=>{this._menuService.addMenuItem(e(this._injector),n)})}_initComponent(){[[ee,ve],[T.THREAD_COMMENT_PANEL,Se],[K,x]].forEach(([n,e])=>{this._componentManager.register(n,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async n=>{var e;if(n){const{unitId:t,subUnitId:i,commentId:s,trigger:m}=n,u=this._sheetsThreadCommentModel.getComment(t,i,s);if(!u||u.resolved)return;const l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!l||l.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((e=l.getActiveSheet())==null?void 0:e.getSheetId())!==i&&await this._commandService.executeCommand(S.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:i}),this._isSwitchToCommenting=!1;const v=A.singleReferenceToGrid(u.ref),{row:f,column:I}=v;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]},[{startRow:f,startColumn:I,endRow:f,endColumn:I}]))return;const y=1;await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(v.row-y,0),endRow:v.row+y,startColumn:Math.max(v.column-y,0),endColumn:v.column+y}}),this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:v.row,col:v.column,commentId:u.id,trigger:m})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(n=>{if(!n){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:t,commentId:i}=n;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===t&&this._selectionShapeInfo.commentId===i)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const s=this._sheetsThreadCommentModel.getComment(e,t,i);if(!s)return;const m=A.singleReferenceToGrid(s.ref),{row:u,column:l}=m;if(Number.isNaN(u)||Number.isNaN(l))return;const h=this._markSelectionService.addShape({range:{startColumn:l,endColumn:l,startRow:u,endRow:u},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});h&&(this._selectionShapeInfo={...n,shapeId:h})}))}},a.SheetsThreadCommentController=Te([c.OnLifecycle(c.LifecycleStages.Starting,a.SheetsThreadCommentController),U(1,_.IMenuService),U(2,d.Inject(d.Injector)),U(3,d.Inject(_.ComponentManager)),U(4,c.ICommandService),U(5,d.Inject(a.SheetsThreadCommentPopupService)),U(6,d.Inject(D.SheetsThreadCommentModel)),U(7,d.Inject(T.ThreadCommentPanelService)),U(8,_.IShortcutService),U(9,c.IUniverInstanceService),U(10,d.Inject(P.SheetPermissionInterceptorBaseController)),U(11,P.IMarkSelectionService)],a.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(r,o,n,e)=>{for(var t=e>1?void 0:e?ye(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&be(o,n,t),t},F=(r,o)=>(n,e)=>o(n,e,r);let B=class extends c.Disposable{constructor(r,o,n,e){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=o,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(r,o,n)=>{const{row:e,col:t,unitId:i,subUnitId:s}=o;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,t)?n({...r,markers:{...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}}):n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var s;const o=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!o)return;const n=o.getUnitId(),e=(s=o.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),i=t==null?void 0:t.with(P.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(W.debounceTime(16)).subscribe(o=>{r()}))}};B=Me([c.OnLifecycle(c.LifecycleStages.Ready,B),F(0,d.Inject(S.SheetInterceptorService)),F(1,d.Inject(D.SheetsThreadCommentModel)),F(2,c.IUniverInstanceService),F(3,se.IRenderManagerService)],B);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(r,o,n,e)=>{for(var t=e>1?void 0:e?Oe(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&we(o,n,t),t},X=(r,o)=>(n,e)=>o(n,e,r);const Ee=(r,o,n)=>{const e=A.singleReferenceToGrid(r),t=n.row-o.row,i=n.column-o.column,s={startColumn:e.column+i,startRow:e.row+t,endColumn:e.column+i,endRow:e.row+t};return A.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends c.Disposable{constructor(n,e,t){super();R(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Y,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,i)=>{const{unitId:s,subUnitId:m,range:u}=e,l={row:u.rows[0],column:u.cols[0]};if(i.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:C,subUnitId:v}=this._copyInfo,f={row:h.startRow,column:h.startColumn};if(!(s===C&&m===v)){const I=[];c.Range.foreach(h,(p,M)=>{const w=this._sheetsThreadCommentModel.getAllByLocation(C,v,p,M);this._threadCommentDataSourceService.syncUpdateMutationToColla?w.forEach(k=>{I.push(k)}):w.forEach(({children:k,...j})=>{j.parentId||I.push(j)})});const $=[],y=[],L=[],z=[],G=p=>{$.unshift({id:O.DeleteCommentMutation.id,params:{unitId:C,subUnitId:v,commentId:p.id}}),L.push({id:O.AddCommentMutation.id,params:{unitId:s,subUnitId:m,comment:{...p,ref:Ee(p.ref,f,l),unitId:s,subUnitId:m},sync:!0}}),y.push({id:O.AddCommentMutation.id,params:{unitId:C,subUnitId:v,comment:p,sync:!0}}),z.unshift({id:O.DeleteCommentMutation.id,params:{unitId:s,subUnitId:m,commentId:p.id}})};return I.forEach(p=>{G(p)}),{redos:[...$,...L],undos:[...z,...y]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),X(0,d.Inject(P.ISheetClipboardService)),X(1,d.Inject(D.SheetsThreadCommentModel)),X(2,O.IThreadCommentDataSourceService)],a.SheetsThreadCommentCopyPasteController);var je=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,De=(r,o,n,e)=>{for(var t=e>1?void 0:e?Re(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&je(o,n,t),t},q=(r,o)=>(n,e)=>o(n,e,r);a.SheetsThreadCommentHoverController=class extends c.Disposable{constructor(o,n,e,t){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(W.debounceTime(100)).subscribe(o=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(o&&(n&&n.temp||!n)){const{location:e}=o,{unitId:t,subUnitId:i,row:s,col:m}=e,u=this._sheetsThreadCommentModel.getByLocation(t,i,s,m);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[S.WorkbookCommentPermission],worksheetTypes:[S.WorksheetViewPermission],rangeTypes:[S.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:m,endRow:s,endColumn:m}]))return;const h=this._sheetsThreadCommentModel.getComment(t,i,u);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:s,col:m,commentId:u,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},a.SheetsThreadCommentHoverController=De([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentHoverController),q(0,d.Inject(P.HoverManagerService)),q(1,d.Inject(a.SheetsThreadCommentPopupService)),q(2,d.Inject(D.SheetsThreadCommentModel)),q(3,d.Inject(P.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentHoverController);var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(r,o,n,e)=>{for(var t=e>1?void 0:e?$e(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&Ne(o,n,t),t},Z=(r,o)=>(n,e)=>o(n,e,r);a.ThreadCommentRemoveSheetsController=class extends c.Disposable{constructor(o,n,e,t){super(),this._sheetInterceptorService=o,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var n;if(o.id===S.RemoveSheetCommand.id){const e=o.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const i=t.getUnitId(),s=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:m}=this._threadCommentModel.ensureMap(i,s),u=Array.from(Object.values(m)).filter(f=>!f.parentId),l=u.map(f=>f.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,C=l.map(f=>({id:O.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:f}})),v=u.map(({children:f,...I})=>({id:O.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...I,children:h?f:void 0},sync:!h}}));return{redos:C,undos:v}}return{redos:[],undos:[]}}}))}},a.ThreadCommentRemoveSheetsController=Ve([c.OnLifecycle(c.LifecycleStages.Ready,a.ThreadCommentRemoveSheetsController),Z(0,d.Inject(S.SheetInterceptorService)),Z(1,c.IUniverInstanceService),Z(2,d.Inject(O.ThreadCommentModel)),Z(3,O.IThreadCommentDataSourceService)],a.ThreadCommentRemoveSheetsController);var ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,He=(r,o,n)=>o in r?ne(r,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[o]=n,Le=(r,o,n,e)=>{for(var t=e>1?void 0:e?Ae(o,n):o,i=r.length-1,s;i>=0;i--)(s=r[i])&&(t=(e?s(o,n,t):s(t))||t);return e&&t&&ne(o,n,t),t},re=(r,o)=>(n,e)=>o(n,e,r),oe=(r,o,n)=>He(r,typeof o!="symbol"?o+"":o,n);a.UniverSheetsThreadCommentPlugin=class extends c.Plugin{constructor(n={},e,t){super();R(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=c.Tools.deepMerge({},ge,n)}onStarting(n){[[a.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(a.SheetsThreadCommentController,this._pluginConfig)}],[B],[a.SheetsThreadCommentCopyPasteController],[a.SheetsThreadCommentHoverController],[a.ThreadCommentRemoveSheetsController],[a.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}},oe(a.UniverSheetsThreadCommentPlugin,"pluginName",Y),oe(a.UniverSheetsThreadCommentPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsThreadCommentPlugin=Le([c.DependentOn(T.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),re(1,d.Inject(d.Injector)),re(2,d.Inject(c.ICommandService))],a.UniverSheetsThreadCommentPlugin),Object.defineProperty(a,"Inject",{enumerable:!0,get:()=>d.Inject}),Object.defineProperty(a,"Injector",{enumerable:!0,get:()=>d.Injector}),Object.defineProperty(a,"ICommandService",{enumerable:!0,get:()=>c.ICommandService}),Object.defineProperty(a,"Plugin",{enumerable:!0,get:()=>c.Plugin}),Object.defineProperty(a,"UniverInstanceType",{enumerable:!0,get:()=>c.UniverInstanceType}),Object.defineProperty(a,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>T.IThreadCommentMentionDataService}),Object.defineProperty(a,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>T.UniverThreadCommentUIPlugin}),Object.defineProperty(a,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>O.IThreadCommentDataSourceService}),Object.defineProperty(a,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel}),a.SHEETS_THREAD_COMMENT=Y,a.ShowAddSheetCommentModalOperation=H,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-thread-comment-base"),require("react"),require("rxjs"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/ui","@univerjs/sheets","@univerjs/engine-formula","@univerjs/thread-comment","@univerjs/sheets-ui","@univerjs/sheets-thread-comment-base","react","rxjs","@univerjs/engine-render"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsThreadComment={},c.UniverCore,c.UniverThreadCommentUi,c.UniverUi,c.UniverSheets,c.UniverEngineFormula,c.UniverThreadComment,c.UniverSheetsUi,c.UniverSheetsThreadCommentBase,c.React,c.rxjs,c.UniverEngineRender))})(this,function(c,o,_,f,v,$,w,P,R,T,L,ie){"use strict";var Le=Object.defineProperty;var ke=(c,o,_)=>o in c?Le(c,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[o]=_;var j=(c,o,_)=>ke(c,typeof o!="symbol"?o+"":o,_);var g=function(){return g=Object.assign||function(r){for(var i,n=1,e=arguments.length;n<e;n++){i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(r[t]=i[t])}return r},g.apply(this,arguments)},oe=function(r,i){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&i.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)i.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(n[e[t]]=r[e[t]]);return n},Y=T.forwardRef(function(r,i){var n=r.icon,e=r.id,t=r.className,s=r.extend,a=oe(r,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),u=T.useRef("_".concat(ce()));return X(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},g({ref:i,className:d},a),s)});function X(r,i,n,e,t){return T.createElement(r.tag,g(g({key:i},se(r,n,t)),e),(ae(r,n).children||[]).map(function(s,a){return X(s,"".concat(i,"-").concat(r.tag,"-").concat(a),n,void 0,t)}))}function se(r,i,n){var e=g({},r.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=i.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+i.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],d=s[1];typeof d=="string"&&(e[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),e}function ae(r,i){var n,e=i.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?g(g({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?g(g({},t),{attrs:g(g({},t.attrs),{id:t.attrs.id+i.idSuffix})}):t})}):r}function ce(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ue={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"}}]},J=T.forwardRef(function(r,i){return T.createElement(Y,Object.assign({},r,{id:"comment-single",ref:i,icon:ue}))});J.displayName="CommentSingle";const Q="univer.sheet.thread-comment-modal",z="comment-single",G="SHEET_THREAD_COMMENT";var de=Object.defineProperty,me=Object.getOwnPropertyDescriptor,he=(r,i,n,e)=>{for(var t=e>1?void 0:e?me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&de(i,n,t),t},x=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentPopupService=class extends o.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new L.BehaviorSubject(null));j(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:t,col:s,unitId:a,subUnitId:d}=n;if(this._activePopup&&t===this._activePopup.row&&s===this._activePopup.col&&a===this._activePopup.unitId&&d===((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(t,s,{componentKey:Q,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 o.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))}},c.SheetsThreadCommentPopupService=he([x(0,o.Inject(P.SheetCanvasPopManagerService)),x(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const le=()=>{const r=o.useDependency(o.IUniverInstanceService),i=o.useDependency(c.SheetsThreadCommentPopupService),n=f.useObservable(i.activePopup$),e=o.useDependency(R.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:s,unitId:a,subUnitId:d,trigger:u}=n,h=e.getByLocation(a,d,t,s),m=`${o.Tools.chatAtABC(s)}${t+1}`,S=()=>{i.hidePopup()},p=C=>{var I,D,b;return(b=(D=(I=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:D.getName())!=null?b:""};return T.createElement(_.ThreadCommentTree,{onClick:()=>{i.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:d,type:o.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:S,getSubUnitName:p,autoFocus:u==="context-menu"})},V={type:o.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var I;const i=r.get(v.SheetsSelectionsService),n=r.get(o.IUniverInstanceService),e=r.get(c.SheetsThreadCommentPopupService),t=r.get(_.ThreadCommentPanelService),s=(I=i.getCurrentLastSelection())==null?void 0:I.primary,a=r.get(R.SheetsThreadCommentModel);if(!s)return!1;const d=v.getSheetCommandTarget(n);if(!d)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:S}=d,p={workbook:u,worksheet:h,unitId:m,subUnitId:S,row:s.startRow,col:s.startColumn};e.showPopup(p);const C=a.getByLocation(m,S,s.startRow,s.startColumn);return C&&t.setActiveComment({unitId:m,subUnitId:S,commentId:C,trigger:"context-menu"}),!0}},pe=()=>{var Z;const r=o.useDependency(P.IMarkSelectionService),i=o.useDependency(o.IUniverInstanceService),n=o.useDependency(c.SheetsThreadCommentPopupService),e=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),t=e.getUnitId(),s=o.useDependency(o.ICommandService),a=T.useMemo(()=>e.activeSheet$.pipe(L.map(l=>l==null?void 0:l.getSheetId())),[e.activeSheet$]),d=f.useObservable(a,(Z=e.getActiveSheet())==null?void 0:Z.getSheetId()),u=T.useRef(),h=o.useDependency(_.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),S=f.useObservable(h.panelVisible$,h.panelVisible),p=T.useCallback(l=>{const y=e.getSheets(),M={};y.forEach((E,U)=>{M[E.getSheetId()]=U});const H=E=>E.map(U=>{var re;const N=$.singleReferenceToGrid(U.ref),He=[(re=M[U.subUnitId])!=null?re:0,N.row,N.column];return{...U,p:He}}).sort((U,N)=>U.p[0]===N.p[0]?U.p[1]===N.p[1]?U.p[2]-N.p[2]:U.p[1]-N.p[1]:U.p[0]-N.p[0]);return[...H(l.filter(E=>!E.resolved)),...H(l.filter(E=>E.resolved))]},[e]),C=T.useCallback(l=>{if(l.unitId===t&&l.subUnitId===d&&!l.resolved){const{row:y,column:M}=$.singleReferenceToGrid(l.ref);if(!Number.isNaN(y)&&!Number.isNaN(M))return r.addShape({range:{startColumn:M,endColumn:M,startRow:y,endRow:y},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[r,d,t]),I=l=>{var y,M;return(M=(y=e.getSheetBySheetId(l))==null?void 0:y.getName())!=null?M:""},D=()=>{s.executeCommand(V.id)},b=l=>{m&&m.unitId===l.unitId&&m.subUnitId===l.subUnitId&&m.commentId===l.id||(u.current&&(r.removeShape(u.current),u.current=null),u.current=C(l))},A=()=>{u.current&&(r.removeShape(u.current),u.current=null)},q=(l,y)=>{y&&n.hidePopup()};return T.useEffect(()=>{!S&&u.current&&r.removeShape(u.current)},[r,S]),T.createElement(_.ThreadCommentPanel,{unitId:t,subUnitId$:a,type:o.UniverInstanceType.UNIVER_SHEET,onAdd:D,getSubUnitName:I,onResolve:q,sortComments:p,onItemEnter:b,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},ve=r=>({id:V.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:z,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),Se=r=>({id:_.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:z,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}),Ce={id:V.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused};var fe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ie=(r,i,n,e)=>{for(var t=e>1?void 0:e?_e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&fe(i,n,t),t},O=(r,i)=>(n,e)=>i(n,e,r);const Pe={};c.SheetsThreadCommentController=class extends o.Disposable{constructor(n,e,t,s,a,d,u,h,m,S,p,C){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._config=n,this._menuService=e,this._injector=t,this._componentManager=s,this._commandService=a,this._sheetsThreadCommentPopupService=d,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=h,this._shortcutService=m,this._univerInstanceService=S,this._sheetPermissionInterceptorBaseController=p,this._markSelectionService=C,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(Ce)}_initCommandListener(){this._commandService.onCommandExecuted(n=>{var e;if(n.id===v.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const t=n.params,{unitId:s,subUnitId:a,selections:d,type:u}=t;if((u===v.SelectionMoveType.MOVE_END||u===void 0)&&((e=d[0])!=null&&e.primary)){const h=d[0].range;if(h.endColumn-h.startColumn>0||h.endRow-h.startRow>0)return;const m=d[0].primary.actualRow,S=d[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(s,a,m,S)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(_.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(s,a,m,S);p&&this._commandService.executeCommand(_.SetActiveCommentOperation.id,{unitId:s,subUnitId:a,commentId:p})}}if(n.id===w.DeleteCommentMutation.id){const t=n.params,s=this._sheetsThreadCommentPopupService.activePopup;if(!s)return;const{unitId:a,subUnitId:d,commentId:u}=s;t.unitId===a&&t.subUnitId===d&&t.commentId===u&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:n={}}=this._config;[ve,Se].forEach(e=>{this._menuService.addMenuItem(e(this._injector),n)})}_initComponent(){[[Q,le],[_.THREAD_COMMENT_PANEL,pe],[z,J]].forEach(([n,e])=>{this._componentManager.register(n,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async n=>{var e;if(n){const{unitId:t,subUnitId:s,commentId:a,trigger:d}=n,u=this._sheetsThreadCommentModel.getComment(t,s,a);if(!u||u.resolved)return;const h=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!h||h.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((e=h.getActiveSheet())==null?void 0:e.getSheetId())!==s&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:s}),this._isSwitchToCommenting=!1;const p=$.singleReferenceToGrid(u.ref),{row:C,column:I}=p;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:C,startColumn:I,endRow:C,endColumn:I}]))return;const b=1;await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-b,0),endRow:p.row+b,startColumn:Math.max(p.column-b,0),endColumn:p.column+b}}),this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:p.row,col:p.column,commentId:u.id,trigger:d})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(n=>{if(!n){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:t,commentId:s}=n;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===t&&this._selectionShapeInfo.commentId===s)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const a=this._sheetsThreadCommentModel.getComment(e,t,s);if(!a)return;const d=$.singleReferenceToGrid(a.ref),{row:u,column:h}=d;if(Number.isNaN(u)||Number.isNaN(h))return;const m=this._markSelectionService.addShape({range:{startColumn:h,endColumn:h,startRow:u,endRow:u},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});m&&(this._selectionShapeInfo={...n,shapeId:m})}))}},c.SheetsThreadCommentController=Ie([o.OnLifecycle(o.LifecycleStages.Starting,c.SheetsThreadCommentController),O(1,f.IMenuService),O(2,o.Inject(o.Injector)),O(3,o.Inject(f.ComponentManager)),O(4,o.ICommandService),O(5,o.Inject(c.SheetsThreadCommentPopupService)),O(6,o.Inject(R.SheetsThreadCommentModel)),O(7,o.Inject(_.ThreadCommentPanelService)),O(8,f.IShortcutService),O(9,o.IUniverInstanceService),O(10,o.Inject(P.SheetPermissionInterceptorBaseController)),O(11,P.IMarkSelectionService)],c.SheetsThreadCommentController);var Te=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,be=(r,i,n,e)=>{for(var t=e>1?void 0:e?ge(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Te(i,n,t),t},k=(r,i)=>(n,e)=>i(n,e,r);let B=class extends o.Disposable{constructor(r,i,n,e){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=i,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(r,i,n)=>{const{row:e,col:t,unitId:s,subUnitId:a}=i;return this._sheetsThreadCommentModel.showCommentMarker(s,a,e,t)?n({...r,markers:{...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}}):n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var a;const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),e=(a=i.getActiveSheet())==null?void 0:a.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),s=t==null?void 0:t.with(P.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});s==null||s.makeDirty(!0),s==null||s.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(L.debounceTime(16)).subscribe(i=>{r()}))}};B=be([o.OnLifecycle(o.LifecycleStages.Ready,B),k(0,o.Inject(v.SheetInterceptorService)),k(1,o.Inject(R.SheetsThreadCommentModel)),k(2,o.IUniverInstanceService),k(3,ie.IRenderManagerService)],B);var ye=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(r,i,n,e)=>{for(var t=e>1?void 0:e?Me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ye(i,n,t),t},K=(r,i)=>(n,e)=>i(n,e,r);const Oe=(r,i,n)=>{const e=$.singleReferenceToGrid(r),t=n.row-i.row,s=n.column-i.column,a={startColumn:e.column+s,startRow:e.row+t,endColumn:e.column+s,endRow:e.row+t};return $.serializeRange(a)};c.SheetsThreadCommentCopyPasteController=class extends o.Disposable{constructor(n,e,t){super();j(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,s)=>{const{unitId:a,subUnitId:d,range:u}=e,h={row:u.rows[0],column:u.cols[0]};if(s.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:S,subUnitId:p}=this._copyInfo,C={row:m.startRow,column:m.startColumn};if(!(a===S&&d===p)){const I=[];o.Range.foreach(m,(l,y)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(S,p,l,y);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(H=>{I.push(H)}):M.forEach(({children:H,...E})=>{E.parentId||I.push(E)})});const D=[],b=[],A=[],q=[],Z=l=>{D.unshift({id:w.DeleteCommentMutation.id,params:{unitId:S,subUnitId:p,commentId:l.id}}),A.push({id:w.AddCommentMutation.id,params:{unitId:a,subUnitId:d,comment:{...l,ref:Oe(l.ref,C,h),unitId:a,subUnitId:d},sync:!0}}),b.push({id:w.AddCommentMutation.id,params:{unitId:S,subUnitId:p,comment:l,sync:!0}}),q.unshift({id:w.DeleteCommentMutation.id,params:{unitId:a,subUnitId:d,commentId:l.id}})};return I.forEach(l=>{Z(l)}),{redos:[...D,...A],undos:[...q,...b]}}}return{redos:[],undos:[]}}}))}},c.SheetsThreadCommentCopyPasteController=we([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentCopyPasteController),K(0,o.Inject(P.ISheetClipboardService)),K(1,o.Inject(R.SheetsThreadCommentModel)),K(2,w.IThreadCommentDataSourceService)],c.SheetsThreadCommentCopyPasteController);var Ue=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(r,i,n,e)=>{for(var t=e>1?void 0:e?Ee(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Ue(i,n,t),t},W=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentHoverController=class extends o.Disposable{constructor(i,n,e,t){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(L.debounceTime(100)).subscribe(i=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(i&&(n&&n.temp||!n)){const{location:e}=i,{unitId:t,subUnitId:s,row:a,col:d}=e,u=this._sheetsThreadCommentModel.getByLocation(t,s,a,d);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:d,endRow:a,endColumn:d}]))return;const m=this._sheetsThreadCommentModel.getComment(t,s,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:a,col:d,commentId:u,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},c.SheetsThreadCommentHoverController=je([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentHoverController),W(0,o.Inject(P.HoverManagerService)),W(1,o.Inject(c.SheetsThreadCommentPopupService)),W(2,o.Inject(R.SheetsThreadCommentModel)),W(3,o.Inject(P.SheetPermissionInterceptorBaseController))],c.SheetsThreadCommentHoverController);var Re=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ne=(r,i,n,e)=>{for(var t=e>1?void 0:e?De(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Re(i,n,t),t},F=(r,i)=>(n,e)=>i(n,e,r);c.ThreadCommentRemoveSheetsController=class extends o.Disposable{constructor(i,n,e,t){super(),this._sheetInterceptorService=i,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var n;if(i.id===v.RemoveSheetCommand.id){const e=i.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const s=t.getUnitId(),a=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!a)return{redos:[],undos:[]};const{commentMap:d}=this._threadCommentModel.ensureMap(s,a),u=Array.from(Object.values(d)).filter(C=>!C.parentId),h=u.map(C=>C.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,S=h.map(C=>({id:w.DeleteCommentMutation.id,params:{unitId:s,subUnitId:a,commentId:C}})),p=u.map(({children:C,...I})=>({id:w.AddCommentMutation.id,params:{unitId:s,subUnitId:a,comment:{...I,children:m?C:void 0},sync:!m}}));return{redos:S,undos:p}}return{redos:[],undos:[]}}}))}},c.ThreadCommentRemoveSheetsController=Ne([o.OnLifecycle(o.LifecycleStages.Ready,c.ThreadCommentRemoveSheetsController),F(0,o.Inject(v.SheetInterceptorService)),F(1,o.IUniverInstanceService),F(2,o.Inject(w.ThreadCommentModel)),F(3,w.IThreadCommentDataSourceService)],c.ThreadCommentRemoveSheetsController);var ee=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(r,i,n)=>i in r?ee(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,Ae=(r,i,n,e)=>{for(var t=e>1?void 0:e?$e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ee(i,n,t),t},te=(r,i)=>(n,e)=>i(n,e,r),ne=(r,i,n)=>Ve(r,typeof i!="symbol"?i+"":i,n);c.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(n={},e,t){super();j(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=o.Tools.deepMerge({},Pe,n)}onStarting(n){[[c.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(c.SheetsThreadCommentController,this._pluginConfig)}],[B],[c.SheetsThreadCommentCopyPasteController],[c.SheetsThreadCommentHoverController],[c.ThreadCommentRemoveSheetsController],[c.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[V].forEach(e=>{this._commandService.registerCommand(e)})}},ne(c.UniverSheetsThreadCommentPlugin,"pluginName",G),ne(c.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentPlugin=Ae([o.DependentOn(_.UniverThreadCommentUIPlugin,R.UniverSheetsThreadCommentBasePlugin),te(1,o.Inject(o.Injector)),te(2,o.Inject(o.ICommandService))],c.UniverSheetsThreadCommentPlugin),Object.defineProperty(c,"ICommandService",{enumerable:!0,get:()=>o.ICommandService}),Object.defineProperty(c,"Inject",{enumerable:!0,get:()=>o.Inject}),Object.defineProperty(c,"Injector",{enumerable:!0,get:()=>o.Injector}),Object.defineProperty(c,"Plugin",{enumerable:!0,get:()=>o.Plugin}),Object.defineProperty(c,"UniverInstanceType",{enumerable:!0,get:()=>o.UniverInstanceType}),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>_.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>_.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService}),Object.defineProperty(c,"SheetsThreadCommentModel",{enumerable:!0,get:()=>R.SheetsThreadCommentModel}),c.SHEETS_THREAD_COMMENT=G,c.ShowAddSheetCommentModalOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -45,38 +45,36 @@
|
|
|
45
45
|
"lib"
|
|
46
46
|
],
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@wendellhu/redi": "0.16.0",
|
|
49
48
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
50
49
|
"rxjs": ">=7.0.0",
|
|
51
|
-
"@univerjs/core": "0.2.
|
|
52
|
-
"@univerjs/engine-
|
|
53
|
-
"@univerjs/engine-
|
|
54
|
-
"@univerjs/sheets": "0.2.
|
|
55
|
-
"@univerjs/sheets-thread-comment-base": "0.2.
|
|
56
|
-
"@univerjs/sheets-ui": "0.2.
|
|
57
|
-
"@univerjs/thread-comment": "0.2.
|
|
58
|
-
"@univerjs/ui": "0.2.
|
|
59
|
-
"@univerjs/thread-comment-ui": "0.2.
|
|
50
|
+
"@univerjs/core": "0.2.5",
|
|
51
|
+
"@univerjs/engine-render": "0.2.5",
|
|
52
|
+
"@univerjs/engine-formula": "0.2.5",
|
|
53
|
+
"@univerjs/sheets": "0.2.5",
|
|
54
|
+
"@univerjs/sheets-thread-comment-base": "0.2.5",
|
|
55
|
+
"@univerjs/sheets-ui": "0.2.5",
|
|
56
|
+
"@univerjs/thread-comment": "0.2.5",
|
|
57
|
+
"@univerjs/ui": "0.2.5",
|
|
58
|
+
"@univerjs/thread-comment-ui": "0.2.5"
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
61
|
"@univerjs/icons": "^0.1.65"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@wendellhu/redi": "0.16.0",
|
|
66
64
|
"clsx": "^2.1.1",
|
|
67
65
|
"react": "18.3.1",
|
|
68
66
|
"rxjs": "^7.8.1",
|
|
69
67
|
"typescript": "^5.5.3",
|
|
70
68
|
"vite": "^5.3.4",
|
|
71
69
|
"vitest": "^2.0.3",
|
|
72
|
-
"@univerjs/core": "0.2.
|
|
73
|
-
"@univerjs/design": "0.2.
|
|
74
|
-
"@univerjs/engine-formula": "0.2.
|
|
75
|
-
"@univerjs/shared": "0.2.
|
|
76
|
-
"@univerjs/
|
|
77
|
-
"@univerjs/thread-comment": "0.2.
|
|
78
|
-
"@univerjs/thread-comment-ui": "0.2.
|
|
79
|
-
"@univerjs/ui": "0.2.
|
|
70
|
+
"@univerjs/core": "0.2.5",
|
|
71
|
+
"@univerjs/design": "0.2.5",
|
|
72
|
+
"@univerjs/engine-formula": "0.2.5",
|
|
73
|
+
"@univerjs/shared": "0.2.5",
|
|
74
|
+
"@univerjs/thread-comment": "0.2.5",
|
|
75
|
+
"@univerjs/sheets-thread-comment-base": "0.2.5",
|
|
76
|
+
"@univerjs/thread-comment-ui": "0.2.5",
|
|
77
|
+
"@univerjs/ui": "0.2.5"
|
|
80
78
|
},
|
|
81
79
|
"univerSpace": {
|
|
82
80
|
".": {
|