@univerjs/sheets 0.3.0 → 0.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +3 -3
- package/lib/es/index.js +1390 -1266
- package/lib/locale/fa-IR.json +14 -0
- package/lib/types/commands/commands/set-border-command.d.ts +1 -1
- package/lib/types/commands/commands/set-defined-name.command.d.ts +4 -6
- package/lib/types/commands/commands/set-style.command.d.ts +2 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/fa-IR.d.ts +3 -0
- package/lib/types/model/range-protection-render.model.d.ts +1 -1
- package/lib/types/model/range-protection.cache.d.ts +6 -0
- package/lib/types/services/numfmt/type.d.ts +1 -1
- package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +5 -1
- package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +1 -1
- package/lib/types/services/ref-range/ref-range.service.d.ts +1 -1
- package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +1 -1
- package/lib/types/sheets-plugin.d.ts +3 -1
- package/lib/umd/index.js +2 -2
- package/package.json +10 -16
package/lib/es/index.js
CHANGED
|
@@ -2,18 +2,170 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, InterceptorEffectEnum, toDisposable, remove, composeInterceptors, DisposableCollection,
|
|
6
|
-
import { SetDefinedNameMutation, RemoveDefinedNameMutation, SetFormulaCalculationResultMutation, handleNumfmtInCell, IDefinedNamesService, stripErrorMargin, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
|
|
5
|
+
import { Tools, CommandType, ICommandService, IUndoRedoService, RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, InterceptorEffectEnum, toDisposable, remove, composeInterceptors, DisposableCollection, normalizeTextRuns, CellValueType, isRealNum, isBooleanString, isSafeNumeric, ObjectMatrix, sequenceExecute, LocaleService, createIdentifier, IContextService, selectionToArray, Rectangle, RANGE_TYPE, ErrorService, Range, cellToRange, PermissionStatus, IPermissionService, isICellData, Dimension, getArrayLength, insertMatrixArray, spliceArray, sliceMatrixArray, concatMatrixArray, BooleanNumber, Direction, mergeWorksheetSnapshotWithDefault, moveMatrixArray, BorderType, BorderStyleTypes, FontWeight, FontItalic, Inject, Injector, IResourceManagerService, Optional, IConfigService, queryObjectMatrix, InterceptorManager, LRUMap, ILogService, DependentOn, Plugin, registerDependencies, mergeOverrideWithDependencies, touchDependencies, ColorKit, getCellInfoInMergeData, makeCellRangeToRangeData, createRowColIter } from "@univerjs/core";
|
|
6
|
+
import { SetDefinedNameMutation, RemoveDefinedNameMutation, SetDefinedNameMutationFactory, SetFormulaCalculationResultMutation, handleNumfmtInCell, IDefinedNamesService, stripErrorMargin, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
|
|
7
7
|
import { DataSyncPrimaryController } from "@univerjs/rpc";
|
|
8
|
-
import { shareReplay, takeUntil, switchMap, of,
|
|
8
|
+
import { Subject, BehaviorSubject, shareReplay, takeUntil, switchMap, of, merge, map, first, filter } from "rxjs";
|
|
9
9
|
import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
|
|
10
10
|
import { takeUntil as takeUntil$1, filter as filter$1, map as map$1 } from "rxjs/operators";
|
|
11
11
|
import { RangeProtectionRuleModel as RangeProtectionRuleModel$1, WorkbookEditablePermission as WorkbookEditablePermission$1, WorksheetEditPermission as WorksheetEditPermission$1, RangeProtectionPermissionEditPoint as RangeProtectionPermissionEditPoint$1 } from "@univerjs/sheets";
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const _RangeProtectionRuleModel = class _RangeProtectionRuleModel {
|
|
13
|
+
constructor() {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* Map<unitId, Map<subUnitId, Map<ruleId, IRangeProtectionRule>>>
|
|
17
|
+
*/
|
|
18
|
+
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
19
|
+
__publicField(this, "_ruleChange", new Subject());
|
|
20
|
+
__publicField(this, "ruleChange$", this._ruleChange.asObservable());
|
|
21
|
+
__publicField(this, "_ruleRefresh", new Subject());
|
|
22
|
+
__publicField(this, "ruleRefresh$", this._ruleRefresh.asObservable());
|
|
23
|
+
__publicField(this, "_rangeRuleInitStateChange", new BehaviorSubject(!1));
|
|
24
|
+
__publicField(this, "rangeRuleInitStateChange$", this._rangeRuleInitStateChange.asObservable());
|
|
25
|
+
}
|
|
26
|
+
ruleRefresh(id) {
|
|
27
|
+
this._ruleRefresh.next(id);
|
|
28
|
+
}
|
|
29
|
+
getRangeRuleInitState() {
|
|
30
|
+
return this._rangeRuleInitStateChange.value;
|
|
31
|
+
}
|
|
32
|
+
changeRuleInitState(state) {
|
|
33
|
+
this._rangeRuleInitStateChange.next(state);
|
|
34
|
+
}
|
|
35
|
+
addRule(unitId, subUnitId, rule) {
|
|
36
|
+
this._ensureRuleMap(unitId, subUnitId).set(rule.id, rule), this._ruleChange.next({ unitId, subUnitId, rule, type: "add" });
|
|
37
|
+
}
|
|
38
|
+
deleteRule(unitId, subUnitId, id) {
|
|
39
|
+
var _a18, _b, _c, _d;
|
|
40
|
+
const rule = (_b = (_a18 = this._model.get(unitId)) == null ? void 0 : _a18.get(subUnitId)) == null ? void 0 : _b.get(id);
|
|
41
|
+
rule && ((_d = (_c = this._model.get(unitId)) == null ? void 0 : _c.get(subUnitId)) == null || _d.delete(id), this._ruleChange.next({ unitId, subUnitId, rule, type: "delete" }));
|
|
42
|
+
}
|
|
43
|
+
setRule(unitId, subUnitId, id, rule) {
|
|
44
|
+
var _a18, _b;
|
|
45
|
+
const oldRule = this.getRule(unitId, subUnitId, id);
|
|
46
|
+
oldRule && ((_b = (_a18 = this._model.get(unitId)) == null ? void 0 : _a18.get(subUnitId)) == null || _b.set(id, rule), this._ruleChange.next({ unitId, subUnitId, oldRule, rule, type: "set" }));
|
|
47
|
+
}
|
|
48
|
+
getRule(unitId, subUnitId, id) {
|
|
49
|
+
var _a18, _b;
|
|
50
|
+
return (_b = (_a18 = this._model.get(unitId)) == null ? void 0 : _a18.get(subUnitId)) == null ? void 0 : _b.get(id);
|
|
51
|
+
}
|
|
52
|
+
getSubunitRuleList(unitId, subUnitId) {
|
|
53
|
+
var _a18;
|
|
54
|
+
return [...(((_a18 = this._model.get(unitId)) == null ? void 0 : _a18.get(subUnitId)) || /* @__PURE__ */ new Map()).values()];
|
|
55
|
+
}
|
|
56
|
+
getSubunitRuleListLength(unitId, subUnitId) {
|
|
57
|
+
var _a18;
|
|
58
|
+
const map2 = (_a18 = this._model.get(unitId)) == null ? void 0 : _a18.get(subUnitId);
|
|
59
|
+
return map2 ? map2.size : 0;
|
|
60
|
+
}
|
|
61
|
+
_ensureRuleMap(unitId, subUnitId) {
|
|
62
|
+
let subUnitMap = this._model.get(unitId);
|
|
63
|
+
subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._model.set(unitId, subUnitMap));
|
|
64
|
+
let ruleMap = subUnitMap.get(subUnitId);
|
|
65
|
+
return ruleMap || (ruleMap = /* @__PURE__ */ new Map(), subUnitMap.set(subUnitId, ruleMap)), ruleMap;
|
|
66
|
+
}
|
|
67
|
+
toObject() {
|
|
68
|
+
const result = {};
|
|
69
|
+
return [...this._model.keys()].forEach((unitId) => {
|
|
70
|
+
const submitMap = this._model.get(unitId), subUnitKeys = [...submitMap.keys()];
|
|
71
|
+
result[unitId] = {}, subUnitKeys.forEach((subunitId) => {
|
|
72
|
+
const ruleMap = submitMap.get(subunitId);
|
|
73
|
+
result[unitId][subunitId] = [...ruleMap.values()];
|
|
74
|
+
});
|
|
75
|
+
}), result;
|
|
76
|
+
}
|
|
77
|
+
fromObject(obj) {
|
|
78
|
+
const result = /* @__PURE__ */ new Map();
|
|
79
|
+
Object.keys(obj).forEach((unitId) => {
|
|
80
|
+
const subUnitObj = obj[unitId], map2 = /* @__PURE__ */ new Map();
|
|
81
|
+
Object.keys(subUnitObj).forEach((subunitId) => {
|
|
82
|
+
const ruleMap = subUnitObj[subunitId].reduce((result2, cur) => (result2.set(cur.id, cur), result2), /* @__PURE__ */ new Map());
|
|
83
|
+
map2.set(subunitId, ruleMap);
|
|
84
|
+
}), result.set(unitId, map2);
|
|
85
|
+
}), this._model = result;
|
|
86
|
+
}
|
|
87
|
+
deleteUnitModel(unitId) {
|
|
88
|
+
this._model.delete(unitId);
|
|
89
|
+
}
|
|
90
|
+
createRuleId(unitId, subUnitId) {
|
|
91
|
+
let id = Tools.generateRandomId(4);
|
|
92
|
+
const ruleMap = this._ensureRuleMap(unitId, subUnitId);
|
|
93
|
+
for (; ruleMap.has(id); )
|
|
94
|
+
id = Tools.generateRandomId(4);
|
|
95
|
+
return id;
|
|
96
|
+
}
|
|
97
|
+
getTargetByPermissionId(unitId, permissionId) {
|
|
98
|
+
const subUnitMap = this._model.get(unitId);
|
|
99
|
+
if (!subUnitMap) return null;
|
|
100
|
+
for (const [subUnitId, ruleMap] of subUnitMap)
|
|
101
|
+
for (const rule of ruleMap.values())
|
|
102
|
+
if (rule.permissionId === permissionId)
|
|
103
|
+
return [unitId, subUnitId];
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
__name(_RangeProtectionRuleModel, "RangeProtectionRuleModel");
|
|
108
|
+
let RangeProtectionRuleModel = _RangeProtectionRuleModel;
|
|
109
|
+
const FactoryDeleteRangeProtectionMutation = /* @__PURE__ */ __name((accessor, param) => {
|
|
110
|
+
const selectionProtectionRuleModel = accessor.get(RangeProtectionRuleModel), rules = param.ruleIds.map((id) => selectionProtectionRuleModel.getRule(param.unitId, param.subUnitId, id)).filter((rule) => !!rule);
|
|
111
|
+
return { id: AddRangeProtectionMutation.id, params: { subUnitId: param.subUnitId, unitId: param.unitId, rules } };
|
|
112
|
+
}, "FactoryDeleteRangeProtectionMutation"), DeleteRangeProtectionMutation = {
|
|
113
|
+
id: "sheet.mutation.delete-range-protection",
|
|
114
|
+
type: CommandType.MUTATION,
|
|
115
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
116
|
+
const { unitId, subUnitId, ruleIds } = params, selectionProtectionRuleModel = accessor.get(RangeProtectionRuleModel);
|
|
117
|
+
return ruleIds.forEach((id) => {
|
|
118
|
+
selectionProtectionRuleModel.deleteRule(unitId, subUnitId, id);
|
|
119
|
+
}), !0;
|
|
120
|
+
}, "handler")
|
|
121
|
+
}, FactoryAddRangeProtectionMutation = /* @__PURE__ */ __name((param) => {
|
|
122
|
+
const deleteParams = { ...param, ruleIds: param.rules.map((rule) => rule.id) };
|
|
123
|
+
return { id: DeleteRangeProtectionMutation.id, params: deleteParams };
|
|
124
|
+
}, "FactoryAddRangeProtectionMutation"), AddRangeProtectionMutation = {
|
|
125
|
+
id: "sheet.mutation.add-range-protection",
|
|
126
|
+
type: CommandType.MUTATION,
|
|
127
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
128
|
+
const { unitId, subUnitId, rules } = params, selectionProtectionRuleModel = accessor.get(RangeProtectionRuleModel);
|
|
129
|
+
return rules.forEach((rule) => {
|
|
130
|
+
selectionProtectionRuleModel.addRule(unitId, subUnitId, rule);
|
|
131
|
+
}), !0;
|
|
132
|
+
}, "handler")
|
|
133
|
+
}, AddRangeProtectionCommand = {
|
|
134
|
+
type: CommandType.COMMAND,
|
|
135
|
+
id: "sheet.command.add-range-protection",
|
|
136
|
+
async handler(accessor, params) {
|
|
137
|
+
if (!params)
|
|
138
|
+
return !1;
|
|
139
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionProtectionModel = accessor.get(RangeProtectionRuleModel), { rule, permissionId } = params, { unitId, subUnitId, ranges, name, description } = rule, rules = [{
|
|
140
|
+
ranges,
|
|
141
|
+
permissionId,
|
|
142
|
+
id: selectionProtectionModel.createRuleId(unitId, subUnitId),
|
|
143
|
+
name,
|
|
144
|
+
description,
|
|
145
|
+
unitType: rule.unitType,
|
|
146
|
+
unitId,
|
|
147
|
+
subUnitId
|
|
148
|
+
}];
|
|
149
|
+
if (await commandService.executeCommand(AddRangeProtectionMutation.id, {
|
|
150
|
+
unitId,
|
|
151
|
+
subUnitId,
|
|
152
|
+
rules
|
|
153
|
+
})) {
|
|
154
|
+
const redoMutations = [{ id: AddRangeProtectionMutation.id, params: { unitId, subUnitId, rules } }], undoMutations = [{ id: DeleteRangeProtectionMutation.id, params: { unitId, subUnitId, ruleIds: rules.map((rule2) => rule2.id) } }];
|
|
155
|
+
undoRedoService.pushUndoRedo({
|
|
156
|
+
unitID: unitId,
|
|
157
|
+
redoMutations,
|
|
158
|
+
undoMutations
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return !0;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
165
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
166
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
15
|
-
return kind && result && __defProp$
|
|
16
|
-
}, "__decorateClass$
|
|
167
|
+
return kind && result && __defProp$g(target, key, result), result;
|
|
168
|
+
}, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g"), SelectionMoveType = /* @__PURE__ */ ((SelectionMoveType2) => (SelectionMoveType2[SelectionMoveType2.MOVE_START = 0] = "MOVE_START", SelectionMoveType2[SelectionMoveType2.MOVING = 1] = "MOVING", SelectionMoveType2[SelectionMoveType2.MOVE_END = 2] = "MOVE_END", SelectionMoveType2))(SelectionMoveType || {}), _a;
|
|
17
169
|
let SheetsSelectionsService = (_a = class extends RxDisposable {
|
|
18
170
|
constructor(_instanceSrv) {
|
|
19
171
|
super();
|
|
@@ -130,7 +282,7 @@ let SheetsSelectionsService = (_a = class extends RxDisposable {
|
|
|
130
282
|
this._workbookSelections.delete(unitId);
|
|
131
283
|
}
|
|
132
284
|
}, __name(_a, "SheetsSelectionsService"), _a);
|
|
133
|
-
SheetsSelectionsService = __decorateClass$
|
|
285
|
+
SheetsSelectionsService = __decorateClass$g([
|
|
134
286
|
__decorateParam$g(0, IUniverInstanceService)
|
|
135
287
|
], SheetsSelectionsService);
|
|
136
288
|
const _WorkbookSelections = class _WorkbookSelections extends Disposable {
|
|
@@ -213,11 +365,11 @@ const DISABLE_NORMAL_SELECTIONS = "DISABLE_NORMAL_SELECTIONS", CELL_CONTENT = cr
|
|
|
213
365
|
CELL_CONTENT,
|
|
214
366
|
ROW_FILTERED
|
|
215
367
|
};
|
|
216
|
-
var InterceptCellContentPriority = /* @__PURE__ */ ((InterceptCellContentPriority2) => (InterceptCellContentPriority2[InterceptCellContentPriority2.DATA_VALIDATION = 9] = "DATA_VALIDATION", InterceptCellContentPriority2[InterceptCellContentPriority2.NUMFMT = 10] = "NUMFMT", InterceptCellContentPriority2))(InterceptCellContentPriority || {}), __defProp$
|
|
217
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
368
|
+
var InterceptCellContentPriority = /* @__PURE__ */ ((InterceptCellContentPriority2) => (InterceptCellContentPriority2[InterceptCellContentPriority2.DATA_VALIDATION = 9] = "DATA_VALIDATION", InterceptCellContentPriority2[InterceptCellContentPriority2.NUMFMT = 10] = "NUMFMT", InterceptCellContentPriority2))(InterceptCellContentPriority || {}), __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
369
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
218
370
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
219
|
-
return kind && result && __defProp$
|
|
220
|
-
}, "__decorateClass$
|
|
371
|
+
return kind && result && __defProp$f(target, key, result), result;
|
|
372
|
+
}, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a2;
|
|
221
373
|
let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
222
374
|
/** @ignore */
|
|
223
375
|
constructor(_univerInstanceService) {
|
|
@@ -248,8 +400,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
248
400
|
if (this._commandInterceptors.includes(interceptor))
|
|
249
401
|
throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
250
402
|
return this._commandInterceptors.push(interceptor), this._commandInterceptors.sort((a, b) => {
|
|
251
|
-
var
|
|
252
|
-
return ((
|
|
403
|
+
var _a18, _b;
|
|
404
|
+
return ((_a18 = b.priority) != null ? _a18 : 0) - ((_b = a.priority) != null ? _b : 0);
|
|
253
405
|
}), this.disposeWithMe(toDisposable(() => remove(this._commandInterceptors, interceptor)));
|
|
254
406
|
}
|
|
255
407
|
// Add a listener function to the command, which will be run before the command is run to get whether it can be executed the command
|
|
@@ -257,8 +409,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
257
409
|
if (this._beforeCommandInterceptor.includes(interceptor))
|
|
258
410
|
throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
259
411
|
return this._beforeCommandInterceptor.push(interceptor), this._beforeCommandInterceptor.sort((a, b) => {
|
|
260
|
-
var
|
|
261
|
-
return ((
|
|
412
|
+
var _a18, _b;
|
|
413
|
+
return ((_a18 = b.priority) != null ? _a18 : 0) - ((_b = a.priority) != null ? _b : 0);
|
|
262
414
|
}), this.disposeWithMe(toDisposable(() => remove(this._beforeCommandInterceptor, interceptor)));
|
|
263
415
|
}
|
|
264
416
|
/**
|
|
@@ -278,8 +430,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
278
430
|
if (this._rangeInterceptors.includes(interceptor))
|
|
279
431
|
throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
280
432
|
return this._rangeInterceptors.push(interceptor), this._rangeInterceptors.sort((a, b) => {
|
|
281
|
-
var
|
|
282
|
-
return ((
|
|
433
|
+
var _a18, _b;
|
|
434
|
+
return ((_a18 = b.priority) != null ? _a18 : 0) - ((_b = a.priority) != null ? _b : 0);
|
|
283
435
|
}), this.disposeWithMe(toDisposable(() => remove(this._rangeInterceptors, interceptor)));
|
|
284
436
|
}
|
|
285
437
|
/**
|
|
@@ -291,13 +443,13 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
291
443
|
const infos = this._commandInterceptors.map((i) => i.getMutations(info));
|
|
292
444
|
return {
|
|
293
445
|
preUndos: infos.map((i) => {
|
|
294
|
-
var
|
|
295
|
-
return (
|
|
446
|
+
var _a18;
|
|
447
|
+
return (_a18 = i.preUndos) != null ? _a18 : [];
|
|
296
448
|
}).flat(),
|
|
297
449
|
undos: infos.map((i) => i.undos).flat(),
|
|
298
450
|
preRedos: infos.map((i) => {
|
|
299
|
-
var
|
|
300
|
-
return (
|
|
451
|
+
var _a18;
|
|
452
|
+
return (_a18 = i.preRedos) != null ? _a18 : [];
|
|
301
453
|
}).flat(),
|
|
302
454
|
redos: infos.map((i) => i.redos).flat()
|
|
303
455
|
};
|
|
@@ -306,13 +458,13 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
306
458
|
const infos = this._rangeInterceptors.map((i) => i.getMutations(info));
|
|
307
459
|
return {
|
|
308
460
|
preUndos: infos.map((i) => {
|
|
309
|
-
var
|
|
310
|
-
return (
|
|
461
|
+
var _a18;
|
|
462
|
+
return (_a18 = i.preUndos) != null ? _a18 : [];
|
|
311
463
|
}).flat(),
|
|
312
464
|
undos: infos.map((i) => i.undos).flat(),
|
|
313
465
|
preRedos: infos.map((i) => {
|
|
314
|
-
var
|
|
315
|
-
return (
|
|
466
|
+
var _a18;
|
|
467
|
+
return (_a18 = i.preRedos) != null ? _a18 : [];
|
|
316
468
|
}).flat(),
|
|
317
469
|
redos: infos.map((i) => i.redos).flat()
|
|
318
470
|
};
|
|
@@ -323,8 +475,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
323
475
|
const interceptors = this._interceptorsByName.get(key);
|
|
324
476
|
interceptors.push(interceptor);
|
|
325
477
|
const sortedInterceptors = interceptors.sort((a, b) => {
|
|
326
|
-
var
|
|
327
|
-
return ((
|
|
478
|
+
var _a18, _b;
|
|
479
|
+
return ((_a18 = b.priority) != null ? _a18 : 0) - ((_b = a.priority) != null ? _b : 0);
|
|
328
480
|
});
|
|
329
481
|
return key === INTERCEPTOR_POINT.CELL_CONTENT ? (this._interceptorsByName.set(
|
|
330
482
|
`${key}-${InterceptorEffectEnum.Style | InterceptorEffectEnum.Value}`,
|
|
@@ -392,7 +544,7 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
|
|
|
392
544
|
disposable && (disposable.dispose(), this._worksheetDisposables.delete(disposableId));
|
|
393
545
|
}
|
|
394
546
|
}, __name(_a2, "SheetInterceptorService"), _a2);
|
|
395
|
-
SheetInterceptorService = __decorateClass$
|
|
547
|
+
SheetInterceptorService = __decorateClass$f([
|
|
396
548
|
__decorateParam$f(0, IUniverInstanceService)
|
|
397
549
|
], SheetInterceptorService);
|
|
398
550
|
function getWorksheetDisposableID(unitId, worksheet) {
|
|
@@ -400,14 +552,14 @@ function getWorksheetDisposableID(unitId, worksheet) {
|
|
|
400
552
|
}
|
|
401
553
|
__name(getWorksheetDisposableID, "getWorksheetDisposableID");
|
|
402
554
|
function handleStyle(styles, oldVal, newVal) {
|
|
403
|
-
var
|
|
555
|
+
var _a18;
|
|
404
556
|
const oldStyle = styles.getStyleByCell(oldVal);
|
|
405
557
|
oldStyle == null && delete oldVal.s, typeof newVal.s == "string" && (newVal.s = styles.get(newVal.s));
|
|
406
558
|
const merge2 = mergeStyle(oldStyle, newVal.s ? newVal.s : null);
|
|
407
559
|
merge2 && Tools.removeNull(merge2), Tools.isEmptyObject(merge2) ? delete oldVal.s : oldVal.s = styles.setValue(merge2);
|
|
408
560
|
const newValueStream = newVal.v ? `${newVal.v}\r
|
|
409
561
|
` : "";
|
|
410
|
-
!newVal.p && oldVal.p && (newValueStream && newValueStream !== ((
|
|
562
|
+
!newVal.p && oldVal.p && (newValueStream && newValueStream !== ((_a18 = oldVal.p.body) == null ? void 0 : _a18.dataStream) ? delete oldVal.p : mergeRichTextStyle(oldVal.p, newVal.s ? newVal.s : null));
|
|
411
563
|
}
|
|
412
564
|
__name(handleStyle, "handleStyle");
|
|
413
565
|
function transformStyle(oldStyle, newStyle) {
|
|
@@ -441,12 +593,12 @@ function skipParagraphs(paragraphs, offset) {
|
|
|
441
593
|
}
|
|
442
594
|
__name(skipParagraphs, "skipParagraphs");
|
|
443
595
|
function mergeRichTextStyle(p, newStyle) {
|
|
444
|
-
var
|
|
596
|
+
var _a18;
|
|
445
597
|
if (p.body == null)
|
|
446
598
|
return;
|
|
447
599
|
Array.isArray(p.body.textRuns) || (p.body.textRuns = []);
|
|
448
600
|
let index = 0;
|
|
449
|
-
const newTextRuns = [], paragraphs = ((
|
|
601
|
+
const newTextRuns = [], paragraphs = ((_a18 = p.body) == null ? void 0 : _a18.paragraphs) || [];
|
|
450
602
|
for (const textRun of p.body.textRuns) {
|
|
451
603
|
const { st, ed, ts = {} } = textRun;
|
|
452
604
|
if (index < st) {
|
|
@@ -492,13 +644,13 @@ function checkCellValueTypeByValue(newVal, oldVal) {
|
|
|
492
644
|
}
|
|
493
645
|
__name(checkCellValueTypeByValue, "checkCellValueTypeByValue");
|
|
494
646
|
function hasNumberFormat(style) {
|
|
495
|
-
var
|
|
496
|
-
return !!((
|
|
647
|
+
var _a18;
|
|
648
|
+
return !!((_a18 = style == null ? void 0 : style.n) != null && _a18.pattern);
|
|
497
649
|
}
|
|
498
650
|
__name(hasNumberFormat, "hasNumberFormat");
|
|
499
651
|
function isTextFormat(style) {
|
|
500
|
-
var
|
|
501
|
-
return ((
|
|
652
|
+
var _a18;
|
|
653
|
+
return ((_a18 = style == null ? void 0 : style.n) == null ? void 0 : _a18.pattern) === DEFAULT_TEXT_FORMAT;
|
|
502
654
|
}
|
|
503
655
|
__name(isTextFormat, "isTextFormat");
|
|
504
656
|
function checkCellValueType(v, type) {
|
|
@@ -629,12 +781,12 @@ const ClearSelectionAllCommand = {
|
|
|
629
781
|
id: "sheet.command.clear-selection-all",
|
|
630
782
|
type: CommandType.COMMAND,
|
|
631
783
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
632
|
-
var
|
|
784
|
+
var _a18;
|
|
633
785
|
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
634
786
|
if (!workbook) return !1;
|
|
635
787
|
const unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
|
|
636
788
|
if (!worksheet) return !1;
|
|
637
|
-
const subUnitId = worksheet.getSheetId(), selections = (
|
|
789
|
+
const subUnitId = worksheet.getSheetId(), selections = (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
638
790
|
if (!(selections != null && selections.length))
|
|
639
791
|
return !1;
|
|
640
792
|
const sequenceExecuteList = [], sequenceExecuteUndoList = [], clearMutationParams = {
|
|
@@ -665,12 +817,12 @@ const ClearSelectionAllCommand = {
|
|
|
665
817
|
id: "sheet.command.clear-selection-content",
|
|
666
818
|
type: CommandType.COMMAND,
|
|
667
819
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
668
|
-
var
|
|
820
|
+
var _a18;
|
|
669
821
|
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
670
822
|
if (!workbook) return !1;
|
|
671
823
|
const unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
|
|
672
824
|
if (!worksheet) return !1;
|
|
673
|
-
const subUnitId = worksheet.getSheetId(), selections = (
|
|
825
|
+
const subUnitId = worksheet.getSheetId(), selections = (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
674
826
|
if (!(selections != null && selections.length))
|
|
675
827
|
return !1;
|
|
676
828
|
const clearMutationParams = {
|
|
@@ -693,12 +845,12 @@ const ClearSelectionAllCommand = {
|
|
|
693
845
|
id: "sheet.command.clear-selection-format",
|
|
694
846
|
type: CommandType.COMMAND,
|
|
695
847
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
696
|
-
var
|
|
848
|
+
var _a18;
|
|
697
849
|
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
698
850
|
if (!workbook) return !1;
|
|
699
851
|
const unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
|
|
700
852
|
if (!worksheet) return !1;
|
|
701
|
-
const subUnitId = worksheet.getSheetId(), selections = (
|
|
853
|
+
const subUnitId = worksheet.getSheetId(), selections = (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
702
854
|
if (!(selections != null && selections.length))
|
|
703
855
|
return !1;
|
|
704
856
|
const sequenceExecuteList = [], sequenceExecuteUndoList = [], clearMutationParams = {
|
|
@@ -788,7 +940,7 @@ const RemoveSheetUndoMutationFactory = /* @__PURE__ */ __name((accessor, params)
|
|
|
788
940
|
type: CommandType.COMMAND,
|
|
789
941
|
id: "sheet.command.copy-sheet",
|
|
790
942
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
791
|
-
var
|
|
943
|
+
var _a18, _b;
|
|
792
944
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), localeService = accessor.get(LocaleService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
793
945
|
if (!target)
|
|
794
946
|
return !1;
|
|
@@ -805,7 +957,7 @@ const RemoveSheetUndoMutationFactory = /* @__PURE__ */ __name((accessor, params)
|
|
|
805
957
|
id: CopySheetCommand.id,
|
|
806
958
|
params: { unitId, subUnitId, targetSubUnitId: config.id }
|
|
807
959
|
}), redos = [
|
|
808
|
-
...(
|
|
960
|
+
...(_a18 = intercepted.preRedos) != null ? _a18 : [],
|
|
809
961
|
{ id: InsertSheetMutation.id, params: insertSheetMutationParams },
|
|
810
962
|
...intercepted.redos
|
|
811
963
|
], undos = [
|
|
@@ -848,11 +1000,11 @@ const MoveRangeMutation = {
|
|
|
848
1000
|
}), !0;
|
|
849
1001
|
}, "handler")
|
|
850
1002
|
};
|
|
851
|
-
var __defProp$
|
|
852
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1003
|
+
var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1004
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
853
1005
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
854
|
-
return kind && result && __defProp$
|
|
855
|
-
}, "__decorateClass$
|
|
1006
|
+
return kind && result && __defProp$e(target, key, result), result;
|
|
1007
|
+
}, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e");
|
|
856
1008
|
const IRefSelectionsService = createIdentifier("sheets-formula.ref-selections.service");
|
|
857
1009
|
var _a3;
|
|
858
1010
|
let RefSelectionsService = (_a3 = class extends SheetsSelectionsService {
|
|
@@ -874,7 +1026,7 @@ let RefSelectionsService = (_a3 = class extends SheetsSelectionsService {
|
|
|
874
1026
|
})), workbooks$.pipe(map((workbooks) => workbooks.map((w) => this._ensureWorkbookSelection(w.getUnitId()))));
|
|
875
1027
|
}
|
|
876
1028
|
}, __name(_a3, "RefSelectionsService"), _a3);
|
|
877
|
-
RefSelectionsService = __decorateClass$
|
|
1029
|
+
RefSelectionsService = __decorateClass$e([
|
|
878
1030
|
__decorateParam$e(0, IUniverInstanceService)
|
|
879
1031
|
], RefSelectionsService);
|
|
880
1032
|
function getSelectionsService(accessor) {
|
|
@@ -1006,7 +1158,7 @@ const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
|
|
|
1006
1158
|
type: CommandType.COMMAND,
|
|
1007
1159
|
id: MoveRangeCommandId,
|
|
1008
1160
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1009
|
-
var
|
|
1161
|
+
var _a18, _b;
|
|
1010
1162
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
|
|
1011
1163
|
if (!target || !await sheetInterceptorService.beforeCommandExecute({ id: MoveRangeCommand.id, params }))
|
|
1012
1164
|
return !1;
|
|
@@ -1021,7 +1173,7 @@ const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
|
|
|
1021
1173
|
id: MoveRangeCommand.id,
|
|
1022
1174
|
params: { ...params }
|
|
1023
1175
|
}), redos = [
|
|
1024
|
-
...(
|
|
1176
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
1025
1177
|
...moveRangeMutations.redos,
|
|
1026
1178
|
...interceptorCommands.redos,
|
|
1027
1179
|
{
|
|
@@ -1581,10 +1733,10 @@ const SetRangeValuesCommand = {
|
|
|
1581
1733
|
id: "sheet.command.set-range-values",
|
|
1582
1734
|
type: CommandType.COMMAND,
|
|
1583
1735
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
1584
|
-
var
|
|
1736
|
+
var _a18;
|
|
1585
1737
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), permissionService = accessor.get(IPermissionService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
1586
1738
|
if (!target) return !1;
|
|
1587
|
-
const { subUnitId, unitId, workbook, worksheet } = target, { value, range } = params, currentSelections = range ? [range] : (
|
|
1739
|
+
const { subUnitId, unitId, workbook, worksheet } = target, { value, range } = params, currentSelections = range ? [range] : (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
1588
1740
|
if (!currentSelections || !currentSelections.length || !permissionService.getPermissionPoint(new WorksheetEditPermission(unitId, subUnitId).id)) return !1;
|
|
1589
1741
|
const cellValue = new ObjectMatrix();
|
|
1590
1742
|
let realCellValue;
|
|
@@ -1822,12 +1974,12 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1822
1974
|
type: CommandType.COMMAND,
|
|
1823
1975
|
id: DeleteRangeMoveLeftCommandId,
|
|
1824
1976
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1825
|
-
var
|
|
1977
|
+
var _a18, _b, _c;
|
|
1826
1978
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
|
|
1827
1979
|
if (!target) return !1;
|
|
1828
1980
|
const { worksheet, workbook, subUnitId, unitId } = target;
|
|
1829
1981
|
let range = params == null ? void 0 : params.range;
|
|
1830
|
-
if (range || (range = (
|
|
1982
|
+
if (range || (range = (_a18 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a18.range), !range) return !1;
|
|
1831
1983
|
const deleteRangeMutationParams = {
|
|
1832
1984
|
range,
|
|
1833
1985
|
subUnitId,
|
|
@@ -1852,12 +2004,12 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1852
2004
|
type: CommandType.COMMAND,
|
|
1853
2005
|
id: DeleteRangeMoveUpCommandId,
|
|
1854
2006
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1855
|
-
var
|
|
2007
|
+
var _a18, _b, _c;
|
|
1856
2008
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
|
|
1857
2009
|
if (!target) return !1;
|
|
1858
2010
|
const { unitId, subUnitId, workbook, worksheet } = target;
|
|
1859
2011
|
let range = params == null ? void 0 : params.range;
|
|
1860
|
-
if (range || (range = (
|
|
2012
|
+
if (range || (range = (_a18 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a18.range), !range) return !1;
|
|
1861
2013
|
const deleteRangeMutationParams = {
|
|
1862
2014
|
range,
|
|
1863
2015
|
subUnitId,
|
|
@@ -1878,6 +2030,38 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1878
2030
|
}, "handler")
|
|
1879
2031
|
// all subsequent mutations should succeed inorder to make the whole process succeed
|
|
1880
2032
|
// Promise.all([]).then(() => true),
|
|
2033
|
+
}, DeleteRangeProtectionCommand = {
|
|
2034
|
+
type: CommandType.COMMAND,
|
|
2035
|
+
id: "sheet.command.delete-range-protection",
|
|
2036
|
+
async handler(accessor, params) {
|
|
2037
|
+
if (!params)
|
|
2038
|
+
return !1;
|
|
2039
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), { unitId, subUnitId, rule } = params, redoMutationParam = {
|
|
2040
|
+
unitId,
|
|
2041
|
+
subUnitId,
|
|
2042
|
+
ruleIds: [rule.id]
|
|
2043
|
+
};
|
|
2044
|
+
return await commandService.executeCommand(DeleteRangeProtectionMutation.id, redoMutationParam) && undoRedoService.pushUndoRedo({
|
|
2045
|
+
unitID: unitId,
|
|
2046
|
+
redoMutations: [{ id: DeleteRangeProtectionMutation.id, params: redoMutationParam }],
|
|
2047
|
+
undoMutations: [{ id: AddRangeProtectionMutation.id, params: { unitId, subUnitId, rules: [rule] } }]
|
|
2048
|
+
}), !0;
|
|
2049
|
+
}
|
|
2050
|
+
}, InsertDefinedNameCommand = {
|
|
2051
|
+
id: "sheet.command.insert-defined-name",
|
|
2052
|
+
type: CommandType.COMMAND,
|
|
2053
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
2054
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
2055
|
+
if (!params) return !1;
|
|
2056
|
+
const insertSheetMutationParams = {
|
|
2057
|
+
...params
|
|
2058
|
+
};
|
|
2059
|
+
return commandService.syncExecuteCommand(SetDefinedNameMutation.id, insertSheetMutationParams) ? (undoRedoService.pushUndoRedo({
|
|
2060
|
+
unitID: params.unitId,
|
|
2061
|
+
undoMutations: [{ id: RemoveDefinedNameMutation.id, params: insertSheetMutationParams }],
|
|
2062
|
+
redoMutations: [{ id: SetDefinedNameMutation.id, params: insertSheetMutationParams }]
|
|
2063
|
+
}), !0) : !1;
|
|
2064
|
+
}, "handler")
|
|
1881
2065
|
}, InsertRowMutationUndoFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
1882
2066
|
if (accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId) == null)
|
|
1883
2067
|
throw new Error("universheet is null error!");
|
|
@@ -1890,7 +2074,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1890
2074
|
id: "sheet.mutation.insert-row",
|
|
1891
2075
|
type: CommandType.MUTATION,
|
|
1892
2076
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
1893
|
-
var
|
|
2077
|
+
var _a18;
|
|
1894
2078
|
const { unitId, subUnitId, range, rowInfo } = params, universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(unitId);
|
|
1895
2079
|
if (universheet == null)
|
|
1896
2080
|
throw new Error("universheet is null error!");
|
|
@@ -1902,7 +2086,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1902
2086
|
hd: 0
|
|
1903
2087
|
}, rowIndex = range.startRow, rowCount = range.endRow - range.startRow + 1;
|
|
1904
2088
|
for (let j = rowIndex; j < rowIndex + rowCount; j++)
|
|
1905
|
-
rowInfo ? insertMatrixArray(j, (
|
|
2089
|
+
rowInfo ? insertMatrixArray(j, (_a18 = rowInfo[j - range.startRow]) != null ? _a18 : defaultRowInfo, rowWrapper) : insertMatrixArray(j, defaultRowInfo, rowWrapper);
|
|
1906
2090
|
return worksheet.setRowCount(worksheet.getRowCount() + range.endRow - range.startRow + 1), worksheet.getCellMatrix().insertRows(range.startRow, rowCount), !0;
|
|
1907
2091
|
}, "handler")
|
|
1908
2092
|
}, InsertColMutationUndoFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
@@ -1917,7 +2101,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1917
2101
|
id: "sheet.mutation.insert-col",
|
|
1918
2102
|
type: CommandType.MUTATION,
|
|
1919
2103
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
1920
|
-
var
|
|
2104
|
+
var _a18;
|
|
1921
2105
|
const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);
|
|
1922
2106
|
if (universheet == null)
|
|
1923
2107
|
throw new Error("universheet is null error!");
|
|
@@ -1929,7 +2113,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1929
2113
|
w: defaultColWidth,
|
|
1930
2114
|
hd: 0
|
|
1931
2115
|
};
|
|
1932
|
-
colInfo ? insertMatrixArray(j, (
|
|
2116
|
+
colInfo ? insertMatrixArray(j, (_a18 = colInfo[j - range.startColumn]) != null ? _a18 : defaultColInfo, columnWrapper) : insertMatrixArray(j, defaultColInfo, columnWrapper);
|
|
1933
2117
|
}
|
|
1934
2118
|
return worksheet.setColumnCount(worksheet.getColumnCount() + range.endColumn - range.startColumn + 1), worksheet.getCellMatrix().insertColumns(range.startColumn, colCount), !0;
|
|
1935
2119
|
}, "handler")
|
|
@@ -1987,7 +2171,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1987
2171
|
id: "sheet.command.insert-range-move-down",
|
|
1988
2172
|
// eslint-disable-next-line max-lines-per-function
|
|
1989
2173
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1990
|
-
var
|
|
2174
|
+
var _a18, _b, _c;
|
|
1991
2175
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService);
|
|
1992
2176
|
if (selectionManagerService.isOverlapping())
|
|
1993
2177
|
return errorService.emit(localeService.t("sheets.info.overlappingSelections")), !1;
|
|
@@ -1995,7 +2179,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
1995
2179
|
if (!target) return !1;
|
|
1996
2180
|
const { unitId, subUnitId, worksheet, workbook } = target;
|
|
1997
2181
|
let range = params == null ? void 0 : params.range;
|
|
1998
|
-
if (range || (range = (
|
|
2182
|
+
if (range || (range = (_a18 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a18.range), !range) return !1;
|
|
1999
2183
|
const redoMutations = [], undoMutations = [], cellMatrix = worksheet.getCellMatrix(), dataRange = cellMatrix.getDataRange(), sliceMaxRow = cellMatrix.getSlice(dataRange.startRow, dataRange.endRow, range.startColumn, range.endColumn).getDataRange().endRow, insertRowCount = Math.max(sliceMaxRow + (range.endRow - range.startRow + 1) - dataRange.endRow, 0);
|
|
2000
2184
|
if (insertRowCount > 0) {
|
|
2001
2185
|
const anchorRow = range.startRow - 1, height = worksheet.getRowHeight(anchorRow), insertRowParams = {
|
|
@@ -2055,7 +2239,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2055
2239
|
id: InsertRangeMoveRightCommandId,
|
|
2056
2240
|
// eslint-disable-next-line max-lines-per-function
|
|
2057
2241
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2058
|
-
var
|
|
2242
|
+
var _a18, _b, _c;
|
|
2059
2243
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService);
|
|
2060
2244
|
if (selectionManagerService.isOverlapping())
|
|
2061
2245
|
return errorService.emit(localeService.t("sheets.info.overlappingSelections")), !1;
|
|
@@ -2063,7 +2247,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2063
2247
|
if (!target) return !1;
|
|
2064
2248
|
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
2065
2249
|
let range = params == null ? void 0 : params.range;
|
|
2066
|
-
if (range || (range = (
|
|
2250
|
+
if (range || (range = (_a18 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a18.range), !range) return !1;
|
|
2067
2251
|
const redoMutations = [], undoMutations = [], cellMatrix = worksheet.getCellMatrix(), dataRange = cellMatrix.getDataRange(), sliceMaxCol = cellMatrix.getSlice(range.startRow, range.endRow, dataRange.startColumn, dataRange.endColumn).getDataRange().endColumn, insertColCount = Math.max(
|
|
2068
2252
|
sliceMaxCol + (range.endColumn - range.startColumn + 1) - dataRange.endColumn,
|
|
2069
2253
|
0
|
|
@@ -2125,7 +2309,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2125
2309
|
type: CommandType.COMMAND,
|
|
2126
2310
|
id: InsertRowCommandId,
|
|
2127
2311
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2128
|
-
var
|
|
2312
|
+
var _a18, _b, _c, _d;
|
|
2129
2313
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
2130
2314
|
if (!target) return !1;
|
|
2131
2315
|
const { workbook, worksheet } = target, { range, direction, unitId, subUnitId, cellValue } = params, { startRow, endRow } = range;
|
|
@@ -2157,7 +2341,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2157
2341
|
id: InsertRowCommand.id,
|
|
2158
2342
|
params
|
|
2159
2343
|
});
|
|
2160
|
-
return redos.unshift(...(
|
|
2344
|
+
return redos.unshift(...(_a18 = intercepted.preRedos) != null ? _a18 : []), redos.push(...(_b = intercepted.redos) != null ? _b : []), redos.push(followSelectionOperation(range, workbook, worksheet)), undos.unshift(...(_c = intercepted.preUndos) != null ? _c : []), undos.push(...(_d = intercepted.undos) != null ? _d : []), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
|
|
2161
2345
|
unitID: params.unitId,
|
|
2162
2346
|
undoMutations: undos,
|
|
2163
2347
|
redoMutations: redos
|
|
@@ -2167,8 +2351,8 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2167
2351
|
type: CommandType.COMMAND,
|
|
2168
2352
|
id: "sheet.command.insert-row-before",
|
|
2169
2353
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
2170
|
-
var
|
|
2171
|
-
const selections = (
|
|
2354
|
+
var _a18;
|
|
2355
|
+
const selections = (_a18 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
2172
2356
|
let range;
|
|
2173
2357
|
if ((selections == null ? void 0 : selections.length) === 1)
|
|
2174
2358
|
range = selections[0];
|
|
@@ -2195,8 +2379,8 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2195
2379
|
type: CommandType.COMMAND,
|
|
2196
2380
|
id: "sheet.command.insert-row-after",
|
|
2197
2381
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
2198
|
-
var
|
|
2199
|
-
const selections = (
|
|
2382
|
+
var _a18;
|
|
2383
|
+
const selections = (_a18 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
2200
2384
|
let range;
|
|
2201
2385
|
if ((selections == null ? void 0 : selections.length) === 1)
|
|
2202
2386
|
range = selections[0];
|
|
@@ -2224,7 +2408,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2224
2408
|
type: CommandType.COMMAND,
|
|
2225
2409
|
id: InsertColCommandId,
|
|
2226
2410
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2227
|
-
var
|
|
2411
|
+
var _a18, _b, _c, _d;
|
|
2228
2412
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), { range, direction, subUnitId, unitId, cellValue } = params, { startColumn, endColumn } = params.range;
|
|
2229
2413
|
range.rangeType = RANGE_TYPE.COLUMN;
|
|
2230
2414
|
const workbook = univerInstanceService.getUniverSheetInstance(params.unitId), worksheet = workbook.getSheetBySheetId(params.subUnitId), anchorCol = direction === Direction.LEFT ? startColumn : startColumn - 1, width = worksheet.getColumnWidth(anchorCol), insertColParams = {
|
|
@@ -2257,7 +2441,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2257
2441
|
id: InsertColCommand.id,
|
|
2258
2442
|
params
|
|
2259
2443
|
});
|
|
2260
|
-
return redos.unshift(...(
|
|
2444
|
+
return redos.unshift(...(_a18 = intercepted.preRedos) != null ? _a18 : []), redos.push(...(_b = intercepted.redos) != null ? _b : []), redos.push(followSelectionOperation(range, workbook, worksheet)), undos.unshift(...(_c = intercepted.preUndos) != null ? _c : []), undos.push(...(_d = intercepted.undos) != null ? _d : []), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
|
|
2261
2445
|
unitID: params.unitId,
|
|
2262
2446
|
undoMutations: undos.filter(Boolean),
|
|
2263
2447
|
redoMutations: redos.filter(Boolean)
|
|
@@ -2322,13 +2506,13 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
|
|
|
2322
2506
|
id: "sheet.command.insert-sheet",
|
|
2323
2507
|
type: CommandType.COMMAND,
|
|
2324
2508
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
2325
|
-
var
|
|
2509
|
+
var _a18;
|
|
2326
2510
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), localeService = accessor.get(LocaleService), target = getSheetCommandTargetWorkbook(univerInstanceService, { unitId: params == null ? void 0 : params.unitId });
|
|
2327
2511
|
if (!target) return !1;
|
|
2328
2512
|
const { unitId, workbook } = target;
|
|
2329
2513
|
let index = workbook.getSheets().length;
|
|
2330
2514
|
const sheet = params == null ? void 0 : params.sheet, sheetId = sheet == null ? void 0 : sheet.id, sheetConfig = mergeWorksheetSnapshotWithDefault(sheet || {});
|
|
2331
|
-
params ? (index = (
|
|
2515
|
+
params ? (index = (_a18 = params.index) != null ? _a18 : index, sheetConfig.id = sheetId || Tools.generateRandomId(), sheetConfig.name = (sheet == null ? void 0 : sheet.name) || workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`)) : (sheetConfig.id = Tools.generateRandomId(), sheetConfig.name = workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`));
|
|
2332
2516
|
const insertSheetMutationParams = {
|
|
2333
2517
|
index,
|
|
2334
2518
|
sheet: sheetConfig,
|
|
@@ -2431,7 +2615,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
|
|
|
2431
2615
|
type: CommandType.COMMAND,
|
|
2432
2616
|
// eslint-disable-next-line max-lines-per-function
|
|
2433
2617
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2434
|
-
var
|
|
2618
|
+
var _a18, _b;
|
|
2435
2619
|
const selectionManagerService = accessor.get(SheetsSelectionsService), {
|
|
2436
2620
|
fromRange: { startRow: fromRow },
|
|
2437
2621
|
toRange: { startRow: toRow },
|
|
@@ -2458,7 +2642,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
|
|
|
2458
2642
|
sourceRange: rangeToMove,
|
|
2459
2643
|
targetRange: destinationRange
|
|
2460
2644
|
}, undoMoveRowsParams = MoveRowsMutationUndoFactory(accessor, moveRowsParams), commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveRowsCommand.id, params }), redos = [
|
|
2461
|
-
...(
|
|
2645
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
2462
2646
|
{ id: MoveRowsMutation.id, params: moveRowsParams }
|
|
2463
2647
|
], undos = [
|
|
2464
2648
|
...(_b = interceptorCommands.preUndos) != null ? _b : [],
|
|
@@ -2491,7 +2675,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
|
|
|
2491
2675
|
type: CommandType.COMMAND,
|
|
2492
2676
|
// eslint-disable-next-line max-lines-per-function
|
|
2493
2677
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2494
|
-
var
|
|
2678
|
+
var _a18, _b;
|
|
2495
2679
|
const selectionManagerService = accessor.get(SheetsSelectionsService), {
|
|
2496
2680
|
fromRange: { startColumn: fromCol },
|
|
2497
2681
|
toRange: { startColumn: toCol },
|
|
@@ -2518,7 +2702,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
|
|
|
2518
2702
|
sourceRange: rangeToMove,
|
|
2519
2703
|
targetRange: destinationRange
|
|
2520
2704
|
}, undoMoveColsParams = MoveColsMutationUndoFactory(accessor, moveColsParams), commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveColsCommand.id, params }), redos = [
|
|
2521
|
-
...(
|
|
2705
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
2522
2706
|
{ id: MoveColsMutation.id, params: moveColsParams }
|
|
2523
2707
|
], undos = [
|
|
2524
2708
|
...(_b = interceptorCommands.preUndos) != null ? _b : [],
|
|
@@ -2555,15 +2739,39 @@ function covertRangeToSelection(range) {
|
|
|
2555
2739
|
};
|
|
2556
2740
|
}
|
|
2557
2741
|
__name(covertRangeToSelection, "covertRangeToSelection");
|
|
2558
|
-
const
|
|
2742
|
+
const RemoveDefinedNameCommand = {
|
|
2743
|
+
id: "sheet.command.remove-defined-name",
|
|
2744
|
+
type: CommandType.COMMAND,
|
|
2745
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
2746
|
+
var _a18, _b;
|
|
2747
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
2748
|
+
if (!params) return !1;
|
|
2749
|
+
const removeSheetMutationParams = {
|
|
2750
|
+
...params
|
|
2751
|
+
}, interceptorCommands = sheetInterceptorService.onCommandExecute({ id: RemoveDefinedNameCommand.id, params }), redos = [
|
|
2752
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
2753
|
+
{ id: RemoveDefinedNameMutation.id, params: removeSheetMutationParams },
|
|
2754
|
+
...interceptorCommands.redos
|
|
2755
|
+
], undos = [
|
|
2756
|
+
...(_b = interceptorCommands.preUndos) != null ? _b : [],
|
|
2757
|
+
{ id: SetDefinedNameMutation.id, params: removeSheetMutationParams },
|
|
2758
|
+
...interceptorCommands.undos
|
|
2759
|
+
];
|
|
2760
|
+
return sequenceExecute(redos, commandService) ? (undoRedoService.pushUndoRedo({
|
|
2761
|
+
unitID: params.unitId,
|
|
2762
|
+
undoMutations: undos.filter(Boolean),
|
|
2763
|
+
redoMutations: redos.filter(Boolean)
|
|
2764
|
+
}), !0) : !1;
|
|
2765
|
+
}, "handler")
|
|
2766
|
+
}, RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
2559
2767
|
type: CommandType.COMMAND,
|
|
2560
2768
|
id: RemoveRowCommandId,
|
|
2561
2769
|
// eslint-disable-next-line max-lines-per-function
|
|
2562
2770
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2563
|
-
var
|
|
2771
|
+
var _a18, _b, _c, _d;
|
|
2564
2772
|
const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
2565
2773
|
let totalRange = params == null ? void 0 : params.range;
|
|
2566
|
-
if (totalRange || (totalRange = (
|
|
2774
|
+
if (totalRange || (totalRange = (_a18 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a18.range), !totalRange) return !1;
|
|
2567
2775
|
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
|
2568
2776
|
if (!target) return !1;
|
|
2569
2777
|
const { workbook, worksheet, subUnitId, unitId } = target;
|
|
@@ -2638,10 +2846,10 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2638
2846
|
type: CommandType.COMMAND,
|
|
2639
2847
|
id: RemoveColCommandId,
|
|
2640
2848
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2641
|
-
var
|
|
2849
|
+
var _a18, _b, _c, _d;
|
|
2642
2850
|
const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
2643
2851
|
let range = params == null ? void 0 : params.range;
|
|
2644
|
-
if (range || (range = (
|
|
2852
|
+
if (range || (range = (_a18 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a18.range), !range) return !1;
|
|
2645
2853
|
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
|
2646
2854
|
if (!target) return !1;
|
|
2647
2855
|
const { workbook, worksheet, subUnitId, unitId } = target;
|
|
@@ -2695,7 +2903,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2695
2903
|
id: "sheet.command.remove-sheet",
|
|
2696
2904
|
type: CommandType.COMMAND,
|
|
2697
2905
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2698
|
-
var
|
|
2906
|
+
var _a18, _b;
|
|
2699
2907
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
2700
2908
|
if (!target) return !1;
|
|
2701
2909
|
const { unitId, subUnitId, workbook, worksheet } = target;
|
|
@@ -2710,7 +2918,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2710
2918
|
), intercepted = sheetInterceptorService.onCommandExecute({
|
|
2711
2919
|
id: RemoveSheetCommand.id,
|
|
2712
2920
|
params: { unitId, subUnitId }
|
|
2713
|
-
}), redos = [...(
|
|
2921
|
+
}), redos = [...(_a18 = intercepted.preRedos) != null ? _a18 : [], { id: RemoveSheetMutation.id, params: RemoveSheetMutationParams }, ...intercepted.redos], undos = [...(_b = intercepted.preUndos) != null ? _b : [], { id: InsertSheetMutation.id, params: InsertSheetMutationParams }, ...intercepted.undos];
|
|
2714
2922
|
return sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
|
|
2715
2923
|
unitID: unitId,
|
|
2716
2924
|
undoMutations: undos,
|
|
@@ -2779,8 +2987,8 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2779
2987
|
id: "sheet.command.remove-worksheet-merge",
|
|
2780
2988
|
// eslint-disable-next-line max-lines-per-function
|
|
2781
2989
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2782
|
-
var
|
|
2783
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (params == null ? void 0 : params.ranges) || ((
|
|
2990
|
+
var _a18;
|
|
2991
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (params == null ? void 0 : params.ranges) || ((_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range));
|
|
2784
2992
|
if (!(selections != null && selections.length)) return !1;
|
|
2785
2993
|
const target = getSheetCommandTarget(univerInstanceService);
|
|
2786
2994
|
if (!target) return !1;
|
|
@@ -2844,7 +3052,65 @@ function getSetRangeStyleParamsForRemoveMerge(worksheet, ranges) {
|
|
|
2844
3052
|
};
|
|
2845
3053
|
}
|
|
2846
3054
|
__name(getSetRangeStyleParamsForRemoveMerge, "getSetRangeStyleParamsForRemoveMerge");
|
|
2847
|
-
const
|
|
3055
|
+
const ReorderRangeUndoMutationFactory = /* @__PURE__ */ __name((params) => {
|
|
3056
|
+
const { order } = params, newOrder = {};
|
|
3057
|
+
return Object.keys(order).forEach((key) => {
|
|
3058
|
+
newOrder[order[Number(key)]] = Number(key);
|
|
3059
|
+
}), {
|
|
3060
|
+
...params,
|
|
3061
|
+
order: newOrder
|
|
3062
|
+
};
|
|
3063
|
+
}, "ReorderRangeUndoMutationFactory"), ReorderRangeMutation = {
|
|
3064
|
+
id: "sheet.mutation.reorder-range",
|
|
3065
|
+
type: CommandType.MUTATION,
|
|
3066
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
3067
|
+
const { subUnitId, unitId, range, order } = params, worksheet = accessor.get(IUniverInstanceService).getUnit(unitId).getSheetBySheetId(subUnitId);
|
|
3068
|
+
if (!worksheet)
|
|
3069
|
+
return !1;
|
|
3070
|
+
const cellDataMatrix = new ObjectMatrix();
|
|
3071
|
+
Range.foreach(range, (row, col) => {
|
|
3072
|
+
if (order.hasOwnProperty(row)) {
|
|
3073
|
+
const targetRow = order[row], cloneCell = Tools.deepClone(worksheet.getCellRaw(targetRow, col));
|
|
3074
|
+
cellDataMatrix.setValue(row, col, cloneCell);
|
|
3075
|
+
}
|
|
3076
|
+
});
|
|
3077
|
+
const worksheetCellDataMatrix = worksheet.getCellMatrix();
|
|
3078
|
+
return cellDataMatrix.forValue((row, col, cellData) => {
|
|
3079
|
+
worksheetCellDataMatrix.setValue(row, col, cellData);
|
|
3080
|
+
}), !0;
|
|
3081
|
+
}, "handler")
|
|
3082
|
+
}, ReorderRangeCommandId = "sheet.command.reorder-range", ReorderRangeCommand = {
|
|
3083
|
+
id: ReorderRangeCommandId,
|
|
3084
|
+
type: CommandType.COMMAND,
|
|
3085
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
3086
|
+
var _a18, _b;
|
|
3087
|
+
const { subUnitId, unitId, range, order } = params, commandService = accessor.get(ICommandService), reorderMutation = {
|
|
3088
|
+
id: ReorderRangeMutation.id,
|
|
3089
|
+
params: {
|
|
3090
|
+
unitId,
|
|
3091
|
+
subUnitId,
|
|
3092
|
+
order,
|
|
3093
|
+
range
|
|
3094
|
+
}
|
|
3095
|
+
}, undoReorderMutation = {
|
|
3096
|
+
id: ReorderRangeMutation.id,
|
|
3097
|
+
params: ReorderRangeUndoMutationFactory(reorderMutation.params)
|
|
3098
|
+
}, interceptorCommands = accessor.get(SheetInterceptorService).onCommandExecute({ id: ReorderRangeCommand.id, params }), redos = [
|
|
3099
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
3100
|
+
reorderMutation,
|
|
3101
|
+
...interceptorCommands.redos
|
|
3102
|
+
], undos = [
|
|
3103
|
+
...(_b = interceptorCommands.preUndos) != null ? _b : [],
|
|
3104
|
+
undoReorderMutation,
|
|
3105
|
+
...interceptorCommands.undos
|
|
3106
|
+
];
|
|
3107
|
+
return sequenceExecute(redos, commandService).result ? (accessor.get(IUndoRedoService).pushUndoRedo({
|
|
3108
|
+
unitID: unitId,
|
|
3109
|
+
undoMutations: undos,
|
|
3110
|
+
redoMutations: redos
|
|
3111
|
+
}), !0) : !1;
|
|
3112
|
+
}, "handler")
|
|
3113
|
+
}, _BorderStyleManagerService = class _BorderStyleManagerService {
|
|
2848
3114
|
constructor() {
|
|
2849
3115
|
__publicField(this, "_borderInfo", {
|
|
2850
3116
|
type: BorderType.ALL,
|
|
@@ -2889,13 +3155,13 @@ __name(forEach, "forEach");
|
|
|
2889
3155
|
const setBorderStyleForRange = /* @__PURE__ */ __name((borderContext, range, defaultStyle, reserve) => {
|
|
2890
3156
|
const { mr, worksheet } = borderContext;
|
|
2891
3157
|
range.startRow < 0 || range.startColumn < 0 || forEach(range, (row, column) => {
|
|
2892
|
-
var
|
|
3158
|
+
var _a18, _b;
|
|
2893
3159
|
const rectangle = worksheet.getMergedCell(row, column);
|
|
2894
3160
|
let bdStyle = defaultStyle;
|
|
2895
3161
|
if (rectangle && (defaultStyle.bc_tr || defaultStyle.ml_tr || defaultStyle.bl_tr || defaultStyle.tl_mr || defaultStyle.tl_bc || defaultStyle.tl_br)) {
|
|
2896
3162
|
if (reserve) {
|
|
2897
3163
|
const style = Tools.deepClone(
|
|
2898
|
-
(
|
|
3164
|
+
(_a18 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a18.s
|
|
2899
3165
|
);
|
|
2900
3166
|
bdStyle = style != null && style.bd ? Object.assign(style.bd, defaultStyle) : defaultStyle;
|
|
2901
3167
|
}
|
|
@@ -3017,10 +3283,10 @@ __name(getBorderContext, "getBorderContext");
|
|
|
3017
3283
|
const innerBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
3018
3284
|
const { range, mr, borderStyle, vertical, horizontal, worksheet } = borderContext;
|
|
3019
3285
|
vertical && forEach(range, (row, column) => {
|
|
3020
|
-
var
|
|
3286
|
+
var _a18, _b, _c;
|
|
3021
3287
|
const mergedRange = worksheet.getMergedCell(row, column);
|
|
3022
3288
|
if (mergedRange) {
|
|
3023
|
-
const topLeftStyle = (
|
|
3289
|
+
const topLeftStyle = (_a18 = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _a18.s;
|
|
3024
3290
|
mergedRange.startColumn !== range.startColumn && mr.setValue(row, column, {
|
|
3025
3291
|
s: {
|
|
3026
3292
|
bd: topLeftStyle != null && topLeftStyle.bd ? Object.assign(topLeftStyle.bd, { l: Tools.deepClone(borderStyle) }) : { l: Tools.deepClone(borderStyle) }
|
|
@@ -3045,10 +3311,10 @@ const innerBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3045
3311
|
}
|
|
3046
3312
|
}
|
|
3047
3313
|
}), horizontal && forEach(range, (row, column) => {
|
|
3048
|
-
var
|
|
3314
|
+
var _a18, _b, _c;
|
|
3049
3315
|
const mergedRange = worksheet.getMergedCell(row, column);
|
|
3050
3316
|
if (mergedRange) {
|
|
3051
|
-
const topLeftStyle = (
|
|
3317
|
+
const topLeftStyle = (_a18 = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _a18.s;
|
|
3052
3318
|
mergedRange.startRow !== range.startRow && mr.setValue(row, column, {
|
|
3053
3319
|
s: {
|
|
3054
3320
|
bd: topLeftStyle != null && topLeftStyle.bd ? Object.assign(topLeftStyle.bd, { t: Tools.deepClone(borderStyle) }) : { t: Tools.deepClone(borderStyle) }
|
|
@@ -3091,11 +3357,11 @@ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3091
3357
|
setBorderStyleForRange(borderContext, range2, defaultStyle, reserve);
|
|
3092
3358
|
}, "setBorderStyle");
|
|
3093
3359
|
!top && !bottom && !left && !right && !vertical && !horizontal && !tl_br && !tl_bc && !tl_mr && !bl_tr && !ml_tr && !bc_tr && (forEach(range, (row, column) => {
|
|
3094
|
-
var
|
|
3360
|
+
var _a18, _b, _c, _d, _e, _f, _g, _h;
|
|
3095
3361
|
const mergedRange = worksheet.getMergedCell(row, column);
|
|
3096
3362
|
if (mergedRange) {
|
|
3097
3363
|
if (mergedRange.endColumn !== range.endColumn) {
|
|
3098
|
-
const style = (
|
|
3364
|
+
const style = (_a18 = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _a18.s;
|
|
3099
3365
|
mr.setValue(row, column, {
|
|
3100
3366
|
s: {
|
|
3101
3367
|
bd: style != null && style.bd ? Object.assign(style.bd, { r: null }) : { r: null }
|
|
@@ -3165,10 +3431,10 @@ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3165
3431
|
id: "sheet.command.set-border",
|
|
3166
3432
|
type: CommandType.COMMAND,
|
|
3167
3433
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3168
|
-
var
|
|
3434
|
+
var _a18;
|
|
3169
3435
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), borderStyleManagerService = accessor.get(BorderStyleManagerService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
3170
3436
|
if (!target) return !1;
|
|
3171
|
-
const selections = (
|
|
3437
|
+
const selections = (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
3172
3438
|
if (!(selections != null && selections.length))
|
|
3173
3439
|
return !1;
|
|
3174
3440
|
const { activeBorderType } = borderStyleManagerService.getBorderInfo();
|
|
@@ -3275,7 +3541,7 @@ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3275
3541
|
type: CommandType.COMMAND,
|
|
3276
3542
|
id: "sheet.command.set-col-visible-on-cols",
|
|
3277
3543
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3278
|
-
var
|
|
3544
|
+
var _a18, _b;
|
|
3279
3545
|
const { unitId, subUnitId, ranges } = params, sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), instanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(instanceService, { unitId, subUnitId });
|
|
3280
3546
|
if (!target) return !1;
|
|
3281
3547
|
const { worksheet } = target, redoMutationParams = {
|
|
@@ -3307,7 +3573,7 @@ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3307
3573
|
undoMutations: [
|
|
3308
3574
|
{ id: SetColHiddenMutation.id, params: undoMutationParams },
|
|
3309
3575
|
{ id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
|
|
3310
|
-
...(
|
|
3576
|
+
...(_a18 = intercepted.undos) != null ? _a18 : []
|
|
3311
3577
|
],
|
|
3312
3578
|
redoMutations: [
|
|
3313
3579
|
...(_b = intercepted.preRedos) != null ? _b : [],
|
|
@@ -3321,8 +3587,8 @@ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3321
3587
|
type: CommandType.COMMAND,
|
|
3322
3588
|
id: "sheet.command.set-selected-cols-visible",
|
|
3323
3589
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
3324
|
-
var
|
|
3325
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), ranges = (
|
|
3590
|
+
var _a18;
|
|
3591
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), ranges = (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
|
|
3326
3592
|
if (!(ranges != null && ranges.length)) return !1;
|
|
3327
3593
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
3328
3594
|
if (!target) return !1;
|
|
@@ -3337,9 +3603,9 @@ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
|
|
|
3337
3603
|
type: CommandType.COMMAND,
|
|
3338
3604
|
id: "sheet.command.set-col-hidden",
|
|
3339
3605
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3340
|
-
var
|
|
3606
|
+
var _a18, _b, _c, _d;
|
|
3341
3607
|
const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
|
|
3342
|
-
let ranges = (
|
|
3608
|
+
let ranges = (_a18 = params == null ? void 0 : params.ranges) != null && _a18.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
|
|
3343
3609
|
if (!(ranges != null && ranges.length)) return !1;
|
|
3344
3610
|
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
3345
3611
|
if (!target) return !1;
|
|
@@ -3422,14 +3688,40 @@ function mergeSelections$1(ranges) {
|
|
|
3422
3688
|
}), merged.push(current), merged;
|
|
3423
3689
|
}
|
|
3424
3690
|
__name(mergeSelections$1, "mergeSelections$1");
|
|
3425
|
-
const
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3691
|
+
const SetDefinedNameCommand = {
|
|
3692
|
+
id: "sheet.command.set-defined-name",
|
|
3693
|
+
type: CommandType.COMMAND,
|
|
3694
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
3695
|
+
var _a18, _b;
|
|
3696
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
3697
|
+
if (!params) return !1;
|
|
3698
|
+
const newDefinedNameMutationParams = {
|
|
3699
|
+
...params
|
|
3700
|
+
}, oldDefinedNameMutationParams = SetDefinedNameMutationFactory(accessor, params), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: SetDefinedNameCommand.id, params }), redos = [
|
|
3701
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
3702
|
+
{ id: RemoveDefinedNameMutation.id, params: oldDefinedNameMutationParams },
|
|
3703
|
+
{ id: SetDefinedNameMutation.id, params: newDefinedNameMutationParams },
|
|
3704
|
+
...interceptorCommands.redos
|
|
3705
|
+
], undos = [
|
|
3706
|
+
...(_b = interceptorCommands.preUndos) != null ? _b : [],
|
|
3707
|
+
{ id: RemoveDefinedNameMutation.id, params: newDefinedNameMutationParams },
|
|
3708
|
+
{ id: SetDefinedNameMutation.id, params: oldDefinedNameMutationParams },
|
|
3709
|
+
...interceptorCommands.undos
|
|
3710
|
+
];
|
|
3711
|
+
return sequenceExecute(redos, commandService) ? (undoRedoService.pushUndoRedo({
|
|
3712
|
+
unitID: params.unitId,
|
|
3713
|
+
undoMutations: undos.filter(Boolean),
|
|
3714
|
+
redoMutations: redos.filter(Boolean)
|
|
3715
|
+
}), !0) : !1;
|
|
3716
|
+
}, "handler")
|
|
3717
|
+
}, SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
3718
|
+
const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);
|
|
3719
|
+
if (universheet == null)
|
|
3720
|
+
throw new Error("universheet is null error!");
|
|
3721
|
+
const worksheet = universheet.getSheetBySheetId(params.subUnitId);
|
|
3722
|
+
if (worksheet == null)
|
|
3723
|
+
throw new Error("worksheet is null error!");
|
|
3724
|
+
const freeze = worksheet.getConfig().freeze;
|
|
3433
3725
|
return {
|
|
3434
3726
|
unitId: params.unitId,
|
|
3435
3727
|
subUnitId: params.subUnitId,
|
|
@@ -3487,6 +3779,64 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3487
3779
|
redoMutations: [{ id: SetFrozenMutation.id, params: redoMutationParams }]
|
|
3488
3780
|
}), !0) : !1;
|
|
3489
3781
|
}, "handler")
|
|
3782
|
+
}, SetRangeProtectionMutation = {
|
|
3783
|
+
id: "sheet.mutation.set-range-protection",
|
|
3784
|
+
type: CommandType.MUTATION,
|
|
3785
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
3786
|
+
const { unitId, subUnitId, rule, ruleId } = params;
|
|
3787
|
+
return accessor.get(RangeProtectionRuleModel).setRule(unitId, subUnitId, ruleId, rule), !0;
|
|
3788
|
+
}, "handler")
|
|
3789
|
+
}, FactorySetRangeProtectionMutation = /* @__PURE__ */ __name((accessor, param) => {
|
|
3790
|
+
const { unitId, subUnitId, ruleId } = param, oldRule = accessor.get(RangeProtectionRuleModel).getRule(unitId, subUnitId, ruleId);
|
|
3791
|
+
return oldRule ? {
|
|
3792
|
+
id: SetRangeProtectionMutation.id,
|
|
3793
|
+
params: {
|
|
3794
|
+
...param,
|
|
3795
|
+
rule: oldRule
|
|
3796
|
+
}
|
|
3797
|
+
} : null;
|
|
3798
|
+
}, "FactorySetRangeProtectionMutation"), SetRangeProtectionCommand = {
|
|
3799
|
+
type: CommandType.COMMAND,
|
|
3800
|
+
id: "sheet.command.set-range-protection",
|
|
3801
|
+
async handler(accessor, params) {
|
|
3802
|
+
if (!params)
|
|
3803
|
+
return !1;
|
|
3804
|
+
const commandService = accessor.get(ICommandService), selectionProtectionModel = accessor.get(RangeProtectionRuleModel), undoRedoService = accessor.get(IUndoRedoService), { rule, permissionId, oldRule } = params, { unitId, subUnitId, ranges, name, description } = rule;
|
|
3805
|
+
if (rule.id) {
|
|
3806
|
+
const redoMutationParam = {
|
|
3807
|
+
unitId,
|
|
3808
|
+
subUnitId,
|
|
3809
|
+
ruleId: rule.id,
|
|
3810
|
+
rule: {
|
|
3811
|
+
ranges,
|
|
3812
|
+
permissionId,
|
|
3813
|
+
id: selectionProtectionModel.createRuleId(unitId, subUnitId),
|
|
3814
|
+
name,
|
|
3815
|
+
description
|
|
3816
|
+
}
|
|
3817
|
+
};
|
|
3818
|
+
if (await commandService.executeCommand(SetRangeProtectionMutation.id, redoMutationParam)) {
|
|
3819
|
+
const redoMutations = [{
|
|
3820
|
+
id: SetRangeProtectionMutation.id,
|
|
3821
|
+
params: redoMutationParam
|
|
3822
|
+
}], undoMutations = [{
|
|
3823
|
+
id: SetRangeProtectionMutation.id,
|
|
3824
|
+
params: {
|
|
3825
|
+
unitId,
|
|
3826
|
+
subUnitId,
|
|
3827
|
+
ruleId: rule.id,
|
|
3828
|
+
rule: oldRule
|
|
3829
|
+
}
|
|
3830
|
+
}];
|
|
3831
|
+
undoRedoService.pushUndoRedo({
|
|
3832
|
+
unitID: unitId,
|
|
3833
|
+
redoMutations,
|
|
3834
|
+
undoMutations
|
|
3835
|
+
});
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
return !0;
|
|
3839
|
+
}
|
|
3490
3840
|
}, SetRowVisibleUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
3491
3841
|
if (accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId) == null)
|
|
3492
3842
|
throw new Error("universheet is null error!");
|
|
@@ -3541,7 +3891,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3541
3891
|
type: CommandType.COMMAND,
|
|
3542
3892
|
id: "sheet.command.set-specific-rows-visible",
|
|
3543
3893
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3544
|
-
var
|
|
3894
|
+
var _a18, _b, _c;
|
|
3545
3895
|
const { unitId, subUnitId, ranges } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), { unitId, subUnitId });
|
|
3546
3896
|
if (!target) return !1;
|
|
3547
3897
|
const { worksheet } = target, redoMutationParams = { unitId, subUnitId, ranges }, setSelectionOperationParams = {
|
|
@@ -3574,7 +3924,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3574
3924
|
return result.result && interceptedResult.result && undoRedoService.pushUndoRedo({
|
|
3575
3925
|
unitID: unitId,
|
|
3576
3926
|
undoMutations: [
|
|
3577
|
-
...(
|
|
3927
|
+
...(_a18 = intercepted.preUndos) != null ? _a18 : [],
|
|
3578
3928
|
{ id: SetRowHiddenMutation.id, params: undoMutationParams },
|
|
3579
3929
|
{ id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
|
|
3580
3930
|
...(_b = intercepted.undos) != null ? _b : []
|
|
@@ -3591,8 +3941,8 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3591
3941
|
type: CommandType.COMMAND,
|
|
3592
3942
|
id: "sheet.command.set-selected-rows-visible",
|
|
3593
3943
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
3594
|
-
var
|
|
3595
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), ranges = (
|
|
3944
|
+
var _a18;
|
|
3945
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), ranges = (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
|
|
3596
3946
|
if (!(ranges != null && ranges.length)) return !1;
|
|
3597
3947
|
const target = getSheetCommandTarget(univerInstanceService);
|
|
3598
3948
|
if (!target) return !1;
|
|
@@ -3607,9 +3957,9 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3607
3957
|
type: CommandType.COMMAND,
|
|
3608
3958
|
id: "sheet.command.set-rows-hidden",
|
|
3609
3959
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3610
|
-
var
|
|
3960
|
+
var _a18, _b, _c, _d, _e, _f;
|
|
3611
3961
|
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
3612
|
-
let ranges = (
|
|
3962
|
+
let ranges = (_a18 = params == null ? void 0 : params.ranges) != null && _a18.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
|
|
3613
3963
|
if (!(ranges != null && ranges.length)) return !1;
|
|
3614
3964
|
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
3615
3965
|
if (!target) return !1;
|
|
@@ -3695,10 +4045,10 @@ const SetStyleCommand = {
|
|
|
3695
4045
|
type: CommandType.COMMAND,
|
|
3696
4046
|
id: "sheet.command.set-style",
|
|
3697
4047
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
3698
|
-
var
|
|
3699
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
|
4048
|
+
var _a18;
|
|
4049
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
3700
4050
|
if (!target) return !1;
|
|
3701
|
-
const { unitId, subUnitId, worksheet } = target, { range, style } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), ranges = range ? [range] : (
|
|
4051
|
+
const { unitId, subUnitId, worksheet } = target, { range, style } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), ranges = range ? [range] : (_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
3702
4052
|
if (!(ranges != null && ranges.length))
|
|
3703
4053
|
return !1;
|
|
3704
4054
|
const cellValue = new ObjectMatrix(), iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
@@ -3735,7 +4085,7 @@ const SetStyleCommand = {
|
|
|
3735
4085
|
params
|
|
3736
4086
|
}), result = sequenceExecute([...redos], commandService);
|
|
3737
4087
|
return setRangeValuesResult && result.result ? (undoRedoService.pushUndoRedo({
|
|
3738
|
-
unitID: unitId,
|
|
4088
|
+
unitID: setRangeValuesMutationParams.unitId,
|
|
3739
4089
|
undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],
|
|
3740
4090
|
redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }, ...redos]
|
|
3741
4091
|
}), !0) : !1;
|
|
@@ -4026,6 +4376,32 @@ const SetStyleCommand = {
|
|
|
4026
4376
|
redoMutations: [{ id: SetTabColorMutation.id, params: setTabColorMutationParams }]
|
|
4027
4377
|
}), !0) : !1;
|
|
4028
4378
|
}, "handler")
|
|
4379
|
+
}, SetWorkbookNameMutation = {
|
|
4380
|
+
id: "sheet.mutation.set-workbook-name",
|
|
4381
|
+
type: CommandType.MUTATION,
|
|
4382
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4383
|
+
const workbook = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET);
|
|
4384
|
+
return workbook ? (workbook.setName(params.name), !0) : !1;
|
|
4385
|
+
}, "handler")
|
|
4386
|
+
}, SetWorkbookNameCommand = {
|
|
4387
|
+
type: CommandType.COMMAND,
|
|
4388
|
+
id: "sheet.command.set-workbook-name",
|
|
4389
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4390
|
+
var _a18;
|
|
4391
|
+
if (!accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET)) return !1;
|
|
4392
|
+
const interceptedCommands = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
4393
|
+
id: SetWorkbookNameCommand.id,
|
|
4394
|
+
params
|
|
4395
|
+
}), redoMutationParams = {
|
|
4396
|
+
name: params.name,
|
|
4397
|
+
unitId: params.unitId
|
|
4398
|
+
}, redos = [
|
|
4399
|
+
...(_a18 = interceptedCommands.preRedos) != null ? _a18 : [],
|
|
4400
|
+
{ id: SetWorkbookNameMutation.id, params: redoMutationParams },
|
|
4401
|
+
...interceptedCommands.redos
|
|
4402
|
+
], commandService = accessor.get(ICommandService);
|
|
4403
|
+
return sequenceExecute(redos, commandService).result;
|
|
4404
|
+
}, "handler")
|
|
4029
4405
|
}, SetWorksheetActiveOperation = {
|
|
4030
4406
|
id: "sheet.operation.set-worksheet-active",
|
|
4031
4407
|
type: CommandType.OPERATION,
|
|
@@ -4074,7 +4450,7 @@ const SetStyleCommand = {
|
|
|
4074
4450
|
id: "sheet.mutation.set-worksheet-col-width",
|
|
4075
4451
|
type: CommandType.MUTATION,
|
|
4076
4452
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4077
|
-
var
|
|
4453
|
+
var _a18;
|
|
4078
4454
|
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4079
4455
|
if (!target) return !1;
|
|
4080
4456
|
const { worksheet } = target, defaultColumnWidth = worksheet.getConfig().defaultColumnWidth, manager = worksheet.getColumnManager(), ranges = params.ranges;
|
|
@@ -4082,7 +4458,7 @@ const SetStyleCommand = {
|
|
|
4082
4458
|
const range = ranges[i];
|
|
4083
4459
|
for (let j = range.startColumn; j < range.endColumn + 1; j++) {
|
|
4084
4460
|
const column = manager.getColumnOrCreate(j);
|
|
4085
|
-
typeof params.colWidth == "number" ? column.w = params.colWidth : column.w = (
|
|
4461
|
+
typeof params.colWidth == "number" ? column.w = params.colWidth : column.w = (_a18 = params.colWidth[j]) != null ? _a18 : defaultColumnWidth;
|
|
4086
4462
|
}
|
|
4087
4463
|
}
|
|
4088
4464
|
return !0;
|
|
@@ -4150,8 +4526,8 @@ const SetStyleCommand = {
|
|
|
4150
4526
|
type: CommandType.COMMAND,
|
|
4151
4527
|
id: "sheet.command.set-worksheet-col-width",
|
|
4152
4528
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4153
|
-
var
|
|
4154
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (
|
|
4529
|
+
var _a18, _b, _c, _d;
|
|
4530
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a18 = params == null ? void 0 : params.ranges) != null && _a18.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
4155
4531
|
if (!(selections != null && selections.length)) return !1;
|
|
4156
4532
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
|
|
4157
4533
|
if (!target) return !1;
|
|
@@ -4236,7 +4612,7 @@ const SetStyleCommand = {
|
|
|
4236
4612
|
type: CommandType.COMMAND,
|
|
4237
4613
|
id: "sheet.command.set-worksheet-name",
|
|
4238
4614
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4239
|
-
var
|
|
4615
|
+
var _a18, _b;
|
|
4240
4616
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
|
|
4241
4617
|
if (!target) return !1;
|
|
4242
4618
|
const { unitId, subUnitId } = target, redoMutationParams = {
|
|
@@ -4250,7 +4626,7 @@ const SetStyleCommand = {
|
|
|
4250
4626
|
id: SetWorksheetNameCommand.id,
|
|
4251
4627
|
params
|
|
4252
4628
|
}), redos = [
|
|
4253
|
-
...(
|
|
4629
|
+
...(_a18 = interceptorCommands.preRedos) != null ? _a18 : [],
|
|
4254
4630
|
{ id: SetWorksheetNameMutation.id, params: redoMutationParams },
|
|
4255
4631
|
...interceptorCommands.redos
|
|
4256
4632
|
], undos = [
|
|
@@ -4295,825 +4671,134 @@ const SetStyleCommand = {
|
|
|
4295
4671
|
redoMutations: [{ id: SetWorksheetOrderMutation.id, params: setWorksheetOrderMutationParams }]
|
|
4296
4672
|
}), !0) : !1;
|
|
4297
4673
|
}, "handler")
|
|
4298
|
-
},
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4674
|
+
}, getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
|
|
4675
|
+
WorksheetEditPermission,
|
|
4676
|
+
WorksheetViewPermission
|
|
4677
|
+
], "getAllWorksheetPermissionPoint"), getAllWorksheetPermissionPointByPointPanel = /* @__PURE__ */ __name(() => [
|
|
4678
|
+
WorksheetCopyPermission,
|
|
4679
|
+
WorksheetDeleteColumnPermission,
|
|
4680
|
+
WorksheetDeleteRowPermission,
|
|
4681
|
+
WorksheetEditExtraObjectPermission,
|
|
4682
|
+
WorksheetFilterPermission,
|
|
4683
|
+
WorksheetInsertColumnPermission,
|
|
4684
|
+
WorksheetInsertRowPermission,
|
|
4685
|
+
WorksheetInsertHyperlinkPermission,
|
|
4686
|
+
WorksheetPivotTablePermission,
|
|
4687
|
+
WorksheetSetCellStylePermission,
|
|
4688
|
+
WorksheetSetCellValuePermission,
|
|
4689
|
+
WorksheetSetColumnStylePermission,
|
|
4690
|
+
WorksheetSetRowStylePermission,
|
|
4691
|
+
WorksheetSortPermission
|
|
4692
|
+
], "getAllWorksheetPermissionPointByPointPanel"), defaultWorksheetPermissionPoint = [
|
|
4693
|
+
P.Copy,
|
|
4694
|
+
P.DeleteColumn,
|
|
4695
|
+
P.DeleteRow,
|
|
4696
|
+
P.EditExtraObject,
|
|
4697
|
+
P.Filter,
|
|
4698
|
+
P.InsertColumn,
|
|
4699
|
+
P.InsertRow,
|
|
4700
|
+
P.InsertHyperlink,
|
|
4701
|
+
P.PivotTable,
|
|
4702
|
+
P.SetCellStyle,
|
|
4703
|
+
P.SetCellValue,
|
|
4704
|
+
P.SetColumnStyle,
|
|
4705
|
+
P.SetRowStyle,
|
|
4706
|
+
P.Sort
|
|
4707
|
+
], _WorksheetProtectionPointModel = class _WorksheetProtectionPointModel {
|
|
4708
|
+
constructor() {
|
|
4709
|
+
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
4710
|
+
__publicField(this, "_pointChange", new Subject());
|
|
4711
|
+
__publicField(this, "pointChange$", this._pointChange.asObservable());
|
|
4329
4712
|
}
|
|
4330
|
-
|
|
4331
|
-
unitId,
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
var
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
},
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a21 = autoHeightInfo[rowIndex]) != null ? _a21 : void 0;
|
|
4713
|
+
addRule(rule) {
|
|
4714
|
+
this._ensureSubUnitMap(rule.unitId).set(rule.subUnitId, rule), this._pointChange.next(rule);
|
|
4715
|
+
}
|
|
4716
|
+
deleteRule(unitId, subUnitId) {
|
|
4717
|
+
var _a18, _b, _c;
|
|
4718
|
+
const rule = (_a18 = this._model.get(unitId)) == null ? void 0 : _a18.get(subUnitId);
|
|
4719
|
+
rule && ((_c = (_b = this._model) == null ? void 0 : _b.get(unitId)) == null || _c.delete(subUnitId), this._pointChange.next(rule));
|
|
4720
|
+
}
|
|
4721
|
+
getRule(unitId, subUnitId) {
|
|
4722
|
+
var _a18, _b;
|
|
4723
|
+
return (_b = (_a18 = this._model) == null ? void 0 : _a18.get(unitId)) == null ? void 0 : _b.get(subUnitId);
|
|
4724
|
+
}
|
|
4725
|
+
toObject() {
|
|
4726
|
+
const result = {};
|
|
4727
|
+
return [...this._model.keys()].forEach((unitId) => {
|
|
4728
|
+
const subUnitMap = this._model.get(unitId);
|
|
4729
|
+
subUnitMap != null && subUnitMap.size && (result[unitId] = [], [...subUnitMap.keys()].forEach((subUnitId) => {
|
|
4730
|
+
const rule = subUnitMap.get(subUnitId);
|
|
4731
|
+
rule && result[unitId].push(rule);
|
|
4732
|
+
}));
|
|
4733
|
+
}), result;
|
|
4734
|
+
}
|
|
4735
|
+
fromObject(obj) {
|
|
4736
|
+
const result = /* @__PURE__ */ new Map();
|
|
4737
|
+
Object.keys(obj).forEach((unitId) => {
|
|
4738
|
+
const subUnitList = obj[unitId];
|
|
4739
|
+
if (subUnitList != null && subUnitList.length) {
|
|
4740
|
+
const subUnitMap = /* @__PURE__ */ new Map();
|
|
4741
|
+
subUnitList.forEach((rule) => {
|
|
4742
|
+
subUnitMap.set(rule.subUnitId, rule);
|
|
4743
|
+
}), result.set(unitId, subUnitMap);
|
|
4362
4744
|
}
|
|
4363
|
-
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
}
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
var _a21, _b;
|
|
4384
|
-
const selections = accessor.get(SheetsSelectionsService).getCurrentSelections(), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
4385
|
-
if (!(selections != null && selections.length))
|
|
4386
|
-
return !1;
|
|
4387
|
-
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
4388
|
-
if (!target) return !1;
|
|
4389
|
-
const { worksheet, subUnitId, unitId } = target, { anchorRow, deltaY } = params, destRowHeight = worksheet.getRowHeight(anchorRow) + deltaY, isAllSheetRange = selections.length === 1 && selections[0].range.rangeType === RANGE_TYPE.ALL, rowSelections = selections.filter((s) => s.range.rangeType === RANGE_TYPE.ROW), rangeType = isAllSheetRange ? RANGE_TYPE.ALL : rowSelections.some(({ range }) => {
|
|
4390
|
-
const { startRow, endRow } = range;
|
|
4391
|
-
return startRow <= anchorRow && anchorRow <= endRow;
|
|
4392
|
-
}) ? RANGE_TYPE.ROW : RANGE_TYPE.NORMAL;
|
|
4393
|
-
let redoMutationParams;
|
|
4394
|
-
if (rangeType === RANGE_TYPE.ALL) {
|
|
4395
|
-
const colCount = worksheet.getRowCount(), allRowRanges = new Array(worksheet.getColumnCount()).fill(void 0).map(
|
|
4396
|
-
(_, index) => ({ startRow: index, endRow: index, startColumn: 0, endColumn: colCount - 1 })
|
|
4397
|
-
);
|
|
4398
|
-
redoMutationParams = {
|
|
4399
|
-
subUnitId,
|
|
4400
|
-
unitId,
|
|
4401
|
-
rowHeight: destRowHeight,
|
|
4402
|
-
ranges: allRowRanges
|
|
4403
|
-
};
|
|
4404
|
-
} else rangeType === RANGE_TYPE.ROW ? redoMutationParams = {
|
|
4405
|
-
subUnitId,
|
|
4406
|
-
unitId,
|
|
4407
|
-
ranges: rowSelections.map((s) => Rectangle.clone(s.range)),
|
|
4408
|
-
rowHeight: destRowHeight
|
|
4409
|
-
} : redoMutationParams = {
|
|
4410
|
-
subUnitId,
|
|
4411
|
-
unitId,
|
|
4412
|
-
rowHeight: destRowHeight,
|
|
4413
|
-
ranges: [
|
|
4414
|
-
{
|
|
4415
|
-
startRow: anchorRow,
|
|
4416
|
-
endRow: anchorRow,
|
|
4417
|
-
startColumn: 0,
|
|
4418
|
-
endColumn: worksheet.getMaxColumns() - 1
|
|
4419
|
-
}
|
|
4420
|
-
]
|
|
4421
|
-
};
|
|
4422
|
-
const undoMutationParams = SetWorksheetRowHeightMutationFactory(redoMutationParams, worksheet), redoSetIsAutoHeightParams = {
|
|
4423
|
-
unitId,
|
|
4424
|
-
subUnitId,
|
|
4425
|
-
ranges: redoMutationParams.ranges,
|
|
4426
|
-
autoHeightInfo: BooleanNumber.FALSE
|
|
4427
|
-
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(redoSetIsAutoHeightParams, worksheet), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), intercepted = sheetInterceptorService.onCommandExecute({
|
|
4428
|
-
id: DeltaRowHeightCommand.id,
|
|
4429
|
-
params: redoMutationParams
|
|
4430
|
-
}), result = sequenceExecute([
|
|
4431
|
-
{
|
|
4432
|
-
id: SetWorksheetRowHeightMutation.id,
|
|
4433
|
-
params: redoMutationParams
|
|
4434
|
-
},
|
|
4435
|
-
{
|
|
4436
|
-
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
4437
|
-
params: redoSetIsAutoHeightParams
|
|
4438
|
-
}
|
|
4439
|
-
], commandService), interceptedResult = sequenceExecute([...intercepted.redos], commandService);
|
|
4440
|
-
return result.result && interceptedResult.result ? (undoRedoService.pushUndoRedo({
|
|
4441
|
-
unitID: unitId,
|
|
4442
|
-
undoMutations: [
|
|
4443
|
-
...(_a21 = intercepted.preUndos) != null ? _a21 : [],
|
|
4444
|
-
{
|
|
4445
|
-
id: SetWorksheetRowHeightMutation.id,
|
|
4446
|
-
params: undoMutationParams
|
|
4447
|
-
},
|
|
4448
|
-
{
|
|
4449
|
-
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
4450
|
-
params: undoSetIsAutoHeightParams
|
|
4451
|
-
},
|
|
4452
|
-
...intercepted.undos
|
|
4453
|
-
],
|
|
4454
|
-
redoMutations: [
|
|
4455
|
-
...(_b = intercepted.preRedos) != null ? _b : [],
|
|
4456
|
-
{
|
|
4457
|
-
id: SetWorksheetRowHeightMutation.id,
|
|
4458
|
-
params: redoMutationParams
|
|
4459
|
-
},
|
|
4460
|
-
{
|
|
4461
|
-
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
4462
|
-
params: redoSetIsAutoHeightParams
|
|
4463
|
-
},
|
|
4464
|
-
...intercepted.redos
|
|
4465
|
-
]
|
|
4466
|
-
}), !0) : !1;
|
|
4467
|
-
}, "handler")
|
|
4468
|
-
}, SetRowHeightCommand = {
|
|
4469
|
-
type: CommandType.COMMAND,
|
|
4470
|
-
id: "sheet.command.set-row-height",
|
|
4471
|
-
// eslint-disable-next-line max-lines-per-function
|
|
4472
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4473
|
-
var _a21, _b, _c, _d;
|
|
4474
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
4475
|
-
if (!(selections != null && selections.length))
|
|
4476
|
-
return !1;
|
|
4477
|
-
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
4478
|
-
if (!target) return !1;
|
|
4479
|
-
const { unitId, subUnitId, worksheet } = target, redoMutationParams = {
|
|
4480
|
-
subUnitId,
|
|
4481
|
-
unitId,
|
|
4482
|
-
ranges: selections,
|
|
4483
|
-
rowHeight: params.value
|
|
4484
|
-
}, undoMutationParams = SetWorksheetRowHeightMutationFactory(redoMutationParams, worksheet), redoSetIsAutoHeightParams = {
|
|
4485
|
-
unitId,
|
|
4486
|
-
subUnitId,
|
|
4487
|
-
ranges: redoMutationParams.ranges,
|
|
4488
|
-
autoHeightInfo: BooleanNumber.FALSE
|
|
4489
|
-
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(redoSetIsAutoHeightParams, worksheet), result = sequenceExecute([
|
|
4490
|
-
{
|
|
4491
|
-
id: SetWorksheetRowHeightMutation.id,
|
|
4492
|
-
params: redoMutationParams
|
|
4493
|
-
},
|
|
4494
|
-
{
|
|
4495
|
-
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
4496
|
-
params: redoSetIsAutoHeightParams
|
|
4497
|
-
}
|
|
4498
|
-
], commandService), intercepted = sheetInterceptorService.onCommandExecute({
|
|
4499
|
-
id: SetRowHeightCommand.id,
|
|
4500
|
-
params: redoMutationParams
|
|
4501
|
-
}), sheetInterceptorResult = sequenceExecute([...intercepted.redos], commandService);
|
|
4502
|
-
return result.result && sheetInterceptorResult.result ? (undoRedoService.pushUndoRedo({
|
|
4503
|
-
unitID: unitId,
|
|
4504
|
-
undoMutations: [
|
|
4505
|
-
...(_c = intercepted.preRedos) != null ? _c : [],
|
|
4506
|
-
{
|
|
4507
|
-
id: SetWorksheetRowHeightMutation.id,
|
|
4508
|
-
params: undoMutationParams
|
|
4509
|
-
},
|
|
4510
|
-
{
|
|
4511
|
-
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
4512
|
-
params: undoSetIsAutoHeightParams
|
|
4513
|
-
},
|
|
4514
|
-
...intercepted.undos
|
|
4515
|
-
],
|
|
4516
|
-
redoMutations: [
|
|
4517
|
-
...(_d = intercepted.preRedos) != null ? _d : [],
|
|
4518
|
-
{
|
|
4519
|
-
id: SetWorksheetRowHeightMutation.id,
|
|
4520
|
-
params: redoMutationParams
|
|
4521
|
-
},
|
|
4522
|
-
{
|
|
4523
|
-
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
4524
|
-
params: redoSetIsAutoHeightParams
|
|
4525
|
-
},
|
|
4526
|
-
...intercepted.redos
|
|
4527
|
-
]
|
|
4528
|
-
}), !0) : !1;
|
|
4529
|
-
}, "handler")
|
|
4530
|
-
}, SetWorksheetRowIsAutoHeightCommand = {
|
|
4531
|
-
type: CommandType.COMMAND,
|
|
4532
|
-
id: "sheet.command.set-row-is-auto-height",
|
|
4533
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4534
|
-
var _a21, _b;
|
|
4535
|
-
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4536
|
-
if (!target) return !1;
|
|
4537
|
-
const { unitId, subUnitId, worksheet } = target, ranges = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
4538
|
-
if (!(ranges != null && ranges.length))
|
|
4539
|
-
return !1;
|
|
4540
|
-
const redoMutationParams = {
|
|
4541
|
-
unitId,
|
|
4542
|
-
subUnitId,
|
|
4543
|
-
ranges,
|
|
4544
|
-
autoHeightInfo: BooleanNumber.TRUE
|
|
4545
|
-
// Hard code first, maybe it will change by the menu item in the future.
|
|
4546
|
-
}, undoMutationParams = SetWorksheetRowIsAutoHeightMutationFactory(redoMutationParams, worksheet), setIsAutoHeightResult = commandService.syncExecuteCommand(
|
|
4547
|
-
SetWorksheetRowIsAutoHeightMutation.id,
|
|
4548
|
-
redoMutationParams
|
|
4549
|
-
), { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
4550
|
-
id: SetWorksheetRowIsAutoHeightCommand.id,
|
|
4551
|
-
params: redoMutationParams
|
|
4552
|
-
}), result = sequenceExecute([...redos], commandService);
|
|
4553
|
-
return setIsAutoHeightResult && result.result ? (undoRedoService.pushUndoRedo({
|
|
4554
|
-
unitID: unitId,
|
|
4555
|
-
undoMutations: [{ id: SetWorksheetRowIsAutoHeightMutation.id, params: undoMutationParams }, ...undos],
|
|
4556
|
-
redoMutations: [{ id: SetWorksheetRowIsAutoHeightMutation.id, params: redoMutationParams }, ...redos]
|
|
4557
|
-
}), !0) : !1;
|
|
4558
|
-
}, "handler")
|
|
4559
|
-
}, SetWorksheetShowCommand = {
|
|
4560
|
-
type: CommandType.COMMAND,
|
|
4561
|
-
id: "sheet.command.set-worksheet-show",
|
|
4562
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4563
|
-
const { unitId, subUnitId } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4564
|
-
if (!getSheetCommandTarget(accessor.get(IUniverInstanceService))) return !1;
|
|
4565
|
-
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
4566
|
-
if (!workbook) return !1;
|
|
4567
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
4568
|
-
if (!worksheet || worksheet.getConfig().hidden === BooleanNumber.FALSE) return !1;
|
|
4569
|
-
const redoMutationParams = {
|
|
4570
|
-
unitId,
|
|
4571
|
-
subUnitId,
|
|
4572
|
-
hidden: BooleanNumber.FALSE
|
|
4573
|
-
}, undoMutationParams = SetWorksheetHideMutationFactory(accessor, redoMutationParams), result = commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams), activeSheetMutationParams = {
|
|
4574
|
-
unitId,
|
|
4575
|
-
subUnitId
|
|
4576
|
-
}, activeResult = commandService.syncExecuteCommand(
|
|
4577
|
-
SetWorksheetActiveOperation.id,
|
|
4578
|
-
activeSheetMutationParams
|
|
4579
|
-
);
|
|
4580
|
-
return result && activeResult ? (undoRedoService.pushUndoRedo({
|
|
4581
|
-
unitID: unitId,
|
|
4582
|
-
undoMutations: [
|
|
4583
|
-
{ id: SetWorksheetHideMutation.id, params: undoMutationParams }
|
|
4584
|
-
// { id: SetWorksheetActiveOperation.id, params: unActiveMutationParams },
|
|
4585
|
-
],
|
|
4586
|
-
redoMutations: [
|
|
4587
|
-
// { id: SetWorksheetActiveOperation.id, params: activeSheetMutationParams },
|
|
4588
|
-
{ id: SetWorksheetHideMutation.id, params: redoMutationParams }
|
|
4589
|
-
]
|
|
4590
|
-
}), !0) : !1;
|
|
4591
|
-
}, "handler")
|
|
4592
|
-
}, createTopMatrixFromRanges = /* @__PURE__ */ __name((ranges) => {
|
|
4593
|
-
const matrix = new ObjectMatrix();
|
|
4594
|
-
return ranges.forEach((range) => {
|
|
4595
|
-
Range.foreach(range, (row, col) => {
|
|
4596
|
-
matrix.setValue(row, col, 1);
|
|
4597
|
-
});
|
|
4598
|
-
}), matrix.forValue((row, col) => {
|
|
4599
|
-
const theLastRowValue = matrix.getValue(row - 1, col);
|
|
4600
|
-
theLastRowValue && matrix.setValue(row, col, theLastRowValue + 1);
|
|
4601
|
-
}), matrix;
|
|
4602
|
-
}, "createTopMatrixFromRanges"), createTopMatrixFromMatrix = /* @__PURE__ */ __name((matrix) => {
|
|
4603
|
-
const _matrix = matrix;
|
|
4604
|
-
return _matrix.forValue((row, col) => {
|
|
4605
|
-
const theLastRowValue = matrix.getValue(row - 1, col);
|
|
4606
|
-
theLastRowValue && _matrix.setValue(row, col, theLastRowValue + 1);
|
|
4607
|
-
}), _matrix;
|
|
4608
|
-
}, "createTopMatrixFromMatrix"), findMaximalRectangle = /* @__PURE__ */ __name((topMatrix) => {
|
|
4609
|
-
const res = {
|
|
4610
|
-
area: 0
|
|
4611
|
-
}, checkArea = /* @__PURE__ */ __name((area, range) => res.area < area ? (res.area = area, res.range = range, !0) : !1, "checkArea");
|
|
4612
|
-
return topMatrix.forValue((row, col, lineArea) => {
|
|
4613
|
-
let cols = 1, rows = lineArea;
|
|
4614
|
-
checkArea(cols * rows, {
|
|
4615
|
-
startRow: row - rows + 1,
|
|
4616
|
-
endRow: row,
|
|
4617
|
-
startColumn: col,
|
|
4618
|
-
endColumn: col
|
|
4619
|
-
});
|
|
4620
|
-
const _range = {
|
|
4621
|
-
startRow: row - rows + 1,
|
|
4622
|
-
endRow: row,
|
|
4623
|
-
startColumn: 0,
|
|
4624
|
-
endColumn: col
|
|
4625
|
-
};
|
|
4626
|
-
for (let k = col - 1; k >= 0 && topMatrix.getValue(row, k); k--) {
|
|
4627
|
-
rows = Math.min(topMatrix.getValue(row, k) || 0, rows), cols++;
|
|
4628
|
-
const area = rows * cols;
|
|
4629
|
-
_range.startColumn = k, _range.startRow = row - rows + 1, checkArea(area, _range);
|
|
4630
|
-
}
|
|
4631
|
-
}), res;
|
|
4632
|
-
}, "findMaximalRectangle"), filterLeftMatrix = /* @__PURE__ */ __name((topMatrix, range) => {
|
|
4633
|
-
Range.foreach(range, (row, col) => {
|
|
4634
|
-
topMatrix.realDeleteValue(row, col);
|
|
4635
|
-
});
|
|
4636
|
-
for (let col = range.startColumn; col <= range.endColumn; col++) {
|
|
4637
|
-
const row = range.endRow + 1;
|
|
4638
|
-
if (topMatrix.getValue(row, col) > 0) {
|
|
4639
|
-
topMatrix.setValue(row, col, 1);
|
|
4640
|
-
let nextRow = row + 1;
|
|
4641
|
-
for (; topMatrix.getValue(nextRow, col) > 0; )
|
|
4642
|
-
topMatrix.setValue(nextRow, col, topMatrix.getValue(nextRow - 1, col) + 1), nextRow++;
|
|
4643
|
-
}
|
|
4644
|
-
}
|
|
4645
|
-
return topMatrix;
|
|
4646
|
-
}, "filterLeftMatrix"), findAllRectangle = /* @__PURE__ */ __name((topMatrix) => {
|
|
4647
|
-
const resultList = [];
|
|
4648
|
-
let result = findMaximalRectangle(topMatrix);
|
|
4649
|
-
for (; result.area > 0; )
|
|
4650
|
-
result.range && (resultList.push(result.range), filterLeftMatrix(topMatrix, result.range)), result = findMaximalRectangle(topMatrix);
|
|
4651
|
-
return resultList;
|
|
4652
|
-
}, "findAllRectangle"), rangeMerge = /* @__PURE__ */ __name((ranges) => {
|
|
4653
|
-
const topMatrix = createTopMatrixFromRanges(ranges);
|
|
4654
|
-
return findAllRectangle(topMatrix);
|
|
4655
|
-
}, "rangeMerge"), _RangeMergeUtil = class _RangeMergeUtil {
|
|
4656
|
-
constructor() {
|
|
4657
|
-
__publicField(this, "_matrix", new ObjectMatrix());
|
|
4658
|
-
}
|
|
4659
|
-
add(...ranges) {
|
|
4660
|
-
return ranges.forEach((range) => {
|
|
4661
|
-
Range.foreach(range, (row, col) => {
|
|
4662
|
-
this._matrix.setValue(row, col, 1);
|
|
4663
|
-
});
|
|
4664
|
-
}), this;
|
|
4665
|
-
}
|
|
4666
|
-
subtract(...ranges) {
|
|
4667
|
-
return ranges.forEach((range) => {
|
|
4668
|
-
Range.foreach(range, (row, col) => {
|
|
4669
|
-
this._matrix.realDeleteValue(row, col);
|
|
4670
|
-
});
|
|
4671
|
-
}), this;
|
|
4672
|
-
}
|
|
4673
|
-
merge() {
|
|
4674
|
-
const topMatrix = createTopMatrixFromMatrix(this._matrix);
|
|
4675
|
-
return findAllRectangle(topMatrix);
|
|
4676
|
-
}
|
|
4677
|
-
};
|
|
4678
|
-
__name(_RangeMergeUtil, "RangeMergeUtil");
|
|
4679
|
-
let RangeMergeUtil = _RangeMergeUtil;
|
|
4680
|
-
const INumfmtService = createIdentifier("INumfmtService");
|
|
4681
|
-
runOnLifecycle(LifecycleStages.Ready, INumfmtService);
|
|
4682
|
-
const factorySetNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) => {
|
|
4683
|
-
const numfmtService = accessor.get(INumfmtService), { values, unitId, subUnitId } = option, cells = [], removeCells = [];
|
|
4684
|
-
Object.keys(values).forEach((id) => {
|
|
4685
|
-
values[id].ranges.forEach((range) => {
|
|
4686
|
-
Range.foreach(range, (row, col) => {
|
|
4687
|
-
const oldNumfmt = numfmtService.getValue(unitId, subUnitId, row, col);
|
|
4688
|
-
oldNumfmt ? cells.push({
|
|
4689
|
-
pattern: oldNumfmt.pattern,
|
|
4690
|
-
row,
|
|
4691
|
-
col
|
|
4692
|
-
}) : removeCells.push({ startColumn: col, endColumn: col, startRow: row, endRow: row });
|
|
4693
|
-
});
|
|
4694
|
-
});
|
|
4695
|
-
});
|
|
4696
|
-
const result = [];
|
|
4697
|
-
if (cells.length) {
|
|
4698
|
-
const params = transformCellsToRange(unitId, subUnitId, cells);
|
|
4699
|
-
Object.keys(params.values).forEach((key) => {
|
|
4700
|
-
const v = params.values[key];
|
|
4701
|
-
v.ranges = rangeMerge(v.ranges);
|
|
4702
|
-
}), result.push({
|
|
4703
|
-
id: SetNumfmtMutation.id,
|
|
4704
|
-
params: transformCellsToRange(unitId, subUnitId, cells)
|
|
4705
|
-
});
|
|
4706
|
-
}
|
|
4707
|
-
return removeCells.length && result.push({
|
|
4708
|
-
id: RemoveNumfmtMutation.id,
|
|
4709
|
-
params: {
|
|
4710
|
-
unitId,
|
|
4711
|
-
subUnitId,
|
|
4712
|
-
ranges: removeCells
|
|
4713
|
-
}
|
|
4714
|
-
}), result;
|
|
4715
|
-
}, "factorySetNumfmtUndoMutation"), SetNumfmtMutation = {
|
|
4716
|
-
id: "sheet.mutation.set.numfmt",
|
|
4717
|
-
type: CommandType.MUTATION,
|
|
4718
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4719
|
-
if (!params)
|
|
4720
|
-
return !1;
|
|
4721
|
-
const { values, refMap } = params, numfmtService = accessor.get(INumfmtService), unitId = params.unitId, sheetId = params.subUnitId, setValues = Object.keys(values).reduce(
|
|
4722
|
-
(result, id) => {
|
|
4723
|
-
const value = refMap[id], ranges = values[id].ranges;
|
|
4724
|
-
return value && result.push({
|
|
4725
|
-
...value,
|
|
4726
|
-
ranges
|
|
4727
|
-
}), result;
|
|
4728
|
-
},
|
|
4729
|
-
[]
|
|
4730
|
-
);
|
|
4731
|
-
return numfmtService.setValues(unitId, sheetId, setValues), !0;
|
|
4732
|
-
}, "handler")
|
|
4733
|
-
}, RemoveNumfmtMutation = {
|
|
4734
|
-
id: "sheet.mutation.remove.numfmt",
|
|
4735
|
-
type: CommandType.MUTATION,
|
|
4736
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4737
|
-
if (!params)
|
|
4738
|
-
return !1;
|
|
4739
|
-
const { unitId, subUnitId, ranges } = params;
|
|
4740
|
-
return accessor.get(INumfmtService).deleteValues(unitId, subUnitId, ranges), !0;
|
|
4741
|
-
}, "handler")
|
|
4742
|
-
}, factoryRemoveNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) => {
|
|
4743
|
-
const numfmtService = accessor.get(INumfmtService), { ranges, unitId, subUnitId } = option, cells = [];
|
|
4744
|
-
if (ranges.forEach((range) => {
|
|
4745
|
-
Range.foreach(range, (row, col) => {
|
|
4746
|
-
const oldNumfmt = numfmtService.getValue(unitId, subUnitId, row, col);
|
|
4747
|
-
oldNumfmt && cells.push({
|
|
4748
|
-
pattern: oldNumfmt.pattern,
|
|
4749
|
-
row,
|
|
4750
|
-
col
|
|
4751
|
-
});
|
|
4752
|
-
});
|
|
4753
|
-
}), !cells.length)
|
|
4754
|
-
return [];
|
|
4755
|
-
const params = transformCellsToRange(unitId, subUnitId, cells);
|
|
4756
|
-
return Object.keys(params.values).forEach((key) => {
|
|
4757
|
-
const v = params.values[key];
|
|
4758
|
-
v.ranges = rangeMerge(v.ranges);
|
|
4759
|
-
}), [{ id: SetNumfmtMutation.id, params }];
|
|
4760
|
-
}, "factoryRemoveNumfmtUndoMutation"), transformCellsToRange = /* @__PURE__ */ __name((unitId, subUnitId, cells) => {
|
|
4761
|
-
const group = groupByKey(cells, "pattern"), refMap = {}, values = {}, getKey = createUniqueKey();
|
|
4762
|
-
return Object.keys(group).forEach((pattern) => {
|
|
4763
|
-
const groupItem = group[pattern], key = getKey();
|
|
4764
|
-
refMap[key] = {
|
|
4765
|
-
pattern
|
|
4766
|
-
}, groupItem.forEach((item) => {
|
|
4767
|
-
values[key] || (values[key] = { ranges: [] }), values[key].ranges.push(cellToRange(item.row, item.col));
|
|
4768
|
-
});
|
|
4769
|
-
}), { unitId, subUnitId, refMap, values };
|
|
4770
|
-
}, "transformCellsToRange"), EmptyMutation = {
|
|
4771
|
-
id: "sheet.mutation.empty",
|
|
4772
|
-
type: CommandType.MUTATION,
|
|
4773
|
-
handler: /* @__PURE__ */ __name(() => !0, "handler")
|
|
4774
|
-
}, InsertDefinedNameCommand = {
|
|
4775
|
-
id: "sheet.command.insert-defined-name",
|
|
4776
|
-
type: CommandType.COMMAND,
|
|
4777
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4778
|
-
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
4779
|
-
if (!params) return !1;
|
|
4780
|
-
const insertSheetMutationParams = {
|
|
4781
|
-
...params
|
|
4782
|
-
};
|
|
4783
|
-
return commandService.syncExecuteCommand(SetDefinedNameMutation.id, insertSheetMutationParams) ? (undoRedoService.pushUndoRedo({
|
|
4784
|
-
unitID: params.unitId,
|
|
4785
|
-
undoMutations: [{ id: RemoveDefinedNameMutation.id, params: insertSheetMutationParams }],
|
|
4786
|
-
redoMutations: [{ id: SetDefinedNameMutation.id, params: insertSheetMutationParams }]
|
|
4787
|
-
}), !0) : !1;
|
|
4788
|
-
}, "handler")
|
|
4789
|
-
}, RemoveDefinedNameCommand = {
|
|
4790
|
-
id: "sheet.command.remove-defined-name",
|
|
4791
|
-
type: CommandType.COMMAND,
|
|
4792
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4793
|
-
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
4794
|
-
if (!params) return !1;
|
|
4795
|
-
const removeSheetMutationParams = {
|
|
4796
|
-
...params
|
|
4797
|
-
};
|
|
4798
|
-
return commandService.syncExecuteCommand(RemoveDefinedNameMutation.id, removeSheetMutationParams) ? (undoRedoService.pushUndoRedo({
|
|
4799
|
-
unitID: params.unitId,
|
|
4800
|
-
undoMutations: [{ id: SetDefinedNameMutation.id, params: removeSheetMutationParams }],
|
|
4801
|
-
redoMutations: [{ id: RemoveDefinedNameMutation.id, params: removeSheetMutationParams }]
|
|
4802
|
-
}), !0) : !1;
|
|
4803
|
-
}, "handler")
|
|
4804
|
-
}, SetDefinedNameCommand = {
|
|
4805
|
-
id: "sheet.command.set-defined-name",
|
|
4806
|
-
type: CommandType.COMMAND,
|
|
4807
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4808
|
-
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
4809
|
-
return params && commandService.syncExecuteCommand(SetDefinedNameMutation.id, params.newDefinedName) ? (undoRedoService.pushUndoRedo({
|
|
4810
|
-
unitID: params.unitId,
|
|
4811
|
-
undoMutations: [{ id: SetDefinedNameMutation.id, params: params.oldDefinedName }],
|
|
4812
|
-
redoMutations: [{ id: SetDefinedNameMutation.id, params: params.newDefinedName }]
|
|
4813
|
-
}), !0) : !1;
|
|
4814
|
-
}, "handler")
|
|
4815
|
-
}, ScrollToCellOperation = {
|
|
4816
|
-
id: "sheet.operation.scroll-to-cell",
|
|
4817
|
-
type: CommandType.OPERATION,
|
|
4818
|
-
handler: /* @__PURE__ */ __name(() => !0, "handler")
|
|
4819
|
-
}, SetWorkbookNameMutation = {
|
|
4820
|
-
id: "sheet.mutation.set-workbook-name",
|
|
4821
|
-
type: CommandType.MUTATION,
|
|
4822
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4823
|
-
const workbook = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET);
|
|
4824
|
-
return workbook ? (workbook.setName(params.name), !0) : !1;
|
|
4825
|
-
}, "handler")
|
|
4826
|
-
}, SetWorkbookNameCommand = {
|
|
4827
|
-
type: CommandType.COMMAND,
|
|
4828
|
-
id: "sheet.command.set-workbook-name",
|
|
4829
|
-
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4830
|
-
var _a21;
|
|
4831
|
-
if (!accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET)) return !1;
|
|
4832
|
-
const interceptedCommands = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
4833
|
-
id: SetWorkbookNameCommand.id,
|
|
4834
|
-
params
|
|
4835
|
-
}), redoMutationParams = {
|
|
4836
|
-
name: params.name,
|
|
4837
|
-
unitId: params.unitId
|
|
4838
|
-
}, redos = [
|
|
4839
|
-
...(_a21 = interceptedCommands.preRedos) != null ? _a21 : [],
|
|
4840
|
-
{ id: SetWorkbookNameMutation.id, params: redoMutationParams },
|
|
4841
|
-
...interceptedCommands.redos
|
|
4842
|
-
], commandService = accessor.get(ICommandService);
|
|
4843
|
-
return sequenceExecute(redos, commandService).result;
|
|
4844
|
-
}, "handler")
|
|
4845
|
-
};
|
|
4846
|
-
var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
4847
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4848
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4849
|
-
return kind && result && __defProp$g(target, key, result), result;
|
|
4850
|
-
}, "__decorateClass$g"), _a4;
|
|
4851
|
-
let WorksheetProtectionRuleModel = (_a4 = class {
|
|
4852
|
-
constructor() {
|
|
4853
|
-
/**
|
|
4854
|
-
*
|
|
4855
|
-
* Map<unitId, Map<subUnitId, Map<subUnitId, IWorksheetProtectionRule>>>
|
|
4856
|
-
*/
|
|
4857
|
-
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
4858
|
-
__publicField(this, "_ruleChange", new Subject());
|
|
4859
|
-
__publicField(this, "_ruleRefresh", new Subject());
|
|
4860
|
-
__publicField(this, "_resetOrder", new Subject());
|
|
4861
|
-
__publicField(this, "ruleChange$", this._ruleChange.asObservable());
|
|
4862
|
-
__publicField(this, "ruleRefresh$", this._ruleRefresh.asObservable());
|
|
4863
|
-
__publicField(this, "resetOrder$", this._resetOrder.asObservable());
|
|
4864
|
-
__publicField(this, "_worksheetRuleInitStateChange", new BehaviorSubject(!1));
|
|
4865
|
-
__publicField(this, "worksheetRuleInitStateChange$", this._worksheetRuleInitStateChange.asObservable());
|
|
4866
|
-
}
|
|
4867
|
-
changeRuleInitState(state) {
|
|
4868
|
-
this._worksheetRuleInitStateChange.next(state);
|
|
4869
|
-
}
|
|
4870
|
-
getSheetRuleInitState() {
|
|
4871
|
-
return this._worksheetRuleInitStateChange.value;
|
|
4872
|
-
}
|
|
4873
|
-
addRule(unitId, rule) {
|
|
4874
|
-
this._ensureSubUnitMap(unitId).set(rule.subUnitId, rule), this._ruleChange.next({ unitId, rule, type: "add", subUnitId: rule.subUnitId });
|
|
4875
|
-
}
|
|
4876
|
-
deleteRule(unitId, subUnitId) {
|
|
4877
|
-
var _a21, _b, _c;
|
|
4878
|
-
const rule = (_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null ? void 0 : _b.get(subUnitId);
|
|
4879
|
-
rule && ((_c = this._model.get(unitId)) == null || _c.delete(subUnitId), this._ruleChange.next({ unitId, rule, type: "delete", subUnitId }));
|
|
4880
|
-
}
|
|
4881
|
-
setRule(unitId, subUnitId, rule) {
|
|
4882
|
-
var _a21, _b;
|
|
4883
|
-
const oldRule = this.getRule(unitId, subUnitId);
|
|
4884
|
-
oldRule && ((_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null || _b.set(subUnitId, rule), this._ruleChange.next({ unitId, oldRule, rule, type: "set", subUnitId }));
|
|
4885
|
-
}
|
|
4886
|
-
getRule(unitId, subUnitId) {
|
|
4887
|
-
var _a21, _b;
|
|
4888
|
-
return (_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null ? void 0 : _b.get(subUnitId);
|
|
4889
|
-
}
|
|
4890
|
-
toObject() {
|
|
4891
|
-
const result = {};
|
|
4892
|
-
return [...this._model.keys()].forEach((unitId) => {
|
|
4893
|
-
const subUnitMap = this._model.get(unitId);
|
|
4894
|
-
subUnitMap != null && subUnitMap.size && (result[unitId] = [], [...subUnitMap.keys()].forEach((subUnitId) => {
|
|
4895
|
-
const rule = subUnitMap.get(subUnitId);
|
|
4896
|
-
rule && result[unitId].push(rule);
|
|
4897
|
-
}));
|
|
4898
|
-
}), result;
|
|
4899
|
-
}
|
|
4900
|
-
fromObject(obj) {
|
|
4901
|
-
const result = /* @__PURE__ */ new Map();
|
|
4902
|
-
Object.keys(obj).forEach((unitId) => {
|
|
4903
|
-
const subUnitList = obj[unitId];
|
|
4904
|
-
if (subUnitList != null && subUnitList.length) {
|
|
4905
|
-
const subUnitMap = /* @__PURE__ */ new Map();
|
|
4906
|
-
subUnitList.forEach((rule) => {
|
|
4907
|
-
subUnitMap.set(rule.subUnitId, rule);
|
|
4908
|
-
}), result.set(unitId, subUnitMap);
|
|
4909
|
-
}
|
|
4910
|
-
}), this._model = result;
|
|
4911
|
-
}
|
|
4912
|
-
deleteUnitModel(unitId) {
|
|
4913
|
-
this._model.delete(unitId);
|
|
4914
|
-
}
|
|
4915
|
-
_ensureSubUnitMap(unitId) {
|
|
4916
|
-
let subUnitMap = this._model.get(unitId);
|
|
4917
|
-
return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._model.set(unitId, subUnitMap)), subUnitMap;
|
|
4918
|
-
}
|
|
4919
|
-
ruleRefresh(permissionId) {
|
|
4920
|
-
this._ruleRefresh.next(permissionId);
|
|
4921
|
-
}
|
|
4922
|
-
resetOrder() {
|
|
4923
|
-
this._resetOrder.next(Math.random());
|
|
4924
|
-
}
|
|
4925
|
-
getTargetByPermissionId(unitId, permissionId) {
|
|
4926
|
-
const subUnitMap = this._model.get(unitId);
|
|
4927
|
-
if (!subUnitMap) return null;
|
|
4928
|
-
for (const [subUnitId, rule] of subUnitMap)
|
|
4929
|
-
if (rule.permissionId === permissionId)
|
|
4930
|
-
return [unitId, subUnitId];
|
|
4931
|
-
}
|
|
4932
|
-
}, __name(_a4, "WorksheetProtectionRuleModel"), _a4);
|
|
4933
|
-
WorksheetProtectionRuleModel = __decorateClass$g([
|
|
4934
|
-
OnLifecycle(LifecycleStages.Starting, WorksheetProtectionRuleModel)
|
|
4935
|
-
], WorksheetProtectionRuleModel);
|
|
4936
|
-
const AddWorksheetProtectionMutation = {
|
|
4937
|
-
id: "sheet.mutation.add-worksheet-protection",
|
|
4938
|
-
type: CommandType.MUTATION,
|
|
4939
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4940
|
-
const { unitId, rule } = params;
|
|
4941
|
-
return accessor.get(WorksheetProtectionRuleModel).addRule(unitId, rule), !0;
|
|
4942
|
-
}, "handler")
|
|
4943
|
-
}, SetWorksheetProtectionMutation = {
|
|
4944
|
-
id: "sheet.mutation.set-worksheet-protection",
|
|
4945
|
-
type: CommandType.MUTATION,
|
|
4946
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4947
|
-
const { unitId, subUnitId, rule } = params;
|
|
4948
|
-
return accessor.get(WorksheetProtectionRuleModel).setRule(unitId, subUnitId, rule), !0;
|
|
4949
|
-
}, "handler")
|
|
4950
|
-
}, DeleteWorksheetProtectionMutation = {
|
|
4951
|
-
id: "sheet.mutation.delete-worksheet-protection",
|
|
4952
|
-
type: CommandType.MUTATION,
|
|
4953
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4954
|
-
const { unitId, subUnitId } = params;
|
|
4955
|
-
return accessor.get(WorksheetProtectionRuleModel).deleteRule(unitId, subUnitId), !0;
|
|
4956
|
-
}, "handler")
|
|
4957
|
-
};
|
|
4958
|
-
var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
4959
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4960
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4961
|
-
return kind && result && __defProp$f(target, key, result), result;
|
|
4962
|
-
}, "__decorateClass$f"), _a5;
|
|
4963
|
-
let RangeProtectionRuleModel = (_a5 = class {
|
|
4964
|
-
constructor() {
|
|
4965
|
-
/**
|
|
4966
|
-
*
|
|
4967
|
-
* Map<unitId, Map<subUnitId, Map<ruleId, IRangeProtectionRule>>>
|
|
4968
|
-
*/
|
|
4969
|
-
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
4970
|
-
__publicField(this, "_ruleChange", new Subject());
|
|
4971
|
-
__publicField(this, "ruleChange$", this._ruleChange.asObservable());
|
|
4972
|
-
__publicField(this, "_ruleRefresh", new Subject());
|
|
4973
|
-
__publicField(this, "ruleRefresh$", this._ruleRefresh.asObservable());
|
|
4974
|
-
__publicField(this, "_rangeRuleInitStateChange", new BehaviorSubject(!1));
|
|
4975
|
-
__publicField(this, "rangeRuleInitStateChange$", this._rangeRuleInitStateChange.asObservable());
|
|
4976
|
-
}
|
|
4977
|
-
ruleRefresh(id) {
|
|
4978
|
-
this._ruleRefresh.next(id);
|
|
4979
|
-
}
|
|
4980
|
-
getRangeRuleInitState() {
|
|
4981
|
-
return this._rangeRuleInitStateChange.value;
|
|
4982
|
-
}
|
|
4983
|
-
changeRuleInitState(state) {
|
|
4984
|
-
this._rangeRuleInitStateChange.next(state);
|
|
4985
|
-
}
|
|
4986
|
-
addRule(unitId, subUnitId, rule) {
|
|
4987
|
-
this._ensureRuleMap(unitId, subUnitId).set(rule.id, rule), this._ruleChange.next({ unitId, subUnitId, rule, type: "add" });
|
|
4988
|
-
}
|
|
4989
|
-
deleteRule(unitId, subUnitId, id) {
|
|
4990
|
-
var _a21, _b, _c, _d;
|
|
4991
|
-
const rule = (_b = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null ? void 0 : _b.get(id);
|
|
4992
|
-
rule && ((_d = (_c = this._model.get(unitId)) == null ? void 0 : _c.get(subUnitId)) == null || _d.delete(id), this._ruleChange.next({ unitId, subUnitId, rule, type: "delete" }));
|
|
4993
|
-
}
|
|
4994
|
-
setRule(unitId, subUnitId, id, rule) {
|
|
4995
|
-
var _a21, _b;
|
|
4996
|
-
const oldRule = this.getRule(unitId, subUnitId, id);
|
|
4997
|
-
oldRule && ((_b = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null || _b.set(id, rule), this._ruleChange.next({ unitId, subUnitId, oldRule, rule, type: "set" }));
|
|
4998
|
-
}
|
|
4999
|
-
getRule(unitId, subUnitId, id) {
|
|
5000
|
-
var _a21, _b;
|
|
5001
|
-
return (_b = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null ? void 0 : _b.get(id);
|
|
5002
|
-
}
|
|
5003
|
-
getSubunitRuleList(unitId, subUnitId) {
|
|
5004
|
-
var _a21;
|
|
5005
|
-
return [...(((_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) || /* @__PURE__ */ new Map()).values()];
|
|
5006
|
-
}
|
|
5007
|
-
getSubunitRuleListLength(unitId, subUnitId) {
|
|
5008
|
-
var _a21;
|
|
5009
|
-
const map2 = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId);
|
|
5010
|
-
return map2 ? map2.size : 0;
|
|
5011
|
-
}
|
|
5012
|
-
_ensureRuleMap(unitId, subUnitId) {
|
|
5013
|
-
let subUnitMap = this._model.get(unitId);
|
|
5014
|
-
subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._model.set(unitId, subUnitMap));
|
|
5015
|
-
let ruleMap = subUnitMap.get(subUnitId);
|
|
5016
|
-
return ruleMap || (ruleMap = /* @__PURE__ */ new Map(), subUnitMap.set(subUnitId, ruleMap)), ruleMap;
|
|
5017
|
-
}
|
|
5018
|
-
toObject() {
|
|
5019
|
-
const result = {};
|
|
5020
|
-
return [...this._model.keys()].forEach((unitId) => {
|
|
5021
|
-
const submitMap = this._model.get(unitId), subUnitKeys = [...submitMap.keys()];
|
|
5022
|
-
result[unitId] = {}, subUnitKeys.forEach((subunitId) => {
|
|
5023
|
-
const ruleMap = submitMap.get(subunitId);
|
|
5024
|
-
result[unitId][subunitId] = [...ruleMap.values()];
|
|
5025
|
-
});
|
|
5026
|
-
}), result;
|
|
5027
|
-
}
|
|
5028
|
-
fromObject(obj) {
|
|
5029
|
-
const result = /* @__PURE__ */ new Map();
|
|
5030
|
-
Object.keys(obj).forEach((unitId) => {
|
|
5031
|
-
const subUnitObj = obj[unitId], map2 = /* @__PURE__ */ new Map();
|
|
5032
|
-
Object.keys(subUnitObj).forEach((subunitId) => {
|
|
5033
|
-
const ruleMap = subUnitObj[subunitId].reduce((result2, cur) => (result2.set(cur.id, cur), result2), /* @__PURE__ */ new Map());
|
|
5034
|
-
map2.set(subunitId, ruleMap);
|
|
5035
|
-
}), result.set(unitId, map2);
|
|
5036
|
-
}), this._model = result;
|
|
5037
|
-
}
|
|
5038
|
-
deleteUnitModel(unitId) {
|
|
5039
|
-
this._model.delete(unitId);
|
|
5040
|
-
}
|
|
5041
|
-
createRuleId(unitId, subUnitId) {
|
|
5042
|
-
let id = Tools.generateRandomId(4);
|
|
5043
|
-
const ruleMap = this._ensureRuleMap(unitId, subUnitId);
|
|
5044
|
-
for (; ruleMap.has(id); )
|
|
5045
|
-
id = Tools.generateRandomId(4);
|
|
5046
|
-
return id;
|
|
5047
|
-
}
|
|
5048
|
-
getTargetByPermissionId(unitId, permissionId) {
|
|
5049
|
-
const subUnitMap = this._model.get(unitId);
|
|
5050
|
-
if (!subUnitMap) return null;
|
|
5051
|
-
for (const [subUnitId, ruleMap] of subUnitMap)
|
|
5052
|
-
for (const rule of ruleMap.values())
|
|
5053
|
-
if (rule.permissionId === permissionId)
|
|
5054
|
-
return [unitId, subUnitId];
|
|
5055
|
-
return null;
|
|
5056
|
-
}
|
|
5057
|
-
}, __name(_a5, "RangeProtectionRuleModel"), _a5);
|
|
5058
|
-
RangeProtectionRuleModel = __decorateClass$f([
|
|
5059
|
-
OnLifecycle(LifecycleStages.Starting, RangeProtectionRuleModel)
|
|
5060
|
-
], RangeProtectionRuleModel);
|
|
5061
|
-
const getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
|
|
5062
|
-
WorksheetEditPermission,
|
|
5063
|
-
WorksheetViewPermission
|
|
5064
|
-
], "getAllWorksheetPermissionPoint"), getAllWorksheetPermissionPointByPointPanel = /* @__PURE__ */ __name(() => [
|
|
5065
|
-
WorksheetCopyPermission,
|
|
5066
|
-
WorksheetDeleteColumnPermission,
|
|
5067
|
-
WorksheetDeleteRowPermission,
|
|
5068
|
-
WorksheetEditExtraObjectPermission,
|
|
5069
|
-
WorksheetFilterPermission,
|
|
5070
|
-
WorksheetInsertColumnPermission,
|
|
5071
|
-
WorksheetInsertRowPermission,
|
|
5072
|
-
WorksheetInsertHyperlinkPermission,
|
|
5073
|
-
WorksheetPivotTablePermission,
|
|
5074
|
-
WorksheetSetCellStylePermission,
|
|
5075
|
-
WorksheetSetCellValuePermission,
|
|
5076
|
-
WorksheetSetColumnStylePermission,
|
|
5077
|
-
WorksheetSetRowStylePermission,
|
|
5078
|
-
WorksheetSortPermission
|
|
5079
|
-
], "getAllWorksheetPermissionPointByPointPanel"), defaultWorksheetPermissionPoint = [
|
|
5080
|
-
P.Copy,
|
|
5081
|
-
P.DeleteColumn,
|
|
5082
|
-
P.DeleteRow,
|
|
5083
|
-
P.EditExtraObject,
|
|
5084
|
-
P.Filter,
|
|
5085
|
-
P.InsertColumn,
|
|
5086
|
-
P.InsertRow,
|
|
5087
|
-
P.InsertHyperlink,
|
|
5088
|
-
P.PivotTable,
|
|
5089
|
-
P.SetCellStyle,
|
|
5090
|
-
P.SetCellValue,
|
|
5091
|
-
P.SetColumnStyle,
|
|
5092
|
-
P.SetRowStyle,
|
|
5093
|
-
P.Sort
|
|
5094
|
-
];
|
|
5095
|
-
var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
5096
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5097
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
5098
|
-
return kind && result && __defProp$e(target, key, result), result;
|
|
5099
|
-
}, "__decorateClass$e"), _a6;
|
|
5100
|
-
let WorksheetProtectionPointModel = (_a6 = class {
|
|
4745
|
+
}), this._model = result;
|
|
4746
|
+
}
|
|
4747
|
+
deleteUnitModel(unitId) {
|
|
4748
|
+
this._model.delete(unitId);
|
|
4749
|
+
}
|
|
4750
|
+
_ensureSubUnitMap(unitId) {
|
|
4751
|
+
let subUnitMap = this._model.get(unitId);
|
|
4752
|
+
return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._model.set(unitId, subUnitMap)), subUnitMap;
|
|
4753
|
+
}
|
|
4754
|
+
getTargetByPermissionId(unitId, permissionId) {
|
|
4755
|
+
const subUnitMap = this._model.get(unitId);
|
|
4756
|
+
if (!subUnitMap) return null;
|
|
4757
|
+
for (const [subUnitId, rule] of subUnitMap)
|
|
4758
|
+
if (rule.permissionId === permissionId)
|
|
4759
|
+
return [unitId, subUnitId];
|
|
4760
|
+
}
|
|
4761
|
+
};
|
|
4762
|
+
__name(_WorksheetProtectionPointModel, "WorksheetProtectionPointModel");
|
|
4763
|
+
let WorksheetProtectionPointModel = _WorksheetProtectionPointModel;
|
|
4764
|
+
const _WorksheetProtectionRuleModel = class _WorksheetProtectionRuleModel {
|
|
5101
4765
|
constructor() {
|
|
4766
|
+
/**
|
|
4767
|
+
*
|
|
4768
|
+
* Map<unitId, Map<subUnitId, Map<subUnitId, IWorksheetProtectionRule>>>
|
|
4769
|
+
*/
|
|
5102
4770
|
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
5103
|
-
__publicField(this, "
|
|
5104
|
-
__publicField(this, "
|
|
4771
|
+
__publicField(this, "_ruleChange", new Subject());
|
|
4772
|
+
__publicField(this, "_ruleRefresh", new Subject());
|
|
4773
|
+
__publicField(this, "_resetOrder", new Subject());
|
|
4774
|
+
__publicField(this, "ruleChange$", this._ruleChange.asObservable());
|
|
4775
|
+
__publicField(this, "ruleRefresh$", this._ruleRefresh.asObservable());
|
|
4776
|
+
__publicField(this, "resetOrder$", this._resetOrder.asObservable());
|
|
4777
|
+
__publicField(this, "_worksheetRuleInitStateChange", new BehaviorSubject(!1));
|
|
4778
|
+
__publicField(this, "worksheetRuleInitStateChange$", this._worksheetRuleInitStateChange.asObservable());
|
|
5105
4779
|
}
|
|
5106
|
-
|
|
5107
|
-
this.
|
|
4780
|
+
changeRuleInitState(state) {
|
|
4781
|
+
this._worksheetRuleInitStateChange.next(state);
|
|
4782
|
+
}
|
|
4783
|
+
getSheetRuleInitState() {
|
|
4784
|
+
return this._worksheetRuleInitStateChange.value;
|
|
4785
|
+
}
|
|
4786
|
+
addRule(unitId, rule) {
|
|
4787
|
+
this._ensureSubUnitMap(unitId).set(rule.subUnitId, rule), this._ruleChange.next({ unitId, rule, type: "add", subUnitId: rule.subUnitId });
|
|
5108
4788
|
}
|
|
5109
4789
|
deleteRule(unitId, subUnitId) {
|
|
5110
|
-
var
|
|
5111
|
-
const rule = (
|
|
5112
|
-
rule && ((_c =
|
|
4790
|
+
var _a18, _b, _c;
|
|
4791
|
+
const rule = (_b = (_a18 = this._model) == null ? void 0 : _a18.get(unitId)) == null ? void 0 : _b.get(subUnitId);
|
|
4792
|
+
rule && ((_c = this._model.get(unitId)) == null || _c.delete(subUnitId), this._ruleChange.next({ unitId, rule, type: "delete", subUnitId }));
|
|
4793
|
+
}
|
|
4794
|
+
setRule(unitId, subUnitId, rule) {
|
|
4795
|
+
var _a18, _b;
|
|
4796
|
+
const oldRule = this.getRule(unitId, subUnitId);
|
|
4797
|
+
oldRule && ((_b = (_a18 = this._model) == null ? void 0 : _a18.get(unitId)) == null || _b.set(subUnitId, rule), this._ruleChange.next({ unitId, oldRule, rule, type: "set", subUnitId }));
|
|
5113
4798
|
}
|
|
5114
4799
|
getRule(unitId, subUnitId) {
|
|
5115
|
-
var
|
|
5116
|
-
return (_b = (
|
|
4800
|
+
var _a18, _b;
|
|
4801
|
+
return (_b = (_a18 = this._model) == null ? void 0 : _a18.get(unitId)) == null ? void 0 : _b.get(subUnitId);
|
|
5117
4802
|
}
|
|
5118
4803
|
toObject() {
|
|
5119
4804
|
const result = {};
|
|
@@ -5144,6 +4829,12 @@ let WorksheetProtectionPointModel = (_a6 = class {
|
|
|
5144
4829
|
let subUnitMap = this._model.get(unitId);
|
|
5145
4830
|
return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._model.set(unitId, subUnitMap)), subUnitMap;
|
|
5146
4831
|
}
|
|
4832
|
+
ruleRefresh(permissionId) {
|
|
4833
|
+
this._ruleRefresh.next(permissionId);
|
|
4834
|
+
}
|
|
4835
|
+
resetOrder() {
|
|
4836
|
+
this._resetOrder.next(Math.random());
|
|
4837
|
+
}
|
|
5147
4838
|
getTargetByPermissionId(unitId, permissionId) {
|
|
5148
4839
|
const subUnitMap = this._model.get(unitId);
|
|
5149
4840
|
if (!subUnitMap) return null;
|
|
@@ -5151,18 +4842,17 @@ let WorksheetProtectionPointModel = (_a6 = class {
|
|
|
5151
4842
|
if (rule.permissionId === permissionId)
|
|
5152
4843
|
return [unitId, subUnitId];
|
|
5153
4844
|
}
|
|
5154
|
-
}
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
], WorksheetProtectionPointModel);
|
|
4845
|
+
};
|
|
4846
|
+
__name(_WorksheetProtectionRuleModel, "WorksheetProtectionRuleModel");
|
|
4847
|
+
let WorksheetProtectionRuleModel = _WorksheetProtectionRuleModel;
|
|
5158
4848
|
var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
5159
4849
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5160
4850
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
5161
4851
|
return kind && result && __defProp$d(target, key, result), result;
|
|
5162
4852
|
}, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d");
|
|
5163
4853
|
const RULE_MODEL_PLUGIN_NAME = "SHEET_WORKSHEET_PROTECTION_PLUGIN", POINT_MODEL_PLUGIN_NAME = "SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN";
|
|
5164
|
-
var
|
|
5165
|
-
let WorksheetPermissionService = (
|
|
4854
|
+
var _a4;
|
|
4855
|
+
let WorksheetPermissionService = (_a4 = class extends RxDisposable {
|
|
5166
4856
|
constructor(_permissionService, _univerInstanceService, _injector, _worksheetProtectionRuleModel, _worksheetProtectionPointRuleModel, _resourceManagerService, _rangeProtectionRuleModel) {
|
|
5167
4857
|
super(), this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._injector = _injector, this._worksheetProtectionRuleModel = _worksheetProtectionRuleModel, this._worksheetProtectionPointRuleModel = _worksheetProtectionPointRuleModel, this._resourceManagerService = _resourceManagerService, this._rangeProtectionRuleModel = _rangeProtectionRuleModel, this._init(), this._initRuleChange(), this._initRuleSnapshot(), this._initPointSnapshot();
|
|
5168
4858
|
}
|
|
@@ -5294,9 +4984,8 @@ let WorksheetPermissionService = (_a7 = class extends RxDisposable {
|
|
|
5294
4984
|
})
|
|
5295
4985
|
);
|
|
5296
4986
|
}
|
|
5297
|
-
}, __name(
|
|
4987
|
+
}, __name(_a4, "WorksheetPermissionService"), _a4);
|
|
5298
4988
|
WorksheetPermissionService = __decorateClass$d([
|
|
5299
|
-
OnLifecycle(LifecycleStages.Starting, WorksheetPermissionService),
|
|
5300
4989
|
__decorateParam$d(0, Inject(IPermissionService)),
|
|
5301
4990
|
__decorateParam$d(1, Inject(IUniverInstanceService)),
|
|
5302
4991
|
__decorateParam$d(2, Inject(Injector)),
|
|
@@ -5312,216 +5001,528 @@ const SetWorksheetPermissionPointsMutation = {
|
|
|
5312
5001
|
const { rule } = params;
|
|
5313
5002
|
return accessor.get(WorksheetProtectionPointModel).addRule(rule), !0;
|
|
5314
5003
|
}, "handler")
|
|
5315
|
-
}, SetWorksheetPermissionPointsCommand = {
|
|
5004
|
+
}, SetWorksheetPermissionPointsCommand = {
|
|
5005
|
+
type: CommandType.COMMAND,
|
|
5006
|
+
id: "sheet.command.set-worksheet-permission-points",
|
|
5007
|
+
async handler(accessor, params) {
|
|
5008
|
+
if (!params)
|
|
5009
|
+
return !1;
|
|
5010
|
+
const commandService = accessor.get(ICommandService), { rule } = params;
|
|
5011
|
+
return commandService.executeCommand(SetWorksheetPermissionPointsMutation.id, {
|
|
5012
|
+
rule,
|
|
5013
|
+
unitId: rule.unitId,
|
|
5014
|
+
subUnitId: rule.subUnitId
|
|
5015
|
+
}), !0;
|
|
5016
|
+
}
|
|
5017
|
+
}, MAXIMUM_ROW_HEIGHT = 2e3, SetWorksheetRowHeightMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
5018
|
+
const { unitId, subUnitId, ranges } = params, rowHeight = {}, manager = worksheet.getRowManager();
|
|
5019
|
+
for (const { startRow, endRow } of ranges)
|
|
5020
|
+
for (let rowIndex = startRow; rowIndex < endRow + 1; rowIndex++) {
|
|
5021
|
+
const row = manager.getRowOrCreate(rowIndex);
|
|
5022
|
+
rowHeight[rowIndex] = row.h;
|
|
5023
|
+
}
|
|
5024
|
+
return {
|
|
5025
|
+
unitId,
|
|
5026
|
+
subUnitId,
|
|
5027
|
+
ranges,
|
|
5028
|
+
rowHeight
|
|
5029
|
+
};
|
|
5030
|
+
}, "SetWorksheetRowHeightMutationFactory"), SetWorksheetRowIsAutoHeightMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
5031
|
+
const { unitId, subUnitId, ranges } = params, autoHeightHash = {}, manager = worksheet.getRowManager();
|
|
5032
|
+
for (const { startRow, endRow } of ranges)
|
|
5033
|
+
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
5034
|
+
const row = manager.getRowOrCreate(rowIndex);
|
|
5035
|
+
autoHeightHash[rowIndex] = row.ia;
|
|
5036
|
+
}
|
|
5037
|
+
return {
|
|
5038
|
+
unitId,
|
|
5039
|
+
subUnitId,
|
|
5040
|
+
ranges,
|
|
5041
|
+
autoHeightInfo: autoHeightHash
|
|
5042
|
+
};
|
|
5043
|
+
}, "SetWorksheetRowIsAutoHeightMutationFactory"), SetWorksheetRowAutoHeightMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
5044
|
+
const { unitId, subUnitId, rowsAutoHeightInfo } = params, results = [], manager = worksheet.getRowManager();
|
|
5045
|
+
for (const rowInfo of rowsAutoHeightInfo) {
|
|
5046
|
+
const { row } = rowInfo, { ah } = manager.getRowOrCreate(row);
|
|
5047
|
+
results.push({ row, autoHeight: ah });
|
|
5048
|
+
}
|
|
5049
|
+
return {
|
|
5050
|
+
unitId,
|
|
5051
|
+
subUnitId,
|
|
5052
|
+
rowsAutoHeightInfo: results
|
|
5053
|
+
};
|
|
5054
|
+
}, "SetWorksheetRowAutoHeightMutationFactory"), SetWorksheetRowHeightMutation = {
|
|
5055
|
+
id: "sheet.mutation.set-worksheet-row-height",
|
|
5056
|
+
type: CommandType.MUTATION,
|
|
5057
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5058
|
+
var _a18;
|
|
5059
|
+
const { ranges, rowHeight } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
5060
|
+
if (!target) return !1;
|
|
5061
|
+
const { worksheet } = target, manager = worksheet.getRowManager(), defaultRowHeight = worksheet.getConfig().defaultRowHeight;
|
|
5062
|
+
for (const { startRow, endRow } of ranges)
|
|
5063
|
+
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
5064
|
+
const row = manager.getRowOrCreate(rowIndex);
|
|
5065
|
+
typeof rowHeight == "number" ? row.h = rowHeight : row.h = (_a18 = rowHeight[rowIndex]) != null ? _a18 : defaultRowHeight, row.h = Math.min(MAXIMUM_ROW_HEIGHT, row.h);
|
|
5066
|
+
}
|
|
5067
|
+
return !0;
|
|
5068
|
+
}, "handler")
|
|
5069
|
+
}, SetWorksheetRowIsAutoHeightMutation = {
|
|
5070
|
+
id: "sheet.mutation.set-worksheet-row-is-auto-height",
|
|
5071
|
+
type: CommandType.MUTATION,
|
|
5072
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5073
|
+
var _a18;
|
|
5074
|
+
const { ranges, autoHeightInfo } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
5075
|
+
if (!target) return !1;
|
|
5076
|
+
const manager = target.worksheet.getRowManager();
|
|
5077
|
+
for (const { startRow, endRow } of ranges)
|
|
5078
|
+
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
5079
|
+
const row = manager.getRowOrCreate(rowIndex);
|
|
5080
|
+
typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a18 = autoHeightInfo[rowIndex]) != null ? _a18 : void 0;
|
|
5081
|
+
}
|
|
5082
|
+
return !0;
|
|
5083
|
+
}, "handler")
|
|
5084
|
+
}, SetWorksheetRowAutoHeightMutation = {
|
|
5085
|
+
id: "sheet.mutation.set-worksheet-row-auto-height",
|
|
5086
|
+
type: CommandType.MUTATION,
|
|
5087
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5088
|
+
const { rowsAutoHeightInfo } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
5089
|
+
if (!target) return !1;
|
|
5090
|
+
const rowManager = target.worksheet.getRowManager();
|
|
5091
|
+
for (const { row, autoHeight } of rowsAutoHeightInfo) {
|
|
5092
|
+
const curRow = rowManager.getRowOrCreate(row);
|
|
5093
|
+
curRow.ah = autoHeight;
|
|
5094
|
+
}
|
|
5095
|
+
return !0;
|
|
5096
|
+
}, "handler")
|
|
5097
|
+
}, DeltaRowHeightCommand = {
|
|
5098
|
+
type: CommandType.COMMAND,
|
|
5099
|
+
id: "sheet.command.delta-row-height",
|
|
5100
|
+
// eslint-disable-next-line max-lines-per-function
|
|
5101
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5102
|
+
var _a18, _b;
|
|
5103
|
+
const selections = accessor.get(SheetsSelectionsService).getCurrentSelections(), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
5104
|
+
if (!(selections != null && selections.length))
|
|
5105
|
+
return !1;
|
|
5106
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
5107
|
+
if (!target) return !1;
|
|
5108
|
+
const { worksheet, subUnitId, unitId } = target, { anchorRow, deltaY } = params, destRowHeight = worksheet.getRowHeight(anchorRow) + deltaY, isAllSheetRange = selections.length === 1 && selections[0].range.rangeType === RANGE_TYPE.ALL, rowSelections = selections.filter((s) => s.range.rangeType === RANGE_TYPE.ROW), rangeType = isAllSheetRange ? RANGE_TYPE.ALL : rowSelections.some(({ range }) => {
|
|
5109
|
+
const { startRow, endRow } = range;
|
|
5110
|
+
return startRow <= anchorRow && anchorRow <= endRow;
|
|
5111
|
+
}) ? RANGE_TYPE.ROW : RANGE_TYPE.NORMAL;
|
|
5112
|
+
let redoMutationParams;
|
|
5113
|
+
if (rangeType === RANGE_TYPE.ALL) {
|
|
5114
|
+
const colCount = worksheet.getRowCount(), allRowRanges = new Array(worksheet.getColumnCount()).fill(void 0).map(
|
|
5115
|
+
(_, index) => ({ startRow: index, endRow: index, startColumn: 0, endColumn: colCount - 1 })
|
|
5116
|
+
);
|
|
5117
|
+
redoMutationParams = {
|
|
5118
|
+
subUnitId,
|
|
5119
|
+
unitId,
|
|
5120
|
+
rowHeight: destRowHeight,
|
|
5121
|
+
ranges: allRowRanges
|
|
5122
|
+
};
|
|
5123
|
+
} else rangeType === RANGE_TYPE.ROW ? redoMutationParams = {
|
|
5124
|
+
subUnitId,
|
|
5125
|
+
unitId,
|
|
5126
|
+
ranges: rowSelections.map((s) => Rectangle.clone(s.range)),
|
|
5127
|
+
rowHeight: destRowHeight
|
|
5128
|
+
} : redoMutationParams = {
|
|
5129
|
+
subUnitId,
|
|
5130
|
+
unitId,
|
|
5131
|
+
rowHeight: destRowHeight,
|
|
5132
|
+
ranges: [
|
|
5133
|
+
{
|
|
5134
|
+
startRow: anchorRow,
|
|
5135
|
+
endRow: anchorRow,
|
|
5136
|
+
startColumn: 0,
|
|
5137
|
+
endColumn: worksheet.getMaxColumns() - 1
|
|
5138
|
+
}
|
|
5139
|
+
]
|
|
5140
|
+
};
|
|
5141
|
+
const undoMutationParams = SetWorksheetRowHeightMutationFactory(redoMutationParams, worksheet), redoSetIsAutoHeightParams = {
|
|
5142
|
+
unitId,
|
|
5143
|
+
subUnitId,
|
|
5144
|
+
ranges: redoMutationParams.ranges,
|
|
5145
|
+
autoHeightInfo: BooleanNumber.FALSE
|
|
5146
|
+
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(redoSetIsAutoHeightParams, worksheet), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), intercepted = sheetInterceptorService.onCommandExecute({
|
|
5147
|
+
id: DeltaRowHeightCommand.id,
|
|
5148
|
+
params: redoMutationParams
|
|
5149
|
+
}), result = sequenceExecute([
|
|
5150
|
+
{
|
|
5151
|
+
id: SetWorksheetRowHeightMutation.id,
|
|
5152
|
+
params: redoMutationParams
|
|
5153
|
+
},
|
|
5154
|
+
{
|
|
5155
|
+
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
5156
|
+
params: redoSetIsAutoHeightParams
|
|
5157
|
+
}
|
|
5158
|
+
], commandService), interceptedResult = sequenceExecute([...intercepted.redos], commandService);
|
|
5159
|
+
return result.result && interceptedResult.result ? (undoRedoService.pushUndoRedo({
|
|
5160
|
+
unitID: unitId,
|
|
5161
|
+
undoMutations: [
|
|
5162
|
+
...(_a18 = intercepted.preUndos) != null ? _a18 : [],
|
|
5163
|
+
{
|
|
5164
|
+
id: SetWorksheetRowHeightMutation.id,
|
|
5165
|
+
params: undoMutationParams
|
|
5166
|
+
},
|
|
5167
|
+
{
|
|
5168
|
+
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
5169
|
+
params: undoSetIsAutoHeightParams
|
|
5170
|
+
},
|
|
5171
|
+
...intercepted.undos
|
|
5172
|
+
],
|
|
5173
|
+
redoMutations: [
|
|
5174
|
+
...(_b = intercepted.preRedos) != null ? _b : [],
|
|
5175
|
+
{
|
|
5176
|
+
id: SetWorksheetRowHeightMutation.id,
|
|
5177
|
+
params: redoMutationParams
|
|
5178
|
+
},
|
|
5179
|
+
{
|
|
5180
|
+
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
5181
|
+
params: redoSetIsAutoHeightParams
|
|
5182
|
+
},
|
|
5183
|
+
...intercepted.redos
|
|
5184
|
+
]
|
|
5185
|
+
}), !0) : !1;
|
|
5186
|
+
}, "handler")
|
|
5187
|
+
}, SetRowHeightCommand = {
|
|
5188
|
+
type: CommandType.COMMAND,
|
|
5189
|
+
id: "sheet.command.set-row-height",
|
|
5190
|
+
// eslint-disable-next-line max-lines-per-function
|
|
5191
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5192
|
+
var _a18, _b, _c, _d;
|
|
5193
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a18 = params == null ? void 0 : params.ranges) != null && _a18.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
5194
|
+
if (!(selections != null && selections.length))
|
|
5195
|
+
return !1;
|
|
5196
|
+
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
5197
|
+
if (!target) return !1;
|
|
5198
|
+
const { unitId, subUnitId, worksheet } = target, redoMutationParams = {
|
|
5199
|
+
subUnitId,
|
|
5200
|
+
unitId,
|
|
5201
|
+
ranges: selections,
|
|
5202
|
+
rowHeight: params.value
|
|
5203
|
+
}, undoMutationParams = SetWorksheetRowHeightMutationFactory(redoMutationParams, worksheet), redoSetIsAutoHeightParams = {
|
|
5204
|
+
unitId,
|
|
5205
|
+
subUnitId,
|
|
5206
|
+
ranges: redoMutationParams.ranges,
|
|
5207
|
+
autoHeightInfo: BooleanNumber.FALSE
|
|
5208
|
+
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(redoSetIsAutoHeightParams, worksheet), result = sequenceExecute([
|
|
5209
|
+
{
|
|
5210
|
+
id: SetWorksheetRowHeightMutation.id,
|
|
5211
|
+
params: redoMutationParams
|
|
5212
|
+
},
|
|
5213
|
+
{
|
|
5214
|
+
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
5215
|
+
params: redoSetIsAutoHeightParams
|
|
5216
|
+
}
|
|
5217
|
+
], commandService), intercepted = sheetInterceptorService.onCommandExecute({
|
|
5218
|
+
id: SetRowHeightCommand.id,
|
|
5219
|
+
params: redoMutationParams
|
|
5220
|
+
}), sheetInterceptorResult = sequenceExecute([...intercepted.redos], commandService);
|
|
5221
|
+
return result.result && sheetInterceptorResult.result ? (undoRedoService.pushUndoRedo({
|
|
5222
|
+
unitID: unitId,
|
|
5223
|
+
undoMutations: [
|
|
5224
|
+
...(_c = intercepted.preRedos) != null ? _c : [],
|
|
5225
|
+
{
|
|
5226
|
+
id: SetWorksheetRowHeightMutation.id,
|
|
5227
|
+
params: undoMutationParams
|
|
5228
|
+
},
|
|
5229
|
+
{
|
|
5230
|
+
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
5231
|
+
params: undoSetIsAutoHeightParams
|
|
5232
|
+
},
|
|
5233
|
+
...intercepted.undos
|
|
5234
|
+
],
|
|
5235
|
+
redoMutations: [
|
|
5236
|
+
...(_d = intercepted.preRedos) != null ? _d : [],
|
|
5237
|
+
{
|
|
5238
|
+
id: SetWorksheetRowHeightMutation.id,
|
|
5239
|
+
params: redoMutationParams
|
|
5240
|
+
},
|
|
5241
|
+
{
|
|
5242
|
+
id: SetWorksheetRowIsAutoHeightMutation.id,
|
|
5243
|
+
params: redoSetIsAutoHeightParams
|
|
5244
|
+
},
|
|
5245
|
+
...intercepted.redos
|
|
5246
|
+
]
|
|
5247
|
+
}), !0) : !1;
|
|
5248
|
+
}, "handler")
|
|
5249
|
+
}, SetWorksheetRowIsAutoHeightCommand = {
|
|
5316
5250
|
type: CommandType.COMMAND,
|
|
5317
|
-
id: "sheet.command.set-
|
|
5318
|
-
async
|
|
5319
|
-
|
|
5251
|
+
id: "sheet.command.set-row-is-auto-height",
|
|
5252
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5253
|
+
var _a18, _b;
|
|
5254
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
5255
|
+
if (!target) return !1;
|
|
5256
|
+
const { unitId, subUnitId, worksheet } = target, ranges = (_a18 = params == null ? void 0 : params.ranges) != null && _a18.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
5257
|
+
if (!(ranges != null && ranges.length))
|
|
5320
5258
|
return !1;
|
|
5321
|
-
const
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5259
|
+
const redoMutationParams = {
|
|
5260
|
+
unitId,
|
|
5261
|
+
subUnitId,
|
|
5262
|
+
ranges,
|
|
5263
|
+
autoHeightInfo: BooleanNumber.TRUE
|
|
5264
|
+
// Hard code first, maybe it will change by the menu item in the future.
|
|
5265
|
+
}, undoMutationParams = SetWorksheetRowIsAutoHeightMutationFactory(redoMutationParams, worksheet), setIsAutoHeightResult = commandService.syncExecuteCommand(
|
|
5266
|
+
SetWorksheetRowIsAutoHeightMutation.id,
|
|
5267
|
+
redoMutationParams
|
|
5268
|
+
), { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
5269
|
+
id: SetWorksheetRowIsAutoHeightCommand.id,
|
|
5270
|
+
params: redoMutationParams
|
|
5271
|
+
}), result = sequenceExecute([...redos], commandService);
|
|
5272
|
+
return setIsAutoHeightResult && result.result ? (undoRedoService.pushUndoRedo({
|
|
5273
|
+
unitID: unitId,
|
|
5274
|
+
undoMutations: [{ id: SetWorksheetRowIsAutoHeightMutation.id, params: undoMutationParams }, ...undos],
|
|
5275
|
+
redoMutations: [{ id: SetWorksheetRowIsAutoHeightMutation.id, params: redoMutationParams }, ...redos]
|
|
5276
|
+
}), !0) : !1;
|
|
5277
|
+
}, "handler")
|
|
5278
|
+
}, SetWorksheetShowCommand = {
|
|
5279
|
+
type: CommandType.COMMAND,
|
|
5280
|
+
id: "sheet.command.set-worksheet-show",
|
|
5281
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
5282
|
+
const { unitId, subUnitId } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService);
|
|
5283
|
+
if (!getSheetCommandTarget(accessor.get(IUniverInstanceService))) return !1;
|
|
5284
|
+
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
5285
|
+
if (!workbook) return !1;
|
|
5286
|
+
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
5287
|
+
if (!worksheet || worksheet.getConfig().hidden === BooleanNumber.FALSE) return !1;
|
|
5288
|
+
const redoMutationParams = {
|
|
5289
|
+
unitId,
|
|
5290
|
+
subUnitId,
|
|
5291
|
+
hidden: BooleanNumber.FALSE
|
|
5292
|
+
}, undoMutationParams = SetWorksheetHideMutationFactory(accessor, redoMutationParams), result = commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams), activeSheetMutationParams = {
|
|
5293
|
+
unitId,
|
|
5294
|
+
subUnitId
|
|
5295
|
+
}, activeResult = commandService.syncExecuteCommand(
|
|
5296
|
+
SetWorksheetActiveOperation.id,
|
|
5297
|
+
activeSheetMutationParams
|
|
5298
|
+
);
|
|
5299
|
+
return result && activeResult ? (undoRedoService.pushUndoRedo({
|
|
5300
|
+
unitID: unitId,
|
|
5301
|
+
undoMutations: [
|
|
5302
|
+
{ id: SetWorksheetHideMutation.id, params: undoMutationParams }
|
|
5303
|
+
// { id: SetWorksheetActiveOperation.id, params: unActiveMutationParams },
|
|
5304
|
+
],
|
|
5305
|
+
redoMutations: [
|
|
5306
|
+
// { id: SetWorksheetActiveOperation.id, params: activeSheetMutationParams },
|
|
5307
|
+
{ id: SetWorksheetHideMutation.id, params: redoMutationParams }
|
|
5308
|
+
]
|
|
5309
|
+
}), !0) : !1;
|
|
5310
|
+
}, "handler")
|
|
5311
|
+
}, AddWorksheetProtectionMutation = {
|
|
5312
|
+
id: "sheet.mutation.add-worksheet-protection",
|
|
5333
5313
|
type: CommandType.MUTATION,
|
|
5334
5314
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5335
|
-
const { unitId,
|
|
5336
|
-
return
|
|
5337
|
-
selectionProtectionRuleModel.deleteRule(unitId, subUnitId, id);
|
|
5338
|
-
}), !0;
|
|
5315
|
+
const { unitId, rule } = params;
|
|
5316
|
+
return accessor.get(WorksheetProtectionRuleModel).addRule(unitId, rule), !0;
|
|
5339
5317
|
}, "handler")
|
|
5340
|
-
},
|
|
5341
|
-
|
|
5342
|
-
return { id: DeleteRangeProtectionMutation.id, params: deleteParams };
|
|
5343
|
-
}, "FactoryAddRangeProtectionMutation"), AddRangeProtectionMutation = {
|
|
5344
|
-
id: "sheet.mutation.add-range-protection",
|
|
5318
|
+
}, DeleteWorksheetProtectionMutation = {
|
|
5319
|
+
id: "sheet.mutation.delete-worksheet-protection",
|
|
5345
5320
|
type: CommandType.MUTATION,
|
|
5346
5321
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5347
|
-
const { unitId, subUnitId
|
|
5348
|
-
return
|
|
5349
|
-
selectionProtectionRuleModel.addRule(unitId, subUnitId, rule);
|
|
5350
|
-
}), !0;
|
|
5322
|
+
const { unitId, subUnitId } = params;
|
|
5323
|
+
return accessor.get(WorksheetProtectionRuleModel).deleteRule(unitId, subUnitId), !0;
|
|
5351
5324
|
}, "handler")
|
|
5352
|
-
},
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5325
|
+
}, EmptyMutation = {
|
|
5326
|
+
id: "sheet.mutation.empty",
|
|
5327
|
+
type: CommandType.MUTATION,
|
|
5328
|
+
handler: /* @__PURE__ */ __name(() => !0, "handler")
|
|
5329
|
+
}, createTopMatrixFromRanges = /* @__PURE__ */ __name((ranges) => {
|
|
5330
|
+
const matrix = new ObjectMatrix();
|
|
5331
|
+
return ranges.forEach((range) => {
|
|
5332
|
+
Range.foreach(range, (row, col) => {
|
|
5333
|
+
matrix.setValue(row, col, 1);
|
|
5334
|
+
});
|
|
5335
|
+
}), matrix.forValue((row, col) => {
|
|
5336
|
+
const theLastRowValue = matrix.getValue(row - 1, col);
|
|
5337
|
+
theLastRowValue && matrix.setValue(row, col, theLastRowValue + 1);
|
|
5338
|
+
}), matrix;
|
|
5339
|
+
}, "createTopMatrixFromRanges"), createTopMatrixFromMatrix = /* @__PURE__ */ __name((matrix) => {
|
|
5340
|
+
const _matrix = matrix;
|
|
5341
|
+
return _matrix.forValue((row, col) => {
|
|
5342
|
+
const theLastRowValue = matrix.getValue(row - 1, col);
|
|
5343
|
+
theLastRowValue && _matrix.setValue(row, col, theLastRowValue + 1);
|
|
5344
|
+
}), _matrix;
|
|
5345
|
+
}, "createTopMatrixFromMatrix"), findMaximalRectangle = /* @__PURE__ */ __name((topMatrix) => {
|
|
5346
|
+
const res = {
|
|
5347
|
+
area: 0
|
|
5348
|
+
}, checkArea = /* @__PURE__ */ __name((area, range) => res.area < area ? (res.area = area, res.range = range, !0) : !1, "checkArea");
|
|
5349
|
+
return topMatrix.forValue((row, col, lineArea) => {
|
|
5350
|
+
let cols = 1, rows = lineArea;
|
|
5351
|
+
checkArea(cols * rows, {
|
|
5352
|
+
startRow: row - rows + 1,
|
|
5353
|
+
endRow: row,
|
|
5354
|
+
startColumn: col,
|
|
5355
|
+
endColumn: col
|
|
5356
|
+
});
|
|
5357
|
+
const _range = {
|
|
5358
|
+
startRow: row - rows + 1,
|
|
5359
|
+
endRow: row,
|
|
5360
|
+
startColumn: 0,
|
|
5361
|
+
endColumn: col
|
|
5362
|
+
};
|
|
5363
|
+
for (let k = col - 1; k >= 0 && topMatrix.getValue(row, k); k--) {
|
|
5364
|
+
rows = Math.min(topMatrix.getValue(row, k) || 0, rows), cols++;
|
|
5365
|
+
const area = rows * cols;
|
|
5366
|
+
_range.startColumn = k, _range.startRow = row - rows + 1, checkArea(area, _range);
|
|
5367
|
+
}
|
|
5368
|
+
}), res;
|
|
5369
|
+
}, "findMaximalRectangle"), filterLeftMatrix = /* @__PURE__ */ __name((topMatrix, range) => {
|
|
5370
|
+
Range.foreach(range, (row, col) => {
|
|
5371
|
+
topMatrix.realDeleteValue(row, col);
|
|
5372
|
+
});
|
|
5373
|
+
for (let col = range.startColumn; col <= range.endColumn; col++) {
|
|
5374
|
+
const row = range.endRow + 1;
|
|
5375
|
+
if (topMatrix.getValue(row, col) > 0) {
|
|
5376
|
+
topMatrix.setValue(row, col, 1);
|
|
5377
|
+
let nextRow = row + 1;
|
|
5378
|
+
for (; topMatrix.getValue(nextRow, col) > 0; )
|
|
5379
|
+
topMatrix.setValue(nextRow, col, topMatrix.getValue(nextRow - 1, col) + 1), nextRow++;
|
|
5380
|
+
}
|
|
5381
|
+
}
|
|
5382
|
+
return topMatrix;
|
|
5383
|
+
}, "filterLeftMatrix"), findAllRectangle = /* @__PURE__ */ __name((topMatrix) => {
|
|
5384
|
+
const resultList = [];
|
|
5385
|
+
let result = findMaximalRectangle(topMatrix);
|
|
5386
|
+
for (; result.area > 0; )
|
|
5387
|
+
result.range && (resultList.push(result.range), filterLeftMatrix(topMatrix, result.range)), result = findMaximalRectangle(topMatrix);
|
|
5388
|
+
return resultList;
|
|
5389
|
+
}, "findAllRectangle"), rangeMerge = /* @__PURE__ */ __name((ranges) => {
|
|
5390
|
+
const topMatrix = createTopMatrixFromRanges(ranges);
|
|
5391
|
+
return findAllRectangle(topMatrix);
|
|
5392
|
+
}, "rangeMerge"), _RangeMergeUtil = class _RangeMergeUtil {
|
|
5393
|
+
constructor() {
|
|
5394
|
+
__publicField(this, "_matrix", new ObjectMatrix());
|
|
5395
|
+
}
|
|
5396
|
+
add(...ranges) {
|
|
5397
|
+
return ranges.forEach((range) => {
|
|
5398
|
+
Range.foreach(range, (row, col) => {
|
|
5399
|
+
this._matrix.setValue(row, col, 1);
|
|
5400
|
+
});
|
|
5401
|
+
}), this;
|
|
5402
|
+
}
|
|
5403
|
+
subtract(...ranges) {
|
|
5404
|
+
return ranges.forEach((range) => {
|
|
5405
|
+
Range.foreach(range, (row, col) => {
|
|
5406
|
+
this._matrix.realDeleteValue(row, col);
|
|
5407
|
+
});
|
|
5408
|
+
}), this;
|
|
5409
|
+
}
|
|
5410
|
+
merge() {
|
|
5411
|
+
const topMatrix = createTopMatrixFromMatrix(this._matrix);
|
|
5412
|
+
return findAllRectangle(topMatrix);
|
|
5413
|
+
}
|
|
5414
|
+
};
|
|
5415
|
+
__name(_RangeMergeUtil, "RangeMergeUtil");
|
|
5416
|
+
let RangeMergeUtil = _RangeMergeUtil;
|
|
5417
|
+
const INumfmtService = createIdentifier("INumfmtService"), factorySetNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) => {
|
|
5418
|
+
const numfmtService = accessor.get(INumfmtService), { values, unitId, subUnitId } = option, cells = [], removeCells = [];
|
|
5419
|
+
Object.keys(values).forEach((id) => {
|
|
5420
|
+
values[id].ranges.forEach((range) => {
|
|
5421
|
+
Range.foreach(range, (row, col) => {
|
|
5422
|
+
const oldNumfmt = numfmtService.getValue(unitId, subUnitId, row, col);
|
|
5423
|
+
oldNumfmt ? cells.push({
|
|
5424
|
+
pattern: oldNumfmt.pattern,
|
|
5425
|
+
row,
|
|
5426
|
+
col
|
|
5427
|
+
}) : removeCells.push({ startColumn: col, endColumn: col, startRow: row, endRow: row });
|
|
5378
5428
|
});
|
|
5379
|
-
}
|
|
5380
|
-
|
|
5429
|
+
});
|
|
5430
|
+
});
|
|
5431
|
+
const result = [];
|
|
5432
|
+
if (cells.length) {
|
|
5433
|
+
const params = transformCellsToRange(unitId, subUnitId, cells);
|
|
5434
|
+
Object.keys(params.values).forEach((key) => {
|
|
5435
|
+
const v = params.values[key];
|
|
5436
|
+
v.ranges = rangeMerge(v.ranges);
|
|
5437
|
+
}), result.push({
|
|
5438
|
+
id: SetNumfmtMutation.id,
|
|
5439
|
+
params: transformCellsToRange(unitId, subUnitId, cells)
|
|
5440
|
+
});
|
|
5381
5441
|
}
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
async handler(accessor, params) {
|
|
5386
|
-
if (!params)
|
|
5387
|
-
return !1;
|
|
5388
|
-
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), { unitId, subUnitId, rule } = params, redoMutationParam = {
|
|
5442
|
+
return removeCells.length && result.push({
|
|
5443
|
+
id: RemoveNumfmtMutation.id,
|
|
5444
|
+
params: {
|
|
5389
5445
|
unitId,
|
|
5390
5446
|
subUnitId,
|
|
5391
|
-
|
|
5392
|
-
}
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
undoMutations: [{ id: AddRangeProtectionMutation.id, params: { unitId, subUnitId, rules: [rule] } }]
|
|
5397
|
-
}), !0;
|
|
5398
|
-
}
|
|
5399
|
-
}, SetRangeProtectionMutation = {
|
|
5400
|
-
id: "sheet.mutation.set-range-protection",
|
|
5447
|
+
ranges: removeCells
|
|
5448
|
+
}
|
|
5449
|
+
}), result;
|
|
5450
|
+
}, "factorySetNumfmtUndoMutation"), SetNumfmtMutation = {
|
|
5451
|
+
id: "sheet.mutation.set.numfmt",
|
|
5401
5452
|
type: CommandType.MUTATION,
|
|
5402
5453
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5403
|
-
const { unitId, subUnitId, rule, ruleId } = params;
|
|
5404
|
-
return accessor.get(RangeProtectionRuleModel).setRule(unitId, subUnitId, ruleId, rule), !0;
|
|
5405
|
-
}, "handler")
|
|
5406
|
-
}, FactorySetRangeProtectionMutation = /* @__PURE__ */ __name((accessor, param) => {
|
|
5407
|
-
const { unitId, subUnitId, ruleId } = param, oldRule = accessor.get(RangeProtectionRuleModel).getRule(unitId, subUnitId, ruleId);
|
|
5408
|
-
return oldRule ? {
|
|
5409
|
-
id: SetRangeProtectionMutation.id,
|
|
5410
|
-
params: {
|
|
5411
|
-
...param,
|
|
5412
|
-
rule: oldRule
|
|
5413
|
-
}
|
|
5414
|
-
} : null;
|
|
5415
|
-
}, "FactorySetRangeProtectionMutation"), SetRangeProtectionCommand = {
|
|
5416
|
-
type: CommandType.COMMAND,
|
|
5417
|
-
id: "sheet.command.set-range-protection",
|
|
5418
|
-
async handler(accessor, params) {
|
|
5419
5454
|
if (!params)
|
|
5420
5455
|
return !1;
|
|
5421
|
-
const
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
if (await commandService.executeCommand(SetRangeProtectionMutation.id, redoMutationParam)) {
|
|
5436
|
-
const redoMutations = [{
|
|
5437
|
-
id: SetRangeProtectionMutation.id,
|
|
5438
|
-
params: redoMutationParam
|
|
5439
|
-
}], undoMutations = [{
|
|
5440
|
-
id: SetRangeProtectionMutation.id,
|
|
5441
|
-
params: {
|
|
5442
|
-
unitId,
|
|
5443
|
-
subUnitId,
|
|
5444
|
-
ruleId: rule.id,
|
|
5445
|
-
rule: oldRule
|
|
5446
|
-
}
|
|
5447
|
-
}];
|
|
5448
|
-
undoRedoService.pushUndoRedo({
|
|
5449
|
-
unitID: unitId,
|
|
5450
|
-
redoMutations,
|
|
5451
|
-
undoMutations
|
|
5452
|
-
});
|
|
5453
|
-
}
|
|
5454
|
-
}
|
|
5455
|
-
return !0;
|
|
5456
|
-
}
|
|
5457
|
-
}, ReorderRangeUndoMutationFactory = /* @__PURE__ */ __name((params) => {
|
|
5458
|
-
const { order } = params, newOrder = {};
|
|
5459
|
-
return Object.keys(order).forEach((key) => {
|
|
5460
|
-
newOrder[order[Number(key)]] = Number(key);
|
|
5461
|
-
}), {
|
|
5462
|
-
...params,
|
|
5463
|
-
order: newOrder
|
|
5464
|
-
};
|
|
5465
|
-
}, "ReorderRangeUndoMutationFactory"), ReorderRangeMutation = {
|
|
5466
|
-
id: "sheet.mutation.reorder-range",
|
|
5456
|
+
const { values, refMap } = params, numfmtService = accessor.get(INumfmtService), unitId = params.unitId, sheetId = params.subUnitId, setValues = Object.keys(values).reduce(
|
|
5457
|
+
(result, id) => {
|
|
5458
|
+
const value = refMap[id], ranges = values[id].ranges;
|
|
5459
|
+
return value && result.push({
|
|
5460
|
+
...value,
|
|
5461
|
+
ranges
|
|
5462
|
+
}), result;
|
|
5463
|
+
},
|
|
5464
|
+
[]
|
|
5465
|
+
);
|
|
5466
|
+
return numfmtService.setValues(unitId, sheetId, setValues), !0;
|
|
5467
|
+
}, "handler")
|
|
5468
|
+
}, RemoveNumfmtMutation = {
|
|
5469
|
+
id: "sheet.mutation.remove.numfmt",
|
|
5467
5470
|
type: CommandType.MUTATION,
|
|
5468
5471
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5469
|
-
|
|
5470
|
-
if (!worksheet)
|
|
5472
|
+
if (!params)
|
|
5471
5473
|
return !1;
|
|
5472
|
-
const
|
|
5474
|
+
const { unitId, subUnitId, ranges } = params;
|
|
5475
|
+
return accessor.get(INumfmtService).deleteValues(unitId, subUnitId, ranges), !0;
|
|
5476
|
+
}, "handler")
|
|
5477
|
+
}, factoryRemoveNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) => {
|
|
5478
|
+
const numfmtService = accessor.get(INumfmtService), { ranges, unitId, subUnitId } = option, cells = [];
|
|
5479
|
+
if (ranges.forEach((range) => {
|
|
5473
5480
|
Range.foreach(range, (row, col) => {
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5481
|
+
const oldNumfmt = numfmtService.getValue(unitId, subUnitId, row, col);
|
|
5482
|
+
oldNumfmt && cells.push({
|
|
5483
|
+
pattern: oldNumfmt.pattern,
|
|
5484
|
+
row,
|
|
5485
|
+
col
|
|
5486
|
+
});
|
|
5478
5487
|
});
|
|
5479
|
-
|
|
5480
|
-
return
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
id:
|
|
5486
|
-
|
|
5488
|
+
}), !cells.length)
|
|
5489
|
+
return [];
|
|
5490
|
+
const params = transformCellsToRange(unitId, subUnitId, cells);
|
|
5491
|
+
return Object.keys(params.values).forEach((key) => {
|
|
5492
|
+
const v = params.values[key];
|
|
5493
|
+
v.ranges = rangeMerge(v.ranges);
|
|
5494
|
+
}), [{ id: SetNumfmtMutation.id, params }];
|
|
5495
|
+
}, "factoryRemoveNumfmtUndoMutation"), transformCellsToRange = /* @__PURE__ */ __name((unitId, subUnitId, cells) => {
|
|
5496
|
+
const group = groupByKey(cells, "pattern"), refMap = {}, values = {}, getKey = createUniqueKey();
|
|
5497
|
+
return Object.keys(group).forEach((pattern) => {
|
|
5498
|
+
const groupItem = group[pattern], key = getKey();
|
|
5499
|
+
refMap[key] = {
|
|
5500
|
+
pattern
|
|
5501
|
+
}, groupItem.forEach((item) => {
|
|
5502
|
+
values[key] || (values[key] = { ranges: [] }), values[key].ranges.push(cellToRange(item.row, item.col));
|
|
5503
|
+
});
|
|
5504
|
+
}), { unitId, subUnitId, refMap, values };
|
|
5505
|
+
}, "transformCellsToRange"), SetWorksheetProtectionMutation = {
|
|
5506
|
+
id: "sheet.mutation.set-worksheet-protection",
|
|
5507
|
+
type: CommandType.MUTATION,
|
|
5487
5508
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
id: ReorderRangeMutation.id,
|
|
5491
|
-
params: {
|
|
5492
|
-
unitId,
|
|
5493
|
-
subUnitId,
|
|
5494
|
-
order,
|
|
5495
|
-
range
|
|
5496
|
-
}
|
|
5497
|
-
}, undoReorderMutation = {
|
|
5498
|
-
id: ReorderRangeMutation.id,
|
|
5499
|
-
params: ReorderRangeUndoMutationFactory(reorderMutation.params)
|
|
5500
|
-
}, interceptorCommands = accessor.get(SheetInterceptorService).onCommandExecute({ id: ReorderRangeCommand.id, params }), redos = [
|
|
5501
|
-
...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
|
|
5502
|
-
reorderMutation,
|
|
5503
|
-
...interceptorCommands.redos
|
|
5504
|
-
], undos = [
|
|
5505
|
-
...(_b = interceptorCommands.preUndos) != null ? _b : [],
|
|
5506
|
-
undoReorderMutation,
|
|
5507
|
-
...interceptorCommands.undos
|
|
5508
|
-
];
|
|
5509
|
-
return sequenceExecute(redos, commandService).result ? (accessor.get(IUndoRedoService).pushUndoRedo({
|
|
5510
|
-
unitID: unitId,
|
|
5511
|
-
undoMutations: undos,
|
|
5512
|
-
redoMutations: redos
|
|
5513
|
-
}), !0) : !1;
|
|
5509
|
+
const { unitId, subUnitId, rule } = params;
|
|
5510
|
+
return accessor.get(WorksheetProtectionRuleModel).setRule(unitId, subUnitId, rule), !0;
|
|
5514
5511
|
}, "handler")
|
|
5515
|
-
},
|
|
5512
|
+
}, ScrollToCellOperation = {
|
|
5513
|
+
id: "sheet.operation.scroll-to-cell",
|
|
5514
|
+
type: CommandType.OPERATION,
|
|
5515
|
+
handler: /* @__PURE__ */ __name(() => !0, "handler")
|
|
5516
|
+
}, ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY = "ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY", MAX_CELL_PER_SHEET_KEY = "maxCellsPerSheet", MAX_CELL_PER_SHEET_DEFAULT = 3e6;
|
|
5516
5517
|
var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
5517
5518
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5518
5519
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
5519
5520
|
return kind && result && __defProp$c(target, key, result), result;
|
|
5520
|
-
}, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c"),
|
|
5521
|
-
let BasicWorksheetController = (
|
|
5521
|
+
}, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c"), _a5;
|
|
5522
|
+
let BasicWorksheetController = (_a5 = class extends Disposable {
|
|
5522
5523
|
// eslint-disable-next-line max-lines-per-function
|
|
5523
5524
|
constructor(_commandService, _configService, _dataSyncPrimaryController) {
|
|
5524
|
-
var
|
|
5525
|
+
var _a18;
|
|
5525
5526
|
super(), this._commandService = _commandService, this._configService = _configService, this._dataSyncPrimaryController = _dataSyncPrimaryController, [
|
|
5526
5527
|
SetRangeValuesMutation,
|
|
5527
5528
|
InsertColMutation,
|
|
@@ -5543,9 +5544,9 @@ let BasicWorksheetController = (_a8 = class extends Disposable {
|
|
|
5543
5544
|
EmptyMutation,
|
|
5544
5545
|
SetWorksheetColWidthMutation
|
|
5545
5546
|
].forEach((mutation) => {
|
|
5546
|
-
var
|
|
5547
|
-
this._commandService.registerCommand(mutation), (
|
|
5548
|
-
}), ((
|
|
5547
|
+
var _a19;
|
|
5548
|
+
this._commandService.registerCommand(mutation), (_a19 = this._dataSyncPrimaryController) == null || _a19.registerSyncingMutations(mutation);
|
|
5549
|
+
}), ((_a18 = this._configService.getConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY)) != null ? _a18 : !1) || [
|
|
5549
5550
|
ClearSelectionAllCommand,
|
|
5550
5551
|
ClearSelectionContentCommand,
|
|
5551
5552
|
ClearSelectionFormatCommand,
|
|
@@ -5635,9 +5636,8 @@ let BasicWorksheetController = (_a8 = class extends Disposable {
|
|
|
5635
5636
|
SetRangeProtectionMutation
|
|
5636
5637
|
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command))), this._configService.setConfig(MAX_CELL_PER_SHEET_KEY, MAX_CELL_PER_SHEET_DEFAULT);
|
|
5637
5638
|
}
|
|
5638
|
-
}, __name(
|
|
5639
|
+
}, __name(_a5, "BasicWorksheetController"), _a5);
|
|
5639
5640
|
BasicWorksheetController = __decorateClass$c([
|
|
5640
|
-
OnLifecycle(LifecycleStages.Starting, BasicWorksheetController),
|
|
5641
5641
|
__decorateParam$c(0, ICommandService),
|
|
5642
5642
|
__decorateParam$c(1, IConfigService),
|
|
5643
5643
|
__decorateParam$c(2, Optional(DataSyncPrimaryController))
|
|
@@ -5646,8 +5646,8 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
|
|
|
5646
5646
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5647
5647
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
5648
5648
|
return kind && result && __defProp$b(target, key, result), result;
|
|
5649
|
-
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"),
|
|
5650
|
-
let CalculateResultApplyController = (
|
|
5649
|
+
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a6;
|
|
5650
|
+
let CalculateResultApplyController = (_a6 = class extends Disposable {
|
|
5651
5651
|
constructor(_univerInstanceService, _commandService) {
|
|
5652
5652
|
super(), this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._initialize();
|
|
5653
5653
|
}
|
|
@@ -5697,9 +5697,8 @@ let CalculateResultApplyController = (_a9 = class extends Disposable {
|
|
|
5697
5697
|
cellDataMatrix.setValue(row, col, newCell);
|
|
5698
5698
|
}), cellDataMatrix.clone();
|
|
5699
5699
|
}
|
|
5700
|
-
}, __name(
|
|
5700
|
+
}, __name(_a6, "CalculateResultApplyController"), _a6);
|
|
5701
5701
|
CalculateResultApplyController = __decorateClass$b([
|
|
5702
|
-
OnLifecycle(LifecycleStages.Ready, CalculateResultApplyController),
|
|
5703
5702
|
__decorateParam$b(0, Inject(IUniverInstanceService)),
|
|
5704
5703
|
__decorateParam$b(1, ICommandService)
|
|
5705
5704
|
], CalculateResultApplyController);
|
|
@@ -5710,8 +5709,8 @@ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPrope
|
|
|
5710
5709
|
return kind && result && __defProp$a(target, key, result), result;
|
|
5711
5710
|
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a");
|
|
5712
5711
|
const SHEET_DEFINED_NAME_PLUGIN = "SHEET_DEFINED_NAME_PLUGIN";
|
|
5713
|
-
var
|
|
5714
|
-
let DefinedNameDataController = (
|
|
5712
|
+
var _a7;
|
|
5713
|
+
let DefinedNameDataController = (_a7 = class extends Disposable {
|
|
5715
5714
|
constructor(_definedNamesService, _resourceManagerService) {
|
|
5716
5715
|
super(), this._definedNamesService = _definedNamesService, this._resourceManagerService = _resourceManagerService, this._initialize();
|
|
5717
5716
|
}
|
|
@@ -5746,9 +5745,8 @@ let DefinedNameDataController = (_a10 = class extends Disposable {
|
|
|
5746
5745
|
})
|
|
5747
5746
|
);
|
|
5748
5747
|
}
|
|
5749
|
-
}, __name(
|
|
5748
|
+
}, __name(_a7, "DefinedNameDataController"), _a7);
|
|
5750
5749
|
DefinedNameDataController = __decorateClass$a([
|
|
5751
|
-
OnLifecycle(LifecycleStages.Ready, DefinedNameDataController),
|
|
5752
5750
|
__decorateParam$a(0, IDefinedNamesService),
|
|
5753
5751
|
__decorateParam$a(1, IResourceManagerService)
|
|
5754
5752
|
], DefinedNameDataController);
|
|
@@ -5847,9 +5845,9 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
|
|
|
5847
5845
|
});
|
|
5848
5846
|
const cacheMatrix = new ObjectMatrix();
|
|
5849
5847
|
return Range.foreach(range, (row, col) => {
|
|
5850
|
-
var
|
|
5848
|
+
var _a18;
|
|
5851
5849
|
if (order.hasOwnProperty(row)) {
|
|
5852
|
-
const targetRow = order[row], cloneCell = (
|
|
5850
|
+
const targetRow = order[row], cloneCell = (_a18 = matrix.getValue(targetRow, col)) != null ? _a18 : 0;
|
|
5853
5851
|
cacheMatrix.setValue(row, col, cloneCell);
|
|
5854
5852
|
}
|
|
5855
5853
|
}), cacheMatrix.forValue((row, col, cellData) => {
|
|
@@ -5884,8 +5882,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
|
|
|
5884
5882
|
matrix.setValue(row, col, 1);
|
|
5885
5883
|
}), matrix.moveColumns(fromCol, count, toCol), queryObjectMatrix(matrix, (value) => value === 1);
|
|
5886
5884
|
}, "handleMoveColsCommon"), handleMoveRange = /* @__PURE__ */ __name((param, targetRange) => {
|
|
5887
|
-
var
|
|
5888
|
-
const toRange = (
|
|
5885
|
+
var _a18, _b;
|
|
5886
|
+
const toRange = (_a18 = param.params) == null ? void 0 : _a18.toRange, fromRange = (_b = param.params) == null ? void 0 : _b.fromRange;
|
|
5889
5887
|
if (!toRange || !fromRange)
|
|
5890
5888
|
return [];
|
|
5891
5889
|
const operators = [];
|
|
@@ -5905,8 +5903,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
|
|
|
5905
5903
|
}
|
|
5906
5904
|
return operators;
|
|
5907
5905
|
}, "handleMoveRange"), handleMoveRangeCommon = /* @__PURE__ */ __name((param, targetRange) => {
|
|
5908
|
-
var
|
|
5909
|
-
const toRange = (
|
|
5906
|
+
var _a18, _b;
|
|
5907
|
+
const toRange = (_a18 = param.params) == null ? void 0 : _a18.toRange, fromRange = (_b = param.params) == null ? void 0 : _b.fromRange;
|
|
5910
5908
|
if (!toRange || !fromRange)
|
|
5911
5909
|
return [targetRange];
|
|
5912
5910
|
if (!Rectangle.intersects(fromRange, targetRange) && !Rectangle.intersects(toRange, targetRange))
|
|
@@ -5930,9 +5928,9 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
|
|
|
5930
5928
|
endRow: toRange.endRow - rowOffset
|
|
5931
5929
|
};
|
|
5932
5930
|
return loopToRange && Range.foreach(loopToRange, (row, col) => {
|
|
5933
|
-
var
|
|
5931
|
+
var _a19;
|
|
5934
5932
|
const targetRow = row + rowOffset, targetCol = col + columnOffset;
|
|
5935
|
-
matrix.setValue(targetRow, targetCol, (
|
|
5933
|
+
matrix.setValue(targetRow, targetCol, (_a19 = fromMatrix.getValue(row, col)) != null ? _a19 : 0);
|
|
5936
5934
|
}), queryObjectMatrix(matrix, (value) => value === 1);
|
|
5937
5935
|
}, "handleMoveRangeCommon"), handleBaseRemoveRange = /* @__PURE__ */ __name((_removeRange, _targetRange) => {
|
|
5938
5936
|
const removeRange = handleRangeTypeInput(_removeRange), targetRange = handleRangeTypeInput(_targetRange), getLength = /* @__PURE__ */ __name((range) => range.endColumn - range.startColumn + 1, "getLength"), getRowLength = /* @__PURE__ */ __name((range) => range.endRow - range.startRow + 1, "getRowLength");
|
|
@@ -5960,8 +5958,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
|
|
|
5960
5958
|
}
|
|
5961
5959
|
return { step: 0, length: 0 };
|
|
5962
5960
|
}, "handleBaseRemoveRange"), handleIRemoveCol = /* @__PURE__ */ __name((param, targetRange) => {
|
|
5963
|
-
var
|
|
5964
|
-
const range = (
|
|
5961
|
+
var _a18;
|
|
5962
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
5965
5963
|
if (!range)
|
|
5966
5964
|
return [];
|
|
5967
5965
|
const operators = [], result = handleBaseRemoveRange(range, targetRange);
|
|
@@ -5977,8 +5975,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
|
|
|
5977
5975
|
}
|
|
5978
5976
|
return operators;
|
|
5979
5977
|
}, "handleIRemoveCol"), handleIRemoveRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
5980
|
-
var
|
|
5981
|
-
const range = (
|
|
5978
|
+
var _a18;
|
|
5979
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
5982
5980
|
if (!range)
|
|
5983
5981
|
return [];
|
|
5984
5982
|
const operators = [], result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
|
|
@@ -6050,8 +6048,8 @@ function handleBaseMoveRange(fromRange, toRange, targetRange) {
|
|
|
6050
6048
|
}
|
|
6051
6049
|
__name(handleBaseMoveRange, "handleBaseMoveRange");
|
|
6052
6050
|
const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6053
|
-
var
|
|
6054
|
-
const range = (
|
|
6051
|
+
var _a18;
|
|
6052
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6055
6053
|
if (!range)
|
|
6056
6054
|
return [];
|
|
6057
6055
|
const operators = [], result = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange)), { step, length } = result;
|
|
@@ -6061,8 +6059,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6061
6059
|
length
|
|
6062
6060
|
}), operators;
|
|
6063
6061
|
}, "handleInsertRow"), handleInsertCol = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6064
|
-
var
|
|
6065
|
-
const range = (
|
|
6062
|
+
var _a18;
|
|
6063
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6066
6064
|
if (!range)
|
|
6067
6065
|
return [];
|
|
6068
6066
|
const operators = [], result = handleBaseInsertRange(range, targetRange), { step, length } = result;
|
|
@@ -6072,8 +6070,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6072
6070
|
length
|
|
6073
6071
|
}), operators;
|
|
6074
6072
|
}, "handleInsertCol"), handleInsertRangeMoveDown = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6075
|
-
var
|
|
6076
|
-
const range = (
|
|
6073
|
+
var _a18;
|
|
6074
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6077
6075
|
if (!range)
|
|
6078
6076
|
return [];
|
|
6079
6077
|
const operators = [], result = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange)), { step, length } = result;
|
|
@@ -6083,8 +6081,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6083
6081
|
length
|
|
6084
6082
|
}), operators;
|
|
6085
6083
|
}, "handleInsertRangeMoveDown"), handleInsertRangeMoveDownCommon = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6086
|
-
var
|
|
6087
|
-
const range = (
|
|
6084
|
+
var _a18;
|
|
6085
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6088
6086
|
if (!range)
|
|
6089
6087
|
return [targetRange];
|
|
6090
6088
|
const moveCount = range.endRow - range.startRow + 1, bottomRange = {
|
|
@@ -6103,8 +6101,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6103
6101
|
matrix.setValue(row + moveCount, col, 1);
|
|
6104
6102
|
}), queryObjectMatrix(matrix, (v) => v === 1);
|
|
6105
6103
|
}, "handleInsertRangeMoveDownCommon"), handleInsertRangeMoveRight = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6106
|
-
var
|
|
6107
|
-
const range = (
|
|
6104
|
+
var _a18;
|
|
6105
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6108
6106
|
if (!range)
|
|
6109
6107
|
return [];
|
|
6110
6108
|
const operators = [], result = handleBaseInsertRange(range, targetRange), { step, length } = result;
|
|
@@ -6114,8 +6112,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6114
6112
|
length
|
|
6115
6113
|
}), operators;
|
|
6116
6114
|
}, "handleInsertRangeMoveRight"), handleInsertRangeMoveRightCommon = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6117
|
-
var
|
|
6118
|
-
const range = (
|
|
6115
|
+
var _a18;
|
|
6116
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6119
6117
|
if (!range)
|
|
6120
6118
|
return [targetRange];
|
|
6121
6119
|
const moveCount = range.endColumn - range.startColumn + 1, bottomRange = {
|
|
@@ -6134,8 +6132,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6134
6132
|
matrix.setValue(row, col + moveCount, 1);
|
|
6135
6133
|
}), queryObjectMatrix(matrix, (v) => v === 1);
|
|
6136
6134
|
}, "handleInsertRangeMoveRightCommon"), handleDeleteRangeMoveLeft = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6137
|
-
var
|
|
6138
|
-
const range = (
|
|
6135
|
+
var _a18;
|
|
6136
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6139
6137
|
if (!range)
|
|
6140
6138
|
return [];
|
|
6141
6139
|
const operators = [], result = handleBaseRemoveRange(range, targetRange);
|
|
@@ -6151,8 +6149,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6151
6149
|
}
|
|
6152
6150
|
return operators;
|
|
6153
6151
|
}, "handleDeleteRangeMoveLeft"), handleDeleteRangeMoveLeftCommon = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6154
|
-
var
|
|
6155
|
-
const range = (
|
|
6152
|
+
var _a18;
|
|
6153
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6156
6154
|
if (!range)
|
|
6157
6155
|
return [targetRange];
|
|
6158
6156
|
const rightRange = {
|
|
@@ -6174,8 +6172,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6174
6172
|
});
|
|
6175
6173
|
}), queryObjectMatrix(matrix, (v) => v === 1);
|
|
6176
6174
|
}, "handleDeleteRangeMoveLeftCommon"), handleDeleteRangeMoveUp = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6177
|
-
var
|
|
6178
|
-
const range = (
|
|
6175
|
+
var _a18;
|
|
6176
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6179
6177
|
if (!range)
|
|
6180
6178
|
return [];
|
|
6181
6179
|
const operators = [], result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
|
|
@@ -6191,8 +6189,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6191
6189
|
}
|
|
6192
6190
|
return operators;
|
|
6193
6191
|
}, "handleDeleteRangeMoveUp"), handleDeleteRangeMoveUpCommon = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6194
|
-
var
|
|
6195
|
-
const range = (
|
|
6192
|
+
var _a18;
|
|
6193
|
+
const range = (_a18 = param.params) == null ? void 0 : _a18.range;
|
|
6196
6194
|
if (!range)
|
|
6197
6195
|
return [targetRange];
|
|
6198
6196
|
const bottomRange = {
|
|
@@ -6213,8 +6211,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
|
|
|
6213
6211
|
});
|
|
6214
6212
|
}), queryObjectMatrix(matrix, (v) => v === 1);
|
|
6215
6213
|
}, "handleDeleteRangeMoveUpCommon"), handleRemoveRowCommon = /* @__PURE__ */ __name((param, targetRange) => {
|
|
6216
|
-
var
|
|
6217
|
-
const ranges = (
|
|
6214
|
+
var _a18;
|
|
6215
|
+
const ranges = (_a18 = param.ranges) != null ? _a18 : [param.range], matrix = new ObjectMatrix();
|
|
6218
6216
|
return Range.foreach(targetRange, (row, col) => {
|
|
6219
6217
|
matrix.setValue(row, col, 1);
|
|
6220
6218
|
}), ranges.forEach((range) => {
|
|
@@ -6389,7 +6387,7 @@ function adjustRangeOnMutation(range, mutation) {
|
|
|
6389
6387
|
}
|
|
6390
6388
|
__name(adjustRangeOnMutation, "adjustRangeOnMutation");
|
|
6391
6389
|
function getEffectedRangesOnCommand(command, deps) {
|
|
6392
|
-
var
|
|
6390
|
+
var _a18, _b, _c, _d, _e, _f;
|
|
6393
6391
|
const { selectionManagerService } = deps;
|
|
6394
6392
|
switch (command.id) {
|
|
6395
6393
|
case EffectRefRangId.MoveColsCommandId: {
|
|
@@ -6444,7 +6442,7 @@ function getEffectedRangesOnCommand(command, deps) {
|
|
|
6444
6442
|
return [command.params.range];
|
|
6445
6443
|
case EffectRefRangId.DeleteRangeMoveUpCommandId:
|
|
6446
6444
|
case EffectRefRangId.InsertRangeMoveDownCommandId: {
|
|
6447
|
-
const range = ((
|
|
6445
|
+
const range = ((_a18 = command.params) == null ? void 0 : _a18.range) || ((_c = (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range)) == null ? void 0 : _c[0]);
|
|
6448
6446
|
return range ? [range] : [];
|
|
6449
6447
|
}
|
|
6450
6448
|
case EffectRefRangId.DeleteRangeMoveLeftCommandId:
|
|
@@ -6531,8 +6529,8 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
|
|
|
6531
6529
|
super(), this._unitId = _unitId, this._subUnitId = _subUnitId, this._range = _range, this._callback = _callback, this._skipIntersects = _skipIntersects;
|
|
6532
6530
|
}
|
|
6533
6531
|
onMutation(mutation) {
|
|
6534
|
-
var
|
|
6535
|
-
if (((
|
|
6532
|
+
var _a18, _b;
|
|
6533
|
+
if (((_a18 = mutation.params) == null ? void 0 : _a18.unitId) !== this._unitId)
|
|
6536
6534
|
return;
|
|
6537
6535
|
if (mutation.id === MoveRangeMutation.id) {
|
|
6538
6536
|
const params = mutation.params;
|
|
@@ -6558,8 +6556,8 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
|
|
|
6558
6556
|
};
|
|
6559
6557
|
__name(_WatchRange, "WatchRange");
|
|
6560
6558
|
let WatchRange = _WatchRange;
|
|
6561
|
-
var
|
|
6562
|
-
let RefRangeService = (
|
|
6559
|
+
var _a8;
|
|
6560
|
+
let RefRangeService = (_a8 = class extends Disposable {
|
|
6563
6561
|
constructor(_commandService, _sheetInterceptorService, _univerInstanceService, _selectionManagerService) {
|
|
6564
6562
|
super();
|
|
6565
6563
|
__publicField(this, "interceptor", new InterceptorManager({ MERGE_REDO, MERGE_UNDO }));
|
|
@@ -6680,8 +6678,8 @@ let RefRangeService = (_a11 = class extends Disposable {
|
|
|
6680
6678
|
[]
|
|
6681
6679
|
).reduce(
|
|
6682
6680
|
(result2, currentValue) => {
|
|
6683
|
-
var
|
|
6684
|
-
return result2.redos.push(...currentValue.redos), result2.undos.push(...currentValue.undos), result2.preRedos.push(...(
|
|
6681
|
+
var _a18, _b;
|
|
6682
|
+
return result2.redos.push(...currentValue.redos), result2.undos.push(...currentValue.undos), result2.preRedos.push(...(_a18 = currentValue.preRedos) != null ? _a18 : []), result2.preUndos.push(...(_b = currentValue.preUndos) != null ? _b : []), result2;
|
|
6685
6683
|
},
|
|
6686
6684
|
{ redos: [], undos: [], preUndos: [], preRedos: [] }
|
|
6687
6685
|
), preRedos = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(
|
|
@@ -6767,9 +6765,8 @@ let RefRangeService = (_a11 = class extends Disposable {
|
|
|
6767
6765
|
registerToService.dispose(), teardownWatching.dispose();
|
|
6768
6766
|
});
|
|
6769
6767
|
}
|
|
6770
|
-
}, __name(
|
|
6768
|
+
}, __name(_a8, "RefRangeService"), _a8);
|
|
6771
6769
|
RefRangeService = __decorateClass$9([
|
|
6772
|
-
OnLifecycle(LifecycleStages.Ready, RefRangeService),
|
|
6773
6770
|
__decorateParam$9(0, ICommandService),
|
|
6774
6771
|
__decorateParam$9(1, Inject(SheetInterceptorService)),
|
|
6775
6772
|
__decorateParam$9(2, Inject(IUniverInstanceService)),
|
|
@@ -6780,13 +6777,13 @@ function getUnitId(univerInstanceService) {
|
|
|
6780
6777
|
}
|
|
6781
6778
|
__name(getUnitId, "getUnitId");
|
|
6782
6779
|
function getSubUnitId(univerInstanceService) {
|
|
6783
|
-
var
|
|
6784
|
-
return (
|
|
6780
|
+
var _a18;
|
|
6781
|
+
return (_a18 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : _a18.getSheetId();
|
|
6785
6782
|
}
|
|
6786
6783
|
__name(getSubUnitId, "getSubUnitId");
|
|
6787
6784
|
function getSelectionRanges(selectionManagerService) {
|
|
6788
|
-
var
|
|
6789
|
-
return ((
|
|
6785
|
+
var _a18;
|
|
6786
|
+
return ((_a18 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range)) || [];
|
|
6790
6787
|
}
|
|
6791
6788
|
__name(getSelectionRanges, "getSelectionRanges");
|
|
6792
6789
|
function getRefRangId(unitId, subUnitId) {
|
|
@@ -6855,8 +6852,8 @@ function getAddMergeMutationRangeByType(selection, type) {
|
|
|
6855
6852
|
}
|
|
6856
6853
|
__name(getAddMergeMutationRangeByType, "getAddMergeMutationRangeByType");
|
|
6857
6854
|
const MERGE_CELL_INTERCEPTOR_CHECK = createInterceptorKey("mergeCellPermissionCheck");
|
|
6858
|
-
var
|
|
6859
|
-
let MergeCellController = (
|
|
6855
|
+
var _a9;
|
|
6856
|
+
let MergeCellController = (_a9 = class extends Disposable {
|
|
6860
6857
|
constructor(_commandService, _refRangeService, _univerInstanceService, _injector, _sheetInterceptorService, _selectionManagerService) {
|
|
6861
6858
|
super();
|
|
6862
6859
|
__publicField(this, "disposableCollection", new DisposableCollection());
|
|
@@ -6867,14 +6864,14 @@ let MergeCellController = (_a12 = class extends Disposable {
|
|
|
6867
6864
|
const self = this;
|
|
6868
6865
|
this._sheetInterceptorService.interceptCommand({
|
|
6869
6866
|
getMutations(commandInfo) {
|
|
6870
|
-
var
|
|
6867
|
+
var _a18;
|
|
6871
6868
|
switch (commandInfo.id) {
|
|
6872
6869
|
case ClearSelectionAllCommand.id:
|
|
6873
6870
|
case ClearSelectionFormatCommand.id: {
|
|
6874
6871
|
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
|
|
6875
6872
|
if (!worksheet)
|
|
6876
6873
|
return { redos: [], undos: [] };
|
|
6877
|
-
const subUnitId = worksheet.getSheetId(), mergeData = worksheet.getConfig().mergeData, selections = (
|
|
6874
|
+
const subUnitId = worksheet.getSheetId(), mergeData = worksheet.getConfig().mergeData, selections = (_a18 = self._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
6878
6875
|
if (selections && selections.length > 0 && selections.some(
|
|
6879
6876
|
(range) => mergeData.some((item) => Rectangle.intersects(item, range))
|
|
6880
6877
|
)) {
|
|
@@ -7569,7 +7566,7 @@ let MergeCellController = (_a12 = class extends Disposable {
|
|
|
7569
7566
|
}
|
|
7570
7567
|
}));
|
|
7571
7568
|
}
|
|
7572
|
-
}, __name(
|
|
7569
|
+
}, __name(_a9, "MergeCellController"), _a9);
|
|
7573
7570
|
MergeCellController = __decorateClass$8([
|
|
7574
7571
|
__decorateParam$8(0, Inject(ICommandService)),
|
|
7575
7572
|
__decorateParam$8(1, Inject(RefRangeService)),
|
|
@@ -7590,8 +7587,8 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
|
|
|
7590
7587
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7591
7588
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
7592
7589
|
return kind && result && __defProp$7(target, key, result), result;
|
|
7593
|
-
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"),
|
|
7594
|
-
let NumberCellDisplayController = (
|
|
7590
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a10;
|
|
7591
|
+
let NumberCellDisplayController = (_a10 = class extends Disposable {
|
|
7595
7592
|
constructor(_sheetInterceptorService) {
|
|
7596
7593
|
super(), this._sheetInterceptorService = _sheetInterceptorService, this._initialize();
|
|
7597
7594
|
}
|
|
@@ -7604,9 +7601,9 @@ let NumberCellDisplayController = (_a13 = class extends Disposable {
|
|
|
7604
7601
|
priority: 11,
|
|
7605
7602
|
effect: InterceptorEffectEnum.Value | InterceptorEffectEnum.Style,
|
|
7606
7603
|
handler: /* @__PURE__ */ __name((cell, location, next) => {
|
|
7607
|
-
var
|
|
7604
|
+
var _a18;
|
|
7608
7605
|
const style = location.workbook.getStyles().getStyleByCell(cell);
|
|
7609
|
-
return (
|
|
7606
|
+
return (_a18 = style == null ? void 0 : style.n) != null && _a18.pattern ? next({ ...cell }) : (cell == null ? void 0 : cell.t) === CellValueType.NUMBER && typeof (cell == null ? void 0 : cell.v) == "number" ? next({
|
|
7610
7607
|
...cell,
|
|
7611
7608
|
v: stripErrorMargin(cell.v)
|
|
7612
7609
|
}) : next({ ...cell });
|
|
@@ -7614,23 +7611,25 @@ let NumberCellDisplayController = (_a13 = class extends Disposable {
|
|
|
7614
7611
|
})
|
|
7615
7612
|
);
|
|
7616
7613
|
}
|
|
7617
|
-
}, __name(
|
|
7614
|
+
}, __name(_a10, "NumberCellDisplayController"), _a10);
|
|
7618
7615
|
NumberCellDisplayController = __decorateClass$7([
|
|
7619
|
-
OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController),
|
|
7620
7616
|
__decorateParam$7(0, Inject(SheetInterceptorService))
|
|
7621
7617
|
], NumberCellDisplayController);
|
|
7622
7618
|
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
7623
7619
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7624
7620
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
7625
7621
|
return kind && result && __defProp$6(target, key, result), result;
|
|
7626
|
-
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"),
|
|
7627
|
-
let RangeProtectionCache = (
|
|
7622
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a11;
|
|
7623
|
+
let RangeProtectionCache = (_a11 = class extends Disposable {
|
|
7628
7624
|
constructor(_ruleModel, _permissionService, _univerInstanceService) {
|
|
7629
7625
|
super();
|
|
7630
7626
|
__publicField(this, "_cellRuleCache", /* @__PURE__ */ new Map());
|
|
7631
7627
|
__publicField(this, "_permissionIdCache", /* @__PURE__ */ new Map());
|
|
7632
7628
|
__publicField(this, "_cellInfoCache", /* @__PURE__ */ new Map());
|
|
7633
|
-
|
|
7629
|
+
// {unitId:{subUnitId:{[row/col]:{permissionId1:{edit:true},permissionId2:{edit:true},permissionId3:{edit:false}}}}}
|
|
7630
|
+
__publicField(this, "_rowInfoCache", /* @__PURE__ */ new Map());
|
|
7631
|
+
__publicField(this, "_colInfoCache", /* @__PURE__ */ new Map());
|
|
7632
|
+
this._ruleModel = _ruleModel, this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._initUpdateCellRuleCache(), this._initUpdateCellInfoCache(), this._initUpdateRowColInfoCache(), this._initCache();
|
|
7634
7633
|
}
|
|
7635
7634
|
_initCache() {
|
|
7636
7635
|
this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {
|
|
@@ -7659,13 +7658,13 @@ let RangeProtectionCache = (_a14 = class extends Disposable {
|
|
|
7659
7658
|
cellInfoMap.delete(`${i}-${j}`);
|
|
7660
7659
|
});
|
|
7661
7660
|
}), this._ruleModel.ruleChange$.subscribe((info) => {
|
|
7662
|
-
var
|
|
7661
|
+
var _a18;
|
|
7663
7662
|
const { unitId, subUnitId } = info, cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
|
|
7664
7663
|
info.rule.ranges.forEach((range) => {
|
|
7665
7664
|
Range.foreach(range, (row, col) => {
|
|
7666
7665
|
cellInfoMap.delete(`${row}-${col}`);
|
|
7667
7666
|
});
|
|
7668
|
-
}), info.type === "set" && ((
|
|
7667
|
+
}), info.type === "set" && ((_a18 = info.oldRule) == null || _a18.ranges.forEach((range) => {
|
|
7669
7668
|
Range.foreach(range, (row, col) => {
|
|
7670
7669
|
this._cellInfoCache.delete(`${row}-${col}`);
|
|
7671
7670
|
});
|
|
@@ -7690,6 +7689,12 @@ let RangeProtectionCache = (_a14 = class extends Disposable {
|
|
|
7690
7689
|
let cellMap = subUnitMap.get(subUnitId);
|
|
7691
7690
|
return cellMap || (cellMap = /* @__PURE__ */ new Map(), subUnitMap.set(subUnitId, cellMap)), cellMap;
|
|
7692
7691
|
}
|
|
7692
|
+
_ensureRowColInfoMap(unitId, subUnitId, type) {
|
|
7693
|
+
let subUnitMap = type === "row" ? this._rowInfoCache.get(unitId) : this._colInfoCache.get(unitId);
|
|
7694
|
+
subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), type === "row" ? this._rowInfoCache.set(unitId, subUnitMap) : this._colInfoCache.set(unitId, subUnitMap));
|
|
7695
|
+
let cellMap = subUnitMap.get(subUnitId);
|
|
7696
|
+
return cellMap || (cellMap = /* @__PURE__ */ new Map(), subUnitMap.set(subUnitId, cellMap)), cellMap;
|
|
7697
|
+
}
|
|
7693
7698
|
_addCellRuleCache(ruleChange) {
|
|
7694
7699
|
const { subUnitId, unitId, rule } = ruleChange, cellMap = this._ensureRuleMap(unitId, subUnitId);
|
|
7695
7700
|
rule.ranges.forEach((range) => {
|
|
@@ -7710,9 +7715,11 @@ let RangeProtectionCache = (_a14 = class extends Disposable {
|
|
|
7710
7715
|
}
|
|
7711
7716
|
reBuildCache(unitId, subUnitId) {
|
|
7712
7717
|
const cellRuleMap = this._ensureRuleMap(unitId, subUnitId), cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
|
|
7713
|
-
cellRuleMap.clear(), cellInfoMap.clear()
|
|
7714
|
-
|
|
7715
|
-
|
|
7718
|
+
cellRuleMap.clear(), cellInfoMap.clear();
|
|
7719
|
+
const rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row"), colInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "col");
|
|
7720
|
+
rowInfoMap.clear(), colInfoMap.clear(), this._ruleModel.getSubunitRuleList(unitId, subUnitId).forEach((rule) => {
|
|
7721
|
+
var _a18, _b, _c, _d, _e, _f;
|
|
7722
|
+
const edit = (_c = (_b = this._permissionService.getPermissionPoint((_a18 = new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId)) == null ? void 0 : _a18.id)) == null ? void 0 : _b.value) != null ? _c : !0, view = (_f = (_e = this._permissionService.getPermissionPoint((_d = new RangeProtectionPermissionViewPoint(unitId, subUnitId, rule.permissionId)) == null ? void 0 : _d.id)) == null ? void 0 : _e.value) != null ? _f : !0, selectionProtection = {
|
|
7716
7723
|
[P.Edit]: edit,
|
|
7717
7724
|
[P.View]: view,
|
|
7718
7725
|
ruleId: rule.id,
|
|
@@ -7720,19 +7727,94 @@ let RangeProtectionCache = (_a14 = class extends Disposable {
|
|
|
7720
7727
|
};
|
|
7721
7728
|
rule.ranges.forEach((range) => {
|
|
7722
7729
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
7723
|
-
for (let i = startRow; i <= endRow; i++)
|
|
7724
|
-
|
|
7730
|
+
for (let i = startRow; i <= endRow; i++) {
|
|
7731
|
+
const rowInfo = rowInfoMap.get(`${i}`);
|
|
7732
|
+
rowInfo ? rowInfo.set(rule.id, { [P.Edit]: edit, [P.View]: view }) : rowInfoMap.set(`${i}`, /* @__PURE__ */ new Map([[rule.id, { [P.Edit]: edit, [P.View]: view }]]));
|
|
7733
|
+
for (let j = startColumn; j <= endColumn; j++) {
|
|
7725
7734
|
cellRuleMap.set(`${i}-${j}`, rule.id), cellInfoMap.set(`${i}-${j}`, selectionProtection);
|
|
7735
|
+
const colInfo = colInfoMap.get(`${j}`);
|
|
7736
|
+
colInfo ? colInfo.set(rule.id, { [P.Edit]: edit, [P.View]: view }) : colInfoMap.set(`${j}`, /* @__PURE__ */ new Map([[rule.id, { [P.Edit]: edit, [P.View]: view }]]));
|
|
7737
|
+
}
|
|
7738
|
+
}
|
|
7726
7739
|
}), this._permissionIdCache.set(rule.permissionId, rule.id);
|
|
7727
7740
|
});
|
|
7728
7741
|
}
|
|
7742
|
+
getRowPermissionInfo(unitId, subUnitId, row, types) {
|
|
7743
|
+
var _a18;
|
|
7744
|
+
const rowInfo = (_a18 = this._rowInfoCache.get(unitId)) == null ? void 0 : _a18.get(subUnitId);
|
|
7745
|
+
if (!rowInfo)
|
|
7746
|
+
return !0;
|
|
7747
|
+
const info = rowInfo.get(`${row}`);
|
|
7748
|
+
return info ? types.every((type) => {
|
|
7749
|
+
for (const actionGroup of info.values())
|
|
7750
|
+
if (actionGroup[type] === !1)
|
|
7751
|
+
return !1;
|
|
7752
|
+
return !0;
|
|
7753
|
+
}) : !0;
|
|
7754
|
+
}
|
|
7755
|
+
getColPermissionInfo(unitId, subUnitId, col, types) {
|
|
7756
|
+
var _a18;
|
|
7757
|
+
const colInfo = (_a18 = this._colInfoCache.get(unitId)) == null ? void 0 : _a18.get(subUnitId);
|
|
7758
|
+
if (!colInfo)
|
|
7759
|
+
return !0;
|
|
7760
|
+
const info = colInfo.get(`${col}`);
|
|
7761
|
+
return info ? types.every((type) => {
|
|
7762
|
+
for (const actionGroup of info.values())
|
|
7763
|
+
if (actionGroup[type] === !1)
|
|
7764
|
+
return !1;
|
|
7765
|
+
return !0;
|
|
7766
|
+
}) : !0;
|
|
7767
|
+
}
|
|
7768
|
+
_initUpdateRowColInfoCache() {
|
|
7769
|
+
this._permissionService.permissionPointUpdate$.pipe(
|
|
7770
|
+
filter((permission) => permission.type === M.SelectRange),
|
|
7771
|
+
map((permission) => permission)
|
|
7772
|
+
).subscribe({
|
|
7773
|
+
next: /* @__PURE__ */ __name((permission) => {
|
|
7774
|
+
var _a18, _b, _c, _d, _e, _f;
|
|
7775
|
+
const { subUnitId, unitId, permissionId } = permission, ruleId = this._permissionIdCache.get(permissionId);
|
|
7776
|
+
if (!ruleId)
|
|
7777
|
+
return;
|
|
7778
|
+
const ruleInstance = this._ruleModel.getRule(unitId, subUnitId, ruleId);
|
|
7779
|
+
if (!ruleInstance)
|
|
7780
|
+
return;
|
|
7781
|
+
const rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row"), colInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "col"), edit = (_c = (_b = this._permissionService.getPermissionPoint((_a18 = new RangeProtectionPermissionEditPoint(unitId, subUnitId, ruleInstance.permissionId)) == null ? void 0 : _a18.id)) == null ? void 0 : _b.value) != null ? _c : !0, view = (_f = (_e = this._permissionService.getPermissionPoint((_d = new RangeProtectionPermissionViewPoint(unitId, subUnitId, ruleInstance.permissionId)) == null ? void 0 : _d.id)) == null ? void 0 : _e.value) != null ? _f : !0;
|
|
7782
|
+
ruleInstance.ranges.forEach((range) => {
|
|
7783
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
7784
|
+
for (let i = startRow; i <= endRow; i++) {
|
|
7785
|
+
const rowInfo = rowInfoMap.get(`${i}`);
|
|
7786
|
+
rowInfo ? rowInfo.set(ruleId, { [P.Edit]: edit, [P.View]: view }) : rowInfoMap.set(`${i}`, /* @__PURE__ */ new Map([[ruleId, { [P.Edit]: edit, [P.View]: view }]]));
|
|
7787
|
+
for (let j = startColumn; j <= endColumn; j++) {
|
|
7788
|
+
const colInfo = colInfoMap.get(`${j}`);
|
|
7789
|
+
colInfo ? colInfo.set(ruleId, { [P.Edit]: edit, [P.View]: view }) : colInfoMap.set(`${j}`, /* @__PURE__ */ new Map([[ruleId, { [P.Edit]: edit, [P.View]: view }]]));
|
|
7790
|
+
}
|
|
7791
|
+
}
|
|
7792
|
+
});
|
|
7793
|
+
}, "next")
|
|
7794
|
+
}), this._ruleModel.ruleChange$.subscribe((info) => {
|
|
7795
|
+
if (info.type === "delete") {
|
|
7796
|
+
const { unitId, subUnitId, rule } = info, rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row"), colInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "col");
|
|
7797
|
+
rule.ranges.forEach((range) => {
|
|
7798
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
7799
|
+
for (let i = startRow; i <= endRow; i++) {
|
|
7800
|
+
const rowInfo = rowInfoMap.get(`${i}`);
|
|
7801
|
+
rowInfo == null || rowInfo.delete(rule.id);
|
|
7802
|
+
for (let j = startColumn; j <= endColumn; j++) {
|
|
7803
|
+
const colInfo = colInfoMap.get(`${j}`);
|
|
7804
|
+
colInfo == null || colInfo.delete(rule.id);
|
|
7805
|
+
}
|
|
7806
|
+
}
|
|
7807
|
+
});
|
|
7808
|
+
}
|
|
7809
|
+
});
|
|
7810
|
+
}
|
|
7729
7811
|
getCellInfo(unitId, subUnitId, row, col) {
|
|
7730
|
-
var
|
|
7812
|
+
var _a18, _b, _c, _d, _e, _f, _g, _h;
|
|
7731
7813
|
const cellMap = this._ensureCellInfoMap(unitId, subUnitId), cacheValue = cellMap.get(`${row}-${col}`);
|
|
7732
7814
|
if (cacheValue)
|
|
7733
7815
|
return cacheValue;
|
|
7734
7816
|
let view = !0, edit = !0;
|
|
7735
|
-
const ruleId = (_b = (
|
|
7817
|
+
const ruleId = (_b = (_a18 = this._cellRuleCache.get(unitId)) == null ? void 0 : _a18.get(subUnitId)) == null ? void 0 : _b.get(`${row}-${col}`);
|
|
7736
7818
|
if (!ruleId)
|
|
7737
7819
|
return;
|
|
7738
7820
|
const rule = this._ruleModel.getRule(unitId, subUnitId, ruleId);
|
|
@@ -7748,7 +7830,7 @@ let RangeProtectionCache = (_a14 = class extends Disposable {
|
|
|
7748
7830
|
}
|
|
7749
7831
|
}
|
|
7750
7832
|
deleteUnit(unitId) {
|
|
7751
|
-
this._cellRuleCache.delete(unitId), this._cellInfoCache.delete(unitId);
|
|
7833
|
+
this._cellRuleCache.delete(unitId), this._cellInfoCache.delete(unitId), this._rowInfoCache.delete(unitId), this._colInfoCache.delete(unitId);
|
|
7752
7834
|
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
7753
7835
|
workbook == null || workbook.getSheets().forEach((sheet) => {
|
|
7754
7836
|
const subUnitId = sheet.getSheetId();
|
|
@@ -7757,7 +7839,7 @@ let RangeProtectionCache = (_a14 = class extends Disposable {
|
|
|
7757
7839
|
});
|
|
7758
7840
|
});
|
|
7759
7841
|
}
|
|
7760
|
-
}, __name(
|
|
7842
|
+
}, __name(_a11, "RangeProtectionCache"), _a11);
|
|
7761
7843
|
RangeProtectionCache = __decorateClass$6([
|
|
7762
7844
|
__decorateParam$6(0, Inject(RangeProtectionRuleModel)),
|
|
7763
7845
|
__decorateParam$6(1, Inject(IPermissionService)),
|
|
@@ -7771,8 +7853,8 @@ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPrope
|
|
|
7771
7853
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7772
7854
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
7773
7855
|
return kind && result && __defProp$5(target, key, result), result;
|
|
7774
|
-
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"),
|
|
7775
|
-
let RangeProtectionRenderModel = (
|
|
7856
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a12;
|
|
7857
|
+
let RangeProtectionRenderModel = (_a12 = class {
|
|
7776
7858
|
constructor(_selectionProtectionRuleModel, _permissionService) {
|
|
7777
7859
|
__publicField(this, "_cache", new LRUMap(1e4));
|
|
7778
7860
|
this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._permissionService = _permissionService, this._init();
|
|
@@ -7792,13 +7874,13 @@ let RangeProtectionRenderModel = (_a15 = class {
|
|
|
7792
7874
|
});
|
|
7793
7875
|
});
|
|
7794
7876
|
}), this._selectionProtectionRuleModel.ruleChange$.subscribe((info) => {
|
|
7795
|
-
var
|
|
7877
|
+
var _a18;
|
|
7796
7878
|
info.rule.ranges.forEach((range) => {
|
|
7797
7879
|
Range.foreach(range, (row, col) => {
|
|
7798
7880
|
const key = this._createKey(info.unitId, info.subUnitId, row, col);
|
|
7799
7881
|
this._cache.delete(key);
|
|
7800
7882
|
});
|
|
7801
|
-
}), info.type === "set" && ((
|
|
7883
|
+
}), info.type === "set" && ((_a18 = info.oldRule) == null || _a18.ranges.forEach((range) => {
|
|
7802
7884
|
Range.foreach(range, (row, col) => {
|
|
7803
7885
|
const key = this._createKey(info.unitId, info.subUnitId, row, col);
|
|
7804
7886
|
this._cache.delete(key);
|
|
@@ -7820,9 +7902,9 @@ let RangeProtectionRenderModel = (_a15 = class {
|
|
|
7820
7902
|
for (const rule of ruleMap)
|
|
7821
7903
|
if (rule.ranges.some((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col)) {
|
|
7822
7904
|
const permissionMap = getAllRangePermissionPoint().reduce((result2, F) => {
|
|
7823
|
-
var
|
|
7905
|
+
var _a18;
|
|
7824
7906
|
const instance = new F(unitId, subUnitId, rule.permissionId), permission = this._permissionService.getPermissionPoint(instance.id);
|
|
7825
|
-
return result2[instance.subType] = (
|
|
7907
|
+
return result2[instance.subType] = (_a18 = permission == null ? void 0 : permission.value) != null ? _a18 : instance.value, result2;
|
|
7826
7908
|
}, {});
|
|
7827
7909
|
result.push({ ...permissionMap, ruleId: rule.id, ranges: rule.ranges });
|
|
7828
7910
|
}
|
|
@@ -7831,9 +7913,8 @@ let RangeProtectionRenderModel = (_a15 = class {
|
|
|
7831
7913
|
clear() {
|
|
7832
7914
|
this._cache.clear();
|
|
7833
7915
|
}
|
|
7834
|
-
}, __name(
|
|
7916
|
+
}, __name(_a12, "RangeProtectionRenderModel"), _a12);
|
|
7835
7917
|
RangeProtectionRenderModel = __decorateClass$5([
|
|
7836
|
-
OnLifecycle(LifecycleStages.Ready, RangeProtectionRenderModel),
|
|
7837
7918
|
__decorateParam$5(0, Inject(RangeProtectionRuleModel)),
|
|
7838
7919
|
__decorateParam$5(1, Inject(IPermissionService))
|
|
7839
7920
|
], RangeProtectionRenderModel);
|
|
@@ -7860,8 +7941,8 @@ const IExclusiveRangeService = createIdentifier("univer.exclusive-range-service"
|
|
|
7860
7941
|
this._ensureFeature(unitId, sheetId, feature).push(...ranges);
|
|
7861
7942
|
}
|
|
7862
7943
|
getExclusiveRanges(unitId, sheetId, feature) {
|
|
7863
|
-
var
|
|
7864
|
-
return (_b = (
|
|
7944
|
+
var _a18, _b;
|
|
7945
|
+
return (_b = (_a18 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a18.get(sheetId)) == null ? void 0 : _b.get(feature);
|
|
7865
7946
|
}
|
|
7866
7947
|
clearExclusiveRanges(unitId, sheetId, feature) {
|
|
7867
7948
|
this._ensureFeature(unitId, sheetId, feature), this._exclusiveRanges.get(unitId).get(sheetId).set(feature, []);
|
|
@@ -7876,10 +7957,10 @@ const IExclusiveRangeService = createIdentifier("univer.exclusive-range-service"
|
|
|
7876
7957
|
getInterestGroupId(selections) {
|
|
7877
7958
|
const interestGroupId = [];
|
|
7878
7959
|
return selections.forEach((selection) => {
|
|
7879
|
-
var
|
|
7960
|
+
var _a18;
|
|
7880
7961
|
const range = selection.range, { unitId, sheetId } = range;
|
|
7881
7962
|
if (!unitId || !sheetId) return;
|
|
7882
|
-
const featureMap = (
|
|
7963
|
+
const featureMap = (_a18 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a18.get(sheetId);
|
|
7883
7964
|
if (featureMap)
|
|
7884
7965
|
for (const feature of featureMap.keys()) {
|
|
7885
7966
|
const featureMapRanges = featureMap.get(feature);
|
|
@@ -7900,8 +7981,8 @@ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPrope
|
|
|
7900
7981
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7901
7982
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
7902
7983
|
return kind && result && __defProp$4(target, key, result), result;
|
|
7903
|
-
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"),
|
|
7904
|
-
let NumfmtService = (
|
|
7984
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a13;
|
|
7985
|
+
let NumfmtService = (_a13 = class extends Disposable {
|
|
7905
7986
|
constructor(_resourceManagerService, _univerInstanceService, _logService) {
|
|
7906
7987
|
super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._logService = _logService;
|
|
7907
7988
|
}
|
|
@@ -7965,7 +8046,7 @@ let NumfmtService = (_a16 = class extends Disposable {
|
|
|
7965
8046
|
});
|
|
7966
8047
|
});
|
|
7967
8048
|
}
|
|
7968
|
-
}, __name(
|
|
8049
|
+
}, __name(_a13, "NumfmtService"), _a13);
|
|
7969
8050
|
NumfmtService = __decorateClass$4([
|
|
7970
8051
|
__decorateParam$4(0, IResourceManagerService),
|
|
7971
8052
|
__decorateParam$4(1, IUniverInstanceService),
|
|
@@ -7977,12 +8058,12 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
|
|
|
7977
8058
|
return kind && result && __defProp$3(target, key, result), result;
|
|
7978
8059
|
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
|
|
7979
8060
|
const mutationIdByRowCol = [InsertColMutation.id, InsertRowMutation.id, RemoveColMutation.id, RemoveRowMutation.id], mutationIdArrByMove = [MoveRowsMutation.id, MoveColsMutation.id];
|
|
7980
|
-
var
|
|
7981
|
-
let RangeProtectionRefRangeService = (
|
|
7982
|
-
constructor(_selectionProtectionRuleModel, _univerInstanceService, _commandService, _refRangeService, _selectionProtectionRenderModel, _rangeProtectionCache) {
|
|
8061
|
+
var _a14;
|
|
8062
|
+
let RangeProtectionRefRangeService = (_a14 = class extends Disposable {
|
|
8063
|
+
constructor(_selectionProtectionRuleModel, _univerInstanceService, _commandService, _refRangeService, _selectionProtectionRenderModel, _rangeProtectionCache, _sheetInterceptorService, _rangeProtectionRuleModel) {
|
|
7983
8064
|
super();
|
|
7984
8065
|
__publicField(this, "disposableCollection", new DisposableCollection());
|
|
7985
|
-
this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._refRangeService = _refRangeService, this._selectionProtectionRenderModel = _selectionProtectionRenderModel, this._rangeProtectionCache = _rangeProtectionCache, this._onRefRangeChange(), this._correctPermissionRange(), this._initReBuildCache();
|
|
8066
|
+
this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._refRangeService = _refRangeService, this._selectionProtectionRenderModel = _selectionProtectionRenderModel, this._rangeProtectionCache = _rangeProtectionCache, this._sheetInterceptorService = _sheetInterceptorService, this._rangeProtectionRuleModel = _rangeProtectionRuleModel, this._onRefRangeChange(), this._correctPermissionRange(), this._initReBuildCache(), this._initRemoveSheet();
|
|
7986
8067
|
}
|
|
7987
8068
|
_onRefRangeChange() {
|
|
7988
8069
|
const registerRefRange = /* @__PURE__ */ __name((unitId, subUnitId) => {
|
|
@@ -8181,15 +8262,37 @@ let RangeProtectionRefRangeService = (_a17 = class extends Disposable {
|
|
|
8181
8262
|
}
|
|
8182
8263
|
}));
|
|
8183
8264
|
}
|
|
8184
|
-
|
|
8265
|
+
_initRemoveSheet() {
|
|
8266
|
+
this._sheetInterceptorService.interceptCommand(
|
|
8267
|
+
{
|
|
8268
|
+
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
8269
|
+
const undos = [], redos = [], preRedos = [], preUndos = [];
|
|
8270
|
+
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
8271
|
+
const params = commandInfo.params, deleteRuleIds = [], addRuleArr = [];
|
|
8272
|
+
this._rangeProtectionRuleModel.getSubunitRuleList(params.unitId, params.subUnitId).forEach((rule) => {
|
|
8273
|
+
deleteRuleIds.push(rule.id), addRuleArr.push(rule);
|
|
8274
|
+
}), deleteRuleIds.length && addRuleArr.length && (preRedos.push({ id: DeleteRangeProtectionMutation.id, params: { unitId: params.unitId, subUnitId: params.subUnitId, ruleIds: deleteRuleIds } }), undos.push({ id: AddRangeProtectionMutation.id, params: { unitId: params.unitId, subUnitId: params.subUnitId, name: "", rules: addRuleArr } }));
|
|
8275
|
+
}
|
|
8276
|
+
return {
|
|
8277
|
+
redos,
|
|
8278
|
+
undos,
|
|
8279
|
+
preRedos,
|
|
8280
|
+
preUndos
|
|
8281
|
+
};
|
|
8282
|
+
}, "getMutations")
|
|
8283
|
+
}
|
|
8284
|
+
);
|
|
8285
|
+
}
|
|
8286
|
+
}, __name(_a14, "RangeProtectionRefRangeService"), _a14);
|
|
8185
8287
|
RangeProtectionRefRangeService = __decorateClass$3([
|
|
8186
|
-
OnLifecycle(LifecycleStages.Ready, RangeProtectionRefRangeService),
|
|
8187
8288
|
__decorateParam$3(0, Inject(RangeProtectionRuleModel)),
|
|
8188
8289
|
__decorateParam$3(1, Inject(IUniverInstanceService)),
|
|
8189
8290
|
__decorateParam$3(2, ICommandService),
|
|
8190
8291
|
__decorateParam$3(3, Inject(RefRangeService)),
|
|
8191
8292
|
__decorateParam$3(4, Inject(RangeProtectionRenderModel)),
|
|
8192
|
-
__decorateParam$3(5, Inject(RangeProtectionCache))
|
|
8293
|
+
__decorateParam$3(5, Inject(RangeProtectionCache)),
|
|
8294
|
+
__decorateParam$3(6, Inject(SheetInterceptorService)),
|
|
8295
|
+
__decorateParam$3(7, Inject(RangeProtectionRuleModel))
|
|
8193
8296
|
], RangeProtectionRefRangeService);
|
|
8194
8297
|
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
8195
8298
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -8197,8 +8300,8 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
|
|
|
8197
8300
|
return kind && result && __defProp$2(target, key, result), result;
|
|
8198
8301
|
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
|
|
8199
8302
|
const PLUGIN_NAME$1 = "SHEET_RANGE_PROTECTION_PLUGIN";
|
|
8200
|
-
var
|
|
8201
|
-
let RangeProtectionService = (
|
|
8303
|
+
var _a15;
|
|
8304
|
+
let RangeProtectionService = (_a15 = class extends Disposable {
|
|
8202
8305
|
constructor(_selectionProtectionRuleModel, _permissionService, _resourceManagerService, _selectionProtectionCache) {
|
|
8203
8306
|
super(), this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._permissionService = _permissionService, this._resourceManagerService = _resourceManagerService, this._selectionProtectionCache = _selectionProtectionCache, this._initSnapshot(), this._initRuleChange();
|
|
8204
8307
|
}
|
|
@@ -8270,7 +8373,7 @@ let RangeProtectionService = (_a18 = class extends Disposable {
|
|
|
8270
8373
|
const instance = new Factor(unitId, subUnitId, rule.permissionId);
|
|
8271
8374
|
instance.value = !1, this._permissionService.addPermissionPoint(instance);
|
|
8272
8375
|
});
|
|
8273
|
-
});
|
|
8376
|
+
}), this._selectionProtectionCache.reBuildCache(unitId, subUnitId);
|
|
8274
8377
|
});
|
|
8275
8378
|
}, "onLoad"),
|
|
8276
8379
|
onUnLoad: /* @__PURE__ */ __name((unitId) => {
|
|
@@ -8279,7 +8382,7 @@ let RangeProtectionService = (_a18 = class extends Disposable {
|
|
|
8279
8382
|
})
|
|
8280
8383
|
);
|
|
8281
8384
|
}
|
|
8282
|
-
}, __name(
|
|
8385
|
+
}, __name(_a15, "RangeProtectionService"), _a15);
|
|
8283
8386
|
RangeProtectionService = __decorateClass$2([
|
|
8284
8387
|
__decorateParam$2(0, Inject(RangeProtectionRuleModel)),
|
|
8285
8388
|
__decorateParam$2(1, Inject(IPermissionService)),
|
|
@@ -8327,8 +8430,8 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
|
|
|
8327
8430
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8328
8431
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8329
8432
|
return kind && result && __defProp$1(target, key, result), result;
|
|
8330
|
-
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"),
|
|
8331
|
-
let WorkbookPermissionService = (
|
|
8433
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a16;
|
|
8434
|
+
let WorkbookPermissionService = (_a16 = class extends Disposable {
|
|
8332
8435
|
constructor(_permissionService, _univerInstanceService, _rangeProtectionRuleModel) {
|
|
8333
8436
|
super(), this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._rangeProtectionRuleModel = _rangeProtectionRuleModel, this._init();
|
|
8334
8437
|
}
|
|
@@ -8363,9 +8466,8 @@ let WorkbookPermissionService = (_a19 = class extends Disposable {
|
|
|
8363
8466
|
});
|
|
8364
8467
|
}));
|
|
8365
8468
|
}
|
|
8366
|
-
}, __name(
|
|
8469
|
+
}, __name(_a16, "WorkbookPermissionService"), _a16);
|
|
8367
8470
|
WorkbookPermissionService = __decorateClass$1([
|
|
8368
|
-
OnLifecycle(LifecycleStages.Starting, WorkbookPermissionService),
|
|
8369
8471
|
__decorateParam$1(0, Inject(IPermissionService)),
|
|
8370
8472
|
__decorateParam$1(1, Inject(IUniverInstanceService)),
|
|
8371
8473
|
__decorateParam$1(2, Inject(RangeProtectionRuleModel))
|
|
@@ -8376,19 +8478,19 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
|
|
|
8376
8478
|
return kind && result && __defProp2(target, key, result), result;
|
|
8377
8479
|
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
|
|
8378
8480
|
const PLUGIN_NAME = "SHEET_PLUGIN";
|
|
8379
|
-
var
|
|
8380
|
-
let UniverSheetsPlugin = (
|
|
8481
|
+
var _a17;
|
|
8482
|
+
let UniverSheetsPlugin = (_a17 = class extends Plugin {
|
|
8381
8483
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
8382
8484
|
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
8383
8485
|
const { ...rest } = this._config;
|
|
8384
8486
|
this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initConfig(), this._initDependencies();
|
|
8385
8487
|
}
|
|
8386
8488
|
_initConfig() {
|
|
8387
|
-
var
|
|
8388
|
-
(
|
|
8489
|
+
var _a18;
|
|
8490
|
+
(_a18 = this._config) != null && _a18.onlyRegisterFormulaRelatedMutations && this._configService.setConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY, !0);
|
|
8389
8491
|
}
|
|
8390
8492
|
_initDependencies() {
|
|
8391
|
-
var
|
|
8493
|
+
var _a18;
|
|
8392
8494
|
const dependencies = [
|
|
8393
8495
|
// services
|
|
8394
8496
|
[BorderStyleManagerService],
|
|
@@ -8417,14 +8519,36 @@ let UniverSheetsPlugin = (_a20 = class extends Plugin {
|
|
|
8417
8519
|
deps: [SheetsSelectionsService]
|
|
8418
8520
|
}]
|
|
8419
8521
|
];
|
|
8420
|
-
(
|
|
8421
|
-
|
|
8422
|
-
|
|
8522
|
+
(_a18 = this._config) != null && _a18.notExecuteFormula || dependencies.push([CalculateResultApplyController]), registerDependencies(this._injector, mergeOverrideWithDependencies(dependencies, this._config.override)), touchDependencies(this._injector, [
|
|
8523
|
+
[SheetInterceptorService],
|
|
8524
|
+
[RangeProtectionService],
|
|
8525
|
+
[IExclusiveRangeService]
|
|
8526
|
+
]);
|
|
8527
|
+
}
|
|
8528
|
+
onStarting() {
|
|
8529
|
+
touchDependencies(this._injector, [
|
|
8530
|
+
[BasicWorksheetController],
|
|
8531
|
+
[MergeCellController],
|
|
8532
|
+
[WorkbookPermissionService],
|
|
8533
|
+
[WorksheetPermissionService]
|
|
8534
|
+
]);
|
|
8535
|
+
}
|
|
8536
|
+
onRendered() {
|
|
8537
|
+
touchDependencies(this._injector, [
|
|
8538
|
+
[INumfmtService]
|
|
8539
|
+
]);
|
|
8423
8540
|
}
|
|
8424
|
-
|
|
8425
|
-
this._injector
|
|
8541
|
+
onReady() {
|
|
8542
|
+
touchDependencies(this._injector, [
|
|
8543
|
+
[CalculateResultApplyController],
|
|
8544
|
+
[DefinedNameDataController],
|
|
8545
|
+
[NumberCellDisplayController],
|
|
8546
|
+
[RangeProtectionRenderModel],
|
|
8547
|
+
[RangeProtectionRefRangeService],
|
|
8548
|
+
[RefRangeService]
|
|
8549
|
+
]);
|
|
8426
8550
|
}
|
|
8427
|
-
}, __name(
|
|
8551
|
+
}, __name(_a17, "UniverSheetsPlugin"), _a17);
|
|
8428
8552
|
__publicField2(UniverSheetsPlugin, "pluginName", PLUGIN_NAME);
|
|
8429
8553
|
__publicField2(UniverSheetsPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
8430
8554
|
UniverSheetsPlugin = __decorateClass([
|
|
@@ -8841,8 +8965,8 @@ const AddWorksheetMergeCommand = {
|
|
|
8841
8965
|
type: CommandType.COMMAND,
|
|
8842
8966
|
id: "sheet.command.add-worksheet-merge-all",
|
|
8843
8967
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
8844
|
-
var
|
|
8845
|
-
const commandService = accessor.get(ICommandService), selections = (
|
|
8968
|
+
var _a18;
|
|
8969
|
+
const commandService = accessor.get(ICommandService), selections = (_a18 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
8846
8970
|
if (!(selections != null && selections.length))
|
|
8847
8971
|
return !1;
|
|
8848
8972
|
const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
@@ -8860,8 +8984,8 @@ const AddWorksheetMergeCommand = {
|
|
|
8860
8984
|
type: CommandType.COMMAND,
|
|
8861
8985
|
id: "sheet.command.add-worksheet-merge-vertical",
|
|
8862
8986
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
8863
|
-
var
|
|
8864
|
-
const commandService = accessor.get(ICommandService), selections = (
|
|
8987
|
+
var _a18;
|
|
8988
|
+
const commandService = accessor.get(ICommandService), selections = (_a18 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
8865
8989
|
if (!(selections != null && selections.length))
|
|
8866
8990
|
return !1;
|
|
8867
8991
|
const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
@@ -8880,8 +9004,8 @@ const AddWorksheetMergeCommand = {
|
|
|
8880
9004
|
type: CommandType.COMMAND,
|
|
8881
9005
|
id: "sheet.command.add-worksheet-merge-horizontal",
|
|
8882
9006
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
8883
|
-
var
|
|
8884
|
-
const commandService = accessor.get(ICommandService), selections = (
|
|
9007
|
+
var _a18;
|
|
9008
|
+
const commandService = accessor.get(ICommandService), selections = (_a18 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a18.map((s) => s.range);
|
|
8885
9009
|
if (!(selections != null && selections.length))
|
|
8886
9010
|
return !1;
|
|
8887
9011
|
const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
@@ -8931,12 +9055,12 @@ const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, pa
|
|
|
8931
9055
|
type: CommandType.COMMAND,
|
|
8932
9056
|
id: "sheet.command.set-hide-gridlines",
|
|
8933
9057
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
8934
|
-
var
|
|
9058
|
+
var _a18;
|
|
8935
9059
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
|
8936
9060
|
if (!target) return !1;
|
|
8937
9061
|
const { unitId, subUnitId } = target;
|
|
8938
9062
|
let hideGridlines = BooleanNumber.FALSE;
|
|
8939
|
-
params && (hideGridlines = (
|
|
9063
|
+
params && (hideGridlines = (_a18 = params.hideGridlines) != null ? _a18 : BooleanNumber.FALSE);
|
|
8940
9064
|
const workbook = univerInstanceService.getUniverSheetInstance(unitId);
|
|
8941
9065
|
if (!workbook || !workbook.getSheetBySheetId(subUnitId)) return !1;
|
|
8942
9066
|
const setHideGridlinesMutationParams = {
|
|
@@ -8971,12 +9095,12 @@ const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, pa
|
|
|
8971
9095
|
type: CommandType.COMMAND,
|
|
8972
9096
|
id: "sheet.command.set-worksheet-right-to-left",
|
|
8973
9097
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
8974
|
-
var
|
|
9098
|
+
var _a18;
|
|
8975
9099
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
|
|
8976
9100
|
if (!target) return !1;
|
|
8977
9101
|
const { unitId, subUnitId } = target;
|
|
8978
9102
|
let rightToLeft = BooleanNumber.FALSE;
|
|
8979
|
-
params && (rightToLeft = (
|
|
9103
|
+
params && (rightToLeft = (_a18 = params.rightToLeft) != null ? _a18 : BooleanNumber.FALSE);
|
|
8980
9104
|
const setWorksheetRightToLeftMutationParams = {
|
|
8981
9105
|
rightToLeft,
|
|
8982
9106
|
unitId,
|