@univerjs/sheets-thread-comment 0.8.2-nightly.202506261607 → 0.8.3-nightly.202506271607
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/index.js +138 -138
- package/lib/index.js +138 -138
- package/lib/types/controllers/config.schema.d.ts +2 -2
- package/lib/types/index.d.ts +2 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var w=(c,a,e)=>a in c?v(c,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[a]=e;var _=(c,a,e)=>w(c,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),u=require("@univerjs/engine-formula"),
|
|
1
|
+
"use strict";var v=Object.defineProperty;var w=(c,a,e)=>a in c?v(c,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[a]=e;var _=(c,a,e)=>w(c,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),u=require("@univerjs/engine-formula"),p=require("@univerjs/sheets"),g=require("@univerjs/thread-comment"),S=require("rxjs");var T=Object.getOwnPropertyDescriptor,y=(c,a,e,n)=>{for(var t=n>1?void 0:n?T(a,e):a,r=c.length-1,o;r>=0;r--)(o=c[r])&&(t=o(t)||t);return t},f=(c,a)=>(e,n)=>a(e,n,c);exports.SheetsThreadCommentModel=class extends d.Disposable{constructor(e,n){super();_(this,"_matrixMap",new Map);_(this,"_locationMap",new Map);_(this,"_commentUpdate$",new S.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 d.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=u.singleReferenceToGrid(t.ref),o=t.parentId,{row:s,column:i}=r,m=t.id,{matrix:h,locationMap:l}=this._ensure(e,n);!o&&s>=0&&i>=0&&(this._addCommentToMatrix(h,s,i,m),l.set(m,{row:s,column:i})),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)!==d.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:i}=e.payload;if(s){const m=u.singleReferenceToGrid(i.ref),{row:h,column:l}=m;this._deleteCommentFromMatrix(r,h,l,i.id),this._commentUpdate$.next({...e,...m})}break}case"update":{const{commentId:s}=e.payload,i=this._threadCommentModel.getComment(n,t,s);if(!i)return;const m=u.singleReferenceToGrid(i.ref);this._commentUpdate$.next({...e,...m});break}case"updateRef":{const s=u.singleReferenceToGrid(e.payload.ref),{commentId:i}=e.payload,m=o.get(i);if(!m)return;const{row:h,column:l}=m;this._deleteCommentFromMatrix(r,h,l,i),o.delete(i),s.row>=0&&s.column>=0&&(this._addCommentToMatrix(r,s.row,s.column,i),o.set(i,{row:s.row,column:s.column})),this._commentUpdate$.next({...e,...s});break}case"resolve":{const{unitId:s,subUnitId:i,payload:m}=e,{locationMap:h}=this._ensure(s,i),l=h.get(m.commentId);l&&this._commentUpdate$.next({...e,...l});break}}}))}getByLocation(e,n,t,r){var i;return(i=this.getAllByLocation(e,n,t,r).filter(m=>!m.resolved)[0])==null?void 0:i.id}getAllByLocation(e,n,t,r){const s=this._ensureCommentMatrix(e,n).getValue(t,r);return s?Array.from(s).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 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=y([f(0,d.Inject(g.ThreadCommentModel)),f(1,d.IUniverInstanceService)],exports.SheetsThreadCommentModel);var I=Object.getOwnPropertyDescriptor,b=(c,a,e,n)=>{for(var t=n>1?void 0:n?I(a,e):a,r=c.length-1,o;r>=0;r--)(o=c[r])&&(t=o(t)||t);return t},C=(c,a)=>(e,n)=>a(e,n,c);exports.SheetsThreadCommentRefRangeController=class extends d.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,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:u.serializeRange(r),commentId:s},silent:o}}],undos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:u.serializeRange(i),commentId:s},silent:o}}]}:{redos:[{id:g.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:s}}],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=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 i=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(o,s,{selectionManagerService:this._selectionManagerService}),m=Array.isArray(i)?i[0]:i;return m&&m.startColumn===o.startColumn&&m.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,m,!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,i)=>{const{redos:m}=this._handleRangeChange(e,n,t,i,!0);d.sequenceExecuteAsync(m,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,i=u.singleReferenceToGrid(s.ref),m={...s,...i};this._register(r,o,m),this._watch(r,o,m)}}_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(d.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsThreadCommentRefRangeController=b([C(0,d.Inject(p.RefRangeService)),C(1,d.Inject(exports.SheetsThreadCommentModel)),C(2,d.Inject(g.ThreadCommentModel)),C(3,d.Inject(p.SheetsSelectionsService)),C(4,d.ICommandService)],exports.SheetsThreadCommentRefRangeController);const U={},x="SHEET_THREAD_COMMENT_BASE_PLUGIN";var P=Object.defineProperty,E=Object.getOwnPropertyDescriptor,$=(c,a,e)=>a in c?P(c,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[a]=e,D=(c,a,e,n)=>{for(var t=n>1?void 0:n?E(a,e):a,r=c.length-1,o;r>=0;r--)(o=c[r])&&(t=o(t)||t);return t},M=(c,a)=>(e,n)=>a(e,n,c),R=(c,a,e)=>$(c,typeof a!="symbol"?a+"":a,e);exports.UniverSheetsThreadCommentPlugin=class extends d.Plugin{constructor(a=U,e,n){super(),this._config=a,this._injector=e,this._commandService=n}onStarting(){[[exports.SheetsThreadCommentModel],[exports.SheetsThreadCommentRefRangeController]].forEach(a=>{this._injector.add(a)}),this._injector.get(exports.SheetsThreadCommentRefRangeController)}};R(exports.UniverSheetsThreadCommentPlugin,"pluginName",x);R(exports.UniverSheetsThreadCommentPlugin,"type",d.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=D([d.DependentOn(g.UniverThreadCommentPlugin),M(1,d.Inject(d.Injector)),M(2,d.Inject(d.ICommandService))],exports.UniverSheetsThreadCommentPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
1
|
var U = Object.defineProperty;
|
|
2
|
-
var x = (
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
2
|
+
var x = (a, e, n) => e in a ? U(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3
|
+
var l = (a, e, n) => x(a, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { Inject as h, IUniverInstanceService as T, Disposable as R, ObjectMatrix as E, UniverInstanceType as y, ICommandService as b, sequenceExecuteAsync as $, toDisposable as D, DependentOn as P, Injector as O, Plugin as A } from "@univerjs/core";
|
|
5
5
|
import { singleReferenceToGrid as u, serializeRange as M } from "@univerjs/engine-formula";
|
|
6
6
|
import { RefRangeService as W, SheetsSelectionsService as L, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as j } from "@univerjs/sheets";
|
|
7
7
|
import { ThreadCommentModel as S, AddCommentMutation as B, DeleteCommentMutation as N, UpdateCommentRefMutation as C, UniverThreadCommentPlugin as V } from "@univerjs/thread-comment";
|
|
8
8
|
import { Subject as H } from "rxjs";
|
|
9
|
-
var F = Object.getOwnPropertyDescriptor, k = (
|
|
10
|
-
for (var
|
|
11
|
-
(s =
|
|
12
|
-
return
|
|
13
|
-
}, w = (
|
|
9
|
+
var F = Object.getOwnPropertyDescriptor, k = (a, e, n, t) => {
|
|
10
|
+
for (var r = t > 1 ? void 0 : t ? F(e, n) : e, o = a.length - 1, s; o >= 0; o--)
|
|
11
|
+
(s = a[o]) && (r = s(r) || r);
|
|
12
|
+
return r;
|
|
13
|
+
}, w = (a, e) => (n, t) => e(n, t, a);
|
|
14
14
|
let p = class extends R {
|
|
15
|
-
constructor(e,
|
|
15
|
+
constructor(e, n) {
|
|
16
16
|
super();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this._threadCommentModel = e, this._univerInstanceService =
|
|
17
|
+
l(this, "_matrixMap", /* @__PURE__ */ new Map());
|
|
18
|
+
l(this, "_locationMap", /* @__PURE__ */ new Map());
|
|
19
|
+
l(this, "_commentUpdate$", new H());
|
|
20
|
+
l(this, "commentUpdate$", this._commentUpdate$.asObservable());
|
|
21
|
+
this._threadCommentModel = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
|
|
22
22
|
this._commentUpdate$.complete();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
_init() {
|
|
26
26
|
this._initData(), this._initUpdateTransform();
|
|
27
27
|
}
|
|
28
|
-
_ensureCommentMatrix(e,
|
|
28
|
+
_ensureCommentMatrix(e, n) {
|
|
29
29
|
let t = this._matrixMap.get(e);
|
|
30
30
|
t || (t = /* @__PURE__ */ new Map(), this._matrixMap.set(e, t));
|
|
31
|
-
let
|
|
32
|
-
return
|
|
31
|
+
let r = t.get(n);
|
|
32
|
+
return r || (r = new E(), t.set(n, r)), r;
|
|
33
33
|
}
|
|
34
|
-
_ensureCommentLocationMap(e,
|
|
34
|
+
_ensureCommentLocationMap(e, n) {
|
|
35
35
|
let t = this._locationMap.get(e);
|
|
36
36
|
t || (t = /* @__PURE__ */ new Map(), this._locationMap.set(e, t));
|
|
37
|
-
let
|
|
38
|
-
return
|
|
37
|
+
let r = t.get(n);
|
|
38
|
+
return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
|
|
39
39
|
}
|
|
40
|
-
_addCommentToMatrix(e,
|
|
40
|
+
_addCommentToMatrix(e, n, t, r) {
|
|
41
41
|
var s;
|
|
42
|
-
const o = (s = e.getValue(
|
|
43
|
-
o.add(
|
|
42
|
+
const o = (s = e.getValue(n, t)) != null ? s : /* @__PURE__ */ new Set();
|
|
43
|
+
o.add(r), e.setValue(n, t, o);
|
|
44
44
|
}
|
|
45
|
-
_deleteCommentFromMatrix(e,
|
|
46
|
-
if (
|
|
47
|
-
const o = e.getValue(
|
|
48
|
-
o && o.has(
|
|
45
|
+
_deleteCommentFromMatrix(e, n, t, r) {
|
|
46
|
+
if (n >= 0 && t >= 0) {
|
|
47
|
+
const o = e.getValue(n, t);
|
|
48
|
+
o && o.has(r) && (o.delete(r), o.size === 0 && e.realDeleteValue(n, t));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
_ensure(e,
|
|
52
|
-
const t = this._ensureCommentMatrix(e,
|
|
53
|
-
return { matrix: t, locationMap:
|
|
51
|
+
_ensure(e, n) {
|
|
52
|
+
const t = this._ensureCommentMatrix(e, n), r = this._ensureCommentLocationMap(e, n);
|
|
53
|
+
return { matrix: t, locationMap: r };
|
|
54
54
|
}
|
|
55
55
|
_initData() {
|
|
56
56
|
const e = this._threadCommentModel.getAll();
|
|
57
|
-
for (const
|
|
58
|
-
for (const t of
|
|
59
|
-
const { unitId:
|
|
60
|
-
this._addComment(
|
|
57
|
+
for (const n of e)
|
|
58
|
+
for (const t of n.threads) {
|
|
59
|
+
const { unitId: r, subUnitId: o, root: s } = t;
|
|
60
|
+
this._addComment(r, o, s);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
_addComment(e,
|
|
64
|
-
const
|
|
65
|
-
!o && s >= 0 &&
|
|
63
|
+
_addComment(e, n, t) {
|
|
64
|
+
const r = u(t.ref), o = t.parentId, { row: s, column: i } = r, c = t.id, { matrix: m, locationMap: d } = this._ensure(e, n);
|
|
65
|
+
!o && s >= 0 && i >= 0 && (this._addCommentToMatrix(m, s, i, c), d.set(c, { row: s, column: i })), o || this._commentUpdate$.next({
|
|
66
66
|
unitId: e,
|
|
67
|
-
subUnitId:
|
|
67
|
+
subUnitId: n,
|
|
68
68
|
payload: t,
|
|
69
69
|
type: "add",
|
|
70
70
|
isRoot: !o,
|
|
71
|
-
...
|
|
71
|
+
...r
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
// eslint-disable-next-line max-lines-per-function
|
|
75
75
|
_initUpdateTransform() {
|
|
76
76
|
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((e) => {
|
|
77
|
-
const { unitId:
|
|
77
|
+
const { unitId: n, subUnitId: t } = e;
|
|
78
78
|
try {
|
|
79
|
-
if (this._univerInstanceService.getUnitType(
|
|
79
|
+
if (this._univerInstanceService.getUnitType(n) !== y.UNIVER_SHEET)
|
|
80
80
|
return;
|
|
81
81
|
} catch {
|
|
82
82
|
}
|
|
83
|
-
const { matrix:
|
|
83
|
+
const { matrix: r, locationMap: o } = this._ensure(n, t);
|
|
84
84
|
switch (e.type) {
|
|
85
85
|
case "add": {
|
|
86
86
|
this._addComment(e.unitId, e.subUnitId, e.payload);
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
case "delete": {
|
|
90
|
-
const { isRoot: s, comment:
|
|
90
|
+
const { isRoot: s, comment: i } = e.payload;
|
|
91
91
|
if (s) {
|
|
92
|
-
const c = u(
|
|
93
|
-
this._deleteCommentFromMatrix(
|
|
92
|
+
const c = u(i.ref), { row: m, column: d } = c;
|
|
93
|
+
this._deleteCommentFromMatrix(r, m, d, i.id), this._commentUpdate$.next({
|
|
94
94
|
...e,
|
|
95
95
|
...c
|
|
96
96
|
});
|
|
@@ -98,10 +98,10 @@ let p = class extends R {
|
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
case "update": {
|
|
101
|
-
const { commentId: s } = e.payload,
|
|
102
|
-
if (!
|
|
101
|
+
const { commentId: s } = e.payload, i = this._threadCommentModel.getComment(n, t, s);
|
|
102
|
+
if (!i)
|
|
103
103
|
return;
|
|
104
|
-
const c = u(
|
|
104
|
+
const c = u(i.ref);
|
|
105
105
|
this._commentUpdate$.next({
|
|
106
106
|
...e,
|
|
107
107
|
...c
|
|
@@ -109,18 +109,18 @@ let p = class extends R {
|
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
case "updateRef": {
|
|
112
|
-
const s = u(e.payload.ref), { commentId:
|
|
112
|
+
const s = u(e.payload.ref), { commentId: i } = e.payload, c = o.get(i);
|
|
113
113
|
if (!c)
|
|
114
114
|
return;
|
|
115
115
|
const { row: m, column: d } = c;
|
|
116
|
-
this._deleteCommentFromMatrix(
|
|
116
|
+
this._deleteCommentFromMatrix(r, m, d, i), o.delete(i), s.row >= 0 && s.column >= 0 && (this._addCommentToMatrix(r, s.row, s.column, i), o.set(i, { row: s.row, column: s.column })), this._commentUpdate$.next({
|
|
117
117
|
...e,
|
|
118
118
|
...s
|
|
119
119
|
});
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
122
|
case "resolve": {
|
|
123
|
-
const { unitId: s, subUnitId:
|
|
123
|
+
const { unitId: s, subUnitId: i, payload: c } = e, { locationMap: m } = this._ensure(s, i), d = m.get(c.commentId);
|
|
124
124
|
d && this._commentUpdate$.next({
|
|
125
125
|
...e,
|
|
126
126
|
...d
|
|
@@ -130,65 +130,65 @@ let p = class extends R {
|
|
|
130
130
|
}
|
|
131
131
|
}));
|
|
132
132
|
}
|
|
133
|
-
getByLocation(e,
|
|
134
|
-
var
|
|
135
|
-
return (
|
|
133
|
+
getByLocation(e, n, t, r) {
|
|
134
|
+
var i;
|
|
135
|
+
return (i = this.getAllByLocation(e, n, t, r).filter((c) => !c.resolved)[0]) == null ? void 0 : i.id;
|
|
136
136
|
}
|
|
137
|
-
getAllByLocation(e,
|
|
138
|
-
const s = this._ensureCommentMatrix(e,
|
|
139
|
-
return s ? Array.from(s).map((
|
|
137
|
+
getAllByLocation(e, n, t, r) {
|
|
138
|
+
const s = this._ensureCommentMatrix(e, n).getValue(t, r);
|
|
139
|
+
return s ? Array.from(s).map((i) => this.getComment(e, n, i)).filter(Boolean) : [];
|
|
140
140
|
}
|
|
141
|
-
getComment(e,
|
|
142
|
-
return this._threadCommentModel.getComment(e,
|
|
141
|
+
getComment(e, n, t) {
|
|
142
|
+
return this._threadCommentModel.getComment(e, n, t);
|
|
143
143
|
}
|
|
144
|
-
getCommentWithChildren(e,
|
|
145
|
-
const o = this.getByLocation(e,
|
|
144
|
+
getCommentWithChildren(e, n, t, r) {
|
|
145
|
+
const o = this.getByLocation(e, n, t, r);
|
|
146
146
|
if (!o)
|
|
147
147
|
return;
|
|
148
|
-
const s = this.getComment(e,
|
|
148
|
+
const s = this.getComment(e, n, o);
|
|
149
149
|
if (s)
|
|
150
|
-
return this._threadCommentModel.getThread(e,
|
|
150
|
+
return this._threadCommentModel.getThread(e, n, s.threadId);
|
|
151
151
|
}
|
|
152
|
-
showCommentMarker(e,
|
|
153
|
-
const o = this.getByLocation(e,
|
|
152
|
+
showCommentMarker(e, n, t, r) {
|
|
153
|
+
const o = this.getByLocation(e, n, t, r);
|
|
154
154
|
if (!o)
|
|
155
155
|
return !1;
|
|
156
|
-
const s = this.getComment(e,
|
|
156
|
+
const s = this.getComment(e, n, o);
|
|
157
157
|
return !!(s && !s.resolved);
|
|
158
158
|
}
|
|
159
|
-
getSubUnitAll(e,
|
|
160
|
-
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId ===
|
|
159
|
+
getSubUnitAll(e, n) {
|
|
160
|
+
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId === n).map((t) => t.root);
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
p = k([
|
|
164
|
-
w(0,
|
|
164
|
+
w(0, h(S)),
|
|
165
165
|
w(1, T)
|
|
166
166
|
], p);
|
|
167
|
-
var z = Object.getOwnPropertyDescriptor, G = (
|
|
168
|
-
for (var
|
|
169
|
-
(s =
|
|
170
|
-
return
|
|
171
|
-
}, _ = (
|
|
167
|
+
var z = Object.getOwnPropertyDescriptor, G = (a, e, n, t) => {
|
|
168
|
+
for (var r = t > 1 ? void 0 : t ? z(e, n) : e, o = a.length - 1, s; o >= 0; o--)
|
|
169
|
+
(s = a[o]) && (r = s(r) || r);
|
|
170
|
+
return r;
|
|
171
|
+
}, _ = (a, e) => (n, t) => e(n, t, a);
|
|
172
172
|
let f = class extends R {
|
|
173
|
-
constructor(e,
|
|
173
|
+
constructor(e, n, t, r, o) {
|
|
174
174
|
super();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const s = t.id,
|
|
175
|
+
l(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
176
|
+
l(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
177
|
+
l(this, "_handleRangeChange", (e, n, t, r, o) => {
|
|
178
|
+
const s = t.id, i = {
|
|
179
179
|
startColumn: t.column,
|
|
180
180
|
endColumn: t.column,
|
|
181
181
|
startRow: t.row,
|
|
182
182
|
endRow: t.row
|
|
183
183
|
};
|
|
184
|
-
return
|
|
184
|
+
return r ? {
|
|
185
185
|
redos: [{
|
|
186
186
|
id: C.id,
|
|
187
187
|
params: {
|
|
188
188
|
unitId: e,
|
|
189
|
-
subUnitId:
|
|
189
|
+
subUnitId: n,
|
|
190
190
|
payload: {
|
|
191
|
-
ref: M(
|
|
191
|
+
ref: M(r),
|
|
192
192
|
commentId: s
|
|
193
193
|
},
|
|
194
194
|
silent: o
|
|
@@ -198,9 +198,9 @@ let f = class extends R {
|
|
|
198
198
|
id: C.id,
|
|
199
199
|
params: {
|
|
200
200
|
unitId: e,
|
|
201
|
-
subUnitId:
|
|
201
|
+
subUnitId: n,
|
|
202
202
|
payload: {
|
|
203
|
-
ref: M(
|
|
203
|
+
ref: M(i),
|
|
204
204
|
commentId: s
|
|
205
205
|
},
|
|
206
206
|
silent: o
|
|
@@ -211,7 +211,7 @@ let f = class extends R {
|
|
|
211
211
|
id: N.id,
|
|
212
212
|
params: {
|
|
213
213
|
unitId: e,
|
|
214
|
-
subUnitId:
|
|
214
|
+
subUnitId: n,
|
|
215
215
|
commentId: s
|
|
216
216
|
}
|
|
217
217
|
}],
|
|
@@ -219,103 +219,103 @@ let f = class extends R {
|
|
|
219
219
|
id: B.id,
|
|
220
220
|
params: {
|
|
221
221
|
unitId: e,
|
|
222
|
-
subUnitId:
|
|
222
|
+
subUnitId: n,
|
|
223
223
|
comment: t,
|
|
224
224
|
sync: !0
|
|
225
225
|
}
|
|
226
226
|
}]
|
|
227
227
|
};
|
|
228
228
|
});
|
|
229
|
-
this._refRangeService = e, this._sheetsThreadCommentModel =
|
|
229
|
+
this._refRangeService = e, this._sheetsThreadCommentModel = n, this._threadCommentModel = t, this._selectionManagerService = r, this._commandService = o, this._initData(), this._initRefRange();
|
|
230
230
|
}
|
|
231
|
-
_getIdWithUnitId(e,
|
|
232
|
-
return `${e}-${
|
|
231
|
+
_getIdWithUnitId(e, n, t) {
|
|
232
|
+
return `${e}-${n}-${t}`;
|
|
233
233
|
}
|
|
234
|
-
_register(e,
|
|
235
|
-
const
|
|
234
|
+
_register(e, n, t) {
|
|
235
|
+
const r = t.id, o = {
|
|
236
236
|
startColumn: t.column,
|
|
237
237
|
endColumn: t.column,
|
|
238
238
|
startRow: t.row,
|
|
239
239
|
endRow: t.row
|
|
240
240
|
};
|
|
241
241
|
this._disposableMap.set(
|
|
242
|
-
this._getIdWithUnitId(e,
|
|
242
|
+
this._getIdWithUnitId(e, n, r),
|
|
243
243
|
this._refRangeService.registerRefRange(o, (s) => {
|
|
244
|
-
const
|
|
244
|
+
const i = j(o, s, { selectionManagerService: this._selectionManagerService }), c = Array.isArray(i) ? i[0] : i;
|
|
245
245
|
return c && c.startColumn === o.startColumn && c.startRow === o.startRow ? {
|
|
246
246
|
undos: [],
|
|
247
247
|
redos: []
|
|
248
|
-
} : this._handleRangeChange(e,
|
|
249
|
-
}, e,
|
|
248
|
+
} : this._handleRangeChange(e, n, t, c, !1);
|
|
249
|
+
}, e, n)
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
|
-
_watch(e,
|
|
253
|
-
const
|
|
252
|
+
_watch(e, n, t) {
|
|
253
|
+
const r = t.id, o = {
|
|
254
254
|
startColumn: t.column,
|
|
255
255
|
endColumn: t.column,
|
|
256
256
|
startRow: t.row,
|
|
257
257
|
endRow: t.row
|
|
258
258
|
};
|
|
259
259
|
this._watcherMap.set(
|
|
260
|
-
this._getIdWithUnitId(e,
|
|
261
|
-
this._refRangeService.watchRange(e,
|
|
262
|
-
const { redos: c } = this._handleRangeChange(e,
|
|
260
|
+
this._getIdWithUnitId(e, n, r),
|
|
261
|
+
this._refRangeService.watchRange(e, n, o, (s, i) => {
|
|
262
|
+
const { redos: c } = this._handleRangeChange(e, n, t, i, !0);
|
|
263
263
|
$(c, this._commandService, { onlyLocal: !0 });
|
|
264
264
|
}, !0)
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
_unwatch(e,
|
|
267
|
+
_unwatch(e, n, t) {
|
|
268
268
|
var o;
|
|
269
|
-
const
|
|
270
|
-
(o = this._watcherMap.get(
|
|
269
|
+
const r = this._getIdWithUnitId(e, n, t);
|
|
270
|
+
(o = this._watcherMap.get(r)) == null || o.dispose(), this._watcherMap.delete(r);
|
|
271
271
|
}
|
|
272
|
-
_unregister(e,
|
|
272
|
+
_unregister(e, n, t) {
|
|
273
273
|
var o;
|
|
274
|
-
const
|
|
275
|
-
(o = this._disposableMap.get(
|
|
274
|
+
const r = this._getIdWithUnitId(e, n, t);
|
|
275
|
+
(o = this._disposableMap.get(r)) == null || o.dispose(), this._disposableMap.delete(r);
|
|
276
276
|
}
|
|
277
277
|
_initData() {
|
|
278
278
|
const e = this._threadCommentModel.getAll();
|
|
279
|
-
for (const
|
|
280
|
-
for (const t of
|
|
281
|
-
const { unitId:
|
|
279
|
+
for (const n of e)
|
|
280
|
+
for (const t of n.threads) {
|
|
281
|
+
const { unitId: r, subUnitId: o, root: s } = t, i = u(s.ref), c = {
|
|
282
282
|
...s,
|
|
283
|
-
...
|
|
283
|
+
...i
|
|
284
284
|
};
|
|
285
|
-
this._register(
|
|
285
|
+
this._register(r, o, c), this._watch(r, o, c);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
_initRefRange() {
|
|
289
289
|
this.disposeWithMe(
|
|
290
290
|
this._sheetsThreadCommentModel.commentUpdate$.subscribe((e) => {
|
|
291
|
-
const { unitId:
|
|
291
|
+
const { unitId: n, subUnitId: t } = e;
|
|
292
292
|
switch (e.type) {
|
|
293
293
|
case "add": {
|
|
294
294
|
if (e.payload.parentId)
|
|
295
295
|
return;
|
|
296
|
-
const
|
|
296
|
+
const r = {
|
|
297
297
|
...e.payload,
|
|
298
298
|
row: e.row,
|
|
299
299
|
column: e.column
|
|
300
300
|
};
|
|
301
|
-
this._register(e.unitId, e.subUnitId,
|
|
301
|
+
this._register(e.unitId, e.subUnitId, r), this._watch(e.unitId, e.subUnitId, r);
|
|
302
302
|
break;
|
|
303
303
|
}
|
|
304
304
|
case "delete": {
|
|
305
|
-
this._unregister(
|
|
305
|
+
this._unregister(n, t, e.payload.commentId), this._unwatch(n, t, e.payload.commentId);
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
308
|
case "updateRef": {
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
309
|
+
const r = this._sheetsThreadCommentModel.getComment(n, t, e.payload.commentId);
|
|
310
|
+
if (!r)
|
|
311
311
|
return;
|
|
312
|
-
this._unregister(
|
|
312
|
+
this._unregister(n, t, e.payload.commentId);
|
|
313
313
|
const o = {
|
|
314
|
-
...
|
|
314
|
+
...r,
|
|
315
315
|
row: e.row,
|
|
316
316
|
column: e.column
|
|
317
317
|
};
|
|
318
|
-
e.silent || (this._unwatch(
|
|
318
|
+
e.silent || (this._unwatch(n, t, e.payload.commentId), this._watch(n, t, o)), this._register(e.unitId, e.subUnitId, o);
|
|
319
319
|
break;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
@@ -328,37 +328,37 @@ let f = class extends R {
|
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
330
|
f = G([
|
|
331
|
-
_(0,
|
|
332
|
-
_(1,
|
|
333
|
-
_(2,
|
|
334
|
-
_(3,
|
|
331
|
+
_(0, h(W)),
|
|
332
|
+
_(1, h(p)),
|
|
333
|
+
_(2, h(S)),
|
|
334
|
+
_(3, h(L)),
|
|
335
335
|
_(4, b)
|
|
336
336
|
], f);
|
|
337
|
-
const q = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
338
|
-
var
|
|
339
|
-
for (var
|
|
340
|
-
(s =
|
|
341
|
-
return
|
|
342
|
-
}, v = (
|
|
337
|
+
const q = {}, J = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
338
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, X = (a, e, n) => e in a ? K(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n, Y = (a, e, n, t) => {
|
|
339
|
+
for (var r = t > 1 ? void 0 : t ? Q(e, n) : e, o = a.length - 1, s; o >= 0; o--)
|
|
340
|
+
(s = a[o]) && (r = s(r) || r);
|
|
341
|
+
return r;
|
|
342
|
+
}, v = (a, e) => (n, t) => e(n, t, a), I = (a, e, n) => X(a, typeof e != "symbol" ? e + "" : e, n);
|
|
343
343
|
let g = class extends A {
|
|
344
|
-
constructor(
|
|
345
|
-
super(), this._injector = e, this._commandService =
|
|
344
|
+
constructor(a = q, e, n) {
|
|
345
|
+
super(), this._config = a, this._injector = e, this._commandService = n;
|
|
346
346
|
}
|
|
347
347
|
onStarting() {
|
|
348
348
|
[
|
|
349
349
|
[p],
|
|
350
350
|
[f]
|
|
351
|
-
].forEach((
|
|
352
|
-
this._injector.add(
|
|
351
|
+
].forEach((a) => {
|
|
352
|
+
this._injector.add(a);
|
|
353
353
|
}), this._injector.get(f);
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
|
-
I(g, "pluginName",
|
|
356
|
+
I(g, "pluginName", J);
|
|
357
357
|
I(g, "type", y.UNIVER_SHEET);
|
|
358
|
-
g =
|
|
358
|
+
g = Y([
|
|
359
359
|
P(V),
|
|
360
|
-
v(1,
|
|
361
|
-
v(2,
|
|
360
|
+
v(1, h(O)),
|
|
361
|
+
v(2, h(b))
|
|
362
362
|
], g);
|
|
363
363
|
export {
|
|
364
364
|
p as SheetsThreadCommentModel,
|
package/lib/index.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
1
|
var U = Object.defineProperty;
|
|
2
|
-
var x = (
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
2
|
+
var x = (a, e, n) => e in a ? U(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3
|
+
var l = (a, e, n) => x(a, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { Inject as h, IUniverInstanceService as T, Disposable as R, ObjectMatrix as E, UniverInstanceType as y, ICommandService as b, sequenceExecuteAsync as $, toDisposable as D, DependentOn as P, Injector as O, Plugin as A } from "@univerjs/core";
|
|
5
5
|
import { singleReferenceToGrid as u, serializeRange as M } from "@univerjs/engine-formula";
|
|
6
6
|
import { RefRangeService as W, SheetsSelectionsService as L, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as j } from "@univerjs/sheets";
|
|
7
7
|
import { ThreadCommentModel as S, AddCommentMutation as B, DeleteCommentMutation as N, UpdateCommentRefMutation as C, UniverThreadCommentPlugin as V } from "@univerjs/thread-comment";
|
|
8
8
|
import { Subject as H } from "rxjs";
|
|
9
|
-
var F = Object.getOwnPropertyDescriptor, k = (
|
|
10
|
-
for (var
|
|
11
|
-
(s =
|
|
12
|
-
return
|
|
13
|
-
}, w = (
|
|
9
|
+
var F = Object.getOwnPropertyDescriptor, k = (a, e, n, t) => {
|
|
10
|
+
for (var r = t > 1 ? void 0 : t ? F(e, n) : e, o = a.length - 1, s; o >= 0; o--)
|
|
11
|
+
(s = a[o]) && (r = s(r) || r);
|
|
12
|
+
return r;
|
|
13
|
+
}, w = (a, e) => (n, t) => e(n, t, a);
|
|
14
14
|
let p = class extends R {
|
|
15
|
-
constructor(e,
|
|
15
|
+
constructor(e, n) {
|
|
16
16
|
super();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this._threadCommentModel = e, this._univerInstanceService =
|
|
17
|
+
l(this, "_matrixMap", /* @__PURE__ */ new Map());
|
|
18
|
+
l(this, "_locationMap", /* @__PURE__ */ new Map());
|
|
19
|
+
l(this, "_commentUpdate$", new H());
|
|
20
|
+
l(this, "commentUpdate$", this._commentUpdate$.asObservable());
|
|
21
|
+
this._threadCommentModel = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
|
|
22
22
|
this._commentUpdate$.complete();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
_init() {
|
|
26
26
|
this._initData(), this._initUpdateTransform();
|
|
27
27
|
}
|
|
28
|
-
_ensureCommentMatrix(e,
|
|
28
|
+
_ensureCommentMatrix(e, n) {
|
|
29
29
|
let t = this._matrixMap.get(e);
|
|
30
30
|
t || (t = /* @__PURE__ */ new Map(), this._matrixMap.set(e, t));
|
|
31
|
-
let
|
|
32
|
-
return
|
|
31
|
+
let r = t.get(n);
|
|
32
|
+
return r || (r = new E(), t.set(n, r)), r;
|
|
33
33
|
}
|
|
34
|
-
_ensureCommentLocationMap(e,
|
|
34
|
+
_ensureCommentLocationMap(e, n) {
|
|
35
35
|
let t = this._locationMap.get(e);
|
|
36
36
|
t || (t = /* @__PURE__ */ new Map(), this._locationMap.set(e, t));
|
|
37
|
-
let
|
|
38
|
-
return
|
|
37
|
+
let r = t.get(n);
|
|
38
|
+
return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
|
|
39
39
|
}
|
|
40
|
-
_addCommentToMatrix(e,
|
|
40
|
+
_addCommentToMatrix(e, n, t, r) {
|
|
41
41
|
var s;
|
|
42
|
-
const o = (s = e.getValue(
|
|
43
|
-
o.add(
|
|
42
|
+
const o = (s = e.getValue(n, t)) != null ? s : /* @__PURE__ */ new Set();
|
|
43
|
+
o.add(r), e.setValue(n, t, o);
|
|
44
44
|
}
|
|
45
|
-
_deleteCommentFromMatrix(e,
|
|
46
|
-
if (
|
|
47
|
-
const o = e.getValue(
|
|
48
|
-
o && o.has(
|
|
45
|
+
_deleteCommentFromMatrix(e, n, t, r) {
|
|
46
|
+
if (n >= 0 && t >= 0) {
|
|
47
|
+
const o = e.getValue(n, t);
|
|
48
|
+
o && o.has(r) && (o.delete(r), o.size === 0 && e.realDeleteValue(n, t));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
_ensure(e,
|
|
52
|
-
const t = this._ensureCommentMatrix(e,
|
|
53
|
-
return { matrix: t, locationMap:
|
|
51
|
+
_ensure(e, n) {
|
|
52
|
+
const t = this._ensureCommentMatrix(e, n), r = this._ensureCommentLocationMap(e, n);
|
|
53
|
+
return { matrix: t, locationMap: r };
|
|
54
54
|
}
|
|
55
55
|
_initData() {
|
|
56
56
|
const e = this._threadCommentModel.getAll();
|
|
57
|
-
for (const
|
|
58
|
-
for (const t of
|
|
59
|
-
const { unitId:
|
|
60
|
-
this._addComment(
|
|
57
|
+
for (const n of e)
|
|
58
|
+
for (const t of n.threads) {
|
|
59
|
+
const { unitId: r, subUnitId: o, root: s } = t;
|
|
60
|
+
this._addComment(r, o, s);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
_addComment(e,
|
|
64
|
-
const
|
|
65
|
-
!o && s >= 0 &&
|
|
63
|
+
_addComment(e, n, t) {
|
|
64
|
+
const r = u(t.ref), o = t.parentId, { row: s, column: i } = r, c = t.id, { matrix: m, locationMap: d } = this._ensure(e, n);
|
|
65
|
+
!o && s >= 0 && i >= 0 && (this._addCommentToMatrix(m, s, i, c), d.set(c, { row: s, column: i })), o || this._commentUpdate$.next({
|
|
66
66
|
unitId: e,
|
|
67
|
-
subUnitId:
|
|
67
|
+
subUnitId: n,
|
|
68
68
|
payload: t,
|
|
69
69
|
type: "add",
|
|
70
70
|
isRoot: !o,
|
|
71
|
-
...
|
|
71
|
+
...r
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
// eslint-disable-next-line max-lines-per-function
|
|
75
75
|
_initUpdateTransform() {
|
|
76
76
|
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((e) => {
|
|
77
|
-
const { unitId:
|
|
77
|
+
const { unitId: n, subUnitId: t } = e;
|
|
78
78
|
try {
|
|
79
|
-
if (this._univerInstanceService.getUnitType(
|
|
79
|
+
if (this._univerInstanceService.getUnitType(n) !== y.UNIVER_SHEET)
|
|
80
80
|
return;
|
|
81
81
|
} catch {
|
|
82
82
|
}
|
|
83
|
-
const { matrix:
|
|
83
|
+
const { matrix: r, locationMap: o } = this._ensure(n, t);
|
|
84
84
|
switch (e.type) {
|
|
85
85
|
case "add": {
|
|
86
86
|
this._addComment(e.unitId, e.subUnitId, e.payload);
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
case "delete": {
|
|
90
|
-
const { isRoot: s, comment:
|
|
90
|
+
const { isRoot: s, comment: i } = e.payload;
|
|
91
91
|
if (s) {
|
|
92
|
-
const c = u(
|
|
93
|
-
this._deleteCommentFromMatrix(
|
|
92
|
+
const c = u(i.ref), { row: m, column: d } = c;
|
|
93
|
+
this._deleteCommentFromMatrix(r, m, d, i.id), this._commentUpdate$.next({
|
|
94
94
|
...e,
|
|
95
95
|
...c
|
|
96
96
|
});
|
|
@@ -98,10 +98,10 @@ let p = class extends R {
|
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
case "update": {
|
|
101
|
-
const { commentId: s } = e.payload,
|
|
102
|
-
if (!
|
|
101
|
+
const { commentId: s } = e.payload, i = this._threadCommentModel.getComment(n, t, s);
|
|
102
|
+
if (!i)
|
|
103
103
|
return;
|
|
104
|
-
const c = u(
|
|
104
|
+
const c = u(i.ref);
|
|
105
105
|
this._commentUpdate$.next({
|
|
106
106
|
...e,
|
|
107
107
|
...c
|
|
@@ -109,18 +109,18 @@ let p = class extends R {
|
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
case "updateRef": {
|
|
112
|
-
const s = u(e.payload.ref), { commentId:
|
|
112
|
+
const s = u(e.payload.ref), { commentId: i } = e.payload, c = o.get(i);
|
|
113
113
|
if (!c)
|
|
114
114
|
return;
|
|
115
115
|
const { row: m, column: d } = c;
|
|
116
|
-
this._deleteCommentFromMatrix(
|
|
116
|
+
this._deleteCommentFromMatrix(r, m, d, i), o.delete(i), s.row >= 0 && s.column >= 0 && (this._addCommentToMatrix(r, s.row, s.column, i), o.set(i, { row: s.row, column: s.column })), this._commentUpdate$.next({
|
|
117
117
|
...e,
|
|
118
118
|
...s
|
|
119
119
|
});
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
122
|
case "resolve": {
|
|
123
|
-
const { unitId: s, subUnitId:
|
|
123
|
+
const { unitId: s, subUnitId: i, payload: c } = e, { locationMap: m } = this._ensure(s, i), d = m.get(c.commentId);
|
|
124
124
|
d && this._commentUpdate$.next({
|
|
125
125
|
...e,
|
|
126
126
|
...d
|
|
@@ -130,65 +130,65 @@ let p = class extends R {
|
|
|
130
130
|
}
|
|
131
131
|
}));
|
|
132
132
|
}
|
|
133
|
-
getByLocation(e,
|
|
134
|
-
var
|
|
135
|
-
return (
|
|
133
|
+
getByLocation(e, n, t, r) {
|
|
134
|
+
var i;
|
|
135
|
+
return (i = this.getAllByLocation(e, n, t, r).filter((c) => !c.resolved)[0]) == null ? void 0 : i.id;
|
|
136
136
|
}
|
|
137
|
-
getAllByLocation(e,
|
|
138
|
-
const s = this._ensureCommentMatrix(e,
|
|
139
|
-
return s ? Array.from(s).map((
|
|
137
|
+
getAllByLocation(e, n, t, r) {
|
|
138
|
+
const s = this._ensureCommentMatrix(e, n).getValue(t, r);
|
|
139
|
+
return s ? Array.from(s).map((i) => this.getComment(e, n, i)).filter(Boolean) : [];
|
|
140
140
|
}
|
|
141
|
-
getComment(e,
|
|
142
|
-
return this._threadCommentModel.getComment(e,
|
|
141
|
+
getComment(e, n, t) {
|
|
142
|
+
return this._threadCommentModel.getComment(e, n, t);
|
|
143
143
|
}
|
|
144
|
-
getCommentWithChildren(e,
|
|
145
|
-
const o = this.getByLocation(e,
|
|
144
|
+
getCommentWithChildren(e, n, t, r) {
|
|
145
|
+
const o = this.getByLocation(e, n, t, r);
|
|
146
146
|
if (!o)
|
|
147
147
|
return;
|
|
148
|
-
const s = this.getComment(e,
|
|
148
|
+
const s = this.getComment(e, n, o);
|
|
149
149
|
if (s)
|
|
150
|
-
return this._threadCommentModel.getThread(e,
|
|
150
|
+
return this._threadCommentModel.getThread(e, n, s.threadId);
|
|
151
151
|
}
|
|
152
|
-
showCommentMarker(e,
|
|
153
|
-
const o = this.getByLocation(e,
|
|
152
|
+
showCommentMarker(e, n, t, r) {
|
|
153
|
+
const o = this.getByLocation(e, n, t, r);
|
|
154
154
|
if (!o)
|
|
155
155
|
return !1;
|
|
156
|
-
const s = this.getComment(e,
|
|
156
|
+
const s = this.getComment(e, n, o);
|
|
157
157
|
return !!(s && !s.resolved);
|
|
158
158
|
}
|
|
159
|
-
getSubUnitAll(e,
|
|
160
|
-
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId ===
|
|
159
|
+
getSubUnitAll(e, n) {
|
|
160
|
+
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId === n).map((t) => t.root);
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
p = k([
|
|
164
|
-
w(0,
|
|
164
|
+
w(0, h(S)),
|
|
165
165
|
w(1, T)
|
|
166
166
|
], p);
|
|
167
|
-
var z = Object.getOwnPropertyDescriptor, G = (
|
|
168
|
-
for (var
|
|
169
|
-
(s =
|
|
170
|
-
return
|
|
171
|
-
}, _ = (
|
|
167
|
+
var z = Object.getOwnPropertyDescriptor, G = (a, e, n, t) => {
|
|
168
|
+
for (var r = t > 1 ? void 0 : t ? z(e, n) : e, o = a.length - 1, s; o >= 0; o--)
|
|
169
|
+
(s = a[o]) && (r = s(r) || r);
|
|
170
|
+
return r;
|
|
171
|
+
}, _ = (a, e) => (n, t) => e(n, t, a);
|
|
172
172
|
let f = class extends R {
|
|
173
|
-
constructor(e,
|
|
173
|
+
constructor(e, n, t, r, o) {
|
|
174
174
|
super();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const s = t.id,
|
|
175
|
+
l(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
176
|
+
l(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
177
|
+
l(this, "_handleRangeChange", (e, n, t, r, o) => {
|
|
178
|
+
const s = t.id, i = {
|
|
179
179
|
startColumn: t.column,
|
|
180
180
|
endColumn: t.column,
|
|
181
181
|
startRow: t.row,
|
|
182
182
|
endRow: t.row
|
|
183
183
|
};
|
|
184
|
-
return
|
|
184
|
+
return r ? {
|
|
185
185
|
redos: [{
|
|
186
186
|
id: C.id,
|
|
187
187
|
params: {
|
|
188
188
|
unitId: e,
|
|
189
|
-
subUnitId:
|
|
189
|
+
subUnitId: n,
|
|
190
190
|
payload: {
|
|
191
|
-
ref: M(
|
|
191
|
+
ref: M(r),
|
|
192
192
|
commentId: s
|
|
193
193
|
},
|
|
194
194
|
silent: o
|
|
@@ -198,9 +198,9 @@ let f = class extends R {
|
|
|
198
198
|
id: C.id,
|
|
199
199
|
params: {
|
|
200
200
|
unitId: e,
|
|
201
|
-
subUnitId:
|
|
201
|
+
subUnitId: n,
|
|
202
202
|
payload: {
|
|
203
|
-
ref: M(
|
|
203
|
+
ref: M(i),
|
|
204
204
|
commentId: s
|
|
205
205
|
},
|
|
206
206
|
silent: o
|
|
@@ -211,7 +211,7 @@ let f = class extends R {
|
|
|
211
211
|
id: N.id,
|
|
212
212
|
params: {
|
|
213
213
|
unitId: e,
|
|
214
|
-
subUnitId:
|
|
214
|
+
subUnitId: n,
|
|
215
215
|
commentId: s
|
|
216
216
|
}
|
|
217
217
|
}],
|
|
@@ -219,103 +219,103 @@ let f = class extends R {
|
|
|
219
219
|
id: B.id,
|
|
220
220
|
params: {
|
|
221
221
|
unitId: e,
|
|
222
|
-
subUnitId:
|
|
222
|
+
subUnitId: n,
|
|
223
223
|
comment: t,
|
|
224
224
|
sync: !0
|
|
225
225
|
}
|
|
226
226
|
}]
|
|
227
227
|
};
|
|
228
228
|
});
|
|
229
|
-
this._refRangeService = e, this._sheetsThreadCommentModel =
|
|
229
|
+
this._refRangeService = e, this._sheetsThreadCommentModel = n, this._threadCommentModel = t, this._selectionManagerService = r, this._commandService = o, this._initData(), this._initRefRange();
|
|
230
230
|
}
|
|
231
|
-
_getIdWithUnitId(e,
|
|
232
|
-
return `${e}-${
|
|
231
|
+
_getIdWithUnitId(e, n, t) {
|
|
232
|
+
return `${e}-${n}-${t}`;
|
|
233
233
|
}
|
|
234
|
-
_register(e,
|
|
235
|
-
const
|
|
234
|
+
_register(e, n, t) {
|
|
235
|
+
const r = t.id, o = {
|
|
236
236
|
startColumn: t.column,
|
|
237
237
|
endColumn: t.column,
|
|
238
238
|
startRow: t.row,
|
|
239
239
|
endRow: t.row
|
|
240
240
|
};
|
|
241
241
|
this._disposableMap.set(
|
|
242
|
-
this._getIdWithUnitId(e,
|
|
242
|
+
this._getIdWithUnitId(e, n, r),
|
|
243
243
|
this._refRangeService.registerRefRange(o, (s) => {
|
|
244
|
-
const
|
|
244
|
+
const i = j(o, s, { selectionManagerService: this._selectionManagerService }), c = Array.isArray(i) ? i[0] : i;
|
|
245
245
|
return c && c.startColumn === o.startColumn && c.startRow === o.startRow ? {
|
|
246
246
|
undos: [],
|
|
247
247
|
redos: []
|
|
248
|
-
} : this._handleRangeChange(e,
|
|
249
|
-
}, e,
|
|
248
|
+
} : this._handleRangeChange(e, n, t, c, !1);
|
|
249
|
+
}, e, n)
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
|
-
_watch(e,
|
|
253
|
-
const
|
|
252
|
+
_watch(e, n, t) {
|
|
253
|
+
const r = t.id, o = {
|
|
254
254
|
startColumn: t.column,
|
|
255
255
|
endColumn: t.column,
|
|
256
256
|
startRow: t.row,
|
|
257
257
|
endRow: t.row
|
|
258
258
|
};
|
|
259
259
|
this._watcherMap.set(
|
|
260
|
-
this._getIdWithUnitId(e,
|
|
261
|
-
this._refRangeService.watchRange(e,
|
|
262
|
-
const { redos: c } = this._handleRangeChange(e,
|
|
260
|
+
this._getIdWithUnitId(e, n, r),
|
|
261
|
+
this._refRangeService.watchRange(e, n, o, (s, i) => {
|
|
262
|
+
const { redos: c } = this._handleRangeChange(e, n, t, i, !0);
|
|
263
263
|
$(c, this._commandService, { onlyLocal: !0 });
|
|
264
264
|
}, !0)
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
_unwatch(e,
|
|
267
|
+
_unwatch(e, n, t) {
|
|
268
268
|
var o;
|
|
269
|
-
const
|
|
270
|
-
(o = this._watcherMap.get(
|
|
269
|
+
const r = this._getIdWithUnitId(e, n, t);
|
|
270
|
+
(o = this._watcherMap.get(r)) == null || o.dispose(), this._watcherMap.delete(r);
|
|
271
271
|
}
|
|
272
|
-
_unregister(e,
|
|
272
|
+
_unregister(e, n, t) {
|
|
273
273
|
var o;
|
|
274
|
-
const
|
|
275
|
-
(o = this._disposableMap.get(
|
|
274
|
+
const r = this._getIdWithUnitId(e, n, t);
|
|
275
|
+
(o = this._disposableMap.get(r)) == null || o.dispose(), this._disposableMap.delete(r);
|
|
276
276
|
}
|
|
277
277
|
_initData() {
|
|
278
278
|
const e = this._threadCommentModel.getAll();
|
|
279
|
-
for (const
|
|
280
|
-
for (const t of
|
|
281
|
-
const { unitId:
|
|
279
|
+
for (const n of e)
|
|
280
|
+
for (const t of n.threads) {
|
|
281
|
+
const { unitId: r, subUnitId: o, root: s } = t, i = u(s.ref), c = {
|
|
282
282
|
...s,
|
|
283
|
-
...
|
|
283
|
+
...i
|
|
284
284
|
};
|
|
285
|
-
this._register(
|
|
285
|
+
this._register(r, o, c), this._watch(r, o, c);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
_initRefRange() {
|
|
289
289
|
this.disposeWithMe(
|
|
290
290
|
this._sheetsThreadCommentModel.commentUpdate$.subscribe((e) => {
|
|
291
|
-
const { unitId:
|
|
291
|
+
const { unitId: n, subUnitId: t } = e;
|
|
292
292
|
switch (e.type) {
|
|
293
293
|
case "add": {
|
|
294
294
|
if (e.payload.parentId)
|
|
295
295
|
return;
|
|
296
|
-
const
|
|
296
|
+
const r = {
|
|
297
297
|
...e.payload,
|
|
298
298
|
row: e.row,
|
|
299
299
|
column: e.column
|
|
300
300
|
};
|
|
301
|
-
this._register(e.unitId, e.subUnitId,
|
|
301
|
+
this._register(e.unitId, e.subUnitId, r), this._watch(e.unitId, e.subUnitId, r);
|
|
302
302
|
break;
|
|
303
303
|
}
|
|
304
304
|
case "delete": {
|
|
305
|
-
this._unregister(
|
|
305
|
+
this._unregister(n, t, e.payload.commentId), this._unwatch(n, t, e.payload.commentId);
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
308
|
case "updateRef": {
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
309
|
+
const r = this._sheetsThreadCommentModel.getComment(n, t, e.payload.commentId);
|
|
310
|
+
if (!r)
|
|
311
311
|
return;
|
|
312
|
-
this._unregister(
|
|
312
|
+
this._unregister(n, t, e.payload.commentId);
|
|
313
313
|
const o = {
|
|
314
|
-
...
|
|
314
|
+
...r,
|
|
315
315
|
row: e.row,
|
|
316
316
|
column: e.column
|
|
317
317
|
};
|
|
318
|
-
e.silent || (this._unwatch(
|
|
318
|
+
e.silent || (this._unwatch(n, t, e.payload.commentId), this._watch(n, t, o)), this._register(e.unitId, e.subUnitId, o);
|
|
319
319
|
break;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
@@ -328,37 +328,37 @@ let f = class extends R {
|
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
330
|
f = G([
|
|
331
|
-
_(0,
|
|
332
|
-
_(1,
|
|
333
|
-
_(2,
|
|
334
|
-
_(3,
|
|
331
|
+
_(0, h(W)),
|
|
332
|
+
_(1, h(p)),
|
|
333
|
+
_(2, h(S)),
|
|
334
|
+
_(3, h(L)),
|
|
335
335
|
_(4, b)
|
|
336
336
|
], f);
|
|
337
|
-
const q = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
338
|
-
var
|
|
339
|
-
for (var
|
|
340
|
-
(s =
|
|
341
|
-
return
|
|
342
|
-
}, v = (
|
|
337
|
+
const q = {}, J = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
338
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, X = (a, e, n) => e in a ? K(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n, Y = (a, e, n, t) => {
|
|
339
|
+
for (var r = t > 1 ? void 0 : t ? Q(e, n) : e, o = a.length - 1, s; o >= 0; o--)
|
|
340
|
+
(s = a[o]) && (r = s(r) || r);
|
|
341
|
+
return r;
|
|
342
|
+
}, v = (a, e) => (n, t) => e(n, t, a), I = (a, e, n) => X(a, typeof e != "symbol" ? e + "" : e, n);
|
|
343
343
|
let g = class extends A {
|
|
344
|
-
constructor(
|
|
345
|
-
super(), this._injector = e, this._commandService =
|
|
344
|
+
constructor(a = q, e, n) {
|
|
345
|
+
super(), this._config = a, this._injector = e, this._commandService = n;
|
|
346
346
|
}
|
|
347
347
|
onStarting() {
|
|
348
348
|
[
|
|
349
349
|
[p],
|
|
350
350
|
[f]
|
|
351
|
-
].forEach((
|
|
352
|
-
this._injector.add(
|
|
351
|
+
].forEach((a) => {
|
|
352
|
+
this._injector.add(a);
|
|
353
353
|
}), this._injector.get(f);
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
|
-
I(g, "pluginName",
|
|
356
|
+
I(g, "pluginName", J);
|
|
357
357
|
I(g, "type", y.UNIVER_SHEET);
|
|
358
|
-
g =
|
|
358
|
+
g = Y([
|
|
359
359
|
P(V),
|
|
360
|
-
v(1,
|
|
361
|
-
v(2,
|
|
360
|
+
v(1, h(O)),
|
|
361
|
+
v(2, h(b))
|
|
362
362
|
], g);
|
|
363
363
|
export {
|
|
364
364
|
p as SheetsThreadCommentModel,
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY = "sheets-thread-comment.config";
|
|
17
17
|
export declare const configSymbol: unique symbol;
|
|
18
|
-
export interface
|
|
18
|
+
export interface IUniverSheetsThreadCommentConfig {
|
|
19
19
|
}
|
|
20
|
-
export declare const defaultPluginConfig:
|
|
20
|
+
export declare const defaultPluginConfig: IUniverSheetsThreadCommentConfig;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export type { IUniverSheetsThreadCommentConfig } from './controllers/config.schema';
|
|
16
17
|
export { SheetsThreadCommentRefRangeController } from './controllers/sheets-thread-comment-ref-range.controller';
|
|
17
18
|
export { SheetsThreadCommentModel } from './models/sheets-thread-comment.model';
|
|
18
|
-
export type { ISheetThreadComment } from './types/interfaces/i-sheet-thread-comment';
|
|
19
19
|
export { UniverSheetsThreadCommentPlugin } from './plugin';
|
|
20
|
+
export type { ISheetThreadComment } from './types/interfaces/i-sheet-thread-comment';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { IUniverSheetsThreadCommentConfig } from './controllers/config.schema';
|
|
1
2
|
import { ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
3
|
export declare class UniverSheetsThreadCommentPlugin extends Plugin {
|
|
4
|
+
private readonly _config;
|
|
3
5
|
protected _injector: Injector;
|
|
4
6
|
protected _commandService: ICommandService;
|
|
5
7
|
static pluginName: string;
|
|
6
8
|
static type: UniverInstanceType;
|
|
7
|
-
constructor(
|
|
9
|
+
constructor(_config: Partial<IUniverSheetsThreadCommentConfig> | undefined, _injector: Injector, _commandService: ICommandService);
|
|
8
10
|
onStarting(): void;
|
|
9
11
|
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(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
|
|
1
|
+
(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"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-nightly.202506271607",
|
|
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/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
59
|
+
"@univerjs/engine-formula": "0.8.3-nightly.202506271607",
|
|
60
|
+
"@univerjs/thread-comment": "0.8.3-nightly.202506271607",
|
|
61
|
+
"@univerjs/sheets": "0.8.3-nightly.202506271607",
|
|
62
|
+
"@univerjs/core": "0.8.3-nightly.202506271607"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"rxjs": "^7.8.2",
|
|
66
66
|
"typescript": "^5.8.3",
|
|
67
67
|
"vite": "^6.3.5",
|
|
68
68
|
"vitest": "^3.2.4",
|
|
69
|
-
"@univerjs-infra/shared": "0.8.
|
|
69
|
+
"@univerjs-infra/shared": "0.8.3"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"test": "vitest run",
|