@trafica/editor 1.0.51 → 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 +20 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8655,8 +8655,10 @@ function EditorCore({
|
|
|
8655
8655
|
const figH = (fig == null ? void 0 : fig.offsetHeight) || drag.ghostH;
|
|
8656
8656
|
const rawX = e.clientX - cr.left - drag.offsetX + container.scrollLeft;
|
|
8657
8657
|
const rawY = e.clientY - cr.top - drag.offsetY + container.scrollTop;
|
|
8658
|
+
const editorH = editorRootRef.current ? editorRootRef.current.offsetHeight - (cr.top - editorRootRef.current.getBoundingClientRect().top) : container.offsetHeight;
|
|
8659
|
+
const maxH = Math.max(container.offsetHeight, editorH);
|
|
8658
8660
|
const x = Math.max(0, Math.min(rawX, container.clientWidth - figW));
|
|
8659
|
-
const y = Math.max(0, Math.min(rawY,
|
|
8661
|
+
const y = Math.max(0, Math.min(rawY, maxH - figH));
|
|
8660
8662
|
if (fig) {
|
|
8661
8663
|
fig.style.position = "absolute";
|
|
8662
8664
|
fig.style.left = `${x}px`;
|
|
@@ -8682,8 +8684,10 @@ function EditorCore({
|
|
|
8682
8684
|
const figH = (fig == null ? void 0 : fig.offsetHeight) || drag.ghostH;
|
|
8683
8685
|
const rawX = e.clientX - cr.left - drag.offsetX + container.scrollLeft;
|
|
8684
8686
|
const rawY = e.clientY - cr.top - drag.offsetY + container.scrollTop;
|
|
8687
|
+
const editorH = editorRootRef.current ? editorRootRef.current.offsetHeight - (cr.top - editorRootRef.current.getBoundingClientRect().top) : container.offsetHeight;
|
|
8688
|
+
const maxH = Math.max(container.offsetHeight, editorH);
|
|
8685
8689
|
const x = Math.max(0, Math.min(rawX, container.clientWidth - figW));
|
|
8686
|
-
const y = Math.max(0, Math.min(rawY,
|
|
8690
|
+
const y = Math.max(0, Math.min(rawY, maxH - figH));
|
|
8687
8691
|
setImageAttr(drag.imagePath, { x: Math.round(x), y: Math.round(y) })(engine);
|
|
8688
8692
|
};
|
|
8689
8693
|
document.addEventListener("mousemove", onMouseMove);
|
|
@@ -8935,6 +8939,9 @@ function prettyPrintHTML(html) {
|
|
|
8935
8939
|
function getCellDOMElement(cellPathJson) {
|
|
8936
8940
|
return document.querySelector(`[data-block-path='${cellPathJson}']`);
|
|
8937
8941
|
}
|
|
8942
|
+
function isNonEditable(node) {
|
|
8943
|
+
return node.nodeType === Node.ELEMENT_NODE && node.contentEditable === "false";
|
|
8944
|
+
}
|
|
8938
8945
|
function isCaretAtContainerStart(container) {
|
|
8939
8946
|
const sel = window.getSelection();
|
|
8940
8947
|
if (!sel || sel.rangeCount === 0 || !sel.isCollapsed) return false;
|
|
@@ -8942,7 +8949,11 @@ function isCaretAtContainerStart(container) {
|
|
|
8942
8949
|
if (range.startOffset !== 0) return false;
|
|
8943
8950
|
let node = range.startContainer;
|
|
8944
8951
|
while (node && node !== container) {
|
|
8945
|
-
|
|
8952
|
+
let sib = node.previousSibling;
|
|
8953
|
+
while (sib) {
|
|
8954
|
+
if (!isNonEditable(sib)) return false;
|
|
8955
|
+
sib = sib.previousSibling;
|
|
8956
|
+
}
|
|
8946
8957
|
node = node.parentNode;
|
|
8947
8958
|
}
|
|
8948
8959
|
return node === container;
|
|
@@ -8954,11 +8965,15 @@ function isCaretAtContainerEnd(container) {
|
|
|
8954
8965
|
const range = sel.getRangeAt(0);
|
|
8955
8966
|
const endNode = range.endContainer;
|
|
8956
8967
|
const endOffset = range.endOffset;
|
|
8957
|
-
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;
|
|
8958
8969
|
if (endOffset !== len) return false;
|
|
8959
8970
|
let node = endNode;
|
|
8960
8971
|
while (node && node !== container) {
|
|
8961
|
-
|
|
8972
|
+
let sib = node.nextSibling;
|
|
8973
|
+
while (sib) {
|
|
8974
|
+
if (!isNonEditable(sib)) return false;
|
|
8975
|
+
sib = sib.nextSibling;
|
|
8976
|
+
}
|
|
8962
8977
|
node = node.parentNode;
|
|
8963
8978
|
}
|
|
8964
8979
|
return node === container;
|