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