@odoo/o-spreadsheet 15.2.4 → 15.2.6

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.
@@ -6613,7 +6613,7 @@ const POW = {
6613
6613
  base (number) ${_lt("The number to raise to the exponent power.")}
6614
6614
  exponent (number) ${_lt("The exponent to raise base to.")}
6615
6615
  `),
6616
- returns: ["BOOLEAN"],
6616
+ returns: ["NUMBER"],
6617
6617
  compute: function (base, exponent) {
6618
6618
  return POWER.compute(base, exponent);
6619
6619
  },
@@ -24694,12 +24694,9 @@ function addFormula(cell) {
24694
24694
  else {
24695
24695
  // Shouldn't we always output the value then ?
24696
24696
  const value = cell.value;
24697
- // what if value = 0? Is this condition correct?
24698
- if (value) {
24699
- const type = getCellType(value);
24700
- attrs.push(["t", type]);
24701
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24702
- }
24697
+ const type = getCellType(value);
24698
+ attrs.push(["t", type]);
24699
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24703
24700
  return { attrs, node };
24704
24701
  }
24705
24702
  }
@@ -27022,14 +27019,31 @@ class ContentEditableHelper {
27022
27019
  * */
27023
27020
  getCurrentSelection() {
27024
27021
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27025
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27026
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27022
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27023
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27027
27024
  return {
27028
- start: startSizeBefore + startSelectionOffset,
27029
- end: endSizeBefore + endSelectionOffset,
27025
+ start: startSizeBefore,
27026
+ end: endSizeBefore,
27030
27027
  };
27031
27028
  }
27032
- findSizeBeforeElement(nodeToFind) {
27029
+ /**
27030
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27031
+ * The selected node is either a Text node or an Element node.
27032
+ *
27033
+ * case 1 -Text node:
27034
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27035
+ * content length of all previous nodes.
27036
+ *
27037
+ * case 2 - Element node:
27038
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27039
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27040
+ *
27041
+ * See the MDN documentation for more details.
27042
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27043
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27044
+ *
27045
+ */
27046
+ findSelectionIndex(nodeToFind, nodeOffset) {
27033
27047
  let it = this.iterateChildren(this.el);
27034
27048
  let usedCharacters = 0;
27035
27049
  let current = it.next();
@@ -27041,6 +27055,19 @@ class ContentEditableHelper {
27041
27055
  }
27042
27056
  current = it.next();
27043
27057
  }
27058
+ if (current.value === nodeToFind) {
27059
+ if (!current.value.hasChildNodes()) {
27060
+ usedCharacters += nodeOffset;
27061
+ }
27062
+ else {
27063
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27064
+ for (const child of children) {
27065
+ if (!child.textContent)
27066
+ continue;
27067
+ usedCharacters += child.textContent.length;
27068
+ }
27069
+ }
27070
+ }
27044
27071
  return usedCharacters;
27045
27072
  }
27046
27073
  getStartAndEndSelection() {
@@ -31302,6 +31329,6 @@ exports.registries = registries;
31302
31329
  exports.setTranslationMethod = setTranslationMethod;
31303
31330
 
31304
31331
 
31305
- __info__.version = '15.2.4';
31306
- __info__.date = '2023-04-13T08:15:24.992Z';
31307
- __info__.hash = '23f0126';
31332
+ __info__.version = '15.2.6';
31333
+ __info__.date = '2023-04-28T12:21:51.546Z';
31334
+ __info__.hash = 'cb8f763';
@@ -4288,7 +4288,24 @@ declare class ContentEditableHelper {
4288
4288
  start: number;
4289
4289
  end: number;
4290
4290
  };
4291
- private findSizeBeforeElement;
4291
+ /**
4292
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
4293
+ * The selected node is either a Text node or an Element node.
4294
+ *
4295
+ * case 1 -Text node:
4296
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
4297
+ * content length of all previous nodes.
4298
+ *
4299
+ * case 2 - Element node:
4300
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
4301
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
4302
+ *
4303
+ * See the MDN documentation for more details.
4304
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
4305
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
4306
+ *
4307
+ */
4308
+ private findSelectionIndex;
4292
4309
  private getStartAndEndSelection;
4293
4310
  }
4294
4311
 
@@ -6590,7 +6590,7 @@ const POW = {
6590
6590
  base (number) ${_lt("The number to raise to the exponent power.")}
6591
6591
  exponent (number) ${_lt("The exponent to raise base to.")}
6592
6592
  `),
6593
- returns: ["BOOLEAN"],
6593
+ returns: ["NUMBER"],
6594
6594
  compute: function (base, exponent) {
6595
6595
  return POWER.compute(base, exponent);
6596
6596
  },
@@ -24671,12 +24671,9 @@ function addFormula(cell) {
24671
24671
  else {
24672
24672
  // Shouldn't we always output the value then ?
24673
24673
  const value = cell.value;
24674
- // what if value = 0? Is this condition correct?
24675
- if (value) {
24676
- const type = getCellType(value);
24677
- attrs.push(["t", type]);
24678
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24679
- }
24674
+ const type = getCellType(value);
24675
+ attrs.push(["t", type]);
24676
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24680
24677
  return { attrs, node };
24681
24678
  }
24682
24679
  }
@@ -26999,14 +26996,31 @@ class ContentEditableHelper {
26999
26996
  * */
27000
26997
  getCurrentSelection() {
27001
26998
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27002
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27003
- let endSizeBefore = this.findSizeBeforeElement(endElement);
26999
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27000
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27004
27001
  return {
27005
- start: startSizeBefore + startSelectionOffset,
27006
- end: endSizeBefore + endSelectionOffset,
27002
+ start: startSizeBefore,
27003
+ end: endSizeBefore,
27007
27004
  };
27008
27005
  }
27009
- findSizeBeforeElement(nodeToFind) {
27006
+ /**
27007
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27008
+ * The selected node is either a Text node or an Element node.
27009
+ *
27010
+ * case 1 -Text node:
27011
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27012
+ * content length of all previous nodes.
27013
+ *
27014
+ * case 2 - Element node:
27015
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27016
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27017
+ *
27018
+ * See the MDN documentation for more details.
27019
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27020
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27021
+ *
27022
+ */
27023
+ findSelectionIndex(nodeToFind, nodeOffset) {
27010
27024
  let it = this.iterateChildren(this.el);
27011
27025
  let usedCharacters = 0;
27012
27026
  let current = it.next();
@@ -27018,6 +27032,19 @@ class ContentEditableHelper {
27018
27032
  }
27019
27033
  current = it.next();
27020
27034
  }
27035
+ if (current.value === nodeToFind) {
27036
+ if (!current.value.hasChildNodes()) {
27037
+ usedCharacters += nodeOffset;
27038
+ }
27039
+ else {
27040
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27041
+ for (const child of children) {
27042
+ if (!child.textContent)
27043
+ continue;
27044
+ usedCharacters += child.textContent.length;
27045
+ }
27046
+ }
27047
+ }
27021
27048
  return usedCharacters;
27022
27049
  }
27023
27050
  getStartAndEndSelection() {
@@ -31256,6 +31283,6 @@ const helpers = {
31256
31283
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31257
31284
 
31258
31285
 
31259
- __info__.version = '15.2.4';
31260
- __info__.date = '2023-04-13T08:15:24.992Z';
31261
- __info__.hash = '23f0126';
31286
+ __info__.version = '15.2.6';
31287
+ __info__.date = '2023-04-28T12:21:51.546Z';
31288
+ __info__.hash = 'cb8f763';
@@ -6610,7 +6610,7 @@
6610
6610
  base (number) ${_lt("The number to raise to the exponent power.")}
6611
6611
  exponent (number) ${_lt("The exponent to raise base to.")}
6612
6612
  `),
6613
- returns: ["BOOLEAN"],
6613
+ returns: ["NUMBER"],
6614
6614
  compute: function (base, exponent) {
6615
6615
  return POWER.compute(base, exponent);
6616
6616
  },
@@ -24691,12 +24691,9 @@
24691
24691
  else {
24692
24692
  // Shouldn't we always output the value then ?
24693
24693
  const value = cell.value;
24694
- // what if value = 0? Is this condition correct?
24695
- if (value) {
24696
- const type = getCellType(value);
24697
- attrs.push(["t", type]);
24698
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24699
- }
24694
+ const type = getCellType(value);
24695
+ attrs.push(["t", type]);
24696
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24700
24697
  return { attrs, node };
24701
24698
  }
24702
24699
  }
@@ -27019,14 +27016,31 @@
27019
27016
  * */
27020
27017
  getCurrentSelection() {
27021
27018
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27022
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27023
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27019
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27020
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27024
27021
  return {
27025
- start: startSizeBefore + startSelectionOffset,
27026
- end: endSizeBefore + endSelectionOffset,
27022
+ start: startSizeBefore,
27023
+ end: endSizeBefore,
27027
27024
  };
27028
27025
  }
27029
- findSizeBeforeElement(nodeToFind) {
27026
+ /**
27027
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27028
+ * The selected node is either a Text node or an Element node.
27029
+ *
27030
+ * case 1 -Text node:
27031
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27032
+ * content length of all previous nodes.
27033
+ *
27034
+ * case 2 - Element node:
27035
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27036
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27037
+ *
27038
+ * See the MDN documentation for more details.
27039
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27040
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27041
+ *
27042
+ */
27043
+ findSelectionIndex(nodeToFind, nodeOffset) {
27030
27044
  let it = this.iterateChildren(this.el);
27031
27045
  let usedCharacters = 0;
27032
27046
  let current = it.next();
@@ -27038,6 +27052,19 @@
27038
27052
  }
27039
27053
  current = it.next();
27040
27054
  }
27055
+ if (current.value === nodeToFind) {
27056
+ if (!current.value.hasChildNodes()) {
27057
+ usedCharacters += nodeOffset;
27058
+ }
27059
+ else {
27060
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27061
+ for (const child of children) {
27062
+ if (!child.textContent)
27063
+ continue;
27064
+ usedCharacters += child.textContent.length;
27065
+ }
27066
+ }
27067
+ }
27041
27068
  return usedCharacters;
27042
27069
  }
27043
27070
  getStartAndEndSelection() {
@@ -31301,9 +31328,9 @@
31301
31328
  Object.defineProperty(exports, '__esModule', { value: true });
31302
31329
 
31303
31330
 
31304
- __info__.version = '15.2.4';
31305
- __info__.date = '2023-04-13T08:15:24.992Z';
31306
- __info__.hash = '23f0126';
31331
+ __info__.version = '15.2.6';
31332
+ __info__.date = '2023-04-28T12:21:51.546Z';
31333
+ __info__.hash = 'cb8f763';
31307
31334
 
31308
31335
 
31309
31336
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);