@mocanvas/editor 4.12.2 → 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 CHANGED
@@ -9130,7 +9130,9 @@ var Editor = class extends EventEmitter {
9130
9130
  }
9131
9131
  if (patches.length) this.updateShapes(patches);
9132
9132
  });
9133
- return ids.map((id) => idMap.get(id));
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) {
@@ -14868,9 +14870,11 @@ function useCanvasEvents(editor) {
14868
14870
  };
14869
14871
  const isHandled = (e) => editor.isEventHandled(e);
14870
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();
14871
14875
  return {
14872
14876
  onPointerDown(e) {
14873
- if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14877
+ if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
14874
14878
  if (e.button === 2) {
14875
14879
  editor.dispatch(pointerInfo(e, "right_click"));
14876
14880
  return;
@@ -14878,6 +14882,7 @@ function useCanvasEvents(editor) {
14878
14882
  if (e.button === 1) {
14879
14883
  editor.dispatch(pointerInfo(e, "middle_click"));
14880
14884
  }
14885
+ ownPointers.add(e.pointerId);
14881
14886
  e.currentTarget.setPointerCapture(e.pointerId);
14882
14887
  editor.getContainer().focus({ preventScroll: true });
14883
14888
  const down = pointerInfo(e, "pointer_down");
@@ -14885,16 +14890,18 @@ function useCanvasEvents(editor) {
14885
14890
  editor.dispatch(down);
14886
14891
  },
14887
14892
  onPointerMove(e) {
14888
- if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14893
+ if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
14889
14894
  if (e.pointerType === "mouse" && e.buttons === 0 && editor.inputs.isPointing) {
14895
+ ownPointers.delete(e.pointerId);
14890
14896
  editor.dispatch(pointerInfo(e, "pointer_up"));
14891
14897
  return;
14892
14898
  }
14893
14899
  editor.dispatch(pointerInfo(e, "pointer_move"));
14894
14900
  },
14895
14901
  onPointerUp(e) {
14896
- if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14902
+ if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
14897
14903
  if (e.button === 2) return;
14904
+ if (!ownPointers.delete(e.pointerId)) return;
14898
14905
  const el = e.currentTarget;
14899
14906
  if (el.hasPointerCapture(e.pointerId)) el.releasePointerCapture(e.pointerId);
14900
14907
  const up = pointerInfo(e, "pointer_up");
@@ -14902,12 +14909,13 @@ function useCanvasEvents(editor) {
14902
14909
  editor.click.handlePointerEvent(up);
14903
14910
  },
14904
14911
  onPointerCancel(e) {
14905
- if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14912
+ if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
14913
+ if (!ownPointers.delete(e.pointerId)) return;
14906
14914
  editor.dispatch(pointerInfo(e, "pointer_up"));
14907
14915
  editor.cancel();
14908
14916
  },
14909
14917
  onWheel(e) {
14910
- if (isHandled(e) || isInFrontOfCanvas(e.target)) return;
14918
+ if (isHandled(e) || isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
14911
14919
  e.preventDefault();
14912
14920
  const point = localPoint(editor, e);
14913
14921
  const scale = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 400 : 1;
@@ -14921,7 +14929,7 @@ function useCanvasEvents(editor) {
14921
14929
  editor.dispatch(info);
14922
14930
  },
14923
14931
  onContextMenu(e) {
14924
- if (isInFrontOfCanvas(e.target)) return;
14932
+ if (isInFrontOfCanvas(e.target) || isElsewhere(e)) return;
14925
14933
  e.preventDefault();
14926
14934
  },
14927
14935
  onKeyDown(e) {