@univerjs/sheets 0.25.1 → 1.0.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/facade.js +199 -264
- package/lib/cjs/index.js +171 -124
- package/lib/es/facade.js +200 -259
- package/lib/es/index.js +374 -321
- package/lib/facade.js +200 -259
- package/lib/index.js +374 -321
- package/lib/types/commands/commands/add-range-protection.command.d.ts +1 -1
- package/lib/types/commands/commands/delete-range-protection.command.d.ts +1 -1
- package/lib/types/commands/commands/register-range-theme.command.d.ts +1 -1
- package/lib/types/commands/commands/set-protection.command.d.ts +1 -1
- package/lib/types/commands/mutations/add-range-protection.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/add-range-theme.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/register-range-theme.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/set-range-protection.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/set-range-theme.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +4 -3
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +1 -1
- package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +1 -1
- package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +1 -1
- package/lib/types/controllers/zebar-crossing.controller.d.ts +1 -1
- package/lib/types/facade/{f-sheet-hooks.d.ts → const.d.ts} +1 -9
- package/lib/types/facade/f-range.d.ts +3 -2
- package/lib/types/facade/f-univer.d.ts +33 -64
- package/lib/types/facade/f-workbook.d.ts +3 -45
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/index.d.ts +186 -106
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +3 -3
- package/lib/types/services/permission/range-permission/range-protection.service.d.ts +2 -2
- package/lib/types/services/permission/type.d.ts +1 -1
- package/lib/types/services/permission/workbook-permission/workbook-permission.service.d.ts +1 -1
- package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +1 -1
- package/lib/types/services/range-theme.service.d.ts +3 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
- /package/lib/types/{model → models}/range-protection-render.model.d.ts +0 -0
- /package/lib/types/{model → models}/range-protection-rule.model.d.ts +0 -0
- /package/lib/types/{model → models}/range-protection.cache.d.ts +0 -0
- /package/lib/types/{model → models}/range-theme-model.d.ts +0 -0
- /package/lib/types/{model → models}/range-theme-util.d.ts +0 -0
- /package/lib/types/{model → models}/range-themes/build-in-theme.factory.d.ts +0 -0
- /package/lib/types/{model → models}/range-themes/default.d.ts +0 -0
- /package/lib/types/{model → models}/zebra-crossing-cache.d.ts +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -159,7 +159,7 @@ const RangeThemeInterceptorId = "sheet.interceptor.range-theme-id";
|
|
|
159
159
|
const IgnoreRangeThemeInterceptorKey = "sheet.interceptor.ignore-range-theme";
|
|
160
160
|
|
|
161
161
|
//#endregion
|
|
162
|
-
//#region \0@oxc-project+runtime@0.
|
|
162
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
163
163
|
function _typeof(o) {
|
|
164
164
|
"@babel/helpers - typeof";
|
|
165
165
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -170,7 +170,7 @@ function _typeof(o) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
//#endregion
|
|
173
|
-
//#region \0@oxc-project+runtime@0.
|
|
173
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
174
174
|
function toPrimitive(t, r) {
|
|
175
175
|
if ("object" != _typeof(t) || !t) return t;
|
|
176
176
|
var e = t[Symbol.toPrimitive];
|
|
@@ -183,14 +183,14 @@ function toPrimitive(t, r) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region \0@oxc-project+runtime@0.
|
|
186
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
187
187
|
function toPropertyKey(t) {
|
|
188
188
|
var i = toPrimitive(t, "string");
|
|
189
189
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
//#endregion
|
|
193
|
-
//#region \0@oxc-project+runtime@0.
|
|
193
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
194
194
|
function _defineProperty(e, r, t) {
|
|
195
195
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
196
196
|
value: t,
|
|
@@ -201,7 +201,7 @@ function _defineProperty(e, r, t) {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
//#endregion
|
|
204
|
-
//#region \0@oxc-project+runtime@0.
|
|
204
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
205
205
|
function __decorateParam(paramIndex, decorator) {
|
|
206
206
|
return function(target, key) {
|
|
207
207
|
decorator(target, key, paramIndex);
|
|
@@ -209,7 +209,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
//#endregion
|
|
212
|
-
//#region \0@oxc-project+runtime@0.
|
|
212
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
213
213
|
function __decorate(decorators, target, key, desc) {
|
|
214
214
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
215
215
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -564,7 +564,7 @@ function getWorksheetDisposableID(unitId, worksheet) {
|
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
//#endregion
|
|
567
|
-
//#region src/
|
|
567
|
+
//#region src/models/range-theme-util.ts
|
|
568
568
|
const serializeRangeStyle = (style) => {
|
|
569
569
|
const result = {};
|
|
570
570
|
if (style.bg) result.bg = { ...style.bg };
|
|
@@ -834,7 +834,7 @@ var RangeThemeStyle = class {
|
|
|
834
834
|
};
|
|
835
835
|
|
|
836
836
|
//#endregion
|
|
837
|
-
//#region src/
|
|
837
|
+
//#region src/models/range-themes/build-in-theme.factory.ts
|
|
838
838
|
/**
|
|
839
839
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
840
840
|
*
|
|
@@ -1062,7 +1062,7 @@ const buildInThemes = [
|
|
|
1062
1062
|
];
|
|
1063
1063
|
|
|
1064
1064
|
//#endregion
|
|
1065
|
-
//#region src/
|
|
1065
|
+
//#region src/models/range-themes/default.ts
|
|
1066
1066
|
const defaultRangeThemeStyleJSON = {
|
|
1067
1067
|
headerRowStyle: {
|
|
1068
1068
|
bg: { rgb: "rgb(68,114,196)" },
|
|
@@ -1086,7 +1086,7 @@ const defaultRangeThemeStyleJSONWithLastRowStyle = new RangeThemeStyle("default-
|
|
|
1086
1086
|
});
|
|
1087
1087
|
|
|
1088
1088
|
//#endregion
|
|
1089
|
-
//#region src/
|
|
1089
|
+
//#region src/models/zebra-crossing-cache.ts
|
|
1090
1090
|
/**
|
|
1091
1091
|
* This class is used for caching zebra crossing toggle ranges.
|
|
1092
1092
|
* `toggleRanges` represents the ranges within the visible area where the original odd/even row state is reversed due to hidden rows.
|
|
@@ -1174,7 +1174,7 @@ var ZebraCrossingCache = class {
|
|
|
1174
1174
|
};
|
|
1175
1175
|
|
|
1176
1176
|
//#endregion
|
|
1177
|
-
//#region src/
|
|
1177
|
+
//#region src/models/range-theme-model.ts
|
|
1178
1178
|
const SHEET_RANGE_THEME_MODEL_PLUGIN = "SHEET_RANGE_THEME_MODEL_PLUGIN";
|
|
1179
1179
|
let SheetRangeThemeModel = class SheetRangeThemeModel extends _univerjs_core.Disposable {
|
|
1180
1180
|
constructor(_sheetInterceptorService, _resourceManagerService, _univerInstanceService) {
|
|
@@ -2342,7 +2342,7 @@ function setNull(value) {
|
|
|
2342
2342
|
* @returns {ISetRangeValuesMutationParams} undo mutation params
|
|
2343
2343
|
*/
|
|
2344
2344
|
const SetRangeValuesUndoMutationFactory = (accessor, params) => {
|
|
2345
|
-
const { unitId, subUnitId, cellValue } = params;
|
|
2345
|
+
const { unitId, subUnitId, cellValue, isOverrideStyle } = params;
|
|
2346
2346
|
const workbook = accessor.get(_univerjs_core.IUniverInstanceService).getUniverSheetInstance(unitId);
|
|
2347
2347
|
if (workbook == null) throw new Error("workbook is null error!");
|
|
2348
2348
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
@@ -2352,12 +2352,13 @@ const SetRangeValuesUndoMutationFactory = (accessor, params) => {
|
|
|
2352
2352
|
const undoData = new _univerjs_core.ObjectMatrix();
|
|
2353
2353
|
new _univerjs_core.ObjectMatrix(cellValue).forValue((row, col, newVal) => {
|
|
2354
2354
|
const cell = _univerjs_core.Tools.deepClone(cellMatrix === null || cellMatrix === void 0 ? void 0 : cellMatrix.getValue(row, col)) || {};
|
|
2355
|
-
|
|
2355
|
+
const oldStyle = styles.getStyleByCell(cell);
|
|
2356
|
+
const newStyle = styles.getStyleByCell(newVal);
|
|
2357
|
+
cell.s = isOverrideStyle && Object.prototype.hasOwnProperty.call(newVal !== null && newVal !== void 0 ? newVal : {}, "s") ? oldStyle !== null && oldStyle !== void 0 ? oldStyle : null : transformStyle(oldStyle, newStyle);
|
|
2356
2358
|
undoData.setValue(row, col, setNull(cell));
|
|
2357
2359
|
});
|
|
2358
2360
|
return {
|
|
2359
2361
|
...params,
|
|
2360
|
-
options: {},
|
|
2361
2362
|
cellValue: undoData.getMatrix()
|
|
2362
2363
|
};
|
|
2363
2364
|
};
|
|
@@ -2365,7 +2366,7 @@ const SetRangeValuesMutation = {
|
|
|
2365
2366
|
id: "sheet.mutation.set-range-values",
|
|
2366
2367
|
type: _univerjs_core.CommandType.MUTATION,
|
|
2367
2368
|
handler: (accessor, params) => {
|
|
2368
|
-
const { cellValue, subUnitId, unitId } = params;
|
|
2369
|
+
const { cellValue, subUnitId, unitId, isOverrideStyle } = params;
|
|
2369
2370
|
const workbook = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId);
|
|
2370
2371
|
if (!workbook) return false;
|
|
2371
2372
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
@@ -2376,7 +2377,7 @@ const SetRangeValuesMutation = {
|
|
|
2376
2377
|
if (!newVal) cellMatrix.realDeleteValue(row, col);
|
|
2377
2378
|
else {
|
|
2378
2379
|
let oldVal = cellMatrix.getValue(row, col) || {};
|
|
2379
|
-
oldVal = mergeCellData(newVal, oldVal, styles);
|
|
2380
|
+
oldVal = mergeCellData(newVal, oldVal, styles, !!isOverrideStyle);
|
|
2380
2381
|
if (_univerjs_core.Tools.isEmptyObject(oldVal)) cellMatrix.realDeleteValue(row, col);
|
|
2381
2382
|
else cellMatrix.setValue(row, col, oldVal);
|
|
2382
2383
|
}
|
|
@@ -2384,7 +2385,7 @@ const SetRangeValuesMutation = {
|
|
|
2384
2385
|
return true;
|
|
2385
2386
|
}
|
|
2386
2387
|
};
|
|
2387
|
-
const overwriteCellPropertiesSet = new Set([
|
|
2388
|
+
const overwriteCellPropertiesSet = /* @__PURE__ */ new Set([
|
|
2388
2389
|
"f",
|
|
2389
2390
|
"p",
|
|
2390
2391
|
"si",
|
|
@@ -2392,7 +2393,7 @@ const overwriteCellPropertiesSet = new Set([
|
|
|
2392
2393
|
"ref",
|
|
2393
2394
|
"xf"
|
|
2394
2395
|
]);
|
|
2395
|
-
function mergeCellData(newValue, oldValue, styles) {
|
|
2396
|
+
function mergeCellData(newValue, oldValue, styles, isOverrideStyle = false) {
|
|
2396
2397
|
const type = getCellType(styles, newValue, oldValue);
|
|
2397
2398
|
Object.keys(newValue).forEach((key) => {
|
|
2398
2399
|
const cellPropertyKey = key;
|
|
@@ -2401,7 +2402,8 @@ function mergeCellData(newValue, oldValue, styles) {
|
|
|
2401
2402
|
updateCellProperty(oldValue, cellPropertyKey, propertyValue);
|
|
2402
2403
|
} else if (cellPropertyKey === "v") {
|
|
2403
2404
|
if (newValue.v !== void 0) oldValue.v = getCellValue(type, newValue);
|
|
2404
|
-
} else if (cellPropertyKey === "s")
|
|
2405
|
+
} else if (cellPropertyKey === "s") if (isOverrideStyle) overrideStyle(styles, oldValue, newValue);
|
|
2406
|
+
else handleStyle(styles, oldValue, newValue);
|
|
2405
2407
|
});
|
|
2406
2408
|
if (oldValue.v !== void 0) {
|
|
2407
2409
|
oldValue.t = type;
|
|
@@ -2413,6 +2415,18 @@ function mergeCellData(newValue, oldValue, styles) {
|
|
|
2413
2415
|
}
|
|
2414
2416
|
return oldValue;
|
|
2415
2417
|
}
|
|
2418
|
+
function overrideStyle(styles, oldValue, newValue) {
|
|
2419
|
+
if (newValue.s === void 0) return;
|
|
2420
|
+
if (newValue.s === null) {
|
|
2421
|
+
delete oldValue.s;
|
|
2422
|
+
return;
|
|
2423
|
+
}
|
|
2424
|
+
const styleValue = typeof newValue.s === "string" ? styles.get(newValue.s) : newValue.s;
|
|
2425
|
+
const styleCell = {};
|
|
2426
|
+
handleStyle(styles, styleCell, { s: styleValue });
|
|
2427
|
+
if (styleCell.s == null) delete oldValue.s;
|
|
2428
|
+
else oldValue.s = styleCell.s;
|
|
2429
|
+
}
|
|
2416
2430
|
function updateCellProperty(cell, key, value) {
|
|
2417
2431
|
if (value === void 0) {} else if (value === null) delete cell[key];
|
|
2418
2432
|
else cell[key] = value;
|
|
@@ -3898,7 +3912,7 @@ function deserializeListOptions(optionsStr) {
|
|
|
3898
3912
|
}
|
|
3899
3913
|
|
|
3900
3914
|
//#endregion
|
|
3901
|
-
//#region src/
|
|
3915
|
+
//#region src/models/range-protection-rule.model.ts
|
|
3902
3916
|
let ViewStateEnum = /* @__PURE__ */ function(ViewStateEnum) {
|
|
3903
3917
|
ViewStateEnum["OthersCanView"] = "othersCanView";
|
|
3904
3918
|
ViewStateEnum["NoOneElseCanView"] = "noOneElseCanView";
|
|
@@ -4045,7 +4059,11 @@ var RangeProtectionRuleModel = class {
|
|
|
4045
4059
|
//#region src/commands/mutations/delete-range-protection.mutation.ts
|
|
4046
4060
|
const FactoryDeleteRangeProtectionMutation = (accessor, param) => {
|
|
4047
4061
|
const selectionProtectionRuleModel = accessor.get(RangeProtectionRuleModel);
|
|
4048
|
-
const rules =
|
|
4062
|
+
const rules = [];
|
|
4063
|
+
for (let i = 0; i < param.ruleIds.length; i++) {
|
|
4064
|
+
const rule = selectionProtectionRuleModel.getRule(param.unitId, param.subUnitId, param.ruleIds[i]);
|
|
4065
|
+
if (rule) rules.push(rule);
|
|
4066
|
+
}
|
|
4049
4067
|
return {
|
|
4050
4068
|
id: AddRangeProtectionMutation.id,
|
|
4051
4069
|
params: {
|
|
@@ -4061,9 +4079,7 @@ const DeleteRangeProtectionMutation = {
|
|
|
4061
4079
|
handler: (accessor, params) => {
|
|
4062
4080
|
const { unitId, subUnitId, ruleIds } = params;
|
|
4063
4081
|
const selectionProtectionRuleModel = accessor.get(RangeProtectionRuleModel);
|
|
4064
|
-
ruleIds.
|
|
4065
|
-
selectionProtectionRuleModel.deleteRule(unitId, subUnitId, id);
|
|
4066
|
-
});
|
|
4082
|
+
for (let i = 0; i < ruleIds.length; i++) selectionProtectionRuleModel.deleteRule(unitId, subUnitId, ruleIds[i]);
|
|
4067
4083
|
return true;
|
|
4068
4084
|
}
|
|
4069
4085
|
};
|
|
@@ -4624,12 +4640,13 @@ SheetSkeletonService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)
|
|
|
4624
4640
|
//#region src/commands/commands/util.ts
|
|
4625
4641
|
function getRangesHeight(ranges, worksheet) {
|
|
4626
4642
|
const cellHeights = new _univerjs_core.ObjectMatrix();
|
|
4627
|
-
|
|
4643
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
4644
|
+
const range = _univerjs_core.Range.transformRange(ranges[i], worksheet);
|
|
4628
4645
|
_univerjs_core.Range.foreach(range, (row, col) => {
|
|
4629
4646
|
const cellHeight = worksheet.getCellHeight(row, col);
|
|
4630
4647
|
if (cellHeight) cellHeights.setValue(row, col, cellHeight);
|
|
4631
4648
|
});
|
|
4632
|
-
}
|
|
4649
|
+
}
|
|
4633
4650
|
return cellHeights;
|
|
4634
4651
|
}
|
|
4635
4652
|
const MAX_RANGE_CELL_COUNT = 1e4;
|
|
@@ -8434,7 +8451,7 @@ let RefRangeService = class RefRangeService extends _univerjs_core.Disposable {
|
|
|
8434
8451
|
}
|
|
8435
8452
|
const refRangeCallbackList = manager.get(rangeString);
|
|
8436
8453
|
if (refRangeCallbackList) refRangeCallbackList.add(callback);
|
|
8437
|
-
else manager.set(rangeString, new Set([callback]));
|
|
8454
|
+
else manager.set(rangeString, /* @__PURE__ */ new Set([callback]));
|
|
8438
8455
|
return (0, _univerjs_core.toDisposable)(() => {
|
|
8439
8456
|
const refRangeCallbackList = manager.get(rangeString);
|
|
8440
8457
|
if (refRangeCallbackList) {
|
|
@@ -13613,15 +13630,14 @@ const SetSelectedColsVisibleCommand = {
|
|
|
13613
13630
|
type: _univerjs_core.CommandType.COMMAND,
|
|
13614
13631
|
id: "sheet.command.set-selected-cols-visible",
|
|
13615
13632
|
handler: (accessor) => {
|
|
13616
|
-
var _selectionManagerServ;
|
|
13617
13633
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
13618
13634
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
13619
|
-
const ranges = (
|
|
13620
|
-
if (!
|
|
13635
|
+
const ranges = getSelectedColRanges(selectionManagerService);
|
|
13636
|
+
if (!ranges.length) return false;
|
|
13621
13637
|
const target = getSheetCommandTarget(accessor.get(_univerjs_core.IUniverInstanceService));
|
|
13622
13638
|
if (!target) return false;
|
|
13623
13639
|
const { worksheet, unitId, subUnitId } = target;
|
|
13624
|
-
const hiddenRanges =
|
|
13640
|
+
const hiddenRanges = getHiddenColRanges(worksheet, ranges);
|
|
13625
13641
|
return commandService.executeCommand(SetSpecificColsVisibleCommand.id, {
|
|
13626
13642
|
unitId,
|
|
13627
13643
|
subUnitId,
|
|
@@ -13633,13 +13649,13 @@ const SetColHiddenCommand = {
|
|
|
13633
13649
|
type: _univerjs_core.CommandType.COMMAND,
|
|
13634
13650
|
id: "sheet.command.set-col-hidden",
|
|
13635
13651
|
handler: (accessor, params) => {
|
|
13636
|
-
var _params$ranges
|
|
13652
|
+
var _params$ranges;
|
|
13637
13653
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
13638
13654
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
13639
13655
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
13640
13656
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
13641
|
-
let ranges = (params === null || params === void 0 || (_params$ranges = params.ranges) === null || _params$ranges === void 0 ? void 0 : _params$ranges.length) ? params.ranges : (
|
|
13642
|
-
if (!
|
|
13657
|
+
let ranges = (params === null || params === void 0 || (_params$ranges = params.ranges) === null || _params$ranges === void 0 ? void 0 : _params$ranges.length) ? params.ranges : getSelectedColRanges(selectionManagerService);
|
|
13658
|
+
if (!ranges.length) return false;
|
|
13643
13659
|
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
13644
13660
|
if (!target) return false;
|
|
13645
13661
|
const { worksheet, unitId, subUnitId } = target;
|
|
@@ -13721,6 +13737,24 @@ const SetColHiddenCommand = {
|
|
|
13721
13737
|
return false;
|
|
13722
13738
|
}
|
|
13723
13739
|
};
|
|
13740
|
+
function getSelectedColRanges(selectionManagerService) {
|
|
13741
|
+
const selections = selectionManagerService.getCurrentSelections();
|
|
13742
|
+
const ranges = [];
|
|
13743
|
+
if (!selections) return ranges;
|
|
13744
|
+
for (let i = 0; i < selections.length; i++) {
|
|
13745
|
+
const range = selections[i].range;
|
|
13746
|
+
if (range.rangeType === _univerjs_core.RANGE_TYPE.COLUMN) ranges.push(range);
|
|
13747
|
+
}
|
|
13748
|
+
return ranges;
|
|
13749
|
+
}
|
|
13750
|
+
function getHiddenColRanges(worksheet, ranges) {
|
|
13751
|
+
const hiddenRanges = [];
|
|
13752
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
13753
|
+
const hiddenCols = worksheet.getHiddenCols(ranges[i].startColumn, ranges[i].endColumn);
|
|
13754
|
+
for (let j = 0; j < hiddenCols.length; j++) hiddenRanges.push(hiddenCols[j]);
|
|
13755
|
+
}
|
|
13756
|
+
return hiddenRanges;
|
|
13757
|
+
}
|
|
13724
13758
|
function divideRangesByHiddenCols(worksheet, ranges) {
|
|
13725
13759
|
const endRow = worksheet.getRowCount() - 1;
|
|
13726
13760
|
const hiddenCols = worksheet.getHiddenCols();
|
|
@@ -14328,16 +14362,15 @@ const SetSelectedRowsVisibleCommand = {
|
|
|
14328
14362
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14329
14363
|
id: "sheet.command.set-selected-rows-visible",
|
|
14330
14364
|
handler: async (accessor) => {
|
|
14331
|
-
var _selectionManagerServ;
|
|
14332
14365
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
14333
14366
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
14334
14367
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
14335
|
-
const ranges = (
|
|
14336
|
-
if (!
|
|
14368
|
+
const ranges = getSelectedRowRanges(selectionManagerService);
|
|
14369
|
+
if (!ranges.length) return false;
|
|
14337
14370
|
const target = getSheetCommandTarget(univerInstanceService);
|
|
14338
14371
|
if (!target) return false;
|
|
14339
14372
|
const { worksheet, unitId, subUnitId } = target;
|
|
14340
|
-
const hiddenRanges =
|
|
14373
|
+
const hiddenRanges = getHiddenRowRanges(worksheet, ranges);
|
|
14341
14374
|
return commandService.executeCommand(SetSpecificRowsVisibleCommand.id, {
|
|
14342
14375
|
unitId,
|
|
14343
14376
|
subUnitId,
|
|
@@ -14349,14 +14382,14 @@ const SetRowHiddenCommand = {
|
|
|
14349
14382
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14350
14383
|
id: "sheet.command.set-rows-hidden",
|
|
14351
14384
|
handler: (accessor, params) => {
|
|
14352
|
-
var _params$ranges,
|
|
14385
|
+
var _params$ranges, _intercepted$preRedos2;
|
|
14353
14386
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
14354
14387
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
14355
14388
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
14356
14389
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
14357
14390
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
14358
|
-
let ranges = (params === null || params === void 0 || (_params$ranges = params.ranges) === null || _params$ranges === void 0 ? void 0 : _params$ranges.length) ? params.ranges : (
|
|
14359
|
-
if (!
|
|
14391
|
+
let ranges = (params === null || params === void 0 || (_params$ranges = params.ranges) === null || _params$ranges === void 0 ? void 0 : _params$ranges.length) ? params.ranges : getSelectedRowRanges(selectionManagerService);
|
|
14392
|
+
if (!ranges.length) return false;
|
|
14360
14393
|
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
14361
14394
|
if (!target) return false;
|
|
14362
14395
|
ranges = divideRangesByHiddenRows(target.worksheet, ranges);
|
|
@@ -14442,6 +14475,24 @@ const SetRowHiddenCommand = {
|
|
|
14442
14475
|
return true;
|
|
14443
14476
|
}
|
|
14444
14477
|
};
|
|
14478
|
+
function getSelectedRowRanges(selectionManagerService) {
|
|
14479
|
+
const selections = selectionManagerService.getCurrentSelections();
|
|
14480
|
+
const ranges = [];
|
|
14481
|
+
if (!selections) return ranges;
|
|
14482
|
+
for (let i = 0; i < selections.length; i++) {
|
|
14483
|
+
const range = selections[i].range;
|
|
14484
|
+
if (range.rangeType === _univerjs_core.RANGE_TYPE.ROW) ranges.push(range);
|
|
14485
|
+
}
|
|
14486
|
+
return ranges;
|
|
14487
|
+
}
|
|
14488
|
+
function getHiddenRowRanges(worksheet, ranges) {
|
|
14489
|
+
const hiddenRanges = [];
|
|
14490
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
14491
|
+
const hiddenRows = worksheet.getHiddenRows(ranges[i].startRow, ranges[i].endRow);
|
|
14492
|
+
for (let j = 0; j < hiddenRows.length; j++) hiddenRanges.push(hiddenRows[j]);
|
|
14493
|
+
}
|
|
14494
|
+
return hiddenRanges;
|
|
14495
|
+
}
|
|
14445
14496
|
function divideRangesByHiddenRows(worksheet, ranges) {
|
|
14446
14497
|
const endCol = worksheet.getMaxColumns() - 1;
|
|
14447
14498
|
const hiddenRows = worksheet.getHiddenRows();
|
|
@@ -17618,6 +17669,70 @@ AutoFillController = __decorate([
|
|
|
17618
17669
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
17619
17670
|
], AutoFillController);
|
|
17620
17671
|
|
|
17672
|
+
//#endregion
|
|
17673
|
+
//#region src/controllers/calculate-result-apply.controller.ts
|
|
17674
|
+
let CalculateResultApplyController = class CalculateResultApplyController extends _univerjs_core.Disposable {
|
|
17675
|
+
constructor(_univerInstanceService, _commandService) {
|
|
17676
|
+
super();
|
|
17677
|
+
this._univerInstanceService = _univerInstanceService;
|
|
17678
|
+
this._commandService = _commandService;
|
|
17679
|
+
this._initialize();
|
|
17680
|
+
}
|
|
17681
|
+
_initialize() {
|
|
17682
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
17683
|
+
if (command.id !== _univerjs_engine_formula.SetFormulaCalculationResultMutation.id) return;
|
|
17684
|
+
const { unitData } = command.params;
|
|
17685
|
+
const unitIds = Object.keys(unitData);
|
|
17686
|
+
const redoMutationsInfo = [];
|
|
17687
|
+
for (let i = 0; i < unitIds.length; i++) {
|
|
17688
|
+
const unitId = unitIds[i];
|
|
17689
|
+
const sheetData = unitData[unitId];
|
|
17690
|
+
if (sheetData == null) continue;
|
|
17691
|
+
const sheetIds = Object.keys(sheetData);
|
|
17692
|
+
for (let j = 0; j < sheetIds.length; j++) {
|
|
17693
|
+
const sheetId = sheetIds[j];
|
|
17694
|
+
const cellData = sheetData[sheetId];
|
|
17695
|
+
if (cellData == null) continue;
|
|
17696
|
+
const setRangeValuesMutation = {
|
|
17697
|
+
subUnitId: sheetId,
|
|
17698
|
+
unitId,
|
|
17699
|
+
cellValue: this._getMergedCellData(unitId, sheetId, cellData)
|
|
17700
|
+
};
|
|
17701
|
+
redoMutationsInfo.push({
|
|
17702
|
+
id: SetRangeValuesMutation.id,
|
|
17703
|
+
params: setRangeValuesMutation
|
|
17704
|
+
});
|
|
17705
|
+
}
|
|
17706
|
+
}
|
|
17707
|
+
return (0, _univerjs_core.sequenceExecute)(redoMutationsInfo, this._commandService, {
|
|
17708
|
+
onlyLocal: true,
|
|
17709
|
+
fromFormula: true,
|
|
17710
|
+
applyFormulaCalculationResult: true
|
|
17711
|
+
});
|
|
17712
|
+
}));
|
|
17713
|
+
}
|
|
17714
|
+
/**
|
|
17715
|
+
* Priority that mainly deals with number format in unitData
|
|
17716
|
+
* @param unitId
|
|
17717
|
+
* @param sheetId
|
|
17718
|
+
* @param cellData
|
|
17719
|
+
* @returns
|
|
17720
|
+
*/
|
|
17721
|
+
_getMergedCellData(unitId, sheetId, cellData) {
|
|
17722
|
+
const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
17723
|
+
const styles = workbook === null || workbook === void 0 ? void 0 : workbook.getStyles();
|
|
17724
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
17725
|
+
const oldCellDataMatrix = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellMatrix();
|
|
17726
|
+
const cellDataMatrix = new _univerjs_core.ObjectMatrix(cellData);
|
|
17727
|
+
cellDataMatrix.forValue((row, col, cell) => {
|
|
17728
|
+
const newCell = (0, _univerjs_engine_formula.handleNumfmtInCell)(oldCellDataMatrix === null || oldCellDataMatrix === void 0 ? void 0 : oldCellDataMatrix.getValue(row, col), cell, styles);
|
|
17729
|
+
cellDataMatrix.setValue(row, col, newCell);
|
|
17730
|
+
});
|
|
17731
|
+
return cellDataMatrix.getMatrix();
|
|
17732
|
+
}
|
|
17733
|
+
};
|
|
17734
|
+
CalculateResultApplyController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)), __decorateParam(1, _univerjs_core.ICommandService)], CalculateResultApplyController);
|
|
17735
|
+
|
|
17621
17736
|
//#endregion
|
|
17622
17737
|
//#region src/controllers/config/config.ts
|
|
17623
17738
|
/**
|
|
@@ -18877,7 +18992,7 @@ ZebraCrossingCacheController = __decorate([
|
|
|
18877
18992
|
], ZebraCrossingCacheController);
|
|
18878
18993
|
|
|
18879
18994
|
//#endregion
|
|
18880
|
-
//#region src/
|
|
18995
|
+
//#region src/models/range-protection-render.model.ts
|
|
18881
18996
|
let RangeProtectionRenderModel = class RangeProtectionRenderModel {
|
|
18882
18997
|
constructor(_selectionProtectionRuleModel, _permissionService) {
|
|
18883
18998
|
this._selectionProtectionRuleModel = _selectionProtectionRuleModel;
|
|
@@ -18948,7 +19063,7 @@ let RangeProtectionRenderModel = class RangeProtectionRenderModel {
|
|
|
18948
19063
|
RangeProtectionRenderModel = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(RangeProtectionRuleModel)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IPermissionService))], RangeProtectionRenderModel);
|
|
18949
19064
|
|
|
18950
19065
|
//#endregion
|
|
18951
|
-
//#region src/
|
|
19066
|
+
//#region src/models/range-protection.cache.ts
|
|
18952
19067
|
let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Disposable {
|
|
18953
19068
|
constructor(_ruleModel, _permissionService, _univerInstanceService) {
|
|
18954
19069
|
super();
|
|
@@ -19113,13 +19228,13 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
19113
19228
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
19114
19229
|
for (let i = startRow; i <= endRow; i++) {
|
|
19115
19230
|
const rowInfo = rowInfoMap.get(`${i}`);
|
|
19116
|
-
if (!rowInfo) rowInfoMap.set(`${i}`, new Map([[rule.id, selectionActions]]));
|
|
19231
|
+
if (!rowInfo) rowInfoMap.set(`${i}`, /* @__PURE__ */ new Map([[rule.id, selectionActions]]));
|
|
19117
19232
|
else rowInfo.set(rule.id, selectionActions);
|
|
19118
19233
|
for (let j = startColumn; j <= endColumn; j++) {
|
|
19119
19234
|
cellRuleMap.set(`${i}-${j}`, rule.id);
|
|
19120
19235
|
cellInfoMap.set(`${i}-${j}`, selectionProtection);
|
|
19121
19236
|
const colInfo = colInfoMap.get(`${j}`);
|
|
19122
|
-
if (!colInfo) colInfoMap.set(`${j}`, new Map([[rule.id, selectionActions]]));
|
|
19237
|
+
if (!colInfo) colInfoMap.set(`${j}`, /* @__PURE__ */ new Map([[rule.id, selectionActions]]));
|
|
19123
19238
|
else colInfo.set(rule.id, selectionActions);
|
|
19124
19239
|
}
|
|
19125
19240
|
}
|
|
@@ -19163,11 +19278,11 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
19163
19278
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
19164
19279
|
for (let i = startRow; i <= endRow; i++) {
|
|
19165
19280
|
const rowInfo = rowInfoMap.get(`${i}`);
|
|
19166
|
-
if (!rowInfo) rowInfoMap.set(`${i}`, new Map([[ruleId, selectionActions]]));
|
|
19281
|
+
if (!rowInfo) rowInfoMap.set(`${i}`, /* @__PURE__ */ new Map([[ruleId, selectionActions]]));
|
|
19167
19282
|
else rowInfo.set(ruleId, selectionActions);
|
|
19168
19283
|
for (let j = startColumn; j <= endColumn; j++) {
|
|
19169
19284
|
const colInfo = colInfoMap.get(`${j}`);
|
|
19170
|
-
if (!colInfo) colInfoMap.set(`${j}`, new Map([[ruleId, selectionActions]]));
|
|
19285
|
+
if (!colInfo) colInfoMap.set(`${j}`, /* @__PURE__ */ new Map([[ruleId, selectionActions]]));
|
|
19171
19286
|
else colInfo.set(ruleId, selectionActions);
|
|
19172
19287
|
}
|
|
19173
19288
|
}
|
|
@@ -19233,7 +19348,7 @@ RangeProtectionCache = __decorate([
|
|
|
19233
19348
|
//#endregion
|
|
19234
19349
|
//#region package.json
|
|
19235
19350
|
var name = "@univerjs/sheets";
|
|
19236
|
-
var version = "0.
|
|
19351
|
+
var version = "1.0.0-alpha.1";
|
|
19237
19352
|
|
|
19238
19353
|
//#endregion
|
|
19239
19354
|
//#region src/controllers/active-worksheet.controller.ts
|
|
@@ -19527,70 +19642,6 @@ BasicWorksheetController = __decorate([
|
|
|
19527
19642
|
__decorateParam(2, (0, _univerjs_core.Optional)(_univerjs_rpc.DataSyncPrimaryController))
|
|
19528
19643
|
], BasicWorksheetController);
|
|
19529
19644
|
|
|
19530
|
-
//#endregion
|
|
19531
|
-
//#region src/controllers/calculate-result-apply.controller.ts
|
|
19532
|
-
let CalculateResultApplyController = class CalculateResultApplyController extends _univerjs_core.Disposable {
|
|
19533
|
-
constructor(_univerInstanceService, _commandService) {
|
|
19534
|
-
super();
|
|
19535
|
-
this._univerInstanceService = _univerInstanceService;
|
|
19536
|
-
this._commandService = _commandService;
|
|
19537
|
-
this._initialize();
|
|
19538
|
-
}
|
|
19539
|
-
_initialize() {
|
|
19540
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
19541
|
-
if (command.id !== _univerjs_engine_formula.SetFormulaCalculationResultMutation.id) return;
|
|
19542
|
-
const { unitData } = command.params;
|
|
19543
|
-
const unitIds = Object.keys(unitData);
|
|
19544
|
-
const redoMutationsInfo = [];
|
|
19545
|
-
for (let i = 0; i < unitIds.length; i++) {
|
|
19546
|
-
const unitId = unitIds[i];
|
|
19547
|
-
const sheetData = unitData[unitId];
|
|
19548
|
-
if (sheetData == null) continue;
|
|
19549
|
-
const sheetIds = Object.keys(sheetData);
|
|
19550
|
-
for (let j = 0; j < sheetIds.length; j++) {
|
|
19551
|
-
const sheetId = sheetIds[j];
|
|
19552
|
-
const cellData = sheetData[sheetId];
|
|
19553
|
-
if (cellData == null) continue;
|
|
19554
|
-
const setRangeValuesMutation = {
|
|
19555
|
-
subUnitId: sheetId,
|
|
19556
|
-
unitId,
|
|
19557
|
-
cellValue: this._getMergedCellData(unitId, sheetId, cellData)
|
|
19558
|
-
};
|
|
19559
|
-
redoMutationsInfo.push({
|
|
19560
|
-
id: SetRangeValuesMutation.id,
|
|
19561
|
-
params: setRangeValuesMutation
|
|
19562
|
-
});
|
|
19563
|
-
}
|
|
19564
|
-
}
|
|
19565
|
-
return (0, _univerjs_core.sequenceExecute)(redoMutationsInfo, this._commandService, {
|
|
19566
|
-
onlyLocal: true,
|
|
19567
|
-
fromFormula: true,
|
|
19568
|
-
applyFormulaCalculationResult: true
|
|
19569
|
-
});
|
|
19570
|
-
}));
|
|
19571
|
-
}
|
|
19572
|
-
/**
|
|
19573
|
-
* Priority that mainly deals with number format in unitData
|
|
19574
|
-
* @param unitId
|
|
19575
|
-
* @param sheetId
|
|
19576
|
-
* @param cellData
|
|
19577
|
-
* @returns
|
|
19578
|
-
*/
|
|
19579
|
-
_getMergedCellData(unitId, sheetId, cellData) {
|
|
19580
|
-
const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
19581
|
-
const styles = workbook === null || workbook === void 0 ? void 0 : workbook.getStyles();
|
|
19582
|
-
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
19583
|
-
const oldCellDataMatrix = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellMatrix();
|
|
19584
|
-
const cellDataMatrix = new _univerjs_core.ObjectMatrix(cellData);
|
|
19585
|
-
cellDataMatrix.forValue((row, col, cell) => {
|
|
19586
|
-
const newCell = (0, _univerjs_engine_formula.handleNumfmtInCell)(oldCellDataMatrix === null || oldCellDataMatrix === void 0 ? void 0 : oldCellDataMatrix.getValue(row, col), cell, styles);
|
|
19587
|
-
cellDataMatrix.setValue(row, col, newCell);
|
|
19588
|
-
});
|
|
19589
|
-
return cellDataMatrix.getMatrix();
|
|
19590
|
-
}
|
|
19591
|
-
};
|
|
19592
|
-
CalculateResultApplyController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)), __decorateParam(1, _univerjs_core.ICommandService)], CalculateResultApplyController);
|
|
19593
|
-
|
|
19594
19645
|
//#endregion
|
|
19595
19646
|
//#region src/controllers/number-cell.controller.ts
|
|
19596
19647
|
/**
|
|
@@ -19629,6 +19680,8 @@ let NumberCellDisplayController = class NumberCellDisplayController extends _uni
|
|
|
19629
19680
|
if ((cell === null || cell === void 0 ? void 0 : cell.t) === _univerjs_core.CellValueType.NUMBER && cell.v !== void 0 && cell.v !== null && (0, _univerjs_core.isRealNum)(cell.v)) {
|
|
19630
19681
|
if (!cell || cell === location.rawData) cell = { ...location.rawData };
|
|
19631
19682
|
cell.v = (0, _univerjs_engine_formula.stripErrorMargin)(Number(cell.v));
|
|
19683
|
+
const text = String(cell.v);
|
|
19684
|
+
if (text.includes("e")) cell.v = text.toUpperCase();
|
|
19632
19685
|
return next(cell);
|
|
19633
19686
|
}
|
|
19634
19687
|
return next(cell);
|
|
@@ -21266,6 +21319,12 @@ exports.BEFORE_CELL_EDIT = BEFORE_CELL_EDIT;
|
|
|
21266
21319
|
exports.BorderStyleManagerService = BorderStyleManagerService;
|
|
21267
21320
|
exports.COMMAND_LISTENER_SKELETON_CHANGE = COMMAND_LISTENER_SKELETON_CHANGE;
|
|
21268
21321
|
exports.COMMAND_LISTENER_VALUE_CHANGE = COMMAND_LISTENER_VALUE_CHANGE;
|
|
21322
|
+
Object.defineProperty(exports, 'CalculateResultApplyController', {
|
|
21323
|
+
enumerable: true,
|
|
21324
|
+
get: function () {
|
|
21325
|
+
return CalculateResultApplyController;
|
|
21326
|
+
}
|
|
21327
|
+
});
|
|
21269
21328
|
exports.CancelFrozenCommand = CancelFrozenCommand;
|
|
21270
21329
|
exports.CancelMarkDirtyRowAutoHeightOperation = CancelMarkDirtyRowAutoHeightOperation;
|
|
21271
21330
|
exports.ClearSelectionAllCommand = ClearSelectionAllCommand;
|
|
@@ -21583,18 +21642,6 @@ exports.TextToNumberCommand = TextToNumberCommand;
|
|
|
21583
21642
|
exports.ToggleCellCheckboxCommand = ToggleCellCheckboxCommand;
|
|
21584
21643
|
exports.ToggleGridlinesCommand = ToggleGridlinesCommand;
|
|
21585
21644
|
exports.ToggleGridlinesMutation = ToggleGridlinesMutation;
|
|
21586
|
-
Object.defineProperty(exports, 'UnitAction', {
|
|
21587
|
-
enumerable: true,
|
|
21588
|
-
get: function () {
|
|
21589
|
-
return _univerjs_protocol.UnitAction;
|
|
21590
|
-
}
|
|
21591
|
-
});
|
|
21592
|
-
Object.defineProperty(exports, 'UnitObject', {
|
|
21593
|
-
enumerable: true,
|
|
21594
|
-
get: function () {
|
|
21595
|
-
return _univerjs_protocol.UnitObject;
|
|
21596
|
-
}
|
|
21597
|
-
});
|
|
21598
21645
|
Object.defineProperty(exports, 'UniverSheetsPlugin', {
|
|
21599
21646
|
enumerable: true,
|
|
21600
21647
|
get: function () {
|