@univerjs/sheets 1.0.4 → 1.2.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 +80 -40
- package/lib/cjs/index.js +322 -186
- package/lib/es/facade.js +76 -36
- package/lib/es/index.js +298 -164
- package/lib/facade.js +76 -36
- package/lib/index.js +298 -164
- package/lib/types/commands/commands/set-workbook-calculation-settings.command.d.ts +18 -0
- package/lib/types/commands/mutations/set-workbook-calculation-settings.mutation.d.ts +21 -0
- package/lib/types/config/config.d.ts +8 -0
- package/lib/types/controllers/auto-fill.controller.d.ts +3 -0
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +10 -4
- package/lib/types/facade/f-range.d.ts +2 -1
- package/lib/types/facade/f-workbook.d.ts +31 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/services/auto-fill/auto-fill.service.d.ts +3 -3
- package/lib/types/services/auto-fill/type.d.ts +8 -1
- package/lib/types/services/permission/workbook-permission/util.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -219,7 +219,7 @@ const RangeThemeInterceptorId = "sheet.interceptor.range-theme-id";
|
|
|
219
219
|
const IgnoreRangeThemeInterceptorKey = "sheet.interceptor.ignore-range-theme";
|
|
220
220
|
|
|
221
221
|
//#endregion
|
|
222
|
-
//#region \0@oxc-project+runtime@0.
|
|
222
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
223
223
|
function _typeof(o) {
|
|
224
224
|
"@babel/helpers - typeof";
|
|
225
225
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -230,7 +230,7 @@ function _typeof(o) {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
//#endregion
|
|
233
|
-
//#region \0@oxc-project+runtime@0.
|
|
233
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
234
234
|
function toPrimitive(t, r) {
|
|
235
235
|
if ("object" != _typeof(t) || !t) return t;
|
|
236
236
|
var e = t[Symbol.toPrimitive];
|
|
@@ -243,14 +243,14 @@ function toPrimitive(t, r) {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
//#endregion
|
|
246
|
-
//#region \0@oxc-project+runtime@0.
|
|
246
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
247
247
|
function toPropertyKey(t) {
|
|
248
248
|
var i = toPrimitive(t, "string");
|
|
249
249
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
//#endregion
|
|
253
|
-
//#region \0@oxc-project+runtime@0.
|
|
253
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
254
254
|
function _defineProperty(e, r, t) {
|
|
255
255
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
256
256
|
value: t,
|
|
@@ -261,7 +261,7 @@ function _defineProperty(e, r, t) {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
//#endregion
|
|
264
|
-
//#region \0@oxc-project+runtime@0.
|
|
264
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
265
265
|
function __decorateParam(paramIndex, decorator) {
|
|
266
266
|
return function(target, key) {
|
|
267
267
|
decorator(target, key, paramIndex);
|
|
@@ -269,7 +269,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
//#endregion
|
|
272
|
-
//#region \0@oxc-project+runtime@0.
|
|
272
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
273
273
|
function __decorate(decorators, target, key, desc) {
|
|
274
274
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
275
275
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11972,6 +11972,7 @@ let AutoFillService = class AutoFillService extends _univerjs_core.Disposable {
|
|
|
11972
11972
|
direction = _univerjs_core.Direction.RIGHT;
|
|
11973
11973
|
target.startColumn = source.endColumn + 1;
|
|
11974
11974
|
} else return false;
|
|
11975
|
+
this.setShowMenu(false);
|
|
11975
11976
|
this.direction = direction;
|
|
11976
11977
|
const autoFillSource = this._injector.invoke((accessor) => rangeToDiscreteRange(source, accessor, unitId, subUnitId));
|
|
11977
11978
|
const autoFillTarget = this._injector.invoke((accessor) => rangeToDiscreteRange(target, accessor, unitId, subUnitId));
|
|
@@ -12024,7 +12025,7 @@ let AutoFillService = class AutoFillService extends _univerjs_core.Disposable {
|
|
|
12024
12025
|
getAllHooks() {
|
|
12025
12026
|
return this._hooks;
|
|
12026
12027
|
}
|
|
12027
|
-
getActiveHooks() {
|
|
12028
|
+
getActiveHooks(applyType = this.applyType) {
|
|
12028
12029
|
const { source, target, unitId, subUnitId } = this.autoFillLocation || {};
|
|
12029
12030
|
if (!source || !target || !unitId || !subUnitId) return [];
|
|
12030
12031
|
const enabledHooks = this._hooks.filter((h) => {
|
|
@@ -12034,7 +12035,7 @@ let AutoFillService = class AutoFillService extends _univerjs_core.Disposable {
|
|
|
12034
12035
|
target,
|
|
12035
12036
|
unitId,
|
|
12036
12037
|
subUnitId
|
|
12037
|
-
}, this._direction,
|
|
12038
|
+
}, this._direction, applyType)) === true;
|
|
12038
12039
|
});
|
|
12039
12040
|
const onlyHooks = enabledHooks.filter((h) => h.type === "ONLY");
|
|
12040
12041
|
if (onlyHooks.length > 0) return this._getOneByPriority(onlyHooks);
|
|
@@ -12083,7 +12084,6 @@ let AutoFillService = class AutoFillService extends _univerjs_core.Disposable {
|
|
|
12083
12084
|
}
|
|
12084
12085
|
fillData(applyType) {
|
|
12085
12086
|
var _activeWorkbook$getAc;
|
|
12086
|
-
this.applyType = applyType;
|
|
12087
12087
|
const activeWorkbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
12088
12088
|
const activeUnitId = activeWorkbook === null || activeWorkbook === void 0 ? void 0 : activeWorkbook.getUnitId();
|
|
12089
12089
|
const activeSubUnitId = activeWorkbook === null || activeWorkbook === void 0 || (_activeWorkbook$getAc = activeWorkbook.getActiveSheet()) === null || _activeWorkbook$getAc === void 0 ? void 0 : _activeWorkbook$getAc.getSheetId();
|
|
@@ -12094,12 +12094,30 @@ let AutoFillService = class AutoFillService extends _univerjs_core.Disposable {
|
|
|
12094
12094
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
12095
12095
|
if (!worksheet) return false;
|
|
12096
12096
|
const direction = this.direction;
|
|
12097
|
+
const activeHooks = this.getActiveHooks(applyType);
|
|
12098
|
+
const fillCallbacks = activeHooks.map((hook) => {
|
|
12099
|
+
var _hook$onPrepareFillDa;
|
|
12100
|
+
return ((_hook$onPrepareFillDa = hook.onPrepareFillData) === null || _hook$onPrepareFillDa === void 0 ? void 0 : _hook$onPrepareFillDa.call(hook, {
|
|
12101
|
+
source,
|
|
12102
|
+
target,
|
|
12103
|
+
unitId,
|
|
12104
|
+
subUnitId
|
|
12105
|
+
}, direction, applyType)) ?? (() => {
|
|
12106
|
+
var _hook$onFillData;
|
|
12107
|
+
return (_hook$onFillData = hook.onFillData) === null || _hook$onFillData === void 0 ? void 0 : _hook$onFillData.call(hook, {
|
|
12108
|
+
source,
|
|
12109
|
+
target,
|
|
12110
|
+
unitId,
|
|
12111
|
+
subUnitId
|
|
12112
|
+
}, direction, applyType);
|
|
12113
|
+
});
|
|
12114
|
+
});
|
|
12115
|
+
this.applyType = applyType;
|
|
12097
12116
|
if (this._prevUndos.length > 0) this._prevUndos.forEach((undo) => {
|
|
12098
12117
|
this._commandService.syncExecuteCommand(undo.id, undo.params);
|
|
12099
12118
|
});
|
|
12100
12119
|
this._prevUndos = [];
|
|
12101
12120
|
const selection = _univerjs_core.Rectangle.union(discreteRangeToRange(source), discreteRangeToRange(target));
|
|
12102
|
-
const activeHooks = this.getActiveHooks();
|
|
12103
12121
|
if (unitId === activeUnitId && subUnitId === activeSubUnitId) this._commandService.syncExecuteCommand(SetSelectionsOperation.id, {
|
|
12104
12122
|
selections: [{
|
|
12105
12123
|
primary: getPrimaryForRange({
|
|
@@ -12118,14 +12136,8 @@ let AutoFillService = class AutoFillService extends _univerjs_core.Disposable {
|
|
|
12118
12136
|
});
|
|
12119
12137
|
const undos = [];
|
|
12120
12138
|
const redos = [];
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
const { undos: hookUndos, redos: hookRedos } = ((_hook$onFillData = hook.onFillData) === null || _hook$onFillData === void 0 ? void 0 : _hook$onFillData.call(hook, {
|
|
12124
|
-
source,
|
|
12125
|
-
target,
|
|
12126
|
-
unitId,
|
|
12127
|
-
subUnitId
|
|
12128
|
-
}, direction, applyType)) || {};
|
|
12139
|
+
fillCallbacks.forEach((fill) => {
|
|
12140
|
+
const { undos: hookUndos, redos: hookRedos } = fill() || {};
|
|
12129
12141
|
if (hookUndos) undos.push(...hookUndos);
|
|
12130
12142
|
if (hookRedos) redos.push(...hookRedos);
|
|
12131
12143
|
});
|
|
@@ -14721,6 +14733,72 @@ const SetTabColorCommand = {
|
|
|
14721
14733
|
}
|
|
14722
14734
|
};
|
|
14723
14735
|
|
|
14736
|
+
//#endregion
|
|
14737
|
+
//#region src/services/permission/permission-point/workbook/editable.ts
|
|
14738
|
+
var WorkbookEditablePermission = class {
|
|
14739
|
+
constructor(unitId) {
|
|
14740
|
+
this.unitId = unitId;
|
|
14741
|
+
_defineProperty(this, "id", void 0);
|
|
14742
|
+
_defineProperty(this, "value", true);
|
|
14743
|
+
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Workbook);
|
|
14744
|
+
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
14745
|
+
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
14746
|
+
this.unitId = unitId;
|
|
14747
|
+
this.id = `${this.type}.${_univerjs_protocol.UnitAction.Edit}_${unitId}`;
|
|
14748
|
+
}
|
|
14749
|
+
};
|
|
14750
|
+
|
|
14751
|
+
//#endregion
|
|
14752
|
+
//#region src/commands/mutations/set-workbook-calculation-settings.mutation.ts
|
|
14753
|
+
const SetWorkbookCalculationSettingsMutation = {
|
|
14754
|
+
id: "sheet.mutation.set-workbook-calculation-settings",
|
|
14755
|
+
type: _univerjs_core.CommandType.MUTATION,
|
|
14756
|
+
handler: (accessor, params) => {
|
|
14757
|
+
const workbook = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
14758
|
+
if (!workbook) return false;
|
|
14759
|
+
workbook.setCalculationSettings(params.settings);
|
|
14760
|
+
return true;
|
|
14761
|
+
}
|
|
14762
|
+
};
|
|
14763
|
+
|
|
14764
|
+
//#endregion
|
|
14765
|
+
//#region src/commands/commands/set-workbook-calculation-settings.command.ts
|
|
14766
|
+
const SetWorkbookCalculationSettingsCommand = {
|
|
14767
|
+
id: "sheet.command.set-workbook-calculation-settings",
|
|
14768
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14769
|
+
handler: (accessor, params) => {
|
|
14770
|
+
if (!params) return false;
|
|
14771
|
+
const target = getSheetCommandTargetWorkbook(accessor.get(_univerjs_core.IUniverInstanceService), params);
|
|
14772
|
+
if (!target) return false;
|
|
14773
|
+
const permission = accessor.get(_univerjs_core.IPermissionService).getPermissionPoint(new WorkbookEditablePermission(params.unitId).id);
|
|
14774
|
+
if (permission && !permission.value) return false;
|
|
14775
|
+
const undoParams = {
|
|
14776
|
+
unitId: params.unitId,
|
|
14777
|
+
settings: target.workbook.getCalculationSettings()
|
|
14778
|
+
};
|
|
14779
|
+
const redoParams = {
|
|
14780
|
+
unitId: params.unitId,
|
|
14781
|
+
settings: (0, _univerjs_core.normalizeWorkbookCalculationSettings)(params.settings)
|
|
14782
|
+
};
|
|
14783
|
+
if (undoParams.settings.iterativeCalculation === redoParams.settings.iterativeCalculation && undoParams.settings.maxIterations === redoParams.settings.maxIterations && undoParams.settings.maxChange === redoParams.settings.maxChange) return true;
|
|
14784
|
+
if (accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(SetWorkbookCalculationSettingsMutation.id, redoParams)) {
|
|
14785
|
+
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
14786
|
+
unitID: params.unitId,
|
|
14787
|
+
undoMutations: [{
|
|
14788
|
+
id: SetWorkbookCalculationSettingsMutation.id,
|
|
14789
|
+
params: undoParams
|
|
14790
|
+
}],
|
|
14791
|
+
redoMutations: [{
|
|
14792
|
+
id: SetWorkbookCalculationSettingsMutation.id,
|
|
14793
|
+
params: redoParams
|
|
14794
|
+
}]
|
|
14795
|
+
});
|
|
14796
|
+
return true;
|
|
14797
|
+
}
|
|
14798
|
+
return false;
|
|
14799
|
+
}
|
|
14800
|
+
};
|
|
14801
|
+
|
|
14724
14802
|
//#endregion
|
|
14725
14803
|
//#region src/commands/mutations/set-workbook-name.mutation.ts
|
|
14726
14804
|
const SetWorkbookNameMutation = {
|
|
@@ -15594,21 +15672,6 @@ var WorkbookDuplicatePermission = class {
|
|
|
15594
15672
|
}
|
|
15595
15673
|
};
|
|
15596
15674
|
|
|
15597
|
-
//#endregion
|
|
15598
|
-
//#region src/services/permission/permission-point/workbook/editable.ts
|
|
15599
|
-
var WorkbookEditablePermission = class {
|
|
15600
|
-
constructor(unitId) {
|
|
15601
|
-
this.unitId = unitId;
|
|
15602
|
-
_defineProperty(this, "id", void 0);
|
|
15603
|
-
_defineProperty(this, "value", true);
|
|
15604
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Workbook);
|
|
15605
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
15606
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
15607
|
-
this.unitId = unitId;
|
|
15608
|
-
this.id = `${this.type}.${_univerjs_protocol.UnitAction.Edit}_${unitId}`;
|
|
15609
|
-
}
|
|
15610
|
-
};
|
|
15611
|
-
|
|
15612
15675
|
//#endregion
|
|
15613
15676
|
//#region src/services/permission/permission-point/workbook/export.ts
|
|
15614
15677
|
var WorkbookExportPermission = class {
|
|
@@ -17422,8 +17485,9 @@ let AutoFillController = class AutoFillController extends _univerjs_core.Disposa
|
|
|
17422
17485
|
onBeforeFillData: (location, direction) => {
|
|
17423
17486
|
return this._presetAndCacheData(location, direction);
|
|
17424
17487
|
},
|
|
17425
|
-
|
|
17426
|
-
|
|
17488
|
+
onPrepareFillData: (location, direction, applyType) => {
|
|
17489
|
+
const prepared = this._prepareFillData(location, direction, applyType);
|
|
17490
|
+
return () => this._fillData(location, direction, applyType, prepared);
|
|
17427
17491
|
}
|
|
17428
17492
|
}));
|
|
17429
17493
|
}
|
|
@@ -17472,7 +17536,7 @@ let AutoFillController = class AutoFillController extends _univerjs_core.Disposa
|
|
|
17472
17536
|
const arrData = this._applyFunctions(copySquad, len, direction, applyType, customApplyFunctions, copyDataPiece, location);
|
|
17473
17537
|
const arrIndex = getDataIndex(csLen, asLen, copySquad.index);
|
|
17474
17538
|
applyDataInTypes[type].push({
|
|
17475
|
-
data: arrData,
|
|
17539
|
+
data: arrData ?? [],
|
|
17476
17540
|
index: arrIndex
|
|
17477
17541
|
});
|
|
17478
17542
|
});
|
|
@@ -17631,28 +17695,9 @@ let AutoFillController = class AutoFillController extends _univerjs_core.Disposa
|
|
|
17631
17695
|
}
|
|
17632
17696
|
return applyMergeRanges;
|
|
17633
17697
|
}
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
const
|
|
17637
|
-
const redos = [];
|
|
17638
|
-
let hasStyle = true;
|
|
17639
|
-
if (applyType === "NO_FORMAT") {
|
|
17640
|
-
hasStyle = false;
|
|
17641
|
-
applyType = "SERIES";
|
|
17642
|
-
}
|
|
17643
|
-
const { source, target, unitId, subUnitId } = location;
|
|
17644
|
-
if (!source || !target || direction == null) return {
|
|
17645
|
-
undos,
|
|
17646
|
-
redos
|
|
17647
|
-
};
|
|
17648
|
-
const sourceRange = discreteRangeToRange(source);
|
|
17649
|
-
const targetRange = discreteRangeToRange(target);
|
|
17650
|
-
const { cols: targetCols, rows: targetRows } = target;
|
|
17651
|
-
const { cols: sourceCols, rows: sourceRows } = source;
|
|
17652
|
-
const copyData = this._copyData;
|
|
17653
|
-
let csLen;
|
|
17654
|
-
if (direction === _univerjs_core.Direction.DOWN || direction === _univerjs_core.Direction.UP) csLen = sourceRows.length;
|
|
17655
|
-
else csLen = sourceCols.length;
|
|
17698
|
+
_getFillCells(location, direction, applyType, hasStyle, csLen) {
|
|
17699
|
+
const { rows: targetRows, cols: targetCols } = location.target;
|
|
17700
|
+
const copyData = _univerjs_core.Tools.deepClone(this._copyData);
|
|
17656
17701
|
const applyDatas = [];
|
|
17657
17702
|
if (direction === _univerjs_core.Direction.DOWN || direction === _univerjs_core.Direction.UP) {
|
|
17658
17703
|
const asLen = targetRows.length;
|
|
@@ -17683,20 +17728,26 @@ let AutoFillController = class AutoFillController extends _univerjs_core.Disposa
|
|
|
17683
17728
|
applyDatas.push(row);
|
|
17684
17729
|
});
|
|
17685
17730
|
}
|
|
17686
|
-
|
|
17731
|
+
return applyDatas;
|
|
17732
|
+
}
|
|
17733
|
+
_prepareFillData(location, direction, applyType) {
|
|
17734
|
+
var _this$_univerInstance4;
|
|
17735
|
+
const hasStyle = applyType !== "NO_FORMAT";
|
|
17736
|
+
const effectiveApplyType = hasStyle ? applyType : "SERIES";
|
|
17737
|
+
const { source, target, unitId } = location;
|
|
17738
|
+
const sourceRange = discreteRangeToRange(source);
|
|
17739
|
+
const targetRange = discreteRangeToRange(target);
|
|
17740
|
+
const { cols: targetCols, rows: targetRows } = target;
|
|
17741
|
+
const { cols: sourceCols, rows: sourceRows } = source;
|
|
17742
|
+
let csLen;
|
|
17743
|
+
if (direction === _univerjs_core.Direction.DOWN || direction === _univerjs_core.Direction.UP) csLen = sourceRows.length;
|
|
17744
|
+
else csLen = sourceCols.length;
|
|
17745
|
+
const applyDatas = this._getFillCells(location, direction, effectiveApplyType, hasStyle, csLen);
|
|
17746
|
+
const applyMergeRanges = hasStyle ? this._getMergeApplyData(sourceRange, targetRange, direction, csLen, location) : [];
|
|
17687
17747
|
const style = (_this$_univerInstance4 = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance4 === void 0 ? void 0 : _this$_univerInstance4.getStyles();
|
|
17688
|
-
|
|
17689
|
-
applyMergeRanges = this._getMergeApplyData(sourceRange, targetRange, direction, csLen, location);
|
|
17690
|
-
applyDatas.forEach((row) => {
|
|
17691
|
-
row.forEach((cellData) => {
|
|
17692
|
-
if (cellData && style) {
|
|
17693
|
-
if (style) cellData.s = style.getStyleByCell(cellData);
|
|
17694
|
-
}
|
|
17695
|
-
});
|
|
17696
|
-
});
|
|
17697
|
-
} else applyDatas.forEach((row, rowIndex) => {
|
|
17748
|
+
applyDatas.forEach((row, rowIndex) => {
|
|
17698
17749
|
row.forEach((cellData, colIndex) => {
|
|
17699
|
-
if (cellData && style) cellData.s = style.getStyleByCell(this._beforeApplyData[rowIndex][colIndex]) || null;
|
|
17750
|
+
if (cellData && style) cellData.s = hasStyle ? style.getStyleByCell(cellData) : style.getStyleByCell(this._beforeApplyData[rowIndex][colIndex]) || null;
|
|
17700
17751
|
});
|
|
17701
17752
|
});
|
|
17702
17753
|
if (applyType === "ONLY_FORMAT") applyDatas.forEach((row, rowIndex) => {
|
|
@@ -17712,30 +17763,59 @@ let AutoFillController = class AutoFillController extends _univerjs_core.Disposa
|
|
|
17712
17763
|
}
|
|
17713
17764
|
});
|
|
17714
17765
|
});
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17766
|
+
const cellValue = new _univerjs_core.ObjectMatrix();
|
|
17767
|
+
targetRows.forEach((row, rowIndex) => {
|
|
17768
|
+
targetCols.forEach((col, colIndex) => {
|
|
17769
|
+
const cell = applyDatas[rowIndex][colIndex];
|
|
17770
|
+
if (cell) cellValue.setValue(row, col, cell);
|
|
17771
|
+
});
|
|
17772
|
+
});
|
|
17773
|
+
const cellValueMatrix = cellValue.getMatrix();
|
|
17774
|
+
this._autoFillService.getActiveHooks(applyType).forEach((hook) => {
|
|
17775
|
+
var _hook$onValidateFillD;
|
|
17776
|
+
(_hook$onValidateFillD = hook.onValidateFillData) === null || _hook$onValidateFillD === void 0 || _hook$onValidateFillD.call(hook, location, direction, applyType, cellValueMatrix);
|
|
17777
|
+
});
|
|
17778
|
+
return {
|
|
17779
|
+
cellValue: cellValueMatrix,
|
|
17780
|
+
applyMergeRanges,
|
|
17781
|
+
hasStyle
|
|
17782
|
+
};
|
|
17783
|
+
}
|
|
17784
|
+
_getRemoveMergeMutations(location) {
|
|
17785
|
+
var _this$_univerInstance5;
|
|
17786
|
+
const { unitId, subUnitId, target } = location;
|
|
17787
|
+
const targetRange = discreteRangeToRange(target);
|
|
17788
|
+
const undos = [];
|
|
17789
|
+
const redos = [];
|
|
17790
|
+
const deleteMergeRanges = ((_this$_univerInstance5 = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance5 === void 0 || (_this$_univerInstance5 = _this$_univerInstance5.getSheetBySheetId(subUnitId)) === null || _this$_univerInstance5 === void 0 ? void 0 : _this$_univerInstance5.getMergeData().filter((merge) => _univerjs_core.Rectangle.intersects(merge, targetRange))) ?? [];
|
|
17791
|
+
if (deleteMergeRanges.length) {
|
|
17792
|
+
const removeMergeMutationParams = {
|
|
17793
|
+
unitId,
|
|
17794
|
+
subUnitId,
|
|
17795
|
+
ranges: deleteMergeRanges
|
|
17796
|
+
};
|
|
17797
|
+
const undoRemoveMergeMutationParams = this._injector.invoke(RemoveMergeUndoMutationFactory, removeMergeMutationParams);
|
|
17798
|
+
redos.push({
|
|
17799
|
+
id: RemoveWorksheetMergeMutation.id,
|
|
17800
|
+
params: removeMergeMutationParams
|
|
17801
|
+
});
|
|
17802
|
+
undos.unshift({
|
|
17803
|
+
id: AddWorksheetMergeMutation.id,
|
|
17804
|
+
params: undoRemoveMergeMutationParams
|
|
17721
17805
|
});
|
|
17722
|
-
if (deleteMergeRanges.length) {
|
|
17723
|
-
const removeMergeMutationParams = {
|
|
17724
|
-
unitId,
|
|
17725
|
-
subUnitId,
|
|
17726
|
-
ranges: deleteMergeRanges
|
|
17727
|
-
};
|
|
17728
|
-
const undoRemoveMergeMutationParams = this._injector.invoke(RemoveMergeUndoMutationFactory, removeMergeMutationParams);
|
|
17729
|
-
redos.push({
|
|
17730
|
-
id: RemoveWorksheetMergeMutation.id,
|
|
17731
|
-
params: removeMergeMutationParams
|
|
17732
|
-
});
|
|
17733
|
-
undos.unshift({
|
|
17734
|
-
id: AddWorksheetMergeMutation.id,
|
|
17735
|
-
params: undoRemoveMergeMutationParams
|
|
17736
|
-
});
|
|
17737
|
-
}
|
|
17738
17806
|
}
|
|
17807
|
+
return {
|
|
17808
|
+
undos,
|
|
17809
|
+
redos
|
|
17810
|
+
};
|
|
17811
|
+
}
|
|
17812
|
+
_fillData(location, direction, applyType, prepared) {
|
|
17813
|
+
const { target, unitId, subUnitId } = location;
|
|
17814
|
+
const { cellValue, applyMergeRanges, hasStyle } = prepared;
|
|
17815
|
+
const { undos, redos } = hasStyle ? this._getRemoveMergeMutations(location) : {
|
|
17816
|
+
undos: [],
|
|
17817
|
+
redos: []
|
|
17818
|
+
};
|
|
17739
17819
|
const clearMutationParams = {
|
|
17740
17820
|
subUnitId,
|
|
17741
17821
|
unitId,
|
|
@@ -17750,22 +17830,15 @@ let AutoFillController = class AutoFillController extends _univerjs_core.Disposa
|
|
|
17750
17830
|
id: SetRangeValuesMutation.id,
|
|
17751
17831
|
params: undoClearMutationParams
|
|
17752
17832
|
});
|
|
17753
|
-
const cellValue = new _univerjs_core.ObjectMatrix();
|
|
17754
|
-
targetRows.forEach((row, rowIndex) => {
|
|
17755
|
-
targetCols.forEach((col, colIndex) => {
|
|
17756
|
-
if (applyDatas[rowIndex][colIndex]) cellValue.setValue(row, col, applyDatas[rowIndex][colIndex]);
|
|
17757
|
-
});
|
|
17758
|
-
});
|
|
17759
|
-
const cellValueMatrix = cellValue.getMatrix();
|
|
17760
17833
|
const setRangeValuesMutationParams = {
|
|
17761
17834
|
subUnitId,
|
|
17762
17835
|
unitId,
|
|
17763
|
-
cellValue
|
|
17836
|
+
cellValue
|
|
17764
17837
|
};
|
|
17765
17838
|
const undoSetRangeValuesMutationParams = this._injector.invoke(SetRangeValuesUndoMutationFactory, setRangeValuesMutationParams);
|
|
17766
|
-
this._autoFillService.getActiveHooks().forEach((hook) => {
|
|
17839
|
+
this._autoFillService.getActiveHooks(applyType).forEach((hook) => {
|
|
17767
17840
|
var _hook$onBeforeSubmit;
|
|
17768
|
-
(_hook$onBeforeSubmit = hook.onBeforeSubmit) === null || _hook$onBeforeSubmit === void 0 || _hook$onBeforeSubmit.call(hook, location, direction, applyType,
|
|
17841
|
+
(_hook$onBeforeSubmit = hook.onBeforeSubmit) === null || _hook$onBeforeSubmit === void 0 || _hook$onBeforeSubmit.call(hook, location, direction, applyType, cellValue);
|
|
17769
17842
|
});
|
|
17770
17843
|
undos.unshift({
|
|
17771
17844
|
id: SetRangeValuesMutation.id,
|
|
@@ -18122,7 +18195,7 @@ SheetsFreezeSyncController = __decorate([
|
|
|
18122
18195
|
//#endregion
|
|
18123
18196
|
//#region src/controllers/permission/sheet-permission-check.controller.ts
|
|
18124
18197
|
let SheetPermissionCheckController = class SheetPermissionCheckController extends _univerjs_core.Disposable {
|
|
18125
|
-
constructor(_commandService, _univerInstanceService, _permissionService, _selectionManagerService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _localeService, _lexerTreeBuilder, _definedNamesService) {
|
|
18198
|
+
constructor(_commandService, _univerInstanceService, _permissionService, _selectionManagerService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _localeService, _lexerTreeBuilder, _definedNamesService, _autoFillService, _formulaDataModel, _functionService) {
|
|
18126
18199
|
super();
|
|
18127
18200
|
this._commandService = _commandService;
|
|
18128
18201
|
this._univerInstanceService = _univerInstanceService;
|
|
@@ -18133,6 +18206,9 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18133
18206
|
this._localeService = _localeService;
|
|
18134
18207
|
this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
18135
18208
|
this._definedNamesService = _definedNamesService;
|
|
18209
|
+
this._autoFillService = _autoFillService;
|
|
18210
|
+
this._formulaDataModel = _formulaDataModel;
|
|
18211
|
+
this._functionService = _functionService;
|
|
18136
18212
|
_defineProperty(this, "disposableCollection", new _univerjs_core.DisposableCollection());
|
|
18137
18213
|
_defineProperty(this, "_triggerPermissionUIEvent$", new rxjs.Subject());
|
|
18138
18214
|
_defineProperty(this, "triggerPermissionUIEvent$", this._triggerPermissionUIEvent$.asObservable());
|
|
@@ -18140,6 +18216,29 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18140
18216
|
}
|
|
18141
18217
|
_initialize() {
|
|
18142
18218
|
this._commandExecutedListener();
|
|
18219
|
+
this.disposeWithMe(this._autoFillService.addHook({
|
|
18220
|
+
id: "permission-check",
|
|
18221
|
+
onValidateFillData: ({ unitId, subUnitId }, _direction, applyType, cellValue) => {
|
|
18222
|
+
if (applyType === "ONLY_FORMAT") return;
|
|
18223
|
+
const formulas = new _univerjs_core.ObjectMatrix(this._formulaDataModel.updateFormulaData(unitId, subUnitId, cellValue));
|
|
18224
|
+
new _univerjs_core.ObjectMatrix(cellValue).forValue((row, column) => {
|
|
18225
|
+
const formula = formulas.getValue(row, column);
|
|
18226
|
+
if (!(formula === null || formula === void 0 ? void 0 : formula.f)) return;
|
|
18227
|
+
const formulaString = this._lexerTreeBuilder.moveFormulaRefOffset(formula.f, formula.x ?? 0, formula.y ?? 0);
|
|
18228
|
+
if (!this._permissionCheckWithFormula({
|
|
18229
|
+
unitId,
|
|
18230
|
+
subUnitId,
|
|
18231
|
+
range: {
|
|
18232
|
+
startRow: row,
|
|
18233
|
+
endRow: row,
|
|
18234
|
+
startColumn: column,
|
|
18235
|
+
endColumn: column
|
|
18236
|
+
},
|
|
18237
|
+
value: { f: formulaString }
|
|
18238
|
+
})) this.blockExecuteWithoutPermission(this._localeService.t("sheets.permission.dialog.formulaErr"));
|
|
18239
|
+
});
|
|
18240
|
+
}
|
|
18241
|
+
}));
|
|
18143
18242
|
}
|
|
18144
18243
|
_commandExecutedListener() {
|
|
18145
18244
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((commandInfo) => {
|
|
@@ -18464,61 +18563,18 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18464
18563
|
_permissionCheckWithFormula(params) {
|
|
18465
18564
|
const target = getSheetCommandTarget(this._univerInstanceService, params);
|
|
18466
18565
|
if (!target) return false;
|
|
18467
|
-
const {
|
|
18566
|
+
const { unitId, subUnitId } = target;
|
|
18468
18567
|
const formulaString = params.value.f;
|
|
18469
18568
|
if (formulaString) {
|
|
18470
|
-
|
|
18471
|
-
const
|
|
18472
|
-
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
if (sheetName) {
|
|
18480
|
-
const targetSheet = workbook.getSheetBySheetName(sheetName);
|
|
18481
|
-
if (!targetSheet) return true;
|
|
18482
|
-
const { startRow, endRow, startColumn, endColumn } = range;
|
|
18483
|
-
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
18484
|
-
var _cell$selectionProtec2;
|
|
18485
|
-
const cell = targetSheet.getCell(r, c);
|
|
18486
|
-
const permission = cell === null || cell === void 0 || (_cell$selectionProtec2 = cell.selectionProtection) === null || _cell$selectionProtec2 === void 0 ? void 0 : _cell$selectionProtec2[0];
|
|
18487
|
-
if ((permission === null || permission === void 0 ? void 0 : permission[_univerjs_protocol.UnitAction.View]) === false) return false;
|
|
18488
|
-
}
|
|
18489
|
-
}
|
|
18490
|
-
}
|
|
18491
|
-
return true;
|
|
18492
|
-
} else {
|
|
18493
|
-
const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
18494
|
-
if (!sequenceNodes) return true;
|
|
18495
|
-
for (let i = 0; i < sequenceNodes.length; i++) {
|
|
18496
|
-
const node = sequenceNodes[i];
|
|
18497
|
-
if (typeof node === "string" || node.nodeType !== _univerjs_engine_formula.sequenceNodeType.REFERENCE) continue;
|
|
18498
|
-
const { token } = node;
|
|
18499
|
-
const { unitId: sequenceGridUnitId, sheetName, range } = (0, _univerjs_engine_formula.deserializeRangeWithSheetWithCache)(token);
|
|
18500
|
-
let sequenceGridWorkbook = workbook;
|
|
18501
|
-
if (sequenceGridUnitId && sequenceGridUnitId !== unitId) {
|
|
18502
|
-
const _sequenceGridWorkbook = this._univerInstanceService.getUnit(sequenceGridUnitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
18503
|
-
if (!_sequenceGridWorkbook) return true;
|
|
18504
|
-
sequenceGridWorkbook = _sequenceGridWorkbook;
|
|
18505
|
-
}
|
|
18506
|
-
const sequenceGridWorksheet = sheetName ? sequenceGridWorkbook.getSheetBySheetName(sheetName) : sequenceGridWorkbook.getActiveSheet();
|
|
18507
|
-
if (!sequenceGridWorksheet) return true;
|
|
18508
|
-
if (sheetName) {
|
|
18509
|
-
const viewPermission = this._permissionService.getPermissionPoint(new WorksheetViewPermission(sequenceGridWorkbook.getUnitId(), sequenceGridWorksheet.getSheetId()).id);
|
|
18510
|
-
if (!viewPermission || viewPermission.value === false) return false;
|
|
18511
|
-
}
|
|
18512
|
-
const { startRow, endRow, startColumn, endColumn } = range;
|
|
18513
|
-
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
18514
|
-
var _cell$selectionProtec3;
|
|
18515
|
-
const cell = sequenceGridWorksheet.getCell(r, c);
|
|
18516
|
-
const permission = cell === null || cell === void 0 || (_cell$selectionProtec3 = cell.selectionProtection) === null || _cell$selectionProtec3 === void 0 ? void 0 : _cell$selectionProtec3[0];
|
|
18517
|
-
if ((permission === null || permission === void 0 ? void 0 : permission[_univerjs_protocol.UnitAction.View]) === false) return false;
|
|
18518
|
-
}
|
|
18519
|
-
}
|
|
18520
|
-
return true;
|
|
18521
|
-
}
|
|
18569
|
+
var _this$_selectionManag3;
|
|
18570
|
+
const ranges = params.range ? [params.range] : ((_this$_selectionManag3 = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag3 === void 0 ? void 0 : _this$_selectionManag3.map((selection) => selection.range)) ?? [];
|
|
18571
|
+
for (const range of ranges) for (let row = range.startRow; row <= range.endRow; row++) for (let column = range.startColumn; column <= range.endColumn; column++) if (!this._permissionCheckFormulaReferences(formulaString, {
|
|
18572
|
+
unitId,
|
|
18573
|
+
subUnitId,
|
|
18574
|
+
row,
|
|
18575
|
+
column
|
|
18576
|
+
})) return false;
|
|
18577
|
+
return true;
|
|
18522
18578
|
}
|
|
18523
18579
|
const { range } = params;
|
|
18524
18580
|
if (range) {
|
|
@@ -18529,6 +18585,73 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18529
18585
|
}
|
|
18530
18586
|
return true;
|
|
18531
18587
|
}
|
|
18588
|
+
_getFormulaReferenceWorkbook(unitId, qualifier) {
|
|
18589
|
+
const workbook = this._univerInstanceService.getUnit(qualifier || unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
18590
|
+
if (workbook || !qualifier) return workbook;
|
|
18591
|
+
const workbooks = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).filter((item) => item.getSnapshot().name.length > 0);
|
|
18592
|
+
const exactMatches = workbooks.filter((item) => item.getSnapshot().name.toLowerCase() === qualifier.toLowerCase());
|
|
18593
|
+
const matches = exactMatches.length > 0 ? exactMatches : workbooks.filter((item) => (0, _univerjs_engine_formula.normalizeFormulaUnitName)(item.getSnapshot().name) === (0, _univerjs_engine_formula.normalizeFormulaUnitName)(qualifier));
|
|
18594
|
+
return matches.length === 1 ? matches[0] : null;
|
|
18595
|
+
}
|
|
18596
|
+
_permissionCheckFormulaReferences(formulaString, context, visitingNames = /* @__PURE__ */ new Set(), referenceOffset) {
|
|
18597
|
+
const { unitId, subUnitId, row, column } = context;
|
|
18598
|
+
const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString) ?? [];
|
|
18599
|
+
for (let index = 0; index < sequenceNodes.length; index++) {
|
|
18600
|
+
const node = sequenceNodes[index];
|
|
18601
|
+
if (typeof node === "string" || node.nodeType !== _univerjs_engine_formula.sequenceNodeType.REFERENCE && node.nodeType !== _univerjs_engine_formula.sequenceNodeType.FUNCTION) continue;
|
|
18602
|
+
const nextNode = sequenceNodes[index + 1];
|
|
18603
|
+
if (node.nodeType === _univerjs_engine_formula.sequenceNodeType.FUNCTION && typeof nextNode === "string" && nextNode.trim() === _univerjs_engine_formula.matchToken.OPEN_BRACKET && this._functionService.hasExecutor(node.token.trim().toUpperCase())) continue;
|
|
18604
|
+
let nameToken = node.token.trim();
|
|
18605
|
+
if (node.nodeType === _univerjs_engine_formula.sequenceNodeType.FUNCTION) {
|
|
18606
|
+
const parts = nameToken.split("!");
|
|
18607
|
+
if (parts.length === 2) {
|
|
18608
|
+
var _this$_univerInstance;
|
|
18609
|
+
const unqualifiedName = parts[1].trim();
|
|
18610
|
+
const unscopedName = this._definedNamesService.getValueByName(unitId, unqualifiedName);
|
|
18611
|
+
const localSheetId = unscopedName === null || unscopedName === void 0 ? void 0 : unscopedName.localSheetId;
|
|
18612
|
+
const localSheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(localSheetId ?? "");
|
|
18613
|
+
if (unscopedName && (localSheetId == null || localSheetId === "AllDefaultWorkbook" || (localSheet === null || localSheet === void 0 ? void 0 : localSheet.getName()) === parts[0])) nameToken = unqualifiedName;
|
|
18614
|
+
}
|
|
18615
|
+
}
|
|
18616
|
+
const definedName = this._definedNamesService.getValueByName(unitId, nameToken, subUnitId);
|
|
18617
|
+
if (definedName) {
|
|
18618
|
+
const nameKey = `${unitId}:${definedName.id}`;
|
|
18619
|
+
if (visitingNames.has(nameKey)) continue;
|
|
18620
|
+
visitingNames.add(nameKey);
|
|
18621
|
+
const definition = definedName.formulaOrRefString;
|
|
18622
|
+
const isFormula = definition.startsWith(_univerjs_engine_formula.operatorToken.EQUALS);
|
|
18623
|
+
const offset = isFormula ? void 0 : {
|
|
18624
|
+
x: column - (definedName.localSheetId === "AllDefaultWorkbook" ? 1 : 0),
|
|
18625
|
+
y: row
|
|
18626
|
+
};
|
|
18627
|
+
const permitted = this._permissionCheckFormulaReferences(isFormula ? definition : `${_univerjs_engine_formula.operatorToken.EQUALS}${definition}`, context, visitingNames, offset);
|
|
18628
|
+
visitingNames.delete(nameKey);
|
|
18629
|
+
if (!permitted) return false;
|
|
18630
|
+
continue;
|
|
18631
|
+
}
|
|
18632
|
+
if (node.nodeType !== _univerjs_engine_formula.sequenceNodeType.REFERENCE) continue;
|
|
18633
|
+
const { unitQualifier, sheetName } = (0, _univerjs_engine_formula.handleRefStringInfo)(node.token.trim());
|
|
18634
|
+
const referenceWorkbook = this._getFormulaReferenceWorkbook(unitId, unitQualifier);
|
|
18635
|
+
const referenceWorksheet = sheetName ? referenceWorkbook === null || referenceWorkbook === void 0 ? void 0 : referenceWorkbook.getSheetBySheetName(sheetName) : referenceWorkbook === null || referenceWorkbook === void 0 ? void 0 : referenceWorkbook.getSheetBySheetId(subUnitId);
|
|
18636
|
+
if (!referenceWorkbook || !referenceWorksheet) continue;
|
|
18637
|
+
const referenceUnitId = referenceWorkbook.getUnitId();
|
|
18638
|
+
const referenceSheetId = referenceWorksheet.getSheetId();
|
|
18639
|
+
const { range } = (0, _univerjs_engine_formula.deserializeRangeWithSheetWithCache)(node.token);
|
|
18640
|
+
const referenceRange = referenceOffset ? (0, _univerjs_core.moveRangeByOffset)({ ...range }, referenceOffset.x, referenceOffset.y) : range;
|
|
18641
|
+
if (referenceOffset) {
|
|
18642
|
+
const wrap = (value, limit) => (value % limit + limit) % limit;
|
|
18643
|
+
referenceRange.startRow = wrap(referenceRange.startRow, _univerjs_core.MAX_ROW_COUNT);
|
|
18644
|
+
referenceRange.endRow = wrap(referenceRange.endRow, _univerjs_core.MAX_ROW_COUNT);
|
|
18645
|
+
referenceRange.startColumn = wrap(referenceRange.startColumn, _univerjs_core.MAX_COLUMN_COUNT);
|
|
18646
|
+
referenceRange.endColumn = wrap(referenceRange.endColumn, _univerjs_core.MAX_COLUMN_COUNT);
|
|
18647
|
+
}
|
|
18648
|
+
if (!this.permissionCheckWithRanges({
|
|
18649
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
18650
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
18651
|
+
}, [referenceRange], referenceUnitId, referenceSheetId)) return false;
|
|
18652
|
+
}
|
|
18653
|
+
return true;
|
|
18654
|
+
}
|
|
18532
18655
|
_permissionCheckBySetRangeValue(permissionTypes, params) {
|
|
18533
18656
|
const { unitId, subUnitId, value, range } = params;
|
|
18534
18657
|
let ranges = [];
|
|
@@ -18624,11 +18747,11 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18624
18747
|
return true;
|
|
18625
18748
|
}
|
|
18626
18749
|
_permissionCheckWithInsertOrDeleteMoveRange(direction, params) {
|
|
18627
|
-
var _this$
|
|
18750
|
+
var _this$_selectionManag4;
|
|
18628
18751
|
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
18629
18752
|
if (!target) return false;
|
|
18630
18753
|
const { worksheet, unitId, subUnitId } = target;
|
|
18631
|
-
const range = (params === null || params === void 0 ? void 0 : params.range) ?? ((_this$
|
|
18754
|
+
const range = (params === null || params === void 0 ? void 0 : params.range) ?? ((_this$_selectionManag4 = this._selectionManagerService.getCurrentLastSelection()) === null || _this$_selectionManag4 === void 0 ? void 0 : _this$_selectionManag4.range);
|
|
18632
18755
|
if (!range) return false;
|
|
18633
18756
|
if (!this.permissionCheckWithRanges({
|
|
18634
18757
|
workbookTypes: [WorkbookEditablePermission],
|
|
@@ -18653,7 +18776,10 @@ SheetPermissionCheckController = __decorate([
|
|
|
18653
18776
|
__decorateParam(5, (0, _univerjs_core.Inject)(WorksheetProtectionRuleModel)),
|
|
18654
18777
|
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
18655
18778
|
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder)),
|
|
18656
|
-
__decorateParam(8, _univerjs_engine_formula.IDefinedNamesService)
|
|
18779
|
+
__decorateParam(8, _univerjs_engine_formula.IDefinedNamesService),
|
|
18780
|
+
__decorateParam(9, IAutoFillService),
|
|
18781
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
18782
|
+
__decorateParam(11, _univerjs_engine_formula.IFunctionService)
|
|
18657
18783
|
], SheetPermissionCheckController);
|
|
18658
18784
|
|
|
18659
18785
|
//#endregion
|
|
@@ -19519,7 +19645,7 @@ RangeProtectionCache = __decorate([
|
|
|
19519
19645
|
//#endregion
|
|
19520
19646
|
//#region package.json
|
|
19521
19647
|
var name = "@univerjs/sheets";
|
|
19522
|
-
var version = "1.0
|
|
19648
|
+
var version = "1.2.0";
|
|
19523
19649
|
|
|
19524
19650
|
//#endregion
|
|
19525
19651
|
//#region src/controllers/active-worksheet.controller.ts
|
|
@@ -19649,6 +19775,7 @@ let BasicWorksheetController = class BasicWorksheetController extends _univerjs_
|
|
|
19649
19775
|
RemoveWorksheetMergeMutation,
|
|
19650
19776
|
RemoveNumfmtMutation,
|
|
19651
19777
|
AddWorksheetMergeMutation,
|
|
19778
|
+
SetWorkbookCalculationSettingsMutation,
|
|
19652
19779
|
SetWorkbookNameMutation,
|
|
19653
19780
|
SetWorksheetNameMutation,
|
|
19654
19781
|
SetNumfmtMutation,
|
|
@@ -19742,6 +19869,7 @@ let BasicWorksheetController = class BasicWorksheetController extends _univerjs_
|
|
|
19742
19869
|
SetTextRotationCommand,
|
|
19743
19870
|
SetTextWrapCommand,
|
|
19744
19871
|
SetVerticalTextAlignCommand,
|
|
19872
|
+
SetWorkbookCalculationSettingsCommand,
|
|
19745
19873
|
SetWorkbookNameCommand,
|
|
19746
19874
|
SetWorksheetActivateCommand,
|
|
19747
19875
|
SetWorksheetActiveOperation,
|
|
@@ -20866,6 +20994,9 @@ let UniverSheetsPlugin = class UniverSheetsPlugin extends _univerjs_core.Plugin
|
|
|
20866
20994
|
}
|
|
20867
20995
|
_initConfig() {
|
|
20868
20996
|
var _this$_config, _this$_config2, _this$_config3;
|
|
20997
|
+
const textLineGap = this._config.textLineGap ?? 0;
|
|
20998
|
+
if (!Number.isFinite(textLineGap) || textLineGap < 0) throw new RangeError("textLineGap must be a finite, non-negative number.");
|
|
20999
|
+
this._configService.setConfig(_univerjs_core.SHEET_TEXT_LINE_GAP, textLineGap);
|
|
20869
21000
|
if ((_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.onlyRegisterFormulaRelatedMutations) this._configService.setConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY, true);
|
|
20870
21001
|
if ((_this$_config2 = this._config) === null || _this$_config2 === void 0 ? void 0 : _this$_config2.isRowStylePrecedeColumnStyle) this._configService.setConfig(_univerjs_core.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, true);
|
|
20871
21002
|
if ((_this$_config3 = this._config) === null || _this$_config3 === void 0 ? void 0 : _this$_config3.autoHeightForMergedCells) this._configService.setConfig(_univerjs_core.AUTO_HEIGHT_FOR_MERGED_CELLS, true);
|
|
@@ -21444,7 +21575,10 @@ function convertPositionCellToSheetOverGrid(unitId, subUnitId, cellOverGridPosit
|
|
|
21444
21575
|
});
|
|
21445
21576
|
const left = (0, _univerjs_engine_render.precisionTo)(startSelectionX + fromColumnOffset, 1);
|
|
21446
21577
|
const top = (0, _univerjs_engine_render.precisionTo)(startSelectionY + fromRowOffset, 1);
|
|
21447
|
-
const endSelectionCell = skeleton.getCellIndexAndOffsetByPosition(left + width, top + height
|
|
21578
|
+
const endSelectionCell = skeleton.getCellIndexAndOffsetByPosition(left + width, top + height, 1, 1, {
|
|
21579
|
+
x: 0,
|
|
21580
|
+
y: 0
|
|
21581
|
+
});
|
|
21448
21582
|
return {
|
|
21449
21583
|
unitId,
|
|
21450
21584
|
subUnitId,
|
|
@@ -21488,14 +21622,14 @@ exports.AddWorksheetProtectionMutation = AddWorksheetProtectionMutation;
|
|
|
21488
21622
|
exports.AppendRowCommand = AppendRowCommand;
|
|
21489
21623
|
exports.AutoClearContentCommand = AutoClearContentCommand;
|
|
21490
21624
|
exports.AutoFillCommand = AutoFillCommand;
|
|
21491
|
-
Object.defineProperty(exports,
|
|
21625
|
+
Object.defineProperty(exports, "AutoFillController", {
|
|
21492
21626
|
enumerable: true,
|
|
21493
21627
|
get: function () {
|
|
21494
21628
|
return AutoFillController;
|
|
21495
21629
|
}
|
|
21496
21630
|
});
|
|
21497
21631
|
exports.AutoFillRules = AutoFillRules;
|
|
21498
|
-
Object.defineProperty(exports,
|
|
21632
|
+
Object.defineProperty(exports, "AutoFillService", {
|
|
21499
21633
|
enumerable: true,
|
|
21500
21634
|
get: function () {
|
|
21501
21635
|
return AutoFillService;
|
|
@@ -21506,7 +21640,7 @@ exports.BEFORE_CELL_EDIT = BEFORE_CELL_EDIT;
|
|
|
21506
21640
|
exports.BorderStyleManagerService = BorderStyleManagerService;
|
|
21507
21641
|
exports.COMMAND_LISTENER_SKELETON_CHANGE = COMMAND_LISTENER_SKELETON_CHANGE;
|
|
21508
21642
|
exports.COMMAND_LISTENER_VALUE_CHANGE = COMMAND_LISTENER_VALUE_CHANGE;
|
|
21509
|
-
Object.defineProperty(exports,
|
|
21643
|
+
Object.defineProperty(exports, "CalculateResultApplyController", {
|
|
21510
21644
|
enumerable: true,
|
|
21511
21645
|
get: function () {
|
|
21512
21646
|
return CalculateResultApplyController;
|
|
@@ -21520,7 +21654,7 @@ exports.ClearSelectionFormatCommand = ClearSelectionFormatCommand;
|
|
|
21520
21654
|
exports.CopySheetCommand = CopySheetCommand;
|
|
21521
21655
|
exports.CopyWorksheetEndMutation = CopyWorksheetEndMutation;
|
|
21522
21656
|
exports.DISABLE_NORMAL_SELECTIONS = DISABLE_NORMAL_SELECTIONS;
|
|
21523
|
-
Object.defineProperty(exports,
|
|
21657
|
+
Object.defineProperty(exports, "DefinedNameDataController", {
|
|
21524
21658
|
enumerable: true,
|
|
21525
21659
|
get: function () {
|
|
21526
21660
|
return DefinedNameDataController;
|
|
@@ -21576,7 +21710,7 @@ exports.MAX_CELL_PER_SHEET_KEY = MAX_CELL_PER_SHEET_KEY;
|
|
|
21576
21710
|
exports.MERGE_CELL_INTERCEPTOR_CHECK = MERGE_CELL_INTERCEPTOR_CHECK;
|
|
21577
21711
|
exports.MarkDirtyFilterChangeMutation = MarkDirtyFilterChangeMutation;
|
|
21578
21712
|
exports.MarkDirtyRowAutoHeightOperation = MarkDirtyRowAutoHeightOperation;
|
|
21579
|
-
Object.defineProperty(exports,
|
|
21713
|
+
Object.defineProperty(exports, "MergeCellController", {
|
|
21580
21714
|
enumerable: true,
|
|
21581
21715
|
get: function () {
|
|
21582
21716
|
return MergeCellController;
|
|
@@ -21590,7 +21724,7 @@ exports.MoveRangeMutation = MoveRangeMutation;
|
|
|
21590
21724
|
exports.MoveRowsCommand = MoveRowsCommand;
|
|
21591
21725
|
exports.MoveRowsMutation = MoveRowsMutation;
|
|
21592
21726
|
exports.MoveRowsMutationUndoFactory = MoveRowsMutationUndoFactory;
|
|
21593
|
-
Object.defineProperty(exports,
|
|
21727
|
+
Object.defineProperty(exports, "NumfmtService", {
|
|
21594
21728
|
enumerable: true,
|
|
21595
21729
|
get: function () {
|
|
21596
21730
|
return NumfmtService;
|
|
@@ -21600,7 +21734,7 @@ exports.OperatorType = OperatorType;
|
|
|
21600
21734
|
exports.PermissionPointsDefinitions = PermissionPointsDefinitions;
|
|
21601
21735
|
exports.REF_SELECTIONS_ENABLED = REF_SELECTIONS_ENABLED;
|
|
21602
21736
|
exports.RangeMergeUtil = RangeMergeUtil;
|
|
21603
|
-
Object.defineProperty(exports,
|
|
21737
|
+
Object.defineProperty(exports, "RangeProtectionCache", {
|
|
21604
21738
|
enumerable: true,
|
|
21605
21739
|
get: function () {
|
|
21606
21740
|
return RangeProtectionCache;
|
|
@@ -21610,33 +21744,33 @@ exports.RangeProtectionPermissionDeleteProtectionPoint = RangeProtectionPermissi
|
|
|
21610
21744
|
exports.RangeProtectionPermissionEditPoint = RangeProtectionPermissionEditPoint;
|
|
21611
21745
|
exports.RangeProtectionPermissionManageCollaPoint = RangeProtectionPermissionManageCollaPoint;
|
|
21612
21746
|
exports.RangeProtectionPermissionViewPoint = RangeProtectionPermissionViewPoint;
|
|
21613
|
-
Object.defineProperty(exports,
|
|
21747
|
+
Object.defineProperty(exports, "RangeProtectionRefRangeService", {
|
|
21614
21748
|
enumerable: true,
|
|
21615
21749
|
get: function () {
|
|
21616
21750
|
return RangeProtectionRefRangeService;
|
|
21617
21751
|
}
|
|
21618
21752
|
});
|
|
21619
|
-
Object.defineProperty(exports,
|
|
21753
|
+
Object.defineProperty(exports, "RangeProtectionRenderModel", {
|
|
21620
21754
|
enumerable: true,
|
|
21621
21755
|
get: function () {
|
|
21622
21756
|
return RangeProtectionRenderModel;
|
|
21623
21757
|
}
|
|
21624
21758
|
});
|
|
21625
21759
|
exports.RangeProtectionRuleModel = RangeProtectionRuleModel;
|
|
21626
|
-
Object.defineProperty(exports,
|
|
21760
|
+
Object.defineProperty(exports, "RangeProtectionService", {
|
|
21627
21761
|
enumerable: true,
|
|
21628
21762
|
get: function () {
|
|
21629
21763
|
return RangeProtectionService;
|
|
21630
21764
|
}
|
|
21631
21765
|
});
|
|
21632
21766
|
exports.RangeThemeStyle = RangeThemeStyle;
|
|
21633
|
-
Object.defineProperty(exports,
|
|
21767
|
+
Object.defineProperty(exports, "RefRangeService", {
|
|
21634
21768
|
enumerable: true,
|
|
21635
21769
|
get: function () {
|
|
21636
21770
|
return RefRangeService;
|
|
21637
21771
|
}
|
|
21638
21772
|
});
|
|
21639
|
-
Object.defineProperty(exports,
|
|
21773
|
+
Object.defineProperty(exports, "RefSelectionsService", {
|
|
21640
21774
|
enumerable: true,
|
|
21641
21775
|
get: function () {
|
|
21642
21776
|
return RefSelectionsService;
|
|
@@ -21728,6 +21862,8 @@ exports.SetTextRotationCommand = SetTextRotationCommand;
|
|
|
21728
21862
|
exports.SetTextWrapCommand = SetTextWrapCommand;
|
|
21729
21863
|
exports.SetUnderlineCommand = SetUnderlineCommand;
|
|
21730
21864
|
exports.SetVerticalTextAlignCommand = SetVerticalTextAlignCommand;
|
|
21865
|
+
exports.SetWorkbookCalculationSettingsCommand = SetWorkbookCalculationSettingsCommand;
|
|
21866
|
+
exports.SetWorkbookCalculationSettingsMutation = SetWorkbookCalculationSettingsMutation;
|
|
21731
21867
|
exports.SetWorkbookNameCommand = SetWorkbookNameCommand;
|
|
21732
21868
|
exports.SetWorkbookNameMutation = SetWorkbookNameMutation;
|
|
21733
21869
|
exports.SetWorksheetActivateCommand = SetWorksheetActivateCommand;
|
|
@@ -21768,57 +21904,57 @@ exports.SetWorksheetRowIsAutoHeightMutationFactory = SetWorksheetRowIsAutoHeight
|
|
|
21768
21904
|
exports.SetWorksheetShowCommand = SetWorksheetShowCommand;
|
|
21769
21905
|
exports.SheetCopyDownCommand = SheetCopyDownCommand;
|
|
21770
21906
|
exports.SheetCopyRightCommand = SheetCopyRightCommand;
|
|
21771
|
-
Object.defineProperty(exports,
|
|
21907
|
+
Object.defineProperty(exports, "SheetInterceptorService", {
|
|
21772
21908
|
enumerable: true,
|
|
21773
21909
|
get: function () {
|
|
21774
21910
|
return SheetInterceptorService;
|
|
21775
21911
|
}
|
|
21776
21912
|
});
|
|
21777
|
-
Object.defineProperty(exports,
|
|
21913
|
+
Object.defineProperty(exports, "SheetLazyExecuteScheduleService", {
|
|
21778
21914
|
enumerable: true,
|
|
21779
21915
|
get: function () {
|
|
21780
21916
|
return SheetLazyExecuteScheduleService;
|
|
21781
21917
|
}
|
|
21782
21918
|
});
|
|
21783
|
-
Object.defineProperty(exports,
|
|
21919
|
+
Object.defineProperty(exports, "SheetPermissionCheckController", {
|
|
21784
21920
|
enumerable: true,
|
|
21785
21921
|
get: function () {
|
|
21786
21922
|
return SheetPermissionCheckController;
|
|
21787
21923
|
}
|
|
21788
21924
|
});
|
|
21789
|
-
Object.defineProperty(exports,
|
|
21925
|
+
Object.defineProperty(exports, "SheetPermissionInitController", {
|
|
21790
21926
|
enumerable: true,
|
|
21791
21927
|
get: function () {
|
|
21792
21928
|
return SheetPermissionInitController;
|
|
21793
21929
|
}
|
|
21794
21930
|
});
|
|
21795
|
-
Object.defineProperty(exports,
|
|
21931
|
+
Object.defineProperty(exports, "SheetRangeThemeModel", {
|
|
21796
21932
|
enumerable: true,
|
|
21797
21933
|
get: function () {
|
|
21798
21934
|
return SheetRangeThemeModel;
|
|
21799
21935
|
}
|
|
21800
21936
|
});
|
|
21801
|
-
Object.defineProperty(exports,
|
|
21937
|
+
Object.defineProperty(exports, "SheetRangeThemeService", {
|
|
21802
21938
|
enumerable: true,
|
|
21803
21939
|
get: function () {
|
|
21804
21940
|
return SheetRangeThemeService;
|
|
21805
21941
|
}
|
|
21806
21942
|
});
|
|
21807
21943
|
exports.SheetSkeletonChangeType = SheetSkeletonChangeType;
|
|
21808
|
-
Object.defineProperty(exports,
|
|
21944
|
+
Object.defineProperty(exports, "SheetSkeletonService", {
|
|
21809
21945
|
enumerable: true,
|
|
21810
21946
|
get: function () {
|
|
21811
21947
|
return SheetSkeletonService;
|
|
21812
21948
|
}
|
|
21813
21949
|
});
|
|
21814
21950
|
exports.SheetValueChangeType = SheetValueChangeType;
|
|
21815
|
-
Object.defineProperty(exports,
|
|
21951
|
+
Object.defineProperty(exports, "SheetsFreezeSyncController", {
|
|
21816
21952
|
enumerable: true,
|
|
21817
21953
|
get: function () {
|
|
21818
21954
|
return SheetsFreezeSyncController;
|
|
21819
21955
|
}
|
|
21820
21956
|
});
|
|
21821
|
-
Object.defineProperty(exports,
|
|
21957
|
+
Object.defineProperty(exports, "SheetsSelectionsService", {
|
|
21822
21958
|
enumerable: true,
|
|
21823
21959
|
get: function () {
|
|
21824
21960
|
return SheetsSelectionsService;
|
|
@@ -21830,7 +21966,7 @@ exports.TextToNumberCommand = TextToNumberCommand;
|
|
|
21830
21966
|
exports.ToggleCellCheckboxCommand = ToggleCellCheckboxCommand;
|
|
21831
21967
|
exports.ToggleGridlinesCommand = ToggleGridlinesCommand;
|
|
21832
21968
|
exports.ToggleGridlinesMutation = ToggleGridlinesMutation;
|
|
21833
|
-
Object.defineProperty(exports,
|
|
21969
|
+
Object.defineProperty(exports, "UniverSheetsPlugin", {
|
|
21834
21970
|
enumerable: true,
|
|
21835
21971
|
get: function () {
|
|
21836
21972
|
return UniverSheetsPlugin;
|
|
@@ -21856,7 +21992,7 @@ exports.WorkbookInsertColumnPermission = WorkbookInsertColumnPermission;
|
|
|
21856
21992
|
exports.WorkbookInsertRowPermission = WorkbookInsertRowPermission;
|
|
21857
21993
|
exports.WorkbookManageCollaboratorPermission = WorkbookManageCollaboratorPermission;
|
|
21858
21994
|
exports.WorkbookMoveSheetPermission = WorkbookMoveSheetPermission;
|
|
21859
|
-
Object.defineProperty(exports,
|
|
21995
|
+
Object.defineProperty(exports, "WorkbookPermissionService", {
|
|
21860
21996
|
enumerable: true,
|
|
21861
21997
|
get: function () {
|
|
21862
21998
|
return WorkbookPermissionService;
|
|
@@ -21880,7 +22016,7 @@ exports.WorksheetInsertColumnPermission = WorksheetInsertColumnPermission;
|
|
|
21880
22016
|
exports.WorksheetInsertHyperlinkPermission = WorksheetInsertHyperlinkPermission;
|
|
21881
22017
|
exports.WorksheetInsertRowPermission = WorksheetInsertRowPermission;
|
|
21882
22018
|
exports.WorksheetManageCollaboratorPermission = WorksheetManageCollaboratorPermission;
|
|
21883
|
-
Object.defineProperty(exports,
|
|
22019
|
+
Object.defineProperty(exports, "WorksheetPermissionService", {
|
|
21884
22020
|
enumerable: true,
|
|
21885
22021
|
get: function () {
|
|
21886
22022
|
return WorksheetPermissionService;
|
|
@@ -21897,7 +22033,7 @@ exports.WorksheetSetColumnStylePermission = WorksheetSetColumnStylePermission;
|
|
|
21897
22033
|
exports.WorksheetSetRowStylePermission = WorksheetSetRowStylePermission;
|
|
21898
22034
|
exports.WorksheetSortPermission = WorksheetSortPermission;
|
|
21899
22035
|
exports.WorksheetViewPermission = WorksheetViewPermission;
|
|
21900
|
-
Object.defineProperty(exports,
|
|
22036
|
+
Object.defineProperty(exports, "ZebraCrossingCacheController", {
|
|
21901
22037
|
enumerable: true,
|
|
21902
22038
|
get: function () {
|
|
21903
22039
|
return ZebraCrossingCacheController;
|