@univerjs/sheets-thread-comment-ui 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -0
- package/lib/es/index.js +139 -139
- package/lib/es/locale/ja-JP.js +11 -0
- package/lib/index.js +139 -139
- package/lib/locale/ja-JP.js +11 -0
- package/lib/types/locale/ja-JP.d.ts +3 -0
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -0
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ae=Object.defineProperty;var me=(r,e,n)=>e in r?ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var k=(r,e,n)=>me(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),f=require("@univerjs/thread-comment-ui"),P=require("@univerjs/sheets-ui"),u=require("@univerjs/ui"),V=require("rxjs"),ee=require("@univerjs/engine-render"),N=require("@univerjs/engine-formula"),w=require("@univerjs/thread-comment"),R=require("react"),te=require("react/jsx-runtime"),ne="univer.sheet.thread-comment-modal",J="SHEET_THREAD_COMMENT";var he=Object.getOwnPropertyDescriptor,de=(r,e,n,t)=>{for(var o=t>1?void 0:t?he(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},G=(r,e)=>(n,t)=>e(n,t,r);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,t,o){super();k(this,"_lastPopup",null);k(this,"_activePopup");k(this,"_activePopup$",new V.BehaviorSubject(null));k(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(n,t){var l;const{row:o,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((l=this.activePopup)==null?void 0:l.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._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:a},{componentKey:ne,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new c.DisposableCollection;h.add(m),h.add({dispose:()=>{t==null||t()}}),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))}};exports.SheetsThreadCommentPopupService=de([G(0,c.Inject(P.SheetCanvasPopManagerService)),G(1,u.IZenZoneService),G(2,c.Inject(P.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const j={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var _;const e=r.get(C.SheetsSelectionsService),n=r.get(c.IUniverInstanceService),t=r.get(exports.SheetsThreadCommentPopupService),o=r.get(f.ThreadCommentPanelService),i=(_=e.getCurrentLastSelection())==null?void 0:_.primary,s=r.get($.SheetsThreadCommentModel);if(!i)return!1;const a=C.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:h,unitId:l,subUnitId:d}=a,S={workbook:m,worksheet:h,unitId:l,subUnitId:d,row:i.startRow,col:i.startColumn};t.showPopup(S);const v=s.getByLocation(l,d,i.startRow,i.startColumn);return v&&o.setActiveComment({unitId:l,subUnitId:d,commentId:v,trigger:"context-menu"}),!0}},ue="sheets-thread-comment.config",X={};var le=Object.getOwnPropertyDescriptor,pe=(r,e,n,t)=>{for(var o=t>1?void 0:t?le(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},x=(r,e)=>(n,t)=>e(n,t,r);let B=class extends c.Disposable{constructor(r,e,n,t){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=e,this._univerInstanceService=n,this._renderManagerService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(r,e,n)=>{const{row:t,col:o,unitId:i,subUnitId:s}=e;return this._sheetsThreadCommentModel.showCommentMarker(i,s,t,o)&&((!r||r===e.rawData)&&(r={...e.rawData}),r.markers={...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}),n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var o;const e=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),t=this._renderManagerService.getRenderById(n);(o=t==null?void 0:t.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{r()}))}};B=pe([x(0,c.Inject(C.SheetInterceptorService)),x(1,c.Inject($.SheetsThreadCommentModel)),x(2,c.IUniverInstanceService),x(3,ee.IRenderManagerService)],B);var Ce=Object.getOwnPropertyDescriptor,ve=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ce(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},z=(r,e)=>(n,t)=>e(n,t,r);const Se=(r,e,n)=>{const t=N.singleReferenceToGrid(r),o=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+o,endColumn:t.column+i,endRow:t.row+o};return N.serializeRange(s)};let L=class extends c.Disposable{constructor(e,n,t){super();k(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:J,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,o)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(o.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:l,subUnitId:d}=this._copyInfo,S={row:h.startRow,column:h.startColumn};if(!(i===l&&s===d)){const v=[];c.Range.foreach(h,(b,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(l,d,b,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{v.push(g)}):M.forEach(({children:g,...U})=>{U.parentId||v.push(U)})});const _=[],T=[],D=[],A=[],q=b=>{_.unshift({id:w.DeleteCommentMutation.id,params:{unitId:l,subUnitId:d,commentId:b.id}}),D.push({id:w.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Se(b.ref,S,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:w.AddCommentMutation.id,params:{unitId:l,subUnitId:d,comment:b,sync:!0}}),A.unshift({id:w.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return v.forEach(b=>{q(b)}),{redos:[..._,...D],undos:[...A,...T]}}}return{redos:[],undos:[]}}}))}};L=ve([z(0,c.Inject(P.ISheetClipboardService)),z(1,c.Inject($.SheetsThreadCommentModel)),z(2,w.IThreadCommentDataSourceService)],L);var _e=Object.getOwnPropertyDescriptor,ge=(r,e,n,t)=>{for(var o=t>1?void 0:t?_e(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},H=(r,e)=>(n,t)=>e(n,t,r);let W=class extends c.Disposable{constructor(r,e,n,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(r=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(r&&(e&&e.temp||!e)){const{location:n}=r,{unitId:t,subUnitId:o,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(t,o,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const h=this._sheetsThreadCommentModel.getComment(t,o,a);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:o,row:i,col:s,commentId:a,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};W=ge([H(0,c.Inject(P.HoverManagerService)),H(1,c.Inject(exports.SheetsThreadCommentPopupService)),H(2,c.Inject($.SheetsThreadCommentModel)),H(3,c.Inject(C.SheetPermissionCheckController))],W);var Ie=Object.getOwnPropertyDescriptor,fe=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ie(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},E=(r,e)=>(n,t)=>e(n,t,r);let F=class extends c.Disposable{constructor(e,n,t,o,i,s,a,m,h,l){super();k(this,"_isSwitchToCommenting",!1);k(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=h,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var S,v,_;const o=(S=e[0])==null?void 0:S.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(P.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:v.skeleton;if(!s||!o)return;const a=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((_=o.rangeType)!=null?_:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(f.SetActiveCommentOperation.id);return}const h=a.actualRow,l=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,h,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(f.SetActiveCommentOperation.id);return}const d=this._sheetsThreadCommentModel.getByLocation(n,t,h,l);d&&this._commandService.executeCommand(f.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:d})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(e,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===w.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:o,subUnitId:i,commentId:s}=t;n.unitId===o&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{var n;if(e){const{unitId:t,subUnitId:o,commentId:i,trigger:s}=e,a=this._sheetsThreadCommentModel.getComment(t,o,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:o}),this._isSwitchToCommenting=!1;const d=N.singleReferenceToGrid(a.ref),{row:S,column:v}=d;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:v,endRow:S,endColumn:v}]))return;const T=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-T,0),endRow:d.row+T,startColumn:Math.max(d.column-T,0),endColumn:d.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:o,row:d.row,col:d.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(e=>{var S,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:o}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,o);if(!i)return;const s=N.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const h=(S=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(t),l=(v=h==null?void 0:h.getMergedCell(a,m))!=null?v:{startColumn:m,endColumn:m,startRow:a,endRow:a},d=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);d&&(this._selectionShapeInfo={...e,shapeId:d})}))}};F=fe([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(f.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(C.SheetPermissionCheckController)),E(6,P.IMarkSelectionService),E(7,c.Inject(C.SheetsSelectionsService)),E(8,P.IEditorBridgeService),E(9,ee.IRenderManagerService)],F);function re({ref:r,...e}){const{icon:n,id:t,className:o,extend:i,...s}=e,a=`univerjs-icon univerjs-icon-${t} ${o||""}`.trim(),m=R.useRef(`_${be()}`);return oe(n,`${t}`,{defIds:n.defIds,idSuffix:m.current},{ref:r,className:a,...s},i)}function oe(r,e,n,t,o){return R.createElement(r.tag,{key:e,...Pe(r,n,o),...t},(Te(r,n).children||[]).map((i,s)=>oe(i,`${e}-${r.tag}-${s}`,n,void 0,o)))}function Pe(r,e,n){const t={...r.attrs};n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1),r.tag==="mask"&&t.id&&(t.id=t.id+e.idSuffix),Object.entries(t).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(t[i]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(([i,s])=>{typeof s=="string"&&(t[i]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),t}function Te(r,e){var t;const{defIds:n}=e;return!n||n.length===0?r:r.tag==="defs"&&((t=r.children)!=null&&t.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function be(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=R.forwardRef(function(e,n){return R.createElement(re,Object.assign({},e,{id:"comment-icon",ref:n,icon:Me}))});ie.displayName="CommentIcon";const we=()=>{const r=u.useDependency(c.IUniverInstanceService),e=u.useDependency(exports.SheetsThreadCommentPopupService),n=u.useObservable(e.activePopup$),t=u.useDependency($.SheetsThreadCommentModel);if(u.useObservable(t.commentUpdate$),!n)return null;const{row:o,col:i,unitId:s,subUnitId:a,trigger:m}=n,h=t.getByLocation(s,a,o,i),l=`${c.Tools.chatAtABC(i)}${o+1}`,d=()=>{e.hidePopup()},S=v=>{var _,T,D;return(D=(T=(_=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getSheetBySheetId(v))==null?void 0:T.getName())!=null?D:""};return te.jsx(f.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:h,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:d,getSubUnitName:S,autoFocus:m==="context-menu"})},ye=()=>{var b;const r=u.useDependency(P.IMarkSelectionService),e=u.useDependency(c.IUniverInstanceService),n=u.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),o=t.getUnitId(),i=u.useDependency(c.ICommandService),s=R.useMemo(()=>t.activeSheet$.pipe(V.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),a=u.useObservable(s,(b=t.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(null),h=u.useDependency(f.ThreadCommentPanelService),l=u.useObservable(h.activeCommentId$),d=u.useObservable(h.panelVisible$,h.panelVisible),S=R.useCallback(p=>{const M=t.getSheets(),g={};M.forEach((y,I)=>{g[y.getSheetId()]=I});const U=y=>y.map(I=>{var Q;const O=N.singleReferenceToGrid(I.ref),ce=[(Q=g[I.subUnitId])!=null?Q:0,O.row,O.column];return{...I,p:ce}}).sort((I,O)=>I.p[0]===O.p[0]?I.p[1]===O.p[1]?I.p[2]-O.p[2]:I.p[1]-O.p[1]:I.p[0]-O.p[0]);return[...U(p.filter(y=>!y.resolved)),...U(p.filter(y=>y.resolved))]},[t]),v=R.useCallback(p=>{var M;if(p.unitId===o&&p.subUnitId===a&&!p.resolved){const{row:g,column:U}=N.singleReferenceToGrid(p.ref),y=t.getSheetBySheetId(p.subUnitId),I=(M=y==null?void 0:y.getMergedCell(g,U))!=null?M:{startColumn:U,endColumn:U,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(U))return r.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[r,a,o]),_=p=>{var M,g;return(g=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?g:""},T=()=>{i.executeCommand(j.id)},D=p=>{l&&l.unitId===p.unitId&&l.subUnitId===p.subUnitId&&l.commentId===p.id||(m.current&&(r.removeShape(m.current),m.current=null),m.current=v(p))},A=()=>{m.current&&(r.removeShape(m.current),m.current=null)},q=(p,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!d&&m.current&&r.removeShape(m.current)},[r,d]),te.jsx(f.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:_,onResolve:q,sortComments:S,onItemEnter:D,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},Ue=r=>({id:j.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:u.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ee=r=>({id:f.ToggleSheetCommentPanelOperation.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:u.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET)}),Re={id:j.id,binding:u.KeyCode.M|u.MetaKeys.CTRL_COMMAND|u.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},Oe={[u.RibbonInsertGroup.MEDIA]:{[f.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:Ee}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.OTHERS]:{[j.id]:{order:0,menuItemFactory:Ue}}}};var ke=Object.getOwnPropertyDescriptor,De=(r,e,n,t)=>{for(var o=t>1?void 0:t?ke(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},K=(r,e)=>(n,t)=>e(n,t,r);let Z=class extends c.Disposable{constructor(r,e,n){super(),this._menuManagerService=r,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Re)}_initMenu(){this._menuManagerService.mergeMenu(Oe)}_initComponent(){[[ne,we],[f.THREAD_COMMENT_PANEL,ye],["CommentIcon",ie]].forEach(([r,e])=>{this.disposeWithMe(this._componentManager.register(r,e))})}};Z=De([K(0,u.IMenuManagerService),K(1,c.Inject(u.ComponentManager)),K(2,u.IShortcutService)],Z);var $e=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,je=(r,e,n)=>e in r?$e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Ae=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ne(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},Y=(r,e)=>(n,t)=>e(n,t,r),se=(r,e,n)=>je(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(e=X,n,t,o){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=o;const{menu:i,...s}=c.merge({},X,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ue,s)}onStarting(){[[Z],[B],[L],[W],[F],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[j].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(Z)}onReady(){this._injector.get(B)}onRendered(){this._injector.get(L),this._injector.get(W),this._injector.get(F)}};se(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",J);se(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Ae([c.DependentOn(f.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),Y(1,c.Inject(c.Injector)),Y(2,c.Inject(c.ICommandService)),Y(3,c.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>f.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>w.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>w.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>w.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>w.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>w.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=J;exports.ShowAddSheetCommentModalOperation=j;
|
|
1
|
+
"use strict";var ae=Object.defineProperty;var me=(r,e,n)=>e in r?ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var k=(r,e,n)=>me(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),f=require("@univerjs/thread-comment-ui"),P=require("@univerjs/sheets-ui"),u=require("@univerjs/ui"),V=require("rxjs"),ee=require("@univerjs/engine-render"),N=require("@univerjs/engine-formula"),w=require("@univerjs/thread-comment"),R=require("react"),te=require("react/jsx-runtime"),ne="univer.sheet.thread-comment-modal",J="SHEET_THREAD_COMMENT";var he=Object.getOwnPropertyDescriptor,de=(r,e,n,t)=>{for(var o=t>1?void 0:t?he(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},G=(r,e)=>(n,t)=>e(n,t,r);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,t,o){super();k(this,"_lastPopup",null);k(this,"_activePopup");k(this,"_activePopup$",new V.BehaviorSubject(null));k(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(n,t){var l;const{row:o,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((l=this.activePopup)==null?void 0:l.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._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:a},{componentKey:ne,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new c.DisposableCollection;h.add(m),h.add({dispose:()=>{t==null||t()}}),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))}};exports.SheetsThreadCommentPopupService=de([G(0,c.Inject(P.SheetCanvasPopManagerService)),G(1,u.IZenZoneService),G(2,c.Inject(P.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const j={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var _;const e=r.get(C.SheetsSelectionsService),n=r.get(c.IUniverInstanceService),t=r.get(exports.SheetsThreadCommentPopupService),o=r.get(f.ThreadCommentPanelService),i=(_=e.getCurrentLastSelection())==null?void 0:_.primary,s=r.get($.SheetsThreadCommentModel);if(!i)return!1;const a=C.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:h,unitId:l,subUnitId:d}=a,S={workbook:m,worksheet:h,unitId:l,subUnitId:d,row:i.startRow,col:i.startColumn};t.showPopup(S);const v=s.getByLocation(l,d,i.startRow,i.startColumn);return v&&o.setActiveComment({unitId:l,subUnitId:d,commentId:v,trigger:"context-menu"}),!0}},ue="sheets-thread-comment.config",X={};var le=Object.getOwnPropertyDescriptor,pe=(r,e,n,t)=>{for(var o=t>1?void 0:t?le(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},x=(r,e)=>(n,t)=>e(n,t,r);let B=class extends c.Disposable{constructor(r,e,n,t){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=e,this._univerInstanceService=n,this._renderManagerService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(r,e,n)=>{const{row:t,col:o,unitId:i,subUnitId:s}=e;return this._sheetsThreadCommentModel.showCommentMarker(i,s,t,o)&&((!r||r===e.rawData)&&(r={...e.rawData}),r.markers={...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}),n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var o;const e=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),t=this._renderManagerService.getRenderById(n);(o=t==null?void 0:t.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{r()}))}};B=pe([x(0,c.Inject(C.SheetInterceptorService)),x(1,c.Inject($.SheetsThreadCommentModel)),x(2,c.IUniverInstanceService),x(3,ee.IRenderManagerService)],B);var Ce=Object.getOwnPropertyDescriptor,ve=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ce(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},z=(r,e)=>(n,t)=>e(n,t,r);const Se=(r,e,n)=>{const t=N.singleReferenceToGrid(r),o=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+o,endColumn:t.column+i,endRow:t.row+o};return N.serializeRange(s)};let L=class extends c.Disposable{constructor(e,n,t){super();k(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:J,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,o)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(o.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:l,subUnitId:d}=this._copyInfo,S={row:h.startRow,column:h.startColumn};if(!(i===l&&s===d)){const v=[];c.Range.foreach(h,(b,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(l,d,b,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{v.push(g)}):M.forEach(({children:g,...U})=>{U.parentId||v.push(U)})});const _=[],T=[],D=[],A=[],q=b=>{_.unshift({id:w.DeleteCommentMutation.id,params:{unitId:l,subUnitId:d,commentId:b.id}}),D.push({id:w.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Se(b.ref,S,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:w.AddCommentMutation.id,params:{unitId:l,subUnitId:d,comment:b,sync:!0}}),A.unshift({id:w.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return v.forEach(b=>{q(b)}),{redos:[..._,...D],undos:[...A,...T]}}}return{redos:[],undos:[]}}}))}};L=ve([z(0,c.Inject(P.ISheetClipboardService)),z(1,c.Inject($.SheetsThreadCommentModel)),z(2,w.IThreadCommentDataSourceService)],L);var _e=Object.getOwnPropertyDescriptor,ge=(r,e,n,t)=>{for(var o=t>1?void 0:t?_e(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},H=(r,e)=>(n,t)=>e(n,t,r);let W=class extends c.Disposable{constructor(r,e,n,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(r=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(r&&(e&&e.temp||!e)){const{location:n}=r,{unitId:t,subUnitId:o,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(t,o,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}],t,o))return;const h=this._sheetsThreadCommentModel.getComment(t,o,a);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:o,row:i,col:s,commentId:a,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};W=ge([H(0,c.Inject(P.HoverManagerService)),H(1,c.Inject(exports.SheetsThreadCommentPopupService)),H(2,c.Inject($.SheetsThreadCommentModel)),H(3,c.Inject(C.SheetPermissionCheckController))],W);var Ie=Object.getOwnPropertyDescriptor,fe=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ie(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},E=(r,e)=>(n,t)=>e(n,t,r);let F=class extends c.Disposable{constructor(e,n,t,o,i,s,a,m,h,l){super();k(this,"_isSwitchToCommenting",!1);k(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=h,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var S,v,_;const o=(S=e[0])==null?void 0:S.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(P.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:v.skeleton;if(!s||!o)return;const a=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((_=o.rangeType)!=null?_:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(f.SetActiveCommentOperation.id);return}const h=a.actualRow,l=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,h,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(f.SetActiveCommentOperation.id);return}const d=this._sheetsThreadCommentModel.getByLocation(n,t,h,l);d&&this._commandService.executeCommand(f.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:d})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(e,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===w.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:o,subUnitId:i,commentId:s}=t;n.unitId===o&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{var n;if(e){const{unitId:t,subUnitId:o,commentId:i,trigger:s}=e,a=this._sheetsThreadCommentModel.getComment(t,o,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:o}),this._isSwitchToCommenting=!1;const d=N.singleReferenceToGrid(a.ref),{row:S,column:v}=d;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:v,endRow:S,endColumn:v}],t,o))return;const T=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-T,0),endRow:d.row+T,startColumn:Math.max(d.column-T,0),endColumn:d.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:o,row:d.row,col:d.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(e=>{var S,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:o}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,o);if(!i)return;const s=N.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const h=(S=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(t),l=(v=h==null?void 0:h.getMergedCell(a,m))!=null?v:{startColumn:m,endColumn:m,startRow:a,endRow:a},d=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);d&&(this._selectionShapeInfo={...e,shapeId:d})}))}};F=fe([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(f.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(C.SheetPermissionCheckController)),E(6,P.IMarkSelectionService),E(7,c.Inject(C.SheetsSelectionsService)),E(8,P.IEditorBridgeService),E(9,ee.IRenderManagerService)],F);function re({ref:r,...e}){const{icon:n,id:t,className:o,extend:i,...s}=e,a=`univerjs-icon univerjs-icon-${t} ${o||""}`.trim(),m=R.useRef(`_${be()}`);return oe(n,`${t}`,{defIds:n.defIds,idSuffix:m.current},{ref:r,className:a,...s},i)}function oe(r,e,n,t,o){return R.createElement(r.tag,{key:e,...Pe(r,n,o),...t},(Te(r,n).children||[]).map((i,s)=>oe(i,`${e}-${r.tag}-${s}`,n,void 0,o)))}function Pe(r,e,n){const t={...r.attrs};n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1),r.tag==="mask"&&t.id&&(t.id=t.id+e.idSuffix),Object.entries(t).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(t[i]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(([i,s])=>{typeof s=="string"&&(t[i]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),t}function Te(r,e){var t;const{defIds:n}=e;return!n||n.length===0?r:r.tag==="defs"&&((t=r.children)!=null&&t.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function be(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=R.forwardRef(function(e,n){return R.createElement(re,Object.assign({},e,{id:"comment-icon",ref:n,icon:Me}))});ie.displayName="CommentIcon";const we=()=>{const r=u.useDependency(c.IUniverInstanceService),e=u.useDependency(exports.SheetsThreadCommentPopupService),n=u.useObservable(e.activePopup$),t=u.useDependency($.SheetsThreadCommentModel);if(u.useObservable(t.commentUpdate$),!n)return null;const{row:o,col:i,unitId:s,subUnitId:a,trigger:m}=n,h=t.getByLocation(s,a,o,i),l=`${c.Tools.chatAtABC(i)}${o+1}`,d=()=>{e.hidePopup()},S=v=>{var _,T,D;return(D=(T=(_=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getSheetBySheetId(v))==null?void 0:T.getName())!=null?D:""};return te.jsx(f.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:h,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:d,getSubUnitName:S,autoFocus:m==="context-menu"})},ye=()=>{var b;const r=u.useDependency(P.IMarkSelectionService),e=u.useDependency(c.IUniverInstanceService),n=u.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),o=t.getUnitId(),i=u.useDependency(c.ICommandService),s=R.useMemo(()=>t.activeSheet$.pipe(V.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),a=u.useObservable(s,(b=t.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(null),h=u.useDependency(f.ThreadCommentPanelService),l=u.useObservable(h.activeCommentId$),d=u.useObservable(h.panelVisible$,h.panelVisible),S=R.useCallback(p=>{const M=t.getSheets(),g={};M.forEach((y,I)=>{g[y.getSheetId()]=I});const U=y=>y.map(I=>{var Q;const O=N.singleReferenceToGrid(I.ref),ce=[(Q=g[I.subUnitId])!=null?Q:0,O.row,O.column];return{...I,p:ce}}).sort((I,O)=>I.p[0]===O.p[0]?I.p[1]===O.p[1]?I.p[2]-O.p[2]:I.p[1]-O.p[1]:I.p[0]-O.p[0]);return[...U(p.filter(y=>!y.resolved)),...U(p.filter(y=>y.resolved))]},[t]),v=R.useCallback(p=>{var M;if(p.unitId===o&&p.subUnitId===a&&!p.resolved){const{row:g,column:U}=N.singleReferenceToGrid(p.ref),y=t.getSheetBySheetId(p.subUnitId),I=(M=y==null?void 0:y.getMergedCell(g,U))!=null?M:{startColumn:U,endColumn:U,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(U))return r.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[r,a,o]),_=p=>{var M,g;return(g=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?g:""},T=()=>{i.executeCommand(j.id)},D=p=>{l&&l.unitId===p.unitId&&l.subUnitId===p.subUnitId&&l.commentId===p.id||(m.current&&(r.removeShape(m.current),m.current=null),m.current=v(p))},A=()=>{m.current&&(r.removeShape(m.current),m.current=null)},q=(p,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!d&&m.current&&r.removeShape(m.current)},[r,d]),te.jsx(f.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:_,onResolve:q,sortComments:S,onItemEnter:D,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},Ue=r=>({id:j.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:u.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ee=r=>({id:f.ToggleSheetCommentPanelOperation.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:u.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET)}),Re={id:j.id,binding:u.KeyCode.M|u.MetaKeys.CTRL_COMMAND|u.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},Oe={[u.RibbonInsertGroup.MEDIA]:{[f.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:Ee}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.OTHERS]:{[j.id]:{order:0,menuItemFactory:Ue}}}};var ke=Object.getOwnPropertyDescriptor,De=(r,e,n,t)=>{for(var o=t>1?void 0:t?ke(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},K=(r,e)=>(n,t)=>e(n,t,r);let Z=class extends c.Disposable{constructor(r,e,n){super(),this._menuManagerService=r,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Re)}_initMenu(){this._menuManagerService.mergeMenu(Oe)}_initComponent(){[[ne,we],[f.THREAD_COMMENT_PANEL,ye],["CommentIcon",ie]].forEach(([r,e])=>{this.disposeWithMe(this._componentManager.register(r,e))})}};Z=De([K(0,u.IMenuManagerService),K(1,c.Inject(u.ComponentManager)),K(2,u.IShortcutService)],Z);var $e=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,je=(r,e,n)=>e in r?$e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Ae=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ne(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},Y=(r,e)=>(n,t)=>e(n,t,r),se=(r,e,n)=>je(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(e=X,n,t,o){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=o;const{menu:i,...s}=c.merge({},X,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ue,s)}onStarting(){[[Z],[B],[L],[W],[F],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[j].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(Z)}onReady(){this._injector.get(B)}onRendered(){this._injector.get(L),this._injector.get(W),this._injector.get(F)}};se(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",J);se(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Ae([c.DependentOn(f.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),Y(1,c.Inject(c.Injector)),Y(2,c.Inject(c.ICommandService)),Y(3,c.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>f.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>w.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>w.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>w.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>w.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>w.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=J;exports.ShowAddSheetCommentModalOperation=j;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={sheetThreadComment:{menu:{addComment:"コメントを追加",commentManagement:"コメント管理"}}};module.exports=e;
|