@trafica/editor 1.0.48 → 1.0.50

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
@@ -8648,11 +8648,15 @@ function EditorCore({
8648
8648
  const container = containerRef.current;
8649
8649
  if (!container) return;
8650
8650
  const cr = container.getBoundingClientRect();
8651
- const x = Math.max(0, e.clientX - cr.left - drag.offsetX + container.scrollLeft);
8652
- const y = Math.max(0, e.clientY - cr.top - drag.offsetY + container.scrollTop);
8653
8651
  const fig = container.querySelector(
8654
8652
  `[data-image-path="${JSON.stringify(drag.imagePath)}"]`
8655
8653
  );
8654
+ const figW = (fig == null ? void 0 : fig.offsetWidth) || drag.ghostW;
8655
+ const figH = (fig == null ? void 0 : fig.offsetHeight) || drag.ghostH;
8656
+ const rawX = e.clientX - cr.left - drag.offsetX + container.scrollLeft;
8657
+ const rawY = e.clientY - cr.top - drag.offsetY + container.scrollTop;
8658
+ const x = Math.max(0, Math.min(rawX, container.clientWidth - figW));
8659
+ const y = Math.max(0, Math.min(rawY, container.offsetHeight - figH));
8656
8660
  if (fig) {
8657
8661
  fig.style.position = "absolute";
8658
8662
  fig.style.left = `${x}px`;
@@ -8671,8 +8675,15 @@ function EditorCore({
8671
8675
  const container = containerRef.current;
8672
8676
  if (!container) return;
8673
8677
  const cr = container.getBoundingClientRect();
8674
- const x = Math.max(0, e.clientX - cr.left - drag.offsetX + container.scrollLeft);
8675
- const y = Math.max(0, e.clientY - cr.top - drag.offsetY + container.scrollTop);
8678
+ const fig = container.querySelector(
8679
+ `[data-image-path="${JSON.stringify(drag.imagePath)}"]`
8680
+ );
8681
+ const figW = (fig == null ? void 0 : fig.offsetWidth) || drag.ghostW;
8682
+ const figH = (fig == null ? void 0 : fig.offsetHeight) || drag.ghostH;
8683
+ const rawX = e.clientX - cr.left - drag.offsetX + container.scrollLeft;
8684
+ const rawY = e.clientY - cr.top - drag.offsetY + container.scrollTop;
8685
+ const x = Math.max(0, Math.min(rawX, container.clientWidth - figW));
8686
+ const y = Math.max(0, Math.min(rawY, container.offsetHeight - figH));
8676
8687
  setImageAttr(drag.imagePath, { x: Math.round(x), y: Math.round(y) })(engine);
8677
8688
  };
8678
8689
  document.addEventListener("mousemove", onMouseMove);