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