@inditextech/weave-sdk 0.60.0 → 0.62.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
@@ -18009,7 +18009,23 @@ const WEAVE_NODES_SELECTION_DEFAULT_CONFIG = {
18009
18009
  },
18010
18010
  behaviors: {
18011
18011
  singleSelection: { enabled: true },
18012
- multipleSelection: { enabled: false }
18012
+ multipleSelection: { enabled: false },
18013
+ onMultipleSelection: () => {
18014
+ return {
18015
+ resizeEnabled: true,
18016
+ rotateEnabled: true,
18017
+ enabledAnchors: [
18018
+ "top-left",
18019
+ "top-center",
18020
+ "top-right",
18021
+ "middle-right",
18022
+ "middle-left",
18023
+ "bottom-left",
18024
+ "bottom-center",
18025
+ "bottom-right"
18026
+ ]
18027
+ };
18028
+ }
18013
18029
  }
18014
18030
  };
18015
18031
 
@@ -18208,8 +18224,12 @@ function getSelectedNodesMetadata(transformer) {
18208
18224
  nodes
18209
18225
  };
18210
18226
  }
18211
- function getTargetAndSkipNodes(instance, e) {
18227
+ function getTargetAndSkipNodes(instance, e, forceTransformer = false) {
18212
18228
  const nodesSelectionPlugin = instance.getPlugin("nodesSelection");
18229
+ if (!nodesSelectionPlugin) return {
18230
+ targetNode: void 0,
18231
+ skipNodes: []
18232
+ };
18213
18233
  let skipNodes = [];
18214
18234
  let node = void 0;
18215
18235
  if (e.type === "dragmove" && nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) {
@@ -18224,9 +18244,10 @@ function getTargetAndSkipNodes(instance, e) {
18224
18244
  if (e.type === "transform") {
18225
18245
  node = e.target;
18226
18246
  skipNodes.push(node.getAttrs().id ?? "");
18247
+ skipNodes.push(...node.nodes().map((node$1) => node$1.getAttrs().id ?? ""));
18227
18248
  }
18228
18249
  return {
18229
- targetNode: node,
18250
+ targetNode: forceTransformer ? nodesSelectionPlugin.getTransformer() : node,
18230
18251
  skipNodes
18231
18252
  };
18232
18253
  }
@@ -19516,7 +19537,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19516
19537
  this.stopPanLoop();
19517
19538
  this.tr.nodes([...selectedNodes]);
19518
19539
  this.handleBehaviors();
19519
- this.triggerSelectedNodesEvent();
19540
+ this.handleMultipleSelectionBehavior();
19520
19541
  stage.container().tabIndex = 1;
19521
19542
  stage.container().focus();
19522
19543
  });
@@ -19527,6 +19548,12 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19527
19548
  this.syncSelection();
19528
19549
  });
19529
19550
  }
19551
+ handleMultipleSelectionBehavior() {
19552
+ if (this.tr.nodes().length > 1 && this.config.behaviors?.onMultipleSelection) {
19553
+ const selectionBehavior = this.config.behaviors?.onMultipleSelection?.(this.tr.nodes());
19554
+ this.tr.setAttrs(selectionBehavior);
19555
+ }
19556
+ }
19530
19557
  syncSelection() {
19531
19558
  const newSelectedNodes = [];
19532
19559
  const actualSelectedNodes = this.tr.nodes();
@@ -19606,6 +19633,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19606
19633
  areNodesSelected = true;
19607
19634
  }
19608
19635
  this.handleBehaviors();
19636
+ this.handleMultipleSelectionBehavior();
19609
19637
  if (areNodesSelected) {
19610
19638
  stage.container().tabIndex = 1;
19611
19639
  stage.container().focus();
@@ -22021,7 +22049,7 @@ var WeaveRegisterManager = class {
22021
22049
 
22022
22050
  //#endregion
22023
22051
  //#region package.json
22024
- var version = "0.60.0";
22052
+ var version = "0.62.0";
22025
22053
 
22026
22054
  //#endregion
22027
22055
  //#region src/managers/setup.ts
@@ -22071,6 +22099,30 @@ var WeaveSetupManager = class {
22071
22099
  }
22072
22100
  };
22073
22101
 
22102
+ //#endregion
22103
+ //#region src/plugins/stage-grid/constants.ts
22104
+ const WEAVE_STAGE_GRID_KEY = "stageGrid";
22105
+ const WEAVE_GRID_TYPES = {
22106
+ ["LINES"]: "lines",
22107
+ ["DOTS"]: "dots"
22108
+ };
22109
+ const WEAVE_GRID_DEFAULT_SIZE = 50;
22110
+ const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
22111
+ const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.1)";
22112
+ const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.1)";
22113
+ const WEAVE_GRID_DEFAULT_STROKE = .5;
22114
+ const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
22115
+ const WEAVE_GRID_DEFAULT_RADIUS = 1;
22116
+ const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
22117
+ const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
22118
+ const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
22119
+ const WEAVE_GRID_LAYER_ID = "gridLayer";
22120
+
22121
+ //#endregion
22122
+ //#region src/plugins/comments-renderer/constants.ts
22123
+ const WEAVE_COMMENTS_RENDERER_KEY = "commentsRenderer";
22124
+ const WEAVE_COMMENTS_TOOL_LAYER_ID = "commentsLayer";
22125
+
22074
22126
  //#endregion
22075
22127
  //#region src/managers/stage.ts
22076
22128
  var WeaveStageManager = class {
@@ -22097,6 +22149,14 @@ var WeaveStageManager = class {
22097
22149
  const stage = this.getStage();
22098
22150
  return stage.findOne(`#${WEAVE_NODES_SELECTION_LAYER_ID}`);
22099
22151
  }
22152
+ getCommentsLayer() {
22153
+ const stage = this.getStage();
22154
+ return stage.findOne(`#${WEAVE_COMMENTS_TOOL_LAYER_ID}`);
22155
+ }
22156
+ getGridLayer() {
22157
+ const stage = this.getStage();
22158
+ return stage.findOne(`#${WEAVE_GRID_LAYER_ID}`);
22159
+ }
22100
22160
  getUtilityLayer() {
22101
22161
  const stage = this.getStage();
22102
22162
  return stage.findOne(`#${__inditextech_weave_types.WEAVE_UTILITY_LAYER_ID}`);
@@ -22222,25 +22282,6 @@ var WeaveStoreManager = class {
22222
22282
  }
22223
22283
  };
22224
22284
 
22225
- //#endregion
22226
- //#region src/plugins/stage-grid/constants.ts
22227
- const WEAVE_STAGE_GRID_KEY = "stageGrid";
22228
- const WEAVE_GRID_TYPES = {
22229
- ["LINES"]: "lines",
22230
- ["DOTS"]: "dots"
22231
- };
22232
- const WEAVE_GRID_DEFAULT_SIZE = 50;
22233
- const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
22234
- const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.1)";
22235
- const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.1)";
22236
- const WEAVE_GRID_DEFAULT_STROKE = .5;
22237
- const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
22238
- const WEAVE_GRID_DEFAULT_RADIUS = 1;
22239
- const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
22240
- const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
22241
- const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
22242
- const WEAVE_GRID_LAYER_ID = "gridLayer";
22243
-
22244
22285
  //#endregion
22245
22286
  //#region src/managers/export.ts
22246
22287
  var WeaveExportManager = class {
@@ -22542,6 +22583,12 @@ var Weave = class {
22542
22583
  getSelectionLayer() {
22543
22584
  return this.stageManager.getSelectionLayer();
22544
22585
  }
22586
+ getCommentsLayer() {
22587
+ return this.stageManager.getCommentsLayer();
22588
+ }
22589
+ getGridLayer() {
22590
+ return this.stageManager.getGridLayer();
22591
+ }
22545
22592
  getUtilityLayer() {
22546
22593
  return this.stageManager.getUtilityLayer();
22547
22594
  }
@@ -25493,13 +25540,13 @@ const WEAVE_COMMENT_NODE_DEFAULTS = {
25493
25540
  }
25494
25541
  },
25495
25542
  creating: {
25496
- paddingX: 8,
25497
- paddingY: -4,
25543
+ paddingX: 16,
25544
+ paddingY: -8,
25498
25545
  stroke: "#1a1aff",
25499
25546
  strokeWidth: 2
25500
25547
  },
25501
25548
  viewing: {
25502
- paddingX: 8,
25549
+ paddingX: 16,
25503
25550
  paddingY: -18,
25504
25551
  stroke: "#1a1aff",
25505
25552
  strokeWidth: 2
@@ -25959,10 +26006,16 @@ var WeaveCommentNode = class extends WeaveNode {
25959
26006
  }
25960
26007
  setCommentDOMPosition(commentNode, commentAction) {
25961
26008
  const stage = this.instance.getStage();
25962
- const rect = commentNode.getClientRect({ relativeTo: stage });
26009
+ this.normalizeNodeSize(commentNode);
26010
+ const rect = commentNode.getClientRect({
26011
+ relativeTo: stage,
26012
+ skipShadow: true,
26013
+ skipStroke: true
26014
+ });
25963
26015
  const scaleX = stage.scaleX();
25964
26016
  const scaleY = stage.scaleY();
25965
26017
  const stagePos = stage.position();
26018
+ const widthContracted = this.config.style.contracted.width;
25966
26019
  let paddingX = 8;
25967
26020
  let paddingY = 0;
25968
26021
  if (commentAction === WEAVE_COMMENT_NODE_ACTION.CREATING) {
@@ -25973,7 +26026,7 @@ var WeaveCommentNode = class extends WeaveNode {
25973
26026
  paddingX = this.config.style.viewing.paddingX;
25974
26027
  paddingY = this.config.style.viewing.paddingY;
25975
26028
  }
25976
- const x = stagePos.x + rect.x * scaleX + rect.width * scaleX + paddingX;
26029
+ const x = stagePos.x + rect.x * scaleX + widthContracted + paddingX;
25977
26030
  const y = stagePos.y + rect.y * scaleY + paddingY;
25978
26031
  const position = {
25979
26032
  x,
@@ -26007,8 +26060,7 @@ var WeaveCommentNode = class extends WeaveNode {
26007
26060
  }
26008
26061
  onZoomChangeHandler = (commentNode) => () => {
26009
26062
  if (!this.commentDomVisible) return;
26010
- const node = this.instance.getStage().findOne(`#${commentNode.id()}`);
26011
- if (node) this.setCommentDOMPosition(node, commentNode.getAttrs().commentAction);
26063
+ this.setCommentDOMPosition(commentNode, commentNode.getAttrs().commentAction);
26012
26064
  };
26013
26065
  normalizeNodeSize(node) {
26014
26066
  const abs = node.getAbsoluteScale();
@@ -26020,8 +26072,7 @@ var WeaveCommentNode = class extends WeaveNode {
26020
26072
  }
26021
26073
  onStageMoveHandler = (commentNode) => () => {
26022
26074
  if (!this.commentDomVisible) return;
26023
- const node = this.instance.getStage().findOne(`#${commentNode.id()}`);
26024
- if (node) this.setCommentDOMPosition(node, commentNode.getAttrs().commentAction);
26075
+ this.setCommentDOMPosition(commentNode, commentNode.getAttrs().commentAction);
26025
26076
  };
26026
26077
  openCommentDOM(commentNode) {
26027
26078
  this.contractNode(commentNode);
@@ -29153,7 +29204,6 @@ var WeaveAlignNodesToolAction = class extends WeaveAction {
29153
29204
  //#endregion
29154
29205
  //#region src/actions/comment-tool/constants.ts
29155
29206
  const WEAVE_COMMENT_TOOL_ACTION_NAME = "commentTool";
29156
- const WEAVE_COMMENT_TOOL_LAYER_NAME = "commentsLayer";
29157
29207
  const WEAVE_COMMENT_TOOL_STATE = {
29158
29208
  ["IDLE"]: "idle",
29159
29209
  ["ADDING"]: "adding",
@@ -29166,10 +29216,6 @@ const WEAVE_COMMENT_TOOL_DEFAULT_CONFIG = { style: { cursor: {
29166
29216
  block: "not-allowed"
29167
29217
  } } };
29168
29218
 
29169
- //#endregion
29170
- //#region src/plugins/comments-renderer/constants.ts
29171
- const WEAVE_COMMENTS_RENDERER_KEY = "commentsRenderer";
29172
-
29173
29219
  //#endregion
29174
29220
  //#region src/actions/comment-tool/comment-tool.ts
29175
29221
  var WeaveCommentToolAction = class extends WeaveAction {
@@ -29350,11 +29396,13 @@ var WeaveCommentToolAction = class extends WeaveAction {
29350
29396
  this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
29351
29397
  }
29352
29398
  handleAdding() {
29353
- const { mousePoint } = this.instance.getMousePointer();
29399
+ const mainLayer = this.instance.getMainLayer();
29400
+ if (!mainLayer) return;
29401
+ const mousePoint = mainLayer.getRelativePointerPosition();
29354
29402
  this.clickPoint = mousePoint;
29355
29403
  this.commentId = v4_default();
29356
29404
  const nodeHandler = this.instance.getNodeHandler("comment");
29357
- if (nodeHandler) {
29405
+ if (nodeHandler && this.clickPoint) {
29358
29406
  const node = nodeHandler.onRender({
29359
29407
  id: this.commentId,
29360
29408
  x: this.clickPoint.x,
@@ -29866,6 +29914,186 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
29866
29914
  }
29867
29915
  };
29868
29916
 
29917
+ //#endregion
29918
+ //#region src/plugins/stage-minimap/constants.ts
29919
+ const WEAVE_STAGE_MINIMAP_KEY = "stageMinimap";
29920
+ const STAGE_MINIMAP_DEFAULT_CONFIG = { style: { viewportReference: {
29921
+ fill: "rgba(0,0,0,0.2)",
29922
+ strokeScaleEnabled: false,
29923
+ stroke: "#e12d3c",
29924
+ strokeWidth: 1
29925
+ } } };
29926
+
29927
+ //#endregion
29928
+ //#region src/plugins/stage-minimap/stage-minimap.ts
29929
+ var WeaveStageMinimapPlugin = class extends WeavePlugin {
29930
+ getLayerName = void 0;
29931
+ initLayer = void 0;
29932
+ constructor(params) {
29933
+ super();
29934
+ this.config = (0, import_lodash.merge)(STAGE_MINIMAP_DEFAULT_CONFIG, params.config);
29935
+ this.initialized = false;
29936
+ }
29937
+ getName() {
29938
+ return WEAVE_STAGE_MINIMAP_KEY;
29939
+ }
29940
+ async setupMinimap() {
29941
+ if (this.initialized) return;
29942
+ const container = this.config.getContainer();
29943
+ if (!container) return;
29944
+ let preview = document.getElementById(this.config.id);
29945
+ const windowAspectRatio = window.innerWidth / window.innerHeight;
29946
+ if (!preview) {
29947
+ preview = document.createElement("div");
29948
+ preview.id = this.config.id;
29949
+ preview.style.width = `${this.config.width}px`;
29950
+ preview.style.height = `${Math.round(this.config.width / windowAspectRatio)}px`;
29951
+ container.appendChild(preview);
29952
+ }
29953
+ this.minimapStage = new konva.default.Stage({
29954
+ id: "minimap",
29955
+ container: this.config.id,
29956
+ width: this.config.width,
29957
+ height: Math.round(this.config.width / windowAspectRatio)
29958
+ });
29959
+ const mainLayer = this.instance.getMainLayer();
29960
+ if (mainLayer) {
29961
+ this.minimapLayer = new konva.default.Layer();
29962
+ this.minimapStage.add(this.minimapLayer);
29963
+ this.minimapViewportReference = new konva.default.Rect({
29964
+ ...this.config.style.viewportReference,
29965
+ id: "minimapViewportReference",
29966
+ listening: false
29967
+ });
29968
+ this.minimapLayer.add(this.minimapViewportReference);
29969
+ await this.updateMinimapContent();
29970
+ this.updateMinimapViewportReference();
29971
+ }
29972
+ const stage = this.instance.getStage();
29973
+ stage.on("dragmove wheel dragend scaleXChange scaleYChange xChange yChange", () => {
29974
+ this.updateMinimapViewportReference();
29975
+ });
29976
+ this.initialized = true;
29977
+ }
29978
+ async updateMinimapContent() {
29979
+ const stage = this.instance.getStage();
29980
+ const mainLayer = this.instance.getMainLayer();
29981
+ if (!mainLayer) return;
29982
+ const box = mainLayer.getClientRect({
29983
+ skipShadow: true,
29984
+ skipStroke: true
29985
+ });
29986
+ if (box.width === 0 || box.height === 0) return;
29987
+ box.x -= this.config.fitToContentPadding;
29988
+ box.y -= this.config.fitToContentPadding;
29989
+ box.width += this.config.fitToContentPadding * 2;
29990
+ box.height += this.config.fitToContentPadding * 2;
29991
+ this.hideLayers();
29992
+ const pixelRatio = .5;
29993
+ const dataUrl = await stage.toDataURL({
29994
+ x: box.x,
29995
+ y: box.y,
29996
+ width: box.width,
29997
+ height: box.height,
29998
+ pixelRatio
29999
+ });
30000
+ this.showLayers();
30001
+ const img = new window.Image();
30002
+ img.onload = () => {
30003
+ const actualImage = this.minimapStage.findOne("#minimapStageImage");
30004
+ if (actualImage) actualImage.destroy();
30005
+ const fitScale = Math.min(this.minimapStage.width() / (box.width * pixelRatio), this.minimapStage.height() / (box.height * pixelRatio));
30006
+ const centerOffset = {
30007
+ x: (this.minimapStage.width() - box.width * pixelRatio * fitScale) / 2,
30008
+ y: (this.minimapStage.height() - box.height * pixelRatio * fitScale) / 2
30009
+ };
30010
+ this.minimapStageImage = new konva.default.Image({
30011
+ id: "minimapStageImage",
30012
+ image: img,
30013
+ x: centerOffset.x,
30014
+ y: centerOffset.y,
30015
+ scaleX: fitScale,
30016
+ scaleY: fitScale,
30017
+ listening: false
30018
+ });
30019
+ this.minimapLayer.add(this.minimapStageImage);
30020
+ this.minimapStageImage.moveToBottom();
30021
+ };
30022
+ img.src = dataUrl;
30023
+ }
30024
+ updateMinimapViewportReference() {
30025
+ const stage = this.instance.getStage();
30026
+ const mainLayer = this.instance.getMainLayer();
30027
+ if (!mainLayer) return;
30028
+ const box = mainLayer.getClientRect({
30029
+ relativeTo: stage,
30030
+ skipShadow: true,
30031
+ skipStroke: true
30032
+ });
30033
+ if (box.width === 0 || box.height === 0) return;
30034
+ box.x -= this.config.fitToContentPadding;
30035
+ box.y -= this.config.fitToContentPadding;
30036
+ box.width += this.config.fitToContentPadding * 2;
30037
+ box.height += this.config.fitToContentPadding * 2;
30038
+ const fitScale = Math.min(this.minimapStage.width() / box.width, this.minimapStage.height() / box.height);
30039
+ const centerOffset = {
30040
+ x: (this.minimapStage.width() - box.width * fitScale) / 2,
30041
+ y: (this.minimapStage.height() - box.height * fitScale) / 2
30042
+ };
30043
+ const sX = stage.scaleX() ?? 1;
30044
+ const sY = stage.scaleY() ?? 1;
30045
+ const x = stage.x();
30046
+ const y = stage.y();
30047
+ const visible = {
30048
+ x: -x / sX,
30049
+ y: -y / sY,
30050
+ width: stage.width() / sX,
30051
+ height: stage.height() / sY
30052
+ };
30053
+ const realX = (visible.x - box.x) * fitScale + centerOffset.x;
30054
+ const realY = (visible.y - box.y) * fitScale + centerOffset.y;
30055
+ const realWidth = visible.width * fitScale;
30056
+ const realHeight = visible.height * fitScale;
30057
+ this.minimapViewportReference.setAttrs({
30058
+ x: realX,
30059
+ y: realY,
30060
+ width: realWidth,
30061
+ height: realHeight
30062
+ });
30063
+ }
30064
+ onRender() {
30065
+ this.setupMinimap();
30066
+ }
30067
+ onInit() {
30068
+ this.instance.addEventListener("onStateChange", async () => {
30069
+ await this.updateMinimapContent();
30070
+ this.updateMinimapViewportReference();
30071
+ });
30072
+ }
30073
+ showLayers() {
30074
+ const selectionLayer = this.instance.getSelectionLayer();
30075
+ const gridLayer = this.instance.getGridLayer();
30076
+ const commentsLayer = this.instance.getCommentsLayer();
30077
+ if (selectionLayer) selectionLayer.show();
30078
+ if (gridLayer) gridLayer.show();
30079
+ if (commentsLayer) commentsLayer.show();
30080
+ }
30081
+ hideLayers() {
30082
+ const selectionLayer = this.instance.getSelectionLayer();
30083
+ const gridLayer = this.instance.getGridLayer();
30084
+ const commentsLayer = this.instance.getCommentsLayer();
30085
+ if (selectionLayer) selectionLayer.hide();
30086
+ if (gridLayer) gridLayer.hide();
30087
+ if (commentsLayer) commentsLayer.hide();
30088
+ }
30089
+ enable() {
30090
+ this.enabled = true;
30091
+ }
30092
+ disable() {
30093
+ this.enabled = false;
30094
+ }
30095
+ };
30096
+
29869
30097
  //#endregion
29870
30098
  //#region src/plugins/stage-resize/constants.ts
29871
30099
  const WEAVE_STAGE_RESIZE_KEY = "stageResize";
@@ -30375,7 +30603,7 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
30375
30603
  if (!utilityLayer) return;
30376
30604
  const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e);
30377
30605
  if (typeof node === "undefined") return;
30378
- const nodeParent = this.instance.getNodeContainer(node);
30606
+ const nodeParent = this.getSelectionParentNode(node);
30379
30607
  if (nodeParent === null) return;
30380
30608
  const stage = this.instance.getStage();
30381
30609
  const visibleNodes = getVisibleNodes(this.instance, stage, nodeParent, skipNodes, this.instance.getMainLayer());
@@ -30438,6 +30666,15 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
30438
30666
  }
30439
30667
  }
30440
30668
  }
30669
+ getSelectionParentNode(node) {
30670
+ let nodeParent = null;
30671
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
30672
+ if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) {
30673
+ if (nodesSelectionPlugin) nodeParent = this.instance.getNodeContainer(nodesSelectionPlugin.getTransformer().nodes()[0]);
30674
+ }
30675
+ if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) nodeParent = this.instance.getNodeContainer(node);
30676
+ return nodeParent;
30677
+ }
30441
30678
  cleanupGuidelines() {
30442
30679
  const utilityLayer = this.instance.getUtilityLayer();
30443
30680
  if (!this.enabled) return;
@@ -30700,9 +30937,9 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30700
30937
  const utilityLayer = this.instance.getUtilityLayer();
30701
30938
  if (!this.enabled) return;
30702
30939
  if (!utilityLayer) return;
30703
- const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e);
30940
+ const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e, true);
30704
30941
  if (typeof node === "undefined") return;
30705
- const nodeParent = this.instance.getNodeContainer(node);
30942
+ const nodeParent = this.getSelectionParentNode();
30706
30943
  if (nodeParent === null) return;
30707
30944
  const stage = this.instance.getStage();
30708
30945
  this.referenceLayer = nodeParent;
@@ -30719,12 +30956,42 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30719
30956
  }
30720
30957
  getBoxClientRect(node) {
30721
30958
  const stage = this.instance.getStage();
30722
- return node.getClientRect({
30959
+ const realNode = node;
30960
+ if (node instanceof konva.default.Transformer) {
30961
+ let minX = Infinity;
30962
+ let minY = Infinity;
30963
+ let maxX = -Infinity;
30964
+ let maxY = -Infinity;
30965
+ node.nodes().forEach((node$1) => {
30966
+ const box = node$1.getClientRect({
30967
+ relativeTo: stage,
30968
+ skipStroke: true,
30969
+ skipShadow: true
30970
+ });
30971
+ minX = Math.min(minX, box.x);
30972
+ minY = Math.min(minY, box.y);
30973
+ maxX = Math.max(maxX, box.x + box.width);
30974
+ maxY = Math.max(maxY, box.y + box.height);
30975
+ });
30976
+ return {
30977
+ x: minX,
30978
+ y: minY,
30979
+ width: maxX - minX,
30980
+ height: maxY - minY
30981
+ };
30982
+ }
30983
+ return realNode.getClientRect({
30723
30984
  relativeTo: stage,
30724
30985
  skipStroke: true,
30725
30986
  skipShadow: true
30726
30987
  });
30727
30988
  }
30989
+ getSelectionParentNode() {
30990
+ let nodeParent = null;
30991
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
30992
+ if (nodesSelectionPlugin) nodeParent = this.instance.getNodeContainer(nodesSelectionPlugin.getTransformer().nodes()[0]);
30993
+ return nodeParent;
30994
+ }
30728
30995
  getPeers(intersectedNodes, targetNode, prev, next) {
30729
30996
  const peers = intersectedNodes.filter((int) => {
30730
30997
  if (prev && next) return int.to.getAttrs().id !== targetNode.getAttrs().id && int.from.getAttrs().id !== targetNode.getAttrs().id;
@@ -30765,7 +31032,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30765
31032
  const center = (prevBox.x + prevBox.width + nextBox.x) / 2;
30766
31033
  const newX = center - box.width / 2;
30767
31034
  this.setNodeClientRectX(node, newX);
30768
- this.snapPositionX = node.x();
31035
+ this.snapPositionX = node instanceof konva.default.Transformer ? newX : node.x();
30769
31036
  this.currentSizeSnapHorizontal = NODE_SNAP_HORIZONTAL.CENTER;
30770
31037
  const newBox = this.getBoxClientRect(node);
30771
31038
  this.peerDistanceX = Math.round(newBox.x - (prevBox.x + prevBox.width));
@@ -30773,7 +31040,13 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30773
31040
  if (this.currentSizeSnapHorizontal === NODE_SNAP_HORIZONTAL.CENTER && delta > this.exitSnappingTolerance) this.currentSizeSnapHorizontal = null;
30774
31041
  }
30775
31042
  if (this.currentSizeSnapHorizontal && this.peerDistanceX && this.snapPositionX) {
30776
- node.x(this.snapPositionX);
31043
+ if (node instanceof konva.default.Transformer) {
31044
+ const box$1 = this.getBoxClientRect(node);
31045
+ const dx = this.snapPositionX - box$1.x;
31046
+ node.nodes().forEach((n) => {
31047
+ n.x(n.x() + dx);
31048
+ });
31049
+ } else node.x(this.snapPositionX);
30777
31050
  const { intersectedNodesWithDistances: newHorizontalIntersectedNodes } = this.getHorizontallyIntersectingNodes(node, visibleNodes);
30778
31051
  this.drawSizeGuidesHorizontally(newHorizontalIntersectedNodes, this.peerDistanceX);
30779
31052
  return;
@@ -30784,7 +31057,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30784
31057
  if (match) {
30785
31058
  const newX = prevBox.x + prevBox.width + match.distance;
30786
31059
  this.setNodeClientRectX(node, newX);
30787
- this.snapPositionX = node.x();
31060
+ this.snapPositionX = node instanceof konva.default.Transformer ? newX : node.x();
30788
31061
  this.currentSizeSnapHorizontal = NODE_SNAP_HORIZONTAL.LEFT;
30789
31062
  const newBox = this.getBoxClientRect(node);
30790
31063
  this.peerDistanceX = Math.round(newBox.x - (prevBox.x + prevBox.width));
@@ -30798,7 +31071,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30798
31071
  if (match) {
30799
31072
  const newX = nextBox.x - match.distance - box.width;
30800
31073
  this.setNodeClientRectX(node, newX);
30801
- this.snapPositionX = node.x();
31074
+ this.snapPositionX = node instanceof konva.default.Transformer ? newX : node.x();
30802
31075
  const newBox = this.getBoxClientRect(node);
30803
31076
  this.peerDistanceX = Math.round(nextBox.x - (newBox.x + newBox.width));
30804
31077
  this.currentSizeSnapHorizontal = NODE_SNAP_HORIZONTAL.RIGHT;
@@ -30829,7 +31102,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30829
31102
  const center = (prevBox.y + prevBox.height + nextBox.y) / 2;
30830
31103
  const newY = center - box.height / 2;
30831
31104
  this.setNodeClientRectY(node, newY);
30832
- this.snapPositionY = node.y();
31105
+ this.snapPositionY = node instanceof konva.default.Transformer ? newY : node.y();
30833
31106
  this.currentSizeSnapVertical = NODE_SNAP_VERTICAL.MIDDLE;
30834
31107
  const newBox = this.getBoxClientRect(node);
30835
31108
  this.peerDistanceY = Math.round(newBox.y - (prevBox.y + prevBox.height));
@@ -30837,7 +31110,13 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30837
31110
  if (this.currentSizeSnapVertical === NODE_SNAP_VERTICAL.MIDDLE && delta > this.exitSnappingTolerance) this.currentSizeSnapVertical = null;
30838
31111
  }
30839
31112
  if (this.currentSizeSnapVertical && this.peerDistanceY && this.snapPositionY) {
30840
- node.y(this.snapPositionY);
31113
+ if (node instanceof konva.default.Transformer) {
31114
+ const box$1 = this.getBoxClientRect(node);
31115
+ const dy = this.snapPositionY - box$1.y;
31116
+ node.nodes().forEach((n) => {
31117
+ n.y(n.y() + dy);
31118
+ });
31119
+ } else node.y(this.snapPositionY);
30841
31120
  const { intersectedNodesWithDistances: newVerticalIntersectedNodes } = this.getVerticallyIntersectingNodes(node, visibleNodes);
30842
31121
  this.drawSizeGuidesVertically(newVerticalIntersectedNodes, this.peerDistanceY);
30843
31122
  return;
@@ -30848,7 +31127,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30848
31127
  if (match) {
30849
31128
  const newY = prevBox.y + prevBox.height + match.distance;
30850
31129
  this.setNodeClientRectY(node, newY);
30851
- this.snapPositionY = node.y();
31130
+ this.snapPositionY = node instanceof konva.default.Transformer ? newY : node.y();
30852
31131
  this.currentSizeSnapVertical = NODE_SNAP_VERTICAL.TOP;
30853
31132
  const newBox = this.getBoxClientRect(node);
30854
31133
  this.peerDistanceY = Math.round(newBox.y - (prevBox.y + prevBox.height));
@@ -30862,7 +31141,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30862
31141
  if (match) {
30863
31142
  const newY = nextBox.y - match.distance - box.height;
30864
31143
  this.setNodeClientRectY(node, newY);
30865
- this.snapPositionY = node.y();
31144
+ this.snapPositionY = node instanceof konva.default.Transformer ? newY : node.y();
30866
31145
  const newBox = this.getBoxClientRect(node);
30867
31146
  this.peerDistanceY = Math.round(nextBox.y - (newBox.y + newBox.height));
30868
31147
  this.currentSizeSnapVertical = NODE_SNAP_VERTICAL.BOTTOM;
@@ -30870,6 +31149,14 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30870
31149
  }
30871
31150
  }
30872
31151
  setNodeClientRectX(node, snappedClientX) {
31152
+ if (node instanceof konva.default.Transformer) {
31153
+ const box$1 = this.getBoxClientRect(node);
31154
+ const dx = snappedClientX - box$1.x;
31155
+ node.nodes().forEach((node$1) => {
31156
+ node$1.x(node$1.x() + dx);
31157
+ });
31158
+ return;
31159
+ } else node.x(snappedClientX);
30873
31160
  if (node.getParent()?.getType() === "Layer") {
30874
31161
  node.x(snappedClientX);
30875
31162
  return;
@@ -30893,6 +31180,14 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30893
31180
  });
30894
31181
  }
30895
31182
  setNodeClientRectY(node, snappedClientY) {
31183
+ if (node instanceof konva.default.Transformer) {
31184
+ const box$1 = this.getBoxClientRect(node);
31185
+ const dy = snappedClientY - box$1.y;
31186
+ node.nodes().forEach((node$1) => {
31187
+ node$1.y(node$1.y() + dy);
31188
+ });
31189
+ return;
31190
+ }
30896
31191
  if (node.getParent()?.getType() === "Layer") {
30897
31192
  node.y(snappedClientY);
30898
31193
  return;
@@ -30945,8 +31240,11 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30945
31240
  getVerticallyIntersectingNodes(targetNode, nodes) {
30946
31241
  const targetBox = this.getBoxClientRect(targetNode);
30947
31242
  const intersectedNodes = [];
31243
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
31244
+ let targetNodes = [targetNode.getAttrs().id ?? ""];
31245
+ if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) targetNodes = [targetNode.getAttrs().id ?? "", ...nodesSelectionPlugin.getTransformer().nodes().map((node) => node.getAttrs().id ?? "")];
30948
31246
  nodes.forEach((node) => {
30949
- if (node === targetNode || !node.isVisible()) return false;
31247
+ if (targetNodes.includes(node.getAttrs().id ?? "") || !node.isVisible()) return false;
30950
31248
  const box = this.getBoxClientRect(node);
30951
31249
  const horizontalOverlap = box.x + box.width > targetBox.x && box.x < targetBox.x + targetBox.width;
30952
31250
  if (horizontalOverlap) intersectedNodes.push(node);
@@ -30993,8 +31291,11 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
30993
31291
  getHorizontallyIntersectingNodes(targetNode, nodes) {
30994
31292
  const targetBox = this.getBoxClientRect(targetNode);
30995
31293
  const intersectedNodes = [];
31294
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
31295
+ let targetNodes = [targetNode.getAttrs().id ?? ""];
31296
+ if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) targetNodes = [targetNode.getAttrs().id ?? "", ...nodesSelectionPlugin.getTransformer().nodes().map((node) => node.getAttrs().id ?? "")];
30996
31297
  nodes.forEach((node) => {
30997
- if (node === targetNode || !node.isVisible()) return false;
31298
+ if (targetNodes.includes(node.getAttrs().id ?? "") || !node.isVisible()) return false;
30998
31299
  const box = this.getBoxClientRect(node);
30999
31300
  const verticalOverlap = box.y + box.height > targetBox.y && box.y < targetBox.y + targetBox.height;
31000
31301
  if (verticalOverlap) intersectedNodes.push(node);
@@ -31203,7 +31504,7 @@ var WeaveCommentsRendererPlugin = class extends WeavePlugin {
31203
31504
  }
31204
31505
  initCommentsLayer() {
31205
31506
  const stage = this.instance.getStage();
31206
- const commentsLayer = new konva.default.Layer({ id: WEAVE_COMMENT_TOOL_LAYER_NAME });
31507
+ const commentsLayer = new konva.default.Layer({ id: WEAVE_COMMENTS_TOOL_LAYER_ID });
31207
31508
  stage.add(commentsLayer);
31208
31509
  const selectionLayer = this.instance.getSelectionLayer();
31209
31510
  if (selectionLayer) {
@@ -31257,7 +31558,7 @@ var WeaveCommentsRendererPlugin = class extends WeavePlugin {
31257
31558
  }
31258
31559
  }
31259
31560
  getCommentsLayer() {
31260
- const commentsLayerId = `#${WEAVE_COMMENT_TOOL_LAYER_NAME}`;
31561
+ const commentsLayerId = `#${WEAVE_COMMENTS_TOOL_LAYER_ID}`;
31261
31562
  const commentLayer = this.instance.getStage()?.findOne(commentsLayerId);
31262
31563
  if (!commentLayer) return this.initCommentsLayer();
31263
31564
  return commentLayer;
@@ -31320,6 +31621,7 @@ exports.TEXT_TOOL_ACTION_NAME = TEXT_TOOL_ACTION_NAME
31320
31621
  exports.TEXT_TOOL_STATE = TEXT_TOOL_STATE
31321
31622
  exports.WEAVE_ARROW_NODE_TYPE = WEAVE_ARROW_NODE_TYPE
31322
31623
  exports.WEAVE_COMMENTS_RENDERER_KEY = WEAVE_COMMENTS_RENDERER_KEY
31624
+ exports.WEAVE_COMMENTS_TOOL_LAYER_ID = WEAVE_COMMENTS_TOOL_LAYER_ID
31323
31625
  exports.WEAVE_COMMENT_CREATE_ACTION = WEAVE_COMMENT_CREATE_ACTION
31324
31626
  exports.WEAVE_COMMENT_NODE_ACTION = WEAVE_COMMENT_NODE_ACTION
31325
31627
  exports.WEAVE_COMMENT_NODE_DEFAULTS = WEAVE_COMMENT_NODE_DEFAULTS
@@ -31327,7 +31629,6 @@ exports.WEAVE_COMMENT_NODE_TYPE = WEAVE_COMMENT_NODE_TYPE
31327
31629
  exports.WEAVE_COMMENT_STATUS = WEAVE_COMMENT_STATUS
31328
31630
  exports.WEAVE_COMMENT_TOOL_ACTION_NAME = WEAVE_COMMENT_TOOL_ACTION_NAME
31329
31631
  exports.WEAVE_COMMENT_TOOL_DEFAULT_CONFIG = WEAVE_COMMENT_TOOL_DEFAULT_CONFIG
31330
- exports.WEAVE_COMMENT_TOOL_LAYER_NAME = WEAVE_COMMENT_TOOL_LAYER_NAME
31331
31632
  exports.WEAVE_COMMENT_TOOL_STATE = WEAVE_COMMENT_TOOL_STATE
31332
31633
  exports.WEAVE_COMMENT_VIEW_ACTION = WEAVE_COMMENT_VIEW_ACTION
31333
31634
  exports.WEAVE_COPY_PASTE_CONFIG_DEFAULT = WEAVE_COPY_PASTE_CONFIG_DEFAULT
@@ -31416,6 +31717,7 @@ exports.WeaveRegularPolygonToolAction = WeaveRegularPolygonToolAction
31416
31717
  exports.WeaveSelectionToolAction = WeaveSelectionToolAction
31417
31718
  exports.WeaveStageDropAreaPlugin = WeaveStageDropAreaPlugin
31418
31719
  exports.WeaveStageGridPlugin = WeaveStageGridPlugin
31720
+ exports.WeaveStageMinimapPlugin = WeaveStageMinimapPlugin
31419
31721
  exports.WeaveStageNode = WeaveStageNode
31420
31722
  exports.WeaveStagePanningPlugin = WeaveStagePanningPlugin
31421
31723
  exports.WeaveStageResizePlugin = WeaveStageResizePlugin