@univerjs/preset-sheets-thread-comment 0.10.12 → 0.10.14
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/umd/index.js +6 -6
- package/package.json +7 -7
package/lib/umd/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// @univerjs/sheets-thread-comment/index
|
|
6
|
-
(function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-formula","@univerjs/sheets","@univerjs/thread-comment","rxjs"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsThreadComment={},d.UniverCore,d.UniverEngineFormula,d.UniverSheets,d.UniverThreadComment,d.rxjs))})(this,(function(d,o,l,p,g,w){"use strict";var D=Object.defineProperty;var x=(d,o,l)=>o in d?D(d,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[o]=l;var f=(d,o,l)=>x(d,typeof o!="symbol"?o+"":o,l);var S=Object.getOwnPropertyDescriptor,T=(h,m,e,n)=>{for(var t=n>1?void 0:n?S(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},M=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentModel=class extends o.Disposable{constructor(e,n){super();f(this,"_matrixMap",new Map);f(this,"_locationMap",new Map);f(this,"_commentUpdate$",new w.Subject);f(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=e,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let t=this._matrixMap.get(e);t||(t=new Map,this._matrixMap.set(e,t));let r=t.get(n);return r||(r=new o.ObjectMatrix,t.set(n,r)),r}_ensureCommentLocationMap(e,n){let t=this._locationMap.get(e);t||(t=new Map,this._locationMap.set(e,t));let r=t.get(n);return r||(r=new Map,t.set(n,r)),r}_addCommentToMatrix(e,n,t,r){var a;const s=(a=e.getValue(n,t))!=null?a:new Set;s.add(r),e.setValue(n,t,s)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const s=e.getValue(n,t);s&&s.has(r)&&(s.delete(r),s.size===0&&e.realDeleteValue(n,t))}}_ensure(e,n){const t=this._ensureCommentMatrix(e,n),r=this._ensureCommentLocationMap(e,n);return{matrix:t,locationMap:r}}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t;this._addComment(r,s,a)}}_addComment(e,n,t){const r=l.singleReferenceToGrid(t.ref),s=t.parentId,{row:a,column:i}=r,c=t.id,{matrix:_,locationMap:u}=this._ensure(e,n);!s&&a>=0&&i>=0&&(this._addCommentToMatrix(_,a,i,c),u.set(c,{row:a,column:i})),s||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!s,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==o.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:s}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:a,comment:i}=e.payload;if(a){const c=l.singleReferenceToGrid(i.ref),{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i.id),this._commentUpdate$.next({...e,...c})}break}case"update":{const{commentId:a}=e.payload,i=this._threadCommentModel.getComment(n,t,a);if(!i)return;const c=l.singleReferenceToGrid(i.ref);this._commentUpdate$.next({...e,...c});break}case"updateRef":{const a=l.singleReferenceToGrid(e.payload.ref),{commentId:i}=e.payload,c=s.get(i);if(!c)return;const{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i),s.delete(i),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,i),s.set(i,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:i,payload:c}=e,{locationMap:_}=this._ensure(a,i),u=_.get(c.commentId);u&&this._commentUpdate$.next({...e,...u});break}}}))}getByLocation(e,n,t,r){var i;return(i=this.getAllByLocation(e,n,t,r).filter(c=>!c.resolved)[0])==null?void 0:i.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(i=>this.getComment(e,n,i)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return;const a=this.getComment(e,n,s);if(a)return this._threadCommentModel.getThread(e,n,a.threadId)}showCommentMarker(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return!1;const a=this.getComment(e,n,s);return!!(a&&!a.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}},d.SheetsThreadCommentModel=T([M(0,o.Inject(g.ThreadCommentModel)),M(1,o.IUniverInstanceService)],d.SheetsThreadCommentModel);var y=Object.getOwnPropertyDescriptor,U=(h,m,e,n)=>{for(var t=n>1?void 0:n?y(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},C=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentRefRangeController=class extends o.Disposable{constructor(e,n,t,r,s){super();f(this,"_disposableMap",new Map);f(this,"_watcherMap",new Map);f(this,"_handleRangeChange",(e,n,t,r,s)=>{const a=t.id,i={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(r),commentId:a},silent:s}}],undos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(i),commentId:a},silent:s}}]}:{redos:[{id:g.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:a}}],undos:[{id:g.AddCommentMutation.id,params:{unitId:e,subUnitId:n,comment:t,sync:!0}}]}});this._refRangeService=e,this._sheetsThreadCommentModel=n,this._threadCommentModel=t,this._selectionManagerService=r,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(s,a=>{const i=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),c=Array.isArray(i)?i[0]:i;return c&&c.startColumn===s.startColumn&&c.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,c,!1)},e,n))}_watch(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watcherMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.watchRange(e,n,s,(a,i)=>{const{redos:c}=this._handleRangeChange(e,n,t,i,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._watcherMap.get(r))==null||s.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._disposableMap.get(r))==null||s.dispose(),this._disposableMap.delete(r)}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t,i=l.singleReferenceToGrid(a.ref),c={...a,...i};this._register(r,s,c),this._watch(r,s,c)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;switch(e.type){case"add":{if(e.payload.parentId)return;const r={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,r),this._watch(e.unitId,e.subUnitId,r);break}case"delete":{this._unregister(n,t,e.payload.commentId),this._unwatch(n,t,e.payload.commentId);break}case"updateRef":{const r=this._sheetsThreadCommentModel.getComment(n,t,e.payload.commentId);if(!r)return;this._unregister(n,t,e.payload.commentId);const s={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,s)),this._register(e.unitId,e.subUnitId,s);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},d.SheetsThreadCommentRefRangeController=U([C(0,o.Inject(p.RefRangeService)),C(1,o.Inject(d.SheetsThreadCommentModel)),C(2,o.Inject(g.ThreadCommentModel)),C(3,o.Inject(p.SheetsSelectionsService)),C(4,o.ICommandService)],d.SheetsThreadCommentRefRangeController);const I={},b="SHEET_THREAD_COMMENT_BASE_PLUGIN";var j=Object.defineProperty,P=Object.getOwnPropertyDescriptor,E=(h,m,e)=>m in h?j(h,m,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[m]=e,$=(h,m,e,n)=>{for(var t=n>1?void 0:n?P(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},v=(h,m)=>(e,n)=>m(e,n,h),R=(h,m,e)=>E(h,typeof m!="symbol"?m+"":m,e);d.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(m=I,e,n){super(),this._config=m,this._injector=e,this._commandService=n}onStarting(){[[d.SheetsThreadCommentModel],[d.SheetsThreadCommentRefRangeController]].forEach(m=>{this._injector.add(m)}),this._injector.get(d.SheetsThreadCommentRefRangeController)}},R(d.UniverSheetsThreadCommentPlugin,"pluginName",b),R(d.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentPlugin=$([o.DependentOn(g.UniverThreadCommentPlugin),v(1,o.Inject(o.Injector)),v(2,o.Inject(o.ICommandService))],d.UniverSheetsThreadCommentPlugin),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
(function(m,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-formula","@univerjs/sheets","@univerjs/thread-comment","rxjs"],i):(m=typeof globalThis<"u"?globalThis:m||self,i(m.UniverSheetsThreadComment={},m.UniverCore,m.UniverEngineFormula,m.UniverSheets,m.UniverThreadComment,m.rxjs))})(this,(function(m,i,p,C,_,y){"use strict";var L=Object.defineProperty;var N=(m,i,p)=>i in m?L(m,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):m[i]=p;var f=(m,i,p)=>N(m,typeof i!="symbol"?i+"":i,p);var w=Object.getOwnPropertyDescriptor,U=(c,o,e,n)=>{for(var t=n>1?void 0:n?w(o,e):o,r=c.length-1,s;r>=0;r--)(s=c[r])&&(t=s(t)||t);return t},S=(c,o)=>(e,n)=>o(e,n,c);m.SheetsThreadCommentModel=class extends i.Disposable{constructor(e,n){super();f(this,"_matrixMap",new Map);f(this,"_locationMap",new Map);f(this,"_commentUpdate$",new y.Subject);f(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=e,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let t=this._matrixMap.get(e);t||(t=new Map,this._matrixMap.set(e,t));let r=t.get(n);return r||(r=new i.ObjectMatrix,t.set(n,r)),r}_ensureCommentLocationMap(e,n){let t=this._locationMap.get(e);t||(t=new Map,this._locationMap.set(e,t));let r=t.get(n);return r||(r=new Map,t.set(n,r)),r}_addCommentToMatrix(e,n,t,r){var a;const s=(a=e.getValue(n,t))!=null?a:new Set;s.add(r),e.setValue(n,t,s)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const s=e.getValue(n,t);s&&s.has(r)&&(s.delete(r),s.size===0&&e.realDeleteValue(n,t))}}_ensure(e,n){const t=this._ensureCommentMatrix(e,n),r=this._ensureCommentLocationMap(e,n);return{matrix:t,locationMap:r}}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t;this._addComment(r,s,a)}}_addComment(e,n,t){const r=p.singleReferenceToGrid(t.ref),s=t.parentId,{row:a,column:d}=r,h=t.id,{matrix:u,locationMap:l}=this._ensure(e,n);!s&&a>=0&&d>=0&&(this._addCommentToMatrix(u,a,d,h),l.set(h,{row:a,column:d})),s||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!s,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==i.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:s}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:a,comment:d}=e.payload;if(a){const h=p.singleReferenceToGrid(d.ref),{row:u,column:l}=h;this._deleteCommentFromMatrix(r,u,l,d.id),this._commentUpdate$.next({...e,...h})}break}case"update":{const{commentId:a}=e.payload,d=this._threadCommentModel.getComment(n,t,a);if(!d)return;const h=p.singleReferenceToGrid(d.ref);this._commentUpdate$.next({...e,...h});break}case"updateRef":{const a=p.singleReferenceToGrid(e.payload.ref),{commentId:d}=e.payload,h=s.get(d);if(!h)return;const{row:u,column:l}=h;this._deleteCommentFromMatrix(r,u,l,d),s.delete(d),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,d),s.set(d,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:d,payload:h}=e,{locationMap:u}=this._ensure(a,d),l=u.get(h.commentId);l&&this._commentUpdate$.next({...e,...l});break}}}))}getByLocation(e,n,t,r){var d;return(d=this.getAllByLocation(e,n,t,r).filter(h=>!h.resolved)[0])==null?void 0:d.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(d=>this.getComment(e,n,d)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return;const a=this.getComment(e,n,s);if(a)return this._threadCommentModel.getThread(e,n,a.threadId)}showCommentMarker(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return!1;const a=this.getComment(e,n,s);return!!(a&&!a.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}},m.SheetsThreadCommentModel=U([S(0,i.Inject(_.ThreadCommentModel)),S(1,i.IUniverInstanceService)],m.SheetsThreadCommentModel);var b=Object.getOwnPropertyDescriptor,j=(c,o,e,n)=>{for(var t=n>1?void 0:n?b(o,e):o,r=c.length-1,s;r>=0;r--)(s=c[r])&&(t=s(t)||t);return t},g=(c,o)=>(e,n)=>o(e,n,c);m.SheetsThreadCommentRefRangeController=class extends i.Disposable{constructor(e,n,t,r,s){super();f(this,"_disposableMap",new Map);f(this,"_watcherMap",new Map);f(this,"_handleRangeChange",(e,n,t,r,s)=>{const a=t.id,d={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:_.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:p.serializeRange(r),commentId:a},silent:s}}],undos:[{id:_.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:p.serializeRange(d),commentId:a},silent:s}}]}:{redos:[{id:_.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:a}}],undos:[{id:_.AddCommentMutation.id,params:{unitId:e,subUnitId:n,comment:t,sync:!0}}]}});this._refRangeService=e,this._sheetsThreadCommentModel=n,this._threadCommentModel=t,this._selectionManagerService=r,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(s,a=>{const d=C.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),h=Array.isArray(d)?d[0]:d;return h&&h.startColumn===s.startColumn&&h.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,h,!1)},e,n))}_watch(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watcherMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.watchRange(e,n,s,(a,d)=>{const{redos:h}=this._handleRangeChange(e,n,t,d,!0);i.sequenceExecuteAsync(h,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._watcherMap.get(r))==null||s.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._disposableMap.get(r))==null||s.dispose(),this._disposableMap.delete(r)}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t,d=p.singleReferenceToGrid(a.ref),h={...a,...d};this._register(r,s,h),this._watch(r,s,h)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;switch(e.type){case"add":{if(e.payload.parentId)return;const r={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,r),this._watch(e.unitId,e.subUnitId,r);break}case"delete":{this._unregister(n,t,e.payload.commentId),this._unwatch(n,t,e.payload.commentId);break}case"updateRef":{const r=this._sheetsThreadCommentModel.getComment(n,t,e.payload.commentId);if(!r)return;this._unregister(n,t,e.payload.commentId);const s={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,s)),this._register(e.unitId,e.subUnitId,s);break}}})),this.disposeWithMe(i.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},m.SheetsThreadCommentRefRangeController=j([g(0,i.Inject(C.RefRangeService)),g(1,i.Inject(m.SheetsThreadCommentModel)),g(2,i.Inject(_.ThreadCommentModel)),g(3,i.Inject(C.SheetsSelectionsService)),g(4,i.ICommandService)],m.SheetsThreadCommentRefRangeController);const E={};var D=Object.getOwnPropertyDescriptor,P=(c,o,e,n)=>{for(var t=n>1?void 0:n?D(o,e):o,r=c.length-1,s;r>=0;r--)(s=c[r])&&(t=s(t)||t);return t},v=(c,o)=>(e,n)=>o(e,n,c);let M=class extends i.Disposable{constructor(c,o,e,n){super(),this._univerInstanceService=c,this._sheetInterceptorService=o,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:c=>{var o;if(c.id===C.RemoveSheetCommand.id){const e=c.params,n=e.unitId||this._univerInstanceService.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),t=e.subUnitId||((o=this._univerInstanceService.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId());if(!n||!t)return{redos:[],undos:[]};const r=this._threadCommentModel.ensureMap(n,t),s=Array.from(r.values()).filter(u=>!u.parentId),a=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=[],h=[];return s.forEach(({children:u,...l})=>{d.push({id:_.DeleteCommentMutation.id,params:{unitId:n,subUnitId:t,commentId:l.id}}),h.push({id:_.AddCommentMutation.id,params:{unitId:n,subUnitId:t,comment:{...l,children:a?u:void 0},sync:!a}})}),{redos:d,undos:h}}else if(c.id===C.CopySheetCommand.id){const e=c.params,{unitId:n,subUnitId:t,targetSubUnitId:r}=e;if(!n||!t||!r)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(n,t),a=Array.from(s.values()).map(l=>({...l,subUnitId:r,id:i.generateRandomId(),threadId:i.generateRandomId()})).filter(l=>!l.parentId),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=[],u=[];return a.forEach(({children:l,...T})=>{h.push({id:_.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:{...T,children:d?l:void 0},sync:!d}}),u.push({id:_.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:T.id}})}),{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};M=P([v(0,i.IUniverInstanceService),v(1,i.Inject(C.SheetInterceptorService)),v(2,i.Inject(_.ThreadCommentModel)),v(3,_.IThreadCommentDataSourceService)],M);const $="SHEET_THREAD_COMMENT_BASE_PLUGIN";var O=Object.defineProperty,A=Object.getOwnPropertyDescriptor,x=(c,o,e)=>o in c?O(c,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[o]=e,W=(c,o,e,n)=>{for(var t=n>1?void 0:n?A(o,e):o,r=c.length-1,s;r>=0;r--)(s=c[r])&&(t=s(t)||t);return t},I=(c,o)=>(e,n)=>o(e,n,c),R=(c,o,e)=>x(c,typeof o!="symbol"?o+"":o,e);m.UniverSheetsThreadCommentPlugin=class extends i.Plugin{constructor(o=E,e,n){super(),this._config=o,this._injector=e,this._commandService=n}onStarting(){[[m.SheetsThreadCommentModel],[m.SheetsThreadCommentRefRangeController],[M]].forEach(o=>{this._injector.add(o)}),i.touchDependencies(this._injector,[[m.SheetsThreadCommentRefRangeController],[M]])}},R(m.UniverSheetsThreadCommentPlugin,"pluginName",$),R(m.UniverSheetsThreadCommentPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),m.UniverSheetsThreadCommentPlugin=W([i.DependentOn(_.UniverThreadCommentPlugin),I(1,i.Inject(i.Injector)),I(2,i.Inject(i.ICommandService))],m.UniverSheetsThreadCommentPlugin),Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// @univerjs/sheets-thread-comment/facade
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// @univerjs/thread-comment-ui/index
|
|
14
|
-
(function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/thread-comment"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/thread-comment","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverThreadCommentUi={},u.UniverCore,u.UniverUi,u.rxjs,u.UniverThreadComment,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,(function(u,a,m,X,B,s,U,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(u,a,m)=>a in u?Ke(u,a,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[a]=m;var Y=(u,a,m)=>Ge(u,typeof a!="symbol"?a+"":a,m);var Se=Object.getOwnPropertyDescriptor,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},oe=(n,e)=>(t,r)=>e(t,r,n);u.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();Y(this,"_panelVisible",!1);Y(this,"_panelVisible$",new X.BehaviorSubject(!1));Y(this,"_activeCommentId");Y(this,"_activeCommentId$",new X.BehaviorSubject(void 0));Y(this,"panelVisible$",this._panelVisible$.asObservable());Y(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},u.ThreadCommentPanelService=we([oe(0,a.Inject(m.ISidebarService)),oe(1,a.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",_e="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(m.ISidebarService),t=n.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},q={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",ce={};var Ne=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ce,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:o,...v}=a.merge({},ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Te,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[de,q].forEach(t=>{this._commandService.registerCommand(t)})}},ue(u.UniverThreadCommentUIPlugin,"pluginName",_e),ue(u.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([a.DependentOn(B.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],u.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},E.apply(this,arguments)},Ee=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},K=d.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,o=n.extend,v=Ee(n,["icon","id","className","extend"]),g="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:I.current},E({ref:e,className:g},v),o)});function ve(n,e,t,r,i){return d.createElement(n.tag,E(E({key:e},ke(n,t,i)),r),(Me(n,t).children||[]).map(function(o,v){return ve(o,"".concat(e,"-").concat(n.tag,"-").concat(v),t,void 0,i)}))}function ke(n,e,t){var r=E({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];v==="mask"&&typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?E(E({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"delete-icon",ref:e,icon:Pe}))});me.displayName="DeleteIcon";var $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"increase-icon",ref:e,icon:$e}))});fe.displayName="IncreaseIcon";var Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"more-horizontal-icon",ref:e,icon:Le}))});he.displayName="MoreHorizontalIcon";var He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"reply-to-comment-icon",ref:e,icon:He}))});pe.displayName="ReplyToCommentIcon";var Ve={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:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"resolved-icon",ref:e,icon:Ve}))});Ce.displayName="ResolvedIcon";var Be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},ge=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"solve-icon",ref:e,icon:Be}))});ge.displayName="SolveIcon";function Ie(n){return{id:"d",body:n,documentStyle:{}}}const be=d.forwardRef((n,e)=>{var H;const{comment:t,onSave:r,id:i,onCancel:o,autoFocus:v,unitId:g,type:I}=n,O=m.useDependency(a.ICommandService),k=m.useDependency(a.LocaleService),[Z,M]=d.useState(!1),w=m.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:g,[j,_]=d.useState(()=>{var f,C,b;return a.BuildTextUtils.transform.getPlainText((b=(C=(f=h.current)==null?void 0:f.getDocumentData().body)==null?void 0:C.dataStream)!=null?b:"")});d.useEffect(()=>{var C,b,T,x;_(a.BuildTextUtils.transform.getPlainText((T=(b=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:b.dataStream)!=null?T:""));const f=(x=h.current)==null?void 0:x.selectionChange$.subscribe(()=>{var l,N,G;_(a.BuildTextUtils.transform.getPlainText((G=(N=(l=h.current)==null?void 0:l.getDocumentData().body)==null?void 0:N.dataStream)!=null?G:""))});return()=>f==null?void 0:f.unsubscribe()},[(H=h.current)==null?void 0:H.selectionChange$]);const F=d.useMemo(()=>({keyCodes:[{keyCode:m.KeyCode.ENTER}],handler:f=>{f===m.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(f){var b,T;if(!h.current)return;w.focus((b=h.current.getEditorId())!=null?b:"");const C=Ie(f);(T=h.current)==null||T.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const y=()=>{if(h.current){const f=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...t,text:f}),h.current.replaceText(""),setTimeout(()=>{var C,b;(C=h.current)==null||C.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:f=>f.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:F,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Ie(t.text),onFocusChange:f=>f&&M(f),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{w.focus(p)},30)}}),Z?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(U.Button,{onClick:()=>{var f;o==null||o(),M(!1),(f=h.current)==null||f.replaceText("",!0),O.executeCommand(q.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(U.Button,{variant:"primary",disabled:!j,onClick:y,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
|
|
15
|
-
`)?e.length-2:e.length,
|
|
16
|
-
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},
|
|
17
|
-
\r`},personId:(
|
|
14
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/thread-comment"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/thread-comment","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.UniverThreadCommentUi={},u.UniverCore,u.UniverUi,u.rxjs,u.UniverThreadComment,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,(function(u,s,m,Q,V,i,U,d,ie){"use strict";var Fe=Object.defineProperty;var qe=(u,s,m)=>s in u?Fe(u,s,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[s]=m;var z=(u,s,m)=>qe(u,typeof s!="symbol"?s+"":s,m);var ye=Object.getOwnPropertyDescriptor,Se=(r,e,t,n)=>{for(var o=n>1?void 0:n?ye(e,t):e,l=r.length-1,v;l>=0;l--)(v=r[l])&&(o=v(o)||o);return o},oe=(r,e)=>(t,n)=>e(t,n,r);u.ThreadCommentPanelService=class extends s.Disposable{constructor(t,n){super();z(this,"_panelVisible",!1);z(this,"_panelVisible$",new Q.BehaviorSubject(!1));z(this,"_activeCommentId");z(this,"_activeCommentId$",new Q.BehaviorSubject(void 0));z(this,"panelVisible$",this._panelVisible$.asObservable());z(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).pipe(Q.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},u.ThreadCommentPanelService=Se([oe(0,s.Inject(m.ISidebarService)),oe(1,s.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",we="UNIVER_THREAD_COMMENT_UI_PLUGIN",ae={id:"thread-comment-ui.operation.toggle-panel",type:s.CommandType.OPERATION,handler(r){const e=r.get(m.ISidebarService),t=r.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:s.CommandType.OPERATION,handler(r,e){return r.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},_e="thread-comment-ui.config",de={};var Te=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ue=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,De=(r,e,t,n)=>{for(var o=n>1?void 0:n?Ne(e,t):e,l=r.length-1,v;l>=0;l--)(v=r[l])&&(o=v(o)||o);return o},se=(r,e)=>(t,n)=>e(t,n,r),ce=(r,e,t)=>Ue(r,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends s.Plugin{constructor(e=de,t,n,o){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=o;const{menu:l,...v}=s.merge({},de,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(_e,v)}onStarting(){var e;s.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ae,F].forEach(t=>{this._commandService.registerCommand(t)})}},ce(u.UniverThreadCommentUIPlugin,"pluginName",we),ce(u.UniverThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([s.DependentOn(V.UniverThreadCommentPlugin),se(1,s.Inject(s.Injector)),se(2,s.ICommandService),se(3,s.IConfigService)],u.UniverThreadCommentUIPlugin);function q({ref:r,...e}){const{icon:t,id:n,className:o,extend:l,...v}=e,S=`univerjs-icon univerjs-icon-${n} ${o||""}`.trim(),g=d.useRef(`_${ke()}`);return ue(t,`${n}`,{defIds:t.defIds,idSuffix:g.current},{ref:r,className:S,...v},l)}function ue(r,e,t,n,o){return d.createElement(r.tag,{key:e,...$e(r,t,o),...n},(Ee(r,t).children||[]).map((l,v)=>ue(l,`${e}-${r.tag}-${v}`,t,void 0,o)))}function $e(r,e,t){const n={...r.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([l,v])=>{l==="mask"&&typeof v=="string"&&(n[l]=v.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([l,v])=>{typeof v=="string"&&(n[l]=v.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function Ee(r,e){var n;const{defIds:t}=e;return!t||t.length===0?r:r.tag==="defs"&&((n=r.children)!=null&&n.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&t&&t.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function ke(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ve=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"delete-icon",ref:t,icon:Me}))});ve.displayName="DeleteIcon";const Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},me=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"increase-icon",ref:t,icon:Oe}))});me.displayName="IncreaseIcon";const je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"more-horizontal-icon",ref:t,icon:je}))});he.displayName="MoreHorizontalIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},fe=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"reply-to-comment-icon",ref:t,icon:Pe}))});fe.displayName="ReplyToCommentIcon";const Le={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:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},pe=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"resolved-icon",ref:t,icon:Le}))});pe.displayName="ResolvedIcon";const He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Ce=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"solve-icon",ref:t,icon:He}))});Ce.displayName="SolveIcon";function ge(r){return{id:"d",body:r,documentStyle:{}}}const Ie=d.forwardRef((r,e)=>{var L;const{comment:t,onSave:n,id:o,onCancel:l,autoFocus:v,unitId:S,type:g}=r,D=m.useDependency(s.ICommandService),E=m.useDependency(s.LocaleService),[W,k]=d.useState(!1),w=m.useDependency(ie.IEditorService),f=d.useRef(null),p=g===s.UniverInstanceType.UNIVER_DOC?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:S,[M,_]=d.useState(()=>{var h,C,I;return s.BuildTextUtils.transform.getPlainText((I=(C=(h=f.current)==null?void 0:h.getDocumentData().body)==null?void 0:C.dataStream)!=null?I:"")});d.useEffect(()=>{var C,I,T,b;_(s.BuildTextUtils.transform.getPlainText((T=(I=(C=f.current)==null?void 0:C.getDocumentData().body)==null?void 0:I.dataStream)!=null?T:""));const h=(b=f.current)==null?void 0:b.selectionChange$.subscribe(()=>{var a,N,K;_(s.BuildTextUtils.transform.getPlainText((K=(N=(a=f.current)==null?void 0:a.getDocumentData().body)==null?void 0:N.dataStream)!=null?K:""))});return()=>h==null?void 0:h.unsubscribe()},[(L=f.current)==null?void 0:L.selectionChange$]);const Z=d.useMemo(()=>({keyCodes:[{keyCode:m.KeyCode.ENTER}],handler:h=>{h===m.KeyCode.ENTER&&D.executeCommand(ie.BreakLineCommand.id)}}),[D]);d.useImperativeHandle(e,()=>({reply(h){var I,T;if(!f.current)return;w.focus((I=f.current.getEditorId())!=null?I:"");const C=ge(h);(T=f.current)==null||T.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const x=()=>{if(f.current){const h=s.Tools.deepClone(f.current.getDocumentData().body);k(!1),n==null||n({...t,text:h}),f.current.replaceText(""),setTimeout(()=>{var C,I;(C=f.current)==null||C.setSelectionRanges([]),(I=f.current)==null||I.blur()},10)}};return i.jsxs("div",{onClick:h=>h.preventDefault(),children:[i.jsx(ie.RichTextEditor,{className:"univer-w-full",editorRef:f,autoFocus:v,keyboardEventConfig:Z,placeholder:E.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&ge(t.text),onFocusChange:h=>h&&k(h),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{w.focus(p)},30)}}),W?i.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[i.jsx(U.Button,{onClick:()=>{var h;l==null||l(),k(!1),(h=f.current)==null||h.replaceText("",!0),D.executeCommand(F.id)},children:E.t("threadCommentUI.editor.cancel")}),i.jsx(U.Button,{variant:"primary",disabled:!M,onClick:x,children:E.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ve=r=>{const{dataStream:e,customRanges:t}=r,n=e.endsWith(`\r
|
|
15
|
+
`)?e.length-2:e.length,o=[];let l=0;return t==null||t.forEach(v=>{l<v.startIndex&&o.push({type:"text",content:e.slice(l,v.startIndex)}),o.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),l=v.endIndex+1}),o.push({type:"text",content:e.slice(l,n)}),o},Be=r=>{const{paragraphs:e=[]}=r;let t=0;return e.map(n=>{const o=s.getBodySlice(r,t,n.startIndex);return t=n.startIndex+1,Ve(o)})},Ae=r=>{let e="";const t=[];return r.forEach(n=>{switch(n.type){case"text":e+=n.content;break;case"mention":{const o=e.length;e+=n.content.label;const l=e.length-1;t.push({rangeId:n.content.id,rangeType:s.CustomRangeType.MENTION,startIndex:o,endIndex:l,properties:{},wholeEntity:!0});break}}}),e+=`\r
|
|
16
|
+
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},be="__mock__",We=r=>{const{item:e,unitId:t,subUnitId:n,editing:o,onEditingChange:l,onReply:v,resolved:S,isRoot:g,onClose:D,onDeleteComment:E,type:W}=r,k=m.useDependency(s.ICommandService),w=m.useDependency(s.LocaleService),f=m.useDependency(s.UserManagerService),p=f.getUser(e.personId),M=m.useObservable(f.currentUser$),_=(M==null?void 0:M.userID)===e.personId,Z=e.id===be,[x,L]=d.useState(!1),h=m.useConfigValue(m.UI_PLUGIN_CONFIG_KEY),C=h==null?void 0:h.avatarFallback,I=()=>{(E==null?void 0:E(e))!==!1&&(k.executeCommand(g?V.DeleteCommentTreeCommand.id:V.DeleteCommentCommand.id,{unitId:t,subUnitId:n,commentId:e.id}),g&&(D==null||D()))};return i.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>L(!1),onMouseEnter:()=>L(!0),children:[i.jsx("div",{className:"univer-absolute univer-left-0 univer-top-0 univer-h-6 univer-w-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat",style:{backgroundImage:`url(${(p==null?void 0:p.avatar)||C})`}}),p?i.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[i.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),i.jsxs("div",{children:[Z||S?null:x&&p?i.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:i.jsx(fe,{})}):null,_&&!Z&&!S?i.jsx(U.Dropdown,{overlay:i.jsx("div",{className:"univer-rounded-lg",children:i.jsxs("ul",{className:"univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",children:[i.jsx("li",{children:i.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>l==null?void 0:l(!0),children:w.t("threadCommentUI.item.edit")})}),i.jsx("li",{children:i.jsx("a",{className:"hover:univer-bg-gray-200",onClick:I,children:w.t("threadCommentUI.item.delete")})})]})}),children:i.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",children:i.jsx(he,{})})}):null]})]}):null,i.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",children:e.dT}),o?i.jsx(Ie,{type:W,id:e.id,comment:e,onCancel:()=>l==null?void 0:l(!1),autoFocus:!0,unitId:t,subUnitId:n,onSave:({text:T,attachments:b})=>{l==null||l(!1),k.executeCommand(V.UpdateCommentCommand.id,{unitId:t,subUnitId:n,payload:{commentId:e.id,text:T,attachments:b}})}}):i.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:Be(e.text).map((T,b)=>i.jsx("div",{className:"univer-break-words",children:T.map((a,N)=>{switch(a.type){case"mention":return i.jsxs("a",{className:"univer-text-primary-600",children:[a.content.label," "]},N);default:return a.content}})},b))})]})},xe=r=>{var re,J,c;const{id:e,unitId:t,subUnitId:n,refStr:o,showEdit:l=!0,onClick:v,showHighlight:S,onClose:g,getSubUnitName:D,prefix:E,autoFocus:W,onMouseEnter:k,onMouseLeave:w,onAddComment:f,onDeleteComment:p,onResolve:M,type:_,style:Z,full:x}=r,L=m.useDependency(V.ThreadCommentModel),[h,C]=d.useState(!1),[I,T]=d.useState(""),b=d.useMemo(()=>L.commentUpdate$.pipe(Q.debounceTime(16)),[L]);m.useObservable(b);const a=e?L.getCommentWithChildren(t,n,e):null,N=m.useDependency(s.ICommandService),K=m.useDependency(s.UserManagerService),O=a==null?void 0:a.root.resolved,j=m.useObservable(K.currentUser$),B=d.useRef(null),Y=[...a?[a.root]:[{id:be,text:{dataStream:`
|
|
17
|
+
\r`},personId:(re=j==null?void 0:j.userID)!=null?re:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:n,threadId:""}],...(J=a==null?void 0:a.children)!=null?J:[]],H=d.useRef(null),X=y=>{y.stopPropagation(),O?N.executeCommand(F.id,{unitId:t,subUnitId:n,commentId:e}):N.executeCommand(F.id),N.executeCommand(V.ResolveCommentCommand.id,{unitId:t,subUnitId:n,commentId:e,resolved:!O}),M==null||M(!O)},R=y=>{y.stopPropagation(),N.executeCommand(F.id),!(a!=null&&a.root&&(p==null?void 0:p(a.root))===!1)&&(N.executeCommand(V.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:n,commentId:e}),g==null||g())};d.useEffect(()=>w==null?void 0:w(),[]);const ee=D((c=a==null?void 0:a.root.subUnitId)!=null?c:n),te=l&&!I&&!O,ne=`${o||(a==null?void 0:a.root.ref)||""}${ee?" · ":""}${ee}`;return i.jsxs("div",{id:`${E}-${t}-${n}-${e}`,className:U.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",U.borderClassName,{"univer-w-[278px]":!x,"univer-w-full":x,"univer-shadow":!O&&(S||h||E==="cell")}),style:Z,onClick:v,onMouseEnter:()=>{k==null||k(),C(!0)},onMouseLeave:()=>{w==null||w(),C(!1)},children:[!O&&S&&i.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}),i.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[i.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[i.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),i.jsx(U.Tooltip,{showIfEllipsis:!0,title:ne,children:i.jsx("div",{className:"univer-flex-1 univer-truncate",children:ne})})]}),!!a&&i.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[i.jsx("div",{className:U.clsx("univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",{"univer-text-green-500":O}),onClick:X,children:O?i.jsx(pe,{}):i.jsx(Ce,{})}),(j==null?void 0:j.userID)===a.root.personId?i.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",onClick:R,children:i.jsx(ve,{})}):null]})]}),i.jsx("div",{ref:H,className:U.clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",U.scrollbarClassName),children:Y.map(y=>i.jsx(We,{unitId:t,subUnitId:n,item:y,isRoot:y.id===(a==null?void 0:a.root.id),editing:I===y.id,resolved:a==null?void 0:a.root.resolved,type:_,onClose:g,onEditingChange:P=>{T(P?y.id:"")},onReply:P=>{P&&requestAnimationFrame(()=>{var A;(A=B.current)==null||A.reply(Ae([{type:"mention",content:{id:P.userID,label:`@${P.name}`}},{type:"text",content:" "}]))})},onAddComment:f,onDeleteComment:p},y.id))}),te&&i.jsx("div",{children:i.jsx(Ie,{ref:B,type:_,unitId:t,subUnitId:n,onSave:async({text:y,attachments:P})=>{const A={text:y,attachments:P,dT:V.getDT(),id:s.generateRandomId(),ref:o,personId:j==null?void 0:j.userID,parentId:a==null?void 0:a.root.id,unitId:t,subUnitId:n,threadId:a==null?void 0:a.root.threadId};(f==null?void 0:f(A))!==!1&&(await N.executeCommand(V.AddCommentCommand.id,{unitId:t,subUnitId:n,comment:A}),H.current&&(H.current.scrollTop=H.current.scrollHeight))},autoFocus:W||!a,onCancel:()=>{a||g==null||g()}},`${W}`)})]})},Ze=r=>{const{unitId:e,subUnitId$:t,type:n,onAdd:o,getSubUnitName:l,onResolve:v,sortComments:S,onItemLeave:g,onItemEnter:D,disableAdd:E,tempComment:W,onAddComment:k,onDeleteComment:w,showComments:f}=r,[p,M]=d.useState("all"),[_,Z]=d.useState("all"),x=m.useDependency(s.LocaleService),L=m.useDependency(s.UserManagerService),h=m.useDependency(V.ThreadCommentModel),[C,I]=d.useState(()=>h.getUnit(e)),T=m.useDependency(u.ThreadCommentPanelService),b=m.useObservable(T.activeCommentId$),a=m.useObservable(h.commentUpdate$),N=m.useDependency(s.ICommandService),K=m.useObservable(t),O=d.useRef(!0),j="panel",B=m.useObservable(L.currentUser$),Y=d.useMemo(()=>{var A;const c=p==="all"?C:(A=C.filter($=>$.subUnitId===K))!=null?A:[],y=S!=null?S:($=>$),P=c.map($=>{var G;return{...$.root,children:(G=$.children)!=null?G:[],users:$.relativeUsers}});if(f){const $=new Map;return P.forEach(G=>{$.set(G.id,G)}),[...f,""].map(G=>$.get(G)).filter(Boolean)}else return y(P)},[f,p,C,S,K]),H=d.useMemo(()=>[...Y.filter(c=>!c.resolved),...Y.filter(c=>c.resolved)],[Y]),X=d.useMemo(()=>_==="resolved"?H.filter(c=>c.resolved):_==="unsolved"?H.filter(c=>!c.resolved):_==="concern_me"&&B!=null&&B.userID?H.filter(c=>c==null?void 0:c.users.has(B.userID)):H,[H,B==null?void 0:B.userID,_]),R=W?[W,...X]:X,ee=R.filter(c=>!c.resolved),te=R.filter(c=>c.resolved),ne=_!=="all"||p!=="all",re=()=>{Z("all"),M("all")};d.useEffect(()=>{e&&I(h.getUnit(e))},[e,h,a]),d.useEffect(()=>{var $;if(!b)return;if(!O.current){O.current=!0;return}const{unitId:c,subUnitId:y,commentId:P}=b,A=`${j}-${c}-${y}-${P}`;($=document.getElementById(A))==null||$.scrollIntoView({block:"center"})},[b]);const J=c=>i.jsx(xe,{full:!0,prefix:j,getSubUnitName:l,id:c.id,unitId:c.unitId,subUnitId:c.subUnitId,refStr:c.ref,type:n,showEdit:(b==null?void 0:b.commentId)===c.id,showHighlight:(b==null?void 0:b.commentId)===c.id,onClick:()=>{O.current=!1,c.resolved?N.executeCommand(F.id):N.executeCommand(F.id,{unitId:c.unitId,subUnitId:c.subUnitId,commentId:c.id,temp:!1})},onMouseEnter:()=>D==null?void 0:D(c),onMouseLeave:()=>g==null?void 0:g(c),onAddComment:k,onDeleteComment:w,onResolve:y=>v==null?void 0:v(c.id,y)},c.id);return i.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[i.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[n===s.UniverInstanceType.UNIVER_SHEET?i.jsx(U.Select,{borderless:!0,value:p,options:[{value:"current",label:x.t("threadCommentUI.filter.sheet.current")},{value:"all",label:x.t("threadCommentUI.filter.sheet.all")}],onChange:M}):null,i.jsx(U.Select,{borderless:!0,value:_,options:[{value:"all",label:x.t("threadCommentUI.filter.status.all")},{value:"resolved",label:x.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:x.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:x.t("threadCommentUI.filter.status.concernMe")}],onChange:Z})]}),R.length===0?i.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[x.t("threadCommentUI.panel.empty"),ne?i.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:i.jsx(U.Button,{onClick:re,children:x.t("threadCommentUI.panel.reset")})}):E?null:i.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:i.jsxs(U.Button,{onClick:o,children:[i.jsx(me,{className:"univer-mr-1.5"}),x.t("threadCommentUI.panel.addComment")]})})]}):i.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ee.map(J),te.length>0&&i.jsx("div",{className:"univer-text-xs",children:x.t("threadCommentUI.panel.solved")}),te.map(J)]})]})};u.SetActiveCommentOperation=F,u.THREAD_COMMENT_PANEL=le,u.ThreadCommentPanel=Ze,u.ThreadCommentTree=xe,u.ToggleSheetCommentPanelOperation=ae,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
// @univerjs/sheets-thread-comment-ui/index
|
|
21
|
-
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react/jsx-runtime","react"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React,d.React))})(this,(function(d,s,p,N,g,P,v,H,ne,A,f,re,R){"use strict";var xe=Object.defineProperty;var Fe=(d,s,p)=>s in d?xe(d,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[s]=p;var D=(d,s,p)=>Fe(d,typeof s!="symbol"?s+"":s,p);const ie="univer.sheet.thread-comment-modal",Y="SHEET_THREAD_COMMENT";var me=Object.getOwnPropertyDescriptor,he=(n,t,r,e)=>{for(var i=e>1?void 0:e?me(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},J=(n,t)=>(r,e)=>t(r,e,n);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(r,e,i){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,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(r=>{r&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(r,e){var l;const{row:i,col:o,unitId:a,subUnitId:c}=r;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:a,subUnitId:c},{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},d.SheetsThreadCommentPopupService=he([J(0,s.Inject(P.SheetCanvasPopManagerService)),J(1,v.IZenZoneService),J(2,s.Inject(P.CellPopupManagerService))],d.SheetsThreadCommentPopupService);const V={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var I;const t=n.get(p.SheetsSelectionsService),r=n.get(s.IUniverInstanceService),e=n.get(d.SheetsThreadCommentPopupService),i=n.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=n.get(N.SheetsThreadCommentModel);if(!o)return!1;const c=p.getSheetCommandTarget(r);if(!c)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=c,S={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(S);const _=a.getByLocation(l,h,o.startRow,o.startColumn);return _&&i.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},le="sheets-thread-comment.config",oe={};var pe=Object.getOwnPropertyDescriptor,ve=(n,t,r,e)=>{for(var i=e>1?void 0:e?pe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},L=(n,t)=>(r,e)=>t(r,e,n);let W=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:i,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,i)&&((!n||n===t.rawData)&&(n={...t.rawData}),n.markers={...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}),r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{n()}))}};W=ve([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject(N.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ne.IRenderManagerService)],W);var Se=Object.getOwnPropertyDescriptor,Ce=(n,t,r,e)=>{for(var i=e>1?void 0:e?Se(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Q=(n,t)=>(r,e)=>t(r,e,n);const _e=(n,t,r)=>{const e=A.singleReferenceToGrid(n),i=r.row-t.row,o=r.column-t.column,a={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return A.serializeRange(a)};let x=class extends s.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Y,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,i)=>{const{unitId:o,subUnitId:a,range:c}=r,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,S={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const _=[];s.Range.foreach(m,(w,C)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,C);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(T=>{_.push(T)}):E.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const I=[],M=[],$=[],B=[],te=w=>{I.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),$.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:_e(w.ref,S,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:f.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),B.unshift({id:f.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return _.forEach(w=>{te(w)}),{redos:[...I,...$],undos:[...B,...M]}}}return{redos:[],undos:[]}}}))}};x=Ce([Q(0,s.Inject(P.ISheetClipboardService)),Q(1,s.Inject(N.SheetsThreadCommentModel)),Q(2,f.IThreadCommentDataSourceService)],x);var fe=Object.getOwnPropertyDescriptor,Ie=(n,t,r,e)=>{for(var i=e>1?void 0:e?fe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},F=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends s.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:i,row:o,col:a}=r,c=this._sheetsThreadCommentModel.getByLocation(e,i,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const m=this._sheetsThreadCommentModel.getComment(e,i,c);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Ie([F(0,s.Inject(P.HoverManagerService)),F(1,s.Inject(d.SheetsThreadCommentPopupService)),F(2,s.Inject(N.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],Z);var ge=Object.getOwnPropertyDescriptor,Pe=(n,t,r,e)=>{for(var i=e>1?void 0:e?ge(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},O=(n,t)=>(r,e)=>t(r,e,n);let q=class extends s.Disposable{constructor(t,r,e,i,o,a,c,u,m,l){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var S,_,I;const i=(S=t[0])==null?void 0:S.range,o=this._renderManagerService.getRenderById(r),a=(_=o==null?void 0:o.with(P.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:_.skeleton;if(!a||!i)return;const c=a.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((I=i.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const m=c.actualRow,l=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:a}=e;r.unitId===i&&r.subUnitId===o&&r.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:i,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,i,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==i&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const h=A.singleReferenceToGrid(c.ref),{row:S,column:_}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:_,endRow:S,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:h.row,col:h.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var S,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,i);if(!o)return;const a=A.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const m=(S=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(c,u))!=null?_:{startColumn:u,endColumn:u,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};q=Pe([O(0,s.ICommandService),O(1,s.Inject(d.SheetsThreadCommentPopupService)),O(2,s.Inject(N.SheetsThreadCommentModel)),O(3,s.Inject(g.ThreadCommentPanelService)),O(4,s.IUniverInstanceService),O(5,s.Inject(p.SheetPermissionCheckController)),O(6,P.IMarkSelectionService),O(7,s.Inject(p.SheetsSelectionsService)),O(8,P.IEditorBridgeService),O(9,ne.IRenderManagerService)],q);var Te=Object.getOwnPropertyDescriptor,be=(n,t,r,e)=>{for(var i=e>1?void 0:e?Te(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},G=(n,t)=>(r,e)=>t(r,e,n);let z=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===p.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const i=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(i,o),c=Array.from(a.values()).filter(S=>!S.parentId),u=c.map(S=>S.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(S=>({id:f.DeleteCommentMutation.id,params:{unitId:i,subUnitId:o,commentId:S}})),h=c.map(({children:S,..._})=>({id:f.AddCommentMutation.id,params:{unitId:i,subUnitId:o,comment:{..._,children:m?S:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=be([G(0,s.Inject(p.SheetInterceptorService)),G(1,s.IUniverInstanceService),G(2,s.Inject(f.ThreadCommentModel)),G(3,f.IThreadCommentDataSourceService)],z);var y=function(){return y=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},y.apply(this,arguments)},ye=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,e=Object.getOwnPropertySymbols(n);i<e.length;i++)t.indexOf(e[i])<0&&Object.prototype.propertyIsEnumerable.call(n,e[i])&&(r[e[i]]=n[e[i]]);return r},se=R.forwardRef(function(n,t){var r=n.icon,e=n.id,i=n.className,o=n.extend,a=ye(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(i||"").trim(),u=R.useRef("_".concat(Ee()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ae(n,t,r,e,i){return R.createElement(n.tag,y(y({key:t},Me(n,r,i)),e),(we(n,r).children||[]).map(function(o,a){return ae(o,"".concat(t,"-").concat(n.tag,"-").concat(a),r,void 0,i)}))}function Me(n,t,r){var e=y({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function we(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?y(y({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&e&&e.includes(i.attrs.id)?y(y({},i),{attrs:y(y({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):n}function Ee(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Ue={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"}}]},ce=R.forwardRef(function(n,t){return R.createElement(se,Object.assign({},n,{id:"comment-icon",ref:t,icon:Ue}))});ce.displayName="CommentIcon";const Re=()=>{const n=v.useDependency(s.IUniverInstanceService),t=v.useDependency(d.SheetsThreadCommentPopupService),r=v.useObservable(t.activePopup$),e=v.useDependency(N.SheetsThreadCommentModel);if(v.useObservable(e.commentUpdate$),!r)return null;const{row:i,col:o,unitId:a,subUnitId:c,trigger:u}=r,m=e.getByLocation(a,c,i,o),l=`${s.Tools.chatAtABC(o)}${i+1}`,h=()=>{t.hidePopup()},S=_=>{var I,M,$;return($=(M=(I=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(_))==null?void 0:M.getName())!=null?$:""};return re.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:S,autoFocus:u==="context-menu"})},Oe=()=>{var w;const n=v.useDependency(P.IMarkSelectionService),t=v.useDependency(s.IUniverInstanceService),r=v.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=v.useDependency(s.ICommandService),a=R.useMemo(()=>e.activeSheet$.pipe(H.map(C=>C==null?void 0:C.getSheetId())),[e.activeSheet$]),c=v.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=R.useRef(null),m=v.useDependency(g.ThreadCommentPanelService),l=v.useObservable(m.activeCommentId$),h=v.useObservable(m.panelVisible$,m.panelVisible),S=R.useCallback(C=>{const E=e.getSheets(),T={};E.forEach((U,b)=>{T[U.getSheetId()]=b});const j=U=>U.map(b=>{var ue;const k=A.singleReferenceToGrid(b.ref),We=[(ue=T[b.subUnitId])!=null?ue:0,k.row,k.column];return{...b,p:We}}).sort((b,k)=>b.p[0]===k.p[0]?b.p[1]===k.p[1]?b.p[2]-k.p[2]:b.p[1]-k.p[1]:b.p[0]-k.p[0]);return[...j(C.filter(U=>!U.resolved)),...j(C.filter(U=>U.resolved))]},[e]),_=R.useCallback(C=>{var E;if(C.unitId===i&&C.subUnitId===c&&!C.resolved){const{row:T,column:j}=A.singleReferenceToGrid(C.ref),U=e.getSheetBySheetId(C.subUnitId),b=(E=U==null?void 0:U.getMergedCell(T,j))!=null?E:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return n.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,i]),I=C=>{var E,T;return(T=(E=e.getSheetBySheetId(C))==null?void 0:E.getName())!=null?T:""},M=()=>{o.executeCommand(V.id)},$=C=>{l&&l.unitId===C.unitId&&l.subUnitId===C.subUnitId&&l.commentId===C.id||(u.current&&(n.removeShape(u.current),u.current=null),u.current=_(C))},B=()=>{u.current&&(n.removeShape(u.current),u.current=null)},te=(C,E)=>{E&&r.hidePopup()};return R.useEffect(()=>{!h&&u.current&&n.removeShape(u.current)},[n,h]),re.jsx(g.ThreadCommentPanel,{unitId:i,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:I,onResolve:te,sortComments:S,onItemEnter:$,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},je=n=>({id:V.id,type:v.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),ke=n=>({id:g.ToggleSheetCommentPanelOperation.id,type:v.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET)}),De={id:V.id,binding:v.KeyCode.M|v.MetaKeys.CTRL_COMMAND|v.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},Ne={[v.RibbonInsertGroup.MEDIA]:{[g.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:ke}},[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{[V.id]:{order:0,menuItemFactory:je}}}};var $e=Object.getOwnPropertyDescriptor,Ae=(n,t,r,e)=>{for(var i=e>1?void 0:e?$e(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},X=(n,t)=>(r,e)=>t(r,e,n);let K=class extends s.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(De)}_initMenu(){this._menuManagerService.mergeMenu(Ne)}_initComponent(){[[ie,Re],[g.THREAD_COMMENT_PANEL,Oe],["CommentIcon",ce]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};K=Ae([X(0,v.IMenuManagerService),X(1,s.Inject(v.ComponentManager)),X(2,v.IShortcutService)],K);var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Be=(n,t,r)=>t in n?Ve(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Le=(n,t,r,e)=>{for(var i=e>1?void 0:e?He(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},ee=(n,t)=>(r,e)=>t(r,e,n),de=(n,t,r)=>Be(n,typeof t!="symbol"?t+"":t,r);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=oe,r,e,i){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=i;const{menu:o,...a}=s.merge({},oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(le,a)}onStarting(){[[K],[W],[x],[Z],[z],[q],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(K)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(x),this._injector.get(Z),this._injector.get(q)}},de(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Y),de(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=Le([s.DependentOn(g.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),ee(1,s.Inject(s.Injector)),ee(2,s.Inject(s.ICommandService)),ee(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Y,d.ShowAddSheetCommentModalOperation=V,Object.defineProperty(d,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}]))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"})}));
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
// index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-thread-comment",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.14",
|
|
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.10.
|
|
62
|
-
"@univerjs/sheets-thread-comment-ui": "0.10.
|
|
63
|
-
"@univerjs/thread-comment": "0.10.
|
|
64
|
-
"@univerjs/thread-comment-ui": "0.10.
|
|
61
|
+
"@univerjs/sheets-thread-comment": "0.10.14",
|
|
62
|
+
"@univerjs/sheets-thread-comment-ui": "0.10.14",
|
|
63
|
+
"@univerjs/thread-comment": "0.10.14",
|
|
64
|
+
"@univerjs/thread-comment-ui": "0.10.14"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@univerjs/core": "0.10.
|
|
67
|
+
"@univerjs/core": "0.10.14",
|
|
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.10.
|
|
72
|
+
"@univerjs-infra/shared": "0.10.14"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"prebuild:preset": "tsx prepare.ts",
|