@inditextech/weave-sdk 0.73.1 → 0.74.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
@@ -18951,6 +18951,14 @@ const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
18951
18951
  const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
18952
18952
  const WEAVE_GRID_LAYER_ID = "gridLayer";
18953
18953
 
18954
+ //#endregion
18955
+ //#region src/plugins/stage-panning/constants.ts
18956
+ const WEAVE_STAGE_PANNING_KEY = "stagePanning";
18957
+ const WEAVE_STAGE_PANNING_DEFAULT_CONFIG = {
18958
+ edgePanOffset: 50,
18959
+ edgePanSpeed: 10
18960
+ };
18961
+
18954
18962
  //#endregion
18955
18963
  //#region src/plugins/nodes-selection/nodes-selection.ts
18956
18964
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
@@ -19124,6 +19132,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19124
19132
  const node = selectedNodes[i];
19125
19133
  node.updatePosition(node.getAbsolutePosition());
19126
19134
  }
19135
+ if (e.evt?.altKey) {
19136
+ tr.stopDrag(e.evt);
19137
+ e.cancelBubble = true;
19138
+ }
19127
19139
  tr.forceUpdate();
19128
19140
  });
19129
19141
  const handleDragMove = (e) => {
@@ -19131,6 +19143,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19131
19143
  x: e.target.x(),
19132
19144
  y: e.target.y()
19133
19145
  };
19146
+ e.cancelBubble = true;
19134
19147
  if (initialPos) {
19135
19148
  const moved = this.checkMovedDrag(initialPos, actualPos);
19136
19149
  if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
@@ -19142,7 +19155,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19142
19155
  return;
19143
19156
  }
19144
19157
  this.didMove = true;
19145
- e.cancelBubble = true;
19146
19158
  const selectedNodes = tr.nodes();
19147
19159
  let selectionContainsFrames = false;
19148
19160
  for (let i = 0; i < selectedNodes.length; i++) {
@@ -19161,12 +19173,15 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19161
19173
  tr.on("dragend", (e) => {
19162
19174
  if (!this.didMove) return;
19163
19175
  e.cancelBubble = true;
19176
+ this.instance.getCloningManager().cleanupClones();
19177
+ this.getStagePanningPlugin()?.cleanupEdgeMoveIntervals();
19164
19178
  const selectedNodes = tr.nodes();
19165
19179
  let selectionContainsFrames = false;
19166
19180
  for (let i = 0; i < selectedNodes.length; i++) {
19167
19181
  const node = selectedNodes[i];
19168
19182
  selectionContainsFrames = selectionContainsFrames || hasFrames(node);
19169
19183
  node.updatePosition(node.getAbsolutePosition());
19184
+ node.setAttrs({ isCloned: void 0 });
19170
19185
  }
19171
19186
  if (this.isSelecting() && tr.nodes().length > 1) {
19172
19187
  const actualCursor = stage.container().style.cursor;
@@ -19407,7 +19422,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19407
19422
  stage.container().addEventListener("keydown", (e) => {
19408
19423
  if (e.code === "Space") this.isSpaceKeyPressed = true;
19409
19424
  if ((e.code === "Backspace" || e.code === "Delete") && Object.keys(window.weaveTextEditing).length === 0) {
19410
- this.removeSelectedNodes();
19425
+ Promise.resolve().then(() => {
19426
+ this.removeSelectedNodes();
19427
+ });
19411
19428
  return;
19412
19429
  }
19413
19430
  });
@@ -19763,6 +19780,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19763
19780
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
19764
19781
  return snappingPlugin;
19765
19782
  }
19783
+ getStagePanningPlugin() {
19784
+ const stagePanning = this.instance.getPlugin(WEAVE_STAGE_PANNING_KEY);
19785
+ return stagePanning;
19786
+ }
19766
19787
  getSelectorConfig() {
19767
19788
  return this.config.selection;
19768
19789
  }
@@ -20336,69 +20357,98 @@ var WeaveNode = class {
20336
20357
  const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
20337
20358
  if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
20338
20359
  });
20360
+ let clone = void 0;
20339
20361
  node.on("dragstart", (e) => {
20362
+ const nodeTarget = e.target;
20340
20363
  this.didMove = false;
20341
20364
  if (e.evt?.buttons === 0) {
20342
- e.target.stopDrag();
20365
+ nodeTarget.stopDrag();
20343
20366
  return;
20344
20367
  }
20345
20368
  const stage = this.instance.getStage();
20346
20369
  const isErasing = this.instance.getActiveAction() === "eraseTool";
20347
20370
  if (isErasing) {
20348
- e.target.stopDrag();
20371
+ nodeTarget.stopDrag();
20349
20372
  return;
20350
20373
  }
20351
- this.instance.emitEvent("onDrag", e.target);
20374
+ this.instance.emitEvent("onDrag", nodeTarget);
20352
20375
  if (stage.isMouseWheelPressed()) {
20353
20376
  e.cancelBubble = true;
20354
- e.target.stopDrag();
20377
+ nodeTarget.stopDrag();
20378
+ }
20379
+ const realNodeTarget = this.getRealSelectedNode(nodeTarget);
20380
+ if (realNodeTarget.getAttrs().isCloned) return;
20381
+ if (e.evt?.altKey) {
20382
+ nodeTarget.stopDrag(e.evt);
20383
+ e.cancelBubble = true;
20384
+ clone = this.instance.getCloningManager().cloneNode(realNodeTarget);
20385
+ if (clone && !this.instance.getCloningManager().isClone(clone)) {
20386
+ clone.setAttrs({ isCloned: true });
20387
+ this.instance.getCloningManager().addClone(clone);
20388
+ }
20389
+ stage.setPointersPositions(e.evt);
20390
+ const nodesSelectionPlugin = this.getNodesSelectionPlugin();
20391
+ nodesSelectionPlugin?.setSelectedNodes([]);
20392
+ setTimeout(() => {
20393
+ nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
20394
+ clone?.startDrag(e.evt);
20395
+ }, 0);
20355
20396
  }
20356
20397
  });
20357
20398
  const handleDragMove = (e) => {
20399
+ const nodeTarget = e.target;
20400
+ e.cancelBubble = true;
20358
20401
  if (e.evt?.buttons === 0) {
20359
- e.target.stopDrag();
20402
+ nodeTarget.stopDrag();
20360
20403
  return;
20361
20404
  }
20362
20405
  this.didMove = true;
20363
20406
  const stage = this.instance.getStage();
20364
20407
  const isErasing = this.instance.getActiveAction() === "eraseTool";
20365
20408
  if (isErasing) {
20366
- e.target.stopDrag();
20409
+ nodeTarget.stopDrag();
20367
20410
  return;
20368
20411
  }
20369
20412
  if (stage.isMouseWheelPressed()) {
20370
20413
  e.cancelBubble = true;
20371
- e.target.stopDrag();
20414
+ nodeTarget.stopDrag();
20372
20415
  return;
20373
20416
  }
20374
- if (this.isSelecting() && this.isNodeSelected(node) && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
20417
+ const realNodeTarget = this.getRealSelectedNode(nodeTarget);
20418
+ if (this.isSelecting() && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
20375
20419
  clearContainerTargets(this.instance);
20376
- const layerToMove = containerOverCursor(this.instance, [node]);
20377
- if (layerToMove && !hasFrames(node) && node.isDragging()) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
20420
+ const layerToMove = containerOverCursor(this.instance, [realNodeTarget]);
20421
+ if (layerToMove && !hasFrames(realNodeTarget) && realNodeTarget.isDragging()) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
20378
20422
  }
20379
20423
  };
20380
20424
  node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
20381
20425
  node.on("dragend", (e) => {
20426
+ const nodeTarget = e.target;
20427
+ e.cancelBubble = true;
20428
+ if (clone) clone = void 0;
20382
20429
  if (!this.didMove) return;
20383
20430
  const isErasing = this.instance.getActiveAction() === "eraseTool";
20384
20431
  if (isErasing) {
20385
- e.target.stopDrag();
20432
+ nodeTarget.stopDrag();
20386
20433
  return;
20387
20434
  }
20388
20435
  this.instance.emitEvent("onDrag", null);
20389
- if (this.isSelecting() && this.isNodeSelected(node) && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
20436
+ const realNodeTarget = this.getRealSelectedNode(nodeTarget);
20437
+ if (this.isSelecting() && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
20390
20438
  clearContainerTargets(this.instance);
20391
20439
  const nodesEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
20392
20440
  const nodesDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
20393
20441
  if (nodesEdgeSnappingPlugin) nodesEdgeSnappingPlugin.cleanupGuidelines();
20394
20442
  if (nodesDistanceSnappingPlugin) nodesDistanceSnappingPlugin.cleanupGuidelines();
20395
- const layerToMove = containerOverCursor(this.instance, [node]);
20443
+ const layerToMove = containerOverCursor(this.instance, [realNodeTarget]);
20396
20444
  let containerToMove = this.instance.getMainLayer();
20397
20445
  if (layerToMove) containerToMove = layerToMove;
20398
20446
  let moved = false;
20399
- if (containerToMove && !hasFrames(node)) moved = moveNodeToContainer(this.instance, e.target, containerToMove);
20447
+ if (containerToMove && !hasFrames(node) && !realNodeTarget.getAttrs().isCloned) moved = moveNodeToContainer(this.instance, realNodeTarget, containerToMove);
20448
+ if (realNodeTarget.getAttrs().isCloned) this.instance.getCloningManager().removeClone(realNodeTarget);
20449
+ realNodeTarget?.setAttrs({ isCloned: void 0 });
20400
20450
  if (containerToMove) containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
20401
- if (!moved) this.instance.updateNode(this.serialize(node));
20451
+ if (!moved) this.instance.updateNode(this.serialize(realNodeTarget));
20402
20452
  }
20403
20453
  });
20404
20454
  node.handleMouseover = () => {
@@ -20556,6 +20606,10 @@ var WeaveNode = class {
20556
20606
  };
20557
20607
  return (0, import_merge.default)(transformProperties, nodeTransformConfig ?? {});
20558
20608
  }
20609
+ getNodesSelectionPlugin() {
20610
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
20611
+ return nodesSelectionPlugin;
20612
+ }
20559
20613
  getNodesEdgeSnappingPlugin() {
20560
20614
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY);
20561
20615
  return snappingPlugin;
@@ -20570,6 +20624,17 @@ var WeaveNode = class {
20570
20624
  y: 0
20571
20625
  };
20572
20626
  }
20627
+ getRealSelectedNode(nodeTarget) {
20628
+ const stage = this.instance.getStage();
20629
+ let realNodeTarget = nodeTarget;
20630
+ if (nodeTarget.getParent() instanceof konva.default.Transformer) {
20631
+ const mousePos = stage.getPointerPosition();
20632
+ const intersections = stage.getAllIntersections(mousePos);
20633
+ const nodesIntersected = intersections.filter((ele) => ele.getAttrs().nodeType);
20634
+ if (nodesIntersected.length > 0) realNodeTarget = this.instance.getInstanceRecursive(nodesIntersected[nodesIntersected.length - 1]);
20635
+ }
20636
+ return realNodeTarget;
20637
+ }
20573
20638
  };
20574
20639
 
20575
20640
  //#endregion
@@ -21390,6 +21455,7 @@ var WeaveTargetingManager = class {
21390
21455
  //#endregion
21391
21456
  //#region src/managers/cloning.ts
21392
21457
  var WeaveCloningManager = class {
21458
+ clones = [];
21393
21459
  constructor(instance) {
21394
21460
  this.instance = instance;
21395
21461
  this.logger = this.instance.getChildLogger("cloning-manager");
@@ -21548,6 +21614,42 @@ var WeaveCloningManager = class {
21548
21614
  }
21549
21615
  newGroup.destroy();
21550
21616
  }
21617
+ recursivelyUpdateKeys(nodes) {
21618
+ for (const child of nodes) {
21619
+ const newNodeId = v4_default();
21620
+ child.key = newNodeId;
21621
+ child.props.id = newNodeId;
21622
+ if (child.props.children) this.recursivelyUpdateKeys(child.props.children);
21623
+ }
21624
+ }
21625
+ cloneNode(targetNode) {
21626
+ const nodeHandler = this.instance.getNodeHandler(targetNode.getAttrs().nodeType);
21627
+ if (!nodeHandler) return void 0;
21628
+ const parent = targetNode.getParent();
21629
+ const serializedNode = nodeHandler.serialize(targetNode);
21630
+ this.recursivelyUpdateKeys(serializedNode.props.children ?? []);
21631
+ const newNodeId = v4_default();
21632
+ serializedNode.key = newNodeId;
21633
+ serializedNode.props.id = newNodeId;
21634
+ const realParent = this.instance.getInstanceRecursive(parent);
21635
+ this.instance.addNode(serializedNode, realParent?.getAttrs().id);
21636
+ return this.instance.getStage().findOne(`#${newNodeId}`);
21637
+ }
21638
+ addClone(node) {
21639
+ this.clones.push(node);
21640
+ }
21641
+ removeClone(node) {
21642
+ this.clones = this.clones.filter((c) => c !== node);
21643
+ }
21644
+ getClones() {
21645
+ return this.clones;
21646
+ }
21647
+ isClone(node) {
21648
+ return this.clones.find((c) => c === node);
21649
+ }
21650
+ cleanupClones() {
21651
+ this.clones = [];
21652
+ }
21551
21653
  };
21552
21654
 
21553
21655
  //#endregion
@@ -21951,7 +22053,7 @@ var WeaveRegisterManager = class {
21951
22053
 
21952
22054
  //#endregion
21953
22055
  //#region package.json
21954
- var version = "0.73.1";
22056
+ var version = "0.74.0";
21955
22057
 
21956
22058
  //#endregion
21957
22059
  //#region src/managers/setup.ts
@@ -22769,7 +22871,7 @@ var Weave = class {
22769
22871
  getNodeContainerId(node) {
22770
22872
  const stage = this.getStage();
22771
22873
  let nodeContainer = node.getParent()?.getAttrs().id ?? "";
22772
- if (typeof node.getParent()?.getAttrs().nodeId !== "undefined") {
22874
+ if (typeof node?.getParent()?.getAttrs().nodeId !== "undefined") {
22773
22875
  const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
22774
22876
  if (realContainer) nodeContainer = realContainer.getAttrs().id ?? "";
22775
22877
  }
@@ -22777,8 +22879,8 @@ var Weave = class {
22777
22879
  }
22778
22880
  getNodeContainer(node) {
22779
22881
  const stage = this.getStage();
22780
- let nodeContainer = node.getParent();
22781
- if (typeof node.getParent()?.getAttrs().nodeId !== "undefined") {
22882
+ let nodeContainer = node?.getParent();
22883
+ if (typeof node?.getParent()?.getAttrs().nodeId !== "undefined") {
22782
22884
  const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
22783
22885
  if (realContainer) nodeContainer = realContainer;
22784
22886
  }
@@ -22833,6 +22935,9 @@ var Weave = class {
22833
22935
  selectionPlugin.setSelectedNodes(instanceNodes);
22834
22936
  }
22835
22937
  }
22938
+ getCloningManager() {
22939
+ return this.cloningManager;
22940
+ }
22836
22941
  nodesToGroupSerialized(instancesToClone) {
22837
22942
  return this.cloningManager.nodesToGroupSerialized(instancesToClone);
22838
22943
  }
@@ -24832,17 +24937,13 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
24832
24937
  fontFamily: "Arial",
24833
24938
  fontStyle: "bold",
24834
24939
  fontSize: 20,
24835
- fontColor: "#000000ff",
24940
+ fontColor: "#000000",
24836
24941
  titleMargin: 20,
24837
- borderColor: "#000000ff",
24942
+ borderColor: "#000000",
24838
24943
  borderWidth: 1,
24839
- onTargetLeave: {
24840
- borderColor: "#000000ff",
24841
- fill: "#ffffffff"
24842
- },
24843
24944
  onTargetEnter: {
24844
- borderColor: "#ff6863ff",
24845
- fill: "#ffffffff"
24945
+ borderColor: "#FF6863FF",
24946
+ fill: "#FFFFFFFF"
24846
24947
  },
24847
24948
  transform: {
24848
24949
  rotateEnabled: false,
@@ -24852,10 +24953,12 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
24852
24953
  padding: 0
24853
24954
  }
24854
24955
  };
24956
+ const WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR = "#FFFFFFFF";
24855
24957
  const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
24856
24958
  title: "Frame XXX",
24857
24959
  frameWidth: 1920,
24858
- frameHeight: 1080
24960
+ frameHeight: 1080,
24961
+ frameBackground: WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
24859
24962
  };
24860
24963
 
24861
24964
  //#endregion
@@ -24880,13 +24983,14 @@ var WeaveFrameNode = class extends WeaveNode {
24880
24983
  ...props.title && { title: props.title },
24881
24984
  ...props.frameWidth && { frameWidth: props.frameWidth },
24882
24985
  ...props.frameHeight && { frameHeight: props.frameHeight },
24986
+ ...props.frameBackground && { frameBackground: props.frameBackground },
24883
24987
  children: []
24884
24988
  }
24885
24989
  };
24886
24990
  }
24887
24991
  onRender(props) {
24888
24992
  const { id, zIndex,...restProps } = props;
24889
- const { fontFamily, fontStyle, fontSize, fontColor, titleMargin, borderColor, borderWidth, onTargetEnter: { borderColor: onTargetEnterBorderColor, fill: onTargetEnterFill }, onTargetLeave: { borderColor: onTargetLeaveBorderColor, fill: onTargetLeaveFill } } = this.config;
24993
+ const { fontFamily, fontStyle, fontSize, fontColor, titleMargin, borderColor, borderWidth, onTargetEnter: { borderColor: onTargetEnterBorderColor, fill: onTargetEnterFill } } = this.config;
24890
24994
  const frameParams = { ...restProps };
24891
24995
  const frame = new konva.default.Group({
24892
24996
  ...frameParams,
@@ -24920,13 +25024,14 @@ var WeaveFrameNode = class extends WeaveNode {
24920
25024
  nodeId: id,
24921
25025
  x: 0,
24922
25026
  y: 0,
25027
+ onTargetEnter: false,
24923
25028
  width: props.frameWidth,
24924
25029
  stroke: borderColor,
24925
25030
  strokeWidth: borderWidth,
24926
25031
  strokeScaleEnabled: true,
24927
25032
  shadowForStrokeEnabled: false,
24928
25033
  height: props.frameHeight,
24929
- fill: frameParams.frameBackground ?? "#ffffffff",
25034
+ fill: frameParams.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR,
24930
25035
  listening: false,
24931
25036
  draggable: false
24932
25037
  });
@@ -24936,7 +25041,7 @@ var WeaveFrameNode = class extends WeaveNode {
24936
25041
  id: `${id}-title`,
24937
25042
  x: 0,
24938
25043
  width: props.frameWidth,
24939
- fontSize: fontSize / stage.scaleX(),
25044
+ fontSize,
24940
25045
  fontFamily,
24941
25046
  fontStyle,
24942
25047
  verticalAlign: "middle",
@@ -24989,7 +25094,9 @@ var WeaveFrameNode = class extends WeaveNode {
24989
25094
  ctx.rect(0, -textHeight, props.frameWidth, textHeight);
24990
25095
  ctx.fillStrokeShape(shape);
24991
25096
  },
25097
+ strokeWidth: 0,
24992
25098
  fill: "transparent",
25099
+ nodeId: id,
24993
25100
  id: `${id}-selection-area`,
24994
25101
  listening: true,
24995
25102
  draggable: true,
@@ -25006,6 +25113,7 @@ var WeaveFrameNode = class extends WeaveNode {
25006
25113
  ctx.rect(0, 0, props.frameWidth, props.frameHeight);
25007
25114
  ctx.fillStrokeShape(shape);
25008
25115
  },
25116
+ strokeWidth: 0,
25009
25117
  fill: "transparent",
25010
25118
  nodeId: id,
25011
25119
  id: `${id}-container-area`,
@@ -25038,29 +25146,24 @@ var WeaveFrameNode = class extends WeaveNode {
25038
25146
  selectionArea.off("dragend");
25039
25147
  this.setupDefaultNodeEvents(frame);
25040
25148
  this.instance.addEventListener("onZoomChange", () => {
25041
- const stage$1 = this.instance.getStage();
25042
- text.fontSize(fontSize / stage$1.scaleX());
25043
- text.width(props.frameWidth);
25044
- const textMeasures$1 = text.measureSize(text.getAttrs().text ?? "");
25045
- const textHeight$1 = textMeasures$1.height + 2 * titleMargin / stage$1.scaleX();
25046
- text.y(-textHeight$1);
25047
- text.height(textHeight$1);
25048
25149
  selectionArea.hitFunc(function(ctx, shape) {
25049
25150
  ctx.beginPath();
25050
- ctx.rect(0, -textHeight$1, props.frameWidth, textHeight$1);
25151
+ ctx.rect(0, -textHeight, props.frameWidth, textHeight);
25051
25152
  ctx.fillStrokeShape(shape);
25052
25153
  });
25053
25154
  });
25054
25155
  frame.off("pointerover");
25055
25156
  frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
25056
25157
  background.setAttrs({
25057
- stroke: onTargetLeaveBorderColor,
25158
+ onTargetEnter: false,
25159
+ stroke: borderColor,
25058
25160
  strokeWidth: borderWidth,
25059
- fill: onTargetLeaveFill
25161
+ fill: frameParams.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
25060
25162
  });
25061
25163
  });
25062
25164
  frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
25063
25165
  background.setAttrs({
25166
+ onTargetEnter: true,
25064
25167
  stroke: onTargetEnterBorderColor,
25065
25168
  strokeWidth: borderWidth,
25066
25169
  fill: onTargetEnterFill
@@ -25082,11 +25185,11 @@ var WeaveFrameNode = class extends WeaveNode {
25082
25185
  const title = stage.findOne(`#${newProps.id}-title`);
25083
25186
  const background = stage.findOne(`#${newProps.id}-bg`);
25084
25187
  const selectionArea = stage.findOne(`#${newProps.id}-selection-area`);
25085
- if (background) background.setAttrs({ fill: newProps.frameBackground ?? "#ffffffff" });
25188
+ if (background && !newProps.onTargetEnter) background.setAttrs({ fill: newProps.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR });
25086
25189
  if (title && selectionArea) {
25087
25190
  title.text(newProps.title);
25088
25191
  const textMeasures = title.measureSize(title.getAttrs().text ?? "");
25089
- const textHeight = textMeasures.height + 2 * titleMargin / stage.scaleX();
25192
+ const textHeight = textMeasures.height + 2 * titleMargin;
25090
25193
  title.y(-textHeight);
25091
25194
  title.height(textHeight);
25092
25195
  selectionArea.hitFunc(function(ctx, shape) {
@@ -25115,6 +25218,7 @@ var WeaveFrameNode = class extends WeaveNode {
25115
25218
  const realAttrs = mainNode?.getAttrs();
25116
25219
  const cleanedAttrs = { ...realAttrs };
25117
25220
  delete cleanedAttrs.draggable;
25221
+ delete cleanedAttrs.onTargetEnter;
25118
25222
  return {
25119
25223
  key: realAttrs?.id ?? "",
25120
25224
  type: realAttrs?.nodeType,
@@ -26233,7 +26337,8 @@ var WeaveVideoNode = class extends WeaveNode {
26233
26337
  id: `${id}-bg`,
26234
26338
  fill: this.config.style.background.color,
26235
26339
  stroke: this.config.style.background.strokeColor,
26236
- strokeWidth: this.config.style.background.strokeWidth
26340
+ strokeWidth: this.config.style.background.strokeWidth,
26341
+ nodeId: id
26237
26342
  });
26238
26343
  videoGroup.add(bg);
26239
26344
  if (!isServer()) {
@@ -26245,7 +26350,8 @@ var WeaveVideoNode = class extends WeaveNode {
26245
26350
  y: 0,
26246
26351
  draggable: false,
26247
26352
  image: void 0,
26248
- name: void 0
26353
+ name: void 0,
26354
+ nodeId: id
26249
26355
  });
26250
26356
  video.hide();
26251
26357
  videoGroup.add(video);
@@ -26258,7 +26364,8 @@ var WeaveVideoNode = class extends WeaveNode {
26258
26364
  height: this.config.style.track.height / this.instance.getStage().scaleY(),
26259
26365
  strokeWidth: 0,
26260
26366
  fill: this.config.style.track.color,
26261
- name: void 0
26367
+ name: void 0,
26368
+ nodeId: id
26262
26369
  });
26263
26370
  this.instance.addEventListener("onZoomChange", () => {
26264
26371
  videoProgress.height(this.config.style.track.height / this.instance.getStage().scaleY());
@@ -26274,7 +26381,8 @@ var WeaveVideoNode = class extends WeaveNode {
26274
26381
  y: 0,
26275
26382
  draggable: false,
26276
26383
  image: void 0,
26277
- name: void 0
26384
+ name: void 0,
26385
+ nodeId: id
26278
26386
  });
26279
26387
  videoPlaceholder.show();
26280
26388
  videoGroup.add(videoPlaceholder);
@@ -26292,7 +26400,8 @@ var WeaveVideoNode = class extends WeaveNode {
26292
26400
  height: this.config.style.icon.internal.paddingY * 2 + this.config.style.icon.height,
26293
26401
  strokeWidth: this.config.style.iconBackground.strokeWidth,
26294
26402
  stroke: this.config.style.iconBackground.strokeColor,
26295
- fill: this.config.style.iconBackground.color
26403
+ fill: this.config.style.iconBackground.color,
26404
+ nodeId: id
26296
26405
  });
26297
26406
  videoIconGroup.add(videoIconBg);
26298
26407
  const videoIcon = new konva.default.Image({
@@ -26303,7 +26412,8 @@ var WeaveVideoNode = class extends WeaveNode {
26303
26412
  width: this.config.style.icon.width,
26304
26413
  height: this.config.style.icon.height,
26305
26414
  fill: "transparent",
26306
- image: this.videoIconImage
26415
+ image: this.videoIconImage,
26416
+ nodeId: id
26307
26417
  });
26308
26418
  videoIconGroup.add(videoIcon);
26309
26419
  videoGroup.add(videoIconGroup);
@@ -30559,18 +30669,18 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
30559
30669
  }
30560
30670
  };
30561
30671
 
30562
- //#endregion
30563
- //#region src/plugins/stage-panning/constants.ts
30564
- const WEAVE_STAGE_PANNING_KEY = "stagePanning";
30565
-
30566
30672
  //#endregion
30567
30673
  //#region src/plugins/stage-panning/stage-panning.ts
30568
30674
  var WeaveStagePanningPlugin = class extends WeavePlugin {
30569
30675
  panning = false;
30676
+ currentPointer = null;
30677
+ stageScrollInterval = void 0;
30678
+ targetScrollIntervals = {};
30570
30679
  getLayerName = void 0;
30571
30680
  initLayer = void 0;
30572
- constructor() {
30681
+ constructor(params) {
30573
30682
  super();
30683
+ this.config = (0, import_merge.default)(WEAVE_STAGE_PANNING_DEFAULT_CONFIG, params?.config ?? {});
30574
30684
  this.pointers = new Map();
30575
30685
  this.panning = false;
30576
30686
  this.isDragging = false;
@@ -30652,6 +30762,8 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30652
30762
  lastPos = null;
30653
30763
  });
30654
30764
  const handleMouseMove = (e) => {
30765
+ const pos = stage.getPointerPosition();
30766
+ if (pos) this.currentPointer = pos;
30655
30767
  if (["touch", "pen"].includes(e.evt.pointerType) && e.evt.buttons !== 1) return;
30656
30768
  this.pointers.set(e.evt.pointerId, {
30657
30769
  x: e.evt.clientX,
@@ -30661,7 +30773,6 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30661
30773
  if (this.isSpaceKeyPressed) stage.container().style.cursor = "grabbing";
30662
30774
  if (!this.isDragging) return;
30663
30775
  this.getContextMenuPlugin()?.cancelLongPressTimer();
30664
- const pos = stage.getPointerPosition();
30665
30776
  if (pos && lastPos) {
30666
30777
  const dx = pos.x - lastPos.x;
30667
30778
  const dy = pos.y - lastPos.y;
@@ -30697,6 +30808,65 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30697
30808
  this.instance.emitEvent("onStageMove");
30698
30809
  };
30699
30810
  window.addEventListener("wheel", handleWheel, { passive: true });
30811
+ stage.on("dragstart", (e) => {
30812
+ const duration = 1e3 / 60;
30813
+ if (this.targetScrollIntervals[e.target.getAttrs().id ?? ""] !== void 0) return;
30814
+ this.targetScrollIntervals[e.target.getAttrs().id ?? ""] = setInterval(() => {
30815
+ const pos = stage.getPointerPosition();
30816
+ const offset = this.config.edgePanOffset;
30817
+ const speed = this.config.edgePanSpeed;
30818
+ if (!pos) return;
30819
+ const isNearLeft = pos.x < offset / stage.scaleX();
30820
+ if (isNearLeft) e.target.x(e.target.x() - speed / stage.scaleX());
30821
+ const isNearRight = pos.x > stage.width() - offset / stage.scaleX();
30822
+ if (isNearRight) e.target.x(e.target.x() + speed / stage.scaleX());
30823
+ const isNearTop = pos.y < offset / stage.scaleY();
30824
+ if (isNearTop) e.target.y(e.target.y() - speed / stage.scaleX());
30825
+ const isNearBottom = pos.y > stage.height() - offset / stage.scaleY();
30826
+ if (isNearBottom) e.target.y(e.target.y() + speed / stage.scaleX());
30827
+ this.getStageGridPlugin()?.renderGrid();
30828
+ }, duration);
30829
+ if (this.stageScrollInterval !== void 0) return;
30830
+ this.stageScrollInterval = setInterval(() => {
30831
+ const pos = stage.getPointerPosition();
30832
+ const offset = this.config.edgePanOffset;
30833
+ const speed = this.config.edgePanSpeed;
30834
+ if (!pos) return;
30835
+ let isOnBorder = false;
30836
+ const isNearLeft = pos.x < offset;
30837
+ if (isNearLeft) {
30838
+ stage.x(stage.x() + speed);
30839
+ isOnBorder = true;
30840
+ }
30841
+ const isNearRight = pos.x > stage.width() - offset;
30842
+ if (isNearRight) {
30843
+ stage.x(stage.x() - speed);
30844
+ isOnBorder = true;
30845
+ }
30846
+ const isNearTop = pos.y < offset;
30847
+ if (isNearTop) {
30848
+ stage.y(stage.y() + speed);
30849
+ isOnBorder = true;
30850
+ }
30851
+ const isNearBottom = pos.y > stage.height() - offset;
30852
+ if (isNearBottom) {
30853
+ stage.y(stage.y() - speed);
30854
+ isOnBorder = true;
30855
+ }
30856
+ if (isOnBorder) {
30857
+ this.getNodesEdgeSnappingPlugin()?.disable();
30858
+ this.getNodesDistanceSnappingPlugin()?.disable();
30859
+ }
30860
+ if (!isOnBorder) {
30861
+ this.getNodesEdgeSnappingPlugin()?.enable();
30862
+ this.getNodesDistanceSnappingPlugin()?.enable();
30863
+ }
30864
+ this.getStageGridPlugin()?.renderGrid();
30865
+ }, duration);
30866
+ });
30867
+ stage.on("dragend", () => {
30868
+ this.cleanupEdgeMoveIntervals();
30869
+ });
30700
30870
  stage.container().style.touchAction = "none";
30701
30871
  stage.container().style.userSelect = "none";
30702
30872
  stage.container().style.setProperty("-webkit-user-drag", "none");
@@ -30741,6 +30911,22 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30741
30911
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
30742
30912
  return snappingPlugin;
30743
30913
  }
30914
+ getStageGridPlugin() {
30915
+ const gridPlugin = this.instance.getPlugin("stageGrid");
30916
+ return gridPlugin;
30917
+ }
30918
+ getCurrentPointer() {
30919
+ return this.currentPointer;
30920
+ }
30921
+ cleanupEdgeMoveIntervals() {
30922
+ const intervals = Object.keys(this.targetScrollIntervals);
30923
+ for (const key of intervals) {
30924
+ clearInterval(this.targetScrollIntervals[key]);
30925
+ this.targetScrollIntervals[key] = void 0;
30926
+ }
30927
+ clearInterval(this.stageScrollInterval);
30928
+ this.stageScrollInterval = void 0;
30929
+ }
30744
30930
  enable() {
30745
30931
  this.enabled = true;
30746
30932
  }
@@ -31751,6 +31937,7 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
31751
31937
  this.enabled = true;
31752
31938
  }
31753
31939
  disable() {
31940
+ this.cleanupGuidelines();
31754
31941
  this.enabled = false;
31755
31942
  }
31756
31943
  };
@@ -32335,6 +32522,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
32335
32522
  this.enabled = true;
32336
32523
  }
32337
32524
  disable() {
32525
+ this.cleanupGuidelines();
32338
32526
  this.enabled = false;
32339
32527
  }
32340
32528
  };
@@ -32552,6 +32740,7 @@ exports.WEAVE_COPY_PASTE_PASTE_CATCHER_ID = WEAVE_COPY_PASTE_PASTE_CATCHER_ID
32552
32740
  exports.WEAVE_COPY_PASTE_PASTE_MODES = WEAVE_COPY_PASTE_PASTE_MODES
32553
32741
  exports.WEAVE_DEFAULT_USER_INFO_FUNCTION = WEAVE_DEFAULT_USER_INFO_FUNCTION
32554
32742
  exports.WEAVE_ELLIPSE_NODE_TYPE = WEAVE_ELLIPSE_NODE_TYPE
32743
+ exports.WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR = WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
32555
32744
  exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
32556
32745
  exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
32557
32746
  exports.WEAVE_FRAME_NODE_TYPE = WEAVE_FRAME_NODE_TYPE
@@ -32585,6 +32774,8 @@ exports.WEAVE_STAGE_GRID_PLUGIN_KEY = WEAVE_STAGE_GRID_PLUGIN_KEY
32585
32774
  exports.WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG = WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG
32586
32775
  exports.WEAVE_STAGE_KEYBOARD_MOVE_KEY = WEAVE_STAGE_KEYBOARD_MOVE_KEY
32587
32776
  exports.WEAVE_STAGE_NODE_TYPE = WEAVE_STAGE_NODE_TYPE
32777
+ exports.WEAVE_STAGE_PANNING_DEFAULT_CONFIG = WEAVE_STAGE_PANNING_DEFAULT_CONFIG
32778
+ exports.WEAVE_STAGE_PANNING_KEY = WEAVE_STAGE_PANNING_KEY
32588
32779
  exports.WEAVE_STAR_NODE_TYPE = WEAVE_STAR_NODE_TYPE
32589
32780
  exports.WEAVE_STROKE_NODE_DEFAULT_CONFIG = WEAVE_STROKE_NODE_DEFAULT_CONFIG
32590
32781
  exports.WEAVE_STROKE_NODE_TYPE = WEAVE_STROKE_NODE_TYPE