@odoo/o-spreadsheet 16.3.16 → 16.3.18
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/dist/o-spreadsheet.cjs.js +124 -82
- package/dist/o-spreadsheet.d.ts +9 -15
- package/dist/o-spreadsheet.esm.js +124 -82
- package/dist/o-spreadsheet.iife.js +124 -82
- package/dist/o-spreadsheet.iife.min.js +253 -253
- package/dist/o_spreadsheet.xml +6 -7
- package/package.json +1 -1
|
@@ -1022,6 +1022,22 @@ function lazy(fn) {
|
|
|
1022
1022
|
lazyValue.map = (callback) => lazy(() => callback(lazyValue()));
|
|
1023
1023
|
return lazyValue;
|
|
1024
1024
|
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Creates a version of the function that's memoized on the value of its first
|
|
1027
|
+
* argument, if any.
|
|
1028
|
+
*/
|
|
1029
|
+
function memoize(func) {
|
|
1030
|
+
const cache = new Map();
|
|
1031
|
+
const funcName = func.name ? func.name + " (memoized)" : "memoized";
|
|
1032
|
+
return {
|
|
1033
|
+
[funcName](...args) {
|
|
1034
|
+
if (!cache.has(args[0])) {
|
|
1035
|
+
cache.set(args[0], func(...args));
|
|
1036
|
+
}
|
|
1037
|
+
return cache.get(args[0]);
|
|
1038
|
+
},
|
|
1039
|
+
}[funcName];
|
|
1040
|
+
}
|
|
1025
1041
|
/**
|
|
1026
1042
|
* Find the next defined value after the given index in an array of strings. If there is no defined value
|
|
1027
1043
|
* after the index, return the closest defined value before the index. Return an empty string if no
|
|
@@ -3694,12 +3710,12 @@ function toString(value) {
|
|
|
3694
3710
|
}
|
|
3695
3711
|
}
|
|
3696
3712
|
/** Normalize string by setting it to lowercase and replacing accent letters with plain letters */
|
|
3697
|
-
function normalizeString(str) {
|
|
3713
|
+
const normalizeString = memoize(function normalizeString(str) {
|
|
3698
3714
|
return str
|
|
3699
3715
|
.toLowerCase()
|
|
3700
3716
|
.normalize("NFD")
|
|
3701
3717
|
.replace(/[\u0300-\u036f]/g, "");
|
|
3702
|
-
}
|
|
3718
|
+
});
|
|
3703
3719
|
/**
|
|
3704
3720
|
* Normalize a value.
|
|
3705
3721
|
* If the cell value is a string, this will set it to lowercase and replacing accent letters with plain letters
|
|
@@ -4430,6 +4446,7 @@ exports.CommandResult = void 0;
|
|
|
4430
4446
|
CommandResult[CommandResult["SplitWillOverwriteContent"] = 90] = "SplitWillOverwriteContent";
|
|
4431
4447
|
CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 91] = "NoSplitSeparatorInSelection";
|
|
4432
4448
|
CommandResult[CommandResult["NoActiveSheet"] = 92] = "NoActiveSheet";
|
|
4449
|
+
CommandResult[CommandResult["NoChanges"] = 93] = "NoChanges";
|
|
4433
4450
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
4434
4451
|
|
|
4435
4452
|
const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
|
|
@@ -9388,6 +9405,17 @@ const SORT_CELLS_DESCENDING = (env) => {
|
|
|
9388
9405
|
};
|
|
9389
9406
|
const IS_ONLY_ONE_RANGE = (env) => {
|
|
9390
9407
|
return env.model.getters.getSelectedZones().length === 1;
|
|
9408
|
+
};
|
|
9409
|
+
const CAN_INSERT_HEADER = (env, dimension) => {
|
|
9410
|
+
if (!IS_ONLY_ONE_RANGE(env)) {
|
|
9411
|
+
return false;
|
|
9412
|
+
}
|
|
9413
|
+
const activeHeaders = dimension === "COL" ? env.model.getters.getActiveCols() : env.model.getters.getActiveRows();
|
|
9414
|
+
const ortogonalActiveHeaders = dimension === "COL" ? env.model.getters.getActiveRows() : env.model.getters.getActiveCols();
|
|
9415
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
9416
|
+
const zone = env.model.getters.getSelectedZone();
|
|
9417
|
+
const allSheetSelected = isEqual(zone, env.model.getters.getSheetZone(sheetId));
|
|
9418
|
+
return isConsecutive(activeHeaders) && (ortogonalActiveHeaders.size === 0 || allSheetSelected);
|
|
9391
9419
|
};
|
|
9392
9420
|
|
|
9393
9421
|
const undo = {
|
|
@@ -16322,17 +16350,13 @@ for (let category of categories) {
|
|
|
16322
16350
|
|
|
16323
16351
|
const insertRow = {
|
|
16324
16352
|
name: MENU_INSERT_ROWS_NAME,
|
|
16325
|
-
isVisible: (env) =>
|
|
16326
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
16327
|
-
env.model.getters.getActiveCols().size === 0,
|
|
16353
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
|
|
16328
16354
|
icon: "o-spreadsheet-Icon.INSERT_ROW",
|
|
16329
16355
|
};
|
|
16330
16356
|
const rowInsertRowBefore = {
|
|
16331
16357
|
name: ROW_INSERT_ROWS_BEFORE_NAME,
|
|
16332
16358
|
execute: INSERT_ROWS_BEFORE_ACTION,
|
|
16333
|
-
isVisible: (env) =>
|
|
16334
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
16335
|
-
env.model.getters.getActiveCols().size === 0,
|
|
16359
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
|
|
16336
16360
|
icon: "o-spreadsheet-Icon.INSERT_ROW_BEFORE",
|
|
16337
16361
|
};
|
|
16338
16362
|
const topBarInsertRowsBefore = {
|
|
@@ -16348,9 +16372,7 @@ const cellInsertRowsBefore = {
|
|
|
16348
16372
|
const rowInsertRowsAfter = {
|
|
16349
16373
|
execute: INSERT_ROWS_AFTER_ACTION,
|
|
16350
16374
|
name: ROW_INSERT_ROWS_AFTER_NAME,
|
|
16351
|
-
isVisible: (env) =>
|
|
16352
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
16353
|
-
env.model.getters.getActiveCols().size === 0,
|
|
16375
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "ROW"),
|
|
16354
16376
|
icon: "o-spreadsheet-Icon.INSERT_ROW_AFTER",
|
|
16355
16377
|
};
|
|
16356
16378
|
const topBarInsertRowsAfter = {
|
|
@@ -16359,17 +16381,13 @@ const topBarInsertRowsAfter = {
|
|
|
16359
16381
|
};
|
|
16360
16382
|
const insertCol = {
|
|
16361
16383
|
name: MENU_INSERT_COLUMNS_NAME,
|
|
16362
|
-
isVisible: (env) =>
|
|
16363
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
16364
|
-
env.model.getters.getActiveRows().size === 0,
|
|
16384
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
|
|
16365
16385
|
icon: "o-spreadsheet-Icon.INSERT_COL",
|
|
16366
16386
|
};
|
|
16367
16387
|
const colInsertColsBefore = {
|
|
16368
16388
|
name: COLUMN_INSERT_COLUMNS_BEFORE_NAME,
|
|
16369
16389
|
execute: INSERT_COLUMNS_BEFORE_ACTION,
|
|
16370
|
-
isVisible: (env) =>
|
|
16371
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
16372
|
-
env.model.getters.getActiveRows().size === 0,
|
|
16390
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
|
|
16373
16391
|
icon: "o-spreadsheet-Icon.INSERT_COL_BEFORE",
|
|
16374
16392
|
};
|
|
16375
16393
|
const topBarInsertColsBefore = {
|
|
@@ -16385,9 +16403,7 @@ const cellInsertColsBefore = {
|
|
|
16385
16403
|
const colInsertColsAfter = {
|
|
16386
16404
|
name: COLUMN_INSERT_COLUMNS_AFTER_NAME,
|
|
16387
16405
|
execute: INSERT_COLUMNS_AFTER_ACTION,
|
|
16388
|
-
isVisible: (env) =>
|
|
16389
|
-
IS_ONLY_ONE_RANGE(env) &&
|
|
16390
|
-
env.model.getters.getActiveRows().size === 0,
|
|
16406
|
+
isVisible: (env) => CAN_INSERT_HEADER(env, "COL"),
|
|
16391
16407
|
icon: "o-spreadsheet-Icon.INSERT_COL_AFTER",
|
|
16392
16408
|
};
|
|
16393
16409
|
const topBarInsertColsAfter = {
|
|
@@ -19714,7 +19730,7 @@ css /* scss */ `
|
|
|
19714
19730
|
}
|
|
19715
19731
|
.o-input-count {
|
|
19716
19732
|
width: fit-content;
|
|
19717
|
-
padding:
|
|
19733
|
+
padding: 4px 0 4px 4px;
|
|
19718
19734
|
}
|
|
19719
19735
|
}
|
|
19720
19736
|
}
|
|
@@ -28996,6 +29012,14 @@ class BordersPlugin extends CorePlugin {
|
|
|
28996
29012
|
// ---------------------------------------------------------------------------
|
|
28997
29013
|
// Command Handling
|
|
28998
29014
|
// ---------------------------------------------------------------------------
|
|
29015
|
+
allowDispatch(cmd) {
|
|
29016
|
+
switch (cmd.type) {
|
|
29017
|
+
case "SET_BORDER":
|
|
29018
|
+
return this.checkBordersUnchanged(cmd);
|
|
29019
|
+
default:
|
|
29020
|
+
return 0 /* CommandResult.Success */;
|
|
29021
|
+
}
|
|
29022
|
+
}
|
|
28999
29023
|
handle(cmd) {
|
|
29000
29024
|
switch (cmd.type) {
|
|
29001
29025
|
case "ADD_MERGE":
|
|
@@ -29415,6 +29439,14 @@ class BordersPlugin extends CorePlugin {
|
|
|
29415
29439
|
this.setBorders(sheetId, [{ ...zone, left: right }], "right", bordersTopLeft.right);
|
|
29416
29440
|
}
|
|
29417
29441
|
}
|
|
29442
|
+
checkBordersUnchanged(cmd) {
|
|
29443
|
+
const currentBorder = this.getCellBorder(cmd);
|
|
29444
|
+
const areAllNewBordersUndefined = !cmd.border?.bottom && !cmd.border?.left && !cmd.border?.right && !cmd.border?.top;
|
|
29445
|
+
if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
|
|
29446
|
+
return 93 /* CommandResult.NoChanges */;
|
|
29447
|
+
}
|
|
29448
|
+
return 0 /* CommandResult.Success */;
|
|
29449
|
+
}
|
|
29418
29450
|
// ---------------------------------------------------------------------------
|
|
29419
29451
|
// Import/Export
|
|
29420
29452
|
// ---------------------------------------------------------------------------
|
|
@@ -29522,8 +29554,9 @@ class CellPlugin extends CorePlugin {
|
|
|
29522
29554
|
allowDispatch(cmd) {
|
|
29523
29555
|
switch (cmd.type) {
|
|
29524
29556
|
case "UPDATE_CELL":
|
|
29557
|
+
return this.checkCellOutOfSheet(cmd);
|
|
29525
29558
|
case "CLEAR_CELL":
|
|
29526
|
-
return this.
|
|
29559
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkCellOutOfSheet, this.checkUselessClearCell));
|
|
29527
29560
|
default:
|
|
29528
29561
|
return 0 /* CommandResult.Success */;
|
|
29529
29562
|
}
|
|
@@ -29682,14 +29715,9 @@ class CellPlugin extends CorePlugin {
|
|
|
29682
29715
|
*/
|
|
29683
29716
|
getCellById(cellId) {
|
|
29684
29717
|
// this must be as fast as possible
|
|
29685
|
-
|
|
29686
|
-
|
|
29687
|
-
|
|
29688
|
-
if (cell) {
|
|
29689
|
-
return cell;
|
|
29690
|
-
}
|
|
29691
|
-
}
|
|
29692
|
-
return undefined;
|
|
29718
|
+
const position = this.getters.getCellPosition(cellId);
|
|
29719
|
+
const sheet = this.cells[position.sheetId];
|
|
29720
|
+
return sheet[cellId];
|
|
29693
29721
|
}
|
|
29694
29722
|
/*
|
|
29695
29723
|
* Reconstructs the original formula string based on a normalized form and its dependencies
|
|
@@ -29926,13 +29954,23 @@ class CellPlugin extends CorePlugin {
|
|
|
29926
29954
|
dependencies: [],
|
|
29927
29955
|
};
|
|
29928
29956
|
}
|
|
29929
|
-
checkCellOutOfSheet(
|
|
29957
|
+
checkCellOutOfSheet(cmd) {
|
|
29958
|
+
const { sheetId, col, row } = cmd;
|
|
29930
29959
|
const sheet = this.getters.tryGetSheet(sheetId);
|
|
29931
29960
|
if (!sheet)
|
|
29932
29961
|
return 27 /* CommandResult.InvalidSheetId */;
|
|
29933
29962
|
const sheetZone = this.getters.getSheetZone(sheetId);
|
|
29934
29963
|
return isInside(col, row, sheetZone) ? 0 /* CommandResult.Success */ : 18 /* CommandResult.TargetOutOfSheet */;
|
|
29935
29964
|
}
|
|
29965
|
+
checkUselessClearCell(cmd) {
|
|
29966
|
+
const cell = this.getters.getCell(cmd);
|
|
29967
|
+
if (!cell)
|
|
29968
|
+
return 93 /* CommandResult.NoChanges */;
|
|
29969
|
+
if (!cell.content && !cell.style && !cell.format) {
|
|
29970
|
+
return 93 /* CommandResult.NoChanges */;
|
|
29971
|
+
}
|
|
29972
|
+
return 0 /* CommandResult.Success */;
|
|
29973
|
+
}
|
|
29936
29974
|
}
|
|
29937
29975
|
|
|
29938
29976
|
class ChartPlugin extends CorePlugin {
|
|
@@ -30848,6 +30886,13 @@ class FiltersPlugin extends CorePlugin {
|
|
|
30848
30886
|
}
|
|
30849
30887
|
onDeleteColumnsRows(cmd) {
|
|
30850
30888
|
for (const table of this.getFilterTables(cmd.sheetId)) {
|
|
30889
|
+
// Remove the filter tables whose data filter headers are in the removed rows.
|
|
30890
|
+
if (cmd.dimension === "ROW" && cmd.elements.includes(table.zone.top)) {
|
|
30891
|
+
const tables = { ...this.tables[cmd.sheetId] };
|
|
30892
|
+
delete tables[table.id];
|
|
30893
|
+
this.history.update("tables", cmd.sheetId, tables);
|
|
30894
|
+
continue;
|
|
30895
|
+
}
|
|
30851
30896
|
const zone = reduceZoneOnDeletion(table.zone, cmd.dimension === "COL" ? "left" : "top", cmd.elements);
|
|
30852
30897
|
if (!zone) {
|
|
30853
30898
|
const tables = { ...this.tables[cmd.sheetId] };
|
|
@@ -33028,10 +33073,13 @@ class SheetPlugin extends CorePlugin {
|
|
|
33028
33073
|
// begin with the end.
|
|
33029
33074
|
rows.sort((a, b) => b - a);
|
|
33030
33075
|
for (let group of groupConsecutive(rows)) {
|
|
33076
|
+
// indexes are sorted in the descending order
|
|
33077
|
+
const from = group[group.length - 1];
|
|
33078
|
+
const to = group[0];
|
|
33031
33079
|
// Move the cells.
|
|
33032
|
-
this.moveCellOnRowsDeletion(sheet,
|
|
33033
|
-
// Effectively delete the
|
|
33034
|
-
|
|
33080
|
+
this.moveCellOnRowsDeletion(sheet, from, to);
|
|
33081
|
+
// Effectively delete the rows
|
|
33082
|
+
this.updateRowsStructureOnDeletion(sheet, from, to);
|
|
33035
33083
|
}
|
|
33036
33084
|
const count = rows.filter((row) => row < sheet.panes.ySplit).length;
|
|
33037
33085
|
if (count) {
|
|
@@ -33053,8 +33101,6 @@ class SheetPlugin extends CorePlugin {
|
|
|
33053
33101
|
this.addEmptyRows(sheet, quantity);
|
|
33054
33102
|
// Move the cells.
|
|
33055
33103
|
this.moveCellsOnAddition(sheet, index, quantity, "rows");
|
|
33056
|
-
// Recompute the left-right/top-bottom.
|
|
33057
|
-
this.updateRowsStructureOnAddition(sheet, row, quantity);
|
|
33058
33104
|
if (index < sheet.panes.ySplit) {
|
|
33059
33105
|
this.setPaneDivisions(sheet.id, sheet.panes.ySplit + quantity, "ROW");
|
|
33060
33106
|
}
|
|
@@ -33155,35 +33201,20 @@ class SheetPlugin extends CorePlugin {
|
|
|
33155
33201
|
}
|
|
33156
33202
|
}
|
|
33157
33203
|
}
|
|
33158
|
-
updateRowsStructureOnDeletion(
|
|
33204
|
+
updateRowsStructureOnDeletion(sheet, deleteFromRow, deleteToRow) {
|
|
33159
33205
|
const rows = [];
|
|
33160
|
-
const cellsQueue = sheet.rows.map((row) => row.cells);
|
|
33206
|
+
const cellsQueue = sheet.rows.map((row) => row.cells).reverse();
|
|
33161
33207
|
for (let i in sheet.rows) {
|
|
33162
|
-
|
|
33208
|
+
const row = Number(i);
|
|
33209
|
+
if (row >= deleteFromRow && row <= deleteToRow) {
|
|
33163
33210
|
continue;
|
|
33164
33211
|
}
|
|
33165
33212
|
rows.push({
|
|
33166
|
-
cells: cellsQueue.
|
|
33213
|
+
cells: cellsQueue.pop(),
|
|
33167
33214
|
});
|
|
33168
33215
|
}
|
|
33169
33216
|
this.history.update("sheets", sheet.id, "rows", rows);
|
|
33170
33217
|
}
|
|
33171
|
-
/**
|
|
33172
|
-
* Update the rows of the sheet after an addition:
|
|
33173
|
-
* - Rename the rows
|
|
33174
|
-
*
|
|
33175
|
-
* @param sheet Sheet on which the deletion occurs
|
|
33176
|
-
* @param addedRow Index of the added row
|
|
33177
|
-
* @param rowsToAdd Number of the rows to add
|
|
33178
|
-
*/
|
|
33179
|
-
updateRowsStructureOnAddition(sheet, addedRow, rowsToAdd) {
|
|
33180
|
-
const rows = [];
|
|
33181
|
-
const cellsQueue = sheet.rows.map((row) => row.cells);
|
|
33182
|
-
sheet.rows.forEach(() => rows.push({
|
|
33183
|
-
cells: cellsQueue.shift(),
|
|
33184
|
-
}));
|
|
33185
|
-
this.history.update("sheets", sheet.id, "rows", rows);
|
|
33186
|
-
}
|
|
33187
33218
|
/**
|
|
33188
33219
|
* Add empty rows at the end of the rows
|
|
33189
33220
|
*
|
|
@@ -33634,6 +33665,7 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
33634
33665
|
}
|
|
33635
33666
|
return evaluatedCell;
|
|
33636
33667
|
};
|
|
33668
|
+
const rangeCache = {};
|
|
33637
33669
|
/**
|
|
33638
33670
|
* Return the values of the cell(s) used in reference, but always in the format of a range even
|
|
33639
33671
|
* if a single cell is referenced. It is a list of col values. This is useful for the formulas that describe parameters as
|
|
@@ -33650,21 +33682,26 @@ class EvaluationPlugin extends UIPlugin {
|
|
|
33650
33682
|
// Performance issue: Avoid fetching data on positions that are out of the spreadsheet
|
|
33651
33683
|
// e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
|
|
33652
33684
|
const sheetZone = getters.getSheetZone(sheetId);
|
|
33653
|
-
const result = [];
|
|
33654
33685
|
const zone = intersection(range.zone, sheetZone);
|
|
33655
33686
|
if (!zone) {
|
|
33656
|
-
|
|
33657
|
-
|
|
33687
|
+
return [[]];
|
|
33688
|
+
}
|
|
33689
|
+
const { top, left, bottom, right } = zone;
|
|
33690
|
+
const cacheKey = `${sheetId}-${top}-${left}-${bottom}-${right}`;
|
|
33691
|
+
if (cacheKey in rangeCache) {
|
|
33692
|
+
return rangeCache[cacheKey];
|
|
33658
33693
|
}
|
|
33694
|
+
const result = new Array(right - left + 1);
|
|
33659
33695
|
// Performance issue: nested loop is faster than a map here
|
|
33660
|
-
for (let col =
|
|
33661
|
-
const rowValues =
|
|
33662
|
-
for (let row =
|
|
33696
|
+
for (let col = left; col <= right; col++) {
|
|
33697
|
+
const rowValues = new Array(bottom - top + 1);
|
|
33698
|
+
for (let row = top; row <= bottom; row++) {
|
|
33663
33699
|
const cell = evalContext.getters.getCell({ sheetId: range.sheetId, col, row });
|
|
33664
|
-
rowValues
|
|
33700
|
+
rowValues[row - top] = cell ? getEvaluatedCell(cell) : undefined;
|
|
33665
33701
|
}
|
|
33666
|
-
result
|
|
33702
|
+
result[col - left] = rowValues;
|
|
33667
33703
|
}
|
|
33704
|
+
rangeCache[cacheKey] = result;
|
|
33668
33705
|
return result;
|
|
33669
33706
|
}
|
|
33670
33707
|
/**
|
|
@@ -34196,6 +34233,8 @@ class FilterEvaluationPlugin extends UIPlugin {
|
|
|
34196
34233
|
case "EVALUATE_CELLS":
|
|
34197
34234
|
case "ACTIVATE_SHEET":
|
|
34198
34235
|
case "REMOVE_FILTER_TABLE":
|
|
34236
|
+
case "ADD_COLUMNS_ROWS":
|
|
34237
|
+
case "REMOVE_COLUMNS_ROWS":
|
|
34199
34238
|
this.isEvaluationDirty = true;
|
|
34200
34239
|
break;
|
|
34201
34240
|
case "START":
|
|
@@ -44934,9 +44973,9 @@ function revertChanges(revisions) {
|
|
|
44934
44973
|
* Apply the changes of the given HistoryChange to the state
|
|
44935
44974
|
*/
|
|
44936
44975
|
function applyChange(change, target) {
|
|
44937
|
-
let val = change.
|
|
44938
|
-
|
|
44939
|
-
for (let pathIndex =
|
|
44976
|
+
let val = change.path[0];
|
|
44977
|
+
const key = change.path[change.path.length - 1];
|
|
44978
|
+
for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
|
|
44940
44979
|
const p = change.path[pathIndex];
|
|
44941
44980
|
if (val[p] === undefined) {
|
|
44942
44981
|
const nextPath = change.path[pathIndex + 1];
|
|
@@ -45603,13 +45642,14 @@ class StateObserver {
|
|
|
45603
45642
|
}
|
|
45604
45643
|
addChange(...args) {
|
|
45605
45644
|
const val = args.pop();
|
|
45606
|
-
const
|
|
45645
|
+
const root = args[0];
|
|
45607
45646
|
let value = root;
|
|
45608
|
-
let key =
|
|
45609
|
-
|
|
45610
|
-
|
|
45647
|
+
let key = args[args.length - 1];
|
|
45648
|
+
const pathLength = args.length - 2;
|
|
45649
|
+
for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
|
|
45650
|
+
const p = args[pathIndex];
|
|
45611
45651
|
if (value[p] === undefined) {
|
|
45612
|
-
const nextPath =
|
|
45652
|
+
const nextPath = args[pathIndex + 1];
|
|
45613
45653
|
value[p] = createEmptyStructure(nextPath);
|
|
45614
45654
|
}
|
|
45615
45655
|
value = value[p];
|
|
@@ -45618,8 +45658,7 @@ class StateObserver {
|
|
|
45618
45658
|
return;
|
|
45619
45659
|
}
|
|
45620
45660
|
this.changes.push({
|
|
45621
|
-
|
|
45622
|
-
path,
|
|
45661
|
+
path: args,
|
|
45623
45662
|
before: value[key],
|
|
45624
45663
|
after: val,
|
|
45625
45664
|
});
|
|
@@ -47469,19 +47508,22 @@ class Model extends EventBus {
|
|
|
47469
47508
|
* Check if the given command is allowed by all the plugins and the history.
|
|
47470
47509
|
*/
|
|
47471
47510
|
checkDispatchAllowed(command) {
|
|
47472
|
-
|
|
47473
|
-
|
|
47511
|
+
const results = isCoreCommand(command)
|
|
47512
|
+
? this.checkDispatchAllowedCoreCommand(command)
|
|
47513
|
+
: this.checkDispatchAllowedLocalCommand(command);
|
|
47514
|
+
if (results.some((r) => r !== 0 /* CommandResult.Success */)) {
|
|
47515
|
+
return new DispatchResult(results.flat());
|
|
47474
47516
|
}
|
|
47475
|
-
return
|
|
47517
|
+
return DispatchResult.Success;
|
|
47476
47518
|
}
|
|
47477
47519
|
checkDispatchAllowedCoreCommand(command) {
|
|
47478
47520
|
const results = this.corePlugins.map((handler) => handler.allowDispatch(command));
|
|
47479
47521
|
results.push(this.range.allowDispatch(command));
|
|
47480
|
-
return
|
|
47522
|
+
return results;
|
|
47481
47523
|
}
|
|
47482
47524
|
checkDispatchAllowedLocalCommand(command) {
|
|
47483
47525
|
const results = this.uiHandlers.map((handler) => handler.allowDispatch(command));
|
|
47484
|
-
return
|
|
47526
|
+
return results;
|
|
47485
47527
|
}
|
|
47486
47528
|
finalize() {
|
|
47487
47529
|
this.status = 3 /* Status.Finalizing */;
|
|
@@ -47797,6 +47839,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
47797
47839
|
exports.tokenize = tokenize;
|
|
47798
47840
|
|
|
47799
47841
|
|
|
47800
|
-
__info__.version = '16.3.
|
|
47801
|
-
__info__.date = '2023-11-
|
|
47802
|
-
__info__.hash = '
|
|
47842
|
+
__info__.version = '16.3.18';
|
|
47843
|
+
__info__.date = '2023-11-24T13:10:15.278Z';
|
|
47844
|
+
__info__.hash = '45f745e';
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -1282,7 +1282,7 @@ declare class StateObserver {
|
|
|
1282
1282
|
commands: CoreCommand[];
|
|
1283
1283
|
};
|
|
1284
1284
|
addCommand(command: CoreCommand): void;
|
|
1285
|
-
addChange(...args:
|
|
1285
|
+
addChange(...args: [...HistoryChange["path"], any]): void;
|
|
1286
1286
|
}
|
|
1287
1287
|
|
|
1288
1288
|
interface Validator {
|
|
@@ -2358,7 +2358,8 @@ declare const enum CommandResult {
|
|
|
2358
2358
|
EmptySplitSeparator = 89,
|
|
2359
2359
|
SplitWillOverwriteContent = 90,
|
|
2360
2360
|
NoSplitSeparatorInSelection = 91,
|
|
2361
|
-
NoActiveSheet = 92
|
|
2361
|
+
NoActiveSheet = 92,
|
|
2362
|
+
NoChanges = 93
|
|
2362
2363
|
}
|
|
2363
2364
|
interface CommandHandler<T> {
|
|
2364
2365
|
allowDispatch(command: T): CommandResult | CommandResult[];
|
|
@@ -2960,7 +2961,8 @@ interface BordersPluginState {
|
|
|
2960
2961
|
declare class BordersPlugin extends CorePlugin<BordersPluginState> implements BordersPluginState {
|
|
2961
2962
|
static getters: readonly ["getCellBorder", "getBordersColors"];
|
|
2962
2963
|
readonly borders: BordersPluginState["borders"];
|
|
2963
|
-
|
|
2964
|
+
allowDispatch(cmd: CoreCommand): CommandResult.Success | CommandResult.NoChanges;
|
|
2965
|
+
handle(cmd: CoreCommand): void;
|
|
2964
2966
|
/**
|
|
2965
2967
|
* Move borders according to the inserted columns.
|
|
2966
2968
|
* Ensure borders continuity.
|
|
@@ -3058,6 +3060,7 @@ declare class BordersPlugin extends CorePlugin<BordersPluginState> implements Bo
|
|
|
3058
3060
|
* Compute the borders to add to the given zone merged.
|
|
3059
3061
|
*/
|
|
3060
3062
|
private addBordersToMerge;
|
|
3063
|
+
private checkBordersUnchanged;
|
|
3061
3064
|
import(data: WorkbookData): void;
|
|
3062
3065
|
export(data: WorkbookData): void;
|
|
3063
3066
|
exportForExcel(data: ExcelWorkbookData): void;
|
|
@@ -3082,7 +3085,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
|
|
|
3082
3085
|
};
|
|
3083
3086
|
};
|
|
3084
3087
|
adaptRanges(applyChange: ApplyRangeChange, sheetId?: UID): void;
|
|
3085
|
-
allowDispatch(cmd: CoreCommand): CommandResult;
|
|
3088
|
+
allowDispatch(cmd: CoreCommand): CommandResult | CommandResult[];
|
|
3086
3089
|
handle(cmd: CoreCommand): void;
|
|
3087
3090
|
/**
|
|
3088
3091
|
* Set a format to all the cells in a zone
|
|
@@ -3155,6 +3158,7 @@ declare class CellPlugin extends CorePlugin<CoreState> implements CoreState {
|
|
|
3155
3158
|
private createFormulaCellWithDependencies;
|
|
3156
3159
|
private createErrorFormula;
|
|
3157
3160
|
private checkCellOutOfSheet;
|
|
3161
|
+
private checkUselessClearCell;
|
|
3158
3162
|
}
|
|
3159
3163
|
|
|
3160
3164
|
/**
|
|
@@ -3672,15 +3676,6 @@ declare class SheetPlugin extends CorePlugin<SheetState$1> implements SheetState
|
|
|
3672
3676
|
*/
|
|
3673
3677
|
private moveCellOnRowsDeletion;
|
|
3674
3678
|
private updateRowsStructureOnDeletion;
|
|
3675
|
-
/**
|
|
3676
|
-
* Update the rows of the sheet after an addition:
|
|
3677
|
-
* - Rename the rows
|
|
3678
|
-
*
|
|
3679
|
-
* @param sheet Sheet on which the deletion occurs
|
|
3680
|
-
* @param addedRow Index of the added row
|
|
3681
|
-
* @param rowsToAdd Number of the rows to add
|
|
3682
|
-
*/
|
|
3683
|
-
private updateRowsStructureOnAddition;
|
|
3684
3679
|
/**
|
|
3685
3680
|
* Add empty rows at the end of the rows
|
|
3686
3681
|
*
|
|
@@ -4805,8 +4800,7 @@ type Getters = {
|
|
|
4805
4800
|
} & LocalHistoryGetters & CoreGetters & AutofillGetters & AutomaticSumGetters & ClipboardGetters & EditionGetters & EvaluationGetters & EvaluationChartGetters & EvaluationConditionalFormatGetters & FindAndReplaceGetters & HighlightGetters & CustomColorsGetters & RendererGetters & SelectionGetters & SelectionInputGetters & CollaborativeGetters & SortGetters & UIOptionsGetters & SheetUIGetters & ViewportGetters & CellPopoverPluginGetters & FilterEvaluationGetters & HeaderVisibilityIUIGetters & SplitToColumnsGetters;
|
|
4806
4801
|
|
|
4807
4802
|
interface HistoryChange {
|
|
4808
|
-
|
|
4809
|
-
path: (string | number)[];
|
|
4803
|
+
path: [any, ...(number | string)[]];
|
|
4810
4804
|
before: any;
|
|
4811
4805
|
after: any;
|
|
4812
4806
|
}
|