@trafica/editor 1.0.52 → 1.0.54

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
@@ -7739,7 +7739,6 @@ function ImageToolbar({ engine, imagePath, editorContainer, onClose }) {
7739
7739
  const top = Math.max(4, rect.top - toolbarH - 6);
7740
7740
  toolbar.style.top = `${top}px`;
7741
7741
  toolbar.style.left = `${rect.left}px`;
7742
- toolbar.style.minWidth = `${rect.width}px`;
7743
7742
  toolbar.style.visibility = "visible";
7744
7743
  });
7745
7744
  const run = (attrs) => {
@@ -8939,6 +8938,9 @@ function prettyPrintHTML(html) {
8939
8938
  function getCellDOMElement(cellPathJson) {
8940
8939
  return document.querySelector(`[data-block-path='${cellPathJson}']`);
8941
8940
  }
8941
+ function isNonEditable(node) {
8942
+ return node.nodeType === Node.ELEMENT_NODE && node.contentEditable === "false";
8943
+ }
8942
8944
  function isCaretAtContainerStart(container) {
8943
8945
  const sel = window.getSelection();
8944
8946
  if (!sel || sel.rangeCount === 0 || !sel.isCollapsed) return false;
@@ -8946,7 +8948,11 @@ function isCaretAtContainerStart(container) {
8946
8948
  if (range.startOffset !== 0) return false;
8947
8949
  let node = range.startContainer;
8948
8950
  while (node && node !== container) {
8949
- if (node.previousSibling) return false;
8951
+ let sib = node.previousSibling;
8952
+ while (sib) {
8953
+ if (!isNonEditable(sib)) return false;
8954
+ sib = sib.previousSibling;
8955
+ }
8950
8956
  node = node.parentNode;
8951
8957
  }
8952
8958
  return node === container;
@@ -8958,11 +8964,15 @@ function isCaretAtContainerEnd(container) {
8958
8964
  const range = sel.getRangeAt(0);
8959
8965
  const endNode = range.endContainer;
8960
8966
  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;
8967
+ 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
8968
  if (endOffset !== len) return false;
8963
8969
  let node = endNode;
8964
8970
  while (node && node !== container) {
8965
- if (node.nextSibling) return false;
8971
+ let sib = node.nextSibling;
8972
+ while (sib) {
8973
+ if (!isNonEditable(sib)) return false;
8974
+ sib = sib.nextSibling;
8975
+ }
8966
8976
  node = node.parentNode;
8967
8977
  }
8968
8978
  return node === container;