@univerjs/preset-sheets-thread-comment 0.11.0 → 0.12.1

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.
@@ -0,0 +1 @@
1
+ "use strict";const e=require("@univerjs/core"),r=require("@univerjs/sheets-thread-comment-ui/locale/ja-JP"),s=require("@univerjs/thread-comment-ui/locale/ja-JP"),t=e.mergeLocales(r,s);module.exports=t;
@@ -0,0 +1,10 @@
1
+ import { mergeLocales as e } from "@univerjs/core";
2
+ import r from "@univerjs/sheets-thread-comment-ui/locale/ja-JP";
3
+ import m from "@univerjs/thread-comment-ui/locale/ja-JP";
4
+ const s = e(
5
+ r,
6
+ m
7
+ );
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,10 @@
1
+ import { mergeLocales as e } from "@univerjs/core";
2
+ import r from "@univerjs/sheets-thread-comment-ui/locale/ja-JP";
3
+ import m from "@univerjs/thread-comment-ui/locale/ja-JP";
4
+ const s = e(
5
+ r,
6
+ m
7
+ );
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ [x: string]: any;
3
+ };
4
+ export default _default;
package/lib/umd/index.js CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
  // @univerjs/sheets-thread-comment-ui/index
21
- (function(c,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"),require("react/jsx-runtime")):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","react/jsx-runtime"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.UniverEngineFormula,c.UniverThreadComment,c.React,c.React))})(this,(function(c,a,v,D,I,g,h,V,X,N,b,O,ee){"use strict";var Ae=Object.defineProperty;var Ve=(c,a,v)=>a in c?Ae(c,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[a]=v;var k=(c,a,v)=>Ve(c,typeof a!="symbol"?a+"":a,v);const te="univer.sheet.thread-comment-modal",G="SHEET_THREAD_COMMENT";var ce=Object.getOwnPropertyDescriptor,me=(r,t,n,e)=>{for(var i=e>1?void 0:e?ce(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},z=(r,t)=>(n,e)=>t(n,e,r);c.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e,i){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=e,this._cellPopupManagerService=i,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,e){var p;const{row:i,col:o,unitId:s,subUnitId:m}=n;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&m===((p=this.activePopup)==null?void 0:p.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 d=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:s,subUnitId:m},{componentKey:te,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(d),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))}},c.SheetsThreadCommentPopupService=me([z(0,a.Inject(g.SheetCanvasPopManagerService)),z(1,h.IZenZoneService),z(2,a.Inject(g.CellPopupManagerService))],c.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var f;const t=r.get(v.SheetsSelectionsService),n=r.get(a.IUniverInstanceService),e=r.get(c.SheetsThreadCommentPopupService),i=r.get(I.ThreadCommentPanelService),o=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=r.get(D.SheetsThreadCommentModel);if(!o)return!1;const m=v.getSheetCommandTarget(n);if(!m)return!1;const{workbook:d,worksheet:u,unitId:p,subUnitId:l}=m,_={workbook:d,worksheet:u,unitId:p,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(_);const C=s.getByLocation(p,l,o.startRow,o.startColumn);return C&&i.setActiveComment({unitId:p,subUnitId:l,commentId:C,trigger:"context-menu"}),!0}},de="sheets-thread-comment.config",ne={};var ue=Object.getOwnPropertyDescriptor,he=(r,t,n,e)=>{for(var i=e>1?void 0:e?ue(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},B=(r,t)=>(n,e)=>t(n,e,r);let L=class extends a.Disposable{constructor(r,t,n,e){super(),this._sheetInterceptorService=r,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:(r,t,n)=>{const{row:e,col:i,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,i)&&((!r||r===t.rawData)&&(r={...t.rawData}),r.markers={...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}),n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{r()}))}};L=he([B(0,a.Inject(v.SheetInterceptorService)),B(1,a.Inject(D.SheetsThreadCommentModel)),B(2,a.IUniverInstanceService),B(3,X.IRenderManagerService)],L);var le=Object.getOwnPropertyDescriptor,pe=(r,t,n,e)=>{for(var i=e>1?void 0:e?le(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},K=(r,t)=>(n,e)=>t(n,e,r);const ve=(r,t,n)=>{const e=N.singleReferenceToGrid(r),i=n.row-t.row,o=n.column-t.column,s={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return N.serializeRange(s)};let W=class extends a.Disposable{constructor(t,n,e){super();k(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,i)=>{const{unitId:o,subUnitId:s,range:m}=n,d={row:m.rows[0],column:m.cols[0]};if(i.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:p,subUnitId:l}=this._copyInfo,_={row:u.startRow,column:u.startColumn};if(!(o===p&&s===l)){const C=[];a.Range.foreach(u,(y,S)=>{const w=this._sheetsThreadCommentModel.getAllByLocation(p,l,y,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?w.forEach(P=>{C.push(P)}):w.forEach(({children:P,...U})=>{U.parentId||C.push(U)})});const f=[],M=[],$=[],H=[],Q=y=>{f.unshift({id:b.DeleteCommentMutation.id,params:{unitId:p,subUnitId:l,commentId:y.id}}),$.push({id:b.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...y,ref:ve(y.ref,_,d),unitId:o,subUnitId:s},sync:!0}}),M.push({id:b.AddCommentMutation.id,params:{unitId:p,subUnitId:l,comment:y,sync:!0}}),H.unshift({id:b.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:y.id}})};return C.forEach(y=>{Q(y)}),{redos:[...f,...$],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};W=pe([K(0,a.Inject(g.ISheetClipboardService)),K(1,a.Inject(D.SheetsThreadCommentModel)),K(2,b.IThreadCommentDataSourceService)],W);var Se=Object.getOwnPropertyDescriptor,Ce=(r,t,n,e)=>{for(var i=e>1?void 0:e?Se(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},x=(r,t)=>(n,e)=>t(n,e,r);let F=class extends a.Disposable{constructor(r,t,n,e){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(r=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(r&&(t&&t.temp||!t)){const{location:n}=r,{unitId:e,subUnitId:i,row:o,col:s}=n,m=this._sheetsThreadCommentModel.getByLocation(e,i,o,s);if(m){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const u=this._sheetsThreadCommentModel.getComment(e,i,m);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:s,commentId:m,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};F=Ce([x(0,a.Inject(g.HoverManagerService)),x(1,a.Inject(c.SheetsThreadCommentPopupService)),x(2,a.Inject(D.SheetsThreadCommentModel)),x(3,a.Inject(v.SheetPermissionCheckController))],F);var _e=Object.getOwnPropertyDescriptor,fe=(r,t,n,e)=>{for(var i=e>1?void 0:e?_e(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},R=(r,t)=>(n,e)=>t(n,e,r);let Z=class extends a.Disposable{constructor(t,n,e,i,o,s,m,d,u,p){super();k(this,"_isSwitchToCommenting",!1);k(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=s,this._markSelectionService=m,this._sheetSelectionService=d,this._editorBridgeService=u,this._renderManagerService=p,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var _,C,f;const i=(_=t[0])==null?void 0:_.range,o=this._renderManagerService.getRenderById(n),s=(C=o==null?void 0:o.with(g.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:C.skeleton;if(!s||!i)return;const m=s.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((f=i.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((m.isMerged||m.isMergedMainCell)&&a.Rectangle.equals(m.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const u=m.actualRow,p=m.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,p)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,u,p);l&&this._commandService.executeCommand(I.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===b.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:s}=e;n.unitId===i&&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:i,commentId:o,trigger:s}=t,m=this._sheetsThreadCommentModel.getComment(e,i,o);if(!m||m.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=d.getActiveSheet())==null?void 0:n.getSheetId())!==i&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const l=N.singleReferenceToGrid(m.ref),{row:_,column:C}=l;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:_,startColumn:C,endRow:_,endColumn:C}]))return;const M=1;if(await this._commandService.executeCommand(g.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:i,row:l.row,col:l.column,commentId:m.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(t=>{var _,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,i);if(!o)return;const s=N.singleReferenceToGrid(o.ref),{row:m,column:d}=s;if(Number.isNaN(m)||Number.isNaN(d))return null;const u=(_=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getSheetBySheetId(e),p=(C=u==null?void 0:u.getMergedCell(m,d))!=null?C:{startColumn:d,endColumn:d,startRow:m,endRow:m},l=this._markSelectionService.addShape({range:p,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};Z=fe([R(0,a.ICommandService),R(1,a.Inject(c.SheetsThreadCommentPopupService)),R(2,a.Inject(D.SheetsThreadCommentModel)),R(3,a.Inject(I.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(v.SheetPermissionCheckController)),R(6,g.IMarkSelectionService),R(7,a.Inject(v.SheetsSelectionsService)),R(8,g.IEditorBridgeService),R(9,X.IRenderManagerService)],Z);function re({ref:r,...t}){const{icon:n,id:e,className:i,extend:o,...s}=t,m=`univerjs-icon univerjs-icon-${e} ${i||""}`.trim(),d=O.useRef(`_${Pe()}`);return ie(n,`${e}`,{defIds:n.defIds,idSuffix:d.current},{ref:r,className:m,...s},o)}function ie(r,t,n,e,i){return O.createElement(r.tag,{key:t,...Ie(r,n,i),...e},(ge(r,n).children||[]).map((o,s)=>ie(o,`${t}-${r.tag}-${s}`,n,void 0,i)))}function Ie(r,t,n){const e={...r.attrs};n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1),r.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(([o,s])=>{o==="mask"&&typeof s=="string"&&(e[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:i}=t;return!i||i.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(([o,s])=>{typeof s=="string"&&(e[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),e}function ge(r,t){var e;const{defIds:n}=t;return!n||n.length===0?r:r.tag==="defs"&&((e=r.children)!=null&&e.length)?{...r,children:r.children.map(i=>typeof i.attrs.id=="string"&&n&&n.includes(i.attrs.id)?{...i,attrs:{...i.attrs,id:i.attrs.id+t.idSuffix}}:i)}:r}function Pe(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";const Te={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"}}]},oe=O.forwardRef(function(t,n){return O.createElement(re,Object.assign({},t,{id:"comment-icon",ref:n,icon:Te}))});oe.displayName="CommentIcon";const be=()=>{const r=h.useDependency(a.IUniverInstanceService),t=h.useDependency(c.SheetsThreadCommentPopupService),n=h.useObservable(t.activePopup$),e=h.useDependency(D.SheetsThreadCommentModel);if(h.useObservable(e.commentUpdate$),!n)return null;const{row:i,col:o,unitId:s,subUnitId:m,trigger:d}=n,u=e.getByLocation(s,m,i,o),p=`${a.Tools.chatAtABC(o)}${i+1}`,l=()=>{t.hidePopup()},_=C=>{var f,M,$;return($=(M=(f=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(C))==null?void 0:M.getName())!=null?$:""};return ee.jsx(I.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:m,type:a.UniverInstanceType.UNIVER_SHEET,refStr:p,onClose:l,getSubUnitName:_,autoFocus:d==="context-menu"})},Me=()=>{var y;const r=h.useDependency(g.IMarkSelectionService),t=h.useDependency(a.IUniverInstanceService),n=h.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=h.useDependency(a.ICommandService),s=O.useMemo(()=>e.activeSheet$.pipe(V.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),m=h.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),d=O.useRef(null),u=h.useDependency(I.ThreadCommentPanelService),p=h.useObservable(u.activeCommentId$),l=h.useObservable(u.panelVisible$,u.panelVisible),_=O.useCallback(S=>{const w=e.getSheets(),P={};w.forEach((E,T)=>{P[E.getSheetId()]=T});const U=E=>E.map(T=>{var ae;const j=N.singleReferenceToGrid(T.ref),Ne=[(ae=P[T.subUnitId])!=null?ae:0,j.row,j.column];return{...T,p:Ne}}).sort((T,j)=>T.p[0]===j.p[0]?T.p[1]===j.p[1]?T.p[2]-j.p[2]:T.p[1]-j.p[1]:T.p[0]-j.p[0]);return[...U(S.filter(E=>!E.resolved)),...U(S.filter(E=>E.resolved))]},[e]),C=O.useCallback(S=>{var w;if(S.unitId===i&&S.subUnitId===m&&!S.resolved){const{row:P,column:U}=N.singleReferenceToGrid(S.ref),E=e.getSheetBySheetId(S.subUnitId),T=(w=E==null?void 0:E.getMergedCell(P,U))!=null?w:{startColumn:U,endColumn:U,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(U))return r.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[r,m,i]),f=S=>{var w,P;return(P=(w=e.getSheetBySheetId(S))==null?void 0:w.getName())!=null?P:""},M=()=>{o.executeCommand(A.id)},$=S=>{p&&p.unitId===S.unitId&&p.subUnitId===S.subUnitId&&p.commentId===S.id||(d.current&&(r.removeShape(d.current),d.current=null),d.current=C(S))},H=()=>{d.current&&(r.removeShape(d.current),d.current=null)},Q=(S,w)=>{w&&n.hidePopup()};return O.useEffect(()=>{!l&&d.current&&r.removeShape(d.current)},[r,l]),ee.jsx(I.ThreadCommentPanel,{unitId:i,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:f,onResolve:Q,sortComments:_,onItemEnter:$,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},ye=r=>({id:A.id,type:h.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:h.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),we=r=>({id:I.ToggleSheetCommentPanelOperation.id,type:h.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:h.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET)}),Ee={id:A.id,binding:h.KeyCode.M|h.MetaKeys.CTRL_COMMAND|h.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},Re={[h.RibbonInsertGroup.MEDIA]:{[I.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:we}},[h.ContextMenuPosition.MAIN_AREA]:{[h.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ye}}}};var Ue=Object.getOwnPropertyDescriptor,Oe=(r,t,n,e)=>{for(var i=e>1?void 0:e?Ue(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},Y=(r,t)=>(n,e)=>t(n,e,r);let q=class extends a.Disposable{constructor(r,t,n){super(),this._menuManagerService=r,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Ee)}_initMenu(){this._menuManagerService.mergeMenu(Re)}_initComponent(){[[te,be],[I.THREAD_COMMENT_PANEL,Me],["CommentIcon",oe]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}};q=Oe([Y(0,h.IMenuManagerService),Y(1,a.Inject(h.ComponentManager)),Y(2,h.IShortcutService)],q);var je=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,De=(r,t,n)=>t in r?je(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,$e=(r,t,n,e)=>{for(var i=e>1?void 0:e?ke(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},J=(r,t)=>(n,e)=>t(n,e,r),se=(r,t,n)=>De(r,typeof t!="symbol"?t+"":t,n);c.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=ne,n,e,i){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=i;const{menu:o,...s}=a.merge({},ne,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(de,s)}onStarting(){[[q],[L],[W],[F],[Z],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(q)}onReady(){this._injector.get(L)}onRendered(){this._injector.get(W),this._injector.get(F),this._injector.get(Z)}},se(c.UniverSheetsThreadCommentUIPlugin,"pluginName",G),se(c.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=$e([a.DependentOn(I.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentPlugin),J(1,a.Inject(a.Injector)),J(2,a.Inject(a.ICommandService)),J(3,a.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>b.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>b.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>b.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>b.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>b.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>b.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=G,c.ShowAddSheetCommentModalOperation=A,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
21
+ (function(c,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"),require("react/jsx-runtime")):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","react/jsx-runtime"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.UniverEngineFormula,c.UniverThreadComment,c.React,c.React))})(this,(function(c,a,v,D,I,g,h,V,X,N,b,O,ee){"use strict";var Ae=Object.defineProperty;var Ve=(c,a,v)=>a in c?Ae(c,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[a]=v;var k=(c,a,v)=>Ve(c,typeof a!="symbol"?a+"":a,v);const te="univer.sheet.thread-comment-modal",G="SHEET_THREAD_COMMENT";var ce=Object.getOwnPropertyDescriptor,me=(r,t,n,e)=>{for(var i=e>1?void 0:e?ce(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},z=(r,t)=>(n,e)=>t(n,e,r);c.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e,i){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=e,this._cellPopupManagerService=i,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,e){var p;const{row:i,col:o,unitId:s,subUnitId:m}=n;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&m===((p=this.activePopup)==null?void 0:p.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 d=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:s,subUnitId:m},{componentKey:te,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(d),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))}},c.SheetsThreadCommentPopupService=me([z(0,a.Inject(g.SheetCanvasPopManagerService)),z(1,h.IZenZoneService),z(2,a.Inject(g.CellPopupManagerService))],c.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var f;const t=r.get(v.SheetsSelectionsService),n=r.get(a.IUniverInstanceService),e=r.get(c.SheetsThreadCommentPopupService),i=r.get(I.ThreadCommentPanelService),o=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=r.get(D.SheetsThreadCommentModel);if(!o)return!1;const m=v.getSheetCommandTarget(n);if(!m)return!1;const{workbook:d,worksheet:u,unitId:p,subUnitId:l}=m,_={workbook:d,worksheet:u,unitId:p,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(_);const C=s.getByLocation(p,l,o.startRow,o.startColumn);return C&&i.setActiveComment({unitId:p,subUnitId:l,commentId:C,trigger:"context-menu"}),!0}},de="sheets-thread-comment.config",ne={};var ue=Object.getOwnPropertyDescriptor,he=(r,t,n,e)=>{for(var i=e>1?void 0:e?ue(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},B=(r,t)=>(n,e)=>t(n,e,r);let L=class extends a.Disposable{constructor(r,t,n,e){super(),this._sheetInterceptorService=r,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:(r,t,n)=>{const{row:e,col:i,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,i)&&((!r||r===t.rawData)&&(r={...t.rawData}),r.markers={...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}),n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{r()}))}};L=he([B(0,a.Inject(v.SheetInterceptorService)),B(1,a.Inject(D.SheetsThreadCommentModel)),B(2,a.IUniverInstanceService),B(3,X.IRenderManagerService)],L);var le=Object.getOwnPropertyDescriptor,pe=(r,t,n,e)=>{for(var i=e>1?void 0:e?le(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},K=(r,t)=>(n,e)=>t(n,e,r);const ve=(r,t,n)=>{const e=N.singleReferenceToGrid(r),i=n.row-t.row,o=n.column-t.column,s={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return N.serializeRange(s)};let W=class extends a.Disposable{constructor(t,n,e){super();k(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,i)=>{const{unitId:o,subUnitId:s,range:m}=n,d={row:m.rows[0],column:m.cols[0]};if(i.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:p,subUnitId:l}=this._copyInfo,_={row:u.startRow,column:u.startColumn};if(!(o===p&&s===l)){const C=[];a.Range.foreach(u,(y,S)=>{const w=this._sheetsThreadCommentModel.getAllByLocation(p,l,y,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?w.forEach(P=>{C.push(P)}):w.forEach(({children:P,...U})=>{U.parentId||C.push(U)})});const f=[],M=[],$=[],H=[],Q=y=>{f.unshift({id:b.DeleteCommentMutation.id,params:{unitId:p,subUnitId:l,commentId:y.id}}),$.push({id:b.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...y,ref:ve(y.ref,_,d),unitId:o,subUnitId:s},sync:!0}}),M.push({id:b.AddCommentMutation.id,params:{unitId:p,subUnitId:l,comment:y,sync:!0}}),H.unshift({id:b.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:y.id}})};return C.forEach(y=>{Q(y)}),{redos:[...f,...$],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};W=pe([K(0,a.Inject(g.ISheetClipboardService)),K(1,a.Inject(D.SheetsThreadCommentModel)),K(2,b.IThreadCommentDataSourceService)],W);var Se=Object.getOwnPropertyDescriptor,Ce=(r,t,n,e)=>{for(var i=e>1?void 0:e?Se(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},x=(r,t)=>(n,e)=>t(n,e,r);let F=class extends a.Disposable{constructor(r,t,n,e){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(r=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(r&&(t&&t.temp||!t)){const{location:n}=r,{unitId:e,subUnitId:i,row:o,col:s}=n,m=this._sheetsThreadCommentModel.getByLocation(e,i,o,s);if(m){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}],e,i))return;const u=this._sheetsThreadCommentModel.getComment(e,i,m);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:s,commentId:m,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};F=Ce([x(0,a.Inject(g.HoverManagerService)),x(1,a.Inject(c.SheetsThreadCommentPopupService)),x(2,a.Inject(D.SheetsThreadCommentModel)),x(3,a.Inject(v.SheetPermissionCheckController))],F);var _e=Object.getOwnPropertyDescriptor,fe=(r,t,n,e)=>{for(var i=e>1?void 0:e?_e(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},R=(r,t)=>(n,e)=>t(n,e,r);let Z=class extends a.Disposable{constructor(t,n,e,i,o,s,m,d,u,p){super();k(this,"_isSwitchToCommenting",!1);k(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=s,this._markSelectionService=m,this._sheetSelectionService=d,this._editorBridgeService=u,this._renderManagerService=p,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var _,C,f;const i=(_=t[0])==null?void 0:_.range,o=this._renderManagerService.getRenderById(n),s=(C=o==null?void 0:o.with(g.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:C.skeleton;if(!s||!i)return;const m=s.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((f=i.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((m.isMerged||m.isMergedMainCell)&&a.Rectangle.equals(m.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const u=m.actualRow,p=m.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,p)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,u,p);l&&this._commandService.executeCommand(I.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===b.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:s}=e;n.unitId===i&&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:i,commentId:o,trigger:s}=t,m=this._sheetsThreadCommentModel.getComment(e,i,o);if(!m||m.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=d.getActiveSheet())==null?void 0:n.getSheetId())!==i&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const l=N.singleReferenceToGrid(m.ref),{row:_,column:C}=l;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:_,startColumn:C,endRow:_,endColumn:C}],e,i))return;const M=1;if(await this._commandService.executeCommand(g.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:i,row:l.row,col:l.column,commentId:m.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(t=>{var _,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,i);if(!o)return;const s=N.singleReferenceToGrid(o.ref),{row:m,column:d}=s;if(Number.isNaN(m)||Number.isNaN(d))return null;const u=(_=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getSheetBySheetId(e),p=(C=u==null?void 0:u.getMergedCell(m,d))!=null?C:{startColumn:d,endColumn:d,startRow:m,endRow:m},l=this._markSelectionService.addShape({range:p,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};Z=fe([R(0,a.ICommandService),R(1,a.Inject(c.SheetsThreadCommentPopupService)),R(2,a.Inject(D.SheetsThreadCommentModel)),R(3,a.Inject(I.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(v.SheetPermissionCheckController)),R(6,g.IMarkSelectionService),R(7,a.Inject(v.SheetsSelectionsService)),R(8,g.IEditorBridgeService),R(9,X.IRenderManagerService)],Z);function re({ref:r,...t}){const{icon:n,id:e,className:i,extend:o,...s}=t,m=`univerjs-icon univerjs-icon-${e} ${i||""}`.trim(),d=O.useRef(`_${Pe()}`);return ie(n,`${e}`,{defIds:n.defIds,idSuffix:d.current},{ref:r,className:m,...s},o)}function ie(r,t,n,e,i){return O.createElement(r.tag,{key:t,...Ie(r,n,i),...e},(ge(r,n).children||[]).map((o,s)=>ie(o,`${t}-${r.tag}-${s}`,n,void 0,i)))}function Ie(r,t,n){const e={...r.attrs};n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1),r.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(([o,s])=>{o==="mask"&&typeof s=="string"&&(e[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:i}=t;return!i||i.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(([o,s])=>{typeof s=="string"&&(e[o]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),e}function ge(r,t){var e;const{defIds:n}=t;return!n||n.length===0?r:r.tag==="defs"&&((e=r.children)!=null&&e.length)?{...r,children:r.children.map(i=>typeof i.attrs.id=="string"&&n&&n.includes(i.attrs.id)?{...i,attrs:{...i.attrs,id:i.attrs.id+t.idSuffix}}:i)}:r}function Pe(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";const Te={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"}}]},oe=O.forwardRef(function(t,n){return O.createElement(re,Object.assign({},t,{id:"comment-icon",ref:n,icon:Te}))});oe.displayName="CommentIcon";const be=()=>{const r=h.useDependency(a.IUniverInstanceService),t=h.useDependency(c.SheetsThreadCommentPopupService),n=h.useObservable(t.activePopup$),e=h.useDependency(D.SheetsThreadCommentModel);if(h.useObservable(e.commentUpdate$),!n)return null;const{row:i,col:o,unitId:s,subUnitId:m,trigger:d}=n,u=e.getByLocation(s,m,i,o),p=`${a.Tools.chatAtABC(o)}${i+1}`,l=()=>{t.hidePopup()},_=C=>{var f,M,$;return($=(M=(f=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(C))==null?void 0:M.getName())!=null?$:""};return ee.jsx(I.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:m,type:a.UniverInstanceType.UNIVER_SHEET,refStr:p,onClose:l,getSubUnitName:_,autoFocus:d==="context-menu"})},Me=()=>{var y;const r=h.useDependency(g.IMarkSelectionService),t=h.useDependency(a.IUniverInstanceService),n=h.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=h.useDependency(a.ICommandService),s=O.useMemo(()=>e.activeSheet$.pipe(V.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),m=h.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),d=O.useRef(null),u=h.useDependency(I.ThreadCommentPanelService),p=h.useObservable(u.activeCommentId$),l=h.useObservable(u.panelVisible$,u.panelVisible),_=O.useCallback(S=>{const w=e.getSheets(),P={};w.forEach((E,T)=>{P[E.getSheetId()]=T});const U=E=>E.map(T=>{var ae;const j=N.singleReferenceToGrid(T.ref),Ne=[(ae=P[T.subUnitId])!=null?ae:0,j.row,j.column];return{...T,p:Ne}}).sort((T,j)=>T.p[0]===j.p[0]?T.p[1]===j.p[1]?T.p[2]-j.p[2]:T.p[1]-j.p[1]:T.p[0]-j.p[0]);return[...U(S.filter(E=>!E.resolved)),...U(S.filter(E=>E.resolved))]},[e]),C=O.useCallback(S=>{var w;if(S.unitId===i&&S.subUnitId===m&&!S.resolved){const{row:P,column:U}=N.singleReferenceToGrid(S.ref),E=e.getSheetBySheetId(S.subUnitId),T=(w=E==null?void 0:E.getMergedCell(P,U))!=null?w:{startColumn:U,endColumn:U,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(U))return r.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[r,m,i]),f=S=>{var w,P;return(P=(w=e.getSheetBySheetId(S))==null?void 0:w.getName())!=null?P:""},M=()=>{o.executeCommand(A.id)},$=S=>{p&&p.unitId===S.unitId&&p.subUnitId===S.subUnitId&&p.commentId===S.id||(d.current&&(r.removeShape(d.current),d.current=null),d.current=C(S))},H=()=>{d.current&&(r.removeShape(d.current),d.current=null)},Q=(S,w)=>{w&&n.hidePopup()};return O.useEffect(()=>{!l&&d.current&&r.removeShape(d.current)},[r,l]),ee.jsx(I.ThreadCommentPanel,{unitId:i,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:f,onResolve:Q,sortComments:_,onItemEnter:$,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},ye=r=>({id:A.id,type:h.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:h.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),we=r=>({id:I.ToggleSheetCommentPanelOperation.id,type:h.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:h.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET)}),Ee={id:A.id,binding:h.KeyCode.M|h.MetaKeys.CTRL_COMMAND|h.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},Re={[h.RibbonInsertGroup.MEDIA]:{[I.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:we}},[h.ContextMenuPosition.MAIN_AREA]:{[h.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ye}}}};var Ue=Object.getOwnPropertyDescriptor,Oe=(r,t,n,e)=>{for(var i=e>1?void 0:e?Ue(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},Y=(r,t)=>(n,e)=>t(n,e,r);let q=class extends a.Disposable{constructor(r,t,n){super(),this._menuManagerService=r,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Ee)}_initMenu(){this._menuManagerService.mergeMenu(Re)}_initComponent(){[[te,be],[I.THREAD_COMMENT_PANEL,Me],["CommentIcon",oe]].forEach(([r,t])=>{this.disposeWithMe(this._componentManager.register(r,t))})}};q=Oe([Y(0,h.IMenuManagerService),Y(1,a.Inject(h.ComponentManager)),Y(2,h.IShortcutService)],q);var je=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,De=(r,t,n)=>t in r?je(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,$e=(r,t,n,e)=>{for(var i=e>1?void 0:e?ke(t,n):t,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(i)||i);return i},J=(r,t)=>(n,e)=>t(n,e,r),se=(r,t,n)=>De(r,typeof t!="symbol"?t+"":t,n);c.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=ne,n,e,i){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=i;const{menu:o,...s}=a.merge({},ne,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(de,s)}onStarting(){[[q],[L],[W],[F],[Z],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(q)}onReady(){this._injector.get(L)}onRendered(){this._injector.get(W),this._injector.get(F),this._injector.get(Z)}},se(c.UniverSheetsThreadCommentUIPlugin,"pluginName",G),se(c.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=$e([a.DependentOn(I.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentPlugin),J(1,a.Inject(a.Injector)),J(2,a.Inject(a.ICommandService)),J(3,a.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>b.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>b.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>b.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>b.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>b.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>b.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=G,c.ShowAddSheetCommentModalOperation=A,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
22
22
 
23
23
 
24
24
  // index
@@ -0,0 +1,10 @@
1
+ // @univerjs/thread-comment-ui/locale/ja-JP
2
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverThreadCommentUiJaJP=t())})(this,(function(){"use strict";return{threadCommentUI:{panel:{title:"コメント管理",empty:"まだコメントはありません",filterEmpty:"一致する結果がありません",reset:"フィルタをリセット",addComment:"コメントを追加",solved:"解決済み"},editor:{placeholder:"返信または@で他のユーザーを追加",reply:"返信",cancel:"キャンセル",save:"保存"},item:{edit:"編集",delete:"コメントを削除"},filter:{sheet:{all:"すべてのシート",current:"現在のシート"},status:{all:"すべてのコメント",resolved:"解決済み",unsolved:"未解決",concernMe:"自分に関連"}}}}}));
3
+
4
+
5
+ // @univerjs/sheets-thread-comment-ui/locale/ja-JP
6
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsThreadCommentUiJaJP=n())})(this,(function(){"use strict";return{sheetThreadComment:{menu:{addComment:"コメントを追加",commentManagement:"コメント管理"}}}}));
7
+
8
+
9
+ // locale/ja-JP
10
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("@univerjs/core"),require("@univerjs/sheets-thread-comment-ui/locale/ja-JP"),require("@univerjs/thread-comment-ui/locale/ja-JP")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/sheets-thread-comment-ui/locale/ja-JP","@univerjs/thread-comment-ui/locale/ja-JP"],n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsThreadCommentJaJP=n(e.UniverCore,e.UniverSheetsThreadCommentUiJaJP,e.UniverThreadCommentUiJaJP))})(this,(function(e,n,i){"use strict";return e.mergeLocales(n,i)}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-thread-comment",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,18 +58,18 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/sheets-thread-comment": "0.11.0",
62
- "@univerjs/sheets-thread-comment-ui": "0.11.0",
63
- "@univerjs/thread-comment": "0.11.0",
64
- "@univerjs/thread-comment-ui": "0.11.0"
61
+ "@univerjs/sheets-thread-comment": "0.12.1",
62
+ "@univerjs/sheets-thread-comment-ui": "0.12.1",
63
+ "@univerjs/thread-comment": "0.12.1",
64
+ "@univerjs/thread-comment-ui": "0.12.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@univerjs/core": "0.11.0",
67
+ "@univerjs/core": "0.12.1",
68
68
  "react": "18.3.1",
69
69
  "react-dom": "18.3.1",
70
70
  "rxjs": "7.8.2",
71
71
  "typescript": "^5.9.3",
72
- "@univerjs-infra/shared": "0.11.0"
72
+ "@univerjs-infra/shared": "0.12.1"
73
73
  },
74
74
  "scripts": {
75
75
  "prebuild:preset": "tsx prepare.ts",