@inditextech/weave-sdk 0.32.0 → 0.34.0

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/sdk.cjs CHANGED
@@ -15646,6 +15646,7 @@ const WEAVE_NODES_SELECTION_LAYER_ID = "selectionLayer";
15646
15646
  const WEAVE_CONTEXT_MENU_KEY = "contextMenu";
15647
15647
  const WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT = 4;
15648
15648
  const WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT = 4;
15649
+ const WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT = 500;
15649
15650
 
15650
15651
  //#endregion
15651
15652
  //#region src/plugins/context-menu/context-menu.ts
@@ -15657,13 +15658,14 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15657
15658
  this.touchTimer = void 0;
15658
15659
  this.tapHold = false;
15659
15660
  this.contextMenuVisible = false;
15660
- this.tapHoldTimeout = 500;
15661
+ this.tapHoldTimeout = WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT;
15661
15662
  const { config } = params ?? {};
15662
15663
  this.config = {
15663
15664
  xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
15664
15665
  yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
15665
15666
  ...config
15666
15667
  };
15668
+ this.pointers = {};
15667
15669
  }
15668
15670
  getName() {
15669
15671
  return WEAVE_CONTEXT_MENU_KEY;
@@ -15681,9 +15683,8 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15681
15683
  const mousePos = stage.getPointerPosition();
15682
15684
  if (mousePos && mousePos.x >= box.x && mousePos.x <= box.x + box.width && mousePos.y >= box.y && mousePos.y <= box.y + box.height) clickOnTransformer = true;
15683
15685
  }
15684
- if (target !== stage && !clickOnTransformer) return;
15685
15686
  let nodes = [];
15686
- if (clickOnTransformer && selectionPlugin) {
15687
+ if (target !== stage && clickOnTransformer && selectionPlugin) {
15687
15688
  const transformer = selectionPlugin.getTransformer();
15688
15689
  nodes = transformer.getNodes().map((node) => {
15689
15690
  const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
@@ -15693,6 +15694,13 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15693
15694
  };
15694
15695
  }).filter((node) => typeof node !== "undefined");
15695
15696
  }
15697
+ if (target !== stage && !clickOnTransformer) {
15698
+ const nodeHandler = this.instance.getNodeHandler(target.getAttrs().nodeType);
15699
+ nodes = [{
15700
+ instance: target,
15701
+ node: nodeHandler?.serialize(target)
15702
+ }];
15703
+ }
15696
15704
  const containerRect = stage.container().getBoundingClientRect();
15697
15705
  const pointerPos = stage.getPointerPosition();
15698
15706
  if (containerRect && pointerPos) {
@@ -15721,28 +15729,24 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15721
15729
  }
15722
15730
  initEvents() {
15723
15731
  const stage = this.instance.getStage();
15724
- stage.on("touchstart", (e) => {
15725
- e.evt.preventDefault();
15726
- if (e.evt instanceof TouchEvent && e.evt.touches && e.evt.touches.length > 1) {
15727
- if (this.touchTimer) clearTimeout(this.touchTimer);
15728
- return;
15729
- }
15732
+ stage.on("pointerdown", (e) => {
15733
+ this.pointers[e.evt.pointerId] = e.evt;
15734
+ if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
15730
15735
  this.touchTimer = setTimeout(() => {
15731
15736
  this.tapHold = true;
15732
15737
  this.triggerContextMenu(e.target);
15733
15738
  }, this.tapHoldTimeout);
15734
15739
  });
15735
- stage.on("touchmove", () => {
15740
+ stage.on("pointermove", () => {
15736
15741
  if (this.touchTimer) clearTimeout(this.touchTimer);
15737
15742
  });
15738
- stage.on("touchend", (e) => {
15739
- e.evt.preventDefault();
15740
- if (e.evt instanceof TouchEvent && e.evt.touches && e.evt.touches.length > 1) {
15741
- if (this.touchTimer) clearTimeout(this.touchTimer);
15742
- return;
15743
+ stage.on("pointerup", (e) => {
15744
+ delete this.pointers[e.evt.pointerId];
15745
+ if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length + 1 > 1) return;
15746
+ if (this.touchTimer) {
15747
+ clearTimeout(this.touchTimer);
15748
+ this.tapHold = false;
15743
15749
  }
15744
- if (this.touchTimer) clearTimeout(this.touchTimer);
15745
- if (this.tapHold) this.tapHold = false;
15746
15750
  });
15747
15751
  stage.on("contextmenu", (e) => {
15748
15752
  e.evt.preventDefault();
@@ -15805,6 +15809,8 @@ function checkIfOverContainer(instance, node) {
15805
15809
  }
15806
15810
  function moveNodeToContainer(instance, node) {
15807
15811
  const nodeIntersected = instance.pointIntersectsContainerElement();
15812
+ const isLocked = instance.allNodesLocked([node]);
15813
+ if (isLocked) return;
15808
15814
  let nodeActualContainer = node.getParent();
15809
15815
  if (!nodeActualContainer) return void 0;
15810
15816
  const actualContainerAttrs = nodeActualContainer.getAttrs();
@@ -15960,8 +15966,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15960
15966
  this.active = false;
15961
15967
  this.cameFromSelectingMultiple = false;
15962
15968
  this.selecting = false;
15969
+ this.dragging = false;
15963
15970
  this.initialized = false;
15964
15971
  this.enabled = false;
15972
+ this.pointers = {};
15965
15973
  }
15966
15974
  getName() {
15967
15975
  return WEAVE_NODES_SELECTION_KEY;
@@ -16009,20 +16017,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16009
16017
  ...this.config.transformer
16010
16018
  });
16011
16019
  selectionLayer?.add(tr);
16012
- tr.on("mouseenter", (e) => {
16013
- if (!this.isPasting()) {
16014
- const stage$1 = this.instance.getStage();
16015
- stage$1.container().style.cursor = "grab";
16016
- e.cancelBubble = true;
16017
- }
16018
- });
16019
- tr.on("mouseleave", (e) => {
16020
- if (!this.isPasting()) {
16021
- const stage$1 = this.instance.getStage();
16022
- stage$1.container().style.cursor = "default";
16023
- e.cancelBubble = true;
16024
- }
16025
- });
16026
16020
  tr.on("transformstart", () => {
16027
16021
  this.triggerSelectedNodesEvent();
16028
16022
  });
@@ -16034,6 +16028,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16034
16028
  this.triggerSelectedNodesEvent();
16035
16029
  });
16036
16030
  tr.on("dragstart", (e) => {
16031
+ this.dragging = true;
16037
16032
  const stage$1 = this.instance.getStage();
16038
16033
  if (stage$1.isMouseWheelPressed()) {
16039
16034
  e.cancelBubble = true;
@@ -16070,6 +16065,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16070
16065
  };
16071
16066
  tr.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 50));
16072
16067
  tr.on("dragend", (e) => {
16068
+ this.dragging = false;
16073
16069
  e.cancelBubble = true;
16074
16070
  const selectedNodes = tr.nodes();
16075
16071
  for (let i = 0; i < selectedNodes.length; i++) {
@@ -16104,11 +16100,11 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16104
16100
  });
16105
16101
  this.tr = tr;
16106
16102
  this.selectionRectangle = selectionRectangle;
16107
- this.tr.on("dblclick dbltap", (evt) => {
16108
- evt.cancelBubble = true;
16103
+ this.tr.on("pointerdblclick", (e) => {
16104
+ e.cancelBubble = true;
16109
16105
  if (this.tr.getNodes().length === 1) {
16110
16106
  const node = this.tr.getNodes()[0];
16111
- node.fire("dblclick");
16107
+ node.fire("pointerdblclick");
16112
16108
  }
16113
16109
  });
16114
16110
  this.initEvents();
@@ -16172,14 +16168,14 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16172
16168
  return;
16173
16169
  }
16174
16170
  });
16175
- stage.on("mousedown touchstart", (e) => {
16171
+ stage.on("pointerdown", (e) => {
16172
+ this.pointers[e.evt.pointerId] = e.evt;
16176
16173
  if (!this.initialized) return;
16177
16174
  if (!this.active) return;
16178
- if (e.evt.button && e.evt.button !== 0) return;
16179
- if (e.evt.touches && e.evt.touches.length > 1) return;
16175
+ if (e.evt.pointerType === "mouse" && e.evt.button !== 0) return;
16176
+ if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
16180
16177
  const selectedGroup = this.instance.getInstanceRecursive(e.target);
16181
16178
  if (!(e.target instanceof konva.default.Stage) && !(selectedGroup && selectedGroup.getAttrs().nodeType === "frame")) return;
16182
- e.evt.preventDefault();
16183
16179
  const intStage = this.instance.getStage();
16184
16180
  x1 = intStage.getRelativePointerPosition()?.x ?? 0;
16185
16181
  y1 = intStage.getRelativePointerPosition()?.y ?? 0;
@@ -16196,7 +16192,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16196
16192
  const handleMouseMove = (e) => {
16197
16193
  if (!this.initialized) return;
16198
16194
  if (!this.active) return;
16199
- if (e.evt instanceof TouchEvent && e.evt.touches && e.evt.touches.length > 1) return;
16195
+ if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
16200
16196
  const contextMenuPlugin = this.instance.getPlugin("contextMenu");
16201
16197
  if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
16202
16198
  this.selecting = false;
@@ -16206,7 +16202,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16206
16202
  this.cameFromSelectingMultiple = false;
16207
16203
  return;
16208
16204
  }
16209
- e.evt.preventDefault();
16210
16205
  const intStage = this.instance.getStage();
16211
16206
  x2 = intStage.getRelativePointerPosition()?.x ?? 0;
16212
16207
  y2 = intStage.getRelativePointerPosition()?.y ?? 0;
@@ -16218,11 +16213,13 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16218
16213
  height: Math.abs(y2 - y1)
16219
16214
  });
16220
16215
  };
16221
- stage.on("mousemove touchmove", (0, import_lodash.throttle)(handleMouseMove, 50));
16222
- stage.on("mouseup touchend", (e) => {
16216
+ stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
16217
+ stage.on("pointerup", (e) => {
16218
+ delete this.pointers[e.evt.pointerId];
16223
16219
  if (!this.initialized) return;
16224
16220
  if (!this.active) return;
16225
- if (e.evt instanceof TouchEvent && e.evt.touches && e.evt.touches.length > 1) return;
16221
+ if (!this.selecting) return;
16222
+ if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length + 1 > 1) return;
16226
16223
  const contextMenuPlugin = this.instance.getPlugin("contextMenu");
16227
16224
  if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
16228
16225
  this.selecting = false;
@@ -16234,7 +16231,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16234
16231
  this.cameFromSelectingMultiple = false;
16235
16232
  return;
16236
16233
  }
16237
- e.evt.preventDefault();
16238
16234
  this.tr.nodes([]);
16239
16235
  this.selectionRectangle.visible(false);
16240
16236
  const shapes = stage.find((node) => {
@@ -16254,25 +16250,34 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16254
16250
  return false;
16255
16251
  });
16256
16252
  const selectedNodes = new Set();
16257
- const framesNodes = selected.filter((shape) => shape.getAttrs().nodeType === "frame");
16258
- const framesNodesIds = selected.map((shape) => shape.getAttrs().id);
16253
+ const framesNodes = selected.map((shape) => {
16254
+ if (shape.getAttrs().nodeType === "frame" && shape.getAttrs().nodeId) return stage.findOne(`#${shape.getAttrs().nodeId}`);
16255
+ return shape;
16256
+ }).filter((shape) => {
16257
+ return shape.getAttrs().nodeType === "frame";
16258
+ });
16259
+ const framesNodesIds = framesNodes.map((shape) => {
16260
+ return shape.getAttrs().id;
16261
+ });
16259
16262
  const otherNodes = selected.filter((shape) => shape.getAttrs().nodeType !== "frame");
16260
16263
  otherNodes.forEach((node) => {
16261
- const parent = this.instance.getInstanceRecursive(node.getParent());
16262
- if (!framesNodesIds.includes(parent?.getAttrs().id)) selectedNodes.add(node);
16264
+ let parent = this.instance.getInstanceRecursive(node.getParent());
16265
+ if (parent?.getAttrs().nodeId) parent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
16266
+ if (parent && !framesNodesIds.includes(parent?.getAttrs().id) && !node.getAttrs().locked) selectedNodes.add(node);
16263
16267
  });
16264
16268
  framesNodes.forEach((node) => {
16265
16269
  const frameNode = node;
16266
- selectedNodes.add(frameNode);
16270
+ if (!frameNode.getAttrs().locked) selectedNodes.add(frameNode);
16267
16271
  });
16268
16272
  this.tr.nodes([...selectedNodes]);
16269
16273
  this.triggerSelectedNodesEvent();
16270
16274
  stage.container().tabIndex = 1;
16271
16275
  stage.container().focus();
16272
16276
  });
16273
- stage.on("click tap", (e) => {
16277
+ stage.on("pointerclick", (e) => {
16274
16278
  if (!this.enabled) return;
16275
16279
  if (this.instance.getActiveAction() !== "selectionTool") return;
16280
+ if (this.dragging) return;
16276
16281
  const contextMenuPlugin = this.instance.getPlugin("contextMenu");
16277
16282
  if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
16278
16283
  this.selecting = false;
@@ -16313,6 +16318,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16313
16318
  return node.getAttrs().id === nodeTargeted.getAttrs().id;
16314
16319
  });
16315
16320
  const isSelected = nodeSelectedIndex !== -1;
16321
+ if (nodeTargeted.getAttrs().locked) return;
16316
16322
  if (!metaPressed) {
16317
16323
  this.tr.nodes([nodeTargeted]);
16318
16324
  nodesSelected = this.tr.nodes().length;
@@ -16676,110 +16682,100 @@ var WeaveNode = class {
16676
16682
  node.scaleY(1);
16677
16683
  }
16678
16684
  setupDefaultNodeEvents(node) {
16679
- this.previousPointer = null;
16680
16685
  this.instance.addEventListener("onNodesChange", () => {
16681
- if (this.isSelecting() && this.isNodeSelected(node)) {
16686
+ if (!this.isLocked(node) && this.isSelecting() && this.isNodeSelected(node)) {
16682
16687
  node.draggable(true);
16683
16688
  return;
16684
16689
  }
16685
16690
  node.draggable(false);
16686
16691
  });
16687
- let transforming = false;
16688
- node.on("transformstart", () => {
16689
- transforming = true;
16690
- });
16691
- const handleTransform = (e) => {
16692
- const node$1 = e.target;
16693
- const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
16694
- const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16695
- if (nodesSelectionPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSelectionPlugin.getTransformer().forceUpdate();
16696
- if (nodesSnappingPlugin && transforming && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.evaluateGuidelines(e);
16697
- if (this.isSelecting() && this.isNodeSelected(node$1)) {
16698
- this.scaleReset(node$1);
16699
- const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16700
- if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
16701
- }
16702
- };
16703
- node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
16704
- node.on("transformend", (e) => {
16705
- const node$1 = e.target;
16706
- transforming = false;
16707
- const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
16708
- const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16709
- if (nodesSnappingPlugin) nodesSnappingPlugin.cleanupEvaluateGuidelines();
16710
- if (nodesSelectionPlugin) nodesSelectionPlugin.getTransformer().forceUpdate();
16711
- const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16712
- if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
16713
- });
16714
- node.on("dragstart", (e) => {
16715
- const stage = this.instance.getStage();
16716
- if (stage.isMouseWheelPressed()) {
16717
- e.cancelBubble = true;
16718
- node.stopDrag();
16719
- return;
16720
- }
16721
- });
16722
- const handleDragMove = (e) => {
16723
- const stage = this.instance.getStage();
16724
- if (stage.isMouseWheelPressed()) {
16725
- e.cancelBubble = true;
16726
- node.stopDrag();
16727
- return;
16728
- }
16729
- if (this.isSelecting() && this.isNodeSelected(node)) {
16730
- clearContainerTargets(this.instance);
16731
- const layerToMove = checkIfOverContainer(this.instance, e.target);
16732
- if (layerToMove) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
16733
- const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
16734
- if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
16735
- }
16736
- };
16737
- node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
16738
- node.on("dragend", (e) => {
16739
- if (this.isSelecting() && this.isNodeSelected(node)) {
16740
- clearContainerTargets(this.instance);
16692
+ const isLocked = node.getAttrs().locked ?? false;
16693
+ if (isLocked) {
16694
+ node.off("transformstart");
16695
+ node.off("transform");
16696
+ node.off("transformend");
16697
+ node.off("dragstart");
16698
+ node.off("dragmove");
16699
+ node.off("dragend");
16700
+ node.off("pointerenter");
16701
+ node.off("pointerleave");
16702
+ } else {
16703
+ let transforming = false;
16704
+ node.on("transformstart", () => {
16705
+ transforming = true;
16706
+ });
16707
+ const handleTransform = (e) => {
16708
+ const node$1 = e.target;
16709
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
16710
+ const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16711
+ if (nodesSelectionPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSelectionPlugin.getTransformer().forceUpdate();
16712
+ if (nodesSnappingPlugin && transforming && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.evaluateGuidelines(e);
16713
+ if (this.isSelecting() && this.isNodeSelected(node$1)) {
16714
+ this.scaleReset(node$1);
16715
+ const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16716
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
16717
+ }
16718
+ };
16719
+ node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
16720
+ node.on("transformend", (e) => {
16721
+ const node$1 = e.target;
16722
+ transforming = false;
16723
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
16741
16724
  const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16742
16725
  if (nodesSnappingPlugin) nodesSnappingPlugin.cleanupEvaluateGuidelines();
16743
- const containerToMove = moveNodeToContainer(this.instance, e.target);
16744
- if (containerToMove) return;
16745
- this.instance.updateNode(this.serialize(node));
16746
- }
16747
- });
16748
- this.previousPointer = null;
16749
- node.on("mouseenter", (e) => {
16750
- const realNode = this.instance.getInstanceRecursive(node);
16751
- if (this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting()) {
16752
- const stage = this.instance.getStage();
16753
- this.previousPointer = stage.container().style.cursor;
16754
- stage.container().style.cursor = "pointer";
16755
- e.cancelBubble = true;
16756
- return;
16757
- }
16758
- if (this.isPasting()) {
16759
- const stage = this.instance.getStage();
16760
- this.previousPointer = stage.container().style.cursor;
16761
- stage.container().style.cursor = "crosshair";
16762
- e.cancelBubble = true;
16763
- return;
16764
- }
16765
- });
16766
- node.on("mouseleave", (e) => {
16767
- const realNode = this.instance.getInstanceRecursive(node);
16768
- if (this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting()) {
16726
+ if (nodesSelectionPlugin) nodesSelectionPlugin.getTransformer().forceUpdate();
16727
+ const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16728
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
16729
+ });
16730
+ node.on("dragstart", (e) => {
16769
16731
  const stage = this.instance.getStage();
16770
- stage.container().style.cursor = this.previousPointer ?? "default";
16771
- this.previousPointer = null;
16772
- e.cancelBubble = true;
16773
- return;
16774
- }
16775
- if (this.isPasting()) {
16732
+ if (stage.isMouseWheelPressed()) {
16733
+ e.cancelBubble = true;
16734
+ e.target.stopDrag();
16735
+ }
16736
+ });
16737
+ const handleDragMove = (e) => {
16776
16738
  const stage = this.instance.getStage();
16777
- this.previousPointer = stage.container().style.cursor;
16778
- stage.container().style.cursor = "crosshair";
16779
- e.cancelBubble = true;
16780
- return;
16781
- }
16782
- });
16739
+ if (stage.isMouseWheelPressed()) {
16740
+ e.cancelBubble = true;
16741
+ e.target.stopDrag();
16742
+ return;
16743
+ }
16744
+ if (this.isSelecting() && this.isNodeSelected(node)) {
16745
+ clearContainerTargets(this.instance);
16746
+ const layerToMove = checkIfOverContainer(this.instance, e.target);
16747
+ if (layerToMove) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
16748
+ const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
16749
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
16750
+ }
16751
+ };
16752
+ node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
16753
+ node.on("dragend", (e) => {
16754
+ if (this.isSelecting() && this.isNodeSelected(node)) {
16755
+ clearContainerTargets(this.instance);
16756
+ const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16757
+ if (nodesSnappingPlugin) nodesSnappingPlugin.cleanupEvaluateGuidelines();
16758
+ const containerToMove = moveNodeToContainer(this.instance, e.target);
16759
+ if (containerToMove) return;
16760
+ this.instance.updateNode(this.serialize(node));
16761
+ }
16762
+ });
16763
+ node.on("pointerenter", (e) => {
16764
+ const realNode = this.instance.getInstanceRecursive(node);
16765
+ const isLocked$1 = realNode.getAttrs().locked ?? false;
16766
+ if (this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting()) {
16767
+ const stage = this.instance.getStage();
16768
+ stage.container().style.cursor = !isLocked$1 ? "pointer" : "default";
16769
+ e.cancelBubble = true;
16770
+ return;
16771
+ }
16772
+ if (this.isPasting()) {
16773
+ const stage = this.instance.getStage();
16774
+ stage.container().style.cursor = "crosshair";
16775
+ e.cancelBubble = true;
16776
+ }
16777
+ });
16778
+ }
16783
16779
  }
16784
16780
  create(key, props) {
16785
16781
  return {
@@ -16811,6 +16807,32 @@ var WeaveNode = class {
16811
16807
  }
16812
16808
  };
16813
16809
  }
16810
+ lock(instance) {
16811
+ if (instance.getAttrs().nodeType !== this.getNodeType()) return;
16812
+ instance.setAttrs({ locked: true });
16813
+ this.instance.updateNode(this.serialize(instance));
16814
+ const selectionPlugin = this.getSelectionPlugin();
16815
+ if (selectionPlugin) {
16816
+ const selectedNodes = selectionPlugin.getSelectedNodes();
16817
+ const newSelectedNodes = selectedNodes.filter((node) => node.getAttrs().id !== instance.getAttrs().id);
16818
+ selectionPlugin.setSelectedNodes(newSelectedNodes);
16819
+ selectionPlugin.getTransformer().forceUpdate();
16820
+ }
16821
+ this.setupDefaultNodeEvents(instance);
16822
+ const stage = this.instance.getStage();
16823
+ stage.container().style.cursor = "default";
16824
+ }
16825
+ unlock(instance) {
16826
+ if (instance.getAttrs().nodeType !== this.getNodeType()) return;
16827
+ instance.setAttrs({ locked: false });
16828
+ this.instance.updateNode(this.serialize(instance));
16829
+ this.setupDefaultNodeEvents(instance);
16830
+ const stage = this.instance.getStage();
16831
+ stage.container().style.cursor = "default";
16832
+ }
16833
+ isLocked(instance) {
16834
+ return instance.getAttrs().locked ?? false;
16835
+ }
16814
16836
  };
16815
16837
 
16816
16838
  //#endregion
@@ -18049,6 +18071,7 @@ var WeaveStateManager = class {
18049
18071
  };
18050
18072
  parent.props.children.push(finalNode);
18051
18073
  }
18074
+ this.instance.emitEvent("onNodeAdded", node);
18052
18075
  if (doRender) this.instance.render();
18053
18076
  }, userName);
18054
18077
  }
@@ -18078,6 +18101,7 @@ var WeaveStateManager = class {
18078
18101
  ...node.props
18079
18102
  }));
18080
18103
  nodeState.props = { ...nodeNew };
18104
+ this.instance.emitEvent("onNodeUpdated", node);
18081
18105
  if (doRender) this.instance.render();
18082
18106
  }, userName);
18083
18107
  }
@@ -18107,6 +18131,7 @@ var WeaveStateManager = class {
18107
18131
  const filteredChildren = newChildren.filter((actNode) => actNode.key !== node.key);
18108
18132
  parentState.props.children = filteredChildren;
18109
18133
  }
18134
+ this.instance.emitEvent("onNodeRemoved", node);
18110
18135
  if (doRender) this.instance.render();
18111
18136
  }, userName);
18112
18137
  }
@@ -18242,7 +18267,7 @@ var WeaveRegisterManager = class {
18242
18267
 
18243
18268
  //#endregion
18244
18269
  //#region package.json
18245
- var version = "0.32.0";
18270
+ var version = "0.34.0";
18246
18271
 
18247
18272
  //#endregion
18248
18273
  //#region src/managers/setup.ts
@@ -18477,6 +18502,7 @@ var WeaveExportManager = class {
18477
18502
  y: unscaledBounds.y - padding,
18478
18503
  width: unscaledBounds.width + 2 * padding,
18479
18504
  height: unscaledBounds.height + 2 * padding,
18505
+ strokeWidth: 0,
18480
18506
  fill: backgroundColor
18481
18507
  });
18482
18508
  exportGroup.add(background);
@@ -18492,10 +18518,10 @@ var WeaveExportManager = class {
18492
18518
  mainLayer.add(exportGroup);
18493
18519
  const backgroundRect = background.getClientRect();
18494
18520
  exportGroup.toImage({
18495
- x: backgroundRect.x,
18496
- y: backgroundRect.y,
18497
- width: backgroundRect.width,
18498
- height: backgroundRect.height,
18521
+ x: Math.round(backgroundRect.x),
18522
+ y: Math.round(backgroundRect.y),
18523
+ width: Math.round(backgroundRect.width),
18524
+ height: Math.round(backgroundRect.height),
18499
18525
  mimeType: format$2,
18500
18526
  pixelRatio,
18501
18527
  quality: options.quality ?? 1,
@@ -18812,6 +18838,9 @@ var Weave = class {
18812
18838
  getElementsTree() {
18813
18839
  return this.stateManager.getElementsTree();
18814
18840
  }
18841
+ isEmpty() {
18842
+ return this.getElementsTree().length === 0;
18843
+ }
18815
18844
  moveUp(node) {
18816
18845
  this.zIndexManager.moveUp(node);
18817
18846
  }
@@ -18852,7 +18881,8 @@ var Weave = class {
18852
18881
  if (selectionPlugin) {
18853
18882
  const stage = this.getStage();
18854
18883
  const instanceNodes = nodesIds.map((nodeId) => {
18855
- const nodeInstance = stage.findOne(`#${nodeId}`);
18884
+ let nodeInstance = stage.findOne(`#${nodeId}`);
18885
+ if (nodeInstance && nodeInstance.getAttrs().nodeType === "frame") nodeInstance = stage.findOne(`#${nodeId}-selector-area`);
18856
18886
  return nodeInstance;
18857
18887
  });
18858
18888
  selectionPlugin.setSelectedNodes(instanceNodes);
@@ -18873,6 +18903,48 @@ var Weave = class {
18873
18903
  async exportNodes(nodes, boundingNodes, options) {
18874
18904
  return await this.exportManager.exportNodes(nodes, boundingNodes, options);
18875
18905
  }
18906
+ allNodesLocked(nodes) {
18907
+ let allNodesLocked = true;
18908
+ for (const node of nodes) {
18909
+ const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
18910
+ if (!nodeHandler) continue;
18911
+ allNodesLocked = allNodesLocked && nodeHandler.isLocked(node);
18912
+ }
18913
+ return allNodesLocked;
18914
+ }
18915
+ allNodesUnlocked(nodes) {
18916
+ let allNodesUnlocked = true;
18917
+ for (const node of nodes) {
18918
+ const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
18919
+ if (!nodeHandler) continue;
18920
+ allNodesUnlocked = allNodesUnlocked && !nodeHandler.isLocked(node);
18921
+ }
18922
+ return allNodesUnlocked;
18923
+ }
18924
+ lockNode(node) {
18925
+ const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
18926
+ if (!nodeHandler) return;
18927
+ nodeHandler.lock(node);
18928
+ }
18929
+ lockNodes(nodes) {
18930
+ for (const node of nodes) {
18931
+ const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
18932
+ if (!nodeHandler) continue;
18933
+ nodeHandler.lock(node);
18934
+ }
18935
+ }
18936
+ unlockNode(node) {
18937
+ const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
18938
+ if (!nodeHandler) return;
18939
+ nodeHandler.unlock(node);
18940
+ }
18941
+ unlockNodes(nodes) {
18942
+ for (const node of nodes) {
18943
+ const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
18944
+ if (!nodeHandler) continue;
18945
+ nodeHandler.unlock(node);
18946
+ }
18947
+ }
18876
18948
  };
18877
18949
 
18878
18950
  //#endregion
@@ -18898,10 +18970,16 @@ var WeaveStageNode = class extends WeaveNode {
18898
18970
  stage.container().addEventListener("blur", () => {
18899
18971
  this.stageFocused = false;
18900
18972
  });
18901
- stage.on("mousedown", (e) => {
18973
+ stage.on("pointermove", (e) => {
18974
+ if (e.target === stage) {
18975
+ const stage$1 = this.instance.getStage();
18976
+ stage$1.container().style.cursor = "default";
18977
+ }
18978
+ });
18979
+ stage.on("pointerdown", (e) => {
18902
18980
  if (e.evt.button === 1) this.wheelMousePressed = true;
18903
18981
  });
18904
- stage.on("mouseup", (e) => {
18982
+ stage.on("pointerup", (e) => {
18905
18983
  if (e.evt.button === 1) this.wheelMousePressed = false;
18906
18984
  });
18907
18985
  stage.batchDraw();
@@ -19237,7 +19315,7 @@ var WeaveTextNode = class extends WeaveNode {
19237
19315
  }
19238
19316
  }
19239
19317
  });
19240
- text.on("dblclick dbltap", (e) => {
19318
+ text.on("pointerdblclick", (e) => {
19241
19319
  e.cancelBubble = true;
19242
19320
  if (this.editing) return;
19243
19321
  if (!(this.isSelecting() && this.isNodeSelected(text))) return;
@@ -19485,7 +19563,7 @@ var WeaveTextNode = class extends WeaveNode {
19485
19563
  this.removeTextAreaDOM(textNode);
19486
19564
  this.instance.removeEventListener("onZoomChange", this.onZoomChangeHandler(textNode).bind(this));
19487
19565
  this.instance.removeEventListener("onStageMove", this.onStageMoveHandler(textNode).bind(this));
19488
- window.removeEventListener("click", handleOutsideClick);
19566
+ window.removeEventListener("pointerclick", handleOutsideClick);
19489
19567
  return;
19490
19568
  }
19491
19569
  };
@@ -19514,14 +19592,14 @@ var WeaveTextNode = class extends WeaveNode {
19514
19592
  this.removeTextAreaDOM(textNode);
19515
19593
  this.textArea.removeEventListener("keydown", handleKeyDown);
19516
19594
  this.textArea.removeEventListener("keyup", handleKeyUp);
19517
- window.removeEventListener("click", handleOutsideClick);
19518
- window.removeEventListener("touchstart", handleOutsideClick);
19595
+ window.removeEventListener("pointerclick", handleOutsideClick);
19596
+ window.removeEventListener("pointerdown", handleOutsideClick);
19519
19597
  return;
19520
19598
  }
19521
19599
  };
19522
19600
  setTimeout(() => {
19523
- window.addEventListener("click", handleOutsideClick);
19524
- window.addEventListener("touchstart", handleOutsideClick);
19601
+ window.addEventListener("pointerclick", handleOutsideClick);
19602
+ window.addEventListener("pointerdown", handleOutsideClick);
19525
19603
  }, 0);
19526
19604
  this.editing = true;
19527
19605
  }
@@ -19673,8 +19751,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19673
19751
  return;
19674
19752
  }
19675
19753
  });
19676
- stage.on("click tap", (e) => {
19677
- e.evt.preventDefault();
19754
+ stage.on("pointerclick", () => {
19678
19755
  if (this.state === IMAGE_TOOL_STATE.IDLE) return;
19679
19756
  if (this.state === IMAGE_TOOL_STATE.UPLOADING) return;
19680
19757
  if (this.state === IMAGE_TOOL_STATE.ADDING) {
@@ -19682,8 +19759,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19682
19759
  return;
19683
19760
  }
19684
19761
  });
19685
- stage.on("mousemove touchmove", (e) => {
19686
- e.evt.preventDefault();
19762
+ stage.on("pointermove", () => {
19687
19763
  const tempImage = this.instance.getStage().findOne(`#${this.tempImageId}`);
19688
19764
  if (this.state === IMAGE_TOOL_STATE.ADDING && tempImage) {
19689
19765
  const mousePos = stage.getRelativePointerPosition();
@@ -20294,7 +20370,7 @@ var WeaveImageNode = class extends WeaveNode {
20294
20370
  });
20295
20371
  image.add(cropGroup);
20296
20372
  this.setupDefaultNodeEvents(image);
20297
- image.on("dblclick dbltap", (evt) => {
20373
+ image.on("pointerdblclick", (evt) => {
20298
20374
  evt.cancelBubble = true;
20299
20375
  if (image.getAttrs().cropping ?? false) return;
20300
20376
  if (!internalImage.getAttr("image")) return;
@@ -22752,7 +22828,6 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
22752
22828
  ...config
22753
22829
  };
22754
22830
  if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
22755
- this.isSpaceKeyPressed = false;
22756
22831
  this.isCtrlOrMetaPressed = false;
22757
22832
  this.updatedMinimumZoom = false;
22758
22833
  this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
@@ -22992,11 +23067,9 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
22992
23067
  initEvents() {
22993
23068
  window.addEventListener("keydown", (e) => {
22994
23069
  if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = true;
22995
- if (e.code === "Space") this.isSpaceKeyPressed = true;
22996
23070
  });
22997
23071
  window.addEventListener("keyup", (e) => {
22998
23072
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlOrMetaPressed = false;
22999
- if (e.code === "Space") this.isSpaceKeyPressed = false;
23000
23073
  });
23001
23074
  const stage = this.instance.getStage();
23002
23075
  const stageContainer = this.instance.getStage().container();
@@ -23022,17 +23095,20 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
23022
23095
  const newScale = initialScale * ev.scale;
23023
23096
  this.setZoom(newScale, false, center);
23024
23097
  });
23025
- window.addEventListener("wheel", (e) => {
23098
+ const handleWheel = (e) => {
23099
+ e.evt.preventDefault();
23026
23100
  const stage$1 = this.instance.getStage();
23027
- if (!this.enabled || !stage$1.isFocused() || !this.isCtrlOrMetaPressed || this.isSpaceKeyPressed) return;
23101
+ const performZoom = this.isCtrlOrMetaPressed || !this.isCtrlOrMetaPressed && e.evt.ctrlKey && e.evt.deltaMode === 0;
23102
+ if (!this.enabled || !stage$1.isFocused() || !performZoom) return;
23028
23103
  const oldScale = stage$1.scaleX();
23029
23104
  const pointer = stage$1.getPointerPosition();
23030
23105
  if (!pointer) return;
23031
23106
  const scaleBy = 1.025;
23032
- const direction = e.deltaY > 0 ? 1 : -1;
23107
+ const direction = e.evt.deltaY > 0 ? 1 : -1;
23033
23108
  const newScale = direction > 0 ? oldScale / scaleBy : oldScale * scaleBy;
23034
23109
  this.setZoom(newScale, false, pointer);
23035
- });
23110
+ };
23111
+ stage.on("wheel", handleWheel);
23036
23112
  }
23037
23113
  };
23038
23114
 
@@ -23315,8 +23391,7 @@ var WeaveEraserToolAction = class extends WeaveAction {
23315
23391
  }
23316
23392
  setupEvents() {
23317
23393
  const stage = this.instance.getStage();
23318
- stage.on("click tap", (e) => {
23319
- e.evt.preventDefault();
23394
+ stage.on("pointerclick", () => {
23320
23395
  if (!this.erasing) return;
23321
23396
  const nodeIntersected = this.instance.pointIntersectsElement();
23322
23397
  if (nodeIntersected) {
@@ -23324,7 +23399,8 @@ var WeaveEraserToolAction = class extends WeaveAction {
23324
23399
  if (!realNode) return;
23325
23400
  const nodeType = realNode.getAttrs().nodeType;
23326
23401
  const nodeHandler = this.instance.getNodeHandler(nodeType);
23327
- if (nodeHandler) {
23402
+ const isLocked = this.instance.allNodesLocked([realNode]);
23403
+ if (nodeHandler && !isLocked) {
23328
23404
  const nodeSerialized = nodeHandler.serialize(realNode);
23329
23405
  this.instance.removeNode(nodeSerialized);
23330
23406
  }
@@ -23424,22 +23500,19 @@ var WeaveRectangleToolAction = class extends WeaveAction {
23424
23500
  return;
23425
23501
  }
23426
23502
  });
23427
- stage.on("mousedown touchstart", (e) => {
23428
- e.evt.preventDefault();
23503
+ stage.on("pointerdown", () => {
23429
23504
  if (this.state === RECTANGLE_TOOL_STATE.ADDING) {
23430
23505
  this.creating = true;
23431
23506
  this.handleAdding();
23432
23507
  }
23433
23508
  });
23434
- stage.on("mousemove touchmove", (e) => {
23435
- e.evt.preventDefault();
23509
+ stage.on("pointermove", () => {
23436
23510
  if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE) {
23437
23511
  this.moved = true;
23438
23512
  this.handleMovement();
23439
23513
  }
23440
23514
  });
23441
- stage.on("mouseup touchend", (e) => {
23442
- e.evt.preventDefault();
23515
+ stage.on("pointerup", () => {
23443
23516
  if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE) {
23444
23517
  this.creating = false;
23445
23518
  this.handleSettingSize();
@@ -23602,22 +23675,19 @@ var WeaveEllipseToolAction = class extends WeaveAction {
23602
23675
  return;
23603
23676
  }
23604
23677
  });
23605
- stage.on("mousedown touchstart", (e) => {
23606
- e.evt.preventDefault();
23678
+ stage.on("pointerdown", () => {
23607
23679
  if (this.state === ELLIPSE_TOOL_STATE.ADDING) {
23608
23680
  this.creating = true;
23609
23681
  this.handleAdding();
23610
23682
  }
23611
23683
  });
23612
- stage.on("mousemove touchmove", (e) => {
23613
- e.evt.preventDefault();
23684
+ stage.on("pointermove", () => {
23614
23685
  if (this.state === ELLIPSE_TOOL_STATE.DEFINING_SIZE) {
23615
23686
  this.moved = true;
23616
23687
  this.handleMovement();
23617
23688
  }
23618
23689
  });
23619
- stage.on("mouseup touchend", (e) => {
23620
- e.evt.preventDefault();
23690
+ stage.on("pointerup", () => {
23621
23691
  if (this.state === ELLIPSE_TOOL_STATE.DEFINING_SIZE) {
23622
23692
  this.creating = false;
23623
23693
  this.handleSettingSize();
@@ -23789,12 +23859,7 @@ var WeavePenToolAction = class extends WeaveAction {
23789
23859
  return;
23790
23860
  }
23791
23861
  });
23792
- stage.on("dblclick dbltap", (e) => {
23793
- e.evt.preventDefault();
23794
- this.cancelAction();
23795
- });
23796
- stage.on("click tap", (e) => {
23797
- e.evt.preventDefault();
23862
+ stage.on("pointerclick", () => {
23798
23863
  if (this.state === PEN_TOOL_STATE.IDLE) return;
23799
23864
  if (this.state === PEN_TOOL_STATE.ADDING) {
23800
23865
  this.handleAdding();
@@ -23805,8 +23870,7 @@ var WeavePenToolAction = class extends WeaveAction {
23805
23870
  return;
23806
23871
  }
23807
23872
  });
23808
- stage.on("mousemove touchmove", (e) => {
23809
- e.evt.preventDefault();
23873
+ stage.on("pointermove", () => {
23810
23874
  this.handleMovement();
23811
23875
  });
23812
23876
  this.initialized = true;
@@ -24029,22 +24093,19 @@ var WeaveBrushToolAction = class extends WeaveAction {
24029
24093
  return;
24030
24094
  }
24031
24095
  });
24032
- stage.on("mousedown touchstart", (e) => {
24096
+ stage.on("pointerdown", (e) => {
24033
24097
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
24034
24098
  this.handleStartStroke();
24035
- e.evt.preventDefault();
24036
24099
  e.evt.stopPropagation();
24037
24100
  });
24038
- stage.on("mousemove touchmove", (e) => {
24101
+ stage.on("pointermove", (e) => {
24039
24102
  if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
24040
24103
  this.handleMovement();
24041
- e.evt.preventDefault();
24042
24104
  e.evt.stopPropagation();
24043
24105
  });
24044
- stage.on("mouseup touchend", (e) => {
24106
+ stage.on("pointerup", (e) => {
24045
24107
  if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
24046
24108
  this.handleEndStroke();
24047
- e.evt.preventDefault();
24048
24109
  e.evt.stopPropagation();
24049
24110
  });
24050
24111
  this.initialized = true;
@@ -24171,17 +24232,13 @@ var WeaveTextToolAction = class extends WeaveAction {
24171
24232
  return;
24172
24233
  }
24173
24234
  });
24174
- stage.on("click tap", (e) => {
24175
- e.evt.preventDefault();
24235
+ stage.on("pointerclick", () => {
24176
24236
  if (this.state === TEXT_TOOL_STATE.IDLE) return;
24177
24237
  if (this.state === TEXT_TOOL_STATE.ADDING) {
24178
24238
  this.handleAdding();
24179
24239
  return;
24180
24240
  }
24181
24241
  });
24182
- stage.on("mousemove touchmove", (e) => {
24183
- e.evt.preventDefault();
24184
- });
24185
24242
  this.initialized = true;
24186
24243
  }
24187
24244
  setState(state) {
@@ -24298,22 +24355,19 @@ var WeaveStarToolAction = class extends WeaveAction {
24298
24355
  return;
24299
24356
  }
24300
24357
  });
24301
- stage.on("mousedown touchstart", (e) => {
24302
- e.evt.preventDefault();
24358
+ stage.on("pointerdown", () => {
24303
24359
  if (this.state === STAR_TOOL_STATE.ADDING) {
24304
24360
  this.creating = true;
24305
24361
  this.handleAdding();
24306
24362
  }
24307
24363
  });
24308
- stage.on("mousemove touchmove", (e) => {
24309
- e.evt.preventDefault();
24364
+ stage.on("pointermove", () => {
24310
24365
  if (this.state === STAR_TOOL_STATE.DEFINING_SIZE) {
24311
24366
  this.moved = true;
24312
24367
  this.handleMovement();
24313
24368
  }
24314
24369
  });
24315
- stage.on("mouseup touchend", (e) => {
24316
- e.evt.preventDefault();
24370
+ stage.on("pointerup", () => {
24317
24371
  if (this.state === STAR_TOOL_STATE.DEFINING_SIZE) {
24318
24372
  this.creating = false;
24319
24373
  this.handleSettingSize();
@@ -24491,12 +24545,10 @@ var WeaveArrowToolAction = class extends WeaveAction {
24491
24545
  return;
24492
24546
  }
24493
24547
  });
24494
- stage.on("dblclick dbltap", (e) => {
24495
- e.evt.preventDefault();
24548
+ stage.on("pointerdblclick", () => {
24496
24549
  this.cancelAction();
24497
24550
  });
24498
- stage.on("click tap", (e) => {
24499
- e.evt.preventDefault();
24551
+ stage.on("pointerclick", () => {
24500
24552
  if (this.state === ARROW_TOOL_STATE.IDLE) return;
24501
24553
  if (this.state === ARROW_TOOL_STATE.ADDING) {
24502
24554
  this.handleAdding();
@@ -24507,8 +24559,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
24507
24559
  return;
24508
24560
  }
24509
24561
  });
24510
- stage.on("mousemove touchmove", (e) => {
24511
- e.evt.preventDefault();
24562
+ stage.on("pointermove", () => {
24512
24563
  this.handleMovement();
24513
24564
  });
24514
24565
  this.initialized = true;
@@ -24742,22 +24793,19 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
24742
24793
  return;
24743
24794
  }
24744
24795
  });
24745
- stage.on("mousedown touchstart", (e) => {
24746
- e.evt.preventDefault();
24796
+ stage.on("pointerdown", () => {
24747
24797
  if (this.state === REGULAR_POLYGON_TOOL_STATE.ADDING) {
24748
24798
  this.creating = true;
24749
24799
  this.handleAdding();
24750
24800
  }
24751
24801
  });
24752
- stage.on("mousemove touchmove", (e) => {
24753
- e.evt.preventDefault();
24802
+ stage.on("pointermove", () => {
24754
24803
  if (this.state === REGULAR_POLYGON_TOOL_STATE.DEFINING_SIZE) {
24755
24804
  this.moved = true;
24756
24805
  this.handleMovement();
24757
24806
  }
24758
24807
  });
24759
- stage.on("mouseup touchend", (e) => {
24760
- e.evt.preventDefault();
24808
+ stage.on("pointerup", () => {
24761
24809
  if (this.state === REGULAR_POLYGON_TOOL_STATE.DEFINING_SIZE) {
24762
24810
  this.creating = false;
24763
24811
  this.handleSettingSize();
@@ -24912,8 +24960,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
24912
24960
  return;
24913
24961
  }
24914
24962
  });
24915
- stage.on("click tap", (e) => {
24916
- e.evt.preventDefault();
24963
+ stage.on("pointerclick", () => {
24917
24964
  if (this.state === FRAME_TOOL_STATE.IDLE) return;
24918
24965
  if (this.state === FRAME_TOOL_STATE.ADDING) {
24919
24966
  this.handleAdding();
@@ -25057,11 +25104,12 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
25057
25104
  link.click();
25058
25105
  this.cancelAction?.();
25059
25106
  }
25060
- async trigger(cancelAction, { nodes, boundingNodes, options, download = true }) {
25107
+ async trigger(cancelAction, { nodes, boundingNodes, options, triggerSelectionTool = true, download = true }) {
25061
25108
  if (!this.instance) throw new Error("Instance not defined");
25062
25109
  const stage = this.instance.getStage();
25063
25110
  stage.container().tabIndex = 1;
25064
25111
  stage.container().focus();
25112
+ this.triggerSelectionTool = triggerSelectionTool;
25065
25113
  this.cancelAction = cancelAction;
25066
25114
  this.options = {
25067
25115
  ...this.defaultFormatOptions,
@@ -25080,7 +25128,253 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
25080
25128
  stage.container().tabIndex = 0;
25081
25129
  stage.container().click();
25082
25130
  stage.container().focus();
25083
- this.instance.triggerAction("selectionTool");
25131
+ if (this.triggerSelectionTool) this.instance.triggerAction("selectionTool");
25132
+ }
25133
+ };
25134
+
25135
+ //#endregion
25136
+ //#region src/actions/align-nodes-tool/constants.ts
25137
+ const ALIGN_NODES_TOOL_ACTION_NAME = "alignNodesTool";
25138
+ const ALIGN_NODES_ALIGN_TO = {
25139
+ ["LEFT_HORIZONTAL"]: "left-horizontal",
25140
+ ["CENTER_HORIZONTAL"]: "center-horizontal",
25141
+ ["RIGHT_HORIZONTAL"]: "right-horizontal",
25142
+ ["TOP_VERTICAL"]: "top-vertical",
25143
+ ["CENTER_VERTICAL"]: "center-vertical",
25144
+ ["BOTTOM_VERTICAL"]: "bottom-vertical"
25145
+ };
25146
+ const ALIGN_NODES_TOOL_STATE = { ["IDLE"]: "idle" };
25147
+
25148
+ //#endregion
25149
+ //#region src/actions/align-nodes-tool/align-nodes-tool.ts
25150
+ var WeaveAlignNodesToolAction = class extends WeaveAction {
25151
+ initialized = false;
25152
+ onPropsChange = void 0;
25153
+ onInit = void 0;
25154
+ constructor() {
25155
+ super();
25156
+ this.initialized = false;
25157
+ this.state = ALIGN_NODES_TOOL_STATE.IDLE;
25158
+ }
25159
+ getName() {
25160
+ return ALIGN_NODES_TOOL_ACTION_NAME;
25161
+ }
25162
+ setupEvents() {
25163
+ this.initialized = true;
25164
+ }
25165
+ setState(state) {
25166
+ this.state = state;
25167
+ }
25168
+ updateNode(node) {
25169
+ const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
25170
+ if (nodeHandler) {
25171
+ const actualNode = nodeHandler.serialize(node);
25172
+ this.instance.updateNode(actualNode);
25173
+ }
25174
+ }
25175
+ getParents(nodes) {
25176
+ if (nodes.length === 0) return [];
25177
+ const counts = {};
25178
+ for (const node of nodes) {
25179
+ let realNode = node;
25180
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25181
+ if (!realNode) continue;
25182
+ const parentId = realNode.getParent()?.getAttrs().id ?? "";
25183
+ const entry = counts[parentId];
25184
+ if (entry) entry.count++;
25185
+ else counts[parentId] = {
25186
+ count: 1,
25187
+ id: realNode.getParent()?.getAttrs().id ?? "",
25188
+ value: realNode.getParent()
25189
+ };
25190
+ }
25191
+ return Object.keys(counts).map((key) => counts[key].id);
25192
+ }
25193
+ alignToLeftHorizontal(nodes) {
25194
+ let targetX = Infinity;
25195
+ for (const node of nodes) {
25196
+ const box = node.getClientRect({ relativeTo: this.instance.getStage() });
25197
+ const realX = box.x;
25198
+ if (realX < targetX) targetX = realX;
25199
+ }
25200
+ for (const node of nodes) {
25201
+ let realNode = node;
25202
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25203
+ if (!realNode) continue;
25204
+ const box = node.getClientRect({ relativeTo: this.instance.getStage() });
25205
+ const deltaX = targetX - box.x;
25206
+ realNode.x(realNode.x() + deltaX);
25207
+ this.updateNode(realNode);
25208
+ }
25209
+ }
25210
+ alignToCenterHorizontal(nodes) {
25211
+ let minX = Infinity;
25212
+ let maxX = -Infinity;
25213
+ for (const node of nodes) {
25214
+ const box = node.getClientRect({ relativeTo: this.instance.getStage() });
25215
+ const realX = box.x;
25216
+ const realXWidth = box.x + box.width;
25217
+ if (realX < minX) minX = realX;
25218
+ if (realXWidth > maxX) maxX = realXWidth;
25219
+ }
25220
+ const targetX = minX + (maxX - minX) / 2;
25221
+ for (const node of nodes) {
25222
+ let realNode = node;
25223
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25224
+ if (!realNode) continue;
25225
+ const box = node.getClientRect({ relativeTo: this.instance.getStage() });
25226
+ const deltaX = targetX - (box.x + box.width / 2);
25227
+ realNode.x(realNode.x() + deltaX);
25228
+ this.updateNode(realNode);
25229
+ }
25230
+ }
25231
+ alignToRightHorizontal(nodes) {
25232
+ let targetX = -Infinity;
25233
+ for (const node of nodes) {
25234
+ const box = node.getClientRect({ relativeTo: this.instance.getStage() });
25235
+ const realX = box.x + box.width;
25236
+ if (realX > targetX) targetX = realX;
25237
+ }
25238
+ for (const node of nodes) {
25239
+ let realNode = node;
25240
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25241
+ if (!realNode) continue;
25242
+ const box = node.getClientRect({ relativeTo: this.instance.getStage() });
25243
+ const deltaX = targetX - (box.x + box.width);
25244
+ realNode.x(realNode.x() + deltaX);
25245
+ this.updateNode(realNode);
25246
+ }
25247
+ }
25248
+ alignToTopVertical(nodes) {
25249
+ let targetY = Infinity;
25250
+ for (const node of nodes) {
25251
+ let realNode = node;
25252
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25253
+ if (!realNode) continue;
25254
+ const box = realNode.getClientRect({ relativeTo: this.instance.getStage() });
25255
+ const realY = box.y;
25256
+ if (realY < targetY) targetY = realY;
25257
+ }
25258
+ for (const node of nodes) {
25259
+ let realNode = node;
25260
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25261
+ if (!realNode) continue;
25262
+ const box = realNode.getClientRect({ relativeTo: this.instance.getStage() });
25263
+ const deltaY = targetY - box.y;
25264
+ realNode.y(realNode.y() + deltaY);
25265
+ this.updateNode(realNode);
25266
+ }
25267
+ }
25268
+ alignToCenterVertical(nodes) {
25269
+ let minY = Infinity;
25270
+ let maxY = -Infinity;
25271
+ for (const node of nodes) {
25272
+ let realNode = node;
25273
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25274
+ if (!realNode) continue;
25275
+ const box = realNode.getClientRect({ relativeTo: this.instance.getStage() });
25276
+ const realY = box.y;
25277
+ const realYWidth = box.y + box.height;
25278
+ if (realY < minY) minY = realY;
25279
+ if (realYWidth > maxY) maxY = realYWidth;
25280
+ }
25281
+ const targetY = minY + (maxY - minY) / 2;
25282
+ for (const node of nodes) {
25283
+ let realNode = node;
25284
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25285
+ if (!realNode) continue;
25286
+ const box = realNode.getClientRect({ relativeTo: this.instance.getStage() });
25287
+ const deltaY = targetY - (box.y + box.height / 2);
25288
+ realNode.y(realNode.y() + deltaY);
25289
+ this.updateNode(realNode);
25290
+ }
25291
+ }
25292
+ alignToBottomVertical(nodes) {
25293
+ let targetY = -Infinity;
25294
+ for (const node of nodes) {
25295
+ let realNode = node;
25296
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25297
+ if (!realNode) continue;
25298
+ const box = realNode.getClientRect({ relativeTo: this.instance.getStage() });
25299
+ const realY = box.y + box.height;
25300
+ if (realY > targetY) targetY = realY;
25301
+ }
25302
+ for (const node of nodes) {
25303
+ let realNode = node;
25304
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25305
+ if (!realNode) continue;
25306
+ const box = realNode.getClientRect({ relativeTo: this.instance.getStage() });
25307
+ const deltaY = targetY - (box.y + box.height);
25308
+ realNode.y(realNode.y() + deltaY);
25309
+ this.updateNode(realNode);
25310
+ }
25311
+ }
25312
+ alignNodes(alignTo) {
25313
+ let selectedNodes = [];
25314
+ const selectionPlugin = this.instance.getPlugin("nodesSelection");
25315
+ if (selectionPlugin) selectedNodes = selectionPlugin.getSelectedNodes();
25316
+ const parentsIds = this.getParents(selectedNodes);
25317
+ let parent = this.instance.getMainLayer();
25318
+ if (parentsIds.length === 1) parent = this.instance.getStage().findOne(`#${parentsIds[0]}`);
25319
+ if (parentsIds.length > 1 && !parentsIds.includes("mainLayer")) {
25320
+ this.cancelAction();
25321
+ return;
25322
+ }
25323
+ selectedNodes = [...selectedNodes.filter((node) => {
25324
+ let realNode = node;
25325
+ if (node.getAttrs().nodeId) realNode = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
25326
+ return realNode?.getParent()?.getAttrs().id === parent?.getAttrs().id;
25327
+ })];
25328
+ switch (alignTo) {
25329
+ case ALIGN_NODES_ALIGN_TO.LEFT_HORIZONTAL: {
25330
+ this.alignToLeftHorizontal(selectedNodes);
25331
+ break;
25332
+ }
25333
+ case ALIGN_NODES_ALIGN_TO.CENTER_HORIZONTAL: {
25334
+ this.alignToCenterHorizontal(selectedNodes);
25335
+ break;
25336
+ }
25337
+ case ALIGN_NODES_ALIGN_TO.RIGHT_HORIZONTAL: {
25338
+ this.alignToRightHorizontal(selectedNodes);
25339
+ break;
25340
+ }
25341
+ case ALIGN_NODES_ALIGN_TO.TOP_VERTICAL: {
25342
+ this.alignToTopVertical(selectedNodes);
25343
+ break;
25344
+ }
25345
+ case ALIGN_NODES_ALIGN_TO.CENTER_VERTICAL: {
25346
+ this.alignToCenterVertical(selectedNodes);
25347
+ break;
25348
+ }
25349
+ case ALIGN_NODES_ALIGN_TO.BOTTOM_VERTICAL: {
25350
+ this.alignToBottomVertical(selectedNodes);
25351
+ break;
25352
+ }
25353
+ default: break;
25354
+ }
25355
+ this.cancelAction();
25356
+ }
25357
+ canAlignSelectedNodes() {
25358
+ let selectedNodes = [];
25359
+ const selectionPlugin = this.instance.getPlugin("nodesSelection");
25360
+ if (selectionPlugin) selectedNodes = selectionPlugin.getSelectedNodes();
25361
+ const parentsIds = this.getParents(selectedNodes);
25362
+ if (parentsIds.length > 1) return false;
25363
+ return true;
25364
+ }
25365
+ trigger(cancelAction, { alignTo, triggerSelectionTool = true }) {
25366
+ if (!this.instance) throw new Error("Instance not defined");
25367
+ if (!this.initialized) this.setupEvents();
25368
+ const stage = this.instance.getStage();
25369
+ stage.container().tabIndex = 1;
25370
+ stage.container().focus();
25371
+ this.triggerSelectionTool = triggerSelectionTool;
25372
+ this.cancelAction = cancelAction;
25373
+ this.alignNodes(alignTo);
25374
+ }
25375
+ cleanup() {
25376
+ if (this.triggerSelectionTool) this.instance.triggerAction("selectionTool");
25377
+ this.setState(ALIGN_NODES_TOOL_STATE.IDLE);
25084
25378
  }
25085
25379
  };
25086
25380
 
@@ -25093,8 +25387,8 @@ const WEAVE_GRID_TYPES = {
25093
25387
  };
25094
25388
  const WEAVE_GRID_DEFAULT_SIZE = 50;
25095
25389
  const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
25096
- const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.2)";
25097
- const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.2)";
25390
+ const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.1)";
25391
+ const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.1)";
25098
25392
  const WEAVE_GRID_DEFAULT_STROKE = .5;
25099
25393
  const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
25100
25394
  const WEAVE_GRID_DEFAULT_RADIUS = 1;
@@ -25145,36 +25439,22 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
25145
25439
  window.addEventListener("keyup", (e) => {
25146
25440
  if (e.code === "Space") this.isSpaceKeyPressed = false;
25147
25441
  });
25148
- stage.on("mousedown", (e) => {
25442
+ stage.on("pointerdown", (e) => {
25149
25443
  const activeAction = this.instance.getActiveAction();
25150
- if (e && e.evt.button === 0 && activeAction === "moveTool") {
25151
- this.moveToolActive = true;
25152
- e.cancelBubble = true;
25153
- }
25154
- if (e && (e.evt.button === 2 || e.evt.buttons === 4)) {
25155
- this.isMouseMiddleButtonPressed = true;
25156
- e.cancelBubble = true;
25157
- }
25444
+ if (e && e.evt.button === 0 && activeAction === "moveTool") this.moveToolActive = true;
25445
+ if (e && (e.evt.button === 2 || e.evt.buttons === 4)) this.isMouseMiddleButtonPressed = true;
25158
25446
  });
25159
- stage.on("mouseup", (e) => {
25447
+ stage.on("pointerup", (e) => {
25160
25448
  const activeAction = this.instance.getActiveAction();
25161
- if (e && e.evt.button === 0 && activeAction === "moveTool") {
25162
- this.moveToolActive = false;
25163
- e.cancelBubble = true;
25164
- }
25165
- if (e && (e.evt.button === 1 || e.evt.buttons === 0)) {
25166
- this.isMouseMiddleButtonPressed = false;
25167
- e.cancelBubble = true;
25168
- }
25449
+ if (e && e.evt.button === 0 && activeAction === "moveTool") this.moveToolActive = false;
25450
+ if (e && (e.evt.button === 1 || e.evt.buttons === 0)) this.isMouseMiddleButtonPressed = false;
25169
25451
  });
25170
- const handleMouseMove = (e) => {
25171
- e.evt.preventDefault();
25452
+ const handleMouseMove = () => {
25172
25453
  if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
25173
25454
  this.onRender();
25174
25455
  };
25175
- stage.on("mousemove", (0, import_lodash.throttle)(handleMouseMove, 50));
25176
- stage.on("touchmove", (e) => {
25177
- e.evt.preventDefault();
25456
+ stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
25457
+ stage.on("pointermove", () => {
25178
25458
  if (!this.enabled) return;
25179
25459
  this.onRender();
25180
25460
  });
@@ -25429,40 +25709,33 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25429
25709
  this.disableMove();
25430
25710
  }
25431
25711
  });
25432
- stage.on("mousedown", (e) => {
25712
+ stage.on("pointerdown", (e) => {
25433
25713
  const activeAction = this.instance.getActiveAction();
25434
25714
  let enableMove = false;
25435
- if (e && e.evt.button === 0 && activeAction === "moveTool") {
25715
+ if (e && (e.evt.pointerType !== "mouse" || e.evt.pointerType === "mouse" && e.evt.buttons === 1) && activeAction === "moveTool") {
25436
25716
  this.moveToolActive = true;
25437
25717
  enableMove = true;
25438
25718
  }
25439
- if (!enableMove && e && e.evt.button === 1) {
25719
+ if (!enableMove && e.evt.pointerType === "mouse" && e.evt.buttons === 4) {
25440
25720
  this.isMouseMiddleButtonPressed = true;
25441
25721
  enableMove = true;
25442
25722
  }
25443
- if (enableMove) {
25444
- this.enableMove();
25445
- e.cancelBubble = true;
25446
- }
25723
+ if (enableMove) this.enableMove();
25447
25724
  });
25448
- stage.on("mouseup", (e) => {
25725
+ stage.on("pointerup", (e) => {
25449
25726
  const activeAction = this.instance.getActiveAction();
25450
25727
  let disableMove = false;
25451
- if (e && e.evt.button === 0 && activeAction === "moveTool") {
25728
+ if (e && (e.evt.pointerType !== "mouse" || e.evt.pointerType === "mouse" && e.evt.buttons === 0) && activeAction === "moveTool") {
25452
25729
  this.moveToolActive = false;
25453
25730
  disableMove = true;
25454
25731
  }
25455
- if (e && (e.evt.button === 1 || e.evt.buttons === 0)) {
25732
+ if (e && e.evt.pointerType === "mouse" && e.evt.buttons === 0) {
25456
25733
  this.isMouseMiddleButtonPressed = false;
25457
25734
  disableMove = true;
25458
25735
  }
25459
- if (disableMove) {
25460
- this.disableMove();
25461
- e.cancelBubble = true;
25462
- }
25736
+ if (disableMove) this.disableMove();
25463
25737
  });
25464
- const handleMouseMove = (e) => {
25465
- e.evt.preventDefault();
25738
+ const handleMouseMove = () => {
25466
25739
  const mousePos = stage.getPointerPosition();
25467
25740
  if (previousMouseX === Infinity) previousMouseX = mousePos?.x ?? 0;
25468
25741
  if (previousMouseY === Infinity) previousMouseY = mousePos?.y ?? 0;
@@ -25475,38 +25748,22 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25475
25748
  stage.y(stage.y() - deltaY);
25476
25749
  this.instance.emitEvent("onStageMove");
25477
25750
  };
25478
- stage.on("mousemove", (0, import_lodash.throttle)(handleMouseMove, 50));
25479
- stage.on("touchstart", (e) => {
25480
- e.evt.preventDefault();
25751
+ stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
25752
+ stage.on("pointerdown", () => {
25481
25753
  const mousePos = stage.getPointerPosition();
25482
25754
  previousMouseX = mousePos?.x ?? 0;
25483
25755
  previousMouseY = mousePos?.y ?? 0;
25484
25756
  });
25485
- stage.on("touchmove", (e) => {
25486
- e.evt.preventDefault();
25487
- const activeAction = this.instance.getActiveAction();
25488
- if (activeAction !== "moveTool") return;
25489
- const mousePos = stage.getPointerPosition();
25490
- if (previousMouseX === Infinity) previousMouseX = mousePos?.x ?? 0;
25491
- if (previousMouseY === Infinity) previousMouseY = mousePos?.y ?? 0;
25492
- const deltaX = previousMouseX - (mousePos?.x ?? 0);
25493
- const deltaY = previousMouseY - (mousePos?.y ?? 0);
25494
- previousMouseX = mousePos?.x ?? 0;
25495
- previousMouseY = mousePos?.y ?? 0;
25496
- if (!this.enabled) return;
25497
- stage.x(stage.x() - deltaX);
25498
- stage.y(stage.y() - deltaY);
25499
- this.instance.emitEvent("onStageMove");
25500
- });
25501
25757
  const handleWheel = (e) => {
25502
25758
  e.evt.preventDefault();
25503
25759
  const stage$1 = this.instance.getStage();
25504
- if (!this.enabled || !stage$1.isFocused() || this.isCtrlOrMetaPressed) return;
25760
+ const performPanning = !this.isCtrlOrMetaPressed && !e.evt.ctrlKey;
25761
+ if (!this.enabled || !stage$1.isFocused() || this.isCtrlOrMetaPressed || e.evt.buttons === 4 || !performPanning) return;
25505
25762
  stage$1.x(stage$1.x() - e.evt.deltaX);
25506
25763
  stage$1.y(stage$1.y() - e.evt.deltaY);
25507
25764
  this.instance.emitEvent("onStageMove");
25508
25765
  };
25509
- stage.on("wheel", (0, import_lodash.throttle)(handleWheel, 10));
25766
+ stage.on("wheel", handleWheel);
25510
25767
  }
25511
25768
  enable() {
25512
25769
  this.enabled = true;
@@ -25842,8 +26099,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
25842
26099
  for (let i = 0; i < inactiveUsers.length; i++) delete this.usersPointers[inactiveUsers[i]];
25843
26100
  this.renderPointers();
25844
26101
  });
25845
- stage.on("dragmove", (e) => {
25846
- e.evt.preventDefault();
26102
+ stage.on("dragmove", () => {
25847
26103
  const userInfo = this.config.getUser();
25848
26104
  const mousePos = stage.getRelativePointerPosition();
25849
26105
  if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
@@ -25852,8 +26108,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
25852
26108
  y: mousePos.y
25853
26109
  });
25854
26110
  });
25855
- stage.on("pointermove", (e) => {
25856
- e.evt.preventDefault();
26111
+ stage.on("pointermove", () => {
25857
26112
  const userInfo = this.config.getUser();
25858
26113
  const mousePos = stage.getRelativePointerPosition();
25859
26114
  if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
@@ -25967,11 +26222,9 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
25967
26222
  initEvents() {
25968
26223
  const stage = this.instance.getStage();
25969
26224
  stage.container().addEventListener("dragover", (e) => {
25970
- e.preventDefault();
25971
26225
  e.stopPropagation();
25972
26226
  });
25973
26227
  stage.container().addEventListener("drop", (e) => {
25974
- e.preventDefault();
25975
26228
  e.stopPropagation();
25976
26229
  this.instance.emitEvent("onStageDrop", e);
25977
26230
  });
@@ -26349,6 +26602,9 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
26349
26602
  };
26350
26603
 
26351
26604
  //#endregion
26605
+ exports.ALIGN_NODES_ALIGN_TO = ALIGN_NODES_ALIGN_TO
26606
+ exports.ALIGN_NODES_TOOL_ACTION_NAME = ALIGN_NODES_TOOL_ACTION_NAME
26607
+ exports.ALIGN_NODES_TOOL_STATE = ALIGN_NODES_TOOL_STATE
26352
26608
  exports.ARROW_TOOL_ACTION_NAME = ARROW_TOOL_ACTION_NAME
26353
26609
  exports.ARROW_TOOL_STATE = ARROW_TOOL_STATE
26354
26610
  exports.BRUSH_TOOL_ACTION_NAME = BRUSH_TOOL_ACTION_NAME
@@ -26422,6 +26678,7 @@ exports.WEAVE_USER_POINTER_KEY = WEAVE_USER_POINTER_KEY
26422
26678
  exports.WEAVE_USER_SELECTION_KEY = WEAVE_USER_SELECTION_KEY
26423
26679
  exports.Weave = Weave
26424
26680
  exports.WeaveAction = WeaveAction
26681
+ exports.WeaveAlignNodesToolAction = WeaveAlignNodesToolAction
26425
26682
  exports.WeaveArrowNode = WeaveArrowNode
26426
26683
  exports.WeaveArrowToolAction = WeaveArrowToolAction
26427
26684
  exports.WeaveBrushToolAction = WeaveBrushToolAction