@univerjs/sheets-thread-comment 0.16.0 → 0.16.1-insiders.20260311-074e8ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +14 -18
- package/lib/es/index.js +192 -187
- package/lib/facade.js +14 -18
- package/lib/index.js +192 -187
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/LICENSE +0 -176
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var w=(i,a,e)=>a in i?T(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e;var _=(i,a,e)=>w(i,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@univerjs/core"),p=require("@univerjs/engine-formula"),C=require("@univerjs/sheets"),u=require("@univerjs/thread-comment"),y=require("rxjs");var U=Object.getOwnPropertyDescriptor,b=(i,a,e,n)=>{for(var t=n>1?void 0:n?U(a,e):a,r=i.length-1,o;r>=0;r--)(o=i[r])&&(t=o(t)||t);return t},S=(i,a)=>(e,n)=>a(e,n,i);exports.SheetsThreadCommentModel=class extends m.Disposable{constructor(e,n){super();_(this,"_matrixMap",new Map);_(this,"_locationMap",new Map);_(this,"_commentUpdate$",new y.Subject);_(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 m.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 s;const o=(s=e.getValue(n,t))!=null?s:new Set;o.add(r),e.setValue(n,t,o)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const o=e.getValue(n,t);o&&o.has(r)&&(o.delete(r),o.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:o,root:s}=t;this._addComment(r,o,s)}}_addComment(e,n,t){const r=p.singleReferenceToGrid(t.ref),o=t.parentId,{row:s,column:c}=r,d=t.id,{matrix:l,locationMap:h}=this._ensure(e,n);!o&&s>=0&&c>=0&&(this._addCommentToMatrix(l,s,c,d),h.set(d,{row:s,column:c})),o||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!o,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==m.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:o}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:s,comment:c}=e.payload;if(s){const d=p.singleReferenceToGrid(c.ref),{row:l,column:h}=d;this._deleteCommentFromMatrix(r,l,h,c.id),this._commentUpdate$.next({...e,...d})}break}case"update":{const{commentId:s}=e.payload,c=this._threadCommentModel.getComment(n,t,s);if(!c)return;const d=p.singleReferenceToGrid(c.ref);this._commentUpdate$.next({...e,...d});break}case"updateRef":{const s=p.singleReferenceToGrid(e.payload.ref),{commentId:c}=e.payload,d=o.get(c);if(!d)return;const{row:l,column:h}=d;this._deleteCommentFromMatrix(r,l,h,c),o.delete(c),s.row>=0&&s.column>=0&&(this._addCommentToMatrix(r,s.row,s.column,c),o.set(c,{row:s.row,column:s.column})),this._commentUpdate$.next({...e,...s});break}case"resolve":{const{unitId:s,subUnitId:c,payload:d}=e,{locationMap:l}=this._ensure(s,c),h=l.get(d.commentId);h&&this._commentUpdate$.next({...e,...h});break}}}))}getByLocation(e,n,t,r){var c;return(c=this.getAllByLocation(e,n,t,r).filter(d=>!d.resolved)[0])==null?void 0:c.id}getAllByLocation(e,n,t,r){const s=this._ensureCommentMatrix(e,n).getValue(t,r);return s?Array.from(s).map(c=>this.getComment(e,n,c)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const o=this.getByLocation(e,n,t,r);if(!o)return;const s=this.getComment(e,n,o);if(s)return this._threadCommentModel.getThread(e,n,s.threadId)}showCommentMarker(e,n,t,r){const o=this.getByLocation(e,n,t,r);if(!o)return!1;const s=this.getComment(e,n,o);return!!(s&&!s.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}};exports.SheetsThreadCommentModel=b([S(0,m.Inject(u.ThreadCommentModel)),S(1,m.IUniverInstanceService)],exports.SheetsThreadCommentModel);var D=Object.getOwnPropertyDescriptor,E=(i,a,e,n)=>{for(var t=n>1?void 0:n?D(a,e):a,r=i.length-1,o;r>=0;r--)(o=i[r])&&(t=o(t)||t);return t},g=(i,a)=>(e,n)=>a(e,n,i);exports.SheetsThreadCommentRefRangeController=class extends m.Disposable{constructor(e,n,t,r,o){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(e,n,t,r,o)=>{const s=t.id,c={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:u.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:p.serializeRange(r),commentId:s},silent:o}}],undos:[{id:u.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:p.serializeRange(c),commentId:s},silent:o}}]}:{redos:[{id:u.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:s}}],undos:[{id:u.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=o,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(o,s=>{const c=C.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(o,s,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===o.startColumn&&d.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,d,!1)},e,n))}_watch(e,n,t){const r=t.id,o={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,o,(s,c)=>{const{redos:d}=this._handleRangeChange(e,n,t,c,!0);m.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var o;const r=this._getIdWithUnitId(e,n,t);(o=this._watcherMap.get(r))==null||o.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var o;const r=this._getIdWithUnitId(e,n,t);(o=this._disposableMap.get(r))==null||o.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:o,root:s}=t,c=p.singleReferenceToGrid(s.ref),d={...s,...c};this._register(r,o,d),this._watch(r,o,d)}}_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 o={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,o)),this._register(e.unitId,e.subUnitId,o);break}}})),this.disposeWithMe(m.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsThreadCommentRefRangeController=E([g(0,m.Inject(C.RefRangeService)),g(1,m.Inject(exports.SheetsThreadCommentModel)),g(2,m.Inject(u.ThreadCommentModel)),g(3,m.Inject(C.SheetsSelectionsService)),g(4,m.ICommandService)],exports.SheetsThreadCommentRefRangeController);const x={};var P=Object.getOwnPropertyDescriptor,$=(i,a,e,n)=>{for(var t=n>1?void 0:n?P(a,e):a,r=i.length-1,o;r>=0;r--)(o=i[r])&&(t=o(t)||t);return t},f=(i,a)=>(e,n)=>a(e,n,i);let M=class extends m.Disposable{constructor(i,a,e,n){super(),this._univerInstanceService=i,this._sheetInterceptorService=a,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var a;if(i.id===C.RemoveSheetCommand.id){const e=i.params,n=e.unitId||this._univerInstanceService.getCurrentUnitOfType(m.UniverInstanceType.UNIVER_SHEET).getUnitId(),t=e.subUnitId||((a=this._univerInstanceService.getCurrentUnitOfType(m.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:a.getSheetId());if(!n||!t)return{redos:[],undos:[]};const r=this._threadCommentModel.ensureMap(n,t),o=Array.from(r.values()).filter(l=>!l.parentId),s=this._threadCommentDataSourceService.syncUpdateMutationToColla,c=[],d=[];return o.forEach(({children:l,...h})=>{c.push({id:u.DeleteCommentMutation.id,params:{unitId:n,subUnitId:t,commentId:h.id}}),d.push({id:u.AddCommentMutation.id,params:{unitId:n,subUnitId:t,comment:{...h,children:s?l:void 0},sync:!s}})}),{redos:c,undos:d}}else if(i.id===C.CopySheetCommand.id){const e=i.params,{unitId:n,subUnitId:t,targetSubUnitId:r}=e;if(!n||!t||!r)return{redos:[],undos:[]};const o=this._threadCommentModel.ensureMap(n,t),s=Array.from(o.values()).map(h=>({...h,subUnitId:r,id:m.generateRandomId(),threadId:m.generateRandomId()})).filter(h=>!h.parentId),c=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=[],l=[];return s.forEach(({children:h,...v})=>{d.push({id:u.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:{...v,children:c?h:void 0},sync:!c}}),l.push({id:u.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:v.id}})}),{redos:d,undos:l}}return{redos:[],undos:[]}}}))}};M=$([f(0,m.IUniverInstanceService),f(1,m.Inject(C.SheetInterceptorService)),f(2,m.Inject(u.ThreadCommentModel)),f(3,u.IThreadCommentDataSourceService)],M);const O="SHEET_THREAD_COMMENT_BASE_PLUGIN";var j=Object.defineProperty,A=Object.getOwnPropertyDescriptor,W=(i,a,e)=>a in i?j(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e,L=(i,a,e,n)=>{for(var t=n>1?void 0:n?A(a,e):a,r=i.length-1,o;r>=0;r--)(o=i[r])&&(t=o(t)||t);return t},I=(i,a)=>(e,n)=>a(e,n,i),R=(i,a,e)=>W(i,typeof a!="symbol"?a+"":a,e);exports.UniverSheetsThreadCommentPlugin=class extends m.Plugin{constructor(a=x,e,n){super(),this._config=a,this._injector=e,this._commandService=n}onStarting(){[[exports.SheetsThreadCommentModel],[exports.SheetsThreadCommentRefRangeController],[M]].forEach(a=>{this._injector.add(a)}),m.touchDependencies(this._injector,[[exports.SheetsThreadCommentRefRangeController],[M]])}};R(exports.UniverSheetsThreadCommentPlugin,"pluginName",O);R(exports.UniverSheetsThreadCommentPlugin,"type",m.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=L([m.DependentOn(u.UniverThreadCommentPlugin),I(1,m.Inject(m.Injector)),I(2,m.Inject(m.ICommandService))],exports.UniverSheetsThreadCommentPlugin);
|
|
1
|
+
"use strict";var w=Object.defineProperty;var y=(i,a,e)=>a in i?w(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e;var _=(i,a,e)=>y(i,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@univerjs/core"),p=require("@univerjs/engine-formula"),C=require("@univerjs/sheets"),u=require("@univerjs/thread-comment"),U=require("rxjs");var b=Object.getOwnPropertyDescriptor,D=(i,a,e,n)=>{for(var t=n>1?void 0:n?b(a,e):a,r=i.length-1,s;r>=0;r--)(s=i[r])&&(t=s(t)||t);return t},I=(i,a)=>(e,n)=>a(e,n,i);exports.SheetsThreadCommentModel=class extends m.Disposable{constructor(e,n){super();_(this,"_matrixMap",new Map);_(this,"_locationMap",new Map);_(this,"_commentUpdate$",new U.Subject);_(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 m.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 o;const s=(o=e.getValue(n,t))!=null?o: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:o}=t;this._addComment(r,s,o)}}_addComment(e,n,t){const r=p.singleReferenceToGrid(t.ref),s=t.parentId,{row:o,column:c}=r,d=t.id,{matrix:l,locationMap:h}=this._ensure(e,n);!s&&o>=0&&c>=0&&(this._addCommentToMatrix(l,o,c,d),h.set(d,{row:o,column:c})),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)!==m.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:o,comment:c}=e.payload;if(o){const d=p.singleReferenceToGrid(c.ref),{row:l,column:h}=d;this._deleteCommentFromMatrix(r,l,h,c.id),this._commentUpdate$.next({...e,...d})}break}case"update":{const{commentId:o}=e.payload,c=this._threadCommentModel.getComment(n,t,o);if(!c)return;const d=p.singleReferenceToGrid(c.ref);this._commentUpdate$.next({...e,...d});break}case"updateRef":{const o=p.singleReferenceToGrid(e.payload.ref),{commentId:c}=e.payload,d=s.get(c);if(!d)return;const{row:l,column:h}=d;this._deleteCommentFromMatrix(r,l,h,c),s.delete(c),o.row>=0&&o.column>=0&&(this._addCommentToMatrix(r,o.row,o.column,c),s.set(c,{row:o.row,column:o.column})),this._commentUpdate$.next({...e,...o});break}case"resolve":{const{unitId:o,subUnitId:c,payload:d}=e,{locationMap:l}=this._ensure(o,c),h=l.get(d.commentId);h&&this._commentUpdate$.next({...e,...h});break}}}))}getByLocation(e,n,t,r){var c;return(c=this.getAllByLocation(e,n,t,r).filter(d=>!d.resolved)[0])==null?void 0:c.id}getAllByLocation(e,n,t,r){const o=this._ensureCommentMatrix(e,n).getValue(t,r);return o?Array.from(o).map(c=>this.getComment(e,n,c)).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 o=this.getComment(e,n,s);if(o)return this._threadCommentModel.getThread(e,n,o.threadId)}showCommentMarker(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return!1;const o=this.getComment(e,n,s);return!!(o&&!o.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}};exports.SheetsThreadCommentModel=D([I(0,m.Inject(u.ThreadCommentModel)),I(1,m.IUniverInstanceService)],exports.SheetsThreadCommentModel);var E=Object.getOwnPropertyDescriptor,P=(i,a,e,n)=>{for(var t=n>1?void 0:n?E(a,e):a,r=i.length-1,s;r>=0;r--)(s=i[r])&&(t=s(t)||t);return t},g=(i,a)=>(e,n)=>a(e,n,i);exports.SheetsThreadCommentRefRangeController=class extends m.Disposable{constructor(e,n,t,r,s){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(e,n,t,r,s)=>{const o=t.id,c={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:u.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:p.serializeRange(r),commentId:o},silent:s}}],undos:[{id:u.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:p.serializeRange(c),commentId:o},silent:s}}]}:{redos:[{id:u.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:o}}],undos:[{id:u.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,o=>{const c=C.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,o,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===s.startColumn&&d.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,d,!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,(o,c)=>{const{redos:d}=this._handleRangeChange(e,n,t,c,!0);m.sequenceExecuteAsync(d,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:o}=t,c=p.singleReferenceToGrid(o.ref),d={...o,...c};this._register(r,s,d),this._watch(r,s,d)}}_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(m.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsThreadCommentRefRangeController=P([g(0,m.Inject(C.RefRangeService)),g(1,m.Inject(exports.SheetsThreadCommentModel)),g(2,m.Inject(u.ThreadCommentModel)),g(3,m.Inject(C.SheetsSelectionsService)),g(4,m.ICommandService)],exports.SheetsThreadCommentRefRangeController);const x="@univerjs/sheets-thread-comment",$="0.16.1-insiders.20260311-074e8ca",T={name:x,version:$},j={};var O=Object.getOwnPropertyDescriptor,A=(i,a,e,n)=>{for(var t=n>1?void 0:n?O(a,e):a,r=i.length-1,s;r>=0;r--)(s=i[r])&&(t=s(t)||t);return t},f=(i,a)=>(e,n)=>a(e,n,i);let M=class extends m.Disposable{constructor(i,a,e,n){super(),this._univerInstanceService=i,this._sheetInterceptorService=a,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var a;if(i.id===C.RemoveSheetCommand.id){const e=i.params,n=e.unitId||this._univerInstanceService.getCurrentUnitOfType(m.UniverInstanceType.UNIVER_SHEET).getUnitId(),t=e.subUnitId||((a=this._univerInstanceService.getCurrentUnitOfType(m.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:a.getSheetId());if(!n||!t)return{redos:[],undos:[]};const r=this._threadCommentModel.ensureMap(n,t),s=Array.from(r.values()).filter(l=>!l.parentId),o=this._threadCommentDataSourceService.syncUpdateMutationToColla,c=[],d=[];return s.forEach(({children:l,...h})=>{c.push({id:u.DeleteCommentMutation.id,params:{unitId:n,subUnitId:t,commentId:h.id}}),d.push({id:u.AddCommentMutation.id,params:{unitId:n,subUnitId:t,comment:{...h,children:o?l:void 0},sync:!o}})}),{redos:c,undos:d}}else if(i.id===C.CopySheetCommand.id){const e=i.params,{unitId:n,subUnitId:t,targetSubUnitId:r}=e;if(!n||!t||!r)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(n,t),o=Array.from(s.values()).map(h=>({...h,subUnitId:r,id:m.generateRandomId(),threadId:m.generateRandomId()})).filter(h=>!h.parentId),c=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=[],l=[];return o.forEach(({children:h,...S})=>{d.push({id:u.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:{...S,children:c?h:void 0},sync:!c}}),l.push({id:u.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:S.id}})}),{redos:d,undos:l}}return{redos:[],undos:[]}}}))}};M=A([f(0,m.IUniverInstanceService),f(1,m.Inject(C.SheetInterceptorService)),f(2,m.Inject(u.ThreadCommentModel)),f(3,u.IThreadCommentDataSourceService)],M);const W="SHEET_THREAD_COMMENT_BASE_PLUGIN";var N=Object.defineProperty,L=Object.getOwnPropertyDescriptor,V=(i,a,e)=>a in i?N(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e,B=(i,a,e,n)=>{for(var t=n>1?void 0:n?L(a,e):a,r=i.length-1,s;r>=0;r--)(s=i[r])&&(t=s(t)||t);return t},R=(i,a)=>(e,n)=>a(e,n,i),v=(i,a,e)=>V(i,typeof a!="symbol"?a+"":a,e);exports.UniverSheetsThreadCommentPlugin=class extends m.Plugin{constructor(a=j,e,n){super(),this._config=a,this._injector=e,this._commandService=n}onStarting(){[[exports.SheetsThreadCommentModel],[exports.SheetsThreadCommentRefRangeController],[M]].forEach(a=>{this._injector.add(a)}),m.touchDependencies(this._injector,[[exports.SheetsThreadCommentRefRangeController],[M]])}};v(exports.UniverSheetsThreadCommentPlugin,"pluginName",W);v(exports.UniverSheetsThreadCommentPlugin,"packageName",T.name);v(exports.UniverSheetsThreadCommentPlugin,"version",T.version);v(exports.UniverSheetsThreadCommentPlugin,"type",m.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=B([m.DependentOn(u.UniverThreadCommentPlugin),R(1,m.Inject(m.Injector)),R(2,m.Inject(m.ICommandService))],exports.UniverSheetsThreadCommentPlugin);
|
package/lib/es/facade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var z = Object.defineProperty;
|
|
2
2
|
var $ = (o, e, n) => e in o ? z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
|
|
3
3
|
var D = (o, e, n) => $(o, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { Inject as B, Injector as L,
|
|
4
|
+
import { Inject as B, Injector as L, UserManagerService as M, UniverInstanceType as N, RichTextValue as p, generateRandomId as E, RichTextBuilder as V, Tools as j, ICommandService as f, IUniverInstanceService as q, Range as G, toDisposable as b, CanceledError as U } from "@univerjs/core";
|
|
5
5
|
import { SheetsThreadCommentModel as v } from "@univerjs/sheets-thread-comment";
|
|
6
6
|
import { FRange as A, FWorkbook as W, FWorksheet as P } from "@univerjs/sheets/facade";
|
|
7
7
|
import { DeleteCommentTreeCommand as w, DeleteCommentCommand as R, getDT as x, UpdateCommentCommand as y, ResolveCommentCommand as T, AddCommentCommand as _, ThreadCommentModel as J } from "@univerjs/thread-comment";
|
|
@@ -21,7 +21,7 @@ class S {
|
|
|
21
21
|
threadId: "",
|
|
22
22
|
dT: "",
|
|
23
23
|
personId: "",
|
|
24
|
-
text:
|
|
24
|
+
text: V.newEmptyData().body,
|
|
25
25
|
attachments: [],
|
|
26
26
|
unitId: "",
|
|
27
27
|
subUnitId: ""
|
|
@@ -75,7 +75,7 @@ class S {
|
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
77
|
get content() {
|
|
78
|
-
return
|
|
78
|
+
return p.createByBody(this._comment.text);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Get the id of the comment
|
|
@@ -140,7 +140,7 @@ class k extends S {
|
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
142
|
setContent(e) {
|
|
143
|
-
return e instanceof
|
|
143
|
+
return e instanceof p ? this._comment.text = e.getData().body : this._comment.text = e, this;
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Set the person id of the comment
|
|
@@ -340,7 +340,7 @@ let l = class {
|
|
|
340
340
|
* ```
|
|
341
341
|
*/
|
|
342
342
|
getRange() {
|
|
343
|
-
const o = this._univerInstanceService.getUnit(this._thread.unitId,
|
|
343
|
+
const o = this._univerInstanceService.getUnit(this._thread.unitId, N.UNIVER_SHEET);
|
|
344
344
|
if (!o)
|
|
345
345
|
return null;
|
|
346
346
|
const e = o.getSheetBySheetId(this._thread.subUnitId);
|
|
@@ -349,7 +349,6 @@ let l = class {
|
|
|
349
349
|
const n = this._getRef();
|
|
350
350
|
return this._injector.createInstance(A, o, e, n);
|
|
351
351
|
}
|
|
352
|
-
// eslint-disable-next-line
|
|
353
352
|
/**
|
|
354
353
|
* @deprecated use `getRichText` as instead
|
|
355
354
|
*/
|
|
@@ -371,7 +370,7 @@ let l = class {
|
|
|
371
370
|
*/
|
|
372
371
|
getRichText() {
|
|
373
372
|
const o = this._thread.text;
|
|
374
|
-
return
|
|
373
|
+
return p.create({ body: o, documentStyle: {}, id: "d" });
|
|
375
374
|
}
|
|
376
375
|
/**
|
|
377
376
|
* Delete the comment and it's replies
|
|
@@ -397,14 +396,12 @@ let l = class {
|
|
|
397
396
|
}
|
|
398
397
|
);
|
|
399
398
|
}
|
|
400
|
-
// eslint-disable-next-line
|
|
401
399
|
/**
|
|
402
400
|
* @deprecated use `deleteAsync` as instead.
|
|
403
401
|
*/
|
|
404
402
|
delete() {
|
|
405
403
|
return this.deleteAsync();
|
|
406
404
|
}
|
|
407
|
-
// eslint-disable-next-line
|
|
408
405
|
/**
|
|
409
406
|
* @deprecated use `updateAsync` as instead
|
|
410
407
|
*/
|
|
@@ -438,7 +435,7 @@ let l = class {
|
|
|
438
435
|
* ```
|
|
439
436
|
*/
|
|
440
437
|
async updateAsync(o) {
|
|
441
|
-
const e = o instanceof
|
|
438
|
+
const e = o instanceof p ? o.getData().body : o, n = x();
|
|
442
439
|
return await this._commandService.executeCommand(
|
|
443
440
|
y.id,
|
|
444
441
|
{
|
|
@@ -453,7 +450,6 @@ let l = class {
|
|
|
453
450
|
}
|
|
454
451
|
);
|
|
455
452
|
}
|
|
456
|
-
// eslint-disable-next-line
|
|
457
453
|
/**
|
|
458
454
|
* @deprecated use `resolveAsync` as instead
|
|
459
455
|
*/
|
|
@@ -547,8 +543,8 @@ let l = class {
|
|
|
547
543
|
};
|
|
548
544
|
l = X([
|
|
549
545
|
I(2, B(L)),
|
|
550
|
-
I(3,
|
|
551
|
-
I(4,
|
|
546
|
+
I(3, f),
|
|
547
|
+
I(4, q),
|
|
552
548
|
I(5, B(v)),
|
|
553
549
|
I(6, B(M))
|
|
554
550
|
], l);
|
|
@@ -572,7 +568,7 @@ class Y extends A {
|
|
|
572
568
|
}
|
|
573
569
|
addComment(e) {
|
|
574
570
|
var c;
|
|
575
|
-
const n = this._injector, t = (c = this.getComment()) == null ? void 0 : c.getCommentData(), r = n.get(
|
|
571
|
+
const n = this._injector, t = (c = this.getComment()) == null ? void 0 : c.getCommentData(), r = n.get(f), i = n.get(M), s = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), m = `${j.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, d = i.getCurrentUser(), h = e instanceof k ? e.build() : { text: e };
|
|
576
572
|
return r.executeCommand(_.id, {
|
|
577
573
|
unitId: s,
|
|
578
574
|
subUnitId: a,
|
|
@@ -592,7 +588,7 @@ class Y extends A {
|
|
|
592
588
|
}
|
|
593
589
|
clearComment() {
|
|
594
590
|
var s;
|
|
595
|
-
const e = this._injector, n = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(
|
|
591
|
+
const e = this._injector, n = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(f), r = this._workbook.getUnitId(), i = this._worksheet.getSheetId();
|
|
596
592
|
return n ? t.executeCommand(w.id, {
|
|
597
593
|
unitId: r,
|
|
598
594
|
subUnitId: i,
|
|
@@ -700,7 +696,7 @@ class ee extends P {
|
|
|
700
696
|
* @param callback Callback function, param contains comment info and target cell.
|
|
701
697
|
*/
|
|
702
698
|
onCommented(e) {
|
|
703
|
-
return this._injector.get(
|
|
699
|
+
return this._injector.get(f).onCommandExecuted((t) => {
|
|
704
700
|
if (t.id === _.id) {
|
|
705
701
|
const r = t.params;
|
|
706
702
|
e(r);
|
|
@@ -764,7 +760,7 @@ class ne extends O {
|
|
|
764
760
|
}
|
|
765
761
|
// eslint-disable-next-line max-lines-per-function
|
|
766
762
|
_initialize(e) {
|
|
767
|
-
const n = e.get(
|
|
763
|
+
const n = e.get(f);
|
|
768
764
|
this.disposeWithMe(
|
|
769
765
|
this.registerEventHandler(
|
|
770
766
|
this.Event.CommentAdded,
|
|
@@ -869,7 +865,7 @@ class ne extends O {
|
|
|
869
865
|
row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
|
|
870
866
|
col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
|
|
871
867
|
comment: m,
|
|
872
|
-
newContent:
|
|
868
|
+
newContent: p.createByBody(a.text)
|
|
873
869
|
};
|
|
874
870
|
if (this.fireEvent(this.Event.BeforeCommentUpdate, g), g.cancel)
|
|
875
871
|
throw new U();
|