@inditextech/weave-sdk 0.52.3 → 0.53.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
@@ -15925,6 +15925,27 @@ function getTopmostShadowHost(el) {
15925
15925
  }
15926
15926
  return current?.shadowRoot || null;
15927
15927
  }
15928
+ function getVisibleNodes(instance, stage, nodeParent, skipNodes, referenceLayer) {
15929
+ const nodesSelection = instance.getPlugin("nodesSelection");
15930
+ if (nodesSelection) nodesSelection.getTransformer().hide();
15931
+ const nodes = getVisibleNodesInViewport(stage, referenceLayer);
15932
+ const finalVisibleNodes = [];
15933
+ nodes.forEach((node) => {
15934
+ const actualNodeParent = instance.getNodeContainer(node);
15935
+ if (actualNodeParent?.getAttrs().id !== nodeParent?.getAttrs().id) return;
15936
+ if (node.getParent()?.getAttrs().nodeType === "group") return;
15937
+ if (skipNodes.includes(node.getParent()?.getAttrs().nodeId)) return;
15938
+ if (skipNodes.includes(node.getAttrs().id ?? "")) return;
15939
+ if (node.getParent() !== referenceLayer && !node.getParent()?.getAttrs().nodeId) return;
15940
+ if (node.getParent() !== referenceLayer && node.getParent()?.getAttrs().nodeId) {
15941
+ const realNode = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
15942
+ if (realNode && realNode !== referenceLayer) return;
15943
+ }
15944
+ finalVisibleNodes.push(node);
15945
+ });
15946
+ if (nodesSelection) nodesSelection.getTransformer().show();
15947
+ return finalVisibleNodes;
15948
+ }
15928
15949
 
15929
15950
  //#endregion
15930
15951
  //#region src/actions/selection-tool/constants.ts
@@ -16160,6 +16181,22 @@ const NODE_SNAP = {
16160
16181
  const WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY = "nodesDistanceSnapping";
16161
16182
  const GUIDE_HORIZONTAL_LINE_NAME = "guide-distance-snapping-horizontal-line";
16162
16183
  const GUIDE_VERTICAL_LINE_NAME = "guide-distance-snapping-vertical-line";
16184
+ const GUIDE_DISTANCE_LINE_DEFAULT_CONFIG = {
16185
+ line: {
16186
+ stroke: "#E12D3C",
16187
+ strokeWidth: 1
16188
+ },
16189
+ label: {
16190
+ linePadding: 10,
16191
+ height: 20,
16192
+ cornerRadius: 0,
16193
+ fill: "#E12D3C",
16194
+ fontStyle: "normal",
16195
+ fontSize: 14,
16196
+ fontFamily: "Arial",
16197
+ paddingX: 4
16198
+ }
16199
+ };
16163
16200
  const GUIDE_ENTER_SNAPPING_TOLERANCE = 3;
16164
16201
  const GUIDE_EXIT_SNAPPING_TOLERANCE = 5;
16165
16202
  const NODE_SNAP_HORIZONTAL = {
@@ -17134,9 +17171,11 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
17134
17171
  this.instance.addNode(node, containerId);
17135
17172
  const realNode = this.instance.getStage().findOne(`#${newNodeId}`);
17136
17173
  if (realNode) nodesToSelect.push(realNode);
17137
- this.instance.emitEvent("onPaste");
17138
17174
  }
17139
- this.instance.emitEvent("onPaste", void 0);
17175
+ this.instance.emitEvent("onPaste", {
17176
+ error: void 0,
17177
+ pastedNodes: nodesToSelect.map((n) => n.getAttrs().id ?? "")
17178
+ });
17140
17179
  const nodesSelectionPlugin = this.getNodesSelectionPlugin();
17141
17180
  nodesSelectionPlugin?.setSelectedNodes(nodesToSelect);
17142
17181
  this.toPaste = void 0;
@@ -17186,7 +17225,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
17186
17225
  await this.writeClipboardData(JSON.stringify(copyClipboard));
17187
17226
  this.instance.emitEvent("onCopy");
17188
17227
  } catch (ex) {
17189
- this.instance.emitEvent("onCopy", ex);
17228
+ this.instance.emitEvent("onCopy", { error: ex });
17190
17229
  }
17191
17230
  }
17192
17231
  async copy() {
@@ -17202,7 +17241,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
17202
17241
  return;
17203
17242
  }
17204
17243
  } catch (ex) {
17205
- this.instance.emitEvent("onPaste", ex);
17244
+ this.instance.emitEvent("onPaste", { error: ex });
17206
17245
  }
17207
17246
  try {
17208
17247
  const items = await navigator.clipboard.read();
@@ -17228,7 +17267,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
17228
17267
  items
17229
17268
  });
17230
17269
  } catch (ex) {
17231
- this.instance.emitEvent("onPaste", ex);
17270
+ this.instance.emitEvent("onPaste", { error: ex });
17232
17271
  }
17233
17272
  }
17234
17273
  getSelectedNodes() {
@@ -19190,7 +19229,7 @@ var WeaveRegisterManager = class {
19190
19229
 
19191
19230
  //#endregion
19192
19231
  //#region package.json
19193
- var version = "0.52.3";
19232
+ var version = "0.53.0";
19194
19233
 
19195
19234
  //#endregion
19196
19235
  //#region src/managers/setup.ts
@@ -19781,6 +19820,15 @@ var Weave = class {
19781
19820
  }
19782
19821
  return nodeContainer;
19783
19822
  }
19823
+ getNodeContainer(node) {
19824
+ const stage = this.getStage();
19825
+ let nodeContainer = node.getParent();
19826
+ if (typeof node.getParent()?.getAttrs().nodeId !== "undefined") {
19827
+ const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
19828
+ if (realContainer) nodeContainer = realContainer;
19829
+ }
19830
+ return nodeContainer;
19831
+ }
19784
19832
  moveUp(node) {
19785
19833
  this.zIndexManager.moveUp(node);
19786
19834
  }
@@ -25596,8 +25644,11 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25596
25644
  super();
25597
25645
  this.pointers = new Map();
25598
25646
  this.panning = false;
25647
+ this.isDragging = false;
25648
+ this.enableMove = false;
25599
25649
  this.enabled = true;
25600
25650
  this.moveToolActive = false;
25651
+ this.isMouseLeftButtonPressed = false;
25601
25652
  this.isMouseMiddleButtonPressed = false;
25602
25653
  this.isCtrlOrMetaPressed = false;
25603
25654
  this.isSpaceKeyPressed = false;
@@ -25609,7 +25660,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25609
25660
  onInit() {
25610
25661
  this.initEvents();
25611
25662
  }
25612
- enableMove() {
25663
+ setCursor() {
25613
25664
  const stage = this.instance.getStage();
25614
25665
  if (stage.container().style.cursor !== "grabbing") {
25615
25666
  this.previousPointer = stage.container().style.cursor;
@@ -25633,7 +25684,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25633
25684
  this.getNodesEdgeSnappingPlugin()?.disable();
25634
25685
  this.getNodesDistanceSnappingPlugin()?.disable();
25635
25686
  this.isSpaceKeyPressed = true;
25636
- this.enableMove();
25687
+ this.setCursor();
25637
25688
  }
25638
25689
  });
25639
25690
  window.addEventListener("keyup", (e) => {
@@ -25648,7 +25699,6 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25648
25699
  }
25649
25700
  });
25650
25701
  let lastPos = null;
25651
- let isDragging = false;
25652
25702
  stage.on("pointerdown", (e) => {
25653
25703
  this.pointers.set(e.evt.pointerId, {
25654
25704
  x: e.evt.clientX,
@@ -25656,14 +25706,15 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25656
25706
  });
25657
25707
  if (this.pointers.size > 1) return;
25658
25708
  const activeAction = this.instance.getActiveAction();
25659
- let enableMove = false;
25660
- if (e && (e.evt.pointerType !== "mouse" || e.evt.pointerType === "mouse" && e.evt.buttons === 1) && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
25661
- if (!enableMove && e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
25662
- if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive || this.isMouseMiddleButtonPressed)) enableMove = true;
25663
- if (enableMove) {
25664
- isDragging = true;
25709
+ this.enableMove = false;
25710
+ if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
25711
+ if (e.evt.pointerType === "mouse" && e.evt.buttons === 1) this.isMouseLeftButtonPressed = true;
25712
+ if (e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
25713
+ if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && this.isMouseLeftButtonPressed || this.isMouseMiddleButtonPressed)) this.enableMove = true;
25714
+ if (this.enableMove) {
25715
+ this.isDragging = true;
25665
25716
  lastPos = stage.getPointerPosition();
25666
- this.enableMove();
25717
+ this.setCursor();
25667
25718
  }
25668
25719
  });
25669
25720
  stage.on("pointercancel", (e) => {
@@ -25677,7 +25728,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25677
25728
  });
25678
25729
  if (this.pointers.size > 1) return;
25679
25730
  if (this.isSpaceKeyPressed) stage.container().style.cursor = "grabbing";
25680
- if (!isDragging) return;
25731
+ if (!this.isDragging) return;
25681
25732
  this.getContextMenuPlugin()?.cancelLongPressTimer();
25682
25733
  const pos = stage.getPointerPosition();
25683
25734
  if (pos && lastPos) {
@@ -25692,7 +25743,11 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25692
25743
  stage.on("pointermove", handleMouseMove);
25693
25744
  stage.on("pointerup", (e) => {
25694
25745
  this.pointers.delete(e.evt.pointerId);
25695
- isDragging = false;
25746
+ this.isMouseLeftButtonPressed = false;
25747
+ this.isMouseMiddleButtonPressed = false;
25748
+ this.moveToolActive = false;
25749
+ this.isDragging = false;
25750
+ this.enableMove = false;
25696
25751
  this.panning = false;
25697
25752
  });
25698
25753
  const handleWheel = (e) => {
@@ -26263,7 +26318,10 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
26263
26318
  if (!utilityLayer) return;
26264
26319
  const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e);
26265
26320
  if (typeof node === "undefined") return;
26266
- const visibleNodes = this.getVisibleNodes(skipNodes);
26321
+ const nodeParent = this.instance.getNodeContainer(node);
26322
+ if (nodeParent === null) return;
26323
+ const stage = this.instance.getStage();
26324
+ const visibleNodes = getVisibleNodes(this.instance, stage, nodeParent, skipNodes, this.instance.getMainLayer());
26267
26325
  const lineGuideStops = this.getLineGuideStops(visibleNodes);
26268
26326
  const itemBounds = this.getObjectSnappingEdges(node);
26269
26327
  const guides = this.getGuides(lineGuideStops, itemBounds, e.type);
@@ -26341,21 +26399,6 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
26341
26399
  });
26342
26400
  }
26343
26401
  }
26344
- getVisibleNodes(skipNodes) {
26345
- const stage = this.instance.getStage();
26346
- const nodesSelection = this.instance.getPlugin("nodesSelection");
26347
- if (nodesSelection) nodesSelection.getTransformer().hide();
26348
- const nodes = getVisibleNodesInViewport(stage, this.instance.getMainLayer());
26349
- const finalVisibleNodes = [];
26350
- nodes.forEach((node) => {
26351
- if (node.getParent()?.getAttrs().nodeType === "group") return;
26352
- if (skipNodes.includes(node.getParent()?.getAttrs().nodeId)) return;
26353
- if (skipNodes.includes(node.getAttrs().id ?? "")) return;
26354
- finalVisibleNodes.push(node);
26355
- });
26356
- if (nodesSelection) nodesSelection.getTransformer().show();
26357
- return finalVisibleNodes;
26358
- }
26359
26402
  getLineGuideStops(nodes) {
26360
26403
  const vertical = [];
26361
26404
  const horizontal = [];
@@ -26577,6 +26620,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
26577
26620
  const { config } = params ?? {};
26578
26621
  this.enterSnappingTolerance = config?.enterSnappingTolerance ?? GUIDE_ENTER_SNAPPING_TOLERANCE;
26579
26622
  this.exitSnappingTolerance = config?.exitSnappingTolerance ?? GUIDE_EXIT_SNAPPING_TOLERANCE;
26623
+ this.uiConfig = import_lodash.default.merge(GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, config?.ui);
26580
26624
  this.enabled = true;
26581
26625
  }
26582
26626
  getName() {
@@ -26596,19 +26640,16 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
26596
26640
  }
26597
26641
  }
26598
26642
  evaluateGuidelines(e) {
26599
- const stage = this.instance.getStage();
26600
- const mainLayer = this.instance.getMainLayer();
26601
26643
  const utilityLayer = this.instance.getUtilityLayer();
26602
26644
  if (!this.enabled) return;
26603
26645
  if (!utilityLayer) return;
26604
26646
  const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e);
26605
26647
  if (typeof node === "undefined") return;
26606
- if (node.getParent() === mainLayer) this.referenceLayer = mainLayer;
26607
- if (node.getParent()?.getAttrs().nodeId) {
26608
- const realNode = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
26609
- if (realNode) this.referenceLayer = realNode;
26610
- }
26611
- const visibleNodes = this.getVisibleNodes(skipNodes);
26648
+ const nodeParent = this.instance.getNodeContainer(node);
26649
+ if (nodeParent === null) return;
26650
+ const stage = this.instance.getStage();
26651
+ this.referenceLayer = nodeParent;
26652
+ const visibleNodes = getVisibleNodes(this.instance, stage, nodeParent, skipNodes, this.referenceLayer);
26612
26653
  const { intersectedNodes: sortedHorizontalIntersectedNodes, intersectedNodesWithDistances: horizontalIntersectedNodes } = this.getHorizontallyIntersectingNodes(node, visibleNodes);
26613
26654
  const { intersectedNodes: sortedVerticalIntersectedNodes, intersectedNodesWithDistances: verticalIntersectedNodes } = this.getVerticallyIntersectingNodes(node, visibleNodes);
26614
26655
  this.cleanupGuidelines();
@@ -26839,6 +26880,11 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
26839
26880
  });
26840
26881
  }
26841
26882
  }
26883
+ isOverlapping(node1, node2) {
26884
+ const box1 = this.getBoxClientRect(node1);
26885
+ const box2 = this.getBoxClientRect(node2);
26886
+ return !(box1.x + box1.width <= box2.x || box2.x + box2.width <= box1.x || box1.y + box1.height <= box2.y || box2.y + box2.height <= box1.y);
26887
+ }
26842
26888
  getVerticallyIntersectingNodes(targetNode, nodes) {
26843
26889
  const targetBox = this.getBoxClientRect(targetNode);
26844
26890
  const intersectedNodes = [];
@@ -26855,30 +26901,32 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
26855
26901
  return ay - by;
26856
26902
  });
26857
26903
  const intersectedNodesWithDistances = [];
26858
- for (let i = 0; i < intersectedNodes.length - 1; i++) {
26859
- const a = intersectedNodes[i];
26860
- const b = intersectedNodes[i + 1];
26861
- const boxA = this.getBoxClientRect(a);
26862
- const boxB = this.getBoxClientRect(b);
26863
- const aBottom = boxA.y + boxA.height;
26864
- const bTop = boxB.y;
26865
- const distance = Math.abs(aBottom - bTop);
26866
- const left = Math.max(boxA.x, boxB.x);
26867
- const right = Math.min(boxA.x + boxA.width, boxB.x + boxB.width);
26868
- let midX;
26869
- if (right > left) midX = left + (right - left) / 2;
26870
- else {
26871
- const aCenterX = boxA.x + boxA.width / 2;
26872
- const bCenterX = boxB.x + boxB.width / 2;
26873
- midX = (aCenterX + bCenterX) / 2;
26874
- }
26875
- intersectedNodesWithDistances.push({
26876
- index: i,
26877
- from: a,
26878
- to: b,
26879
- midX,
26880
- distance: Math.round(distance)
26881
- });
26904
+ for (let i = 0; i < intersectedNodes.length; i++) for (let j = i + 1; j < intersectedNodes.length; j++) {
26905
+ const nodeA = intersectedNodes[i];
26906
+ const nodeB = intersectedNodes[j];
26907
+ if (!this.isOverlapping(nodeA, nodeB)) {
26908
+ const boxA = this.getBoxClientRect(nodeA);
26909
+ const boxB = this.getBoxClientRect(nodeB);
26910
+ const aBottom = boxA.y + boxA.height;
26911
+ const bTop = boxB.y;
26912
+ const distance = Math.abs(aBottom - bTop);
26913
+ const left = Math.max(boxA.x, boxB.x);
26914
+ const right = Math.min(boxA.x + boxA.width, boxB.x + boxB.width);
26915
+ let midX;
26916
+ if (right > left) midX = left + (right - left) / 2;
26917
+ else {
26918
+ const aCenterX = boxA.x + boxA.width / 2;
26919
+ const bCenterX = boxB.x + boxB.width / 2;
26920
+ midX = (aCenterX + bCenterX) / 2;
26921
+ }
26922
+ intersectedNodesWithDistances.push({
26923
+ index: i,
26924
+ from: nodeA,
26925
+ to: nodeB,
26926
+ midX,
26927
+ distance: Math.round(distance)
26928
+ });
26929
+ }
26882
26930
  }
26883
26931
  return {
26884
26932
  intersectedNodes,
@@ -26901,56 +26949,38 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
26901
26949
  return ax - bx;
26902
26950
  });
26903
26951
  const intersectedNodesWithDistances = [];
26904
- for (let i = 0; i < intersectedNodes.length - 1; i++) {
26905
- const a = intersectedNodes[i];
26906
- const b = intersectedNodes[i + 1];
26907
- const boxA = this.getBoxClientRect(a);
26908
- const boxB = this.getBoxClientRect(b);
26909
- const aRight = boxA.x + boxA.width;
26910
- const bLeft = boxB.x;
26911
- const distance = Math.abs(Math.round(aRight - bLeft));
26912
- const top = Math.max(boxA.y, boxB.y);
26913
- const bottom = Math.min(boxA.y + boxA.height, boxB.y + boxB.height);
26914
- let midY;
26915
- if (bottom > top) midY = top + (bottom - top) / 2;
26916
- else {
26917
- const aCenterY = boxA.y + boxA.height / 2;
26918
- const bCenterY = boxB.y + boxB.height / 2;
26919
- midY = (aCenterY + bCenterY) / 2;
26920
- }
26921
- intersectedNodesWithDistances.push({
26922
- index: i,
26923
- from: a,
26924
- to: b,
26925
- midY,
26926
- distance
26927
- });
26952
+ for (let i = 0; i < intersectedNodes.length; i++) for (let j = i + 1; j < intersectedNodes.length; j++) {
26953
+ const nodeA = intersectedNodes[i];
26954
+ const nodeB = intersectedNodes[j];
26955
+ if (!this.isOverlapping(nodeA, nodeB)) {
26956
+ const boxA = this.getBoxClientRect(nodeA);
26957
+ const boxB = this.getBoxClientRect(nodeB);
26958
+ const aRight = boxA.x + boxA.width;
26959
+ const bLeft = boxB.x;
26960
+ const distance = Math.abs(Math.round(aRight - bLeft));
26961
+ const top = Math.max(boxA.y, boxB.y);
26962
+ const bottom = Math.min(boxA.y + boxA.height, boxB.y + boxB.height);
26963
+ let midY;
26964
+ if (bottom > top) midY = top + (bottom - top) / 2;
26965
+ else {
26966
+ const aCenterY = boxA.y + boxA.height / 2;
26967
+ const bCenterY = boxB.y + boxB.height / 2;
26968
+ midY = (aCenterY + bCenterY) / 2;
26969
+ }
26970
+ intersectedNodesWithDistances.push({
26971
+ index: i,
26972
+ from: nodeA,
26973
+ to: nodeB,
26974
+ midY,
26975
+ distance: Math.round(distance)
26976
+ });
26977
+ }
26928
26978
  }
26929
26979
  return {
26930
26980
  intersectedNodes,
26931
26981
  intersectedNodesWithDistances
26932
26982
  };
26933
26983
  }
26934
- getVisibleNodes(skipNodes) {
26935
- const stage = this.instance.getStage();
26936
- const nodesSelection = this.instance.getPlugin("nodesSelection");
26937
- if (nodesSelection) nodesSelection.getTransformer().hide();
26938
- const nodes = getVisibleNodesInViewport(stage, this.referenceLayer);
26939
- const finalVisibleNodes = [];
26940
- nodes.forEach((node) => {
26941
- if (node.getParent()?.getAttrs().nodeType === "group") return;
26942
- if (skipNodes.includes(node.getParent()?.getAttrs().nodeId)) return;
26943
- if (skipNodes.includes(node.getAttrs().id ?? "")) return;
26944
- if (node.getParent() !== this.referenceLayer && !node.getParent()?.getAttrs().nodeId) return;
26945
- if (node.getParent() !== this.referenceLayer && node.getParent()?.getAttrs().nodeId) {
26946
- const realNode = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
26947
- if (realNode && realNode !== this.referenceLayer) return;
26948
- }
26949
- finalVisibleNodes.push(node);
26950
- });
26951
- if (nodesSelection) nodesSelection.getTransformer().show();
26952
- return finalVisibleNodes;
26953
- }
26954
26984
  drawSizeGuidesHorizontally(intersectionsH, peerDistance) {
26955
26985
  const utilityLayer = this.instance.getUtilityLayer();
26956
26986
  if (utilityLayer) intersectionsH.forEach((pairInfo) => {
@@ -26967,40 +26997,60 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
26967
26997
  if (pairInfo.distance === peerDistance) this.renderVerticalLineWithDistanceBetweenNodes(from, to, pairInfo.midX, `${pairInfo.distance}`);
26968
26998
  });
26969
26999
  }
26970
- renderDistanceLabel(ctx, stage, labelText, { canvasMidX, canvasMidY }) {
27000
+ renderDistanceLabel(ctx, stage, labelText, orientation, { canvasMidX, canvasMidY }, config) {
26971
27001
  const scaleX = stage?.scaleX() || 1;
26972
27002
  const scaleY = stage?.scaleY() || 1;
26973
- const fontSize = 12;
26974
- const fontFamily = "Arial";
26975
- const padding = 6;
27003
+ const fontSize = config.label.fontSize;
27004
+ const fontFamily = config.label.fontFamily;
27005
+ const fontStyle = config.label.fontStyle;
27006
+ const cornerRadius = config.label.cornerRadius;
27007
+ const linePadding = config.label.linePadding;
27008
+ const fill = config.label.fill;
27009
+ const height = config.label.height;
27010
+ const paddingX = config.label.paddingX;
26976
27011
  const tempText = new konva.default.Text({
26977
27012
  text: labelText,
26978
27013
  fontSize,
27014
+ fontStyle,
26979
27015
  fontFamily,
26980
27016
  visible: false
26981
27017
  });
26982
27018
  const textWidth = tempText.width();
26983
- const textHeight = tempText.height();
26984
- const labelWidth = textWidth + padding * 2;
26985
- const labelHeight = textHeight + padding * 2;
27019
+ const labelWidth = textWidth + paddingX * 2;
27020
+ const labelHeight = height;
26986
27021
  ctx.save();
26987
27022
  ctx.scale(1 / scaleX, 1 / scaleY);
26988
- const labelX = canvasMidX - labelWidth / 2;
26989
- const labelY = canvasMidY - labelHeight / 2;
27023
+ let labelX = canvasMidX - labelWidth / 2;
27024
+ let labelY = canvasMidY + linePadding;
27025
+ if (orientation === "vertical") {
27026
+ labelX = canvasMidX + linePadding;
27027
+ labelY = canvasMidY - labelWidth / 2;
27028
+ }
27029
+ const r = Math.min(cornerRadius, labelWidth / 2, labelHeight / 2);
26990
27030
  ctx.beginPath();
26991
- ctx.rect(labelX, labelY, labelWidth, labelHeight);
26992
- ctx.fillStyle = "#ff0000";
27031
+ ctx.moveTo(labelX + r, labelY);
27032
+ ctx.lineTo(labelX + labelWidth - r, labelY);
27033
+ ctx.quadraticCurveTo(labelX + labelWidth, labelY, labelX + labelWidth, labelY + r);
27034
+ ctx.lineTo(labelX + labelWidth, labelY + labelHeight - r);
27035
+ ctx.quadraticCurveTo(labelX + labelWidth, labelY + labelHeight, labelX + labelWidth - r, labelY + labelHeight);
27036
+ ctx.lineTo(labelX + r, labelY + labelHeight);
27037
+ ctx.quadraticCurveTo(labelX, labelY + labelHeight, labelX, labelY + labelHeight - r);
27038
+ ctx.lineTo(labelX, labelY + r);
27039
+ ctx.quadraticCurveTo(labelX, labelY, labelX + r, labelY);
27040
+ ctx.closePath();
27041
+ ctx.fillStyle = fill;
26993
27042
  ctx.fill();
26994
- ctx.font = `bold ${fontSize}px ${fontFamily}`;
27043
+ ctx.font = `${fontStyle} ${fontSize}px ${fontFamily}`;
26995
27044
  ctx.fillStyle = "white";
26996
27045
  ctx.textAlign = "center";
26997
27046
  ctx.textBaseline = "middle";
26998
- ctx.fillText(labelText, canvasMidX, labelY + labelHeight / 2);
27047
+ ctx.fillText(labelText, labelX + labelWidth / 2, labelY + labelHeight / 2);
26999
27048
  ctx.restore();
27000
27049
  }
27001
27050
  renderHorizontalLineWithDistanceBetweenNodes(from, to, midY, labelText) {
27002
27051
  const utilityLayer = this.instance.getUtilityLayer();
27003
27052
  const renderLabel = this.renderDistanceLabel;
27053
+ const uiConfig = this.uiConfig;
27004
27054
  const lineWithLabel = new konva.default.Shape({
27005
27055
  name: GUIDE_HORIZONTAL_LINE_NAME,
27006
27056
  sceneFunc: function(ctx, shape) {
@@ -27014,8 +27064,8 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
27014
27064
  ctx.moveTo(x1, y);
27015
27065
  ctx.lineTo(x2, y);
27016
27066
  ctx.closePath();
27017
- ctx.strokeStyle = "#ff0000";
27018
- ctx.lineWidth = 1;
27067
+ ctx.strokeStyle = uiConfig.line.stroke;
27068
+ ctx.lineWidth = uiConfig.line.strokeWidth;
27019
27069
  ctx.setLineDash([]);
27020
27070
  ctx.stroke();
27021
27071
  ctx.closePath();
@@ -27023,10 +27073,10 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
27023
27073
  const worldMidY = y;
27024
27074
  const canvasMidX = worldMidX * scaleX;
27025
27075
  const canvasMidY = worldMidY * scaleY;
27026
- renderLabel(ctx, stage, labelText, {
27076
+ renderLabel(ctx, stage, labelText, "horizontal", {
27027
27077
  canvasMidX,
27028
27078
  canvasMidY
27029
- });
27079
+ }, uiConfig);
27030
27080
  ctx.fillStrokeShape(shape);
27031
27081
  }
27032
27082
  });
@@ -27036,6 +27086,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
27036
27086
  renderVerticalLineWithDistanceBetweenNodes(from, to, midX, labelText) {
27037
27087
  const utilityLayer = this.instance.getUtilityLayer();
27038
27088
  const renderLabel = this.renderDistanceLabel;
27089
+ const uiConfig = this.uiConfig;
27039
27090
  const lineWithLabel = new konva.default.Shape({
27040
27091
  name: GUIDE_VERTICAL_LINE_NAME,
27041
27092
  sceneFunc: function(ctx, shape) {
@@ -27049,18 +27100,18 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
27049
27100
  ctx.setLineDash([]);
27050
27101
  ctx.moveTo(x, y1);
27051
27102
  ctx.lineTo(x, y2);
27052
- ctx.strokeStyle = "#ff0000";
27053
- ctx.lineWidth = 1;
27103
+ ctx.strokeStyle = uiConfig.line.stroke;
27104
+ ctx.lineWidth = uiConfig.line.strokeWidth;
27054
27105
  ctx.stroke();
27055
27106
  ctx.closePath();
27056
27107
  const worldMidX = x;
27057
27108
  const worldMidY = (y1 + y2) / 2;
27058
27109
  const canvasMidX = worldMidX * scaleX;
27059
27110
  const canvasMidY = worldMidY * scaleY;
27060
- renderLabel(ctx, stage, labelText, {
27111
+ renderLabel(ctx, stage, labelText, "vertical", {
27061
27112
  canvasMidX,
27062
27113
  canvasMidY
27063
- });
27114
+ }, uiConfig);
27064
27115
  ctx.fillStrokeShape(shape);
27065
27116
  }
27066
27117
  });
@@ -27090,6 +27141,7 @@ exports.ERASER_TOOL_ACTION_NAME = ERASER_TOOL_ACTION_NAME
27090
27141
  exports.ERASER_TOOL_STATE = ERASER_TOOL_STATE
27091
27142
  exports.FRAME_TOOL_ACTION_NAME = FRAME_TOOL_ACTION_NAME
27092
27143
  exports.FRAME_TOOL_STATE = FRAME_TOOL_STATE
27144
+ exports.GUIDE_DISTANCE_LINE_DEFAULT_CONFIG = GUIDE_DISTANCE_LINE_DEFAULT_CONFIG
27093
27145
  exports.GUIDE_ENTER_SNAPPING_TOLERANCE = GUIDE_ENTER_SNAPPING_TOLERANCE
27094
27146
  exports.GUIDE_EXIT_SNAPPING_TOLERANCE = GUIDE_EXIT_SNAPPING_TOLERANCE
27095
27147
  exports.GUIDE_HORIZONTAL_LINE_NAME = GUIDE_HORIZONTAL_LINE_NAME
@@ -27224,6 +27276,7 @@ exports.getSelectedNodesMetadata = getSelectedNodesMetadata
27224
27276
  exports.getTargetAndSkipNodes = getTargetAndSkipNodes
27225
27277
  exports.getTargetedNode = getTargetedNode
27226
27278
  exports.getTopmostShadowHost = getTopmostShadowHost
27279
+ exports.getVisibleNodes = getVisibleNodes
27227
27280
  exports.getVisibleNodesInViewport = getVisibleNodesInViewport
27228
27281
  exports.hasFrames = hasFrames
27229
27282
  exports.hasImages = hasImages