@inditextech/weave-sdk 0.73.0 → 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
  });
@@ -19475,11 +19492,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19475
19492
  const contextMenuPlugin = this.getContextMenuPlugin();
19476
19493
  if (moved) contextMenuPlugin?.cancelLongPressTimer();
19477
19494
  else this.hideSelectorArea();
19478
- if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
19479
- this.selecting = false;
19480
- this.stopPanLoop();
19481
- return;
19482
- }
19495
+ if (contextMenuPlugin?.isContextMenuVisible()) this.stopPanLoop();
19483
19496
  if (this.isSpaceKeyPressed) return;
19484
19497
  if (!this.selecting) return;
19485
19498
  this.updateSelectionRect();
@@ -19533,11 +19546,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19533
19546
  this.hideSelectorArea();
19534
19547
  return;
19535
19548
  }
19536
- if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
19537
- this.selecting = false;
19538
- this.stopPanLoop();
19539
- return;
19540
- }
19549
+ if (contextMenuPlugin?.isContextMenuVisible()) this.stopPanLoop();
19541
19550
  if (!this.selectionRectangle.visible()) {
19542
19551
  this.hideSelectorArea();
19543
19552
  return;
@@ -19628,11 +19637,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19628
19637
  if (!this.enabled) return;
19629
19638
  if (this.instance.getActiveAction() !== SELECTION_TOOL_ACTION_NAME) return;
19630
19639
  const contextMenuPlugin = this.getContextMenuPlugin();
19631
- if (contextMenuPlugin?.isContextMenuVisible()) {
19632
- this.selecting = false;
19633
- this.stopPanLoop();
19634
- return;
19635
- }
19640
+ if (contextMenuPlugin?.isContextMenuVisible()) this.stopPanLoop();
19636
19641
  this.hideHoverState();
19637
19642
  const selectedGroup = getTargetedNode(this.instance);
19638
19643
  if (!this.initialized) return;
@@ -19775,6 +19780,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19775
19780
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
19776
19781
  return snappingPlugin;
19777
19782
  }
19783
+ getStagePanningPlugin() {
19784
+ const stagePanning = this.instance.getPlugin(WEAVE_STAGE_PANNING_KEY);
19785
+ return stagePanning;
19786
+ }
19778
19787
  getSelectorConfig() {
19779
19788
  return this.config.selection;
19780
19789
  }
@@ -20348,69 +20357,98 @@ var WeaveNode = class {
20348
20357
  const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
20349
20358
  if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
20350
20359
  });
20360
+ let clone = void 0;
20351
20361
  node.on("dragstart", (e) => {
20362
+ const nodeTarget = e.target;
20352
20363
  this.didMove = false;
20353
20364
  if (e.evt?.buttons === 0) {
20354
- e.target.stopDrag();
20365
+ nodeTarget.stopDrag();
20355
20366
  return;
20356
20367
  }
20357
20368
  const stage = this.instance.getStage();
20358
20369
  const isErasing = this.instance.getActiveAction() === "eraseTool";
20359
20370
  if (isErasing) {
20360
- e.target.stopDrag();
20371
+ nodeTarget.stopDrag();
20361
20372
  return;
20362
20373
  }
20363
- this.instance.emitEvent("onDrag", e.target);
20374
+ this.instance.emitEvent("onDrag", nodeTarget);
20364
20375
  if (stage.isMouseWheelPressed()) {
20365
20376
  e.cancelBubble = true;
20366
- 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);
20367
20396
  }
20368
20397
  });
20369
20398
  const handleDragMove = (e) => {
20399
+ const nodeTarget = e.target;
20400
+ e.cancelBubble = true;
20370
20401
  if (e.evt?.buttons === 0) {
20371
- e.target.stopDrag();
20402
+ nodeTarget.stopDrag();
20372
20403
  return;
20373
20404
  }
20374
20405
  this.didMove = true;
20375
20406
  const stage = this.instance.getStage();
20376
20407
  const isErasing = this.instance.getActiveAction() === "eraseTool";
20377
20408
  if (isErasing) {
20378
- e.target.stopDrag();
20409
+ nodeTarget.stopDrag();
20379
20410
  return;
20380
20411
  }
20381
20412
  if (stage.isMouseWheelPressed()) {
20382
20413
  e.cancelBubble = true;
20383
- e.target.stopDrag();
20414
+ nodeTarget.stopDrag();
20384
20415
  return;
20385
20416
  }
20386
- 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) {
20387
20419
  clearContainerTargets(this.instance);
20388
- const layerToMove = containerOverCursor(this.instance, [node]);
20389
- 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 });
20390
20422
  }
20391
20423
  };
20392
20424
  node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
20393
20425
  node.on("dragend", (e) => {
20426
+ const nodeTarget = e.target;
20427
+ e.cancelBubble = true;
20428
+ if (clone) clone = void 0;
20394
20429
  if (!this.didMove) return;
20395
20430
  const isErasing = this.instance.getActiveAction() === "eraseTool";
20396
20431
  if (isErasing) {
20397
- e.target.stopDrag();
20432
+ nodeTarget.stopDrag();
20398
20433
  return;
20399
20434
  }
20400
20435
  this.instance.emitEvent("onDrag", null);
20401
- 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) {
20402
20438
  clearContainerTargets(this.instance);
20403
20439
  const nodesEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
20404
20440
  const nodesDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
20405
20441
  if (nodesEdgeSnappingPlugin) nodesEdgeSnappingPlugin.cleanupGuidelines();
20406
20442
  if (nodesDistanceSnappingPlugin) nodesDistanceSnappingPlugin.cleanupGuidelines();
20407
- const layerToMove = containerOverCursor(this.instance, [node]);
20443
+ const layerToMove = containerOverCursor(this.instance, [realNodeTarget]);
20408
20444
  let containerToMove = this.instance.getMainLayer();
20409
20445
  if (layerToMove) containerToMove = layerToMove;
20410
20446
  let moved = false;
20411
- 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 });
20412
20450
  if (containerToMove) containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
20413
- if (!moved) this.instance.updateNode(this.serialize(node));
20451
+ if (!moved) this.instance.updateNode(this.serialize(realNodeTarget));
20414
20452
  }
20415
20453
  });
20416
20454
  node.handleMouseover = () => {
@@ -20568,6 +20606,10 @@ var WeaveNode = class {
20568
20606
  };
20569
20607
  return (0, import_merge.default)(transformProperties, nodeTransformConfig ?? {});
20570
20608
  }
20609
+ getNodesSelectionPlugin() {
20610
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
20611
+ return nodesSelectionPlugin;
20612
+ }
20571
20613
  getNodesEdgeSnappingPlugin() {
20572
20614
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY);
20573
20615
  return snappingPlugin;
@@ -20582,6 +20624,17 @@ var WeaveNode = class {
20582
20624
  y: 0
20583
20625
  };
20584
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
+ }
20585
20638
  };
20586
20639
 
20587
20640
  //#endregion
@@ -21402,6 +21455,7 @@ var WeaveTargetingManager = class {
21402
21455
  //#endregion
21403
21456
  //#region src/managers/cloning.ts
21404
21457
  var WeaveCloningManager = class {
21458
+ clones = [];
21405
21459
  constructor(instance) {
21406
21460
  this.instance = instance;
21407
21461
  this.logger = this.instance.getChildLogger("cloning-manager");
@@ -21560,6 +21614,42 @@ var WeaveCloningManager = class {
21560
21614
  }
21561
21615
  newGroup.destroy();
21562
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
+ }
21563
21653
  };
21564
21654
 
21565
21655
  //#endregion
@@ -21963,7 +22053,7 @@ var WeaveRegisterManager = class {
21963
22053
 
21964
22054
  //#endregion
21965
22055
  //#region package.json
21966
- var version = "0.73.0";
22056
+ var version = "0.74.0";
21967
22057
 
21968
22058
  //#endregion
21969
22059
  //#region src/managers/setup.ts
@@ -22781,7 +22871,7 @@ var Weave = class {
22781
22871
  getNodeContainerId(node) {
22782
22872
  const stage = this.getStage();
22783
22873
  let nodeContainer = node.getParent()?.getAttrs().id ?? "";
22784
- if (typeof node.getParent()?.getAttrs().nodeId !== "undefined") {
22874
+ if (typeof node?.getParent()?.getAttrs().nodeId !== "undefined") {
22785
22875
  const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
22786
22876
  if (realContainer) nodeContainer = realContainer.getAttrs().id ?? "";
22787
22877
  }
@@ -22789,8 +22879,8 @@ var Weave = class {
22789
22879
  }
22790
22880
  getNodeContainer(node) {
22791
22881
  const stage = this.getStage();
22792
- let nodeContainer = node.getParent();
22793
- if (typeof node.getParent()?.getAttrs().nodeId !== "undefined") {
22882
+ let nodeContainer = node?.getParent();
22883
+ if (typeof node?.getParent()?.getAttrs().nodeId !== "undefined") {
22794
22884
  const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
22795
22885
  if (realContainer) nodeContainer = realContainer;
22796
22886
  }
@@ -22845,6 +22935,9 @@ var Weave = class {
22845
22935
  selectionPlugin.setSelectedNodes(instanceNodes);
22846
22936
  }
22847
22937
  }
22938
+ getCloningManager() {
22939
+ return this.cloningManager;
22940
+ }
22848
22941
  nodesToGroupSerialized(instancesToClone) {
22849
22942
  return this.cloningManager.nodesToGroupSerialized(instancesToClone);
22850
22943
  }
@@ -24844,17 +24937,13 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
24844
24937
  fontFamily: "Arial",
24845
24938
  fontStyle: "bold",
24846
24939
  fontSize: 20,
24847
- fontColor: "#000000ff",
24940
+ fontColor: "#000000",
24848
24941
  titleMargin: 20,
24849
- borderColor: "#000000ff",
24942
+ borderColor: "#000000",
24850
24943
  borderWidth: 1,
24851
- onTargetLeave: {
24852
- borderColor: "#000000ff",
24853
- fill: "#ffffffff"
24854
- },
24855
24944
  onTargetEnter: {
24856
- borderColor: "#ff6863ff",
24857
- fill: "#ffffffff"
24945
+ borderColor: "#FF6863FF",
24946
+ fill: "#FFFFFFFF"
24858
24947
  },
24859
24948
  transform: {
24860
24949
  rotateEnabled: false,
@@ -24864,10 +24953,12 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
24864
24953
  padding: 0
24865
24954
  }
24866
24955
  };
24956
+ const WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR = "#FFFFFFFF";
24867
24957
  const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
24868
24958
  title: "Frame XXX",
24869
24959
  frameWidth: 1920,
24870
- frameHeight: 1080
24960
+ frameHeight: 1080,
24961
+ frameBackground: WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
24871
24962
  };
24872
24963
 
24873
24964
  //#endregion
@@ -24892,13 +24983,14 @@ var WeaveFrameNode = class extends WeaveNode {
24892
24983
  ...props.title && { title: props.title },
24893
24984
  ...props.frameWidth && { frameWidth: props.frameWidth },
24894
24985
  ...props.frameHeight && { frameHeight: props.frameHeight },
24986
+ ...props.frameBackground && { frameBackground: props.frameBackground },
24895
24987
  children: []
24896
24988
  }
24897
24989
  };
24898
24990
  }
24899
24991
  onRender(props) {
24900
24992
  const { id, zIndex,...restProps } = props;
24901
- 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;
24902
24994
  const frameParams = { ...restProps };
24903
24995
  const frame = new konva.default.Group({
24904
24996
  ...frameParams,
@@ -24932,13 +25024,14 @@ var WeaveFrameNode = class extends WeaveNode {
24932
25024
  nodeId: id,
24933
25025
  x: 0,
24934
25026
  y: 0,
25027
+ onTargetEnter: false,
24935
25028
  width: props.frameWidth,
24936
25029
  stroke: borderColor,
24937
25030
  strokeWidth: borderWidth,
24938
25031
  strokeScaleEnabled: true,
24939
25032
  shadowForStrokeEnabled: false,
24940
25033
  height: props.frameHeight,
24941
- fill: frameParams.frameBackground ?? "#ffffffff",
25034
+ fill: frameParams.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR,
24942
25035
  listening: false,
24943
25036
  draggable: false
24944
25037
  });
@@ -24948,7 +25041,7 @@ var WeaveFrameNode = class extends WeaveNode {
24948
25041
  id: `${id}-title`,
24949
25042
  x: 0,
24950
25043
  width: props.frameWidth,
24951
- fontSize: fontSize / stage.scaleX(),
25044
+ fontSize,
24952
25045
  fontFamily,
24953
25046
  fontStyle,
24954
25047
  verticalAlign: "middle",
@@ -25001,7 +25094,9 @@ var WeaveFrameNode = class extends WeaveNode {
25001
25094
  ctx.rect(0, -textHeight, props.frameWidth, textHeight);
25002
25095
  ctx.fillStrokeShape(shape);
25003
25096
  },
25097
+ strokeWidth: 0,
25004
25098
  fill: "transparent",
25099
+ nodeId: id,
25005
25100
  id: `${id}-selection-area`,
25006
25101
  listening: true,
25007
25102
  draggable: true,
@@ -25018,6 +25113,7 @@ var WeaveFrameNode = class extends WeaveNode {
25018
25113
  ctx.rect(0, 0, props.frameWidth, props.frameHeight);
25019
25114
  ctx.fillStrokeShape(shape);
25020
25115
  },
25116
+ strokeWidth: 0,
25021
25117
  fill: "transparent",
25022
25118
  nodeId: id,
25023
25119
  id: `${id}-container-area`,
@@ -25050,29 +25146,24 @@ var WeaveFrameNode = class extends WeaveNode {
25050
25146
  selectionArea.off("dragend");
25051
25147
  this.setupDefaultNodeEvents(frame);
25052
25148
  this.instance.addEventListener("onZoomChange", () => {
25053
- const stage$1 = this.instance.getStage();
25054
- text.fontSize(fontSize / stage$1.scaleX());
25055
- text.width(props.frameWidth);
25056
- const textMeasures$1 = text.measureSize(text.getAttrs().text ?? "");
25057
- const textHeight$1 = textMeasures$1.height + 2 * titleMargin / stage$1.scaleX();
25058
- text.y(-textHeight$1);
25059
- text.height(textHeight$1);
25060
25149
  selectionArea.hitFunc(function(ctx, shape) {
25061
25150
  ctx.beginPath();
25062
- ctx.rect(0, -textHeight$1, props.frameWidth, textHeight$1);
25151
+ ctx.rect(0, -textHeight, props.frameWidth, textHeight);
25063
25152
  ctx.fillStrokeShape(shape);
25064
25153
  });
25065
25154
  });
25066
25155
  frame.off("pointerover");
25067
25156
  frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
25068
25157
  background.setAttrs({
25069
- stroke: onTargetLeaveBorderColor,
25158
+ onTargetEnter: false,
25159
+ stroke: borderColor,
25070
25160
  strokeWidth: borderWidth,
25071
- fill: onTargetLeaveFill
25161
+ fill: frameParams.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
25072
25162
  });
25073
25163
  });
25074
25164
  frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
25075
25165
  background.setAttrs({
25166
+ onTargetEnter: true,
25076
25167
  stroke: onTargetEnterBorderColor,
25077
25168
  strokeWidth: borderWidth,
25078
25169
  fill: onTargetEnterFill
@@ -25094,11 +25185,11 @@ var WeaveFrameNode = class extends WeaveNode {
25094
25185
  const title = stage.findOne(`#${newProps.id}-title`);
25095
25186
  const background = stage.findOne(`#${newProps.id}-bg`);
25096
25187
  const selectionArea = stage.findOne(`#${newProps.id}-selection-area`);
25097
- if (background) background.setAttrs({ fill: newProps.frameBackground ?? "#ffffffff" });
25188
+ if (background && !newProps.onTargetEnter) background.setAttrs({ fill: newProps.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR });
25098
25189
  if (title && selectionArea) {
25099
25190
  title.text(newProps.title);
25100
25191
  const textMeasures = title.measureSize(title.getAttrs().text ?? "");
25101
- const textHeight = textMeasures.height + 2 * titleMargin / stage.scaleX();
25192
+ const textHeight = textMeasures.height + 2 * titleMargin;
25102
25193
  title.y(-textHeight);
25103
25194
  title.height(textHeight);
25104
25195
  selectionArea.hitFunc(function(ctx, shape) {
@@ -25127,6 +25218,7 @@ var WeaveFrameNode = class extends WeaveNode {
25127
25218
  const realAttrs = mainNode?.getAttrs();
25128
25219
  const cleanedAttrs = { ...realAttrs };
25129
25220
  delete cleanedAttrs.draggable;
25221
+ delete cleanedAttrs.onTargetEnter;
25130
25222
  return {
25131
25223
  key: realAttrs?.id ?? "",
25132
25224
  type: realAttrs?.nodeType,
@@ -26245,7 +26337,8 @@ var WeaveVideoNode = class extends WeaveNode {
26245
26337
  id: `${id}-bg`,
26246
26338
  fill: this.config.style.background.color,
26247
26339
  stroke: this.config.style.background.strokeColor,
26248
- strokeWidth: this.config.style.background.strokeWidth
26340
+ strokeWidth: this.config.style.background.strokeWidth,
26341
+ nodeId: id
26249
26342
  });
26250
26343
  videoGroup.add(bg);
26251
26344
  if (!isServer()) {
@@ -26257,7 +26350,8 @@ var WeaveVideoNode = class extends WeaveNode {
26257
26350
  y: 0,
26258
26351
  draggable: false,
26259
26352
  image: void 0,
26260
- name: void 0
26353
+ name: void 0,
26354
+ nodeId: id
26261
26355
  });
26262
26356
  video.hide();
26263
26357
  videoGroup.add(video);
@@ -26270,7 +26364,8 @@ var WeaveVideoNode = class extends WeaveNode {
26270
26364
  height: this.config.style.track.height / this.instance.getStage().scaleY(),
26271
26365
  strokeWidth: 0,
26272
26366
  fill: this.config.style.track.color,
26273
- name: void 0
26367
+ name: void 0,
26368
+ nodeId: id
26274
26369
  });
26275
26370
  this.instance.addEventListener("onZoomChange", () => {
26276
26371
  videoProgress.height(this.config.style.track.height / this.instance.getStage().scaleY());
@@ -26286,7 +26381,8 @@ var WeaveVideoNode = class extends WeaveNode {
26286
26381
  y: 0,
26287
26382
  draggable: false,
26288
26383
  image: void 0,
26289
- name: void 0
26384
+ name: void 0,
26385
+ nodeId: id
26290
26386
  });
26291
26387
  videoPlaceholder.show();
26292
26388
  videoGroup.add(videoPlaceholder);
@@ -26304,7 +26400,8 @@ var WeaveVideoNode = class extends WeaveNode {
26304
26400
  height: this.config.style.icon.internal.paddingY * 2 + this.config.style.icon.height,
26305
26401
  strokeWidth: this.config.style.iconBackground.strokeWidth,
26306
26402
  stroke: this.config.style.iconBackground.strokeColor,
26307
- fill: this.config.style.iconBackground.color
26403
+ fill: this.config.style.iconBackground.color,
26404
+ nodeId: id
26308
26405
  });
26309
26406
  videoIconGroup.add(videoIconBg);
26310
26407
  const videoIcon = new konva.default.Image({
@@ -26315,7 +26412,8 @@ var WeaveVideoNode = class extends WeaveNode {
26315
26412
  width: this.config.style.icon.width,
26316
26413
  height: this.config.style.icon.height,
26317
26414
  fill: "transparent",
26318
- image: this.videoIconImage
26415
+ image: this.videoIconImage,
26416
+ nodeId: id
26319
26417
  });
26320
26418
  videoIconGroup.add(videoIcon);
26321
26419
  videoGroup.add(videoIconGroup);
@@ -30571,18 +30669,18 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
30571
30669
  }
30572
30670
  };
30573
30671
 
30574
- //#endregion
30575
- //#region src/plugins/stage-panning/constants.ts
30576
- const WEAVE_STAGE_PANNING_KEY = "stagePanning";
30577
-
30578
30672
  //#endregion
30579
30673
  //#region src/plugins/stage-panning/stage-panning.ts
30580
30674
  var WeaveStagePanningPlugin = class extends WeavePlugin {
30581
30675
  panning = false;
30676
+ currentPointer = null;
30677
+ stageScrollInterval = void 0;
30678
+ targetScrollIntervals = {};
30582
30679
  getLayerName = void 0;
30583
30680
  initLayer = void 0;
30584
- constructor() {
30681
+ constructor(params) {
30585
30682
  super();
30683
+ this.config = (0, import_merge.default)(WEAVE_STAGE_PANNING_DEFAULT_CONFIG, params?.config ?? {});
30586
30684
  this.pointers = new Map();
30587
30685
  this.panning = false;
30588
30686
  this.isDragging = false;
@@ -30664,6 +30762,8 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30664
30762
  lastPos = null;
30665
30763
  });
30666
30764
  const handleMouseMove = (e) => {
30765
+ const pos = stage.getPointerPosition();
30766
+ if (pos) this.currentPointer = pos;
30667
30767
  if (["touch", "pen"].includes(e.evt.pointerType) && e.evt.buttons !== 1) return;
30668
30768
  this.pointers.set(e.evt.pointerId, {
30669
30769
  x: e.evt.clientX,
@@ -30673,7 +30773,6 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30673
30773
  if (this.isSpaceKeyPressed) stage.container().style.cursor = "grabbing";
30674
30774
  if (!this.isDragging) return;
30675
30775
  this.getContextMenuPlugin()?.cancelLongPressTimer();
30676
- const pos = stage.getPointerPosition();
30677
30776
  if (pos && lastPos) {
30678
30777
  const dx = pos.x - lastPos.x;
30679
30778
  const dy = pos.y - lastPos.y;
@@ -30709,6 +30808,65 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30709
30808
  this.instance.emitEvent("onStageMove");
30710
30809
  };
30711
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
+ });
30712
30870
  stage.container().style.touchAction = "none";
30713
30871
  stage.container().style.userSelect = "none";
30714
30872
  stage.container().style.setProperty("-webkit-user-drag", "none");
@@ -30753,6 +30911,22 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30753
30911
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
30754
30912
  return snappingPlugin;
30755
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
+ }
30756
30930
  enable() {
30757
30931
  this.enabled = true;
30758
30932
  }
@@ -31763,6 +31937,7 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
31763
31937
  this.enabled = true;
31764
31938
  }
31765
31939
  disable() {
31940
+ this.cleanupGuidelines();
31766
31941
  this.enabled = false;
31767
31942
  }
31768
31943
  };
@@ -32347,6 +32522,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
32347
32522
  this.enabled = true;
32348
32523
  }
32349
32524
  disable() {
32525
+ this.cleanupGuidelines();
32350
32526
  this.enabled = false;
32351
32527
  }
32352
32528
  };
@@ -32564,6 +32740,7 @@ exports.WEAVE_COPY_PASTE_PASTE_CATCHER_ID = WEAVE_COPY_PASTE_PASTE_CATCHER_ID
32564
32740
  exports.WEAVE_COPY_PASTE_PASTE_MODES = WEAVE_COPY_PASTE_PASTE_MODES
32565
32741
  exports.WEAVE_DEFAULT_USER_INFO_FUNCTION = WEAVE_DEFAULT_USER_INFO_FUNCTION
32566
32742
  exports.WEAVE_ELLIPSE_NODE_TYPE = WEAVE_ELLIPSE_NODE_TYPE
32743
+ exports.WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR = WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
32567
32744
  exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
32568
32745
  exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
32569
32746
  exports.WEAVE_FRAME_NODE_TYPE = WEAVE_FRAME_NODE_TYPE
@@ -32597,6 +32774,8 @@ exports.WEAVE_STAGE_GRID_PLUGIN_KEY = WEAVE_STAGE_GRID_PLUGIN_KEY
32597
32774
  exports.WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG = WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG
32598
32775
  exports.WEAVE_STAGE_KEYBOARD_MOVE_KEY = WEAVE_STAGE_KEYBOARD_MOVE_KEY
32599
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
32600
32779
  exports.WEAVE_STAR_NODE_TYPE = WEAVE_STAR_NODE_TYPE
32601
32780
  exports.WEAVE_STROKE_NODE_DEFAULT_CONFIG = WEAVE_STROKE_NODE_DEFAULT_CONFIG
32602
32781
  exports.WEAVE_STROKE_NODE_TYPE = WEAVE_STROKE_NODE_TYPE