@mocanvas/editor 4.12.1 → 4.12.2

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
@@ -14849,6 +14849,8 @@ function resolveTarget(editor, point) {
14849
14849
  if (filled && editor.getSelectedShapeIds().includes(filled.id)) return { target: "shape", shape: filled };
14850
14850
  return { target: "canvas" };
14851
14851
  }
14852
+ var IN_FRONT_OF_CANVAS_CLASS = "mocanvas-in-front-of-canvas";
14853
+ var IN_FRONT_OF_CANVAS_SELECTOR = `.${IN_FRONT_OF_CANVAS_CLASS}`;
14852
14854
  function useCanvasEvents(editor) {
14853
14855
  return useMemo(() => {
14854
14856
  const pointerInfo = (e, name) => {
@@ -14865,9 +14867,10 @@ function useCanvasEvents(editor) {
14865
14867
  };
14866
14868
  };
14867
14869
  const isHandled = (e) => editor.isEventHandled(e);
14870
+ const isInFrontOfCanvas = (target) => target instanceof Element && target.closest(IN_FRONT_OF_CANVAS_SELECTOR) !== null;
14868
14871
  return {
14869
14872
  onPointerDown(e) {
14870
- if (isHandled(e)) return;
14873
+ if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14871
14874
  if (e.button === 2) {
14872
14875
  editor.dispatch(pointerInfo(e, "right_click"));
14873
14876
  return;
@@ -14882,7 +14885,7 @@ function useCanvasEvents(editor) {
14882
14885
  editor.dispatch(down);
14883
14886
  },
14884
14887
  onPointerMove(e) {
14885
- if (isHandled(e)) return;
14888
+ if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14886
14889
  if (e.pointerType === "mouse" && e.buttons === 0 && editor.inputs.isPointing) {
14887
14890
  editor.dispatch(pointerInfo(e, "pointer_up"));
14888
14891
  return;
@@ -14890,7 +14893,7 @@ function useCanvasEvents(editor) {
14890
14893
  editor.dispatch(pointerInfo(e, "pointer_move"));
14891
14894
  },
14892
14895
  onPointerUp(e) {
14893
- if (isHandled(e)) return;
14896
+ if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14894
14897
  if (e.button === 2) return;
14895
14898
  const el = e.currentTarget;
14896
14899
  if (el.hasPointerCapture(e.pointerId)) el.releasePointerCapture(e.pointerId);
@@ -14899,12 +14902,12 @@ function useCanvasEvents(editor) {
14899
14902
  editor.click.handlePointerEvent(up);
14900
14903
  },
14901
14904
  onPointerCancel(e) {
14902
- if (isHandled(e)) return;
14905
+ if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14903
14906
  editor.dispatch(pointerInfo(e, "pointer_up"));
14904
14907
  editor.cancel();
14905
14908
  },
14906
14909
  onWheel(e) {
14907
- if (isHandled(e)) return;
14910
+ if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14908
14911
  e.preventDefault();
14909
14912
  const point = localPoint(editor, e);
14910
14913
  const scale = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 400 : 1;
@@ -14918,6 +14921,7 @@ function useCanvasEvents(editor) {
14918
14921
  editor.dispatch(info);
14919
14922
  },
14920
14923
  onContextMenu(e) {
14924
+ if (isInFrontOfCanvas(e.target)) return;
14921
14925
  e.preventDefault();
14922
14926
  },
14923
14927
  onKeyDown(e) {
@@ -15127,7 +15131,7 @@ function CanvasBody({ editor, className, style, children, components, indicatorO
15127
15131
  Brush ? /* @__PURE__ */ jsx(Brush, { editor }) : null
15128
15132
  ] }),
15129
15133
  children,
15130
- InFrontOfTheCanvas ? /* @__PURE__ */ jsx("div", { className: "mocanvas-in-front-of-canvas", style: { ...layerStyle, pointerEvents: "none" }, children: /* @__PURE__ */ jsx(InFrontOfTheCanvas, {}) }) : null
15134
+ InFrontOfTheCanvas ? /* @__PURE__ */ jsx("div", { className: IN_FRONT_OF_CANVAS_CLASS, style: { ...layerStyle, pointerEvents: "none" }, children: /* @__PURE__ */ jsx(InFrontOfTheCanvas, {}) }) : null
15131
15135
  ]
15132
15136
  }
15133
15137
  ) });