@univerjs/sheets-thread-comment 1.0.0-rc.0 → 1.0.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/facade.js +13 -11
- package/lib/cjs/index.js +7 -8
- package/lib/es/facade.js +12 -10
- package/lib/es/index.js +7 -8
- package/lib/facade.js +12 -10
- package/lib/index.js +7 -8
- package/lib/types/facade/f-range.d.ts +5 -5
- package/lib/types/facade/f-thread-comment.d.ts +3 -3
- package/lib/types/facade/f-worksheet.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/lib/cjs/facade.js
CHANGED
|
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
24
|
value: mod,
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
@@ -35,7 +35,7 @@ _univerjs_thread_comment = __toESM(_univerjs_thread_comment);
|
|
|
35
35
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
36
36
|
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
37
37
|
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
39
39
|
function _typeof(o) {
|
|
40
40
|
"@babel/helpers - typeof";
|
|
41
41
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -46,7 +46,7 @@ function _typeof(o) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
50
50
|
function toPrimitive(t, r) {
|
|
51
51
|
if ("object" != _typeof(t) || !t) return t;
|
|
52
52
|
var e = t[Symbol.toPrimitive];
|
|
@@ -59,14 +59,14 @@ function toPrimitive(t, r) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
//#endregion
|
|
62
|
-
//#region \0@oxc-project+runtime@0.
|
|
62
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
63
63
|
function toPropertyKey(t) {
|
|
64
64
|
var i = toPrimitive(t, "string");
|
|
65
65
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region \0@oxc-project+runtime@0.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
70
70
|
function _defineProperty(e, r, t) {
|
|
71
71
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
72
72
|
value: t,
|
|
@@ -77,7 +77,7 @@ function _defineProperty(e, r, t) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
|
-
//#region \0@oxc-project+runtime@0.
|
|
80
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
81
81
|
function __decorateParam(paramIndex, decorator) {
|
|
82
82
|
return function(target, key) {
|
|
83
83
|
decorator(target, key, paramIndex);
|
|
@@ -85,7 +85,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
//#endregion
|
|
88
|
-
//#region \0@oxc-project+runtime@0.
|
|
88
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
89
89
|
function __decorate(decorators, target, key, desc) {
|
|
90
90
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
91
91
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -103,7 +103,7 @@ var _FThreadComment;
|
|
|
103
103
|
var FTheadCommentItem = class FTheadCommentItem {
|
|
104
104
|
/**
|
|
105
105
|
* Create a new FTheadCommentItem
|
|
106
|
-
* @param {IThreadComment|undefined} comment The comment
|
|
106
|
+
* @param {IThreadComment|undefined} [comment] The comment
|
|
107
107
|
* @returns {FTheadCommentItem} A new instance of FTheadCommentItem
|
|
108
108
|
* @example
|
|
109
109
|
* ```ts
|
|
@@ -374,7 +374,8 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
374
374
|
}
|
|
375
375
|
_getRef() {
|
|
376
376
|
var _this$_parent;
|
|
377
|
-
|
|
377
|
+
const ref = ((_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.ref) || this._thread.ref;
|
|
378
|
+
return (0, _univerjs_engine_formula.deserializeRangeWithSheet)(ref).range;
|
|
378
379
|
}
|
|
379
380
|
/**
|
|
380
381
|
* Whether the comment is a root comment
|
|
@@ -413,7 +414,7 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
413
414
|
}
|
|
414
415
|
/**
|
|
415
416
|
* Get the replies of the comment
|
|
416
|
-
* @returns {FThreadComment[]}
|
|
417
|
+
* @returns {FThreadComment[] | undefined} The loaded replies, or `undefined` when the thread or its replies are unavailable.
|
|
417
418
|
* @example
|
|
418
419
|
* ```ts
|
|
419
420
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -545,7 +546,7 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
545
546
|
}
|
|
546
547
|
/**
|
|
547
548
|
* Resolve the comment
|
|
548
|
-
* @param {boolean} resolved Whether the comment is resolved
|
|
549
|
+
* @param {boolean} [resolved] Whether the comment is resolved
|
|
549
550
|
* @returns {Promise<boolean>} Set the comment to resolved or not operation result
|
|
550
551
|
* @example
|
|
551
552
|
* ```ts
|
|
@@ -714,6 +715,7 @@ var FRangeSheetsThreadCommentMixin = class extends _univerjs_sheets_facade.FRang
|
|
|
714
715
|
id: firstNonEmpty(options.id, commentData === null || commentData === void 0 ? void 0 : commentData.id),
|
|
715
716
|
ref: refStr,
|
|
716
717
|
personId: firstNonEmpty(options.personId, commentData === null || commentData === void 0 ? void 0 : commentData.personId, currentUser.userID),
|
|
718
|
+
authorName: options.authorName ?? (commentData === null || commentData === void 0 ? void 0 : commentData.authorName),
|
|
717
719
|
parentId: currentComment === null || currentComment === void 0 ? void 0 : currentComment.id,
|
|
718
720
|
unitId,
|
|
719
721
|
subUnitId: sheetId,
|
package/lib/cjs/index.js
CHANGED
|
@@ -5,7 +5,7 @@ let _univerjs_sheets = require("@univerjs/sheets");
|
|
|
5
5
|
let _univerjs_thread_comment = require("@univerjs/thread-comment");
|
|
6
6
|
let rxjs = require("rxjs");
|
|
7
7
|
|
|
8
|
-
//#region \0@oxc-project+runtime@0.
|
|
8
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
9
9
|
function _typeof(o) {
|
|
10
10
|
"@babel/helpers - typeof";
|
|
11
11
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -16,7 +16,7 @@ function _typeof(o) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
|
-
//#region \0@oxc-project+runtime@0.
|
|
19
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
20
20
|
function toPrimitive(t, r) {
|
|
21
21
|
if ("object" != _typeof(t) || !t) return t;
|
|
22
22
|
var e = t[Symbol.toPrimitive];
|
|
@@ -29,14 +29,14 @@ function toPrimitive(t, r) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
|
-
//#region \0@oxc-project+runtime@0.
|
|
32
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
33
33
|
function toPropertyKey(t) {
|
|
34
34
|
var i = toPrimitive(t, "string");
|
|
35
35
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
|
-
//#region \0@oxc-project+runtime@0.
|
|
39
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
40
40
|
function _defineProperty(e, r, t) {
|
|
41
41
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
42
|
value: t,
|
|
@@ -47,7 +47,7 @@ function _defineProperty(e, r, t) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region \0@oxc-project+runtime@0.
|
|
50
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
51
51
|
function __decorateParam(paramIndex, decorator) {
|
|
52
52
|
return function(target, key) {
|
|
53
53
|
decorator(target, key, paramIndex);
|
|
@@ -55,7 +55,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
59
59
|
function __decorate(decorators, target, key, desc) {
|
|
60
60
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
61
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -228,7 +228,6 @@ let SheetsThreadCommentModel = class SheetsThreadCommentModel extends _univerjs_
|
|
|
228
228
|
});
|
|
229
229
|
break;
|
|
230
230
|
}
|
|
231
|
-
default: break;
|
|
232
231
|
}
|
|
233
232
|
}));
|
|
234
233
|
}
|
|
@@ -593,7 +592,7 @@ SheetsThreadCommentResourceController = __decorate([
|
|
|
593
592
|
//#endregion
|
|
594
593
|
//#region package.json
|
|
595
594
|
var name = "@univerjs/sheets-thread-comment";
|
|
596
|
-
var version = "1.0.0
|
|
595
|
+
var version = "1.0.0";
|
|
597
596
|
|
|
598
597
|
//#endregion
|
|
599
598
|
//#region src/config/config.ts
|
package/lib/es/facade.js
CHANGED
|
@@ -7,7 +7,7 @@ import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, Reso
|
|
|
7
7
|
import { deserializeRangeWithSheet } from "@univerjs/engine-formula";
|
|
8
8
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
9
9
|
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
11
11
|
function _typeof(o) {
|
|
12
12
|
"@babel/helpers - typeof";
|
|
13
13
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -18,7 +18,7 @@ function _typeof(o) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.
|
|
21
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
22
22
|
function toPrimitive(t, r) {
|
|
23
23
|
if ("object" != _typeof(t) || !t) return t;
|
|
24
24
|
var e = t[Symbol.toPrimitive];
|
|
@@ -31,14 +31,14 @@ function toPrimitive(t, r) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
35
35
|
function toPropertyKey(t) {
|
|
36
36
|
var i = toPrimitive(t, "string");
|
|
37
37
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
42
42
|
function _defineProperty(e, r, t) {
|
|
43
43
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
44
44
|
value: t,
|
|
@@ -49,7 +49,7 @@ function _defineProperty(e, r, t) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
53
53
|
function __decorateParam(paramIndex, decorator) {
|
|
54
54
|
return function(target, key) {
|
|
55
55
|
decorator(target, key, paramIndex);
|
|
@@ -57,7 +57,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
61
61
|
function __decorate(decorators, target, key, desc) {
|
|
62
62
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
63
63
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -75,7 +75,7 @@ var _FThreadComment;
|
|
|
75
75
|
var FTheadCommentItem = class FTheadCommentItem {
|
|
76
76
|
/**
|
|
77
77
|
* Create a new FTheadCommentItem
|
|
78
|
-
* @param {IThreadComment|undefined} comment The comment
|
|
78
|
+
* @param {IThreadComment|undefined} [comment] The comment
|
|
79
79
|
* @returns {FTheadCommentItem} A new instance of FTheadCommentItem
|
|
80
80
|
* @example
|
|
81
81
|
* ```ts
|
|
@@ -346,7 +346,8 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
346
346
|
}
|
|
347
347
|
_getRef() {
|
|
348
348
|
var _this$_parent;
|
|
349
|
-
|
|
349
|
+
const ref = ((_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.ref) || this._thread.ref;
|
|
350
|
+
return deserializeRangeWithSheet(ref).range;
|
|
350
351
|
}
|
|
351
352
|
/**
|
|
352
353
|
* Whether the comment is a root comment
|
|
@@ -385,7 +386,7 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
385
386
|
}
|
|
386
387
|
/**
|
|
387
388
|
* Get the replies of the comment
|
|
388
|
-
* @returns {FThreadComment[]}
|
|
389
|
+
* @returns {FThreadComment[] | undefined} The loaded replies, or `undefined` when the thread or its replies are unavailable.
|
|
389
390
|
* @example
|
|
390
391
|
* ```ts
|
|
391
392
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -517,7 +518,7 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
517
518
|
}
|
|
518
519
|
/**
|
|
519
520
|
* Resolve the comment
|
|
520
|
-
* @param {boolean} resolved Whether the comment is resolved
|
|
521
|
+
* @param {boolean} [resolved] Whether the comment is resolved
|
|
521
522
|
* @returns {Promise<boolean>} Set the comment to resolved or not operation result
|
|
522
523
|
* @example
|
|
523
524
|
* ```ts
|
|
@@ -686,6 +687,7 @@ var FRangeSheetsThreadCommentMixin = class extends FRange {
|
|
|
686
687
|
id: firstNonEmpty(options.id, commentData === null || commentData === void 0 ? void 0 : commentData.id),
|
|
687
688
|
ref: refStr,
|
|
688
689
|
personId: firstNonEmpty(options.personId, commentData === null || commentData === void 0 ? void 0 : commentData.personId, currentUser.userID),
|
|
690
|
+
authorName: options.authorName ?? (commentData === null || commentData === void 0 ? void 0 : commentData.authorName),
|
|
689
691
|
parentId: currentComment === null || currentComment === void 0 ? void 0 : currentComment.id,
|
|
690
692
|
unitId,
|
|
691
693
|
subUnitId: sheetId,
|
package/lib/es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptor
|
|
|
4
4
|
import { AddCommentMutation, DeleteCommentMutation, IThreadCommentDataSourceService, TC_PLUGIN_NAME, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentRefMutation, createThreadCommentResourceHook, deserializeThreadCommentAnchor } from "@univerjs/thread-comment";
|
|
5
5
|
import { Subject } from "rxjs";
|
|
6
6
|
|
|
7
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -227,7 +227,6 @@ let SheetsThreadCommentModel = class SheetsThreadCommentModel extends Disposable
|
|
|
227
227
|
});
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
-
default: break;
|
|
231
230
|
}
|
|
232
231
|
}));
|
|
233
232
|
}
|
|
@@ -592,7 +591,7 @@ SheetsThreadCommentResourceController = __decorate([
|
|
|
592
591
|
//#endregion
|
|
593
592
|
//#region package.json
|
|
594
593
|
var name = "@univerjs/sheets-thread-comment";
|
|
595
|
-
var version = "1.0.0
|
|
594
|
+
var version = "1.0.0";
|
|
596
595
|
|
|
597
596
|
//#endregion
|
|
598
597
|
//#region src/config/config.ts
|
package/lib/facade.js
CHANGED
|
@@ -7,7 +7,7 @@ import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, Reso
|
|
|
7
7
|
import { deserializeRangeWithSheet } from "@univerjs/engine-formula";
|
|
8
8
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
9
9
|
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
11
11
|
function _typeof(o) {
|
|
12
12
|
"@babel/helpers - typeof";
|
|
13
13
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -18,7 +18,7 @@ function _typeof(o) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.
|
|
21
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
22
22
|
function toPrimitive(t, r) {
|
|
23
23
|
if ("object" != _typeof(t) || !t) return t;
|
|
24
24
|
var e = t[Symbol.toPrimitive];
|
|
@@ -31,14 +31,14 @@ function toPrimitive(t, r) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
35
35
|
function toPropertyKey(t) {
|
|
36
36
|
var i = toPrimitive(t, "string");
|
|
37
37
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
42
42
|
function _defineProperty(e, r, t) {
|
|
43
43
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
44
44
|
value: t,
|
|
@@ -49,7 +49,7 @@ function _defineProperty(e, r, t) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
53
53
|
function __decorateParam(paramIndex, decorator) {
|
|
54
54
|
return function(target, key) {
|
|
55
55
|
decorator(target, key, paramIndex);
|
|
@@ -57,7 +57,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
61
61
|
function __decorate(decorators, target, key, desc) {
|
|
62
62
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
63
63
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -75,7 +75,7 @@ var _FThreadComment;
|
|
|
75
75
|
var FTheadCommentItem = class FTheadCommentItem {
|
|
76
76
|
/**
|
|
77
77
|
* Create a new FTheadCommentItem
|
|
78
|
-
* @param {IThreadComment|undefined} comment The comment
|
|
78
|
+
* @param {IThreadComment|undefined} [comment] The comment
|
|
79
79
|
* @returns {FTheadCommentItem} A new instance of FTheadCommentItem
|
|
80
80
|
* @example
|
|
81
81
|
* ```ts
|
|
@@ -346,7 +346,8 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
346
346
|
}
|
|
347
347
|
_getRef() {
|
|
348
348
|
var _this$_parent;
|
|
349
|
-
|
|
349
|
+
const ref = ((_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.ref) || this._thread.ref;
|
|
350
|
+
return deserializeRangeWithSheet(ref).range;
|
|
350
351
|
}
|
|
351
352
|
/**
|
|
352
353
|
* Whether the comment is a root comment
|
|
@@ -385,7 +386,7 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
385
386
|
}
|
|
386
387
|
/**
|
|
387
388
|
* Get the replies of the comment
|
|
388
|
-
* @returns {FThreadComment[]}
|
|
389
|
+
* @returns {FThreadComment[] | undefined} The loaded replies, or `undefined` when the thread or its replies are unavailable.
|
|
389
390
|
* @example
|
|
390
391
|
* ```ts
|
|
391
392
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -517,7 +518,7 @@ let FThreadComment = _FThreadComment = class FThreadComment {
|
|
|
517
518
|
}
|
|
518
519
|
/**
|
|
519
520
|
* Resolve the comment
|
|
520
|
-
* @param {boolean} resolved Whether the comment is resolved
|
|
521
|
+
* @param {boolean} [resolved] Whether the comment is resolved
|
|
521
522
|
* @returns {Promise<boolean>} Set the comment to resolved or not operation result
|
|
522
523
|
* @example
|
|
523
524
|
* ```ts
|
|
@@ -686,6 +687,7 @@ var FRangeSheetsThreadCommentMixin = class extends FRange {
|
|
|
686
687
|
id: firstNonEmpty(options.id, commentData === null || commentData === void 0 ? void 0 : commentData.id),
|
|
687
688
|
ref: refStr,
|
|
688
689
|
personId: firstNonEmpty(options.personId, commentData === null || commentData === void 0 ? void 0 : commentData.personId, currentUser.userID),
|
|
690
|
+
authorName: options.authorName ?? (commentData === null || commentData === void 0 ? void 0 : commentData.authorName),
|
|
689
691
|
parentId: currentComment === null || currentComment === void 0 ? void 0 : currentComment.id,
|
|
690
692
|
unitId,
|
|
691
693
|
subUnitId: sheetId,
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptor
|
|
|
4
4
|
import { AddCommentMutation, DeleteCommentMutation, IThreadCommentDataSourceService, TC_PLUGIN_NAME, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentRefMutation, createThreadCommentResourceHook, deserializeThreadCommentAnchor } from "@univerjs/thread-comment";
|
|
5
5
|
import { Subject } from "rxjs";
|
|
6
6
|
|
|
7
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -227,7 +227,6 @@ let SheetsThreadCommentModel = class SheetsThreadCommentModel extends Disposable
|
|
|
227
227
|
});
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
-
default: break;
|
|
231
230
|
}
|
|
232
231
|
}));
|
|
233
232
|
}
|
|
@@ -592,7 +591,7 @@ SheetsThreadCommentResourceController = __decorate([
|
|
|
592
591
|
//#endregion
|
|
593
592
|
//#region package.json
|
|
594
593
|
var name = "@univerjs/sheets-thread-comment";
|
|
595
|
-
var version = "1.0.0
|
|
594
|
+
var version = "1.0.0";
|
|
596
595
|
|
|
597
596
|
//#endregion
|
|
598
597
|
//#region src/config/config.ts
|
|
@@ -17,7 +17,7 @@ import * as UniverCore from '@univerjs/core';
|
|
|
17
17
|
import { FRange } from '@univerjs/sheets/facade';
|
|
18
18
|
import * as ThreadComment from '@univerjs/thread-comment';
|
|
19
19
|
import { FTheadCommentBuilder, FThreadComment } from './f-thread-comment';
|
|
20
|
-
export type ISheetCellCommentCreateOptions = Pick<ThreadComment.ICreateThreadCommentOptions, 'attachments' | 'dateTime' | 'id' | 'personId' | 'threadId'>;
|
|
20
|
+
export type ISheetCellCommentCreateOptions = Pick<ThreadComment.ICreateThreadCommentOptions, 'attachments' | 'authorName' | 'dateTime' | 'id' | 'personId' | 'threadId'>;
|
|
21
21
|
/**
|
|
22
22
|
* @ignore
|
|
23
23
|
*/
|
|
@@ -52,8 +52,8 @@ export interface IFRangeSheetsThreadCommentMixin {
|
|
|
52
52
|
/**
|
|
53
53
|
* Add a comment to the start cell in the current range.
|
|
54
54
|
* @param content The content of the comment.
|
|
55
|
-
* @param options Optional stable IDs, author, attachments, and creation time.
|
|
56
|
-
* @returns Whether the comment is added successfully.
|
|
55
|
+
* @param [options] Optional stable IDs, author, attachments, and creation time.
|
|
56
|
+
* @returns {Promise<boolean>} Whether the comment is added successfully.
|
|
57
57
|
* @throws {TypeError} If the content is empty.
|
|
58
58
|
* @example
|
|
59
59
|
* ```ts
|
|
@@ -80,7 +80,7 @@ export interface IFRangeSheetsThreadCommentMixin {
|
|
|
80
80
|
addCommentAsync(content: ThreadComment.ThreadCommentContent | FTheadCommentBuilder, options?: ISheetCellCommentCreateOptions): Promise<boolean>;
|
|
81
81
|
/**
|
|
82
82
|
* Clear the comment of the start cell in the current range.
|
|
83
|
-
* @returns Whether the comment is cleared successfully.
|
|
83
|
+
* @returns {Promise<boolean>} Whether the comment is cleared successfully.
|
|
84
84
|
* @example
|
|
85
85
|
* ```ts
|
|
86
86
|
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
@@ -91,7 +91,7 @@ export interface IFRangeSheetsThreadCommentMixin {
|
|
|
91
91
|
clearCommentAsync(): Promise<boolean>;
|
|
92
92
|
/**
|
|
93
93
|
* Clear all of the comments in the current range.
|
|
94
|
-
* @returns Whether the comments are cleared successfully.
|
|
94
|
+
* @returns {Promise<boolean>} Whether the comments are cleared successfully.
|
|
95
95
|
* @example
|
|
96
96
|
* ```ts
|
|
97
97
|
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
@@ -26,7 +26,7 @@ export declare class FTheadCommentItem {
|
|
|
26
26
|
protected _comment: IThreadComment;
|
|
27
27
|
/**
|
|
28
28
|
* Create a new FTheadCommentItem
|
|
29
|
-
* @param {IThreadComment|undefined} comment The comment
|
|
29
|
+
* @param {IThreadComment|undefined} [comment] The comment
|
|
30
30
|
* @returns {FTheadCommentItem} A new instance of FTheadCommentItem
|
|
31
31
|
* @example
|
|
32
32
|
* ```ts
|
|
@@ -283,7 +283,7 @@ export declare class FThreadComment {
|
|
|
283
283
|
getCommentData(): IBaseComment;
|
|
284
284
|
/**
|
|
285
285
|
* Get the replies of the comment
|
|
286
|
-
* @returns {FThreadComment[]}
|
|
286
|
+
* @returns {FThreadComment[] | undefined} The loaded replies, or `undefined` when the thread or its replies are unavailable.
|
|
287
287
|
* @example
|
|
288
288
|
* ```ts
|
|
289
289
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -377,7 +377,7 @@ export declare class FThreadComment {
|
|
|
377
377
|
updateAsync(content: IDocumentBody | RichTextValue): Promise<boolean>;
|
|
378
378
|
/**
|
|
379
379
|
* Resolve the comment
|
|
380
|
-
* @param {boolean} resolved Whether the comment is resolved
|
|
380
|
+
* @param {boolean} [resolved] Whether the comment is resolved
|
|
381
381
|
* @returns {Promise<boolean>} Set the comment to resolved or not operation result
|
|
382
382
|
* @example
|
|
383
383
|
* ```ts
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-thread-comment`,`@univerjs/sheets/facade`,`@univerjs/thread-comment`,`@univerjs/engine-formula`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadCommentFacade={},e.UniverCore,e.UniverSheetsThreadComment,e.UniverSheetsFacade,e.UniverThreadComment,e.UniverEngineFormula,e.UniverCoreFacade))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e));t=m(t),i=m(i);function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var x,S=class e{static create(t){return new e(t)}constructor(e){v(this,`_comment`,{id:(0,t.generateRandomId)(),ref:``,threadId:``,dT:``,personId:``,text:t.RichTextBuilder.newEmptyData().body,attachments:[],unitId:``,subUnitId:``}),e&&(this._comment=e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return t.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return C.create(t.Tools.deepClone(this._comment))}},C=class e extends S{static create(t){return new e(t)}setContent(e){return e instanceof t.RichTextValue?this._comment.text=e.getData().body:this._comment.text=e,this}setPersonId(e){return this._comment.personId=e,this}setDateTime(e){return this._comment.dT=(0,i.getDT)(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}};let w=x=class{constructor(e,t,n,r,i,a,o){this._thread=e,this._parent=t,this._injector=n,this._commandService=r,this._univerInstanceService=i,this._threadCommentModel=a,this._userManagerService=o}_getRef(){var e;return(0,a.deserializeRangeWithSheet)(((e=this._parent)==null?void 0:e.ref)||this._thread.ref).range}getIsRoot(){return!this._parent}getCommentData(){let{children:e,...t}=this._thread;return t}getReplies(){var e;let t=this._getRef(),n=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return n==null||(e=n.children)==null?void 0:e.map(e=>this._injector.createInstance(x,e))}getRange(){let e=this._univerInstanceService.getUnit(this._thread.unitId,t.UniverInstanceType.UNIVER_SHEET);if(!e)return null;let n=e.getSheetBySheetId(this._thread.subUnitId);if(!n)return null;let i=this._getRef();return this._injector.createInstance(r.FRange,e,n,i)}getRichText(){let e=this._thread.text;return t.RichTextValue.create({body:e,documentStyle:{},id:`d`})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?i.DeleteCommentTreeCommand.id:i.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}async updateAsync(e){let n=e instanceof t.RichTextValue?e.getData().body:e,r=(0,i.getDT)();return await this._commandService.executeCommand(i.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:n,updated:!0,updateT:r}})}resolveAsync(e){return this._commandService.executeCommand(i.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:e??!this._thread.resolved})}replyAsync(e){var n;let r=e.build();return this._commandService.executeCommand(i.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:(0,t.generateRandomId)(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((n=this._parent)==null?void 0:n.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||(0,i.getDT)(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}};w=x=b([y(2,(0,t.Inject)(t.Injector)),y(3,t.ICommandService),y(4,t.IUniverInstanceService),y(5,(0,t.Inject)(n.SheetsThreadCommentModel)),y(6,(0,t.Inject)(t.UserManagerService))],w);function T(...e){for(let t of e)if(t)return t;return t.generateRandomId()}var E=class extends r.FRange{_initialize(e){let r;Object.defineProperty(this,"_dependencies",{get:()=>r??={commandService:e.get(t.ICommandService),model:e.get(n.SheetsThreadCommentModel),userManagerService:e.get(t.UserManagerService)}})}_getCommentDataInRange(){let e=this._dependencies.model,n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),i=[];return t.Range.foreach(this._range,(t,a)=>{let o=e.getByLocation(n,r,t,a),s=o?e.getComment(n,r,o):null;s&&i.push(s)}),i}_getStartCellCommentData(){let e=this._dependencies.model,t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=e.getByLocation(t,n,this._range.startRow,this._range.startColumn);return r?e.getComment(t,n,r)??null:null}getComment(){let e=this._getStartCellCommentData();return e?this._injector.createInstance(w,e):null}getComments(){return this._getCommentDataInRange().map(e=>this._injector.createInstance(w,e))}addCommentAsync(e,n={}){let{commandService:r,userManagerService:a}=this._dependencies,o=this._getStartCellCommentData(),s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),l=`${t.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,u=a.getCurrentUser(),d=null,f;return e instanceof C?(d=e.build(),f=d.text):f=i.normalizeThreadCommentContent(e),r.executeCommand(i.AddCommentCommand.id,{unitId:s,subUnitId:c,comment:{text:f,dT:n.dateTime?i.getDT(n.dateTime):(d==null?void 0:d.dT)||i.getDT(),attachments:n.attachments??(d==null?void 0:d.attachments)??[],id:T(n.id,d==null?void 0:d.id),ref:l,personId:T(n.personId,d==null?void 0:d.personId,u.userID),parentId:o==null?void 0:o.id,unitId:s,subUnitId:c,threadId:T(o==null?void 0:o.threadId,n.threadId,d==null?void 0:d.threadId)}})}clearCommentAsync(){let{commandService:e}=this._dependencies,t=this._getStartCellCommentData(),n=this._workbook.getUnitId(),r=this._worksheet.getSheetId();return t?e.executeCommand(i.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,threadId:t.threadId,commentId:t.id}):Promise.resolve(!0)}async clearCommentsAsync(){let{commandService:e}=this._dependencies,t=this._workbook.getUnitId(),n=this._worksheet.getSheetId();return(await Promise.all(this._getCommentDataInRange().map(r=>e.executeCommand(i.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:n,threadId:r.threadId,commentId:r.id})))).every(Boolean)}};r.FRange.extend(E);var D=class extends r.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(i.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(w,e.root))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}};r.FWorkbook.extend(D);var O=class extends r.FWorksheet{getComments(){return this._injector.get(n.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(w,e))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onCommented(e){return this._injector.get(t.ICommandService).onCommandExecuted(t=>{if(t.id===i.AddCommentCommand.id){let n=t.params;e(n)}})}getCommentById(e){let t=this._injector.get(n.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(w,t)}};r.FWorksheet.extend(O);var k=class extends o.FEventName{get CommentAdded(){return`CommentAdded`}get BeforeCommentAdd(){return`BeforeCommentAdd`}get CommentUpdated(){return`CommentUpdated`}get BeforeCommentUpdate(){return`BeforeCommentUpdate`}get CommentDeleted(){return`CommentDeleted`}get BeforeCommentDelete(){return`BeforeCommentDelete`}get CommentResolved(){return`CommentResolved`}get BeforeCommentResolve(){return`BeforeCommentResolve`}};o.FEventName.extend(k);var A=class extends o.FUniver{_initialize(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded,()=>n.onCommandExecuted(e=>{var t,n;if(e.id!==i.AddCommentCommand.id)return;let r=e.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s}=a,{comment:c}=r,l=s.getCommentById(c.id);if(!l)return;let u={workbook:o,worksheet:s,row:((t=l.getRange())==null?void 0:t.getRow())??0,col:((n=l.getRange())==null?void 0:n.getColumn())??0,comment:l};this.fireEvent(this.Event.CommentAdded,u)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated,()=>n.onCommandExecuted(e=>{var t,n;if(e.id!==i.UpdateCommentCommand.id)return;let r=e.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s}=a,{payload:c}=r,l=s.getCommentById(c.commentId);if(!l)return;let u={workbook:o,worksheet:s,row:((t=l.getRange())==null?void 0:t.getRow())??0,col:((n=l.getRange())==null?void 0:n.getColumn())??0,comment:l};this.fireEvent(this.Event.CommentUpdated,u)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let t=e.params,n=this.getSheetCommandTarget(t);if(!n)return;let{workbook:r,worksheet:a}=n,{commentId:o}=t,s={workbook:r,worksheet:a,commentId:o};this.fireEvent(this.Event.CommentDeleted,s)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved,()=>n.onCommandExecuted(e=>{var t,n;if(e.id!==i.ResolveCommentCommand.id)return;let r=e.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s}=a,{commentId:c,resolved:l}=r,u=s.getCommentById(c);if(!u)return;let d={workbook:o,worksheet:s,row:((t=u.getRange())==null?void 0:t.getRow())??0,col:((n=u.getRange())==null?void 0:n.getColumn())??0,comment:u,resolved:l};this.fireEvent(this.Event.CommentResolved,d)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==i.AddCommentCommand.id)return;let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:o,worksheet:s}=r,{comment:c}=n,{range:l}=(0,a.deserializeRangeWithSheet)(c.ref),u={workbook:o,worksheet:s,row:l.startRow,col:l.startColumn,comment:S.create(c)};if(this.fireEvent(this.Event.BeforeCommentAdd,u),u.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>n.beforeCommandExecuted(e=>{var n,r;if(e.id!==i.UpdateCommentCommand.id)return;let a=e.params,o=this.getSheetCommandTarget(a);if(!o)return;let{workbook:s,worksheet:c}=o,{payload:l}=a,u=c.getCommentById(l.commentId);if(!u)return;let d={workbook:s,worksheet:c,row:((n=u.getRange())==null?void 0:n.getRow())??0,col:((r=u.getRange())==null?void 0:r.getColumn())??0,comment:u,newContent:t.RichTextValue.createByBody(l.text)};if(this.fireEvent(this.Event.BeforeCommentUpdate,d),d.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete,()=>n.beforeCommandExecuted(e=>{var n,r;if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let a=e.params,o=this.getSheetCommandTarget(a);if(!o)return;let{workbook:s,worksheet:c}=o,{commentId:l}=a,u=c.getCommentById(l);if(!u)return;let d={workbook:s,worksheet:c,row:((n=u.getRange())==null?void 0:n.getRow())??0,col:((r=u.getRange())==null?void 0:r.getColumn())??0,comment:u};if(this.fireEvent(this.Event.BeforeCommentDelete,d),d.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve,()=>n.beforeCommandExecuted(e=>{if(e.id!==i.ResolveCommentCommand.id)return;let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:a,worksheet:o}=r,{commentId:s,resolved:c}=n,l=o.getCommentById(s);if(!l)return;let u={workbook:a,worksheet:o,row:l.getRange().getRow()??0,col:l.getRange().getColumn()??0,comment:l,resolved:c};if(this.fireEvent(this.Event.BeforeCommentResolve,u),u.cancel)throw new t.CanceledError})))}newTheadComment(e){return new C(e)}};o.FUniver.extend(A),Object.defineProperty(e,"FThreadComment",{enumerable:!0,get:function(){return w}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-thread-comment`,`@univerjs/sheets/facade`,`@univerjs/thread-comment`,`@univerjs/engine-formula`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadCommentFacade={},e.UniverCore,e.UniverSheetsThreadComment,e.UniverSheetsFacade,e.UniverThreadComment,e.UniverEngineFormula,e.UniverCoreFacade))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule||!f.call(e,`default`)?c(n,`default`,{value:e,enumerable:!0}):n,e));t=m(t),i=m(i);function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var x,S=class e{static create(t){return new e(t)}constructor(e){v(this,`_comment`,{id:(0,t.generateRandomId)(),ref:``,threadId:``,dT:``,personId:``,text:t.RichTextBuilder.newEmptyData().body,attachments:[],unitId:``,subUnitId:``}),e&&(this._comment=e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return t.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return C.create(t.Tools.deepClone(this._comment))}},C=class e extends S{static create(t){return new e(t)}setContent(e){return e instanceof t.RichTextValue?this._comment.text=e.getData().body:this._comment.text=e,this}setPersonId(e){return this._comment.personId=e,this}setDateTime(e){return this._comment.dT=(0,i.getDT)(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}};let w=x=class{constructor(e,t,n,r,i,a,o){this._thread=e,this._parent=t,this._injector=n,this._commandService=r,this._univerInstanceService=i,this._threadCommentModel=a,this._userManagerService=o}_getRef(){var e;let t=((e=this._parent)==null?void 0:e.ref)||this._thread.ref;return(0,a.deserializeRangeWithSheet)(t).range}getIsRoot(){return!this._parent}getCommentData(){let{children:e,...t}=this._thread;return t}getReplies(){var e;let t=this._getRef(),n=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return n==null||(e=n.children)==null?void 0:e.map(e=>this._injector.createInstance(x,e))}getRange(){let e=this._univerInstanceService.getUnit(this._thread.unitId,t.UniverInstanceType.UNIVER_SHEET);if(!e)return null;let n=e.getSheetBySheetId(this._thread.subUnitId);if(!n)return null;let i=this._getRef();return this._injector.createInstance(r.FRange,e,n,i)}getRichText(){let e=this._thread.text;return t.RichTextValue.create({body:e,documentStyle:{},id:`d`})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?i.DeleteCommentTreeCommand.id:i.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}async updateAsync(e){let n=e instanceof t.RichTextValue?e.getData().body:e,r=(0,i.getDT)();return await this._commandService.executeCommand(i.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:n,updated:!0,updateT:r}})}resolveAsync(e){return this._commandService.executeCommand(i.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:e??!this._thread.resolved})}replyAsync(e){var n;let r=e.build();return this._commandService.executeCommand(i.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:(0,t.generateRandomId)(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((n=this._parent)==null?void 0:n.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||(0,i.getDT)(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}};w=x=b([y(2,(0,t.Inject)(t.Injector)),y(3,t.ICommandService),y(4,t.IUniverInstanceService),y(5,(0,t.Inject)(n.SheetsThreadCommentModel)),y(6,(0,t.Inject)(t.UserManagerService))],w);function T(...e){for(let t of e)if(t)return t;return t.generateRandomId()}var E=class extends r.FRange{_initialize(e){let r;Object.defineProperty(this,"_dependencies",{get:()=>r??={commandService:e.get(t.ICommandService),model:e.get(n.SheetsThreadCommentModel),userManagerService:e.get(t.UserManagerService)}})}_getCommentDataInRange(){let e=this._dependencies.model,n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),i=[];return t.Range.foreach(this._range,(t,a)=>{let o=e.getByLocation(n,r,t,a),s=o?e.getComment(n,r,o):null;s&&i.push(s)}),i}_getStartCellCommentData(){let e=this._dependencies.model,t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=e.getByLocation(t,n,this._range.startRow,this._range.startColumn);return r?e.getComment(t,n,r)??null:null}getComment(){let e=this._getStartCellCommentData();return e?this._injector.createInstance(w,e):null}getComments(){return this._getCommentDataInRange().map(e=>this._injector.createInstance(w,e))}addCommentAsync(e,n={}){let{commandService:r,userManagerService:a}=this._dependencies,o=this._getStartCellCommentData(),s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),l=`${t.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,u=a.getCurrentUser(),d=null,f;return e instanceof C?(d=e.build(),f=d.text):f=i.normalizeThreadCommentContent(e),r.executeCommand(i.AddCommentCommand.id,{unitId:s,subUnitId:c,comment:{text:f,dT:n.dateTime?i.getDT(n.dateTime):(d==null?void 0:d.dT)||i.getDT(),attachments:n.attachments??(d==null?void 0:d.attachments)??[],id:T(n.id,d==null?void 0:d.id),ref:l,personId:T(n.personId,d==null?void 0:d.personId,u.userID),authorName:n.authorName??(d==null?void 0:d.authorName),parentId:o==null?void 0:o.id,unitId:s,subUnitId:c,threadId:T(o==null?void 0:o.threadId,n.threadId,d==null?void 0:d.threadId)}})}clearCommentAsync(){let{commandService:e}=this._dependencies,t=this._getStartCellCommentData(),n=this._workbook.getUnitId(),r=this._worksheet.getSheetId();return t?e.executeCommand(i.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,threadId:t.threadId,commentId:t.id}):Promise.resolve(!0)}async clearCommentsAsync(){let{commandService:e}=this._dependencies,t=this._workbook.getUnitId(),n=this._worksheet.getSheetId();return(await Promise.all(this._getCommentDataInRange().map(r=>e.executeCommand(i.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:n,threadId:r.threadId,commentId:r.id})))).every(Boolean)}};r.FRange.extend(E);var D=class extends r.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(i.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(w,e.root))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}};r.FWorkbook.extend(D);var O=class extends r.FWorksheet{getComments(){return this._injector.get(n.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(w,e))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onCommented(e){return this._injector.get(t.ICommandService).onCommandExecuted(t=>{if(t.id===i.AddCommentCommand.id){let n=t.params;e(n)}})}getCommentById(e){let t=this._injector.get(n.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(w,t)}};r.FWorksheet.extend(O);var k=class extends o.FEventName{get CommentAdded(){return`CommentAdded`}get BeforeCommentAdd(){return`BeforeCommentAdd`}get CommentUpdated(){return`CommentUpdated`}get BeforeCommentUpdate(){return`BeforeCommentUpdate`}get CommentDeleted(){return`CommentDeleted`}get BeforeCommentDelete(){return`BeforeCommentDelete`}get CommentResolved(){return`CommentResolved`}get BeforeCommentResolve(){return`BeforeCommentResolve`}};o.FEventName.extend(k);var A=class extends o.FUniver{_initialize(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded,()=>n.onCommandExecuted(e=>{var t,n;if(e.id!==i.AddCommentCommand.id)return;let r=e.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s}=a,{comment:c}=r,l=s.getCommentById(c.id);if(!l)return;let u={workbook:o,worksheet:s,row:((t=l.getRange())==null?void 0:t.getRow())??0,col:((n=l.getRange())==null?void 0:n.getColumn())??0,comment:l};this.fireEvent(this.Event.CommentAdded,u)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated,()=>n.onCommandExecuted(e=>{var t,n;if(e.id!==i.UpdateCommentCommand.id)return;let r=e.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s}=a,{payload:c}=r,l=s.getCommentById(c.commentId);if(!l)return;let u={workbook:o,worksheet:s,row:((t=l.getRange())==null?void 0:t.getRow())??0,col:((n=l.getRange())==null?void 0:n.getColumn())??0,comment:l};this.fireEvent(this.Event.CommentUpdated,u)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let t=e.params,n=this.getSheetCommandTarget(t);if(!n)return;let{workbook:r,worksheet:a}=n,{commentId:o}=t,s={workbook:r,worksheet:a,commentId:o};this.fireEvent(this.Event.CommentDeleted,s)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved,()=>n.onCommandExecuted(e=>{var t,n;if(e.id!==i.ResolveCommentCommand.id)return;let r=e.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s}=a,{commentId:c,resolved:l}=r,u=s.getCommentById(c);if(!u)return;let d={workbook:o,worksheet:s,row:((t=u.getRange())==null?void 0:t.getRow())??0,col:((n=u.getRange())==null?void 0:n.getColumn())??0,comment:u,resolved:l};this.fireEvent(this.Event.CommentResolved,d)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==i.AddCommentCommand.id)return;let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:o,worksheet:s}=r,{comment:c}=n,{range:l}=(0,a.deserializeRangeWithSheet)(c.ref),u={workbook:o,worksheet:s,row:l.startRow,col:l.startColumn,comment:S.create(c)};if(this.fireEvent(this.Event.BeforeCommentAdd,u),u.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>n.beforeCommandExecuted(e=>{var n,r;if(e.id!==i.UpdateCommentCommand.id)return;let a=e.params,o=this.getSheetCommandTarget(a);if(!o)return;let{workbook:s,worksheet:c}=o,{payload:l}=a,u=c.getCommentById(l.commentId);if(!u)return;let d={workbook:s,worksheet:c,row:((n=u.getRange())==null?void 0:n.getRow())??0,col:((r=u.getRange())==null?void 0:r.getColumn())??0,comment:u,newContent:t.RichTextValue.createByBody(l.text)};if(this.fireEvent(this.Event.BeforeCommentUpdate,d),d.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete,()=>n.beforeCommandExecuted(e=>{var n,r;if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let a=e.params,o=this.getSheetCommandTarget(a);if(!o)return;let{workbook:s,worksheet:c}=o,{commentId:l}=a,u=c.getCommentById(l);if(!u)return;let d={workbook:s,worksheet:c,row:((n=u.getRange())==null?void 0:n.getRow())??0,col:((r=u.getRange())==null?void 0:r.getColumn())??0,comment:u};if(this.fireEvent(this.Event.BeforeCommentDelete,d),d.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve,()=>n.beforeCommandExecuted(e=>{if(e.id!==i.ResolveCommentCommand.id)return;let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:a,worksheet:o}=r,{commentId:s,resolved:c}=n,l=o.getCommentById(s);if(!l)return;let u={workbook:a,worksheet:o,row:l.getRange().getRow()??0,col:l.getRange().getColumn()??0,comment:l,resolved:c};if(this.fireEvent(this.Event.BeforeCommentResolve,u),u.cancel)throw new t.CanceledError})))}newTheadComment(e){return new C(e)}};o.FUniver.extend(A),Object.defineProperty(e,"FThreadComment",{enumerable:!0,get:function(){return w}})});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(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`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadComment={},e.UniverCore,e.UniverEngineFormula,e.UniverSheets,e.UniverThreadComment,e.rxjs))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let f=class extends t.Disposable{constructor(e,t){super(),this._threadCommentModel=e,this._univerInstanceService=t,l(this,`_matrixMap`,new Map),l(this,`_locationMap`,new Map),l(this,`_commentUpdate$`,new a.Subject),l(this,`commentUpdate$`,this._commentUpdate$.asObservable()),this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let r=this._matrixMap.get(e);r||(r=new Map,this._matrixMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_ensureCommentLocationMap(e,t){let n=this._locationMap.get(e);n||(n=new Map,this._locationMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_addCommentToMatrix(e,t,n,r){let i=e.getValue(t,n)??new Set;i.add(r),e.setValue(t,n,i)}_deleteCommentFromMatrix(e,t,n,r){if(t>=0&&n>=0){let i=e.getValue(t,n);i&&i.has(r)&&(i.delete(r),i.size===0&&e.realDeleteValue(t,n))}}_ensure(e,t){return{matrix:this._ensureCommentMatrix(e,t),locationMap:this._ensureCommentLocationMap(e,t)}}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:n,root:r}=e;this._addComment(t,n,r)}}_addComment(e,t,r){if((0,i.deserializeThreadCommentAnchor)(r.ref))return;let a=(0,n.singleReferenceToGrid)(r.ref),o=r.parentId,{row:s,column:c}=a,l=r.id,{matrix:u,locationMap:d}=this._ensure(e,t);!o&&s>=0&&c>=0&&(this._addCommentToMatrix(u,s,c,l),d.set(l,{row:s,column:c})),o||this._commentUpdate$.next({unitId:e,subUnitId:t,payload:r,type:`add`,isRoot:!o,...a})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:r,subUnitId:a}=e;try{if(this._univerInstanceService.getUnitType(r)!==t.UniverInstanceType.UNIVER_SHEET)return}catch{}let{matrix:o,locationMap:s}=this._ensure(r,a);switch(e.type){case`add`:this._addComment(e.unitId,e.subUnitId,e.payload);break;case`delete`:{let{isRoot:t,comment:r}=e.payload;if((0,i.deserializeThreadCommentAnchor)(r.ref))return;if(t){let t=(0,n.singleReferenceToGrid)(r.ref),{row:i,column:a}=t;this._deleteCommentFromMatrix(o,i,a,r.id),this._commentUpdate$.next({...e,...t})}break}case`update`:{let{commentId:t}=e.payload,o=this._threadCommentModel.getComment(r,a,t);if(!o||(0,i.deserializeThreadCommentAnchor)(o.ref))return;let s=(0,n.singleReferenceToGrid)(o.ref);this._commentUpdate$.next({...e,...s});break}case`updateRef`:{if((0,i.deserializeThreadCommentAnchor)(e.payload.ref))return;let t=(0,n.singleReferenceToGrid)(e.payload.ref),{commentId:r}=e.payload,a=s.get(r);if(!a)return;let{row:c,column:l}=a;this._deleteCommentFromMatrix(o,c,l,r),s.delete(r),t.row>=0&&t.column>=0&&(this._addCommentToMatrix(o,t.row,t.column,r),s.set(r,{row:t.row,column:t.column})),this._commentUpdate$.next({...e,...t});break}case`resolve`:{let{unitId:t,subUnitId:n,payload:r}=e,{locationMap:i}=this._ensure(t,n),a=i.get(r.commentId);a&&this._commentUpdate$.next({...e,...a});break}default:break}}))}getByLocation(e,t,n,r){var i;let a=this.getAllByLocation(e,t,n,r).filter(e=>!e.resolved);return(i=a[a.length-1])==null?void 0:i.id}getAllByLocation(e,t,n,r){let i=this._ensureCommentMatrix(e,t).getValue(n,r);if(!i)return[];let a=[];for(let n of i){let r=this.getComment(e,t,n);r&&a.push(r)}return a}getComment(e,t,n){return this._threadCommentModel.getComment(e,t,n)}getCommentWithChildren(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return;let a=this.getComment(e,t,i);if(a)return this._threadCommentModel.getThread(e,t,a.threadId)}showCommentMarker(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return!1;let a=this.getComment(e,t,i);return!!(a&&!a.resolved)}getSubUnitAll(e,t){return this._threadCommentModel.getUnit(e).filter(e=>e.subUnitId===t).map(e=>e.root)}};f=d([u(0,(0,t.Inject)(i.ThreadCommentModel)),u(1,t.IUniverInstanceService)],f);let p=class extends t.Disposable{constructor(e,t,r,a,o){super(),this._refRangeService=e,this._sheetsThreadCommentModel=t,this._threadCommentModel=r,this._selectionManagerService=a,this._commandService=o,l(this,`_disposableMap`,new Map),l(this,`_watcherMap`,new Map),l(this,`_handleRangeChange`,(e,t,r,a,o)=>{let s=r.id,c={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};return a?{redos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(a),commentId:s},silent:o}}],undos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(c),commentId:s},silent:o}}]}:{redos:[{id:i.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:s}}],undos:[{id:i.AddCommentMutation.id,params:{unitId:e,subUnitId:t,comment:r,sync:!0}}]}}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}-${t}-${n}`}_register(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(this._getIdWithUnitId(e,t,i),this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,n,s,!1)},e,t))}_watch(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watcherMap.set(this._getIdWithUnitId(e,n,i),this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._watcherMap.get(i))==null||r.dispose(),this._watcherMap.delete(i)}_unregister(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._disposableMap.get(i))==null||r.dispose(),this._disposableMap.delete(i)}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:r,root:a}=e;if((0,i.deserializeThreadCommentAnchor)(a.ref))continue;let o=(0,n.singleReferenceToGrid)(a.ref),s={...a,...o};this._register(t,r,s),this._watch(t,r,s)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n}=e;switch(e.type){case`add`:{if(e.payload.parentId)return;let t={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,t),this._watch(e.unitId,e.subUnitId,t);break}case`delete`:this._unregister(t,n,e.payload.commentId),this._unwatch(t,n,e.payload.commentId);break;case`updateRef`:{let r=this._sheetsThreadCommentModel.getComment(t,n,e.payload.commentId);if(!r)return;this._unregister(t,n,e.payload.commentId);let i={...r,row:e.row,column:e.column};e.silent||(this._unwatch(t,n,e.payload.commentId),this._watch(t,n,i)),this._register(e.unitId,e.subUnitId,i);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};p=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(i.ThreadCommentModel)),u(3,(0,t.Inject)(r.SheetsSelectionsService)),u(4,t.ICommandService)],p);let m=`SHEET_${i.TC_PLUGIN_NAME}`,h=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._threadCommentModel=r,this._threadCommentDataSourceService=i,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource((0,i.createThreadCommentResourceHook)(this._threadCommentModel,this._threadCommentDataSourceService,m,[t.UniverInstanceType.UNIVER_SHEET])))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,a=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!a||!o)return{redos:[],undos:[]};let s=this._threadCommentModel.ensureMap(a,o),c=Array.from(s.values()).filter(e=>!e.parentId),l=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=[],d=[];return c.forEach(({children:e,...t})=>{u.push({id:i.DeleteCommentMutation.id,params:{unitId:a,subUnitId:o,commentId:t.id}}),d.push({id:i.AddCommentMutation.id,params:{unitId:a,subUnitId:o,comment:{...t,children:l?e:void 0},sync:!l}})}),{redos:u,undos:d}}else if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:a}=e.params;if(!n||!r||!a)return{redos:[],undos:[]};let o=this._threadCommentModel.ensureMap(n,r),s=Array.from(o.values()).map(e=>({...e,subUnitId:a,id:(0,t.generateRandomId)(),threadId:(0,t.generateRandomId)()})).filter(e=>!e.parentId),c=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=[],u=[];return s.forEach(({children:e,...t})=>{l.push({id:i.AddCommentMutation.id,params:{unitId:n,subUnitId:a,comment:{...t,children:c?e:void 0},sync:!c}}),u.push({id:i.DeleteCommentMutation.id,params:{unitId:n,subUnitId:a,commentId:t.id}})}),{redos:l,undos:u}}return{redos:[],undos:[]}}}))}};h=d([u(0,t.IResourceManagerService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(r.SheetInterceptorService)),u(3,(0,t.Inject)(i.ThreadCommentModel)),u(4,i.IThreadCommentDataSourceService)],h);var g=`@univerjs/sheets-thread-comment`,_=`1.0.0-rc.0`;let v={},y=class extends t.Plugin{constructor(e=v,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{...a}=(0,t.merge)({},v,this._config);this._configService.setConfig(`sheets-thread-comment.config`,a)}onStarting(){[[f],[p],[h]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[p],[h]])}};l(y,`pluginName`,`SHEET_THREAD_COMMENT_BASE_PLUGIN`),l(y,`packageName`,g),l(y,`version`,_),l(y,`type`,t.UniverInstanceType.UNIVER_SHEET),y=d([(0,t.DependentOn)(i.UniverThreadCommentPlugin,r.UniverSheetsPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,(0,t.Inject)(t.ICommandService)),u(3,t.IConfigService)],y),e.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=m,Object.defineProperty(e,"SheetsThreadCommentModel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SheetsThreadCommentRefRangeController",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SheetsThreadCommentResourceController",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UniverSheetsThreadCommentPlugin",{enumerable:!0,get:function(){return y}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(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`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadComment={},e.UniverCore,e.UniverEngineFormula,e.UniverSheets,e.UniverThreadComment,e.rxjs))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let f=class extends t.Disposable{constructor(e,t){super(),this._threadCommentModel=e,this._univerInstanceService=t,l(this,`_matrixMap`,new Map),l(this,`_locationMap`,new Map),l(this,`_commentUpdate$`,new a.Subject),l(this,`commentUpdate$`,this._commentUpdate$.asObservable()),this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let r=this._matrixMap.get(e);r||(r=new Map,this._matrixMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_ensureCommentLocationMap(e,t){let n=this._locationMap.get(e);n||(n=new Map,this._locationMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_addCommentToMatrix(e,t,n,r){let i=e.getValue(t,n)??new Set;i.add(r),e.setValue(t,n,i)}_deleteCommentFromMatrix(e,t,n,r){if(t>=0&&n>=0){let i=e.getValue(t,n);i&&i.has(r)&&(i.delete(r),i.size===0&&e.realDeleteValue(t,n))}}_ensure(e,t){return{matrix:this._ensureCommentMatrix(e,t),locationMap:this._ensureCommentLocationMap(e,t)}}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:n,root:r}=e;this._addComment(t,n,r)}}_addComment(e,t,r){if((0,i.deserializeThreadCommentAnchor)(r.ref))return;let a=(0,n.singleReferenceToGrid)(r.ref),o=r.parentId,{row:s,column:c}=a,l=r.id,{matrix:u,locationMap:d}=this._ensure(e,t);!o&&s>=0&&c>=0&&(this._addCommentToMatrix(u,s,c,l),d.set(l,{row:s,column:c})),o||this._commentUpdate$.next({unitId:e,subUnitId:t,payload:r,type:`add`,isRoot:!o,...a})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:r,subUnitId:a}=e;try{if(this._univerInstanceService.getUnitType(r)!==t.UniverInstanceType.UNIVER_SHEET)return}catch{}let{matrix:o,locationMap:s}=this._ensure(r,a);switch(e.type){case`add`:this._addComment(e.unitId,e.subUnitId,e.payload);break;case`delete`:{let{isRoot:t,comment:r}=e.payload;if((0,i.deserializeThreadCommentAnchor)(r.ref))return;if(t){let t=(0,n.singleReferenceToGrid)(r.ref),{row:i,column:a}=t;this._deleteCommentFromMatrix(o,i,a,r.id),this._commentUpdate$.next({...e,...t})}break}case`update`:{let{commentId:t}=e.payload,o=this._threadCommentModel.getComment(r,a,t);if(!o||(0,i.deserializeThreadCommentAnchor)(o.ref))return;let s=(0,n.singleReferenceToGrid)(o.ref);this._commentUpdate$.next({...e,...s});break}case`updateRef`:{if((0,i.deserializeThreadCommentAnchor)(e.payload.ref))return;let t=(0,n.singleReferenceToGrid)(e.payload.ref),{commentId:r}=e.payload,a=s.get(r);if(!a)return;let{row:c,column:l}=a;this._deleteCommentFromMatrix(o,c,l,r),s.delete(r),t.row>=0&&t.column>=0&&(this._addCommentToMatrix(o,t.row,t.column,r),s.set(r,{row:t.row,column:t.column})),this._commentUpdate$.next({...e,...t});break}case`resolve`:{let{unitId:t,subUnitId:n,payload:r}=e,{locationMap:i}=this._ensure(t,n),a=i.get(r.commentId);a&&this._commentUpdate$.next({...e,...a});break}}}))}getByLocation(e,t,n,r){var i;let a=this.getAllByLocation(e,t,n,r).filter(e=>!e.resolved);return(i=a[a.length-1])==null?void 0:i.id}getAllByLocation(e,t,n,r){let i=this._ensureCommentMatrix(e,t).getValue(n,r);if(!i)return[];let a=[];for(let n of i){let r=this.getComment(e,t,n);r&&a.push(r)}return a}getComment(e,t,n){return this._threadCommentModel.getComment(e,t,n)}getCommentWithChildren(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return;let a=this.getComment(e,t,i);if(a)return this._threadCommentModel.getThread(e,t,a.threadId)}showCommentMarker(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return!1;let a=this.getComment(e,t,i);return!(!a||a.resolved)}getSubUnitAll(e,t){return this._threadCommentModel.getUnit(e).filter(e=>e.subUnitId===t).map(e=>e.root)}};f=d([u(0,(0,t.Inject)(i.ThreadCommentModel)),u(1,t.IUniverInstanceService)],f);let p=class extends t.Disposable{constructor(e,t,r,a,o){super(),this._refRangeService=e,this._sheetsThreadCommentModel=t,this._threadCommentModel=r,this._selectionManagerService=a,this._commandService=o,l(this,`_disposableMap`,new Map),l(this,`_watcherMap`,new Map),l(this,`_handleRangeChange`,(e,t,r,a,o)=>{let s=r.id,c={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};return a?{redos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(a),commentId:s},silent:o}}],undos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(c),commentId:s},silent:o}}]}:{redos:[{id:i.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:s}}],undos:[{id:i.AddCommentMutation.id,params:{unitId:e,subUnitId:t,comment:r,sync:!0}}]}}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}-${t}-${n}`}_register(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(this._getIdWithUnitId(e,t,i),this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,n,s,!1)},e,t))}_watch(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watcherMap.set(this._getIdWithUnitId(e,n,i),this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._watcherMap.get(i))==null||r.dispose(),this._watcherMap.delete(i)}_unregister(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._disposableMap.get(i))==null||r.dispose(),this._disposableMap.delete(i)}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:r,root:a}=e;if((0,i.deserializeThreadCommentAnchor)(a.ref))continue;let o=(0,n.singleReferenceToGrid)(a.ref),s={...a,...o};this._register(t,r,s),this._watch(t,r,s)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n}=e;switch(e.type){case`add`:{if(e.payload.parentId)return;let t={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,t),this._watch(e.unitId,e.subUnitId,t);break}case`delete`:this._unregister(t,n,e.payload.commentId),this._unwatch(t,n,e.payload.commentId);break;case`updateRef`:{let r=this._sheetsThreadCommentModel.getComment(t,n,e.payload.commentId);if(!r)return;this._unregister(t,n,e.payload.commentId);let i={...r,row:e.row,column:e.column};e.silent||(this._unwatch(t,n,e.payload.commentId),this._watch(t,n,i)),this._register(e.unitId,e.subUnitId,i);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};p=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(i.ThreadCommentModel)),u(3,(0,t.Inject)(r.SheetsSelectionsService)),u(4,t.ICommandService)],p);let m=`SHEET_${i.TC_PLUGIN_NAME}`,h=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._threadCommentModel=r,this._threadCommentDataSourceService=i,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){this.disposeWithMe(this._resourceManagerService.registerPluginResource((0,i.createThreadCommentResourceHook)(this._threadCommentModel,this._threadCommentDataSourceService,m,[t.UniverInstanceType.UNIVER_SHEET])))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,a=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!a||!o)return{redos:[],undos:[]};let s=this._threadCommentModel.ensureMap(a,o),c=Array.from(s.values()).filter(e=>!e.parentId),l=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=[],d=[];return c.forEach(({children:e,...t})=>{u.push({id:i.DeleteCommentMutation.id,params:{unitId:a,subUnitId:o,commentId:t.id}}),d.push({id:i.AddCommentMutation.id,params:{unitId:a,subUnitId:o,comment:{...t,children:l?e:void 0},sync:!l}})}),{redos:u,undos:d}}if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:a}=e.params;if(!n||!r||!a)return{redos:[],undos:[]};let o=this._threadCommentModel.ensureMap(n,r),s=Array.from(o.values()).map(e=>({...e,subUnitId:a,id:(0,t.generateRandomId)(),threadId:(0,t.generateRandomId)()})).filter(e=>!e.parentId),c=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=[],u=[];return s.forEach(({children:e,...t})=>{l.push({id:i.AddCommentMutation.id,params:{unitId:n,subUnitId:a,comment:{...t,children:c?e:void 0},sync:!c}}),u.push({id:i.DeleteCommentMutation.id,params:{unitId:n,subUnitId:a,commentId:t.id}})}),{redos:l,undos:u}}return{redos:[],undos:[]}}}))}};h=d([u(0,t.IResourceManagerService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(r.SheetInterceptorService)),u(3,(0,t.Inject)(i.ThreadCommentModel)),u(4,i.IThreadCommentDataSourceService)],h);var g=`@univerjs/sheets-thread-comment`,_=`1.0.0`;let v={},y=class extends t.Plugin{constructor(e=v,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{...a}=(0,t.merge)({},v,this._config);this._configService.setConfig(`sheets-thread-comment.config`,a)}onStarting(){[[f],[p],[h]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[p],[h]])}};l(y,`pluginName`,`SHEET_THREAD_COMMENT_BASE_PLUGIN`),l(y,`packageName`,g),l(y,`version`,_),l(y,`type`,t.UniverInstanceType.UNIVER_SHEET),y=d([(0,t.DependentOn)(i.UniverThreadCommentPlugin,r.UniverSheetsPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,(0,t.Inject)(t.ICommandService)),u(3,t.IConfigService)],y),e.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=m,Object.defineProperty(e,"SheetsThreadCommentModel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SheetsThreadCommentRefRangeController",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"SheetsThreadCommentResourceController",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UniverSheetsThreadCommentPlugin",{enumerable:!0,get:function(){return y}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Thread comment integration for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -62,16 +62,16 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/core": "1.0.0
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/thread-comment": "1.0.0
|
|
65
|
+
"@univerjs/core": "1.0.0",
|
|
66
|
+
"@univerjs/engine-formula": "1.0.0",
|
|
67
|
+
"@univerjs/sheets": "1.0.0",
|
|
68
|
+
"@univerjs/thread-comment": "1.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
+
"@univerjs-infra/shared": "1.0.0",
|
|
71
72
|
"rxjs": "^7.8.2",
|
|
72
73
|
"typescript": "^6.0.3",
|
|
73
|
-
"vitest": "^5.0.0"
|
|
74
|
-
"@univerjs-infra/shared": "1.0.0-rc.0"
|
|
74
|
+
"vitest": "^5.0.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"test": "vitest run",
|