@inditextech/weave-sdk 2.3.3 → 2.4.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.d.ts +121 -9
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +600 -22
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.node.d.ts +58 -22
- package/dist/sdk.node.d.ts.map +1 -1
- package/dist/sdk.node.js +321 -22
- package/dist/sdk.node.js.map +1 -1
- package/package.json +2 -2
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
|
|
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.
|
|
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.
|
|
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.
|
|
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;
|
|
@@ -20049,6 +20053,7 @@ var WeaveNode = class {
|
|
|
20049
20053
|
node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
|
|
20050
20054
|
node.on("transformend", (e) => {
|
|
20051
20055
|
const node$1 = e.target;
|
|
20056
|
+
e.target.setAttr("strokeScaleEnabled", true);
|
|
20052
20057
|
this.instance.emitEvent("onTransform", null);
|
|
20053
20058
|
transforming = false;
|
|
20054
20059
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -20453,7 +20458,7 @@ var WeaveAction = class {
|
|
|
20453
20458
|
if (!this.tapStart) return false;
|
|
20454
20459
|
const dx = e.evt.clientX - this.tapStart.x;
|
|
20455
20460
|
const dy = e.evt.clientY - this.tapStart.y;
|
|
20456
|
-
const dist = Math.
|
|
20461
|
+
const dist = Math.hypot(dx, dy);
|
|
20457
20462
|
const dt = performance.now() - this.tapStart.time;
|
|
20458
20463
|
const TAP_DISTANCE = 10;
|
|
20459
20464
|
const TAP_TIME = 300;
|
|
@@ -21015,8 +21020,8 @@ var WeaveGroupsManager = class {
|
|
|
21015
21020
|
}
|
|
21016
21021
|
extractTransformFromMatrix(m) {
|
|
21017
21022
|
const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
|
|
21018
|
-
const scaleX = Math.
|
|
21019
|
-
const scaleY = Math.
|
|
21023
|
+
const scaleX = Math.hypot(a, b);
|
|
21024
|
+
const scaleY = Math.hypot(c, d);
|
|
21020
21025
|
const rotation = Math.atan2(b, a) * (180 / Math.PI);
|
|
21021
21026
|
return {
|
|
21022
21027
|
x: e,
|
|
@@ -21842,7 +21847,7 @@ var WeaveRegisterManager = class {
|
|
|
21842
21847
|
|
|
21843
21848
|
//#endregion
|
|
21844
21849
|
//#region package.json
|
|
21845
|
-
var version = "2.
|
|
21850
|
+
var version = "2.4.0";
|
|
21846
21851
|
|
|
21847
21852
|
//#endregion
|
|
21848
21853
|
//#region src/managers/setup.ts
|
|
@@ -23243,15 +23248,75 @@ var WeaveEllipseNode = class extends WeaveNode {
|
|
|
23243
23248
|
//#endregion
|
|
23244
23249
|
//#region src/nodes/line/constants.ts
|
|
23245
23250
|
const WEAVE_LINE_NODE_TYPE = "line";
|
|
23251
|
+
const WEAVE_LINE_NODE_DEFAULT_CONFIG = { snapAngles: {
|
|
23252
|
+
angles: [
|
|
23253
|
+
0,
|
|
23254
|
+
45,
|
|
23255
|
+
90,
|
|
23256
|
+
135,
|
|
23257
|
+
180,
|
|
23258
|
+
225,
|
|
23259
|
+
270,
|
|
23260
|
+
315
|
|
23261
|
+
],
|
|
23262
|
+
activateThreshold: 5,
|
|
23263
|
+
releaseThreshold: 10
|
|
23264
|
+
} };
|
|
23265
|
+
|
|
23266
|
+
//#endregion
|
|
23267
|
+
//#region src/utils/greedy-snapper.ts
|
|
23268
|
+
var GreedySnapper = class {
|
|
23269
|
+
snappedAngle = null;
|
|
23270
|
+
constructor(config) {
|
|
23271
|
+
this.config = config;
|
|
23272
|
+
}
|
|
23273
|
+
reset() {
|
|
23274
|
+
this.snappedAngle = null;
|
|
23275
|
+
}
|
|
23276
|
+
apply(angleDeg) {
|
|
23277
|
+
const { snapAngles, activateThreshold, releaseThreshold } = this.config;
|
|
23278
|
+
const normalized = (angleDeg % 360 + 360) % 360;
|
|
23279
|
+
if (this.snappedAngle !== null) {
|
|
23280
|
+
const diff = Math.abs(normalized - this.snappedAngle);
|
|
23281
|
+
if (diff > releaseThreshold) {
|
|
23282
|
+
this.snappedAngle = null;
|
|
23283
|
+
return normalized;
|
|
23284
|
+
}
|
|
23285
|
+
return this.snappedAngle;
|
|
23286
|
+
}
|
|
23287
|
+
let closest = snapAngles[0];
|
|
23288
|
+
let minDiff = Math.abs(normalized - closest);
|
|
23289
|
+
for (const a of snapAngles) {
|
|
23290
|
+
const d = Math.abs(normalized - a);
|
|
23291
|
+
if (d < minDiff) {
|
|
23292
|
+
minDiff = d;
|
|
23293
|
+
closest = a;
|
|
23294
|
+
}
|
|
23295
|
+
}
|
|
23296
|
+
if (minDiff <= activateThreshold) {
|
|
23297
|
+
this.snappedAngle = closest;
|
|
23298
|
+
return closest;
|
|
23299
|
+
}
|
|
23300
|
+
return normalized;
|
|
23301
|
+
}
|
|
23302
|
+
};
|
|
23246
23303
|
|
|
23247
23304
|
//#endregion
|
|
23248
23305
|
//#region src/nodes/line/line.ts
|
|
23249
23306
|
var WeaveLineNode = class extends WeaveNode {
|
|
23307
|
+
startHandle = null;
|
|
23308
|
+
endHandle = null;
|
|
23250
23309
|
nodeType = WEAVE_LINE_NODE_TYPE;
|
|
23251
23310
|
constructor(params) {
|
|
23252
23311
|
super();
|
|
23253
|
-
|
|
23254
|
-
this.
|
|
23312
|
+
this.config = mergeExceptArrays(WEAVE_LINE_NODE_DEFAULT_CONFIG, params?.config ?? {});
|
|
23313
|
+
this.handleNodeChanges = null;
|
|
23314
|
+
this.handleZoomChanges = null;
|
|
23315
|
+
this.snapper = new GreedySnapper({
|
|
23316
|
+
snapAngles: this.config.snapAngles.angles,
|
|
23317
|
+
activateThreshold: this.config.snapAngles.activateThreshold,
|
|
23318
|
+
releaseThreshold: this.config.snapAngles.releaseThreshold
|
|
23319
|
+
});
|
|
23255
23320
|
}
|
|
23256
23321
|
onRender(props) {
|
|
23257
23322
|
const line = new Konva.Line({
|
|
@@ -23262,11 +23327,240 @@ var WeaveLineNode = class extends WeaveNode {
|
|
|
23262
23327
|
this.setupDefaultNodeAugmentation(line);
|
|
23263
23328
|
const defaultTransformerProperties = this.defaultGetTransformerProperties(this.config.transform);
|
|
23264
23329
|
line.getTransformerProperties = function() {
|
|
23265
|
-
return
|
|
23330
|
+
return {
|
|
23331
|
+
...defaultTransformerProperties,
|
|
23332
|
+
ignoreStroke: true,
|
|
23333
|
+
rotateEnabled: this.points().length !== 4,
|
|
23334
|
+
keepRatio: this.points().length !== 4,
|
|
23335
|
+
flipEnabled: this.points().length === 4,
|
|
23336
|
+
shiftBehavior: this.points().length === 4 ? "none" : "default"
|
|
23337
|
+
};
|
|
23338
|
+
};
|
|
23339
|
+
let originalStartHandleVisibility = null;
|
|
23340
|
+
let originalEndHandleVisibility = null;
|
|
23341
|
+
line.on("dragstart", () => {
|
|
23342
|
+
originalStartHandleVisibility = this.startHandle?.visible() ?? false;
|
|
23343
|
+
originalEndHandleVisibility = this.endHandle?.visible() ?? false;
|
|
23344
|
+
this.startHandle?.visible(false);
|
|
23345
|
+
this.endHandle?.visible(false);
|
|
23346
|
+
});
|
|
23347
|
+
line.on("dragend", () => {
|
|
23348
|
+
this.startHandle?.visible(originalStartHandleVisibility);
|
|
23349
|
+
this.endHandle?.visible(originalEndHandleVisibility);
|
|
23350
|
+
originalStartHandleVisibility = null;
|
|
23351
|
+
originalEndHandleVisibility = null;
|
|
23352
|
+
});
|
|
23353
|
+
line.allowedAnchors = function() {
|
|
23354
|
+
if (this.points().length !== 4) return [
|
|
23355
|
+
"top-left",
|
|
23356
|
+
"top-center",
|
|
23357
|
+
"top-right",
|
|
23358
|
+
"middle-right",
|
|
23359
|
+
"middle-left",
|
|
23360
|
+
"bottom-left",
|
|
23361
|
+
"bottom-center",
|
|
23362
|
+
"bottom-right"
|
|
23363
|
+
];
|
|
23364
|
+
return [];
|
|
23266
23365
|
};
|
|
23267
23366
|
this.setupDefaultNodeEvents(line);
|
|
23367
|
+
if (!this.handleZoomChanges) {
|
|
23368
|
+
this.handleZoomChanges = () => {
|
|
23369
|
+
if (this.startHandle) this.startHandle.scale({
|
|
23370
|
+
x: 1 / this.instance.getStage().scaleX(),
|
|
23371
|
+
y: 1 / this.instance.getStage().scaleY()
|
|
23372
|
+
});
|
|
23373
|
+
if (this.endHandle) this.endHandle.scale({
|
|
23374
|
+
x: 1 / this.instance.getStage().scaleX(),
|
|
23375
|
+
y: 1 / this.instance.getStage().scaleY()
|
|
23376
|
+
});
|
|
23377
|
+
};
|
|
23378
|
+
this.instance.addEventListener("onZoomChange", this.handleZoomChanges);
|
|
23379
|
+
}
|
|
23380
|
+
if (!this.handleNodeChanges) {
|
|
23381
|
+
this.handleNodeChanges = (nodes) => {
|
|
23382
|
+
if (nodes.length === 1 && nodes[0].instance.getAttrs().nodeType === "line" && nodes[0].instance.points().length === 4) {
|
|
23383
|
+
const lineSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
|
|
23384
|
+
if (!lineSelected) return;
|
|
23385
|
+
this.setupHandles();
|
|
23386
|
+
this.showHandles(lineSelected);
|
|
23387
|
+
} else {
|
|
23388
|
+
this.startHandle?.setAttr("lineId", void 0);
|
|
23389
|
+
this.startHandle?.visible(false);
|
|
23390
|
+
this.endHandle?.setAttr("lineId", void 0);
|
|
23391
|
+
this.endHandle?.visible(false);
|
|
23392
|
+
}
|
|
23393
|
+
};
|
|
23394
|
+
this.instance.addEventListener("onNodesChange", this.handleNodeChanges);
|
|
23395
|
+
}
|
|
23268
23396
|
return line;
|
|
23269
23397
|
}
|
|
23398
|
+
defineFinalPoint(handle, origin, e) {
|
|
23399
|
+
let pos = {
|
|
23400
|
+
x: 0,
|
|
23401
|
+
y: 0
|
|
23402
|
+
};
|
|
23403
|
+
if (e.evt.shiftKey) {
|
|
23404
|
+
const handlePosition = handle.position();
|
|
23405
|
+
let dx = handlePosition.x - origin.x;
|
|
23406
|
+
let dy = handlePosition.y - origin.y;
|
|
23407
|
+
const angle = Math.atan2(dy, dx);
|
|
23408
|
+
const angleDeg = angle * 180 / Math.PI;
|
|
23409
|
+
const snapped = this.snapper.apply(angleDeg);
|
|
23410
|
+
const dist = Math.hypot(dx, dy);
|
|
23411
|
+
const rad = snapped * Math.PI / 180;
|
|
23412
|
+
dx = Math.cos(rad) * dist;
|
|
23413
|
+
dy = Math.sin(rad) * dist;
|
|
23414
|
+
pos.x = origin.x + dx;
|
|
23415
|
+
pos.y = origin.y + dy;
|
|
23416
|
+
} else pos = handle.position();
|
|
23417
|
+
return pos;
|
|
23418
|
+
}
|
|
23419
|
+
setupHandles() {
|
|
23420
|
+
if (!this.startHandle) {
|
|
23421
|
+
const startHandle = new Konva.Circle({
|
|
23422
|
+
id: "line-start-handle",
|
|
23423
|
+
radius: 5,
|
|
23424
|
+
fill: "#ffffff",
|
|
23425
|
+
stroke: "#000000",
|
|
23426
|
+
strokeWidth: 1,
|
|
23427
|
+
edgeDistanceDisableOnDrag: true,
|
|
23428
|
+
scaleX: 1 / this.instance.getStage().scaleX(),
|
|
23429
|
+
scaleY: 1 / this.instance.getStage().scaleY(),
|
|
23430
|
+
draggable: true
|
|
23431
|
+
});
|
|
23432
|
+
startHandle.on("pointerover", () => {
|
|
23433
|
+
this.instance.getStage().container().style.cursor = "move";
|
|
23434
|
+
});
|
|
23435
|
+
startHandle.on("pointerout", () => {
|
|
23436
|
+
this.instance.getStage().container().style.cursor = "default";
|
|
23437
|
+
});
|
|
23438
|
+
startHandle.on("dragstart", (e) => {
|
|
23439
|
+
const lineId = e.target.getAttr("lineId");
|
|
23440
|
+
const line = this.instance.getStage().findOne(`#${lineId}`);
|
|
23441
|
+
if (!line) return;
|
|
23442
|
+
if (line.points().length === 4) line.setAttr("eventTarget", true);
|
|
23443
|
+
this.instance.emitEvent("onDrag", e.target);
|
|
23444
|
+
});
|
|
23445
|
+
startHandle.on("dragmove", (e) => {
|
|
23446
|
+
const draggedTarget = e.target;
|
|
23447
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
23448
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
23449
|
+
if (!draggedLine) return;
|
|
23450
|
+
const pos = this.defineFinalPoint(startHandle, {
|
|
23451
|
+
x: draggedLine.x() + draggedLine.points()[2],
|
|
23452
|
+
y: draggedLine.y() + draggedLine.points()[3]
|
|
23453
|
+
}, e);
|
|
23454
|
+
const [, , x2, y2] = draggedLine.points();
|
|
23455
|
+
startHandle.position(pos);
|
|
23456
|
+
draggedLine.points([
|
|
23457
|
+
pos.x - draggedLine.x(),
|
|
23458
|
+
pos.y - draggedLine.y(),
|
|
23459
|
+
x2,
|
|
23460
|
+
y2
|
|
23461
|
+
]);
|
|
23462
|
+
});
|
|
23463
|
+
startHandle.on("dragend", (e) => {
|
|
23464
|
+
const draggedTarget = e.target;
|
|
23465
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
23466
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
23467
|
+
if (!draggedLine) return;
|
|
23468
|
+
const { x, y } = startHandle.position();
|
|
23469
|
+
const [, , x2, y2] = draggedLine.points();
|
|
23470
|
+
draggedLine.points([
|
|
23471
|
+
x - draggedLine.x(),
|
|
23472
|
+
y - draggedLine.y(),
|
|
23473
|
+
x2,
|
|
23474
|
+
y2
|
|
23475
|
+
]);
|
|
23476
|
+
this.instance.updateNode(this.serialize(draggedLine));
|
|
23477
|
+
this.instance.emitEvent("onDrag", null);
|
|
23478
|
+
});
|
|
23479
|
+
this.startHandle = startHandle;
|
|
23480
|
+
this.startHandle.visible(false);
|
|
23481
|
+
this.instance.getSelectionLayer()?.add(this.startHandle);
|
|
23482
|
+
}
|
|
23483
|
+
if (!this.endHandle) {
|
|
23484
|
+
const endHandle = new Konva.Circle({
|
|
23485
|
+
id: "line-end-handle",
|
|
23486
|
+
radius: 5,
|
|
23487
|
+
fill: "#ffffff",
|
|
23488
|
+
stroke: "#000000",
|
|
23489
|
+
strokeWidth: 1,
|
|
23490
|
+
edgeDistanceDisableOnDrag: true,
|
|
23491
|
+
scaleX: 1 / this.instance.getStage().scaleX(),
|
|
23492
|
+
scaleY: 1 / this.instance.getStage().scaleY(),
|
|
23493
|
+
draggable: true
|
|
23494
|
+
});
|
|
23495
|
+
endHandle.on("pointerover", () => {
|
|
23496
|
+
this.instance.getStage().container().style.cursor = "move";
|
|
23497
|
+
});
|
|
23498
|
+
endHandle.on("pointerout", () => {
|
|
23499
|
+
this.instance.getStage().container().style.cursor = "default";
|
|
23500
|
+
});
|
|
23501
|
+
endHandle.on("dragstart", (e) => {
|
|
23502
|
+
const lineId = e.target.getAttr("lineId");
|
|
23503
|
+
const line = this.instance.getStage().findOne(`#${lineId}`);
|
|
23504
|
+
if (!line) return;
|
|
23505
|
+
if (line.points().length === 4) line.setAttr("eventTarget", true);
|
|
23506
|
+
this.instance.emitEvent("onDrag", e.target);
|
|
23507
|
+
});
|
|
23508
|
+
endHandle.on("dragmove", (e) => {
|
|
23509
|
+
const draggedTarget = e.target;
|
|
23510
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
23511
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
23512
|
+
if (!draggedLine) return;
|
|
23513
|
+
const pos = this.defineFinalPoint(endHandle, {
|
|
23514
|
+
x: draggedLine.x() + draggedLine.points()[0],
|
|
23515
|
+
y: draggedLine.y() + draggedLine.points()[1]
|
|
23516
|
+
}, e);
|
|
23517
|
+
const [x1, y1] = draggedLine.points();
|
|
23518
|
+
endHandle.position(pos);
|
|
23519
|
+
draggedLine.points([
|
|
23520
|
+
x1,
|
|
23521
|
+
y1,
|
|
23522
|
+
pos.x - draggedLine.x(),
|
|
23523
|
+
pos.y - draggedLine.y()
|
|
23524
|
+
]);
|
|
23525
|
+
});
|
|
23526
|
+
endHandle.on("dragend", (e) => {
|
|
23527
|
+
const draggedTarget = e.target;
|
|
23528
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
23529
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
23530
|
+
if (!draggedLine) return;
|
|
23531
|
+
const { x, y } = endHandle.position();
|
|
23532
|
+
const [x1, y1] = draggedLine.points();
|
|
23533
|
+
draggedLine.points([
|
|
23534
|
+
x1,
|
|
23535
|
+
y1,
|
|
23536
|
+
x - draggedLine.x(),
|
|
23537
|
+
y - draggedLine.y()
|
|
23538
|
+
]);
|
|
23539
|
+
this.instance.updateNode(this.serialize(draggedLine));
|
|
23540
|
+
this.instance.emitEvent("onDrag", null);
|
|
23541
|
+
});
|
|
23542
|
+
this.endHandle = endHandle;
|
|
23543
|
+
this.endHandle.visible(false);
|
|
23544
|
+
this.instance.getSelectionLayer()?.add(this.endHandle);
|
|
23545
|
+
}
|
|
23546
|
+
}
|
|
23547
|
+
showHandles(line) {
|
|
23548
|
+
const [x1, y1, x2, y2] = line.points();
|
|
23549
|
+
if (this.startHandle === null || this.endHandle === null) return;
|
|
23550
|
+
const lineId = line.getAttrs().id;
|
|
23551
|
+
this.startHandle.setAttr("lineId", lineId);
|
|
23552
|
+
this.startHandle.setAttr("targetNode", lineId);
|
|
23553
|
+
this.startHandle.x(line.x() + x1);
|
|
23554
|
+
this.startHandle.y(line.y() + y1);
|
|
23555
|
+
this.startHandle.visible(true);
|
|
23556
|
+
this.startHandle.moveToTop();
|
|
23557
|
+
this.endHandle.setAttr("lineId", lineId);
|
|
23558
|
+
this.endHandle.setAttr("targetNode", lineId);
|
|
23559
|
+
this.endHandle.x(line.x() + x2);
|
|
23560
|
+
this.endHandle.y(line.y() + y2);
|
|
23561
|
+
this.endHandle.visible(true);
|
|
23562
|
+
this.endHandle.moveToTop();
|
|
23563
|
+
}
|
|
23270
23564
|
onUpdate(nodeInstance, nextProps) {
|
|
23271
23565
|
nodeInstance.setAttrs({ ...nextProps });
|
|
23272
23566
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -25231,7 +25525,7 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
25231
25525
|
const p1 = centerline[i + 1];
|
|
25232
25526
|
const dx = p1.x - p0.x;
|
|
25233
25527
|
const dy = p1.y - p0.y;
|
|
25234
|
-
const segLen = Math.
|
|
25528
|
+
const segLen = Math.hypot(dx, dy) || 1;
|
|
25235
25529
|
const nx = -dy / segLen;
|
|
25236
25530
|
const ny = dx / segLen;
|
|
25237
25531
|
const w0 = baseW * p0.pressure / 2;
|
|
@@ -26928,7 +27222,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
26928
27222
|
this.enabled = false;
|
|
26929
27223
|
}
|
|
26930
27224
|
getDistance(p1, p2) {
|
|
26931
|
-
return Math.
|
|
27225
|
+
return Math.hypot(p2.x - p1.x, p2.y - p1.y);
|
|
26932
27226
|
}
|
|
26933
27227
|
getCenter(p1, p2) {
|
|
26934
27228
|
return {
|
|
@@ -31809,7 +32103,11 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
|
|
|
31809
32103
|
if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) {
|
|
31810
32104
|
if (nodesSelectionPlugin) nodeParent = this.instance.getNodeContainer(nodesSelectionPlugin.getTransformer().nodes()[0]);
|
|
31811
32105
|
}
|
|
31812
|
-
if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1)
|
|
32106
|
+
if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) if (node.getAttrs().targetNode) {
|
|
32107
|
+
const targetNodeId = node.getAttrs().targetNode;
|
|
32108
|
+
const targetNode = this.instance.getStage().findOne(`#${targetNodeId}`);
|
|
32109
|
+
if (targetNode) nodeParent = this.instance.getNodeContainer(targetNode);
|
|
32110
|
+
} else nodeParent = this.instance.getNodeContainer(node);
|
|
31813
32111
|
return nodeParent;
|
|
31814
32112
|
}
|
|
31815
32113
|
cleanupGuidelines() {
|
|
@@ -32097,6 +32395,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
|
|
|
32097
32395
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
32098
32396
|
if (!this.enabled) return;
|
|
32099
32397
|
if (!utilityLayer) return;
|
|
32398
|
+
if (e.target.getAttr("edgeDistanceDisableOnDrag")) return;
|
|
32100
32399
|
const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e, true);
|
|
32101
32400
|
if (typeof node === "undefined") return;
|
|
32102
32401
|
const nodeParent = this.getSelectionParentNode();
|
|
@@ -32800,5 +33099,5 @@ if (typeof window === "undefined") {
|
|
|
32800
33099
|
}
|
|
32801
33100
|
|
|
32802
33101
|
//#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 };
|
|
33102
|
+
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
33103
|
//# sourceMappingURL=sdk.node.js.map
|