@univerjs/sheets-thread-comment-ui 0.5.1-nightly.202412251606 → 0.5.1-nightly.202412261606
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 +2 -2
- package/lib/es/index.js +114 -111
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ce=Object.defineProperty;var Se=(o,t,n)=>t in o?Ce(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>Se(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),T=require("@univerjs/thread-comment-ui"),I=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),ae=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),ce="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ie=(o,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&_e(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new k.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var d;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((d=this.activePopup)==null?void 0:d.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:ce,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(m),u.add({dispose:()=>{e==null||e()}}),this._lastPopup=u}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=Ie([oe(0,a.Inject(I.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(T.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:u,unitId:d,subUnitId:h}=c,l={workbook:m,worksheet:u,unitId:d,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(d,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:d,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},ge="sheets-thread-comment.config",Pe={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let F=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject($.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,ae.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:d,subUnitId:h}=this._copyInfo,l={row:u.startRow,column:u.startColumn};if(!(i===d&&s===h)){const p=[];a.Range.foreach(u,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(d,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{p.push(g)}):M.forEach(({children:g,...O})=>{O.parentId||p.push(O)})});const f=[],b=[],N=[],V=[],J=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:d,subUnitId:h,commentId:y.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Re(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:d,subUnitId:h,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return p.forEach(y=>{J(y)}),{redos:[...f,...N],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,a.Inject(I.ISheetClipboardService)),K(1,a.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let G=class extends a.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const u=this._sheetsThreadCommentModel.getComment(e,r,c);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([L(0,a.Inject(I.HoverManagerService)),L(1,a.Inject(exports.SheetsThreadCommentPopupService)),L(2,a.Inject($.SheetsThreadCommentModel)),L(3,a.Inject(I.SheetPermissionInterceptorBaseController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends a.Disposable{constructor(t,n,e,r,i,s,c,m,u,d){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=u,this._renderManagerService=d,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=c.actualRow,d=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,u,d);h&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(c.ref),{row:l,column:p}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const b=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-b,0),endRow:h.row+b,startColumn:Math.max(h.column-b,0),endColumn:h.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const u=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),d=(p=u==null?void 0:u.getMergedCell(c,m))!=null?p:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:d,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,a.ICommandService),E(1,a.Inject(exports.SheetsThreadCommentPopupService)),E(2,a.Inject($.SheetsThreadCommentModel)),E(3,a.Inject(T.ThreadCommentPanelService)),E(4,a.IUniverInstanceService),E(5,a.Inject(I.SheetPermissionInterceptorBaseController)),E(6,I.IMarkSelectionService),E(7,a.Inject(C.SheetsSelectionsService)),E(8,I.IEditorBridgeService),E(9,ae.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),u=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=c.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:u?l:void 0},sync:!u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,a.Inject(C.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,a.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var w=function(){return w=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},w.apply(this,arguments)},Be=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},me=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=Be(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Le()));return de(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function de(o,t,n,e,r){return R.createElement(o.tag,w(w({key:t},ke(o,n,r)),e),(He(o,n).children||[]).map(function(i,s){return de(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function ke(o,t,n){var e=w({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function He(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Le(){return Math.random().toString(36).substring(2,8)}me.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=R.forwardRef(function(o,t){return R.createElement(me,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});ue.displayName="CommentSingle";var Q={exports:{}},B={};/**
|
|
1
|
+
"use strict";var Se=Object.defineProperty;var _e=(o,t,n)=>t in o?Se(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>_e(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),T=require("@univerjs/thread-comment-ui"),I=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),ce=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),me="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new k.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var d;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((d=this.activePopup)==null?void 0:d.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:me,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(m),u.add({dispose:()=>{e==null||e()}}),this._lastPopup=u}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ge([oe(0,a.Inject(I.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(T.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:u,unitId:d,subUnitId:h}=c,l={workbook:m,worksheet:u,unitId:d,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(d,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:d,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},Pe="sheets-thread-comment.config",ie={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let F=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject($.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,ce.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:d,subUnitId:h}=this._copyInfo,l={row:u.startRow,column:u.startColumn};if(!(i===d&&s===h)){const p=[];a.Range.foreach(u,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(d,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{p.push(g)}):M.forEach(({children:g,...O})=>{O.parentId||p.push(O)})});const f=[],b=[],N=[],V=[],J=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:d,subUnitId:h,commentId:y.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Re(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:d,subUnitId:h,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return p.forEach(y=>{J(y)}),{redos:[...f,...N],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,a.Inject(I.ISheetClipboardService)),K(1,a.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let G=class extends a.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const u=this._sheetsThreadCommentModel.getComment(e,r,c);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([L(0,a.Inject(I.HoverManagerService)),L(1,a.Inject(exports.SheetsThreadCommentPopupService)),L(2,a.Inject($.SheetsThreadCommentModel)),L(3,a.Inject(I.SheetPermissionInterceptorBaseController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends a.Disposable{constructor(t,n,e,r,i,s,c,m,u,d){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=u,this._renderManagerService=d,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=c.actualRow,d=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,u,d);h&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(c.ref),{row:l,column:p}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const b=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-b,0),endRow:h.row+b,startColumn:Math.max(h.column-b,0),endColumn:h.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const u=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),d=(p=u==null?void 0:u.getMergedCell(c,m))!=null?p:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:d,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,a.ICommandService),E(1,a.Inject(exports.SheetsThreadCommentPopupService)),E(2,a.Inject($.SheetsThreadCommentModel)),E(3,a.Inject(T.ThreadCommentPanelService)),E(4,a.IUniverInstanceService),E(5,a.Inject(I.SheetPermissionInterceptorBaseController)),E(6,I.IMarkSelectionService),E(7,a.Inject(C.SheetsSelectionsService)),E(8,I.IEditorBridgeService),E(9,ce.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),u=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=c.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:u?l:void 0},sync:!u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,a.Inject(C.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,a.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var w=function(){return w=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},w.apply(this,arguments)},Be=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},de=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=Be(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Le()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ue(o,t,n,e,r){return R.createElement(o.tag,w(w({key:t},ke(o,n,r)),e),(He(o,n).children||[]).map(function(i,s){return ue(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function ke(o,t,n){var e=w({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function He(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Le(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=R.forwardRef(function(o,t){return R.createElement(de,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});he.displayName="CommentSingle";var Q={exports:{}},B={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var se;function Fe(){if(se)return B;se=1;var o=R,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(c,m,u){var d,h={},l=null,p=null;u!==void 0&&(l=""+u),m.key!==void 0&&(l=""+m.key),m.ref!==void 0&&(p=m.ref);for(d in m)e.call(m,d)&&!i.hasOwnProperty(d)&&(h[d]=m[d]);if(c&&c.defaultProps)for(d in m=c.defaultProps,m)h[d]===void 0&&(h[d]=m[d]);return{$$typeof:t,type:c,key:l,ref:p,props:h,_owner:r.current}}return B.Fragment=n,B.jsx=s,B.jsxs=s,B}var ae;function qe(){return ae||(ae=1,Q.exports=Fe()),Q.exports}var le=qe();const Ge=()=>{const o=a.useDependency(a.IUniverInstanceService),t=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=a.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,u=e.getByLocation(s,c,r,i),d=`${a.Tools.chatAtABC(i)}${r+1}`,h=()=>{t.hidePopup()},l=p=>{var f,b,N;return(N=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(p))==null?void 0:b.getName())!=null?N:""};return le.jsx(T.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:d,onClose:h,getSubUnitName:l,autoFocus:m==="context-menu"})},Ze=()=>{var y;const o=a.useDependency(I.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=a.useDependency(a.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(k.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=S.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=R.useRef(),u=a.useDependency(T.ThreadCommentPanelService),d=S.useObservable(u.activeCommentId$),h=S.useObservable(u.panelVisible$,u.panelVisible),l=R.useCallback(v=>{const M=e.getSheets(),g={};M.forEach((U,P)=>{g[U.getSheetId()]=P});const O=U=>U.map(P=>{var re;const j=x.singleReferenceToGrid(P.ref),Ce=[(re=g[P.subUnitId])!=null?re:0,j.row,j.column];return{...P,p:Ce}}).sort((P,j)=>P.p[0]===j.p[0]?P.p[1]===j.p[1]?P.p[2]-j.p[2]:P.p[1]-j.p[1]:P.p[0]-j.p[0]);return[...O(v.filter(U=>!U.resolved)),...O(v.filter(U=>U.resolved))]},[e]),p=R.useCallback(v=>{var M;if(v.unitId===r&&v.subUnitId===c&&!v.resolved){const{row:g,column:O}=x.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),P=(M=U==null?void 0:U.getMergedCell(g,O))!=null?M:{startColumn:O,endColumn:O,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(O))return o.addShape({range:P,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=v=>{var M,g;return(g=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?g:""},b=()=>{i.executeCommand(A.id)},N=v=>{d&&d.unitId===v.unitId&&d.subUnitId===v.subUnitId&&d.commentId===v.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=p(v))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},J=(v,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!h&&m.current&&o.removeShape(m.current)},[o,h]),le.jsx(T.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:J,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},ze=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:te,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ye=o=>({id:T.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:te,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),Je={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},Ke={[S.RibbonStartGroup.OTHERS]:{[T.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Ye}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ze}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Qe(t,n,r),r},X=(o,t)=>(n,e)=>t(n,e,o);let Y=class extends a.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Je)}_initMenu(){this._menuManagerService.mergeMenu(Ke)}_initComponent(){[[me,Ge],[T.THREAD_COMMENT_PANEL,Ze],[te,he]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};Y=et([X(0,S.IMenuManagerService),X(1,a.Inject(S.ComponentManager)),X(2,S.IShortcutService)],Y);var pe=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,t,n)=>t in o?pe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,rt=(o,t,n,e)=>{for(var r=e>1?void 0:e?tt(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&pe(t,n,r),r},ee=(o,t)=>(n,e)=>t(n,e,o),ve=(o,t,n)=>nt(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=ie,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=a.Tools.deepMerge(ie,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Pe,s)}onStarting(){[[Y],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(Y)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};ve(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ne);ve(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=rt([a.DependentOn(T.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,a.Inject(a.Injector)),ee(2,a.Inject(a.ICommandService)),ee(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>T.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ne;exports.ShowAddSheetCommentModalOperation=A;
|
package/lib/es/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var E = (o, e, n) =>
|
|
4
|
-
import { Inject as _, Disposable as $, DisposableCollection as
|
|
5
|
-
import { SheetsSelectionsService as
|
|
6
|
-
import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as
|
|
7
|
-
import { ThreadCommentPanelService as ce, SetActiveCommentOperation as te, ThreadCommentTree as
|
|
1
|
+
var ke = Object.defineProperty;
|
|
2
|
+
var Fe = (o, e, n) => e in o ? ke(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
|
|
3
|
+
var E = (o, e, n) => Fe(o, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { Inject as _, Disposable as $, DisposableCollection as We, CommandType as Ze, IUniverInstanceService as N, InterceptorEffectEnum as ze, UniverInstanceType as b, Range as qe, ICommandService as ae, RANGE_TYPE as he, Rectangle as Ge, useDependency as R, Tools as Se, DependentOn as Je, Injector as Ye, Plugin as Ke, IConfigService as Qe } from "@univerjs/core";
|
|
5
|
+
import { SheetsSelectionsService as ge, getSheetCommandTarget as Xe, SheetInterceptorService as Ie, INTERCEPTOR_POINT as et, WorkbookCommentPermission as K, WorksheetViewPermission as Q, RangeProtectionPermissionViewPoint as X, SetWorksheetActiveOperation as tt, RemoveSheetCommand as nt } from "@univerjs/sheets";
|
|
6
|
+
import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as rt } from "@univerjs/sheets-thread-comment";
|
|
7
|
+
import { ThreadCommentPanelService as ce, SetActiveCommentOperation as te, ThreadCommentTree as ot, ThreadCommentPanel as it, ToggleSheetCommentPanelOperation as Pe, THREAD_COMMENT_PANEL as st, UniverThreadCommentUIPlugin as at } from "@univerjs/thread-comment-ui";
|
|
8
8
|
import { UniverThreadCommentUIPlugin as Un } from "@univerjs/thread-comment-ui";
|
|
9
|
-
import { SheetCanvasPopManagerService as
|
|
10
|
-
import { IZenZoneService as
|
|
11
|
-
import { BehaviorSubject as
|
|
12
|
-
import { IRenderManagerService as
|
|
13
|
-
import { singleReferenceToGrid as V, serializeRange as
|
|
14
|
-
import { IThreadCommentDataSourceService as
|
|
9
|
+
import { SheetCanvasPopManagerService as ct, ISheetClipboardService as ut, COPY_TYPE as mt, HoverManagerService as dt, SheetPermissionInterceptorBaseController as Te, IMarkSelectionService as be, IEditorBridgeService as ht, SheetSkeletonManagerService as lt, ScrollToRangeOperation as pt, whenSheetEditorFocused as _t, getCurrentRangeDisable$ as Me } from "@univerjs/sheets-ui";
|
|
10
|
+
import { IZenZoneService as vt, useObservable as A, KeyCode as ft, MetaKeys as le, MenuItemType as we, getMenuHiddenObservable as ye, RibbonStartGroup as Ct, ContextMenuPosition as St, ContextMenuGroup as gt, ComponentManager as It, IMenuManagerService as Pt, IShortcutService as Tt } from "@univerjs/ui";
|
|
11
|
+
import { BehaviorSubject as bt, debounceTime as ue, map as Mt } from "rxjs";
|
|
12
|
+
import { IRenderManagerService as Ee } from "@univerjs/engine-render";
|
|
13
|
+
import { singleReferenceToGrid as V, serializeRange as wt } from "@univerjs/engine-formula";
|
|
14
|
+
import { IThreadCommentDataSourceService as Re, DeleteCommentMutation as F, AddCommentMutation as se, ThreadCommentModel as yt } from "@univerjs/thread-comment";
|
|
15
15
|
import { AddCommentCommand as Nn, DeleteCommentCommand as xn, DeleteCommentTreeCommand as Dn, IThreadCommentDataSourceService as jn, ResolveCommentCommand as An, UpdateCommentCommand as Vn } from "@univerjs/thread-comment";
|
|
16
|
-
import
|
|
17
|
-
const
|
|
18
|
-
var
|
|
19
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
16
|
+
import Et, { forwardRef as Oe, useRef as Ue, createElement as $e, useMemo as Rt, useCallback as pe, useEffect as Ot } from "react";
|
|
17
|
+
const Ne = "univer.sheet.thread-comment-modal", me = "comment-single", xe = "SHEET_THREAD_COMMENT";
|
|
18
|
+
var Ut = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, Nt = (o, e, n, t) => {
|
|
19
|
+
for (var r = t > 1 ? void 0 : t ? $t(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
20
20
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
21
|
-
return t && r &&
|
|
21
|
+
return t && r && Ut(e, n, r), r;
|
|
22
22
|
}, _e = (o, e) => (n, t) => e(n, t, o);
|
|
23
23
|
let O = class extends $ {
|
|
24
24
|
constructor(e, n) {
|
|
25
25
|
super();
|
|
26
26
|
E(this, "_lastPopup", null);
|
|
27
27
|
E(this, "_activePopup");
|
|
28
|
-
E(this, "_activePopup$", new
|
|
28
|
+
E(this, "_activePopup$", new bt(null));
|
|
29
29
|
E(this, "activePopup$", this._activePopup$.asObservable());
|
|
30
30
|
this._canvasPopupManagerService = e, this._zenZoneService = n, this._initZenVisible(), this.disposeWithMe(() => {
|
|
31
31
|
this._activePopup$.complete();
|
|
@@ -53,7 +53,7 @@ let O = class extends $ {
|
|
|
53
53
|
t,
|
|
54
54
|
r,
|
|
55
55
|
{
|
|
56
|
-
componentKey:
|
|
56
|
+
componentKey: Ne,
|
|
57
57
|
onClickOutside: () => {
|
|
58
58
|
this.hidePopup();
|
|
59
59
|
},
|
|
@@ -66,7 +66,7 @@ let O = class extends $ {
|
|
|
66
66
|
);
|
|
67
67
|
if (!a)
|
|
68
68
|
throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
|
|
69
|
-
const c = new
|
|
69
|
+
const c = new We();
|
|
70
70
|
c.add(a), c.add({
|
|
71
71
|
dispose: () => {
|
|
72
72
|
n == null || n();
|
|
@@ -83,19 +83,19 @@ let O = class extends $ {
|
|
|
83
83
|
}, this._activePopup$.next(this._activePopup));
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
O =
|
|
87
|
-
_e(0, _(
|
|
88
|
-
_e(1,
|
|
86
|
+
O = Nt([
|
|
87
|
+
_e(0, _(ct)),
|
|
88
|
+
_e(1, vt)
|
|
89
89
|
], O);
|
|
90
90
|
const B = {
|
|
91
|
-
type:
|
|
91
|
+
type: Ze.OPERATION,
|
|
92
92
|
id: "sheets.operation.show-comment-modal",
|
|
93
93
|
handler(o) {
|
|
94
94
|
var v;
|
|
95
|
-
const e = o.get(
|
|
95
|
+
const e = o.get(ge), n = o.get(N), t = o.get(O), r = o.get(ce), i = (v = e.getCurrentLastSelection()) == null ? void 0 : v.primary, s = o.get(x);
|
|
96
96
|
if (!i)
|
|
97
97
|
return !1;
|
|
98
|
-
const a =
|
|
98
|
+
const a = Xe(n);
|
|
99
99
|
if (!a)
|
|
100
100
|
return !1;
|
|
101
101
|
const { workbook: c, worksheet: d, unitId: u, subUnitId: m } = a, h = {
|
|
@@ -115,7 +115,7 @@ const B = {
|
|
|
115
115
|
trigger: "context-menu"
|
|
116
116
|
}), !0;
|
|
117
117
|
}
|
|
118
|
-
},
|
|
118
|
+
}, xt = "sheets-thread-comment.config", ve = {};
|
|
119
119
|
var Dt = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, At = (o, e, n, t) => {
|
|
120
120
|
for (var r = t > 1 ? void 0 : t ? jt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
121
121
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
@@ -128,9 +128,9 @@ let W = class extends $ {
|
|
|
128
128
|
_initViewModelIntercept() {
|
|
129
129
|
this.disposeWithMe(
|
|
130
130
|
this._sheetInterceptorService.intercept(
|
|
131
|
-
|
|
131
|
+
et.CELL_CONTENT,
|
|
132
132
|
{
|
|
133
|
-
effect:
|
|
133
|
+
effect: ze.Style,
|
|
134
134
|
handler: (o, e, n) => {
|
|
135
135
|
const { row: t, col: r, unitId: i, subUnitId: s } = e;
|
|
136
136
|
return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, r) ? n({
|
|
@@ -163,10 +163,10 @@ let W = class extends $ {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
W = At([
|
|
166
|
-
H(0, _(
|
|
166
|
+
H(0, _(Ie)),
|
|
167
167
|
H(1, _(x)),
|
|
168
168
|
H(2, N),
|
|
169
|
-
H(3,
|
|
169
|
+
H(3, Ee)
|
|
170
170
|
], W);
|
|
171
171
|
var Vt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, Ht = (o, e, n, t) => {
|
|
172
172
|
for (var r = t > 1 ? void 0 : t ? Bt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -180,7 +180,7 @@ const Lt = (o, e, n) => {
|
|
|
180
180
|
endColumn: t.column + i,
|
|
181
181
|
endRow: t.row + r
|
|
182
182
|
};
|
|
183
|
-
return
|
|
183
|
+
return wt(s);
|
|
184
184
|
};
|
|
185
185
|
let Z = class extends $ {
|
|
186
186
|
constructor(e, n, t) {
|
|
@@ -192,7 +192,7 @@ let Z = class extends $ {
|
|
|
192
192
|
_initClipboardHook() {
|
|
193
193
|
this.disposeWithMe(
|
|
194
194
|
this._sheetClipboardService.addClipboardHook({
|
|
195
|
-
id:
|
|
195
|
+
id: xe,
|
|
196
196
|
onBeforeCopy: (e, n, t) => {
|
|
197
197
|
this._copyInfo = {
|
|
198
198
|
unitId: e,
|
|
@@ -206,14 +206,14 @@ let Z = class extends $ {
|
|
|
206
206
|
row: a.rows[0],
|
|
207
207
|
column: a.cols[0]
|
|
208
208
|
};
|
|
209
|
-
if (r.copyType ===
|
|
209
|
+
if (r.copyType === mt.CUT && this._copyInfo) {
|
|
210
210
|
const { range: d, unitId: u, subUnitId: m } = this._copyInfo, h = {
|
|
211
211
|
row: d.startRow,
|
|
212
212
|
column: d.startColumn
|
|
213
213
|
};
|
|
214
214
|
if (!(i === u && s === m)) {
|
|
215
215
|
const l = [];
|
|
216
|
-
|
|
216
|
+
qe.foreach(d, (g, p) => {
|
|
217
217
|
const I = this._sheetsThreadCommentModel.getAllByLocation(u, m, g, p);
|
|
218
218
|
this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((f) => {
|
|
219
219
|
l.push(f);
|
|
@@ -277,9 +277,9 @@ let Z = class extends $ {
|
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
279
|
Z = Ht([
|
|
280
|
-
ne(0, _(
|
|
280
|
+
ne(0, _(ut)),
|
|
281
281
|
ne(1, _(x)),
|
|
282
|
-
ne(2,
|
|
282
|
+
ne(2, Re)
|
|
283
283
|
], Z);
|
|
284
284
|
var kt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, Wt = (o, e, n, t) => {
|
|
285
285
|
for (var r = t > 1 ? void 0 : t ? Ft(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -320,10 +320,10 @@ let z = class extends $ {
|
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
z = Wt([
|
|
323
|
-
L(0, _(
|
|
323
|
+
L(0, _(dt)),
|
|
324
324
|
L(1, _(O)),
|
|
325
325
|
L(2, _(x)),
|
|
326
|
-
L(3, _(
|
|
326
|
+
L(3, _(Te))
|
|
327
327
|
], z);
|
|
328
328
|
var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, qt = (o, e, n, t) => {
|
|
329
329
|
for (var r = t > 1 ? void 0 : t ? zt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -339,11 +339,11 @@ let q = class extends $ {
|
|
|
339
339
|
}
|
|
340
340
|
_handleSelectionChange(e, n, t) {
|
|
341
341
|
var h, l, v;
|
|
342
|
-
const r = (h = e[0]) == null ? void 0 : h.range, i = this._renderManagerService.getRenderById(n), s = (l = i == null ? void 0 : i.with(
|
|
342
|
+
const r = (h = e[0]) == null ? void 0 : h.range, i = this._renderManagerService.getRenderById(n), s = (l = i == null ? void 0 : i.with(lt).getWorksheetSkeleton(t)) == null ? void 0 : l.skeleton;
|
|
343
343
|
if (!s || !r)
|
|
344
344
|
return;
|
|
345
345
|
const a = s.getCellWithCoordByIndex(r.startRow, r.startColumn);
|
|
346
|
-
if ((((v = r.rangeType) != null ? v : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) &&
|
|
346
|
+
if ((((v = r.rangeType) != null ? v : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && Ge.equals(a.mergeInfo, r))) {
|
|
347
347
|
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
@@ -397,7 +397,7 @@ let q = class extends $ {
|
|
|
397
397
|
const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
|
|
398
398
|
if (!c || c.getUnitId() !== t)
|
|
399
399
|
return;
|
|
400
|
-
this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(
|
|
400
|
+
this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(tt.id, {
|
|
401
401
|
unitId: t,
|
|
402
402
|
subUnitId: r
|
|
403
403
|
}), this._isSwitchToCommenting = !1;
|
|
@@ -409,7 +409,7 @@ let q = class extends $ {
|
|
|
409
409
|
}, [{ startRow: h, startColumn: l, endRow: h, endColumn: l }]))
|
|
410
410
|
return;
|
|
411
411
|
const S = 1;
|
|
412
|
-
if (await this._commandService.executeCommand(
|
|
412
|
+
if (await this._commandService.executeCommand(pt.id, {
|
|
413
413
|
range: {
|
|
414
414
|
startRow: Math.max(m.row - S, 0),
|
|
415
415
|
endRow: m.row + S,
|
|
@@ -478,11 +478,11 @@ q = qt([
|
|
|
478
478
|
w(2, _(x)),
|
|
479
479
|
w(3, _(ce)),
|
|
480
480
|
w(4, N),
|
|
481
|
-
w(5, _(
|
|
482
|
-
w(6,
|
|
483
|
-
w(7, _(
|
|
484
|
-
w(8,
|
|
485
|
-
w(9,
|
|
481
|
+
w(5, _(Te)),
|
|
482
|
+
w(6, be),
|
|
483
|
+
w(7, _(ge)),
|
|
484
|
+
w(8, ht),
|
|
485
|
+
w(9, Ee)
|
|
486
486
|
], q);
|
|
487
487
|
var Gt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, Yt = (o, e, n, t) => {
|
|
488
488
|
for (var r = t > 1 ? void 0 : t ? Jt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -498,7 +498,7 @@ let G = class extends $ {
|
|
|
498
498
|
this._sheetInterceptorService.interceptCommand({
|
|
499
499
|
getMutations: (o) => {
|
|
500
500
|
var e;
|
|
501
|
-
if (o.id ===
|
|
501
|
+
if (o.id === nt.id) {
|
|
502
502
|
const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
|
|
503
503
|
if (!t)
|
|
504
504
|
return { redos: [], undos: [] };
|
|
@@ -533,10 +533,10 @@ let G = class extends $ {
|
|
|
533
533
|
}
|
|
534
534
|
};
|
|
535
535
|
G = Yt([
|
|
536
|
-
k(0, _(
|
|
536
|
+
k(0, _(Ie)),
|
|
537
537
|
k(1, N),
|
|
538
|
-
k(2, _(
|
|
539
|
-
k(3,
|
|
538
|
+
k(2, _(yt)),
|
|
539
|
+
k(3, Re)
|
|
540
540
|
], G);
|
|
541
541
|
var P = function() {
|
|
542
542
|
return P = Object.assign || function(o) {
|
|
@@ -553,13 +553,13 @@ var P = function() {
|
|
|
553
553
|
for (var r = 0, t = Object.getOwnPropertySymbols(o); r < t.length; r++)
|
|
554
554
|
e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
|
|
555
555
|
return n;
|
|
556
|
-
},
|
|
557
|
-
var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Kt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c =
|
|
558
|
-
return
|
|
556
|
+
}, De = Oe(function(o, e) {
|
|
557
|
+
var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Kt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c = Ue("_".concat(en()));
|
|
558
|
+
return je(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, P({ ref: e, className: a }, s), i);
|
|
559
559
|
});
|
|
560
|
-
function
|
|
561
|
-
return
|
|
562
|
-
return
|
|
560
|
+
function je(o, e, n, t, r) {
|
|
561
|
+
return $e(o.tag, P(P({ key: e }, Qt(o, n, r)), t), (Xt(o, n).children || []).map(function(i, s) {
|
|
562
|
+
return je(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
|
|
563
563
|
}));
|
|
564
564
|
}
|
|
565
565
|
function Qt(o, e, n) {
|
|
@@ -580,15 +580,15 @@ function Xt(o, e) {
|
|
|
580
580
|
function en() {
|
|
581
581
|
return Math.random().toString(36).substring(2, 8);
|
|
582
582
|
}
|
|
583
|
-
|
|
584
|
-
var tn = { 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" } }] },
|
|
585
|
-
return
|
|
583
|
+
De.displayName = "UniverIcon";
|
|
584
|
+
var tn = { 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" } }] }, Ae = Oe(function(o, e) {
|
|
585
|
+
return $e(De, Object.assign({}, o, {
|
|
586
586
|
id: "comment-single",
|
|
587
587
|
ref: e,
|
|
588
588
|
icon: tn
|
|
589
589
|
}));
|
|
590
590
|
});
|
|
591
|
-
|
|
591
|
+
Ae.displayName = "CommentSingle";
|
|
592
592
|
var re = { exports: {} }, j = {};
|
|
593
593
|
/**
|
|
594
594
|
* @license React
|
|
@@ -599,11 +599,11 @@ var re = { exports: {} }, j = {};
|
|
|
599
599
|
* This source code is licensed under the MIT license found in the
|
|
600
600
|
* LICENSE file in the root directory of this source tree.
|
|
601
601
|
*/
|
|
602
|
-
var
|
|
602
|
+
var fe;
|
|
603
603
|
function nn() {
|
|
604
|
-
if (
|
|
605
|
-
|
|
606
|
-
var o =
|
|
604
|
+
if (fe) return j;
|
|
605
|
+
fe = 1;
|
|
606
|
+
var o = Et, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
607
607
|
function s(a, c, d) {
|
|
608
608
|
var u, m = {}, h = null, l = null;
|
|
609
609
|
d !== void 0 && (h = "" + d), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (l = c.ref);
|
|
@@ -613,23 +613,23 @@ function nn() {
|
|
|
613
613
|
}
|
|
614
614
|
return j.Fragment = n, j.jsx = s, j.jsxs = s, j;
|
|
615
615
|
}
|
|
616
|
-
var
|
|
616
|
+
var Ce;
|
|
617
617
|
function rn() {
|
|
618
|
-
return
|
|
618
|
+
return Ce || (Ce = 1, re.exports = nn()), re.exports;
|
|
619
619
|
}
|
|
620
|
-
var
|
|
620
|
+
var Ve = rn();
|
|
621
621
|
const on = () => {
|
|
622
622
|
const o = R(N), e = R(O), n = A(e.activePopup$), t = R(x);
|
|
623
623
|
if (A(t.commentUpdate$), !n)
|
|
624
624
|
return null;
|
|
625
|
-
const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, d = t.getByLocation(s, a, r, i), u = `${
|
|
625
|
+
const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, d = t.getByLocation(s, a, r, i), u = `${Se.chatAtABC(i)}${r + 1}`, m = () => {
|
|
626
626
|
e.hidePopup();
|
|
627
627
|
}, h = (l) => {
|
|
628
628
|
var v, S, U;
|
|
629
629
|
return (U = (S = (v = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : v.getSheetBySheetId(l)) == null ? void 0 : S.getName()) != null ? U : "";
|
|
630
630
|
};
|
|
631
|
-
return /* @__PURE__ */
|
|
632
|
-
|
|
631
|
+
return /* @__PURE__ */ Ve.jsx(
|
|
632
|
+
ot,
|
|
633
633
|
{
|
|
634
634
|
onClick: () => {
|
|
635
635
|
e.persistPopup();
|
|
@@ -647,15 +647,15 @@ const on = () => {
|
|
|
647
647
|
);
|
|
648
648
|
}, sn = () => {
|
|
649
649
|
var g;
|
|
650
|
-
const o = R(
|
|
650
|
+
const o = R(be), e = R(N), n = R(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = R(ae), s = Rt(() => t.activeSheet$.pipe(Mt((p) => p == null ? void 0 : p.getSheetId())), [t.activeSheet$]), a = A(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = Ue(), d = R(ce), u = A(d.activeCommentId$), m = A(d.panelVisible$, d.panelVisible), h = pe((p) => {
|
|
651
651
|
const I = t.getSheets(), f = {};
|
|
652
652
|
I.forEach((T, C) => {
|
|
653
653
|
f[T.getSheetId()] = C;
|
|
654
654
|
});
|
|
655
655
|
const M = (T) => T.map((C) => {
|
|
656
656
|
var de;
|
|
657
|
-
const y = V(C.ref),
|
|
658
|
-
return { ...C, p:
|
|
657
|
+
const y = V(C.ref), Le = [(de = f[C.subUnitId]) != null ? de : 0, y.row, y.column];
|
|
658
|
+
return { ...C, p: Le };
|
|
659
659
|
}).sort((C, y) => C.p[0] === y.p[0] ? C.p[1] === y.p[1] ? C.p[2] - y.p[2] : C.p[1] - y.p[1] : C.p[0] - y.p[0]);
|
|
660
660
|
return [
|
|
661
661
|
...M(p.filter((T) => !T.resolved)),
|
|
@@ -695,10 +695,10 @@ const on = () => {
|
|
|
695
695
|
}, ee = (p, I) => {
|
|
696
696
|
I && n.hidePopup();
|
|
697
697
|
};
|
|
698
|
-
return
|
|
698
|
+
return Ot(() => {
|
|
699
699
|
!m && c.current && o.removeShape(c.current);
|
|
700
|
-
}, [o, m]), /* @__PURE__ */
|
|
701
|
-
|
|
700
|
+
}, [o, m]), /* @__PURE__ */ Ve.jsx(
|
|
701
|
+
it,
|
|
702
702
|
{
|
|
703
703
|
unitId: r,
|
|
704
704
|
subUnitId$: s,
|
|
@@ -714,39 +714,39 @@ const on = () => {
|
|
|
714
714
|
);
|
|
715
715
|
}, an = (o) => ({
|
|
716
716
|
id: B.id,
|
|
717
|
-
type:
|
|
717
|
+
type: we.BUTTON,
|
|
718
718
|
icon: me,
|
|
719
719
|
title: "sheetThreadComment.menu.addComment",
|
|
720
|
-
hidden$:
|
|
721
|
-
disabled$:
|
|
720
|
+
hidden$: ye(o, b.UNIVER_SHEET),
|
|
721
|
+
disabled$: Me(o, {
|
|
722
722
|
workbookTypes: [K],
|
|
723
723
|
worksheetTypes: [Q],
|
|
724
724
|
rangeTypes: [X]
|
|
725
725
|
})
|
|
726
726
|
}), cn = (o) => ({
|
|
727
|
-
id:
|
|
728
|
-
type:
|
|
727
|
+
id: Pe.id,
|
|
728
|
+
type: we.BUTTON,
|
|
729
729
|
icon: me,
|
|
730
730
|
tooltip: "sheetThreadComment.menu.commentManagement",
|
|
731
|
-
disabled$:
|
|
731
|
+
disabled$: Me(o, {
|
|
732
732
|
workbookTypes: [K],
|
|
733
733
|
worksheetTypes: [Q],
|
|
734
734
|
rangeTypes: [X]
|
|
735
735
|
}),
|
|
736
|
-
hidden$:
|
|
736
|
+
hidden$: ye(o, b.UNIVER_SHEET)
|
|
737
737
|
}), un = {
|
|
738
738
|
id: B.id,
|
|
739
|
-
binding:
|
|
740
|
-
preconditions:
|
|
739
|
+
binding: ft.M | le.CTRL_COMMAND | le.ALT,
|
|
740
|
+
preconditions: _t
|
|
741
741
|
}, mn = {
|
|
742
|
-
[
|
|
743
|
-
[
|
|
742
|
+
[Ct.OTHERS]: {
|
|
743
|
+
[Pe.id]: {
|
|
744
744
|
order: 1,
|
|
745
745
|
menuItemFactory: cn
|
|
746
746
|
}
|
|
747
747
|
},
|
|
748
|
-
[
|
|
749
|
-
[
|
|
748
|
+
[St.MAIN_AREA]: {
|
|
749
|
+
[gt.OTHERS]: {
|
|
750
750
|
[B.id]: {
|
|
751
751
|
order: 0,
|
|
752
752
|
menuItemFactory: an
|
|
@@ -771,29 +771,32 @@ let J = class extends $ {
|
|
|
771
771
|
}
|
|
772
772
|
_initComponent() {
|
|
773
773
|
[
|
|
774
|
-
[
|
|
775
|
-
[
|
|
776
|
-
[me,
|
|
774
|
+
[Ne, on],
|
|
775
|
+
[st, sn],
|
|
776
|
+
[me, Ae]
|
|
777
777
|
].forEach(([o, e]) => {
|
|
778
778
|
this._componentManager.register(o, e);
|
|
779
779
|
});
|
|
780
780
|
}
|
|
781
781
|
};
|
|
782
782
|
J = ln([
|
|
783
|
-
oe(0,
|
|
784
|
-
oe(1, _(
|
|
785
|
-
oe(2,
|
|
783
|
+
oe(0, Pt),
|
|
784
|
+
oe(1, _(It)),
|
|
785
|
+
oe(2, Tt)
|
|
786
786
|
], J);
|
|
787
|
-
var
|
|
787
|
+
var Be = Object.defineProperty, pn = Object.getOwnPropertyDescriptor, _n = (o, e, n) => e in o ? Be(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, vn = (o, e, n, t) => {
|
|
788
788
|
for (var r = t > 1 ? void 0 : t ? pn(e, n) : e, i = o.length - 1, s; i >= 0; i--)
|
|
789
789
|
(s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
790
|
-
return t && r &&
|
|
791
|
-
}, ie = (o, e) => (n, t) => e(n, t, o),
|
|
792
|
-
let Y = class extends
|
|
793
|
-
constructor(o =
|
|
790
|
+
return t && r && Be(e, n, r), r;
|
|
791
|
+
}, ie = (o, e) => (n, t) => e(n, t, o), He = (o, e, n) => _n(o, typeof e != "symbol" ? e + "" : e, n);
|
|
792
|
+
let Y = class extends Ke {
|
|
793
|
+
constructor(o = ve, e, n, t) {
|
|
794
794
|
super(), this._config = o, this._injector = e, this._commandService = n, this._configService = t;
|
|
795
|
-
const { menu: r, ...i } =
|
|
796
|
-
|
|
795
|
+
const { menu: r, ...i } = Se.deepMerge(
|
|
796
|
+
ve,
|
|
797
|
+
this._config
|
|
798
|
+
);
|
|
799
|
+
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(xt, i);
|
|
797
800
|
}
|
|
798
801
|
onStarting() {
|
|
799
802
|
[
|
|
@@ -817,13 +820,13 @@ let Y = class extends Ye {
|
|
|
817
820
|
this._injector.get(Z), this._injector.get(z), this._injector.get(q);
|
|
818
821
|
}
|
|
819
822
|
};
|
|
820
|
-
|
|
821
|
-
|
|
823
|
+
He(Y, "pluginName", xe);
|
|
824
|
+
He(Y, "type", b.UNIVER_SHEET);
|
|
822
825
|
Y = vn([
|
|
823
|
-
|
|
824
|
-
ie(1, _(
|
|
826
|
+
Je(at, rt),
|
|
827
|
+
ie(1, _(Ye)),
|
|
825
828
|
ie(2, _(ae)),
|
|
826
|
-
ie(3,
|
|
829
|
+
ie(3, Qe)
|
|
827
830
|
], Y);
|
|
828
831
|
export {
|
|
829
832
|
Nn as AddCommentCommand,
|
|
@@ -831,7 +834,7 @@ export {
|
|
|
831
834
|
Dn as DeleteCommentTreeCommand,
|
|
832
835
|
jn as IThreadCommentDataSourceService,
|
|
833
836
|
An as ResolveCommentCommand,
|
|
834
|
-
|
|
837
|
+
xe as SHEETS_THREAD_COMMENT,
|
|
835
838
|
O as SheetsThreadCommentPopupService,
|
|
836
839
|
B as ShowAddSheetCommentModalOperation,
|
|
837
840
|
Y as UniverSheetsThreadCommentUIPlugin,
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],a):(d=typeof globalThis<"u"?globalThis:d||self,a(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,a,v,A,P,I,f,k,ie,$,C,E){"use strict";var rt=Object.defineProperty;var it=(d,a,v)=>a in d?rt(d,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[a]=v;var N=(d,a,v)=>it(d,typeof a!="symbol"?a+"":a,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var Se=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(i,t,n,e)=>{for(var r=e>1?void 0:e?_e(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Se(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var m;const{row:r,col:o,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new a.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},d.SheetsThreadCommentPopupService=fe([se(0,a.Inject(I.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const B={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var g;const t=i.get(v.SheetsSelectionsService),n=i.get(a.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(P.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=s.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ce="sheets-thread-comment.config",Ie={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ge(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends a.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([L(0,a.Inject(v.SheetInterceptorService)),L(1,a.Inject(A.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=$.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,s={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return $.serializeRange(s)};let F=class extends a.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:s,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&s===l)){const S=[];a.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(T=>{S.push(T)}):R.forEach(({children:T,...j})=>{j.parentId||S.push(j)})});const g=[],M=[],V=[],H=[],re=w=>{g.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:s},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...g,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,a.Inject(I.ISheetClipboardService)),X(1,a.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends a.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,a.Inject(I.HoverManagerService)),G(1,a.Inject(d.SheetsThreadCommentPopupService)),G(2,a.Inject(A.SheetsThreadCommentModel)),G(3,a.Inject(I.SheetPermissionInterceptorBaseController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends a.Disposable{constructor(t,n,e,r,o,s,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,g;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),s=(S=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((g=r.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:s}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=$.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const s=$.singleReferenceToGrid(o.ref),{row:c,column:u}=s;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,a.ICommandService),U(1,a.Inject(d.SheetsThreadCommentPopupService)),U(2,a.Inject(A.SheetsThreadCommentModel)),U(3,a.Inject(P.ThreadCommentPanelService)),U(4,a.IUniverInstanceService),U(5,a.Inject(I.SheetPermissionInterceptorBaseController)),U(6,I.IMarkSelectionService),U(7,a.Inject(v.SheetsSelectionsService)),U(8,I.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends a.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,o),c=Array.from(s.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,a.Inject(v.SheetInterceptorService)),q(1,a.IUniverInstanceService),q(2,a.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},$e=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ae=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,s=$e(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(xe()));return ce(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},s),o)});function ce(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},Be(i,n,r)),e),(ke(i,n).children||[]).map(function(o,s){return ce(o,"".concat(t,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function Be(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ke(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function xe(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=E.forwardRef(function(i,t){return E.createElement(ae,Object.assign({},i,{id:"comment-single",ref:t,icon:He}))});ue.displayName="CommentSingle";var ee={exports:{}},x={};/**
|
|
1
|
+
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,s,v,A,P,I,f,k,ie,$,C,E){"use strict";var rt=Object.defineProperty;var it=(d,s,v)=>s in d?rt(d,s,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[s]=v;var N=(d,s,v)=>it(d,typeof s!="symbol"?s+"":s,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ce=(i,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_e(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var m;const{row:r,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},d.SheetsThreadCommentPopupService=Ce([se(0,s.Inject(I.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const B={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var g;const t=i.get(v.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(P.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,a=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=a.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ae={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ge(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([L(0,s.Inject(v.SheetInterceptorService)),L(1,s.Inject(A.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=$.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return $.serializeRange(a)};let F=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&a===l)){const S=[];s.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(T=>{S.push(T)}):R.forEach(({children:T,...j})=>{j.parentId||S.push(j)})});const g=[],M=[],V=[],H=[],re=w=>{g.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...g,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,s.Inject(I.ISheetClipboardService)),X(1,s.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,s.Inject(I.HoverManagerService)),G(1,s.Inject(d.SheetsThreadCommentPopupService)),G(2,s.Inject(A.SheetsThreadCommentModel)),G(3,s.Inject(I.SheetPermissionInterceptorBaseController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(t,n,e,r,o,a,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,g;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),a=(S=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!a||!r)return;const c=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((g=r.rangeType)!=null?g:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=$.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=$.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,s.ICommandService),U(1,s.Inject(d.SheetsThreadCommentPopupService)),U(2,s.Inject(A.SheetsThreadCommentModel)),U(3,s.Inject(P.ThreadCommentPanelService)),U(4,s.IUniverInstanceService),U(5,s.Inject(I.SheetPermissionInterceptorBaseController)),U(6,I.IMarkSelectionService),U(7,s.Inject(v.SheetsSelectionsService)),U(8,I.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),c=Array.from(a.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,s.Inject(v.SheetInterceptorService)),q(1,s.IUniverInstanceService),q(2,s.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},$e=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ce=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=$e(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(xe()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ue(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},Be(i,n,r)),e),(ke(i,n).children||[]).map(function(o,a){return ue(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function Be(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ke(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function xe(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=E.forwardRef(function(i,t){return E.createElement(ce,Object.assign({},i,{id:"comment-single",ref:t,icon:He}))});de.displayName="CommentSingle";var ee={exports:{}},x={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var me;function Le(){if(me)return x;me=1;var i=E,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,h){var m,l={},p=null,S=null;h!==void 0&&(p=""+h),u.key!==void 0&&(p=""+u.key),u.ref!==void 0&&(S=u.ref);for(m in u)e.call(u,m)&&!o.hasOwnProperty(m)&&(l[m]=u[m]);if(c&&c.defaultProps)for(m in u=c.defaultProps,u)l[m]===void 0&&(l[m]=u[m]);return{$$typeof:t,type:c,key:p,ref:S,props:l,_owner:r.current}}return x.Fragment=n,x.jsx=a,x.jsxs=a,x}var he;function We(){return he||(he=1,ee.exports=Le()),ee.exports}var le=We();const Fe=()=>{const i=s.useDependency(s.IUniverInstanceService),t=s.useDependency(d.SheetsThreadCommentPopupService),n=f.useObservable(t.activePopup$),e=s.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:a,subUnitId:c,trigger:u}=n,h=e.getByLocation(a,c,r,o),m=`${s.Tools.chatAtABC(o)}${r+1}`,l=()=>{t.hidePopup()},p=S=>{var g,M,V;return(V=(M=(g=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:M.getName())!=null?V:""};return le.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:l,getSubUnitName:p,autoFocus:u==="context-menu"})},Ge=()=>{var w;const i=s.useDependency(I.IMarkSelectionService),t=s.useDependency(s.IUniverInstanceService),n=s.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=s.useDependency(s.ICommandService),a=E.useMemo(()=>e.activeSheet$.pipe(k.map(_=>_==null?void 0:_.getSheetId())),[e.activeSheet$]),c=f.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),h=s.useDependency(P.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),l=f.useObservable(h.panelVisible$,h.panelVisible),p=E.useCallback(_=>{const R=e.getSheets(),T={};R.forEach((O,b)=>{T[O.getSheetId()]=b});const j=O=>O.map(b=>{var Se;const D=$.singleReferenceToGrid(b.ref),nt=[(Se=T[b.subUnitId])!=null?Se:0,D.row,D.column];return{...b,p:nt}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(_.filter(O=>!O.resolved)),...j(_.filter(O=>O.resolved))]},[e]),S=E.useCallback(_=>{var R;if(_.unitId===r&&_.subUnitId===c&&!_.resolved){const{row:T,column:j}=$.singleReferenceToGrid(_.ref),O=e.getSheetBySheetId(_.subUnitId),b=(R=O==null?void 0:O.getMergedCell(T,j))!=null?R:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,c,r]),g=_=>{var R,T;return(T=(R=e.getSheetBySheetId(_))==null?void 0:R.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=_=>{m&&m.unitId===_.unitId&&m.subUnitId===_.subUnitId&&m.commentId===_.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=S(_))},H=()=>{u.current&&(i.removeShape(u.current),u.current=null)},re=(_,R)=>{R&&n.hidePopup()};return E.useEffect(()=>{!l&&u.current&&i.removeShape(u.current)},[i,l]),le.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:g,onResolve:re,sortComments:p,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ze=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),ze=i=>({id:P.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET)}),qe={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},Ye={[f.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:ze}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ze}}}};var Je=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Qe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Je(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);let J=class extends s.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(qe)}_initMenu(){this._menuManagerService.mergeMenu(Ye)}_initComponent(){[[oe,Fe],[P.THREAD_COMMENT_PANEL,Ge],[K,de]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};J=Qe([te(0,f.IMenuManagerService),te(1,s.Inject(f.ComponentManager)),te(2,f.IShortcutService)],J);var pe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(i,t,n)=>t in i?pe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,tt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&pe(t,n,r),r},ne=(i,t)=>(n,e)=>t(n,e,i),ve=(i,t,n)=>et(i,typeof t!="symbol"?t+"":t,n);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=ae,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...a}=s.Tools.deepMerge(ae,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ie,a)}onStarting(){[[J],[W],[F],[Z],[Y],[z],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(J)}onReady(){this._injector.get(W),this._injector.get(Y)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(z)}},ve(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),ve(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=tt([s.DependentOn(P.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),ne(1,s.Inject(s.Injector)),ne(2,s.Inject(s.ICommandService)),ne(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Q,d.ShowAddSheetCommentModalOperation=B,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment-ui",
|
|
3
|
-
"version": "0.5.1-nightly.
|
|
3
|
+
"version": "0.5.1-nightly.202412261606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.2.8",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/core": "0.5.1-nightly.
|
|
58
|
-
"@univerjs/engine-formula": "0.5.1-nightly.
|
|
59
|
-
"@univerjs/engine-render": "0.5.1-nightly.
|
|
60
|
-
"@univerjs/sheets": "0.5.1-nightly.
|
|
61
|
-
"@univerjs/sheets-thread-comment": "0.5.1-nightly.
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/thread-comment
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/ui": "0.5.1-nightly.
|
|
57
|
+
"@univerjs/core": "0.5.1-nightly.202412261606",
|
|
58
|
+
"@univerjs/engine-formula": "0.5.1-nightly.202412261606",
|
|
59
|
+
"@univerjs/engine-render": "0.5.1-nightly.202412261606",
|
|
60
|
+
"@univerjs/sheets": "0.5.1-nightly.202412261606",
|
|
61
|
+
"@univerjs/sheets-thread-comment": "0.5.1-nightly.202412261606",
|
|
62
|
+
"@univerjs/sheets-ui": "0.5.1-nightly.202412261606",
|
|
63
|
+
"@univerjs/thread-comment": "0.5.1-nightly.202412261606",
|
|
64
|
+
"@univerjs/thread-comment-ui": "0.5.1-nightly.202412261606",
|
|
65
|
+
"@univerjs/ui": "0.5.1-nightly.202412261606"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"postcss": "^8.4.49",
|