@inditextech/weave-sdk 2.3.3 → 2.5.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.node.js CHANGED
@@ -17806,6 +17806,10 @@ function getTargetAndSkipNodes(instance, e, forceTransformer = false) {
17806
17806
  if (e.type === "dragmove" && nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) {
17807
17807
  node = nodesSelectionPlugin.getTransformer().nodes()[0];
17808
17808
  skipNodes.push(node.getAttrs().id ?? "");
17809
+ if (node.getAttr("eventTarget")) {
17810
+ node = e.target;
17811
+ skipNodes.push(e.target.getAttrs().id ?? "");
17812
+ }
17809
17813
  }
17810
17814
  if (e.type === "dragmove" && nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) {
17811
17815
  const { nodes } = getSelectedNodesMetadata(nodesSelectionPlugin.getTransformer());
@@ -18704,27 +18708,27 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18704
18708
  if (shape) {
18705
18709
  const targetNode = this.instance.getInstanceRecursive(shape);
18706
18710
  if (targetNode && targetNode !== nodeHovered) {
18707
- this.instance.getStage().handleMouseover();
18708
- nodeHovered?.handleMouseout();
18709
- targetNode?.handleMouseover();
18711
+ this.instance.getStage().handleMouseover?.();
18712
+ nodeHovered?.handleMouseout?.();
18713
+ targetNode?.handleMouseover?.();
18710
18714
  nodeHovered = targetNode;
18711
18715
  }
18712
- targetNode?.handleMouseover();
18713
- } else nodeHovered?.handleMouseout();
18716
+ targetNode?.handleMouseover?.();
18717
+ } else nodeHovered?.handleMouseout?.();
18714
18718
  });
18715
18719
  tr.on("mouseover", () => {
18716
18720
  stage.container().style.cursor = "grab";
18717
18721
  });
18718
18722
  tr.on("mouseout", () => {
18719
- this.instance.getStage().handleMouseover();
18723
+ this.instance.getStage().handleMouseover?.();
18720
18724
  nodeHovered = void 0;
18721
18725
  });
18722
18726
  window.addEventListener("mouseout", () => {
18723
18727
  if (nodeHovered) {
18724
- nodeHovered.handleMouseout();
18728
+ nodeHovered?.handleMouseout?.();
18725
18729
  nodeHovered = void 0;
18726
18730
  }
18727
- this.instance.getStage().handleMouseover();
18731
+ this.instance.getStage().handleMouseover?.();
18728
18732
  });
18729
18733
  const handleTransform = (e) => {
18730
18734
  const moved = this.checkMoved(e);
@@ -19047,7 +19051,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19047
19051
  if (!this.tapStart) return false;
19048
19052
  const dx = actual.x - init.x;
19049
19053
  const dy = actual.y - init.y;
19050
- const dist = Math.sqrt(dx * dx + dy * dy);
19054
+ const dist = Math.hypot(dx, dy);
19051
19055
  const MOVED_DISTANCE = 5;
19052
19056
  if (dist <= MOVED_DISTANCE) return false;
19053
19057
  return true;
@@ -19056,7 +19060,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19056
19060
  if (!this.tapStart) return false;
19057
19061
  const dx = e.evt.clientX - this.tapStart.x;
19058
19062
  const dy = e.evt.clientY - this.tapStart.y;
19059
- const dist = Math.sqrt(dx * dx + dy * dy);
19063
+ const dist = Math.hypot(dx, dy);
19060
19064
  const MOVED_DISTANCE = 5;
19061
19065
  if (dist <= MOVED_DISTANCE) return false;
19062
19066
  return true;
@@ -19066,7 +19070,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19066
19070
  const now$2 = performance.now();
19067
19071
  const dx = e.evt.clientX - this.tapStart.x;
19068
19072
  const dy = e.evt.clientY - this.tapStart.y;
19069
- const dist = Math.sqrt(dx * dx + dy * dy);
19073
+ const dist = Math.hypot(dx, dy);
19070
19074
  const DOUBLE_TAP_DISTANCE = 10;
19071
19075
  const DOUBLE_TAP_TIME = 300;
19072
19076
  this.isDoubleTap = false;
@@ -19510,10 +19514,8 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = { paddingOnPaste: {
19510
19514
  var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19511
19515
  constructor(params) {
19512
19516
  super();
19513
- this.config = {
19514
- ...WEAVE_COPY_PASTE_CONFIG_DEFAULT,
19515
- ...params?.config
19516
- };
19517
+ this.getImageBase64 = params.getImageBase64;
19518
+ this.config = mergeExceptArrays(WEAVE_COPY_PASTE_CONFIG_DEFAULT, params?.config);
19517
19519
  this.actualInternalPaddingX = 0;
19518
19520
  this.actualInternalPaddingY = 0;
19519
19521
  this.lastInternalPasteSnapshot = "";
@@ -19525,11 +19527,18 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19525
19527
  onInit() {
19526
19528
  this.initEvents();
19527
19529
  }
19528
- writeClipboardData(data) {
19530
+ writeClipboardData(base64Data, data) {
19529
19531
  return new Promise((resolve, reject) => {
19530
19532
  setTimeout(async () => {
19531
19533
  if (typeof navigator.clipboard === "undefined") return reject(new Error("Clipboard API not supported"));
19532
- navigator.clipboard.writeText(data).then(() => {
19534
+ const res = await fetch(base64Data);
19535
+ const imageBlob = await res.blob();
19536
+ const textBlob = new Blob([data], { type: "text/plain" });
19537
+ const item = new ClipboardItem({
19538
+ [imageBlob.type]: imageBlob,
19539
+ [textBlob.type]: textBlob
19540
+ });
19541
+ navigator.clipboard.write([item]).then(() => {
19533
19542
  resolve();
19534
19543
  }).catch((error) => {
19535
19544
  reject(error);
@@ -19595,7 +19604,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19595
19604
  window.addEventListener("keydown", async (e) => {
19596
19605
  if (stage.isFocused() && e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
19597
19606
  e.preventDefault();
19598
- await this.performCopy();
19607
+ await this.handleCopy();
19599
19608
  return;
19600
19609
  }
19601
19610
  if (stage.isFocused() && e.code === "KeyV" && (e.ctrlKey || e.metaKey)) {
@@ -19749,8 +19758,9 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19749
19758
  }
19750
19759
  this.cancel();
19751
19760
  }
19752
- async performCopy() {
19761
+ async handleCopy() {
19753
19762
  if (!this.enabled) return;
19763
+ this.instance.emitEvent("onPrepareCopy");
19754
19764
  const stage = this.instance.getStage();
19755
19765
  stage.container().style.cursor = "default";
19756
19766
  stage.container().focus();
@@ -19789,7 +19799,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19789
19799
  };
19790
19800
  }
19791
19801
  try {
19792
- await this.writeClipboardData(JSON.stringify(copyClipboard));
19802
+ const imageBase64Data = await this.getImageBase64(this.instance, selectedNodes);
19803
+ await this.writeClipboardData(imageBase64Data, JSON.stringify(copyClipboard));
19793
19804
  this.actualInternalPaddingX = 0;
19794
19805
  this.actualInternalPaddingY = 0;
19795
19806
  this.lastInternalPasteSnapshot = "";
@@ -19799,7 +19810,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19799
19810
  }
19800
19811
  }
19801
19812
  async copy() {
19802
- await this.performCopy();
19813
+ await this.handleCopy();
19803
19814
  }
19804
19815
  async paste(position, relativePosition) {
19805
19816
  const stage = this.instance.getStage();
@@ -20049,6 +20060,7 @@ var WeaveNode = class {
20049
20060
  node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
20050
20061
  node.on("transformend", (e) => {
20051
20062
  const node$1 = e.target;
20063
+ e.target.setAttr("strokeScaleEnabled", true);
20052
20064
  this.instance.emitEvent("onTransform", null);
20053
20065
  transforming = false;
20054
20066
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
@@ -20453,7 +20465,7 @@ var WeaveAction = class {
20453
20465
  if (!this.tapStart) return false;
20454
20466
  const dx = e.evt.clientX - this.tapStart.x;
20455
20467
  const dy = e.evt.clientY - this.tapStart.y;
20456
- const dist = Math.sqrt(dx * dx + dy * dy);
20468
+ const dist = Math.hypot(dx, dy);
20457
20469
  const dt = performance.now() - this.tapStart.time;
20458
20470
  const TAP_DISTANCE = 10;
20459
20471
  const TAP_TIME = 300;
@@ -21015,8 +21027,8 @@ var WeaveGroupsManager = class {
21015
21027
  }
21016
21028
  extractTransformFromMatrix(m) {
21017
21029
  const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
21018
- const scaleX = Math.sqrt(a * a + b * b);
21019
- const scaleY = Math.sqrt(c * c + d * d);
21030
+ const scaleX = Math.hypot(a, b);
21031
+ const scaleY = Math.hypot(c, d);
21020
21032
  const rotation = Math.atan2(b, a) * (180 / Math.PI);
21021
21033
  return {
21022
21034
  x: e,
@@ -21842,7 +21854,7 @@ var WeaveRegisterManager = class {
21842
21854
 
21843
21855
  //#endregion
21844
21856
  //#region package.json
21845
- var version = "2.3.3";
21857
+ var version = "2.5.0";
21846
21858
 
21847
21859
  //#endregion
21848
21860
  //#region src/managers/setup.ts
@@ -23243,15 +23255,75 @@ var WeaveEllipseNode = class extends WeaveNode {
23243
23255
  //#endregion
23244
23256
  //#region src/nodes/line/constants.ts
23245
23257
  const WEAVE_LINE_NODE_TYPE = "line";
23258
+ const WEAVE_LINE_NODE_DEFAULT_CONFIG = { snapAngles: {
23259
+ angles: [
23260
+ 0,
23261
+ 45,
23262
+ 90,
23263
+ 135,
23264
+ 180,
23265
+ 225,
23266
+ 270,
23267
+ 315
23268
+ ],
23269
+ activateThreshold: 5,
23270
+ releaseThreshold: 10
23271
+ } };
23272
+
23273
+ //#endregion
23274
+ //#region src/utils/greedy-snapper.ts
23275
+ var GreedySnapper = class {
23276
+ snappedAngle = null;
23277
+ constructor(config) {
23278
+ this.config = config;
23279
+ }
23280
+ reset() {
23281
+ this.snappedAngle = null;
23282
+ }
23283
+ apply(angleDeg) {
23284
+ const { snapAngles, activateThreshold, releaseThreshold } = this.config;
23285
+ const normalized = (angleDeg % 360 + 360) % 360;
23286
+ if (this.snappedAngle !== null) {
23287
+ const diff = Math.abs(normalized - this.snappedAngle);
23288
+ if (diff > releaseThreshold) {
23289
+ this.snappedAngle = null;
23290
+ return normalized;
23291
+ }
23292
+ return this.snappedAngle;
23293
+ }
23294
+ let closest = snapAngles[0];
23295
+ let minDiff = Math.abs(normalized - closest);
23296
+ for (const a of snapAngles) {
23297
+ const d = Math.abs(normalized - a);
23298
+ if (d < minDiff) {
23299
+ minDiff = d;
23300
+ closest = a;
23301
+ }
23302
+ }
23303
+ if (minDiff <= activateThreshold) {
23304
+ this.snappedAngle = closest;
23305
+ return closest;
23306
+ }
23307
+ return normalized;
23308
+ }
23309
+ };
23246
23310
 
23247
23311
  //#endregion
23248
23312
  //#region src/nodes/line/line.ts
23249
23313
  var WeaveLineNode = class extends WeaveNode {
23314
+ startHandle = null;
23315
+ endHandle = null;
23250
23316
  nodeType = WEAVE_LINE_NODE_TYPE;
23251
23317
  constructor(params) {
23252
23318
  super();
23253
- const { config } = params ?? {};
23254
- this.config = { transform: { ...config?.transform } };
23319
+ this.config = mergeExceptArrays(WEAVE_LINE_NODE_DEFAULT_CONFIG, params?.config ?? {});
23320
+ this.handleNodeChanges = null;
23321
+ this.handleZoomChanges = null;
23322
+ this.snapper = new GreedySnapper({
23323
+ snapAngles: this.config.snapAngles.angles,
23324
+ activateThreshold: this.config.snapAngles.activateThreshold,
23325
+ releaseThreshold: this.config.snapAngles.releaseThreshold
23326
+ });
23255
23327
  }
23256
23328
  onRender(props) {
23257
23329
  const line = new Konva.Line({
@@ -23262,11 +23334,240 @@ var WeaveLineNode = class extends WeaveNode {
23262
23334
  this.setupDefaultNodeAugmentation(line);
23263
23335
  const defaultTransformerProperties = this.defaultGetTransformerProperties(this.config.transform);
23264
23336
  line.getTransformerProperties = function() {
23265
- return defaultTransformerProperties;
23337
+ return {
23338
+ ...defaultTransformerProperties,
23339
+ ignoreStroke: true,
23340
+ rotateEnabled: this.points().length !== 4,
23341
+ keepRatio: this.points().length !== 4,
23342
+ flipEnabled: this.points().length === 4,
23343
+ shiftBehavior: this.points().length === 4 ? "none" : "default"
23344
+ };
23345
+ };
23346
+ let originalStartHandleVisibility = null;
23347
+ let originalEndHandleVisibility = null;
23348
+ line.on("dragstart", () => {
23349
+ originalStartHandleVisibility = this.startHandle?.visible() ?? false;
23350
+ originalEndHandleVisibility = this.endHandle?.visible() ?? false;
23351
+ this.startHandle?.visible(false);
23352
+ this.endHandle?.visible(false);
23353
+ });
23354
+ line.on("dragend", () => {
23355
+ this.startHandle?.visible(originalStartHandleVisibility);
23356
+ this.endHandle?.visible(originalEndHandleVisibility);
23357
+ originalStartHandleVisibility = null;
23358
+ originalEndHandleVisibility = null;
23359
+ });
23360
+ line.allowedAnchors = function() {
23361
+ if (this.points().length !== 4) return [
23362
+ "top-left",
23363
+ "top-center",
23364
+ "top-right",
23365
+ "middle-right",
23366
+ "middle-left",
23367
+ "bottom-left",
23368
+ "bottom-center",
23369
+ "bottom-right"
23370
+ ];
23371
+ return [];
23266
23372
  };
23267
23373
  this.setupDefaultNodeEvents(line);
23374
+ if (!this.handleZoomChanges) {
23375
+ this.handleZoomChanges = () => {
23376
+ if (this.startHandle) this.startHandle.scale({
23377
+ x: 1 / this.instance.getStage().scaleX(),
23378
+ y: 1 / this.instance.getStage().scaleY()
23379
+ });
23380
+ if (this.endHandle) this.endHandle.scale({
23381
+ x: 1 / this.instance.getStage().scaleX(),
23382
+ y: 1 / this.instance.getStage().scaleY()
23383
+ });
23384
+ };
23385
+ this.instance.addEventListener("onZoomChange", this.handleZoomChanges);
23386
+ }
23387
+ if (!this.handleNodeChanges) {
23388
+ this.handleNodeChanges = (nodes) => {
23389
+ if (nodes.length === 1 && nodes[0].instance.getAttrs().nodeType === "line" && nodes[0].instance.points().length === 4) {
23390
+ const lineSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
23391
+ if (!lineSelected) return;
23392
+ this.setupHandles();
23393
+ this.showHandles(lineSelected);
23394
+ } else {
23395
+ this.startHandle?.setAttr("lineId", void 0);
23396
+ this.startHandle?.visible(false);
23397
+ this.endHandle?.setAttr("lineId", void 0);
23398
+ this.endHandle?.visible(false);
23399
+ }
23400
+ };
23401
+ this.instance.addEventListener("onNodesChange", this.handleNodeChanges);
23402
+ }
23268
23403
  return line;
23269
23404
  }
23405
+ defineFinalPoint(handle, origin, e) {
23406
+ let pos = {
23407
+ x: 0,
23408
+ y: 0
23409
+ };
23410
+ if (e.evt.shiftKey) {
23411
+ const handlePosition = handle.position();
23412
+ let dx = handlePosition.x - origin.x;
23413
+ let dy = handlePosition.y - origin.y;
23414
+ const angle = Math.atan2(dy, dx);
23415
+ const angleDeg = angle * 180 / Math.PI;
23416
+ const snapped = this.snapper.apply(angleDeg);
23417
+ const dist = Math.hypot(dx, dy);
23418
+ const rad = snapped * Math.PI / 180;
23419
+ dx = Math.cos(rad) * dist;
23420
+ dy = Math.sin(rad) * dist;
23421
+ pos.x = origin.x + dx;
23422
+ pos.y = origin.y + dy;
23423
+ } else pos = handle.position();
23424
+ return pos;
23425
+ }
23426
+ setupHandles() {
23427
+ if (!this.startHandle) {
23428
+ const startHandle = new Konva.Circle({
23429
+ id: "line-start-handle",
23430
+ radius: 5,
23431
+ fill: "#ffffff",
23432
+ stroke: "#000000",
23433
+ strokeWidth: 1,
23434
+ edgeDistanceDisableOnDrag: true,
23435
+ scaleX: 1 / this.instance.getStage().scaleX(),
23436
+ scaleY: 1 / this.instance.getStage().scaleY(),
23437
+ draggable: true
23438
+ });
23439
+ startHandle.on("pointerover", () => {
23440
+ this.instance.getStage().container().style.cursor = "move";
23441
+ });
23442
+ startHandle.on("pointerout", () => {
23443
+ this.instance.getStage().container().style.cursor = "default";
23444
+ });
23445
+ startHandle.on("dragstart", (e) => {
23446
+ const lineId = e.target.getAttr("lineId");
23447
+ const line = this.instance.getStage().findOne(`#${lineId}`);
23448
+ if (!line) return;
23449
+ if (line.points().length === 4) line.setAttr("eventTarget", true);
23450
+ this.instance.emitEvent("onDrag", e.target);
23451
+ });
23452
+ startHandle.on("dragmove", (e) => {
23453
+ const draggedTarget = e.target;
23454
+ const lineId = draggedTarget.getAttr("lineId");
23455
+ const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
23456
+ if (!draggedLine) return;
23457
+ const pos = this.defineFinalPoint(startHandle, {
23458
+ x: draggedLine.x() + draggedLine.points()[2],
23459
+ y: draggedLine.y() + draggedLine.points()[3]
23460
+ }, e);
23461
+ const [, , x2, y2] = draggedLine.points();
23462
+ startHandle.position(pos);
23463
+ draggedLine.points([
23464
+ pos.x - draggedLine.x(),
23465
+ pos.y - draggedLine.y(),
23466
+ x2,
23467
+ y2
23468
+ ]);
23469
+ });
23470
+ startHandle.on("dragend", (e) => {
23471
+ const draggedTarget = e.target;
23472
+ const lineId = draggedTarget.getAttr("lineId");
23473
+ const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
23474
+ if (!draggedLine) return;
23475
+ const { x, y } = startHandle.position();
23476
+ const [, , x2, y2] = draggedLine.points();
23477
+ draggedLine.points([
23478
+ x - draggedLine.x(),
23479
+ y - draggedLine.y(),
23480
+ x2,
23481
+ y2
23482
+ ]);
23483
+ this.instance.updateNode(this.serialize(draggedLine));
23484
+ this.instance.emitEvent("onDrag", null);
23485
+ });
23486
+ this.startHandle = startHandle;
23487
+ this.startHandle.visible(false);
23488
+ this.instance.getSelectionLayer()?.add(this.startHandle);
23489
+ }
23490
+ if (!this.endHandle) {
23491
+ const endHandle = new Konva.Circle({
23492
+ id: "line-end-handle",
23493
+ radius: 5,
23494
+ fill: "#ffffff",
23495
+ stroke: "#000000",
23496
+ strokeWidth: 1,
23497
+ edgeDistanceDisableOnDrag: true,
23498
+ scaleX: 1 / this.instance.getStage().scaleX(),
23499
+ scaleY: 1 / this.instance.getStage().scaleY(),
23500
+ draggable: true
23501
+ });
23502
+ endHandle.on("pointerover", () => {
23503
+ this.instance.getStage().container().style.cursor = "move";
23504
+ });
23505
+ endHandle.on("pointerout", () => {
23506
+ this.instance.getStage().container().style.cursor = "default";
23507
+ });
23508
+ endHandle.on("dragstart", (e) => {
23509
+ const lineId = e.target.getAttr("lineId");
23510
+ const line = this.instance.getStage().findOne(`#${lineId}`);
23511
+ if (!line) return;
23512
+ if (line.points().length === 4) line.setAttr("eventTarget", true);
23513
+ this.instance.emitEvent("onDrag", e.target);
23514
+ });
23515
+ endHandle.on("dragmove", (e) => {
23516
+ const draggedTarget = e.target;
23517
+ const lineId = draggedTarget.getAttr("lineId");
23518
+ const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
23519
+ if (!draggedLine) return;
23520
+ const pos = this.defineFinalPoint(endHandle, {
23521
+ x: draggedLine.x() + draggedLine.points()[0],
23522
+ y: draggedLine.y() + draggedLine.points()[1]
23523
+ }, e);
23524
+ const [x1, y1] = draggedLine.points();
23525
+ endHandle.position(pos);
23526
+ draggedLine.points([
23527
+ x1,
23528
+ y1,
23529
+ pos.x - draggedLine.x(),
23530
+ pos.y - draggedLine.y()
23531
+ ]);
23532
+ });
23533
+ endHandle.on("dragend", (e) => {
23534
+ const draggedTarget = e.target;
23535
+ const lineId = draggedTarget.getAttr("lineId");
23536
+ const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
23537
+ if (!draggedLine) return;
23538
+ const { x, y } = endHandle.position();
23539
+ const [x1, y1] = draggedLine.points();
23540
+ draggedLine.points([
23541
+ x1,
23542
+ y1,
23543
+ x - draggedLine.x(),
23544
+ y - draggedLine.y()
23545
+ ]);
23546
+ this.instance.updateNode(this.serialize(draggedLine));
23547
+ this.instance.emitEvent("onDrag", null);
23548
+ });
23549
+ this.endHandle = endHandle;
23550
+ this.endHandle.visible(false);
23551
+ this.instance.getSelectionLayer()?.add(this.endHandle);
23552
+ }
23553
+ }
23554
+ showHandles(line) {
23555
+ const [x1, y1, x2, y2] = line.points();
23556
+ if (this.startHandle === null || this.endHandle === null) return;
23557
+ const lineId = line.getAttrs().id;
23558
+ this.startHandle.setAttr("lineId", lineId);
23559
+ this.startHandle.setAttr("targetNode", lineId);
23560
+ this.startHandle.x(line.x() + x1);
23561
+ this.startHandle.y(line.y() + y1);
23562
+ this.startHandle.visible(true);
23563
+ this.startHandle.moveToTop();
23564
+ this.endHandle.setAttr("lineId", lineId);
23565
+ this.endHandle.setAttr("targetNode", lineId);
23566
+ this.endHandle.x(line.x() + x2);
23567
+ this.endHandle.y(line.y() + y2);
23568
+ this.endHandle.visible(true);
23569
+ this.endHandle.moveToTop();
23570
+ }
23270
23571
  onUpdate(nodeInstance, nextProps) {
23271
23572
  nodeInstance.setAttrs({ ...nextProps });
23272
23573
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
@@ -25231,7 +25532,7 @@ var WeaveStrokeNode = class extends WeaveNode {
25231
25532
  const p1 = centerline[i + 1];
25232
25533
  const dx = p1.x - p0.x;
25233
25534
  const dy = p1.y - p0.y;
25234
- const segLen = Math.sqrt(dx * dx + dy * dy) || 1;
25535
+ const segLen = Math.hypot(dx, dy) || 1;
25235
25536
  const nx = -dy / segLen;
25236
25537
  const ny = dx / segLen;
25237
25538
  const w0 = baseW * p0.pressure / 2;
@@ -26928,7 +27229,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
26928
27229
  this.enabled = false;
26929
27230
  }
26930
27231
  getDistance(p1, p2) {
26931
- return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
27232
+ return Math.hypot(p2.x - p1.x, p2.y - p1.y);
26932
27233
  }
26933
27234
  getCenter(p1, p2) {
26934
27235
  return {
@@ -31809,7 +32110,11 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
31809
32110
  if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) {
31810
32111
  if (nodesSelectionPlugin) nodeParent = this.instance.getNodeContainer(nodesSelectionPlugin.getTransformer().nodes()[0]);
31811
32112
  }
31812
- if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) nodeParent = this.instance.getNodeContainer(node);
32113
+ if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) if (node.getAttrs().targetNode) {
32114
+ const targetNodeId = node.getAttrs().targetNode;
32115
+ const targetNode = this.instance.getStage().findOne(`#${targetNodeId}`);
32116
+ if (targetNode) nodeParent = this.instance.getNodeContainer(targetNode);
32117
+ } else nodeParent = this.instance.getNodeContainer(node);
31813
32118
  return nodeParent;
31814
32119
  }
31815
32120
  cleanupGuidelines() {
@@ -32097,6 +32402,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
32097
32402
  const utilityLayer = this.instance.getUtilityLayer();
32098
32403
  if (!this.enabled) return;
32099
32404
  if (!utilityLayer) return;
32405
+ if (e.target.getAttr("edgeDistanceDisableOnDrag")) return;
32100
32406
  const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e, true);
32101
32407
  if (typeof node === "undefined") return;
32102
32408
  const nodeParent = this.getSelectionParentNode();
@@ -32800,5 +33106,5 @@ if (typeof window === "undefined") {
32800
33106
  }
32801
33107
 
32802
33108
  //#endregion
32803
- export { ALIGN_NODES_ALIGN_TO, ALIGN_NODES_TOOL_ACTION_NAME, ALIGN_NODES_TOOL_STATE, ARROW_TOOL_ACTION_NAME, ARROW_TOOL_STATE, BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_DEFAULT_CONFIG, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, ELLIPSE_TOOL_ACTION_NAME, ELLIPSE_TOOL_STATE, ERASER_TOOL_ACTION_NAME, ERASER_TOOL_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, GUIDE_ENTER_SNAPPING_TOLERANCE, GUIDE_EXIT_SNAPPING_TOLERANCE, GUIDE_HORIZONTAL_LINE_NAME, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, GUIDE_VERTICAL_LINE_NAME, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NODE_SNAP_HORIZONTAL, NODE_SNAP_VERTICAL, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, REGULAR_POLYGON_TOOL_ACTION_NAME, REGULAR_POLYGON_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, STAGE_MINIMAP_DEFAULT_CONFIG, STAR_TOOL_ACTION_NAME, STAR_TOOL_STATE, TEXT_LAYOUT, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, VIDEO_TOOL_ACTION_NAME, VIDEO_TOOL_STATE, WEAVE_ARROW_NODE_TYPE, WEAVE_COMMENTS_RENDERER_KEY, WEAVE_COMMENTS_TOOL_LAYER_ID, WEAVE_COMMENT_CREATE_ACTION, WEAVE_COMMENT_NODE_ACTION, WEAVE_COMMENT_NODE_DEFAULTS, WEAVE_COMMENT_NODE_TYPE, WEAVE_COMMENT_STATUS, WEAVE_COMMENT_TOOL_ACTION_NAME, WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, WEAVE_COMMENT_TOOL_STATE, WEAVE_COMMENT_VIEW_ACTION, WEAVE_COPY_PASTE_CONFIG_DEFAULT, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_COPY_PASTE_PASTE_CATCHER_ID, WEAVE_COPY_PASTE_PASTE_MODES, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_ELLIPSE_NODE_TYPE, WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS, WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO, WEAVE_GRID_DEFAULT_MAJOR_EVERY, WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_RADIUS, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_STROKE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_GROUP_NODE_TYPE, WEAVE_IMAGE_CROP_END_TYPE, WEAVE_IMAGE_DEFAULT_CONFIG, WEAVE_IMAGE_NODE_TYPE, WEAVE_LAYER_NODE_TYPE, WEAVE_LINE_NODE_TYPE, WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_LAYER_ID, WEAVE_NODES_SELECTION_DEFAULT_CONFIG, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_RECTANGLE_NODE_TYPE, WEAVE_REGULAR_POLYGON_NODE_TYPE, WEAVE_STAGE_DEFAULT_MODE, WEAVE_STAGE_GRID_PLUGIN_KEY, WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG, WEAVE_STAGE_KEYBOARD_MOVE_KEY, WEAVE_STAGE_MINIMAP_KEY, WEAVE_STAGE_NODE_TYPE, WEAVE_STAGE_PANNING_DEFAULT_CONFIG, WEAVE_STAGE_PANNING_KEY, WEAVE_STAR_NODE_TYPE, WEAVE_STROKE_NODE_DEFAULT_CONFIG, WEAVE_STROKE_NODE_TYPE, WEAVE_TEXT_NODE_TYPE, WEAVE_USERS_POINTERS_CONFIG_DEFAULT_PROPS, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_SELECTION_KEY, WEAVE_USER_POINTER_KEY, WEAVE_USER_SELECTION_KEY, WEAVE_VIDEO_DEFAULT_CONFIG, WEAVE_VIDEO_NODE_TYPE, Weave, WeaveAction, WeaveAlignNodesToolAction, WeaveArrowNode, WeaveArrowToolAction, WeaveBrushToolAction, WeaveCommentNode, WeaveCommentToolAction, WeaveCommentsRendererPlugin, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveEllipseNode, WeaveEllipseToolAction, WeaveEraserToolAction, WeaveExportNodesToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesDistanceSnappingPlugin, WeaveNodesEdgeSnappingPlugin, WeaveNodesMultiSelectionFeedbackPlugin, WeaveNodesSelectionPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRegularPolygonNode, WeaveRegularPolygonToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageKeyboardMovePlugin, WeaveStageMinimapPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStarNode, WeaveStarToolAction, WeaveStore, WeaveStrokeNode, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveUsersSelectionPlugin, WeaveVideoNode, WeaveVideoToolAction, WeaveZoomInToolAction, WeaveZoomOutToolAction, canComposite, clearContainerTargets, containerOverCursor, containsNodeDeep, defaultInitialState, getBoundingBox, getExportBoundingBox, getPositionRelativeToContainerOnPosition, getSelectedNodesMetadata, getStageClickPoint, getTargetAndSkipNodes, getTargetedNode, getTopmostShadowHost, getVisibleNodes, getVisibleNodesInViewport, hasFrames, hasImages, intersectArrays, isIOS, isInShadowDOM, isNodeInSelection, isServer, memoize, mergeExceptArrays, moveNodeToContainer, resetScale, setupCanvasBackend, setupSkiaBackend };
33109
+ export { ALIGN_NODES_ALIGN_TO, ALIGN_NODES_TOOL_ACTION_NAME, ALIGN_NODES_TOOL_STATE, ARROW_TOOL_ACTION_NAME, ARROW_TOOL_STATE, BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_DEFAULT_CONFIG, BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, ELLIPSE_TOOL_ACTION_NAME, ELLIPSE_TOOL_STATE, ERASER_TOOL_ACTION_NAME, ERASER_TOOL_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, GUIDE_ENTER_SNAPPING_TOLERANCE, GUIDE_EXIT_SNAPPING_TOLERANCE, GUIDE_HORIZONTAL_LINE_NAME, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, GUIDE_VERTICAL_LINE_NAME, IMAGE_TOOL_ACTION_NAME, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NODE_SNAP_HORIZONTAL, NODE_SNAP_VERTICAL, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, REGULAR_POLYGON_TOOL_ACTION_NAME, REGULAR_POLYGON_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, STAGE_MINIMAP_DEFAULT_CONFIG, STAR_TOOL_ACTION_NAME, STAR_TOOL_STATE, TEXT_LAYOUT, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, VIDEO_TOOL_ACTION_NAME, VIDEO_TOOL_STATE, WEAVE_ARROW_NODE_TYPE, WEAVE_COMMENTS_RENDERER_KEY, WEAVE_COMMENTS_TOOL_LAYER_ID, WEAVE_COMMENT_CREATE_ACTION, WEAVE_COMMENT_NODE_ACTION, WEAVE_COMMENT_NODE_DEFAULTS, WEAVE_COMMENT_NODE_TYPE, WEAVE_COMMENT_STATUS, WEAVE_COMMENT_TOOL_ACTION_NAME, WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, WEAVE_COMMENT_TOOL_STATE, WEAVE_COMMENT_VIEW_ACTION, WEAVE_COPY_PASTE_CONFIG_DEFAULT, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_COPY_PASTE_PASTE_CATCHER_ID, WEAVE_COPY_PASTE_PASTE_MODES, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_ELLIPSE_NODE_TYPE, WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS, WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO, WEAVE_GRID_DEFAULT_MAJOR_EVERY, WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_RADIUS, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_STROKE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_GROUP_NODE_TYPE, WEAVE_IMAGE_CROP_END_TYPE, WEAVE_IMAGE_DEFAULT_CONFIG, WEAVE_IMAGE_NODE_TYPE, WEAVE_LAYER_NODE_TYPE, WEAVE_LINE_NODE_DEFAULT_CONFIG, WEAVE_LINE_NODE_TYPE, WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_LAYER_ID, WEAVE_NODES_SELECTION_DEFAULT_CONFIG, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_RECTANGLE_NODE_TYPE, WEAVE_REGULAR_POLYGON_NODE_TYPE, WEAVE_STAGE_DEFAULT_MODE, WEAVE_STAGE_GRID_PLUGIN_KEY, WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG, WEAVE_STAGE_KEYBOARD_MOVE_KEY, WEAVE_STAGE_MINIMAP_KEY, WEAVE_STAGE_NODE_TYPE, WEAVE_STAGE_PANNING_DEFAULT_CONFIG, WEAVE_STAGE_PANNING_KEY, WEAVE_STAR_NODE_TYPE, WEAVE_STROKE_NODE_DEFAULT_CONFIG, WEAVE_STROKE_NODE_TYPE, WEAVE_TEXT_NODE_TYPE, WEAVE_USERS_POINTERS_CONFIG_DEFAULT_PROPS, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_SELECTION_KEY, WEAVE_USER_POINTER_KEY, WEAVE_USER_SELECTION_KEY, WEAVE_VIDEO_DEFAULT_CONFIG, WEAVE_VIDEO_NODE_TYPE, Weave, WeaveAction, WeaveAlignNodesToolAction, WeaveArrowNode, WeaveArrowToolAction, WeaveBrushToolAction, WeaveCommentNode, WeaveCommentToolAction, WeaveCommentsRendererPlugin, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveEllipseNode, WeaveEllipseToolAction, WeaveEraserToolAction, WeaveExportNodesToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesDistanceSnappingPlugin, WeaveNodesEdgeSnappingPlugin, WeaveNodesMultiSelectionFeedbackPlugin, WeaveNodesSelectionPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRegularPolygonNode, WeaveRegularPolygonToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageKeyboardMovePlugin, WeaveStageMinimapPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStarNode, WeaveStarToolAction, WeaveStore, WeaveStrokeNode, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveUsersSelectionPlugin, WeaveVideoNode, WeaveVideoToolAction, WeaveZoomInToolAction, WeaveZoomOutToolAction, canComposite, clearContainerTargets, containerOverCursor, containsNodeDeep, defaultInitialState, getBoundingBox, getExportBoundingBox, getPositionRelativeToContainerOnPosition, getSelectedNodesMetadata, getStageClickPoint, getTargetAndSkipNodes, getTargetedNode, getTopmostShadowHost, getVisibleNodes, getVisibleNodesInViewport, hasFrames, hasImages, intersectArrays, isIOS, isInShadowDOM, isNodeInSelection, isServer, memoize, mergeExceptArrays, moveNodeToContainer, resetScale, setupCanvasBackend, setupSkiaBackend };
32804
33110
  //# sourceMappingURL=sdk.node.js.map