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