@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/types/plugin.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { IUniverSheetsThreadCommentConfig } from './
|
|
1
|
+
import { IUniverSheetsThreadCommentConfig } from './config/config';
|
|
2
2
|
import { ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
3
|
export declare class UniverSheetsThreadCommentPlugin extends Plugin {
|
|
4
4
|
private readonly _config;
|
|
5
5
|
protected _injector: Injector;
|
|
6
6
|
protected _commandService: ICommandService;
|
|
7
7
|
static pluginName: string;
|
|
8
|
+
static packageName: string;
|
|
9
|
+
static version: string;
|
|
8
10
|
static type: UniverInstanceType;
|
|
9
11
|
constructor(_config: Partial<IUniverSheetsThreadCommentConfig> | undefined, _injector: Injector, _commandService: ICommandService);
|
|
10
12
|
onStarting(): void;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(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"})}));
|
|
1
|
+
(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 V=(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)=>V(m,typeof i!="symbol"?i+"":i,p);var w=Object.getOwnPropertyDescriptor,b=(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},I=(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=b([I(0,i.Inject(_.ThreadCommentModel)),I(1,i.IUniverInstanceService)],m.SheetsThreadCommentModel);var j=Object.getOwnPropertyDescriptor,E=(c,o,e,n)=>{for(var t=n>1?void 0:n?j(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=E([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 R={name:"@univerjs/sheets-thread-comment",version:"0.17.0"},D={};var P=Object.getOwnPropertyDescriptor,$=(c,o,e,n)=>{for(var t=n>1?void 0:n?P(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,...U})=>{h.push({id:_.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:{...U,children:d?l:void 0},sync:!d}}),u.push({id:_.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:U.id}})}),{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};M=$([v(0,i.IUniverInstanceService),v(1,i.Inject(C.SheetInterceptorService)),v(2,i.Inject(_.ThreadCommentModel)),v(3,_.IThreadCommentDataSourceService)],M);const O="SHEET_THREAD_COMMENT_BASE_PLUGIN";var A=Object.defineProperty,x=Object.getOwnPropertyDescriptor,W=(c,o,e)=>o in c?A(c,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[o]=e,N=(c,o,e,n)=>{for(var t=n>1?void 0:n?x(o,e):o,r=c.length-1,s;r>=0;r--)(s=c[r])&&(t=s(t)||t);return t},T=(c,o)=>(e,n)=>o(e,n,c),S=(c,o,e)=>W(c,typeof o!="symbol"?o+"":o,e);m.UniverSheetsThreadCommentPlugin=class extends i.Plugin{constructor(o=D,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]])}},S(m.UniverSheetsThreadCommentPlugin,"pluginName",O),S(m.UniverSheetsThreadCommentPlugin,"packageName",R.name),S(m.UniverSheetsThreadCommentPlugin,"version",R.version),S(m.UniverSheetsThreadCommentPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),m.UniverSheetsThreadCommentPlugin=N([i.DependentOn(_.UniverThreadCommentPlugin),T(1,i.Inject(i.Injector)),T(2,i.Inject(i.ICommandService))],m.UniverSheetsThreadCommentPlugin),Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer sheets thread comment base plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -56,17 +56,17 @@
|
|
|
56
56
|
"rxjs": ">=7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@univerjs/engine-formula": "0.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
59
|
+
"@univerjs/engine-formula": "0.17.0",
|
|
60
|
+
"@univerjs/thread-comment": "0.17.0",
|
|
61
|
+
"@univerjs/sheets": "0.17.0",
|
|
62
|
+
"@univerjs/core": "0.17.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"rxjs": "^7.8.2",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"vite": "^7.3.1",
|
|
68
68
|
"vitest": "^4.0.18",
|
|
69
|
-
"@univerjs-infra/shared": "0.
|
|
69
|
+
"@univerjs-infra/shared": "0.17.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"test": "vitest run",
|
|
File without changes
|