@univerjs/sheets-thread-comment 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +0 -4
- package/lib/es/index.js +192 -187
- package/lib/facade.js +0 -4
- 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/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.17.0",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
|
@@ -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
|
*/
|
|
@@ -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
|
*/
|
|
@@ -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
|
*/
|