@univerjs/sheets-thread-comment 1.5.1 → 1.6.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/README.md +1 -1
- package/lib/cjs/facade.js +6 -6
- package/lib/cjs/index.js +108 -9
- package/lib/cjs/locale/ar-SA.js +4 -0
- package/lib/cjs/locale/ca-ES.js +4 -0
- package/lib/cjs/locale/de-DE.js +4 -0
- package/lib/cjs/locale/en-US.js +19 -0
- package/lib/cjs/locale/es-ES.js +4 -0
- package/lib/cjs/locale/fa-IR.js +4 -0
- package/lib/cjs/locale/fr-FR.js +4 -0
- package/lib/cjs/locale/id-ID.js +4 -0
- package/lib/cjs/locale/it-IT.js +4 -0
- package/lib/cjs/locale/ja-JP.js +4 -0
- package/lib/cjs/locale/ko-KR.js +4 -0
- package/lib/cjs/locale/pl-PL.js +4 -0
- package/lib/cjs/locale/pt-BR.js +4 -0
- package/lib/cjs/locale/ru-RU.js +4 -0
- package/lib/cjs/locale/sk-SK.js +4 -0
- package/lib/cjs/locale/vi-VN.js +4 -0
- package/lib/cjs/locale/zh-CN.js +4 -0
- package/lib/cjs/locale/zh-HK.js +4 -0
- package/lib/cjs/locale/zh-TW.js +4 -0
- package/lib/es/facade.js +6 -6
- package/lib/es/index.js +111 -12
- package/lib/es/locale/ar-SA.js +4 -0
- package/lib/es/locale/ca-ES.js +4 -0
- package/lib/es/locale/de-DE.js +4 -0
- package/lib/es/locale/en-US.js +19 -0
- package/lib/es/locale/es-ES.js +4 -0
- package/lib/es/locale/fa-IR.js +4 -0
- package/lib/es/locale/fr-FR.js +4 -0
- package/lib/es/locale/id-ID.js +4 -0
- package/lib/es/locale/it-IT.js +4 -0
- package/lib/es/locale/ja-JP.js +4 -0
- package/lib/es/locale/ko-KR.js +4 -0
- package/lib/es/locale/pl-PL.js +4 -0
- package/lib/es/locale/pt-BR.js +4 -0
- package/lib/es/locale/ru-RU.js +4 -0
- package/lib/es/locale/sk-SK.js +4 -0
- package/lib/es/locale/vi-VN.js +4 -0
- package/lib/es/locale/zh-CN.js +4 -0
- package/lib/es/locale/zh-HK.js +4 -0
- package/lib/es/locale/zh-TW.js +4 -0
- package/lib/facade.js +6 -6
- package/lib/index.js +111 -12
- package/lib/locale/ar-SA.js +4 -0
- package/lib/locale/ca-ES.js +4 -0
- package/lib/locale/de-DE.js +4 -0
- package/lib/locale/en-US.js +19 -0
- package/lib/locale/es-ES.js +4 -0
- package/lib/locale/fa-IR.js +4 -0
- package/lib/locale/fr-FR.js +4 -0
- package/lib/locale/id-ID.js +4 -0
- package/lib/locale/it-IT.js +4 -0
- package/lib/locale/ja-JP.js +4 -0
- package/lib/locale/ko-KR.js +4 -0
- package/lib/locale/pl-PL.js +4 -0
- package/lib/locale/pt-BR.js +4 -0
- package/lib/locale/ru-RU.js +4 -0
- package/lib/locale/sk-SK.js +4 -0
- package/lib/locale/vi-VN.js +4 -0
- package/lib/locale/zh-CN.js +4 -0
- package/lib/locale/zh-HK.js +4 -0
- package/lib/locale/zh-TW.js +4 -0
- package/lib/types/controllers/sheets-thread-comment-permission.controller.d.ts +33 -0
- package/lib/types/locale/ar-SA.d.ts +18 -0
- package/lib/types/locale/ca-ES.d.ts +18 -0
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +23 -0
- package/lib/types/locale/es-ES.d.ts +18 -0
- package/lib/types/locale/fa-IR.d.ts +18 -0
- package/lib/types/locale/fr-FR.d.ts +18 -0
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/ja-JP.d.ts +18 -0
- package/lib/types/locale/ko-KR.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/ru-RU.d.ts +18 -0
- package/lib/types/locale/sk-SK.d.ts +18 -0
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/locale/vi-VN.d.ts +18 -0
- package/lib/types/locale/zh-CN.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/locale/zh-TW.d.ts +18 -0
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/sheets-thread-comment-authz.service.d.ts +31 -0
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -0
- package/lib/umd/locale/de-DE.js +1 -0
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/es-ES.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/fr-FR.js +1 -0
- package/lib/umd/locale/id-ID.js +1 -0
- package/lib/umd/locale/it-IT.js +1 -0
- package/lib/umd/locale/ja-JP.js +1 -0
- package/lib/umd/locale/ko-KR.js +1 -0
- package/lib/umd/locale/pl-PL.js +1 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/sk-SK.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-HK.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +13 -8
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
|
|
12
12
|
| --- | --- | :---: | :---: | :---: | :---: |
|
|
13
|
-
| `@univerjs/sheets-thread-comment` | `UniverSheetsThreadComment` | No |
|
|
13
|
+
| `@univerjs/sheets-thread-comment` | `UniverSheetsThreadComment` | No | Yes | Yes | No |
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
package/lib/cjs/facade.js
CHANGED
|
@@ -34,7 +34,7 @@ _univerjs_thread_comment = __toESM(_univerjs_thread_comment);
|
|
|
34
34
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
35
35
|
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
36
36
|
|
|
37
|
-
// \0@oxc-project+runtime@0.
|
|
37
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
38
38
|
function _typeof(o) {
|
|
39
39
|
"@babel/helpers - typeof";
|
|
40
40
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -44,7 +44,7 @@ function _typeof(o) {
|
|
|
44
44
|
}, _typeof(o);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// \0@oxc-project+runtime@0.
|
|
47
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
48
48
|
function toPrimitive(t, e) {
|
|
49
49
|
if ("object" != _typeof(t) || !t) return t;
|
|
50
50
|
var r;
|
|
@@ -56,13 +56,13 @@ function toPrimitive(t, e) {
|
|
|
56
56
|
return ("string" === e ? String : Number)(t);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// \0@oxc-project+runtime@0.
|
|
59
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
60
60
|
function toPropertyKey(t) {
|
|
61
61
|
var i = toPrimitive(t, "string");
|
|
62
62
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
// \0@oxc-project+runtime@0.
|
|
65
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
66
66
|
function _defineProperty(e, r, t) {
|
|
67
67
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
68
68
|
value: t,
|
|
@@ -72,14 +72,14 @@ function _defineProperty(e, r, t) {
|
|
|
72
72
|
}) : e[r] = t, e;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// \0@oxc-project+runtime@0.
|
|
75
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
76
76
|
function __decorateParam(paramIndex, decorator) {
|
|
77
77
|
return function(target, key) {
|
|
78
78
|
decorator(target, key, paramIndex);
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// \0@oxc-project+runtime@0.
|
|
82
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
83
83
|
function __decorate(decorators, target, key, desc) {
|
|
84
84
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
85
85
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
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
|
-
// \0@oxc-project+runtime@0.
|
|
8
|
+
// \0@oxc-project+runtime@0.158.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) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}, _typeof(o);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// \0@oxc-project+runtime@0.
|
|
18
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, e) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var r;
|
|
@@ -27,13 +27,13 @@ function toPrimitive(t, e) {
|
|
|
27
27
|
return ("string" === e ? String : Number)(t);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
// \0@oxc-project+runtime@0.
|
|
30
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
31
31
|
function toPropertyKey(t) {
|
|
32
32
|
var i = toPrimitive(t, "string");
|
|
33
33
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// \0@oxc-project+runtime@0.
|
|
36
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
37
37
|
function _defineProperty(e, r, t) {
|
|
38
38
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
39
39
|
value: t,
|
|
@@ -43,14 +43,14 @@ function _defineProperty(e, r, t) {
|
|
|
43
43
|
}) : e[r] = t, e;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// \0@oxc-project+runtime@0.
|
|
46
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
47
47
|
function __decorateParam(paramIndex, decorator) {
|
|
48
48
|
return function(target, key) {
|
|
49
49
|
decorator(target, key, paramIndex);
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// \0@oxc-project+runtime@0.
|
|
53
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
54
54
|
function __decorate(decorators, target, key, desc) {
|
|
55
55
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
56
56
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -582,7 +582,7 @@ SheetsThreadCommentResourceController = __decorate([
|
|
|
582
582
|
|
|
583
583
|
// package.json
|
|
584
584
|
var name = "@univerjs/sheets-thread-comment";
|
|
585
|
-
var version = "1.
|
|
585
|
+
var version = "1.6.0";
|
|
586
586
|
|
|
587
587
|
// src/config/config.ts
|
|
588
588
|
/**
|
|
@@ -604,6 +604,98 @@ const SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY = "sheets-thread-comment.config";
|
|
|
604
604
|
const configSymbol = Symbol(SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY);
|
|
605
605
|
const defaultPluginConfig = {};
|
|
606
606
|
|
|
607
|
+
// src/controllers/sheets-thread-comment-permission.controller.ts
|
|
608
|
+
let SheetsThreadCommentPermissionController = class SheetsThreadCommentPermissionController extends _univerjs_core.Disposable {
|
|
609
|
+
constructor(_localeService, _commandService, _sheetPermissionCheckController, _threadCommentModel, _authzService) {
|
|
610
|
+
super();
|
|
611
|
+
this._localeService = _localeService;
|
|
612
|
+
this._commandService = _commandService;
|
|
613
|
+
this._sheetPermissionCheckController = _sheetPermissionCheckController;
|
|
614
|
+
this._threadCommentModel = _threadCommentModel;
|
|
615
|
+
this._authzService = _authzService;
|
|
616
|
+
this._commandExecutedListener();
|
|
617
|
+
}
|
|
618
|
+
_commandExecutedListener() {
|
|
619
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
620
|
+
const { id } = command;
|
|
621
|
+
if (!command.params) return;
|
|
622
|
+
if (id === _univerjs_thread_comment.AddCommentCommand.id) {
|
|
623
|
+
const { unitId, subUnitId, comment } = command.params;
|
|
624
|
+
this._checkWrite(comment.parentId ? "reply" : "add", unitId, subUnitId, comment.ref, comment.personId);
|
|
625
|
+
} else if (id === _univerjs_thread_comment.UpdateCommentCommand.id) {
|
|
626
|
+
const { unitId, subUnitId, payload } = command.params;
|
|
627
|
+
const comment = this._threadCommentModel.getComment(unitId, subUnitId, payload.commentId);
|
|
628
|
+
if (comment) this._checkWrite("update", unitId, subUnitId, comment.ref, comment.personId);
|
|
629
|
+
} else if (id === _univerjs_thread_comment.ResolveCommentCommand.id || id === _univerjs_thread_comment.DeleteCommentCommand.id || id === _univerjs_thread_comment.DeleteCommentTreeCommand.id) {
|
|
630
|
+
var _this$_threadCommentM;
|
|
631
|
+
const { unitId, subUnitId, commentId } = command.params;
|
|
632
|
+
const action = id === _univerjs_thread_comment.ResolveCommentCommand.id ? "resolve" : "delete";
|
|
633
|
+
const comment = action === "delete" && id === _univerjs_thread_comment.DeleteCommentTreeCommand.id ? (_this$_threadCommentM = this._threadCommentModel.getCommentWithChildren(unitId, subUnitId, commentId)) === null || _this$_threadCommentM === void 0 ? void 0 : _this$_threadCommentM.root : this._threadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
634
|
+
if (comment) this._checkWrite(action, unitId, subUnitId, comment.ref, comment.personId);
|
|
635
|
+
}
|
|
636
|
+
}));
|
|
637
|
+
}
|
|
638
|
+
_checkWrite(action, unitId, subUnitId, ref, personId) {
|
|
639
|
+
if (this._authzService.canWrite(action, {
|
|
640
|
+
unitId,
|
|
641
|
+
subUnitId,
|
|
642
|
+
ref,
|
|
643
|
+
personId
|
|
644
|
+
})) return;
|
|
645
|
+
this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment.permission.commentErr"));
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
SheetsThreadCommentPermissionController = __decorate([
|
|
649
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
650
|
+
__decorateParam(1, _univerjs_core.ICommandService),
|
|
651
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController)),
|
|
652
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_thread_comment.ThreadCommentModel)),
|
|
653
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_thread_comment.IThreadCommentAuthzService))
|
|
654
|
+
], SheetsThreadCommentPermissionController);
|
|
655
|
+
|
|
656
|
+
// src/services/sheets-thread-comment-authz.service.ts
|
|
657
|
+
let SheetsThreadCommentAuthz = class SheetsThreadCommentAuthz extends _univerjs_core.Disposable {
|
|
658
|
+
constructor(_permissionCheckController, _authzService) {
|
|
659
|
+
super();
|
|
660
|
+
this._permissionCheckController = _permissionCheckController;
|
|
661
|
+
this._authzService = _authzService;
|
|
662
|
+
this.disposeWithMe(this._authzService.registerAuthz(_univerjs_core.UniverInstanceType.UNIVER_SHEET, this));
|
|
663
|
+
}
|
|
664
|
+
canRead(target) {
|
|
665
|
+
return this._checkPermission(target, false);
|
|
666
|
+
}
|
|
667
|
+
canWrite(_action, target) {
|
|
668
|
+
return this._checkPermission(target, true);
|
|
669
|
+
}
|
|
670
|
+
_checkPermission(target, write) {
|
|
671
|
+
const { unitId, subUnitId, ref } = target;
|
|
672
|
+
const permissionTypes = write ? {
|
|
673
|
+
workbookTypes: [_univerjs_sheets.WorkbookCommentPermission],
|
|
674
|
+
worksheetTypes: [_univerjs_sheets.WorksheetViewPermission]
|
|
675
|
+
} : {
|
|
676
|
+
workbookTypes: [_univerjs_sheets.WorkbookViewPermission],
|
|
677
|
+
worksheetTypes: [_univerjs_sheets.WorksheetViewPermission]
|
|
678
|
+
};
|
|
679
|
+
if (ref) {
|
|
680
|
+
const anchor = (0, _univerjs_thread_comment.deserializeThreadCommentAnchor)(ref);
|
|
681
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== _univerjs_thread_comment.ThreadCommentAnchorKind.SHEET_DRAWING) {
|
|
682
|
+
const { row, column } = (0, _univerjs_engine_formula.singleReferenceToGrid)(ref);
|
|
683
|
+
if (Number.isFinite(row) && Number.isFinite(column)) return this._permissionCheckController.permissionCheckWithRanges({
|
|
684
|
+
...permissionTypes,
|
|
685
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionViewPoint]
|
|
686
|
+
}, [{
|
|
687
|
+
startRow: row,
|
|
688
|
+
startColumn: column,
|
|
689
|
+
endRow: row,
|
|
690
|
+
endColumn: column
|
|
691
|
+
}], unitId, subUnitId);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return this._permissionCheckController.permissionCheckWithoutRange(permissionTypes, unitId, subUnitId);
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
SheetsThreadCommentAuthz = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_thread_comment.IThreadCommentAuthzService))], SheetsThreadCommentAuthz);
|
|
698
|
+
|
|
607
699
|
// src/plugin.ts
|
|
608
700
|
let UniverSheetsThreadCommentPlugin = class UniverSheetsThreadCommentPlugin extends _univerjs_core.Plugin {
|
|
609
701
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
@@ -619,11 +711,18 @@ let UniverSheetsThreadCommentPlugin = class UniverSheetsThreadCommentPlugin exte
|
|
|
619
711
|
[
|
|
620
712
|
[SheetsThreadCommentModel],
|
|
621
713
|
[SheetsThreadCommentRefRangeController],
|
|
622
|
-
[SheetsThreadCommentResourceController]
|
|
714
|
+
[SheetsThreadCommentResourceController],
|
|
715
|
+
[SheetsThreadCommentAuthz],
|
|
716
|
+
[SheetsThreadCommentPermissionController]
|
|
623
717
|
].forEach((dep) => {
|
|
624
718
|
this._injector.add(dep);
|
|
625
719
|
});
|
|
626
|
-
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
720
|
+
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
721
|
+
[SheetsThreadCommentRefRangeController],
|
|
722
|
+
[SheetsThreadCommentResourceController],
|
|
723
|
+
[SheetsThreadCommentAuthz],
|
|
724
|
+
[SheetsThreadCommentPermissionController]
|
|
725
|
+
]);
|
|
627
726
|
}
|
|
628
727
|
};
|
|
629
728
|
_defineProperty(UniverSheetsThreadCommentPlugin, "pluginName", SHEET_THREAD_COMMENT_BASE);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/locale/en-US.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
const locale = { "sheets-thread-comment": { permission: { commentErr: "You do not have permission to use comments." } } };
|
|
18
|
+
|
|
19
|
+
module.exports = locale;
|
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
|
-
// \0@oxc-project+runtime@0.
|
|
10
|
+
// \0@oxc-project+runtime@0.158.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) {
|
|
@@ -17,7 +17,7 @@ function _typeof(o) {
|
|
|
17
17
|
}, _typeof(o);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// \0@oxc-project+runtime@0.
|
|
20
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
21
21
|
function toPrimitive(t, e) {
|
|
22
22
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
23
|
var r;
|
|
@@ -29,13 +29,13 @@ function toPrimitive(t, e) {
|
|
|
29
29
|
return ("string" === e ? String : Number)(t);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// \0@oxc-project+runtime@0.
|
|
32
|
+
// \0@oxc-project+runtime@0.158.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
|
-
// \0@oxc-project+runtime@0.
|
|
38
|
+
// \0@oxc-project+runtime@0.158.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,
|
|
@@ -45,14 +45,14 @@ function _defineProperty(e, r, t) {
|
|
|
45
45
|
}) : e[r] = t, e;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// \0@oxc-project+runtime@0.
|
|
48
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
49
49
|
function __decorateParam(paramIndex, decorator) {
|
|
50
50
|
return function(target, key) {
|
|
51
51
|
decorator(target, key, paramIndex);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// \0@oxc-project+runtime@0.
|
|
55
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
56
56
|
function __decorate(decorators, target, key, desc) {
|
|
57
57
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
58
58
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
package/lib/es/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, ObjectMatrix, Plugin, UniverInstanceType, generateRandomId, merge, sequenceExecuteAsync, toDisposable, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUniverInstanceService, Inject, Injector, LocaleService, ObjectMatrix, Plugin, UniverInstanceType, generateRandomId, merge, sequenceExecuteAsync, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
2
|
import { serializeRange, singleReferenceToGrid } from "@univerjs/engine-formula";
|
|
3
|
-
import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
|
|
4
|
-
import { AddCommentMutation, DeleteCommentMutation, IThreadCommentDataSourceService, TC_PLUGIN_NAME, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentRefMutation, createThreadCommentResourceHook, deserializeThreadCommentAnchor } from "@univerjs/thread-comment";
|
|
3
|
+
import { CopySheetCommand, RangeProtectionPermissionViewPoint, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCommentPermission, WorkbookViewPermission, WorksheetViewPermission, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
|
|
4
|
+
import { AddCommentCommand, AddCommentMutation, DeleteCommentCommand, DeleteCommentMutation, DeleteCommentTreeCommand, IThreadCommentAuthzService, IThreadCommentDataSourceService, ResolveCommentCommand, TC_PLUGIN_NAME, ThreadCommentAnchorKind, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentCommand, UpdateCommentRefMutation, createThreadCommentResourceHook, deserializeThreadCommentAnchor } from "@univerjs/thread-comment";
|
|
5
5
|
import { Subject } from "rxjs";
|
|
6
6
|
|
|
7
|
-
// \0@oxc-project+runtime@0.
|
|
7
|
+
// \0@oxc-project+runtime@0.158.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) {
|
|
@@ -14,7 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// \0@oxc-project+runtime@0.
|
|
17
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
18
18
|
function toPrimitive(t, e) {
|
|
19
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
20
20
|
var r;
|
|
@@ -26,13 +26,13 @@ function toPrimitive(t, e) {
|
|
|
26
26
|
return ("string" === e ? String : Number)(t);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// \0@oxc-project+runtime@0.
|
|
29
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
30
30
|
function toPropertyKey(t) {
|
|
31
31
|
var i = toPrimitive(t, "string");
|
|
32
32
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// \0@oxc-project+runtime@0.
|
|
35
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
36
36
|
function _defineProperty(e, r, t) {
|
|
37
37
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
38
38
|
value: t,
|
|
@@ -42,14 +42,14 @@ function _defineProperty(e, r, t) {
|
|
|
42
42
|
}) : e[r] = t, e;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// \0@oxc-project+runtime@0.
|
|
45
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
46
46
|
function __decorateParam(paramIndex, decorator) {
|
|
47
47
|
return function(target, key) {
|
|
48
48
|
decorator(target, key, paramIndex);
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// \0@oxc-project+runtime@0.
|
|
52
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
53
53
|
function __decorate(decorators, target, key, desc) {
|
|
54
54
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
55
55
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -581,7 +581,7 @@ SheetsThreadCommentResourceController = __decorate([
|
|
|
581
581
|
|
|
582
582
|
// package.json
|
|
583
583
|
var name = "@univerjs/sheets-thread-comment";
|
|
584
|
-
var version = "1.
|
|
584
|
+
var version = "1.6.0";
|
|
585
585
|
|
|
586
586
|
// src/config/config.ts
|
|
587
587
|
/**
|
|
@@ -603,6 +603,98 @@ const SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY = "sheets-thread-comment.config";
|
|
|
603
603
|
const configSymbol = Symbol(SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY);
|
|
604
604
|
const defaultPluginConfig = {};
|
|
605
605
|
|
|
606
|
+
// src/controllers/sheets-thread-comment-permission.controller.ts
|
|
607
|
+
let SheetsThreadCommentPermissionController = class SheetsThreadCommentPermissionController extends Disposable {
|
|
608
|
+
constructor(_localeService, _commandService, _sheetPermissionCheckController, _threadCommentModel, _authzService) {
|
|
609
|
+
super();
|
|
610
|
+
this._localeService = _localeService;
|
|
611
|
+
this._commandService = _commandService;
|
|
612
|
+
this._sheetPermissionCheckController = _sheetPermissionCheckController;
|
|
613
|
+
this._threadCommentModel = _threadCommentModel;
|
|
614
|
+
this._authzService = _authzService;
|
|
615
|
+
this._commandExecutedListener();
|
|
616
|
+
}
|
|
617
|
+
_commandExecutedListener() {
|
|
618
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
619
|
+
const { id } = command;
|
|
620
|
+
if (!command.params) return;
|
|
621
|
+
if (id === AddCommentCommand.id) {
|
|
622
|
+
const { unitId, subUnitId, comment } = command.params;
|
|
623
|
+
this._checkWrite(comment.parentId ? "reply" : "add", unitId, subUnitId, comment.ref, comment.personId);
|
|
624
|
+
} else if (id === UpdateCommentCommand.id) {
|
|
625
|
+
const { unitId, subUnitId, payload } = command.params;
|
|
626
|
+
const comment = this._threadCommentModel.getComment(unitId, subUnitId, payload.commentId);
|
|
627
|
+
if (comment) this._checkWrite("update", unitId, subUnitId, comment.ref, comment.personId);
|
|
628
|
+
} else if (id === ResolveCommentCommand.id || id === DeleteCommentCommand.id || id === DeleteCommentTreeCommand.id) {
|
|
629
|
+
var _this$_threadCommentM;
|
|
630
|
+
const { unitId, subUnitId, commentId } = command.params;
|
|
631
|
+
const action = id === ResolveCommentCommand.id ? "resolve" : "delete";
|
|
632
|
+
const comment = action === "delete" && id === DeleteCommentTreeCommand.id ? (_this$_threadCommentM = this._threadCommentModel.getCommentWithChildren(unitId, subUnitId, commentId)) === null || _this$_threadCommentM === void 0 ? void 0 : _this$_threadCommentM.root : this._threadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
633
|
+
if (comment) this._checkWrite(action, unitId, subUnitId, comment.ref, comment.personId);
|
|
634
|
+
}
|
|
635
|
+
}));
|
|
636
|
+
}
|
|
637
|
+
_checkWrite(action, unitId, subUnitId, ref, personId) {
|
|
638
|
+
if (this._authzService.canWrite(action, {
|
|
639
|
+
unitId,
|
|
640
|
+
subUnitId,
|
|
641
|
+
ref,
|
|
642
|
+
personId
|
|
643
|
+
})) return;
|
|
644
|
+
this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment.permission.commentErr"));
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
SheetsThreadCommentPermissionController = __decorate([
|
|
648
|
+
__decorateParam(0, Inject(LocaleService)),
|
|
649
|
+
__decorateParam(1, ICommandService),
|
|
650
|
+
__decorateParam(2, Inject(SheetPermissionCheckController)),
|
|
651
|
+
__decorateParam(3, Inject(ThreadCommentModel)),
|
|
652
|
+
__decorateParam(4, Inject(IThreadCommentAuthzService))
|
|
653
|
+
], SheetsThreadCommentPermissionController);
|
|
654
|
+
|
|
655
|
+
// src/services/sheets-thread-comment-authz.service.ts
|
|
656
|
+
let SheetsThreadCommentAuthz = class SheetsThreadCommentAuthz extends Disposable {
|
|
657
|
+
constructor(_permissionCheckController, _authzService) {
|
|
658
|
+
super();
|
|
659
|
+
this._permissionCheckController = _permissionCheckController;
|
|
660
|
+
this._authzService = _authzService;
|
|
661
|
+
this.disposeWithMe(this._authzService.registerAuthz(UniverInstanceType.UNIVER_SHEET, this));
|
|
662
|
+
}
|
|
663
|
+
canRead(target) {
|
|
664
|
+
return this._checkPermission(target, false);
|
|
665
|
+
}
|
|
666
|
+
canWrite(_action, target) {
|
|
667
|
+
return this._checkPermission(target, true);
|
|
668
|
+
}
|
|
669
|
+
_checkPermission(target, write) {
|
|
670
|
+
const { unitId, subUnitId, ref } = target;
|
|
671
|
+
const permissionTypes = write ? {
|
|
672
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
673
|
+
worksheetTypes: [WorksheetViewPermission]
|
|
674
|
+
} : {
|
|
675
|
+
workbookTypes: [WorkbookViewPermission],
|
|
676
|
+
worksheetTypes: [WorksheetViewPermission]
|
|
677
|
+
};
|
|
678
|
+
if (ref) {
|
|
679
|
+
const anchor = deserializeThreadCommentAnchor(ref);
|
|
680
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== ThreadCommentAnchorKind.SHEET_DRAWING) {
|
|
681
|
+
const { row, column } = singleReferenceToGrid(ref);
|
|
682
|
+
if (Number.isFinite(row) && Number.isFinite(column)) return this._permissionCheckController.permissionCheckWithRanges({
|
|
683
|
+
...permissionTypes,
|
|
684
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
685
|
+
}, [{
|
|
686
|
+
startRow: row,
|
|
687
|
+
startColumn: column,
|
|
688
|
+
endRow: row,
|
|
689
|
+
endColumn: column
|
|
690
|
+
}], unitId, subUnitId);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return this._permissionCheckController.permissionCheckWithoutRange(permissionTypes, unitId, subUnitId);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
SheetsThreadCommentAuthz = __decorate([__decorateParam(0, Inject(SheetPermissionCheckController)), __decorateParam(1, Inject(IThreadCommentAuthzService))], SheetsThreadCommentAuthz);
|
|
697
|
+
|
|
606
698
|
// src/plugin.ts
|
|
607
699
|
let UniverSheetsThreadCommentPlugin = class UniverSheetsThreadCommentPlugin extends Plugin {
|
|
608
700
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
@@ -618,11 +710,18 @@ let UniverSheetsThreadCommentPlugin = class UniverSheetsThreadCommentPlugin exte
|
|
|
618
710
|
[
|
|
619
711
|
[SheetsThreadCommentModel],
|
|
620
712
|
[SheetsThreadCommentRefRangeController],
|
|
621
|
-
[SheetsThreadCommentResourceController]
|
|
713
|
+
[SheetsThreadCommentResourceController],
|
|
714
|
+
[SheetsThreadCommentAuthz],
|
|
715
|
+
[SheetsThreadCommentPermissionController]
|
|
622
716
|
].forEach((dep) => {
|
|
623
717
|
this._injector.add(dep);
|
|
624
718
|
});
|
|
625
|
-
touchDependencies(this._injector, [
|
|
719
|
+
touchDependencies(this._injector, [
|
|
720
|
+
[SheetsThreadCommentRefRangeController],
|
|
721
|
+
[SheetsThreadCommentResourceController],
|
|
722
|
+
[SheetsThreadCommentAuthz],
|
|
723
|
+
[SheetsThreadCommentPermissionController]
|
|
724
|
+
]);
|
|
626
725
|
}
|
|
627
726
|
};
|
|
628
727
|
_defineProperty(UniverSheetsThreadCommentPlugin, "pluginName", SHEET_THREAD_COMMENT_BASE);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/locale/en-US.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
const locale = { "sheets-thread-comment": { permission: { commentErr: "You do not have permission to use comments." } } };
|
|
18
|
+
|
|
19
|
+
export { locale as default };
|