@trafica/editor 1.0.52 → 1.0.53

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/index.js CHANGED
@@ -8939,6 +8939,9 @@ function prettyPrintHTML(html) {
8939
8939
  function getCellDOMElement(cellPathJson) {
8940
8940
  return document.querySelector(`[data-block-path='${cellPathJson}']`);
8941
8941
  }
8942
+ function isNonEditable(node) {
8943
+ return node.nodeType === Node.ELEMENT_NODE && node.contentEditable === "false";
8944
+ }
8942
8945
  function isCaretAtContainerStart(container) {
8943
8946
  const sel = window.getSelection();
8944
8947
  if (!sel || sel.rangeCount === 0 || !sel.isCollapsed) return false;
@@ -8946,7 +8949,11 @@ function isCaretAtContainerStart(container) {
8946
8949
  if (range.startOffset !== 0) return false;
8947
8950
  let node = range.startContainer;
8948
8951
  while (node && node !== container) {
8949
- if (node.previousSibling) return false;
8952
+ let sib = node.previousSibling;
8953
+ while (sib) {
8954
+ if (!isNonEditable(sib)) return false;
8955
+ sib = sib.previousSibling;
8956
+ }
8950
8957
  node = node.parentNode;
8951
8958
  }
8952
8959
  return node === container;
@@ -8958,11 +8965,15 @@ function isCaretAtContainerEnd(container) {
8958
8965
  const range = sel.getRangeAt(0);
8959
8966
  const endNode = range.endContainer;
8960
8967
  const endOffset = range.endOffset;
8961
- const len = endNode.nodeType === Node.TEXT_NODE ? (_b = (_a = endNode.textContent) == null ? void 0 : _a.length) != null ? _b : 0 : endNode.childNodes.length;
8968
+ const len = endNode.nodeType === Node.TEXT_NODE ? (_b = (_a = endNode.textContent) == null ? void 0 : _a.length) != null ? _b : 0 : Array.from(endNode.childNodes).filter((n) => !isNonEditable(n)).length;
8962
8969
  if (endOffset !== len) return false;
8963
8970
  let node = endNode;
8964
8971
  while (node && node !== container) {
8965
- if (node.nextSibling) return false;
8972
+ let sib = node.nextSibling;
8973
+ while (sib) {
8974
+ if (!isNonEditable(sib)) return false;
8975
+ sib = sib.nextSibling;
8976
+ }
8966
8977
  node = node.parentNode;
8967
8978
  }
8968
8979
  return node === container;