@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.d.ts +120 -6
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +617 -32
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.node.d.ts +43 -5
- package/dist/sdk.node.d.ts.map +1 -1
- package/dist/sdk.node.js +338 -32
- package/dist/sdk.node.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.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;
|
|
@@ -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.
|
|
19514
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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;
|
|
@@ -21137,15 +21149,75 @@ var WeaveEllipseNode = class extends WeaveNode {
|
|
|
21137
21149
|
//#endregion
|
|
21138
21150
|
//#region src/nodes/line/constants.ts
|
|
21139
21151
|
const WEAVE_LINE_NODE_TYPE = "line";
|
|
21152
|
+
const WEAVE_LINE_NODE_DEFAULT_CONFIG = { snapAngles: {
|
|
21153
|
+
angles: [
|
|
21154
|
+
0,
|
|
21155
|
+
45,
|
|
21156
|
+
90,
|
|
21157
|
+
135,
|
|
21158
|
+
180,
|
|
21159
|
+
225,
|
|
21160
|
+
270,
|
|
21161
|
+
315
|
|
21162
|
+
],
|
|
21163
|
+
activateThreshold: 5,
|
|
21164
|
+
releaseThreshold: 10
|
|
21165
|
+
} };
|
|
21166
|
+
|
|
21167
|
+
//#endregion
|
|
21168
|
+
//#region src/utils/greedy-snapper.ts
|
|
21169
|
+
var GreedySnapper = class {
|
|
21170
|
+
snappedAngle = null;
|
|
21171
|
+
constructor(config) {
|
|
21172
|
+
this.config = config;
|
|
21173
|
+
}
|
|
21174
|
+
reset() {
|
|
21175
|
+
this.snappedAngle = null;
|
|
21176
|
+
}
|
|
21177
|
+
apply(angleDeg) {
|
|
21178
|
+
const { snapAngles, activateThreshold, releaseThreshold } = this.config;
|
|
21179
|
+
const normalized = (angleDeg % 360 + 360) % 360;
|
|
21180
|
+
if (this.snappedAngle !== null) {
|
|
21181
|
+
const diff = Math.abs(normalized - this.snappedAngle);
|
|
21182
|
+
if (diff > releaseThreshold) {
|
|
21183
|
+
this.snappedAngle = null;
|
|
21184
|
+
return normalized;
|
|
21185
|
+
}
|
|
21186
|
+
return this.snappedAngle;
|
|
21187
|
+
}
|
|
21188
|
+
let closest = snapAngles[0];
|
|
21189
|
+
let minDiff = Math.abs(normalized - closest);
|
|
21190
|
+
for (const a of snapAngles) {
|
|
21191
|
+
const d = Math.abs(normalized - a);
|
|
21192
|
+
if (d < minDiff) {
|
|
21193
|
+
minDiff = d;
|
|
21194
|
+
closest = a;
|
|
21195
|
+
}
|
|
21196
|
+
}
|
|
21197
|
+
if (minDiff <= activateThreshold) {
|
|
21198
|
+
this.snappedAngle = closest;
|
|
21199
|
+
return closest;
|
|
21200
|
+
}
|
|
21201
|
+
return normalized;
|
|
21202
|
+
}
|
|
21203
|
+
};
|
|
21140
21204
|
|
|
21141
21205
|
//#endregion
|
|
21142
21206
|
//#region src/nodes/line/line.ts
|
|
21143
21207
|
var WeaveLineNode = class extends WeaveNode {
|
|
21208
|
+
startHandle = null;
|
|
21209
|
+
endHandle = null;
|
|
21144
21210
|
nodeType = WEAVE_LINE_NODE_TYPE;
|
|
21145
21211
|
constructor(params) {
|
|
21146
21212
|
super();
|
|
21147
|
-
|
|
21148
|
-
this.
|
|
21213
|
+
this.config = mergeExceptArrays(WEAVE_LINE_NODE_DEFAULT_CONFIG, params?.config ?? {});
|
|
21214
|
+
this.handleNodeChanges = null;
|
|
21215
|
+
this.handleZoomChanges = null;
|
|
21216
|
+
this.snapper = new GreedySnapper({
|
|
21217
|
+
snapAngles: this.config.snapAngles.angles,
|
|
21218
|
+
activateThreshold: this.config.snapAngles.activateThreshold,
|
|
21219
|
+
releaseThreshold: this.config.snapAngles.releaseThreshold
|
|
21220
|
+
});
|
|
21149
21221
|
}
|
|
21150
21222
|
onRender(props) {
|
|
21151
21223
|
const line = new Konva.Line({
|
|
@@ -21156,11 +21228,240 @@ var WeaveLineNode = class extends WeaveNode {
|
|
|
21156
21228
|
this.setupDefaultNodeAugmentation(line);
|
|
21157
21229
|
const defaultTransformerProperties = this.defaultGetTransformerProperties(this.config.transform);
|
|
21158
21230
|
line.getTransformerProperties = function() {
|
|
21159
|
-
return
|
|
21231
|
+
return {
|
|
21232
|
+
...defaultTransformerProperties,
|
|
21233
|
+
ignoreStroke: true,
|
|
21234
|
+
rotateEnabled: this.points().length !== 4,
|
|
21235
|
+
keepRatio: this.points().length !== 4,
|
|
21236
|
+
flipEnabled: this.points().length === 4,
|
|
21237
|
+
shiftBehavior: this.points().length === 4 ? "none" : "default"
|
|
21238
|
+
};
|
|
21239
|
+
};
|
|
21240
|
+
let originalStartHandleVisibility = null;
|
|
21241
|
+
let originalEndHandleVisibility = null;
|
|
21242
|
+
line.on("dragstart", () => {
|
|
21243
|
+
originalStartHandleVisibility = this.startHandle?.visible() ?? false;
|
|
21244
|
+
originalEndHandleVisibility = this.endHandle?.visible() ?? false;
|
|
21245
|
+
this.startHandle?.visible(false);
|
|
21246
|
+
this.endHandle?.visible(false);
|
|
21247
|
+
});
|
|
21248
|
+
line.on("dragend", () => {
|
|
21249
|
+
this.startHandle?.visible(originalStartHandleVisibility);
|
|
21250
|
+
this.endHandle?.visible(originalEndHandleVisibility);
|
|
21251
|
+
originalStartHandleVisibility = null;
|
|
21252
|
+
originalEndHandleVisibility = null;
|
|
21253
|
+
});
|
|
21254
|
+
line.allowedAnchors = function() {
|
|
21255
|
+
if (this.points().length !== 4) return [
|
|
21256
|
+
"top-left",
|
|
21257
|
+
"top-center",
|
|
21258
|
+
"top-right",
|
|
21259
|
+
"middle-right",
|
|
21260
|
+
"middle-left",
|
|
21261
|
+
"bottom-left",
|
|
21262
|
+
"bottom-center",
|
|
21263
|
+
"bottom-right"
|
|
21264
|
+
];
|
|
21265
|
+
return [];
|
|
21160
21266
|
};
|
|
21161
21267
|
this.setupDefaultNodeEvents(line);
|
|
21268
|
+
if (!this.handleZoomChanges) {
|
|
21269
|
+
this.handleZoomChanges = () => {
|
|
21270
|
+
if (this.startHandle) this.startHandle.scale({
|
|
21271
|
+
x: 1 / this.instance.getStage().scaleX(),
|
|
21272
|
+
y: 1 / this.instance.getStage().scaleY()
|
|
21273
|
+
});
|
|
21274
|
+
if (this.endHandle) this.endHandle.scale({
|
|
21275
|
+
x: 1 / this.instance.getStage().scaleX(),
|
|
21276
|
+
y: 1 / this.instance.getStage().scaleY()
|
|
21277
|
+
});
|
|
21278
|
+
};
|
|
21279
|
+
this.instance.addEventListener("onZoomChange", this.handleZoomChanges);
|
|
21280
|
+
}
|
|
21281
|
+
if (!this.handleNodeChanges) {
|
|
21282
|
+
this.handleNodeChanges = (nodes) => {
|
|
21283
|
+
if (nodes.length === 1 && nodes[0].instance.getAttrs().nodeType === "line" && nodes[0].instance.points().length === 4) {
|
|
21284
|
+
const lineSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
|
|
21285
|
+
if (!lineSelected) return;
|
|
21286
|
+
this.setupHandles();
|
|
21287
|
+
this.showHandles(lineSelected);
|
|
21288
|
+
} else {
|
|
21289
|
+
this.startHandle?.setAttr("lineId", void 0);
|
|
21290
|
+
this.startHandle?.visible(false);
|
|
21291
|
+
this.endHandle?.setAttr("lineId", void 0);
|
|
21292
|
+
this.endHandle?.visible(false);
|
|
21293
|
+
}
|
|
21294
|
+
};
|
|
21295
|
+
this.instance.addEventListener("onNodesChange", this.handleNodeChanges);
|
|
21296
|
+
}
|
|
21162
21297
|
return line;
|
|
21163
21298
|
}
|
|
21299
|
+
defineFinalPoint(handle, origin, e) {
|
|
21300
|
+
let pos = {
|
|
21301
|
+
x: 0,
|
|
21302
|
+
y: 0
|
|
21303
|
+
};
|
|
21304
|
+
if (e.evt.shiftKey) {
|
|
21305
|
+
const handlePosition = handle.position();
|
|
21306
|
+
let dx = handlePosition.x - origin.x;
|
|
21307
|
+
let dy = handlePosition.y - origin.y;
|
|
21308
|
+
const angle = Math.atan2(dy, dx);
|
|
21309
|
+
const angleDeg = angle * 180 / Math.PI;
|
|
21310
|
+
const snapped = this.snapper.apply(angleDeg);
|
|
21311
|
+
const dist = Math.hypot(dx, dy);
|
|
21312
|
+
const rad = snapped * Math.PI / 180;
|
|
21313
|
+
dx = Math.cos(rad) * dist;
|
|
21314
|
+
dy = Math.sin(rad) * dist;
|
|
21315
|
+
pos.x = origin.x + dx;
|
|
21316
|
+
pos.y = origin.y + dy;
|
|
21317
|
+
} else pos = handle.position();
|
|
21318
|
+
return pos;
|
|
21319
|
+
}
|
|
21320
|
+
setupHandles() {
|
|
21321
|
+
if (!this.startHandle) {
|
|
21322
|
+
const startHandle = new Konva.Circle({
|
|
21323
|
+
id: "line-start-handle",
|
|
21324
|
+
radius: 5,
|
|
21325
|
+
fill: "#ffffff",
|
|
21326
|
+
stroke: "#000000",
|
|
21327
|
+
strokeWidth: 1,
|
|
21328
|
+
edgeDistanceDisableOnDrag: true,
|
|
21329
|
+
scaleX: 1 / this.instance.getStage().scaleX(),
|
|
21330
|
+
scaleY: 1 / this.instance.getStage().scaleY(),
|
|
21331
|
+
draggable: true
|
|
21332
|
+
});
|
|
21333
|
+
startHandle.on("pointerover", () => {
|
|
21334
|
+
this.instance.getStage().container().style.cursor = "move";
|
|
21335
|
+
});
|
|
21336
|
+
startHandle.on("pointerout", () => {
|
|
21337
|
+
this.instance.getStage().container().style.cursor = "default";
|
|
21338
|
+
});
|
|
21339
|
+
startHandle.on("dragstart", (e) => {
|
|
21340
|
+
const lineId = e.target.getAttr("lineId");
|
|
21341
|
+
const line = this.instance.getStage().findOne(`#${lineId}`);
|
|
21342
|
+
if (!line) return;
|
|
21343
|
+
if (line.points().length === 4) line.setAttr("eventTarget", true);
|
|
21344
|
+
this.instance.emitEvent("onDrag", e.target);
|
|
21345
|
+
});
|
|
21346
|
+
startHandle.on("dragmove", (e) => {
|
|
21347
|
+
const draggedTarget = e.target;
|
|
21348
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
21349
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
21350
|
+
if (!draggedLine) return;
|
|
21351
|
+
const pos = this.defineFinalPoint(startHandle, {
|
|
21352
|
+
x: draggedLine.x() + draggedLine.points()[2],
|
|
21353
|
+
y: draggedLine.y() + draggedLine.points()[3]
|
|
21354
|
+
}, e);
|
|
21355
|
+
const [, , x2, y2] = draggedLine.points();
|
|
21356
|
+
startHandle.position(pos);
|
|
21357
|
+
draggedLine.points([
|
|
21358
|
+
pos.x - draggedLine.x(),
|
|
21359
|
+
pos.y - draggedLine.y(),
|
|
21360
|
+
x2,
|
|
21361
|
+
y2
|
|
21362
|
+
]);
|
|
21363
|
+
});
|
|
21364
|
+
startHandle.on("dragend", (e) => {
|
|
21365
|
+
const draggedTarget = e.target;
|
|
21366
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
21367
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
21368
|
+
if (!draggedLine) return;
|
|
21369
|
+
const { x, y } = startHandle.position();
|
|
21370
|
+
const [, , x2, y2] = draggedLine.points();
|
|
21371
|
+
draggedLine.points([
|
|
21372
|
+
x - draggedLine.x(),
|
|
21373
|
+
y - draggedLine.y(),
|
|
21374
|
+
x2,
|
|
21375
|
+
y2
|
|
21376
|
+
]);
|
|
21377
|
+
this.instance.updateNode(this.serialize(draggedLine));
|
|
21378
|
+
this.instance.emitEvent("onDrag", null);
|
|
21379
|
+
});
|
|
21380
|
+
this.startHandle = startHandle;
|
|
21381
|
+
this.startHandle.visible(false);
|
|
21382
|
+
this.instance.getSelectionLayer()?.add(this.startHandle);
|
|
21383
|
+
}
|
|
21384
|
+
if (!this.endHandle) {
|
|
21385
|
+
const endHandle = new Konva.Circle({
|
|
21386
|
+
id: "line-end-handle",
|
|
21387
|
+
radius: 5,
|
|
21388
|
+
fill: "#ffffff",
|
|
21389
|
+
stroke: "#000000",
|
|
21390
|
+
strokeWidth: 1,
|
|
21391
|
+
edgeDistanceDisableOnDrag: true,
|
|
21392
|
+
scaleX: 1 / this.instance.getStage().scaleX(),
|
|
21393
|
+
scaleY: 1 / this.instance.getStage().scaleY(),
|
|
21394
|
+
draggable: true
|
|
21395
|
+
});
|
|
21396
|
+
endHandle.on("pointerover", () => {
|
|
21397
|
+
this.instance.getStage().container().style.cursor = "move";
|
|
21398
|
+
});
|
|
21399
|
+
endHandle.on("pointerout", () => {
|
|
21400
|
+
this.instance.getStage().container().style.cursor = "default";
|
|
21401
|
+
});
|
|
21402
|
+
endHandle.on("dragstart", (e) => {
|
|
21403
|
+
const lineId = e.target.getAttr("lineId");
|
|
21404
|
+
const line = this.instance.getStage().findOne(`#${lineId}`);
|
|
21405
|
+
if (!line) return;
|
|
21406
|
+
if (line.points().length === 4) line.setAttr("eventTarget", true);
|
|
21407
|
+
this.instance.emitEvent("onDrag", e.target);
|
|
21408
|
+
});
|
|
21409
|
+
endHandle.on("dragmove", (e) => {
|
|
21410
|
+
const draggedTarget = e.target;
|
|
21411
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
21412
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
21413
|
+
if (!draggedLine) return;
|
|
21414
|
+
const pos = this.defineFinalPoint(endHandle, {
|
|
21415
|
+
x: draggedLine.x() + draggedLine.points()[0],
|
|
21416
|
+
y: draggedLine.y() + draggedLine.points()[1]
|
|
21417
|
+
}, e);
|
|
21418
|
+
const [x1, y1] = draggedLine.points();
|
|
21419
|
+
endHandle.position(pos);
|
|
21420
|
+
draggedLine.points([
|
|
21421
|
+
x1,
|
|
21422
|
+
y1,
|
|
21423
|
+
pos.x - draggedLine.x(),
|
|
21424
|
+
pos.y - draggedLine.y()
|
|
21425
|
+
]);
|
|
21426
|
+
});
|
|
21427
|
+
endHandle.on("dragend", (e) => {
|
|
21428
|
+
const draggedTarget = e.target;
|
|
21429
|
+
const lineId = draggedTarget.getAttr("lineId");
|
|
21430
|
+
const draggedLine = this.instance.getStage().findOne(`#${lineId}`);
|
|
21431
|
+
if (!draggedLine) return;
|
|
21432
|
+
const { x, y } = endHandle.position();
|
|
21433
|
+
const [x1, y1] = draggedLine.points();
|
|
21434
|
+
draggedLine.points([
|
|
21435
|
+
x1,
|
|
21436
|
+
y1,
|
|
21437
|
+
x - draggedLine.x(),
|
|
21438
|
+
y - draggedLine.y()
|
|
21439
|
+
]);
|
|
21440
|
+
this.instance.updateNode(this.serialize(draggedLine));
|
|
21441
|
+
this.instance.emitEvent("onDrag", null);
|
|
21442
|
+
});
|
|
21443
|
+
this.endHandle = endHandle;
|
|
21444
|
+
this.endHandle.visible(false);
|
|
21445
|
+
this.instance.getSelectionLayer()?.add(this.endHandle);
|
|
21446
|
+
}
|
|
21447
|
+
}
|
|
21448
|
+
showHandles(line) {
|
|
21449
|
+
const [x1, y1, x2, y2] = line.points();
|
|
21450
|
+
if (this.startHandle === null || this.endHandle === null) return;
|
|
21451
|
+
const lineId = line.getAttrs().id;
|
|
21452
|
+
this.startHandle.setAttr("lineId", lineId);
|
|
21453
|
+
this.startHandle.setAttr("targetNode", lineId);
|
|
21454
|
+
this.startHandle.x(line.x() + x1);
|
|
21455
|
+
this.startHandle.y(line.y() + y1);
|
|
21456
|
+
this.startHandle.visible(true);
|
|
21457
|
+
this.startHandle.moveToTop();
|
|
21458
|
+
this.endHandle.setAttr("lineId", lineId);
|
|
21459
|
+
this.endHandle.setAttr("targetNode", lineId);
|
|
21460
|
+
this.endHandle.x(line.x() + x2);
|
|
21461
|
+
this.endHandle.y(line.y() + y2);
|
|
21462
|
+
this.endHandle.visible(true);
|
|
21463
|
+
this.endHandle.moveToTop();
|
|
21464
|
+
}
|
|
21164
21465
|
onUpdate(nodeInstance, nextProps) {
|
|
21165
21466
|
nodeInstance.setAttrs({ ...nextProps });
|
|
21166
21467
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -23125,7 +23426,7 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
23125
23426
|
const p1 = centerline[i + 1];
|
|
23126
23427
|
const dx = p1.x - p0.x;
|
|
23127
23428
|
const dy = p1.y - p0.y;
|
|
23128
|
-
const segLen = Math.
|
|
23429
|
+
const segLen = Math.hypot(dx, dy) || 1;
|
|
23129
23430
|
const nx = -dy / segLen;
|
|
23130
23431
|
const ny = dx / segLen;
|
|
23131
23432
|
const w0 = baseW * p0.pressure / 2;
|
|
@@ -24822,7 +25123,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
24822
25123
|
this.enabled = false;
|
|
24823
25124
|
}
|
|
24824
25125
|
getDistance(p1, p2) {
|
|
24825
|
-
return Math.
|
|
25126
|
+
return Math.hypot(p2.x - p1.x, p2.y - p1.y);
|
|
24826
25127
|
}
|
|
24827
25128
|
getCenter(p1, p2) {
|
|
24828
25129
|
return {
|
|
@@ -29708,7 +30009,11 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
|
|
|
29708
30009
|
if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length > 1) {
|
|
29709
30010
|
if (nodesSelectionPlugin) nodeParent = this.instance.getNodeContainer(nodesSelectionPlugin.getTransformer().nodes()[0]);
|
|
29710
30011
|
}
|
|
29711
|
-
if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1)
|
|
30012
|
+
if (nodesSelectionPlugin && nodesSelectionPlugin.getTransformer().nodes().length === 1) if (node.getAttrs().targetNode) {
|
|
30013
|
+
const targetNodeId = node.getAttrs().targetNode;
|
|
30014
|
+
const targetNode = this.instance.getStage().findOne(`#${targetNodeId}`);
|
|
30015
|
+
if (targetNode) nodeParent = this.instance.getNodeContainer(targetNode);
|
|
30016
|
+
} else nodeParent = this.instance.getNodeContainer(node);
|
|
29712
30017
|
return nodeParent;
|
|
29713
30018
|
}
|
|
29714
30019
|
cleanupGuidelines() {
|
|
@@ -29996,6 +30301,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
|
|
|
29996
30301
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
29997
30302
|
if (!this.enabled) return;
|
|
29998
30303
|
if (!utilityLayer) return;
|
|
30304
|
+
if (e.target.getAttr("edgeDistanceDisableOnDrag")) return;
|
|
29999
30305
|
const { targetNode: node, skipNodes } = getTargetAndSkipNodes(this.instance, e, true);
|
|
30000
30306
|
if (typeof node === "undefined") return;
|
|
30001
30307
|
const nodeParent = this.getSelectionParentNode();
|
|
@@ -30911,8 +31217,8 @@ var WeaveGroupsManager = class {
|
|
|
30911
31217
|
}
|
|
30912
31218
|
extractTransformFromMatrix(m) {
|
|
30913
31219
|
const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
|
|
30914
|
-
const scaleX = Math.
|
|
30915
|
-
const scaleY = Math.
|
|
31220
|
+
const scaleX = Math.hypot(a, b);
|
|
31221
|
+
const scaleY = Math.hypot(c, d);
|
|
30916
31222
|
const rotation = Math.atan2(b, a) * (180 / Math.PI);
|
|
30917
31223
|
return {
|
|
30918
31224
|
x: e,
|
|
@@ -31738,7 +32044,7 @@ var WeaveRegisterManager = class {
|
|
|
31738
32044
|
|
|
31739
32045
|
//#endregion
|
|
31740
32046
|
//#region package.json
|
|
31741
|
-
var version = "2.
|
|
32047
|
+
var version = "2.5.0";
|
|
31742
32048
|
|
|
31743
32049
|
//#endregion
|
|
31744
32050
|
//#region src/managers/setup.ts
|
|
@@ -32788,11 +33094,290 @@ var Weave = class {
|
|
|
32788
33094
|
}
|
|
32789
33095
|
};
|
|
32790
33096
|
|
|
33097
|
+
//#endregion
|
|
33098
|
+
//#region src/actions/line-tool/constants.ts
|
|
33099
|
+
const LINE_TOOL_ACTION_NAME = "lineTool";
|
|
33100
|
+
const LINE_TOOL_STATE = {
|
|
33101
|
+
["IDLE"]: "idle",
|
|
33102
|
+
["ADDING"]: "adding",
|
|
33103
|
+
["DEFINING_SIZE"]: "definingSize",
|
|
33104
|
+
["ADDED"]: "added"
|
|
33105
|
+
};
|
|
33106
|
+
const LINE_TOOL_DEFAULT_CONFIG = { snapAngles: {
|
|
33107
|
+
angles: [
|
|
33108
|
+
0,
|
|
33109
|
+
45,
|
|
33110
|
+
90,
|
|
33111
|
+
135,
|
|
33112
|
+
180,
|
|
33113
|
+
225,
|
|
33114
|
+
270,
|
|
33115
|
+
315
|
|
33116
|
+
],
|
|
33117
|
+
activateThreshold: 5,
|
|
33118
|
+
releaseThreshold: 10
|
|
33119
|
+
} };
|
|
33120
|
+
|
|
33121
|
+
//#endregion
|
|
33122
|
+
//#region src/actions/line-tool/line-tool.ts
|
|
33123
|
+
var WeaveLineToolAction = class extends WeaveAction {
|
|
33124
|
+
initialized = false;
|
|
33125
|
+
initialCursor = null;
|
|
33126
|
+
snappedAngle = null;
|
|
33127
|
+
shiftPressed = false;
|
|
33128
|
+
onPropsChange = void 0;
|
|
33129
|
+
onInit = void 0;
|
|
33130
|
+
constructor(params) {
|
|
33131
|
+
super();
|
|
33132
|
+
this.config = mergeExceptArrays(LINE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
|
|
33133
|
+
this.pointers = new Map();
|
|
33134
|
+
this.initialized = false;
|
|
33135
|
+
this.state = LINE_TOOL_STATE.IDLE;
|
|
33136
|
+
this.lineId = null;
|
|
33137
|
+
this.shiftPressed = false;
|
|
33138
|
+
this.tempLineId = null;
|
|
33139
|
+
this.tempMainLineNode = null;
|
|
33140
|
+
this.tempLineNode = null;
|
|
33141
|
+
this.container = void 0;
|
|
33142
|
+
this.snappedAngle = null;
|
|
33143
|
+
this.measureContainer = void 0;
|
|
33144
|
+
this.clickPoint = null;
|
|
33145
|
+
this.snapper = new GreedySnapper({
|
|
33146
|
+
snapAngles: this.config.snapAngles.angles,
|
|
33147
|
+
activateThreshold: this.config.snapAngles.activateThreshold,
|
|
33148
|
+
releaseThreshold: this.config.snapAngles.releaseThreshold
|
|
33149
|
+
});
|
|
33150
|
+
this.props = this.initProps();
|
|
33151
|
+
}
|
|
33152
|
+
getName() {
|
|
33153
|
+
return LINE_TOOL_ACTION_NAME;
|
|
33154
|
+
}
|
|
33155
|
+
initProps() {
|
|
33156
|
+
return {
|
|
33157
|
+
stroke: "#000000ff",
|
|
33158
|
+
strokeWidth: 1,
|
|
33159
|
+
opacity: 1
|
|
33160
|
+
};
|
|
33161
|
+
}
|
|
33162
|
+
setupEvents() {
|
|
33163
|
+
const stage = this.instance.getStage();
|
|
33164
|
+
window.addEventListener("keydown", (e) => {
|
|
33165
|
+
if (e.code === "Enter" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
33166
|
+
this.cancelAction();
|
|
33167
|
+
return;
|
|
33168
|
+
}
|
|
33169
|
+
if (e.code === "Escape" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
33170
|
+
this.cancelAction();
|
|
33171
|
+
return;
|
|
33172
|
+
}
|
|
33173
|
+
if (e.key === "Shift" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
33174
|
+
this.snappedAngle = null;
|
|
33175
|
+
this.shiftPressed = true;
|
|
33176
|
+
}
|
|
33177
|
+
});
|
|
33178
|
+
window.addEventListener("keyup", (e) => {
|
|
33179
|
+
if (e.key === "Shift" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
33180
|
+
this.snappedAngle = null;
|
|
33181
|
+
this.shiftPressed = false;
|
|
33182
|
+
}
|
|
33183
|
+
});
|
|
33184
|
+
stage.on("pointerdown", (e) => {
|
|
33185
|
+
this.setTapStart(e);
|
|
33186
|
+
this.pointers.set(e.evt.pointerId, {
|
|
33187
|
+
x: e.evt.clientX,
|
|
33188
|
+
y: e.evt.clientY
|
|
33189
|
+
});
|
|
33190
|
+
if (this.pointers.size === 2 && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
33191
|
+
this.state = LINE_TOOL_STATE.ADDING;
|
|
33192
|
+
return;
|
|
33193
|
+
}
|
|
33194
|
+
if (!this.tempMainLineNode && this.state === LINE_TOOL_STATE.ADDING) this.handleAdding();
|
|
33195
|
+
if (this.tempMainLineNode && this.state === LINE_TOOL_STATE.ADDING) this.state = LINE_TOOL_STATE.DEFINING_SIZE;
|
|
33196
|
+
});
|
|
33197
|
+
stage.on("pointermove", () => {
|
|
33198
|
+
if (this.state === LINE_TOOL_STATE.IDLE) return;
|
|
33199
|
+
this.setCursor();
|
|
33200
|
+
if (this.pointers.size === 2 && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
|
|
33201
|
+
this.state = LINE_TOOL_STATE.ADDING;
|
|
33202
|
+
return;
|
|
33203
|
+
}
|
|
33204
|
+
if (this.state === LINE_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
|
|
33205
|
+
});
|
|
33206
|
+
stage.on("pointerup", (e) => {
|
|
33207
|
+
this.pointers.delete(e.evt.pointerId);
|
|
33208
|
+
if (this.state === LINE_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
|
|
33209
|
+
});
|
|
33210
|
+
this.initialized = true;
|
|
33211
|
+
}
|
|
33212
|
+
setState(state) {
|
|
33213
|
+
this.state = state;
|
|
33214
|
+
}
|
|
33215
|
+
addLine() {
|
|
33216
|
+
this.setCursor();
|
|
33217
|
+
this.setFocusStage();
|
|
33218
|
+
this.instance.emitEvent("onAddingLine");
|
|
33219
|
+
this.shiftPressed = false;
|
|
33220
|
+
this.clickPoint = null;
|
|
33221
|
+
this.setState(LINE_TOOL_STATE.ADDING);
|
|
33222
|
+
}
|
|
33223
|
+
handleAdding() {
|
|
33224
|
+
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
33225
|
+
this.clickPoint = mousePoint;
|
|
33226
|
+
this.container = container;
|
|
33227
|
+
this.measureContainer = measureContainer;
|
|
33228
|
+
this.lineId = v4_default();
|
|
33229
|
+
this.tempLineId = v4_default();
|
|
33230
|
+
if (!this.tempLineNode) {
|
|
33231
|
+
this.tempMainLineNode = new Konva.Line({
|
|
33232
|
+
...this.props,
|
|
33233
|
+
id: this.lineId,
|
|
33234
|
+
strokeScaleEnabled: true,
|
|
33235
|
+
x: this.clickPoint?.x ?? 0,
|
|
33236
|
+
y: this.clickPoint?.y ?? 0,
|
|
33237
|
+
points: [0, 0]
|
|
33238
|
+
});
|
|
33239
|
+
this.measureContainer?.add(this.tempMainLineNode);
|
|
33240
|
+
this.tempLineNode = new Konva.Line({
|
|
33241
|
+
...this.props,
|
|
33242
|
+
id: this.tempLineId,
|
|
33243
|
+
x: this.clickPoint?.x ?? 0,
|
|
33244
|
+
y: this.clickPoint?.y ?? 0,
|
|
33245
|
+
strokeScaleEnabled: true,
|
|
33246
|
+
points: [0, 0]
|
|
33247
|
+
});
|
|
33248
|
+
this.measureContainer?.add(this.tempLineNode);
|
|
33249
|
+
this.setState(LINE_TOOL_STATE.DEFINING_SIZE);
|
|
33250
|
+
}
|
|
33251
|
+
}
|
|
33252
|
+
defineFinalPoint() {
|
|
33253
|
+
if (!this.tempLineNode || !this.measureContainer) return {
|
|
33254
|
+
x: 0,
|
|
33255
|
+
y: 0
|
|
33256
|
+
};
|
|
33257
|
+
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
33258
|
+
const pos = {
|
|
33259
|
+
x: 0,
|
|
33260
|
+
y: 0
|
|
33261
|
+
};
|
|
33262
|
+
if (this.shiftPressed) {
|
|
33263
|
+
let dx = mousePoint.x - (this.tempLineNode.x() + this.tempLineNode.points()[0]);
|
|
33264
|
+
let dy = mousePoint.y - (this.tempLineNode.y() + this.tempLineNode.points()[1]);
|
|
33265
|
+
const angle = Math.atan2(dy, dx);
|
|
33266
|
+
const angleDeg = angle * 180 / Math.PI;
|
|
33267
|
+
const snapped = this.snapper.apply(angleDeg);
|
|
33268
|
+
const dist = Math.hypot(dx, dy);
|
|
33269
|
+
const rad = snapped * Math.PI / 180;
|
|
33270
|
+
dx = Math.cos(rad) * dist;
|
|
33271
|
+
dy = Math.sin(rad) * dist;
|
|
33272
|
+
pos.x = this.tempLineNode.points()[0] + dx;
|
|
33273
|
+
pos.y = this.tempLineNode.points()[1] + dy;
|
|
33274
|
+
} else {
|
|
33275
|
+
pos.x = mousePoint.x - this.tempLineNode.x();
|
|
33276
|
+
pos.y = mousePoint.y - this.tempLineNode.y();
|
|
33277
|
+
}
|
|
33278
|
+
return pos;
|
|
33279
|
+
}
|
|
33280
|
+
handleSettingSize() {
|
|
33281
|
+
if (this.lineId && this.tempLineNode && this.tempMainLineNode && this.measureContainer) {
|
|
33282
|
+
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
33283
|
+
const pos = this.defineFinalPoint();
|
|
33284
|
+
const newPoints = [
|
|
33285
|
+
...this.tempMainLineNode.points(),
|
|
33286
|
+
pos.x,
|
|
33287
|
+
pos.y
|
|
33288
|
+
];
|
|
33289
|
+
this.tempMainLineNode.setAttrs({
|
|
33290
|
+
...this.props,
|
|
33291
|
+
points: newPoints
|
|
33292
|
+
});
|
|
33293
|
+
this.tempLineNode.setAttrs({
|
|
33294
|
+
...this.props,
|
|
33295
|
+
x: mousePoint.x,
|
|
33296
|
+
y: mousePoint.y,
|
|
33297
|
+
points: [0, 0]
|
|
33298
|
+
});
|
|
33299
|
+
this.cancelAction();
|
|
33300
|
+
}
|
|
33301
|
+
}
|
|
33302
|
+
handleMovement() {
|
|
33303
|
+
if (this.state !== LINE_TOOL_STATE.DEFINING_SIZE) return;
|
|
33304
|
+
if (this.tempLineNode && this.measureContainer) {
|
|
33305
|
+
const pos = this.defineFinalPoint();
|
|
33306
|
+
this.tempLineNode.setAttrs({
|
|
33307
|
+
...this.props,
|
|
33308
|
+
points: [
|
|
33309
|
+
this.tempLineNode.points()[0],
|
|
33310
|
+
this.tempLineNode.points()[1],
|
|
33311
|
+
pos.x,
|
|
33312
|
+
pos.y
|
|
33313
|
+
]
|
|
33314
|
+
});
|
|
33315
|
+
}
|
|
33316
|
+
}
|
|
33317
|
+
trigger(cancelAction) {
|
|
33318
|
+
if (!this.instance) throw new Error("Instance not defined");
|
|
33319
|
+
if (!this.initialized) this.setupEvents();
|
|
33320
|
+
const stage = this.instance.getStage();
|
|
33321
|
+
stage.container().tabIndex = 1;
|
|
33322
|
+
stage.container().focus();
|
|
33323
|
+
this.cancelAction = cancelAction;
|
|
33324
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
33325
|
+
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
33326
|
+
this.props = this.initProps();
|
|
33327
|
+
this.addLine();
|
|
33328
|
+
}
|
|
33329
|
+
cleanup() {
|
|
33330
|
+
const stage = this.instance.getStage();
|
|
33331
|
+
this.tempLineNode?.destroy();
|
|
33332
|
+
if (this.lineId && this.tempMainLineNode?.points().length === 4) {
|
|
33333
|
+
const nodeHandler = this.instance.getNodeHandler("line");
|
|
33334
|
+
if (nodeHandler) {
|
|
33335
|
+
const clonedLine = this.tempMainLineNode.clone();
|
|
33336
|
+
nodeHandler.scaleReset(clonedLine);
|
|
33337
|
+
this.tempMainLineNode.destroy();
|
|
33338
|
+
const node = nodeHandler.create(this.lineId, {
|
|
33339
|
+
...this.props,
|
|
33340
|
+
...clonedLine.getAttrs(),
|
|
33341
|
+
hitStrokeWidth: 16
|
|
33342
|
+
});
|
|
33343
|
+
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
33344
|
+
this.instance.emitEvent("onAddedLine");
|
|
33345
|
+
}
|
|
33346
|
+
}
|
|
33347
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
33348
|
+
if (selectionPlugin) {
|
|
33349
|
+
const node = stage.findOne(`#${this.lineId}`);
|
|
33350
|
+
if (node) selectionPlugin.setSelectedNodes([node]);
|
|
33351
|
+
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
33352
|
+
}
|
|
33353
|
+
stage.container().style.cursor = "default";
|
|
33354
|
+
this.initialCursor = null;
|
|
33355
|
+
this.lineId = null;
|
|
33356
|
+
this.tempMainLineNode = null;
|
|
33357
|
+
this.tempLineId = null;
|
|
33358
|
+
this.tempLineNode = null;
|
|
33359
|
+
this.container = void 0;
|
|
33360
|
+
this.measureContainer = void 0;
|
|
33361
|
+
this.clickPoint = null;
|
|
33362
|
+
this.setState(LINE_TOOL_STATE.IDLE);
|
|
33363
|
+
}
|
|
33364
|
+
setCursor() {
|
|
33365
|
+
const stage = this.instance.getStage();
|
|
33366
|
+
stage.container().style.cursor = "crosshair";
|
|
33367
|
+
}
|
|
33368
|
+
setFocusStage() {
|
|
33369
|
+
const stage = this.instance.getStage();
|
|
33370
|
+
stage.container().tabIndex = 1;
|
|
33371
|
+
stage.container().blur();
|
|
33372
|
+
stage.container().focus();
|
|
33373
|
+
}
|
|
33374
|
+
};
|
|
33375
|
+
|
|
32791
33376
|
//#endregion
|
|
32792
33377
|
//#region src/index.ts
|
|
32793
33378
|
window._weave_isServerSide = false;
|
|
32794
33379
|
window._weave_serverSideBackend = void 0;
|
|
32795
33380
|
|
|
32796
33381
|
//#endregion
|
|
32797
|
-
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 };
|
|
33382
|
+
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, LINE_TOOL_ACTION_NAME, LINE_TOOL_DEFAULT_CONFIG, LINE_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, WeaveLineToolAction, 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 };
|
|
32798
33383
|
//# sourceMappingURL=sdk.js.map
|