@odoo/o-spreadsheet 15.0.4 → 15.0.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.
@@ -6595,7 +6595,7 @@ const POW = {
6595
6595
  base (number) ${_lt("The number to raise to the exponent power.")}
6596
6596
  exponent (number) ${_lt("The exponent to raise base to.")}
6597
6597
  `),
6598
- returns: ["BOOLEAN"],
6598
+ returns: ["NUMBER"],
6599
6599
  compute: function (base, exponent) {
6600
6600
  return POWER.compute(base, exponent);
6601
6601
  },
@@ -24782,12 +24782,9 @@ function addFormula(cell) {
24782
24782
  else {
24783
24783
  // Shouldn't we always output the value then ?
24784
24784
  const value = cell.value;
24785
- // what if value = 0? Is this condition correct?
24786
- if (value) {
24787
- const type = getCellType(value);
24788
- attrs.push(["t", type]);
24789
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24790
- }
24785
+ const type = getCellType(value);
24786
+ attrs.push(["t", type]);
24787
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24791
24788
  return { attrs, node };
24792
24789
  }
24793
24790
  }
@@ -27080,14 +27077,31 @@ class ContentEditableHelper {
27080
27077
  * */
27081
27078
  getCurrentSelection() {
27082
27079
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27083
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27084
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27080
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27081
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27085
27082
  return {
27086
- start: startSizeBefore + startSelectionOffset,
27087
- end: endSizeBefore + endSelectionOffset,
27083
+ start: startSizeBefore,
27084
+ end: endSizeBefore,
27088
27085
  };
27089
27086
  }
27090
- findSizeBeforeElement(nodeToFind) {
27087
+ /**
27088
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27089
+ * The selected node is either a Text node or an Element node.
27090
+ *
27091
+ * case 1 -Text node:
27092
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27093
+ * content length of all previous nodes.
27094
+ *
27095
+ * case 2 - Element node:
27096
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27097
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27098
+ *
27099
+ * See the MDN documentation for more details.
27100
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27101
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27102
+ *
27103
+ */
27104
+ findSelectionIndex(nodeToFind, nodeOffset) {
27091
27105
  let it = this.iterateChildren(this.el);
27092
27106
  let usedCharacters = 0;
27093
27107
  let current = it.next();
@@ -27099,6 +27113,19 @@ class ContentEditableHelper {
27099
27113
  }
27100
27114
  current = it.next();
27101
27115
  }
27116
+ if (current.value === nodeToFind) {
27117
+ if (!current.value.hasChildNodes()) {
27118
+ usedCharacters += nodeOffset;
27119
+ }
27120
+ else {
27121
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27122
+ for (const child of children) {
27123
+ if (!child.textContent)
27124
+ continue;
27125
+ usedCharacters += child.textContent.length;
27126
+ }
27127
+ }
27128
+ }
27102
27129
  return usedCharacters;
27103
27130
  }
27104
27131
  getStartAndEndSelection() {
@@ -31369,6 +31396,6 @@ exports.registries = registries;
31369
31396
  exports.setTranslationMethod = setTranslationMethod;
31370
31397
 
31371
31398
 
31372
- __info__.version = '15.0.4';
31373
- __info__.date = '2023-04-13T08:14:04.472Z';
31374
- __info__.hash = 'f66eddd';
31399
+ __info__.version = '15.0.6';
31400
+ __info__.date = '2023-04-28T12:21:58.554Z';
31401
+ __info__.hash = 'b319dc2';
@@ -4279,7 +4279,24 @@ declare class ContentEditableHelper {
4279
4279
  start: number;
4280
4280
  end: number;
4281
4281
  };
4282
- private findSizeBeforeElement;
4282
+ /**
4283
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
4284
+ * The selected node is either a Text node or an Element node.
4285
+ *
4286
+ * case 1 -Text node:
4287
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
4288
+ * content length of all previous nodes.
4289
+ *
4290
+ * case 2 - Element node:
4291
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
4292
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
4293
+ *
4294
+ * See the MDN documentation for more details.
4295
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
4296
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
4297
+ *
4298
+ */
4299
+ private findSelectionIndex;
4283
4300
  private getStartAndEndSelection;
4284
4301
  }
4285
4302
 
@@ -6572,7 +6572,7 @@ const POW = {
6572
6572
  base (number) ${_lt("The number to raise to the exponent power.")}
6573
6573
  exponent (number) ${_lt("The exponent to raise base to.")}
6574
6574
  `),
6575
- returns: ["BOOLEAN"],
6575
+ returns: ["NUMBER"],
6576
6576
  compute: function (base, exponent) {
6577
6577
  return POWER.compute(base, exponent);
6578
6578
  },
@@ -24759,12 +24759,9 @@ function addFormula(cell) {
24759
24759
  else {
24760
24760
  // Shouldn't we always output the value then ?
24761
24761
  const value = cell.value;
24762
- // what if value = 0? Is this condition correct?
24763
- if (value) {
24764
- const type = getCellType(value);
24765
- attrs.push(["t", type]);
24766
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24767
- }
24762
+ const type = getCellType(value);
24763
+ attrs.push(["t", type]);
24764
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24768
24765
  return { attrs, node };
24769
24766
  }
24770
24767
  }
@@ -27057,14 +27054,31 @@ class ContentEditableHelper {
27057
27054
  * */
27058
27055
  getCurrentSelection() {
27059
27056
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27060
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27061
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27057
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27058
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27062
27059
  return {
27063
- start: startSizeBefore + startSelectionOffset,
27064
- end: endSizeBefore + endSelectionOffset,
27060
+ start: startSizeBefore,
27061
+ end: endSizeBefore,
27065
27062
  };
27066
27063
  }
27067
- findSizeBeforeElement(nodeToFind) {
27064
+ /**
27065
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27066
+ * The selected node is either a Text node or an Element node.
27067
+ *
27068
+ * case 1 -Text node:
27069
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27070
+ * content length of all previous nodes.
27071
+ *
27072
+ * case 2 - Element node:
27073
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27074
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27075
+ *
27076
+ * See the MDN documentation for more details.
27077
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27078
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27079
+ *
27080
+ */
27081
+ findSelectionIndex(nodeToFind, nodeOffset) {
27068
27082
  let it = this.iterateChildren(this.el);
27069
27083
  let usedCharacters = 0;
27070
27084
  let current = it.next();
@@ -27076,6 +27090,19 @@ class ContentEditableHelper {
27076
27090
  }
27077
27091
  current = it.next();
27078
27092
  }
27093
+ if (current.value === nodeToFind) {
27094
+ if (!current.value.hasChildNodes()) {
27095
+ usedCharacters += nodeOffset;
27096
+ }
27097
+ else {
27098
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27099
+ for (const child of children) {
27100
+ if (!child.textContent)
27101
+ continue;
27102
+ usedCharacters += child.textContent.length;
27103
+ }
27104
+ }
27105
+ }
27079
27106
  return usedCharacters;
27080
27107
  }
27081
27108
  getStartAndEndSelection() {
@@ -31324,6 +31351,6 @@ const helpers = {
31324
31351
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, normalize, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31325
31352
 
31326
31353
 
31327
- __info__.version = '15.0.4';
31328
- __info__.date = '2023-04-13T08:14:04.472Z';
31329
- __info__.hash = 'f66eddd';
31354
+ __info__.version = '15.0.6';
31355
+ __info__.date = '2023-04-28T12:21:58.554Z';
31356
+ __info__.hash = 'b319dc2';
@@ -6592,7 +6592,7 @@
6592
6592
  base (number) ${_lt("The number to raise to the exponent power.")}
6593
6593
  exponent (number) ${_lt("The exponent to raise base to.")}
6594
6594
  `),
6595
- returns: ["BOOLEAN"],
6595
+ returns: ["NUMBER"],
6596
6596
  compute: function (base, exponent) {
6597
6597
  return POWER.compute(base, exponent);
6598
6598
  },
@@ -24779,12 +24779,9 @@
24779
24779
  else {
24780
24780
  // Shouldn't we always output the value then ?
24781
24781
  const value = cell.value;
24782
- // what if value = 0? Is this condition correct?
24783
- if (value) {
24784
- const type = getCellType(value);
24785
- attrs.push(["t", type]);
24786
- node = escapeXml /*xml*/ `<v>${value}</v>`;
24787
- }
24782
+ const type = getCellType(value);
24783
+ attrs.push(["t", type]);
24784
+ node = escapeXml /*xml*/ `<v>${value}</v>`;
24788
24785
  return { attrs, node };
24789
24786
  }
24790
24787
  }
@@ -27077,14 +27074,31 @@
27077
27074
  * */
27078
27075
  getCurrentSelection() {
27079
27076
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27080
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27081
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27077
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27078
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27082
27079
  return {
27083
- start: startSizeBefore + startSelectionOffset,
27084
- end: endSizeBefore + endSelectionOffset,
27080
+ start: startSizeBefore,
27081
+ end: endSizeBefore,
27085
27082
  };
27086
27083
  }
27087
- findSizeBeforeElement(nodeToFind) {
27084
+ /**
27085
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27086
+ * The selected node is either a Text node or an Element node.
27087
+ *
27088
+ * case 1 -Text node:
27089
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27090
+ * content length of all previous nodes.
27091
+ *
27092
+ * case 2 - Element node:
27093
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27094
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27095
+ *
27096
+ * See the MDN documentation for more details.
27097
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27098
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27099
+ *
27100
+ */
27101
+ findSelectionIndex(nodeToFind, nodeOffset) {
27088
27102
  let it = this.iterateChildren(this.el);
27089
27103
  let usedCharacters = 0;
27090
27104
  let current = it.next();
@@ -27096,6 +27110,19 @@
27096
27110
  }
27097
27111
  current = it.next();
27098
27112
  }
27113
+ if (current.value === nodeToFind) {
27114
+ if (!current.value.hasChildNodes()) {
27115
+ usedCharacters += nodeOffset;
27116
+ }
27117
+ else {
27118
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27119
+ for (const child of children) {
27120
+ if (!child.textContent)
27121
+ continue;
27122
+ usedCharacters += child.textContent.length;
27123
+ }
27124
+ }
27125
+ }
27099
27126
  return usedCharacters;
27100
27127
  }
27101
27128
  getStartAndEndSelection() {
@@ -31368,9 +31395,9 @@
31368
31395
  Object.defineProperty(exports, '__esModule', { value: true });
31369
31396
 
31370
31397
 
31371
- __info__.version = '15.0.4';
31372
- __info__.date = '2023-04-13T08:14:04.472Z';
31373
- __info__.hash = 'f66eddd';
31398
+ __info__.version = '15.0.6';
31399
+ __info__.date = '2023-04-28T12:21:58.554Z';
31400
+ __info__.hash = 'b319dc2';
31374
31401
 
31375
31402
 
31376
31403
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);