@odoo/o-spreadsheet 18.0.19 → 18.0.20

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 18.0.19
6
- * @date 2025-03-12T15:33:28.300Z
7
- * @hash d8dea1b
5
+ * @version 18.0.20
6
+ * @date 2025-03-19T08:21:32.426Z
7
+ * @hash 3f48d8b
8
8
  */
9
9
 
10
10
  'use strict';
@@ -6109,11 +6109,13 @@ function getDefaultCellHeight(ctx, cell, colSize) {
6109
6109
  if (!cell || (!cell.isFormula && !cell.content)) {
6110
6110
  return DEFAULT_CELL_HEIGHT;
6111
6111
  }
6112
- const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
6113
- const numberOfLines = cell.isFormula
6114
- ? 1
6115
- : splitTextToWidth(ctx, cell.content, cell.style, maxWidth).length;
6116
- const fontSize = computeTextFontSizeInPixels(cell.style);
6112
+ const content = cell.isFormula ? "" : cell.content;
6113
+ return getCellContentHeight(ctx, content, cell.style, colSize);
6114
+ }
6115
+ function getCellContentHeight(ctx, content, style, colSize) {
6116
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
6117
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
6118
+ const fontSize = computeTextFontSizeInPixels(style);
6117
6119
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
6118
6120
  }
6119
6121
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -8276,13 +8278,6 @@ class CellClipboardHandler extends AbstractCellClipboardHandler {
8276
8278
  this.clearClippedZones(content);
8277
8279
  const selection = target[0];
8278
8280
  this.pasteZone(sheetId, selection.left, selection.top, content.cells, options);
8279
- this.dispatch("MOVE_RANGES", {
8280
- target: content.zones,
8281
- sheetId: content.sheetId,
8282
- targetSheetId: sheetId,
8283
- col: selection.left,
8284
- row: selection.top,
8285
- });
8286
8281
  }
8287
8282
  /**
8288
8283
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -8791,14 +8786,15 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
8791
8786
  }
8792
8787
  merges.push(mergesInRow);
8793
8788
  }
8794
- return { merges };
8789
+ return { merges, sheetId };
8795
8790
  }
8796
8791
  /**
8797
8792
  * Paste the clipboard content in the given target
8798
8793
  */
8799
8794
  paste(target, content, options) {
8800
8795
  if (options.isCutOperation) {
8801
- return;
8796
+ const copiedMerges = content.merges.flat().filter(isDefined);
8797
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
8802
8798
  }
8803
8799
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
8804
8800
  }
@@ -8833,6 +8829,27 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
8833
8829
  }
8834
8830
  }
8835
8831
 
8832
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
8833
+ copy(data) {
8834
+ return {
8835
+ zones: data.clippedZones,
8836
+ sheetId: data.sheetId,
8837
+ };
8838
+ }
8839
+ paste(target, content, options) {
8840
+ if (options.isCutOperation) {
8841
+ const selection = target.zones[0];
8842
+ this.dispatch("MOVE_RANGES", {
8843
+ target: content.zones,
8844
+ sheetId: content.sheetId,
8845
+ targetSheetId: target.sheetId,
8846
+ col: selection.left,
8847
+ row: selection.top,
8848
+ });
8849
+ }
8850
+ }
8851
+ }
8852
+
8836
8853
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
8837
8854
  isPasteAllowed(sheetId, target, content, options) {
8838
8855
  if (!("cells" in content)) {
@@ -9000,7 +9017,8 @@ clipboardHandlersRegistries.cellHandlers
9000
9017
  .add("merge", MergeClipboardHandler)
9001
9018
  .add("border", BorderClipboardHandler)
9002
9019
  .add("table", TableClipboardHandler)
9003
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
9020
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
9021
+ .add("references", ReferenceClipboardHandler);
9004
9022
 
9005
9023
  function transformZone(zone, executed) {
9006
9024
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -28437,7 +28455,7 @@ autoCompleteProviders.add("pivot_group_values", {
28437
28455
  text,
28438
28456
  description: usedLabel,
28439
28457
  htmlContent: [{ value: text, color }],
28440
- fuzzySearchKey: value + usedLabel,
28458
+ fuzzySearchKey: text + usedLabel,
28441
28459
  };
28442
28460
  });
28443
28461
  },
@@ -38840,8 +38858,8 @@ class AbstractComposerStore extends SpreadsheetStore {
38840
38858
  this.updateRangeColor();
38841
38859
  }
38842
38860
  cancelEdition() {
38843
- this.cancelEditionAndActivateSheet();
38844
38861
  this.resetContent();
38862
+ this.cancelEditionAndActivateSheet();
38845
38863
  }
38846
38864
  setCurrentContent(content, selection) {
38847
38865
  if (selection && !this.isSelectionValid(content.length, selection.start, selection.end)) {
@@ -38857,8 +38875,8 @@ class AbstractComposerStore extends SpreadsheetStore {
38857
38875
  switch (cmd.type) {
38858
38876
  case "SELECT_FIGURE":
38859
38877
  if (cmd.id) {
38860
- this.cancelEditionAndActivateSheet();
38861
38878
  this.resetContent();
38879
+ this.cancelEditionAndActivateSheet();
38862
38880
  }
38863
38881
  break;
38864
38882
  case "START_CHANGE_HIGHLIGHT":
@@ -44753,6 +44771,7 @@ class RemoveDuplicatesPanel extends owl.Component {
44753
44771
  columns: {},
44754
44772
  });
44755
44773
  setup() {
44774
+ this.updateColumns();
44756
44775
  owl.onWillUpdateProps(() => this.updateColumns());
44757
44776
  }
44758
44777
  toggleHasHeader() {
@@ -46541,8 +46560,8 @@ class CellComposerStore extends AbstractComposerStore {
46541
46560
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
46542
46561
  if (!sheetIdExists && this.editionMode !== "inactive") {
46543
46562
  this.sheetId = this.getters.getActiveSheetId();
46544
- this.cancelEditionAndActivateSheet();
46545
46563
  this.resetContent();
46564
+ this.cancelEditionAndActivateSheet();
46546
46565
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
46547
46566
  }
46548
46567
  break;
@@ -62898,12 +62917,7 @@ class SheetUIPlugin extends UIPlugin {
62898
62917
  }
62899
62918
  break;
62900
62919
  case "AUTORESIZE_ROWS":
62901
- this.dispatch("RESIZE_COLUMNS_ROWS", {
62902
- elements: cmd.rows,
62903
- dimension: "ROW",
62904
- size: null,
62905
- sheetId: cmd.sheetId,
62906
- });
62920
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
62907
62921
  break;
62908
62922
  }
62909
62923
  }
@@ -63068,6 +63082,48 @@ class SheetUIPlugin extends UIPlugin {
63068
63082
  }
63069
63083
  return "Success" /* CommandResult.Success */;
63070
63084
  }
63085
+ autoResizeRows(sheetId, rows) {
63086
+ const rowSizes = [];
63087
+ for (const row of rows) {
63088
+ let evaluatedRowSize = 0;
63089
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
63090
+ const cell = this.getters.getCellById(cellId);
63091
+ if (!cell) {
63092
+ continue;
63093
+ }
63094
+ const position = this.getters.getCellPosition(cell.id);
63095
+ const colSize = this.getters.getColSize(sheetId, position.col);
63096
+ if (cell.isFormula) {
63097
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
63098
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63099
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
63100
+ evaluatedRowSize = evaluatedSize;
63101
+ }
63102
+ }
63103
+ else {
63104
+ const content = cell.content;
63105
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63106
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
63107
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
63108
+ evaluatedRowSize = 0;
63109
+ }
63110
+ }
63111
+ }
63112
+ rowSizes.push(evaluatedRowSize || null);
63113
+ }
63114
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
63115
+ for (let i = 0; i < rowSizes.length; i++) {
63116
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
63117
+ }
63118
+ for (const [size, rows] of groupedSizes) {
63119
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
63120
+ elements: rows,
63121
+ dimension: "ROW",
63122
+ size,
63123
+ sheetId,
63124
+ });
63125
+ }
63126
+ }
63071
63127
  }
63072
63128
 
63073
63129
  class TableComputedStylePlugin extends UIPlugin {
@@ -73551,6 +73607,6 @@ exports.tokenColors = tokenColors;
73551
73607
  exports.tokenize = tokenize;
73552
73608
 
73553
73609
 
73554
- __info__.version = "18.0.19";
73555
- __info__.date = "2025-03-12T15:33:28.300Z";
73556
- __info__.hash = "d8dea1b";
73610
+ __info__.version = "18.0.20";
73611
+ __info__.date = "2025-03-19T08:21:32.426Z";
73612
+ __info__.hash = "3f48d8b";
@@ -5276,6 +5276,7 @@ declare class SheetUIPlugin extends UIPlugin {
5276
5276
  * not outside the sheet.
5277
5277
  */
5278
5278
  private checkZonesAreInSheet;
5279
+ private autoResizeRows;
5279
5280
  }
5280
5281
 
5281
5282
  declare class HeaderPositionsUIPlugin extends UIPlugin {
@@ -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 18.0.19
6
- * @date 2025-03-12T15:33:28.300Z
7
- * @hash d8dea1b
5
+ * @version 18.0.20
6
+ * @date 2025-03-19T08:21:32.426Z
7
+ * @hash 3f48d8b
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -6107,11 +6107,13 @@ function getDefaultCellHeight(ctx, cell, colSize) {
6107
6107
  if (!cell || (!cell.isFormula && !cell.content)) {
6108
6108
  return DEFAULT_CELL_HEIGHT;
6109
6109
  }
6110
- const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
6111
- const numberOfLines = cell.isFormula
6112
- ? 1
6113
- : splitTextToWidth(ctx, cell.content, cell.style, maxWidth).length;
6114
- const fontSize = computeTextFontSizeInPixels(cell.style);
6110
+ const content = cell.isFormula ? "" : cell.content;
6111
+ return getCellContentHeight(ctx, content, cell.style, colSize);
6112
+ }
6113
+ function getCellContentHeight(ctx, content, style, colSize) {
6114
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
6115
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
6116
+ const fontSize = computeTextFontSizeInPixels(style);
6115
6117
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
6116
6118
  }
6117
6119
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -8274,13 +8276,6 @@ class CellClipboardHandler extends AbstractCellClipboardHandler {
8274
8276
  this.clearClippedZones(content);
8275
8277
  const selection = target[0];
8276
8278
  this.pasteZone(sheetId, selection.left, selection.top, content.cells, options);
8277
- this.dispatch("MOVE_RANGES", {
8278
- target: content.zones,
8279
- sheetId: content.sheetId,
8280
- targetSheetId: sheetId,
8281
- col: selection.left,
8282
- row: selection.top,
8283
- });
8284
8279
  }
8285
8280
  /**
8286
8281
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -8789,14 +8784,15 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
8789
8784
  }
8790
8785
  merges.push(mergesInRow);
8791
8786
  }
8792
- return { merges };
8787
+ return { merges, sheetId };
8793
8788
  }
8794
8789
  /**
8795
8790
  * Paste the clipboard content in the given target
8796
8791
  */
8797
8792
  paste(target, content, options) {
8798
8793
  if (options.isCutOperation) {
8799
- return;
8794
+ const copiedMerges = content.merges.flat().filter(isDefined);
8795
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
8800
8796
  }
8801
8797
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
8802
8798
  }
@@ -8831,6 +8827,27 @@ class MergeClipboardHandler extends AbstractCellClipboardHandler {
8831
8827
  }
8832
8828
  }
8833
8829
 
8830
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
8831
+ copy(data) {
8832
+ return {
8833
+ zones: data.clippedZones,
8834
+ sheetId: data.sheetId,
8835
+ };
8836
+ }
8837
+ paste(target, content, options) {
8838
+ if (options.isCutOperation) {
8839
+ const selection = target.zones[0];
8840
+ this.dispatch("MOVE_RANGES", {
8841
+ target: content.zones,
8842
+ sheetId: content.sheetId,
8843
+ targetSheetId: target.sheetId,
8844
+ col: selection.left,
8845
+ row: selection.top,
8846
+ });
8847
+ }
8848
+ }
8849
+ }
8850
+
8834
8851
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
8835
8852
  isPasteAllowed(sheetId, target, content, options) {
8836
8853
  if (!("cells" in content)) {
@@ -8998,7 +9015,8 @@ clipboardHandlersRegistries.cellHandlers
8998
9015
  .add("merge", MergeClipboardHandler)
8999
9016
  .add("border", BorderClipboardHandler)
9000
9017
  .add("table", TableClipboardHandler)
9001
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
9018
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
9019
+ .add("references", ReferenceClipboardHandler);
9002
9020
 
9003
9021
  function transformZone(zone, executed) {
9004
9022
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -28435,7 +28453,7 @@ autoCompleteProviders.add("pivot_group_values", {
28435
28453
  text,
28436
28454
  description: usedLabel,
28437
28455
  htmlContent: [{ value: text, color }],
28438
- fuzzySearchKey: value + usedLabel,
28456
+ fuzzySearchKey: text + usedLabel,
28439
28457
  };
28440
28458
  });
28441
28459
  },
@@ -38838,8 +38856,8 @@ class AbstractComposerStore extends SpreadsheetStore {
38838
38856
  this.updateRangeColor();
38839
38857
  }
38840
38858
  cancelEdition() {
38841
- this.cancelEditionAndActivateSheet();
38842
38859
  this.resetContent();
38860
+ this.cancelEditionAndActivateSheet();
38843
38861
  }
38844
38862
  setCurrentContent(content, selection) {
38845
38863
  if (selection && !this.isSelectionValid(content.length, selection.start, selection.end)) {
@@ -38855,8 +38873,8 @@ class AbstractComposerStore extends SpreadsheetStore {
38855
38873
  switch (cmd.type) {
38856
38874
  case "SELECT_FIGURE":
38857
38875
  if (cmd.id) {
38858
- this.cancelEditionAndActivateSheet();
38859
38876
  this.resetContent();
38877
+ this.cancelEditionAndActivateSheet();
38860
38878
  }
38861
38879
  break;
38862
38880
  case "START_CHANGE_HIGHLIGHT":
@@ -44751,6 +44769,7 @@ class RemoveDuplicatesPanel extends Component {
44751
44769
  columns: {},
44752
44770
  });
44753
44771
  setup() {
44772
+ this.updateColumns();
44754
44773
  onWillUpdateProps(() => this.updateColumns());
44755
44774
  }
44756
44775
  toggleHasHeader() {
@@ -46539,8 +46558,8 @@ class CellComposerStore extends AbstractComposerStore {
46539
46558
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
46540
46559
  if (!sheetIdExists && this.editionMode !== "inactive") {
46541
46560
  this.sheetId = this.getters.getActiveSheetId();
46542
- this.cancelEditionAndActivateSheet();
46543
46561
  this.resetContent();
46562
+ this.cancelEditionAndActivateSheet();
46544
46563
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
46545
46564
  }
46546
46565
  break;
@@ -62896,12 +62915,7 @@ class SheetUIPlugin extends UIPlugin {
62896
62915
  }
62897
62916
  break;
62898
62917
  case "AUTORESIZE_ROWS":
62899
- this.dispatch("RESIZE_COLUMNS_ROWS", {
62900
- elements: cmd.rows,
62901
- dimension: "ROW",
62902
- size: null,
62903
- sheetId: cmd.sheetId,
62904
- });
62918
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
62905
62919
  break;
62906
62920
  }
62907
62921
  }
@@ -63066,6 +63080,48 @@ class SheetUIPlugin extends UIPlugin {
63066
63080
  }
63067
63081
  return "Success" /* CommandResult.Success */;
63068
63082
  }
63083
+ autoResizeRows(sheetId, rows) {
63084
+ const rowSizes = [];
63085
+ for (const row of rows) {
63086
+ let evaluatedRowSize = 0;
63087
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
63088
+ const cell = this.getters.getCellById(cellId);
63089
+ if (!cell) {
63090
+ continue;
63091
+ }
63092
+ const position = this.getters.getCellPosition(cell.id);
63093
+ const colSize = this.getters.getColSize(sheetId, position.col);
63094
+ if (cell.isFormula) {
63095
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
63096
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63097
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
63098
+ evaluatedRowSize = evaluatedSize;
63099
+ }
63100
+ }
63101
+ else {
63102
+ const content = cell.content;
63103
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63104
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
63105
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
63106
+ evaluatedRowSize = 0;
63107
+ }
63108
+ }
63109
+ }
63110
+ rowSizes.push(evaluatedRowSize || null);
63111
+ }
63112
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
63113
+ for (let i = 0; i < rowSizes.length; i++) {
63114
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
63115
+ }
63116
+ for (const [size, rows] of groupedSizes) {
63117
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
63118
+ elements: rows,
63119
+ dimension: "ROW",
63120
+ size,
63121
+ sheetId,
63122
+ });
63123
+ }
63124
+ }
63069
63125
  }
63070
63126
 
63071
63127
  class TableComputedStylePlugin extends UIPlugin {
@@ -73506,6 +73562,6 @@ const constants = {
73506
73562
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
73507
73563
 
73508
73564
 
73509
- __info__.version = "18.0.19";
73510
- __info__.date = "2025-03-12T15:33:28.300Z";
73511
- __info__.hash = "d8dea1b";
73565
+ __info__.version = "18.0.20";
73566
+ __info__.date = "2025-03-19T08:21:32.426Z";
73567
+ __info__.hash = "3f48d8b";
@@ -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 18.0.19
6
- * @date 2025-03-12T15:33:28.300Z
7
- * @hash d8dea1b
5
+ * @version 18.0.20
6
+ * @date 2025-03-19T08:21:32.426Z
7
+ * @hash 3f48d8b
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -6108,11 +6108,13 @@
6108
6108
  if (!cell || (!cell.isFormula && !cell.content)) {
6109
6109
  return DEFAULT_CELL_HEIGHT;
6110
6110
  }
6111
- const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
6112
- const numberOfLines = cell.isFormula
6113
- ? 1
6114
- : splitTextToWidth(ctx, cell.content, cell.style, maxWidth).length;
6115
- const fontSize = computeTextFontSizeInPixels(cell.style);
6111
+ const content = cell.isFormula ? "" : cell.content;
6112
+ return getCellContentHeight(ctx, content, cell.style, colSize);
6113
+ }
6114
+ function getCellContentHeight(ctx, content, style, colSize) {
6115
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
6116
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
6117
+ const fontSize = computeTextFontSizeInPixels(style);
6116
6118
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
6117
6119
  }
6118
6120
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -8275,13 +8277,6 @@
8275
8277
  this.clearClippedZones(content);
8276
8278
  const selection = target[0];
8277
8279
  this.pasteZone(sheetId, selection.left, selection.top, content.cells, options);
8278
- this.dispatch("MOVE_RANGES", {
8279
- target: content.zones,
8280
- sheetId: content.sheetId,
8281
- targetSheetId: sheetId,
8282
- col: selection.left,
8283
- row: selection.top,
8284
- });
8285
8280
  }
8286
8281
  /**
8287
8282
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -8790,14 +8785,15 @@
8790
8785
  }
8791
8786
  merges.push(mergesInRow);
8792
8787
  }
8793
- return { merges };
8788
+ return { merges, sheetId };
8794
8789
  }
8795
8790
  /**
8796
8791
  * Paste the clipboard content in the given target
8797
8792
  */
8798
8793
  paste(target, content, options) {
8799
8794
  if (options.isCutOperation) {
8800
- return;
8795
+ const copiedMerges = content.merges.flat().filter(isDefined);
8796
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
8801
8797
  }
8802
8798
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
8803
8799
  }
@@ -8832,6 +8828,27 @@
8832
8828
  }
8833
8829
  }
8834
8830
 
8831
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
8832
+ copy(data) {
8833
+ return {
8834
+ zones: data.clippedZones,
8835
+ sheetId: data.sheetId,
8836
+ };
8837
+ }
8838
+ paste(target, content, options) {
8839
+ if (options.isCutOperation) {
8840
+ const selection = target.zones[0];
8841
+ this.dispatch("MOVE_RANGES", {
8842
+ target: content.zones,
8843
+ sheetId: content.sheetId,
8844
+ targetSheetId: target.sheetId,
8845
+ col: selection.left,
8846
+ row: selection.top,
8847
+ });
8848
+ }
8849
+ }
8850
+ }
8851
+
8835
8852
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
8836
8853
  isPasteAllowed(sheetId, target, content, options) {
8837
8854
  if (!("cells" in content)) {
@@ -8999,7 +9016,8 @@
8999
9016
  .add("merge", MergeClipboardHandler)
9000
9017
  .add("border", BorderClipboardHandler)
9001
9018
  .add("table", TableClipboardHandler)
9002
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
9019
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
9020
+ .add("references", ReferenceClipboardHandler);
9003
9021
 
9004
9022
  function transformZone(zone, executed) {
9005
9023
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -28436,7 +28454,7 @@ stores.inject(MyMetaStore, storeInstance);
28436
28454
  text,
28437
28455
  description: usedLabel,
28438
28456
  htmlContent: [{ value: text, color }],
28439
- fuzzySearchKey: value + usedLabel,
28457
+ fuzzySearchKey: text + usedLabel,
28440
28458
  };
28441
28459
  });
28442
28460
  },
@@ -38839,8 +38857,8 @@ stores.inject(MyMetaStore, storeInstance);
38839
38857
  this.updateRangeColor();
38840
38858
  }
38841
38859
  cancelEdition() {
38842
- this.cancelEditionAndActivateSheet();
38843
38860
  this.resetContent();
38861
+ this.cancelEditionAndActivateSheet();
38844
38862
  }
38845
38863
  setCurrentContent(content, selection) {
38846
38864
  if (selection && !this.isSelectionValid(content.length, selection.start, selection.end)) {
@@ -38856,8 +38874,8 @@ stores.inject(MyMetaStore, storeInstance);
38856
38874
  switch (cmd.type) {
38857
38875
  case "SELECT_FIGURE":
38858
38876
  if (cmd.id) {
38859
- this.cancelEditionAndActivateSheet();
38860
38877
  this.resetContent();
38878
+ this.cancelEditionAndActivateSheet();
38861
38879
  }
38862
38880
  break;
38863
38881
  case "START_CHANGE_HIGHLIGHT":
@@ -44752,6 +44770,7 @@ stores.inject(MyMetaStore, storeInstance);
44752
44770
  columns: {},
44753
44771
  });
44754
44772
  setup() {
44773
+ this.updateColumns();
44755
44774
  owl.onWillUpdateProps(() => this.updateColumns());
44756
44775
  }
44757
44776
  toggleHasHeader() {
@@ -46540,8 +46559,8 @@ stores.inject(MyMetaStore, storeInstance);
46540
46559
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
46541
46560
  if (!sheetIdExists && this.editionMode !== "inactive") {
46542
46561
  this.sheetId = this.getters.getActiveSheetId();
46543
- this.cancelEditionAndActivateSheet();
46544
46562
  this.resetContent();
46563
+ this.cancelEditionAndActivateSheet();
46545
46564
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
46546
46565
  }
46547
46566
  break;
@@ -62897,12 +62916,7 @@ stores.inject(MyMetaStore, storeInstance);
62897
62916
  }
62898
62917
  break;
62899
62918
  case "AUTORESIZE_ROWS":
62900
- this.dispatch("RESIZE_COLUMNS_ROWS", {
62901
- elements: cmd.rows,
62902
- dimension: "ROW",
62903
- size: null,
62904
- sheetId: cmd.sheetId,
62905
- });
62919
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
62906
62920
  break;
62907
62921
  }
62908
62922
  }
@@ -63067,6 +63081,48 @@ stores.inject(MyMetaStore, storeInstance);
63067
63081
  }
63068
63082
  return "Success" /* CommandResult.Success */;
63069
63083
  }
63084
+ autoResizeRows(sheetId, rows) {
63085
+ const rowSizes = [];
63086
+ for (const row of rows) {
63087
+ let evaluatedRowSize = 0;
63088
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
63089
+ const cell = this.getters.getCellById(cellId);
63090
+ if (!cell) {
63091
+ continue;
63092
+ }
63093
+ const position = this.getters.getCellPosition(cell.id);
63094
+ const colSize = this.getters.getColSize(sheetId, position.col);
63095
+ if (cell.isFormula) {
63096
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
63097
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63098
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
63099
+ evaluatedRowSize = evaluatedSize;
63100
+ }
63101
+ }
63102
+ else {
63103
+ const content = cell.content;
63104
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
63105
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
63106
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
63107
+ evaluatedRowSize = 0;
63108
+ }
63109
+ }
63110
+ }
63111
+ rowSizes.push(evaluatedRowSize || null);
63112
+ }
63113
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
63114
+ for (let i = 0; i < rowSizes.length; i++) {
63115
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
63116
+ }
63117
+ for (const [size, rows] of groupedSizes) {
63118
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
63119
+ elements: rows,
63120
+ dimension: "ROW",
63121
+ size,
63122
+ sheetId,
63123
+ });
63124
+ }
63125
+ }
63070
63126
  }
63071
63127
 
63072
63128
  class TableComputedStylePlugin extends UIPlugin {
@@ -73550,9 +73606,9 @@ stores.inject(MyMetaStore, storeInstance);
73550
73606
  exports.tokenize = tokenize;
73551
73607
 
73552
73608
 
73553
- __info__.version = "18.0.19";
73554
- __info__.date = "2025-03-12T15:33:28.300Z";
73555
- __info__.hash = "d8dea1b";
73609
+ __info__.version = "18.0.20";
73610
+ __info__.date = "2025-03-19T08:21:32.426Z";
73611
+ __info__.hash = "3f48d8b";
73556
73612
 
73557
73613
 
73558
73614
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);