@odoo/o-spreadsheet 17.0.68 → 17.0.70

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.0.68
6
- * @date 2025-06-27T09:09:05.702Z
7
- * @hash 33404c6
5
+ * @version 17.0.70
6
+ * @date 2025-07-28T13:26:37.626Z
7
+ * @hash 2ec8d82
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -4586,6 +4586,8 @@
4586
4586
  function splitTextToWidth(ctx, text, style, width) {
4587
4587
  if (!style)
4588
4588
  style = {};
4589
+ if (isMarkdownLink(text))
4590
+ text = parseMarkdownLink(text).label;
4589
4591
  const brokenText = [];
4590
4592
  // Checking if text contains NEWLINE before split makes it very slightly slower if text contains it,
4591
4593
  // but 5-10x faster if it doesn't
@@ -32340,38 +32342,111 @@
32340
32342
  * In all the sheets, replace the table-only references in the formula cells with standard references.
32341
32343
  */
32342
32344
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
32345
+ let deconstructedSheets = null;
32343
32346
  for (let tableSheet of convertedSheets) {
32344
32347
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
32348
+ if (!tables || tables.length === 0) {
32349
+ continue;
32350
+ }
32351
+ // Only deconstruct sheets if we are sure there are tables to process
32352
+ if (!deconstructedSheets) {
32353
+ deconstructedSheets = deconstructSheets(convertedSheets);
32354
+ }
32345
32355
  for (let table of tables) {
32346
- const tabRef = table.name + "[";
32347
- for (let sheet of convertedSheets) {
32348
- for (let xc in sheet.cells) {
32349
- const cell = sheet.cells[xc];
32350
- if (cell && cell.content && cell.content.startsWith("=")) {
32351
- let refIndex;
32352
- while ((refIndex = cell.content.indexOf(tabRef)) !== -1) {
32353
- let endIndex = refIndex + tabRef.length;
32354
- let openBrackets = 1;
32355
- while (openBrackets > 0 && endIndex < cell.content.length) {
32356
- if (cell.content[endIndex] === "[") {
32357
- openBrackets++;
32358
- }
32359
- else if (cell.content[endIndex] === "]") {
32360
- openBrackets--;
32361
- }
32362
- endIndex++;
32363
- }
32364
- let reference = cell.content.slice(refIndex + tabRef.length, endIndex - 1);
32365
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
32366
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
32367
- cell.content =
32368
- cell.content.slice(0, refIndex) + convertedRef + cell.content.slice(endIndex);
32356
+ for (let sheetId in deconstructedSheets) {
32357
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
32358
+ for (let xc in deconstructedSheets[sheetId]) {
32359
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
32360
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
32361
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
32362
+ if (!possibleTable.endsWith(table.name)) {
32363
+ continue;
32369
32364
  }
32365
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
32366
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
32367
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
32368
+ deconstructedSheets[sheetId][xc][i + 2] =
32369
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
32370
+ convertedRef +
32371
+ deconstructedSheets[sheetId][xc][i + 2];
32372
+ deconstructedSheets[sheetId][xc].splice(i, 2);
32370
32373
  }
32371
32374
  }
32372
32375
  }
32373
32376
  }
32374
32377
  }
32378
+ if (!deconstructedSheets) {
32379
+ return;
32380
+ }
32381
+ for (let sheetId in deconstructedSheets) {
32382
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
32383
+ for (let xc in deconstructedSheets[sheetId]) {
32384
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
32385
+ if (deconstructedCell.length === 1) {
32386
+ sheet.cells[xc].content = deconstructedCell[0];
32387
+ continue;
32388
+ }
32389
+ let newContent = "";
32390
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
32391
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
32392
+ }
32393
+ newContent += deconstructedCell[deconstructedCell.length - 1];
32394
+ sheet.cells[xc].content = newContent;
32395
+ }
32396
+ }
32397
+ }
32398
+ /**
32399
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
32400
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
32401
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
32402
+ */
32403
+ function deconstructSheets(convertedSheets) {
32404
+ const deconstructedSheets = {};
32405
+ for (let sheet of convertedSheets) {
32406
+ for (let xc in sheet.cells) {
32407
+ const cellContent = sheet.cells[xc]?.content;
32408
+ if (!cellContent || !cellContent.startsWith("=")) {
32409
+ continue;
32410
+ }
32411
+ const startIndex = cellContent.indexOf("[");
32412
+ if (startIndex === -1) {
32413
+ continue;
32414
+ }
32415
+ const deconstructedCell = [];
32416
+ let possibleTable = cellContent.slice(0, startIndex);
32417
+ let possibleRef = "";
32418
+ let openBrackets = 1;
32419
+ let mainPossibleTableIndex = 0;
32420
+ let mainOpenBracketIndex = startIndex;
32421
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
32422
+ if (cellContent[index] === "[") {
32423
+ if (openBrackets === 0) {
32424
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
32425
+ mainOpenBracketIndex = index;
32426
+ }
32427
+ openBrackets++;
32428
+ continue;
32429
+ }
32430
+ if (cellContent[index] === "]") {
32431
+ openBrackets--;
32432
+ if (openBrackets === 0) {
32433
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
32434
+ deconstructedCell.push(possibleTable);
32435
+ deconstructedCell.push(possibleRef);
32436
+ mainPossibleTableIndex = index + 1;
32437
+ }
32438
+ }
32439
+ }
32440
+ if (deconstructedCell.length) {
32441
+ if (!deconstructedSheets[sheet.id]) {
32442
+ deconstructedSheets[sheet.id] = {};
32443
+ }
32444
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
32445
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
32446
+ }
32447
+ }
32448
+ }
32449
+ return deconstructedSheets;
32375
32450
  }
32376
32451
  /**
32377
32452
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -43395,6 +43470,23 @@
43395
43470
  static getters = ["getRowSize", "getHeaderSize"];
43396
43471
  tallestCellInRow = {};
43397
43472
  ctx = document.createElement("canvas").getContext("2d");
43473
+ beforeHandle(cmd) {
43474
+ switch (cmd.type) {
43475
+ // Ensure rows are updated before "UPDATE_CELL" is dispatched from cell plugin.
43476
+ // "UPDATE_CELL" uses the Sheet core plugin to access row data.
43477
+ // If "ADD_COLUMNS_ROWS" has not been processed yet by header_sizes_ui,
43478
+ // size updates may apply to incorrect (pre-insert) rows.
43479
+ case "ADD_COLUMNS_ROWS":
43480
+ if (cmd.dimension === "COL") {
43481
+ return;
43482
+ }
43483
+ const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
43484
+ const newCells = Array(cmd.quantity).fill(undefined);
43485
+ const newTallestCells = insertItemsAtIndex(this.tallestCellInRow[cmd.sheetId], newCells, addIndex);
43486
+ this.history.update("tallestCellInRow", cmd.sheetId, newTallestCells);
43487
+ break;
43488
+ }
43489
+ }
43398
43490
  handle(cmd) {
43399
43491
  switch (cmd.type) {
43400
43492
  case "START":
@@ -43424,16 +43516,6 @@
43424
43516
  this.history.update("tallestCellInRow", cmd.sheetId, tallestCells);
43425
43517
  break;
43426
43518
  }
43427
- case "ADD_COLUMNS_ROWS": {
43428
- if (cmd.dimension === "COL") {
43429
- return;
43430
- }
43431
- const addIndex = getAddHeaderStartIndex(cmd.position, cmd.base);
43432
- const newCells = Array(cmd.quantity).fill(undefined);
43433
- const newTallestCells = insertItemsAtIndex(this.tallestCellInRow[cmd.sheetId], newCells, addIndex);
43434
- this.history.update("tallestCellInRow", cmd.sheetId, newTallestCells);
43435
- break;
43436
- }
43437
43519
  case "RESIZE_COLUMNS_ROWS":
43438
43520
  {
43439
43521
  const sheetId = cmd.sheetId;
@@ -50798,6 +50880,14 @@
50798
50880
  const isBasedBefore = cmd.base < start;
50799
50881
  const deltaCol = isBasedBefore && isCol ? thickness : 0;
50800
50882
  const deltaRow = isBasedBefore && !isCol ? thickness : 0;
50883
+ const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50884
+ const originalSize = Object.fromEntries(toRemove.map((element) => {
50885
+ const size = isCol
50886
+ ? this.getters.getColSize(cmd.sheetId, element)
50887
+ : this.getters.getUserRowSize(cmd.sheetId, element);
50888
+ const isDefaultCol = isCol && size === DEFAULT_CELL_WIDTH;
50889
+ return [element, isDefaultCol || size === undefined ? null : size];
50890
+ }));
50801
50891
  const target = [
50802
50892
  {
50803
50893
  left: isCol ? start + deltaCol : 0,
@@ -50817,14 +50907,12 @@
50817
50907
  },
50818
50908
  ];
50819
50909
  state.paste(pasteTarget, { selectTarget: true });
50820
- const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50821
50910
  let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
50822
50911
  for (const element of toRemove) {
50823
- const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
50824
50912
  this.dispatch("RESIZE_COLUMNS_ROWS", {
50825
50913
  dimension: cmd.dimension,
50826
50914
  sheetId: cmd.sheetId,
50827
- size,
50915
+ size: originalSize[element],
50828
50916
  elements: [currentIndex],
50829
50917
  });
50830
50918
  currentIndex += 1;
@@ -52502,14 +52590,12 @@
52502
52590
  this.editionState = "initializing";
52503
52591
  }
52504
52592
  stopEdition() {
52505
- const input = this.sheetNameRef.el;
52506
- if (!this.state.isEditing || !input)
52593
+ if (!this.state.isEditing || !this.sheetNameRef.el)
52507
52594
  return;
52508
52595
  this.state.isEditing = false;
52509
52596
  this.editionState = "initializing";
52510
- input.blur();
52597
+ this.sheetNameRef.el.blur();
52511
52598
  const inputValue = this.getInputContent() || "";
52512
- input.innerText = inputValue;
52513
52599
  interactiveRenameSheet(this.env, this.props.sheetId, inputValue, () => this.startEdition());
52514
52600
  }
52515
52601
  cancelEdition() {
@@ -58362,9 +58448,9 @@
58362
58448
  exports.tokenize = tokenize;
58363
58449
 
58364
58450
 
58365
- __info__.version = "17.0.68";
58366
- __info__.date = "2025-06-27T09:09:05.702Z";
58367
- __info__.hash = "33404c6";
58451
+ __info__.version = "17.0.70";
58452
+ __info__.date = "2025-07-28T13:26:37.626Z";
58453
+ __info__.hash = "2ec8d82";
58368
58454
 
58369
58455
 
58370
58456
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);