@mocanvas/editor 4.12.1 → 4.12.3
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 +19 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9130,7 +9130,9 @@ var Editor = class extends EventEmitter {
|
|
|
9130
9130
|
}
|
|
9131
9131
|
if (patches.length) this.updateShapes(patches);
|
|
9132
9132
|
});
|
|
9133
|
-
|
|
9133
|
+
const duplicates = ids.map((id) => idMap.get(id));
|
|
9134
|
+
this.setSelectedShapes(duplicates);
|
|
9135
|
+
return duplicates;
|
|
9134
9136
|
}
|
|
9135
9137
|
/** Serializable content for the clipboard: shapes (with descendants) and bindings between them. */
|
|
9136
9138
|
getContentFromCurrentPage(ids) {
|
|
@@ -14849,6 +14851,8 @@ function resolveTarget(editor, point) {
|
|
|
14849
14851
|
if (filled && editor.getSelectedShapeIds().includes(filled.id)) return { target: "shape", shape: filled };
|
|
14850
14852
|
return { target: "canvas" };
|
|
14851
14853
|
}
|
|
14854
|
+
var IN_FRONT_OF_CANVAS_CLASS = "mocanvas-in-front-of-canvas";
|
|
14855
|
+
var IN_FRONT_OF_CANVAS_SELECTOR = `.${IN_FRONT_OF_CANVAS_CLASS}`;
|
|
14852
14856
|
function useCanvasEvents(editor) {
|
|
14853
14857
|
return useMemo(() => {
|
|
14854
14858
|
const pointerInfo = (e, name) => {
|
|
@@ -14865,9 +14869,12 @@ function useCanvasEvents(editor) {
|
|
|
14865
14869
|
};
|
|
14866
14870
|
};
|
|
14867
14871
|
const isHandled = (e) => editor.isEventHandled(e);
|
|
14872
|
+
const isInFrontOfCanvas = (target) => target instanceof Element && target.closest(IN_FRONT_OF_CANVAS_SELECTOR) !== null;
|
|
14873
|
+
const isElsewhere = (e) => e.currentTarget instanceof Node && e.target instanceof Node && !e.currentTarget.contains(e.target);
|
|
14874
|
+
const ownPointers = /* @__PURE__ */ new Set();
|
|
14868
14875
|
return {
|
|
14869
14876
|
onPointerDown(e) {
|
|
14870
|
-
if (isHandled(e)) return;
|
|
14877
|
+
if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
|
|
14871
14878
|
if (e.button === 2) {
|
|
14872
14879
|
editor.dispatch(pointerInfo(e, "right_click"));
|
|
14873
14880
|
return;
|
|
@@ -14875,6 +14882,7 @@ function useCanvasEvents(editor) {
|
|
|
14875
14882
|
if (e.button === 1) {
|
|
14876
14883
|
editor.dispatch(pointerInfo(e, "middle_click"));
|
|
14877
14884
|
}
|
|
14885
|
+
ownPointers.add(e.pointerId);
|
|
14878
14886
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
14879
14887
|
editor.getContainer().focus({ preventScroll: true });
|
|
14880
14888
|
const down = pointerInfo(e, "pointer_down");
|
|
@@ -14882,16 +14890,18 @@ function useCanvasEvents(editor) {
|
|
|
14882
14890
|
editor.dispatch(down);
|
|
14883
14891
|
},
|
|
14884
14892
|
onPointerMove(e) {
|
|
14885
|
-
if (isHandled(e)) return;
|
|
14893
|
+
if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
|
|
14886
14894
|
if (e.pointerType === "mouse" && e.buttons === 0 && editor.inputs.isPointing) {
|
|
14895
|
+
ownPointers.delete(e.pointerId);
|
|
14887
14896
|
editor.dispatch(pointerInfo(e, "pointer_up"));
|
|
14888
14897
|
return;
|
|
14889
14898
|
}
|
|
14890
14899
|
editor.dispatch(pointerInfo(e, "pointer_move"));
|
|
14891
14900
|
},
|
|
14892
14901
|
onPointerUp(e) {
|
|
14893
|
-
if (isHandled(e)) return;
|
|
14902
|
+
if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
|
|
14894
14903
|
if (e.button === 2) return;
|
|
14904
|
+
if (!ownPointers.delete(e.pointerId)) return;
|
|
14895
14905
|
const el = e.currentTarget;
|
|
14896
14906
|
if (el.hasPointerCapture(e.pointerId)) el.releasePointerCapture(e.pointerId);
|
|
14897
14907
|
const up = pointerInfo(e, "pointer_up");
|
|
@@ -14899,12 +14909,13 @@ function useCanvasEvents(editor) {
|
|
|
14899
14909
|
editor.click.handlePointerEvent(up);
|
|
14900
14910
|
},
|
|
14901
14911
|
onPointerCancel(e) {
|
|
14902
|
-
if (isHandled(e)) return;
|
|
14912
|
+
if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
|
|
14913
|
+
if (!ownPointers.delete(e.pointerId)) return;
|
|
14903
14914
|
editor.dispatch(pointerInfo(e, "pointer_up"));
|
|
14904
14915
|
editor.cancel();
|
|
14905
14916
|
},
|
|
14906
14917
|
onWheel(e) {
|
|
14907
|
-
if (isHandled(e)) return;
|
|
14918
|
+
if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
|
|
14908
14919
|
e.preventDefault();
|
|
14909
14920
|
const point = localPoint(editor, e);
|
|
14910
14921
|
const scale = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 400 : 1;
|
|
@@ -14918,6 +14929,7 @@ function useCanvasEvents(editor) {
|
|
|
14918
14929
|
editor.dispatch(info);
|
|
14919
14930
|
},
|
|
14920
14931
|
onContextMenu(e) {
|
|
14932
|
+
if (isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
|
|
14921
14933
|
e.preventDefault();
|
|
14922
14934
|
},
|
|
14923
14935
|
onKeyDown(e) {
|
|
@@ -15127,7 +15139,7 @@ function CanvasBody({ editor, className, style, children, components, indicatorO
|
|
|
15127
15139
|
Brush ? /* @__PURE__ */ jsx(Brush, { editor }) : null
|
|
15128
15140
|
] }),
|
|
15129
15141
|
children,
|
|
15130
|
-
InFrontOfTheCanvas ? /* @__PURE__ */ jsx("div", { className:
|
|
15142
|
+
InFrontOfTheCanvas ? /* @__PURE__ */ jsx("div", { className: IN_FRONT_OF_CANVAS_CLASS, style: { ...layerStyle, pointerEvents: "none" }, children: /* @__PURE__ */ jsx(InFrontOfTheCanvas, {}) }) : null
|
|
15131
15143
|
]
|
|
15132
15144
|
}
|
|
15133
15145
|
) });
|