@inditextech/weave-sdk 0.73.1 → 0.74.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.cjs +313 -88
- package/dist/sdk.d.cts +192 -138
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +192 -138
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +310 -89
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -18321,6 +18321,14 @@ function isIOS() {
|
|
|
18321
18321
|
return /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
18322
18322
|
}
|
|
18323
18323
|
const isServer = () => typeof window === "undefined";
|
|
18324
|
+
const getPositionRelativeToContainerOnPosition = (instance) => {
|
|
18325
|
+
let position = instance.getStage().getRelativePointerPosition();
|
|
18326
|
+
if (!position) return position;
|
|
18327
|
+
const container = containerOverCursor(instance, [], position);
|
|
18328
|
+
position = container?.getRelativePointerPosition();
|
|
18329
|
+
if (!position) return position;
|
|
18330
|
+
return position;
|
|
18331
|
+
};
|
|
18324
18332
|
|
|
18325
18333
|
//#endregion
|
|
18326
18334
|
//#region src/actions/selection-tool/constants.ts
|
|
@@ -18951,6 +18959,14 @@ const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
|
|
|
18951
18959
|
const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
|
|
18952
18960
|
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
18953
18961
|
|
|
18962
|
+
//#endregion
|
|
18963
|
+
//#region src/plugins/stage-panning/constants.ts
|
|
18964
|
+
const WEAVE_STAGE_PANNING_KEY = "stagePanning";
|
|
18965
|
+
const WEAVE_STAGE_PANNING_DEFAULT_CONFIG = {
|
|
18966
|
+
edgePanOffset: 50,
|
|
18967
|
+
edgePanSpeed: 10
|
|
18968
|
+
};
|
|
18969
|
+
|
|
18954
18970
|
//#endregion
|
|
18955
18971
|
//#region src/plugins/nodes-selection/nodes-selection.ts
|
|
18956
18972
|
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
@@ -19119,11 +19135,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19119
19135
|
return;
|
|
19120
19136
|
}
|
|
19121
19137
|
e.cancelBubble = true;
|
|
19122
|
-
const selectedNodes = tr.nodes();
|
|
19123
|
-
for (let i = 0; i < selectedNodes.length; i++) {
|
|
19124
|
-
const node = selectedNodes[i];
|
|
19125
|
-
node.updatePosition(node.getAbsolutePosition());
|
|
19126
|
-
}
|
|
19127
19138
|
tr.forceUpdate();
|
|
19128
19139
|
});
|
|
19129
19140
|
const handleDragMove = (e) => {
|
|
@@ -19131,6 +19142,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19131
19142
|
x: e.target.x(),
|
|
19132
19143
|
y: e.target.y()
|
|
19133
19144
|
};
|
|
19145
|
+
e.cancelBubble = true;
|
|
19134
19146
|
if (initialPos) {
|
|
19135
19147
|
const moved = this.checkMovedDrag(initialPos, actualPos);
|
|
19136
19148
|
if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
@@ -19142,7 +19154,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19142
19154
|
return;
|
|
19143
19155
|
}
|
|
19144
19156
|
this.didMove = true;
|
|
19145
|
-
e.cancelBubble = true;
|
|
19146
19157
|
const selectedNodes = tr.nodes();
|
|
19147
19158
|
let selectionContainsFrames = false;
|
|
19148
19159
|
for (let i = 0; i < selectedNodes.length; i++) {
|
|
@@ -19161,6 +19172,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19161
19172
|
tr.on("dragend", (e) => {
|
|
19162
19173
|
if (!this.didMove) return;
|
|
19163
19174
|
e.cancelBubble = true;
|
|
19175
|
+
this.instance.getCloningManager().cleanupClones();
|
|
19176
|
+
this.getStagePanningPlugin()?.cleanupEdgeMoveIntervals();
|
|
19164
19177
|
const selectedNodes = tr.nodes();
|
|
19165
19178
|
let selectionContainsFrames = false;
|
|
19166
19179
|
for (let i = 0; i < selectedNodes.length; i++) {
|
|
@@ -19196,6 +19209,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19196
19209
|
const promises = [];
|
|
19197
19210
|
for (let i = 0; i < selectedNodes.length; i++) {
|
|
19198
19211
|
const nodeHandler = this.instance.getNodeHandler(selectedNodes[i].getAttrs().nodeType);
|
|
19212
|
+
selectedNodes[i].setAttrs({ isCloned: void 0 });
|
|
19199
19213
|
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(selectedNodes[i]));
|
|
19200
19214
|
promises.push(nodeUpdatePromise(selectedNodes[i]));
|
|
19201
19215
|
}
|
|
@@ -19407,7 +19421,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19407
19421
|
stage.container().addEventListener("keydown", (e) => {
|
|
19408
19422
|
if (e.code === "Space") this.isSpaceKeyPressed = true;
|
|
19409
19423
|
if ((e.code === "Backspace" || e.code === "Delete") && Object.keys(window.weaveTextEditing).length === 0) {
|
|
19410
|
-
|
|
19424
|
+
Promise.resolve().then(() => {
|
|
19425
|
+
this.removeSelectedNodes();
|
|
19426
|
+
});
|
|
19411
19427
|
return;
|
|
19412
19428
|
}
|
|
19413
19429
|
});
|
|
@@ -19763,6 +19779,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19763
19779
|
const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
|
|
19764
19780
|
return snappingPlugin;
|
|
19765
19781
|
}
|
|
19782
|
+
getStagePanningPlugin() {
|
|
19783
|
+
const stagePanning = this.instance.getPlugin(WEAVE_STAGE_PANNING_KEY);
|
|
19784
|
+
return stagePanning;
|
|
19785
|
+
}
|
|
19766
19786
|
getSelectorConfig() {
|
|
19767
19787
|
return this.config.selection;
|
|
19768
19788
|
}
|
|
@@ -20336,73 +20356,127 @@ var WeaveNode = class {
|
|
|
20336
20356
|
const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
|
|
20337
20357
|
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
|
|
20338
20358
|
});
|
|
20359
|
+
const stage = this.instance.getStage();
|
|
20360
|
+
let originalPosition = null;
|
|
20361
|
+
this.instance.addEventListener("onSelectionState", (state) => {
|
|
20362
|
+
const nodesSelectionPlugin = this.getSelectionPlugin();
|
|
20363
|
+
const selectedNodes = nodesSelectionPlugin?.getSelectedNodes() ?? [];
|
|
20364
|
+
if (!state && selectedNodes?.some((n) => n.getAttrs().id === node.getAttrs().id)) originalPosition = node.getAbsolutePosition();
|
|
20365
|
+
});
|
|
20366
|
+
node.on("mousedown", (e) => {
|
|
20367
|
+
const nodeTarget = e.target;
|
|
20368
|
+
originalPosition = nodeTarget.getAbsolutePosition();
|
|
20369
|
+
});
|
|
20339
20370
|
node.on("dragstart", (e) => {
|
|
20371
|
+
const nodeTarget = e.target;
|
|
20340
20372
|
this.didMove = false;
|
|
20341
20373
|
if (e.evt?.buttons === 0) {
|
|
20342
|
-
|
|
20374
|
+
nodeTarget.stopDrag();
|
|
20343
20375
|
return;
|
|
20344
20376
|
}
|
|
20345
|
-
const stage = this.instance.getStage();
|
|
20346
20377
|
const isErasing = this.instance.getActiveAction() === "eraseTool";
|
|
20347
20378
|
if (isErasing) {
|
|
20348
|
-
|
|
20379
|
+
nodeTarget.stopDrag();
|
|
20349
20380
|
return;
|
|
20350
20381
|
}
|
|
20351
|
-
this.instance.emitEvent("onDrag",
|
|
20382
|
+
this.instance.emitEvent("onDrag", nodeTarget);
|
|
20352
20383
|
if (stage.isMouseWheelPressed()) {
|
|
20353
20384
|
e.cancelBubble = true;
|
|
20354
|
-
|
|
20385
|
+
nodeTarget.stopDrag();
|
|
20386
|
+
}
|
|
20387
|
+
const realNodeTarget = this.getRealSelectedNode(nodeTarget);
|
|
20388
|
+
if (realNodeTarget.getAttrs().isCloned) return;
|
|
20389
|
+
if (e.evt?.altKey) {
|
|
20390
|
+
nodeTarget.setAttrs({ isCloneOrigin: true });
|
|
20391
|
+
nodeTarget.setAttrs({ isCloned: false });
|
|
20392
|
+
nodeTarget.stopDrag(e.evt);
|
|
20393
|
+
e.cancelBubble = true;
|
|
20394
|
+
const clone = this.instance.getCloningManager().cloneNode(realNodeTarget);
|
|
20395
|
+
if (clone && !this.instance.getCloningManager().isClone(clone)) {
|
|
20396
|
+
clone.setAttrs({ isCloneOrigin: false });
|
|
20397
|
+
clone.setAttrs({ isCloned: true });
|
|
20398
|
+
this.instance.getCloningManager().addClone(clone);
|
|
20399
|
+
}
|
|
20400
|
+
stage.setPointersPositions(e.evt);
|
|
20401
|
+
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
20402
|
+
nodesSelectionPlugin?.setSelectedNodes([]);
|
|
20403
|
+
requestAnimationFrame(() => {
|
|
20404
|
+
nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
|
|
20405
|
+
clone?.startDrag(e.evt);
|
|
20406
|
+
});
|
|
20355
20407
|
}
|
|
20356
20408
|
});
|
|
20357
20409
|
const handleDragMove = (e) => {
|
|
20410
|
+
const nodeTarget = e.target;
|
|
20411
|
+
e.cancelBubble = true;
|
|
20358
20412
|
if (e.evt?.buttons === 0) {
|
|
20359
|
-
|
|
20413
|
+
nodeTarget.stopDrag();
|
|
20360
20414
|
return;
|
|
20361
20415
|
}
|
|
20362
20416
|
this.didMove = true;
|
|
20363
|
-
const stage = this.instance.getStage();
|
|
20417
|
+
const stage$1 = this.instance.getStage();
|
|
20364
20418
|
const isErasing = this.instance.getActiveAction() === "eraseTool";
|
|
20365
20419
|
if (isErasing) {
|
|
20366
|
-
|
|
20420
|
+
nodeTarget.stopDrag();
|
|
20367
20421
|
return;
|
|
20368
20422
|
}
|
|
20369
|
-
if (stage.isMouseWheelPressed()) {
|
|
20423
|
+
if (stage$1.isMouseWheelPressed()) {
|
|
20370
20424
|
e.cancelBubble = true;
|
|
20371
|
-
|
|
20425
|
+
nodeTarget.stopDrag();
|
|
20372
20426
|
return;
|
|
20373
20427
|
}
|
|
20374
|
-
|
|
20428
|
+
const realNodeTarget = this.getRealSelectedNode(nodeTarget);
|
|
20429
|
+
if (this.isSelecting() && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20375
20430
|
clearContainerTargets(this.instance);
|
|
20376
|
-
const layerToMove = containerOverCursor(this.instance, [
|
|
20377
|
-
if (layerToMove && !hasFrames(
|
|
20431
|
+
const layerToMove = containerOverCursor(this.instance, [realNodeTarget]);
|
|
20432
|
+
if (layerToMove && !hasFrames(realNodeTarget) && realNodeTarget.isDragging()) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
20378
20433
|
}
|
|
20379
20434
|
};
|
|
20380
20435
|
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
|
|
20381
20436
|
node.on("dragend", (e) => {
|
|
20437
|
+
const nodeTarget = e.target;
|
|
20438
|
+
e.cancelBubble = true;
|
|
20439
|
+
if (nodeTarget.getAttrs().isCloneOrigin && originalPosition) {
|
|
20440
|
+
nodeTarget.setAbsolutePosition(originalPosition);
|
|
20441
|
+
nodeTarget.setAttrs({ isCloneOrigin: void 0 });
|
|
20442
|
+
nodeTarget.setAttrs({ isCloned: void 0 });
|
|
20443
|
+
originalPosition = null;
|
|
20444
|
+
return;
|
|
20445
|
+
}
|
|
20382
20446
|
if (!this.didMove) return;
|
|
20383
20447
|
const isErasing = this.instance.getActiveAction() === "eraseTool";
|
|
20384
20448
|
if (isErasing) {
|
|
20385
|
-
|
|
20449
|
+
nodeTarget.stopDrag();
|
|
20386
20450
|
return;
|
|
20387
20451
|
}
|
|
20388
20452
|
this.instance.emitEvent("onDrag", null);
|
|
20389
|
-
|
|
20453
|
+
const realNodeTarget = this.getRealSelectedNode(nodeTarget);
|
|
20454
|
+
if (this.isSelecting() && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20390
20455
|
clearContainerTargets(this.instance);
|
|
20391
20456
|
const nodesEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
20392
20457
|
const nodesDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
|
|
20393
20458
|
if (nodesEdgeSnappingPlugin) nodesEdgeSnappingPlugin.cleanupGuidelines();
|
|
20394
20459
|
if (nodesDistanceSnappingPlugin) nodesDistanceSnappingPlugin.cleanupGuidelines();
|
|
20395
|
-
const layerToMove = containerOverCursor(this.instance, [
|
|
20460
|
+
const layerToMove = containerOverCursor(this.instance, [realNodeTarget]);
|
|
20396
20461
|
let containerToMove = this.instance.getMainLayer();
|
|
20397
20462
|
if (layerToMove) containerToMove = layerToMove;
|
|
20398
20463
|
let moved = false;
|
|
20399
|
-
if (containerToMove && !hasFrames(node)) moved = moveNodeToContainer(this.instance,
|
|
20464
|
+
if (containerToMove && !hasFrames(node)) moved = moveNodeToContainer(this.instance, realNodeTarget, containerToMove);
|
|
20465
|
+
if (realNodeTarget.getAttrs().isCloned) {
|
|
20466
|
+
this.instance.getCloningManager().removeClone(realNodeTarget);
|
|
20467
|
+
originalPosition = realNodeTarget.getAbsolutePosition();
|
|
20468
|
+
}
|
|
20400
20469
|
if (containerToMove) containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
20401
|
-
if (!moved) this.instance.updateNode(this.serialize(
|
|
20470
|
+
if (!moved) this.instance.updateNode(this.serialize(realNodeTarget));
|
|
20402
20471
|
}
|
|
20472
|
+
nodeTarget.setAttrs({ isCloned: void 0 });
|
|
20473
|
+
nodeTarget.setAttrs({ isCloneOrigin: void 0 });
|
|
20474
|
+
realNodeTarget.setAttrs({ isCloned: void 0 });
|
|
20475
|
+
realNodeTarget.setAttrs({ isCloneOrigin: void 0 });
|
|
20476
|
+
originalPosition = realNodeTarget.getAbsolutePosition();
|
|
20403
20477
|
});
|
|
20404
20478
|
node.handleMouseover = () => {
|
|
20405
|
-
const stage = this.instance.getStage();
|
|
20479
|
+
const stage$1 = this.instance.getStage();
|
|
20406
20480
|
const activeAction = this.instance.getActiveAction();
|
|
20407
20481
|
const isNodeSelectionEnabled = this.getSelectionPlugin()?.isEnabled();
|
|
20408
20482
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
@@ -20410,24 +20484,24 @@ var WeaveNode = class {
|
|
|
20410
20484
|
const isLocked$1 = realNode.getAttrs().locked ?? false;
|
|
20411
20485
|
if ([MOVE_TOOL_ACTION_NAME].includes(activeAction ?? "")) return;
|
|
20412
20486
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isLocked$1) {
|
|
20413
|
-
const stage$
|
|
20414
|
-
stage$
|
|
20487
|
+
const stage$2 = this.instance.getStage();
|
|
20488
|
+
stage$2.container().style.cursor = "default";
|
|
20415
20489
|
}
|
|
20416
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20417
|
-
const stage$
|
|
20418
|
-
stage$
|
|
20490
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage$1.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20491
|
+
const stage$2 = this.instance.getStage();
|
|
20492
|
+
stage$2.container().style.cursor = "pointer";
|
|
20419
20493
|
}
|
|
20420
|
-
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20421
|
-
const stage$
|
|
20422
|
-
stage$
|
|
20494
|
+
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage$1.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20495
|
+
const stage$2 = this.instance.getStage();
|
|
20496
|
+
stage$2.container().style.cursor = "grab";
|
|
20423
20497
|
}
|
|
20424
20498
|
if (this.isPasting()) {
|
|
20425
|
-
const stage$
|
|
20426
|
-
stage$
|
|
20499
|
+
const stage$2 = this.instance.getStage();
|
|
20500
|
+
stage$2.container().style.cursor = "crosshair";
|
|
20427
20501
|
}
|
|
20428
20502
|
};
|
|
20429
20503
|
node.on("pointerover", (e) => {
|
|
20430
|
-
const stage = this.instance.getStage();
|
|
20504
|
+
const stage$1 = this.instance.getStage();
|
|
20431
20505
|
const activeAction = this.instance.getActiveAction();
|
|
20432
20506
|
const isNodeSelectionEnabled = this.getSelectionPlugin()?.isEnabled();
|
|
20433
20507
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
@@ -20435,13 +20509,13 @@ var WeaveNode = class {
|
|
|
20435
20509
|
const isLocked$1 = realNode.getAttrs().locked ?? false;
|
|
20436
20510
|
if ([MOVE_TOOL_ACTION_NAME].includes(activeAction ?? "")) return;
|
|
20437
20511
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isLocked$1) {
|
|
20438
|
-
const stage$
|
|
20439
|
-
stage$
|
|
20512
|
+
const stage$2 = this.instance.getStage();
|
|
20513
|
+
stage$2.container().style.cursor = "default";
|
|
20440
20514
|
e.cancelBubble = true;
|
|
20441
20515
|
}
|
|
20442
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20443
|
-
const stage$
|
|
20444
|
-
stage$
|
|
20516
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !isLocked$1 && stage$1.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20517
|
+
const stage$2 = this.instance.getStage();
|
|
20518
|
+
stage$2.container().style.cursor = "pointer";
|
|
20445
20519
|
this.setHoverState(realNode);
|
|
20446
20520
|
e.cancelBubble = true;
|
|
20447
20521
|
}
|
|
@@ -20450,8 +20524,8 @@ var WeaveNode = class {
|
|
|
20450
20524
|
e.cancelBubble = true;
|
|
20451
20525
|
}
|
|
20452
20526
|
if (this.isPasting()) {
|
|
20453
|
-
const stage$
|
|
20454
|
-
stage$
|
|
20527
|
+
const stage$2 = this.instance.getStage();
|
|
20528
|
+
stage$2.container().style.cursor = "crosshair";
|
|
20455
20529
|
e.cancelBubble = true;
|
|
20456
20530
|
}
|
|
20457
20531
|
});
|
|
@@ -20556,6 +20630,10 @@ var WeaveNode = class {
|
|
|
20556
20630
|
};
|
|
20557
20631
|
return (0, import_merge.default)(transformProperties, nodeTransformConfig ?? {});
|
|
20558
20632
|
}
|
|
20633
|
+
getNodesSelectionPlugin() {
|
|
20634
|
+
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
20635
|
+
return nodesSelectionPlugin;
|
|
20636
|
+
}
|
|
20559
20637
|
getNodesEdgeSnappingPlugin() {
|
|
20560
20638
|
const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY);
|
|
20561
20639
|
return snappingPlugin;
|
|
@@ -20570,6 +20648,17 @@ var WeaveNode = class {
|
|
|
20570
20648
|
y: 0
|
|
20571
20649
|
};
|
|
20572
20650
|
}
|
|
20651
|
+
getRealSelectedNode(nodeTarget) {
|
|
20652
|
+
const stage = this.instance.getStage();
|
|
20653
|
+
let realNodeTarget = nodeTarget;
|
|
20654
|
+
if (nodeTarget.getParent() instanceof konva.default.Transformer) {
|
|
20655
|
+
const mousePos = stage.getPointerPosition();
|
|
20656
|
+
const intersections = stage.getAllIntersections(mousePos);
|
|
20657
|
+
const nodesIntersected = intersections.filter((ele) => ele.getAttrs().nodeType);
|
|
20658
|
+
if (nodesIntersected.length > 0) realNodeTarget = this.instance.getInstanceRecursive(nodesIntersected[nodesIntersected.length - 1]);
|
|
20659
|
+
}
|
|
20660
|
+
return realNodeTarget;
|
|
20661
|
+
}
|
|
20573
20662
|
};
|
|
20574
20663
|
|
|
20575
20664
|
//#endregion
|
|
@@ -21390,6 +21479,7 @@ var WeaveTargetingManager = class {
|
|
|
21390
21479
|
//#endregion
|
|
21391
21480
|
//#region src/managers/cloning.ts
|
|
21392
21481
|
var WeaveCloningManager = class {
|
|
21482
|
+
clones = [];
|
|
21393
21483
|
constructor(instance) {
|
|
21394
21484
|
this.instance = instance;
|
|
21395
21485
|
this.logger = this.instance.getChildLogger("cloning-manager");
|
|
@@ -21548,6 +21638,42 @@ var WeaveCloningManager = class {
|
|
|
21548
21638
|
}
|
|
21549
21639
|
newGroup.destroy();
|
|
21550
21640
|
}
|
|
21641
|
+
recursivelyUpdateKeys(nodes) {
|
|
21642
|
+
for (const child of nodes) {
|
|
21643
|
+
const newNodeId = v4_default();
|
|
21644
|
+
child.key = newNodeId;
|
|
21645
|
+
child.props.id = newNodeId;
|
|
21646
|
+
if (child.props.children) this.recursivelyUpdateKeys(child.props.children);
|
|
21647
|
+
}
|
|
21648
|
+
}
|
|
21649
|
+
cloneNode(targetNode) {
|
|
21650
|
+
const nodeHandler = this.instance.getNodeHandler(targetNode.getAttrs().nodeType);
|
|
21651
|
+
if (!nodeHandler) return void 0;
|
|
21652
|
+
const parent = targetNode.getParent();
|
|
21653
|
+
const serializedNode = nodeHandler.serialize(targetNode);
|
|
21654
|
+
this.recursivelyUpdateKeys(serializedNode.props.children ?? []);
|
|
21655
|
+
const newNodeId = v4_default();
|
|
21656
|
+
serializedNode.key = newNodeId;
|
|
21657
|
+
serializedNode.props.id = newNodeId;
|
|
21658
|
+
const realParent = this.instance.getInstanceRecursive(parent);
|
|
21659
|
+
this.instance.addNode(serializedNode, realParent?.getAttrs().id);
|
|
21660
|
+
return this.instance.getStage().findOne(`#${newNodeId}`);
|
|
21661
|
+
}
|
|
21662
|
+
addClone(node) {
|
|
21663
|
+
this.clones.push(node);
|
|
21664
|
+
}
|
|
21665
|
+
removeClone(node) {
|
|
21666
|
+
this.clones = this.clones.filter((c) => c !== node);
|
|
21667
|
+
}
|
|
21668
|
+
getClones() {
|
|
21669
|
+
return this.clones;
|
|
21670
|
+
}
|
|
21671
|
+
isClone(node) {
|
|
21672
|
+
return this.clones.find((c) => c === node);
|
|
21673
|
+
}
|
|
21674
|
+
cleanupClones() {
|
|
21675
|
+
this.clones = [];
|
|
21676
|
+
}
|
|
21551
21677
|
};
|
|
21552
21678
|
|
|
21553
21679
|
//#endregion
|
|
@@ -21951,7 +22077,7 @@ var WeaveRegisterManager = class {
|
|
|
21951
22077
|
|
|
21952
22078
|
//#endregion
|
|
21953
22079
|
//#region package.json
|
|
21954
|
-
var version = "0.
|
|
22080
|
+
var version = "0.74.1";
|
|
21955
22081
|
|
|
21956
22082
|
//#endregion
|
|
21957
22083
|
//#region src/managers/setup.ts
|
|
@@ -22769,7 +22895,7 @@ var Weave = class {
|
|
|
22769
22895
|
getNodeContainerId(node) {
|
|
22770
22896
|
const stage = this.getStage();
|
|
22771
22897
|
let nodeContainer = node.getParent()?.getAttrs().id ?? "";
|
|
22772
|
-
if (typeof node
|
|
22898
|
+
if (typeof node?.getParent()?.getAttrs().nodeId !== "undefined") {
|
|
22773
22899
|
const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
|
|
22774
22900
|
if (realContainer) nodeContainer = realContainer.getAttrs().id ?? "";
|
|
22775
22901
|
}
|
|
@@ -22777,8 +22903,8 @@ var Weave = class {
|
|
|
22777
22903
|
}
|
|
22778
22904
|
getNodeContainer(node) {
|
|
22779
22905
|
const stage = this.getStage();
|
|
22780
|
-
let nodeContainer = node
|
|
22781
|
-
if (typeof node
|
|
22906
|
+
let nodeContainer = node?.getParent();
|
|
22907
|
+
if (typeof node?.getParent()?.getAttrs().nodeId !== "undefined") {
|
|
22782
22908
|
const realContainer = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
|
|
22783
22909
|
if (realContainer) nodeContainer = realContainer;
|
|
22784
22910
|
}
|
|
@@ -22833,6 +22959,9 @@ var Weave = class {
|
|
|
22833
22959
|
selectionPlugin.setSelectedNodes(instanceNodes);
|
|
22834
22960
|
}
|
|
22835
22961
|
}
|
|
22962
|
+
getCloningManager() {
|
|
22963
|
+
return this.cloningManager;
|
|
22964
|
+
}
|
|
22836
22965
|
nodesToGroupSerialized(instancesToClone) {
|
|
22837
22966
|
return this.cloningManager.nodesToGroupSerialized(instancesToClone);
|
|
22838
22967
|
}
|
|
@@ -24832,17 +24961,13 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
|
24832
24961
|
fontFamily: "Arial",
|
|
24833
24962
|
fontStyle: "bold",
|
|
24834
24963
|
fontSize: 20,
|
|
24835
|
-
fontColor: "#
|
|
24964
|
+
fontColor: "#000000",
|
|
24836
24965
|
titleMargin: 20,
|
|
24837
|
-
borderColor: "#
|
|
24966
|
+
borderColor: "#000000",
|
|
24838
24967
|
borderWidth: 1,
|
|
24839
|
-
onTargetLeave: {
|
|
24840
|
-
borderColor: "#000000ff",
|
|
24841
|
-
fill: "#ffffffff"
|
|
24842
|
-
},
|
|
24843
24968
|
onTargetEnter: {
|
|
24844
|
-
borderColor: "#
|
|
24845
|
-
fill: "#
|
|
24969
|
+
borderColor: "#FF6863FF",
|
|
24970
|
+
fill: "#FFFFFFFF"
|
|
24846
24971
|
},
|
|
24847
24972
|
transform: {
|
|
24848
24973
|
rotateEnabled: false,
|
|
@@ -24852,10 +24977,12 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
|
24852
24977
|
padding: 0
|
|
24853
24978
|
}
|
|
24854
24979
|
};
|
|
24980
|
+
const WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR = "#FFFFFFFF";
|
|
24855
24981
|
const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
24856
24982
|
title: "Frame XXX",
|
|
24857
24983
|
frameWidth: 1920,
|
|
24858
|
-
frameHeight: 1080
|
|
24984
|
+
frameHeight: 1080,
|
|
24985
|
+
frameBackground: WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
|
|
24859
24986
|
};
|
|
24860
24987
|
|
|
24861
24988
|
//#endregion
|
|
@@ -24880,13 +25007,14 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
24880
25007
|
...props.title && { title: props.title },
|
|
24881
25008
|
...props.frameWidth && { frameWidth: props.frameWidth },
|
|
24882
25009
|
...props.frameHeight && { frameHeight: props.frameHeight },
|
|
25010
|
+
...props.frameBackground && { frameBackground: props.frameBackground },
|
|
24883
25011
|
children: []
|
|
24884
25012
|
}
|
|
24885
25013
|
};
|
|
24886
25014
|
}
|
|
24887
25015
|
onRender(props) {
|
|
24888
25016
|
const { id, zIndex,...restProps } = props;
|
|
24889
|
-
const { fontFamily, fontStyle, fontSize, fontColor, titleMargin, borderColor, borderWidth, onTargetEnter: { borderColor: onTargetEnterBorderColor, fill: onTargetEnterFill }
|
|
25017
|
+
const { fontFamily, fontStyle, fontSize, fontColor, titleMargin, borderColor, borderWidth, onTargetEnter: { borderColor: onTargetEnterBorderColor, fill: onTargetEnterFill } } = this.config;
|
|
24890
25018
|
const frameParams = { ...restProps };
|
|
24891
25019
|
const frame = new konva.default.Group({
|
|
24892
25020
|
...frameParams,
|
|
@@ -24920,13 +25048,14 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
24920
25048
|
nodeId: id,
|
|
24921
25049
|
x: 0,
|
|
24922
25050
|
y: 0,
|
|
25051
|
+
onTargetEnter: false,
|
|
24923
25052
|
width: props.frameWidth,
|
|
24924
25053
|
stroke: borderColor,
|
|
24925
25054
|
strokeWidth: borderWidth,
|
|
24926
25055
|
strokeScaleEnabled: true,
|
|
24927
25056
|
shadowForStrokeEnabled: false,
|
|
24928
25057
|
height: props.frameHeight,
|
|
24929
|
-
fill: frameParams.frameBackground ??
|
|
25058
|
+
fill: frameParams.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR,
|
|
24930
25059
|
listening: false,
|
|
24931
25060
|
draggable: false
|
|
24932
25061
|
});
|
|
@@ -24936,7 +25065,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
24936
25065
|
id: `${id}-title`,
|
|
24937
25066
|
x: 0,
|
|
24938
25067
|
width: props.frameWidth,
|
|
24939
|
-
fontSize
|
|
25068
|
+
fontSize,
|
|
24940
25069
|
fontFamily,
|
|
24941
25070
|
fontStyle,
|
|
24942
25071
|
verticalAlign: "middle",
|
|
@@ -24989,7 +25118,9 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
24989
25118
|
ctx.rect(0, -textHeight, props.frameWidth, textHeight);
|
|
24990
25119
|
ctx.fillStrokeShape(shape);
|
|
24991
25120
|
},
|
|
25121
|
+
strokeWidth: 0,
|
|
24992
25122
|
fill: "transparent",
|
|
25123
|
+
nodeId: id,
|
|
24993
25124
|
id: `${id}-selection-area`,
|
|
24994
25125
|
listening: true,
|
|
24995
25126
|
draggable: true,
|
|
@@ -25006,6 +25137,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
25006
25137
|
ctx.rect(0, 0, props.frameWidth, props.frameHeight);
|
|
25007
25138
|
ctx.fillStrokeShape(shape);
|
|
25008
25139
|
},
|
|
25140
|
+
strokeWidth: 0,
|
|
25009
25141
|
fill: "transparent",
|
|
25010
25142
|
nodeId: id,
|
|
25011
25143
|
id: `${id}-container-area`,
|
|
@@ -25038,29 +25170,24 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
25038
25170
|
selectionArea.off("dragend");
|
|
25039
25171
|
this.setupDefaultNodeEvents(frame);
|
|
25040
25172
|
this.instance.addEventListener("onZoomChange", () => {
|
|
25041
|
-
const stage$1 = this.instance.getStage();
|
|
25042
|
-
text.fontSize(fontSize / stage$1.scaleX());
|
|
25043
|
-
text.width(props.frameWidth);
|
|
25044
|
-
const textMeasures$1 = text.measureSize(text.getAttrs().text ?? "");
|
|
25045
|
-
const textHeight$1 = textMeasures$1.height + 2 * titleMargin / stage$1.scaleX();
|
|
25046
|
-
text.y(-textHeight$1);
|
|
25047
|
-
text.height(textHeight$1);
|
|
25048
25173
|
selectionArea.hitFunc(function(ctx, shape) {
|
|
25049
25174
|
ctx.beginPath();
|
|
25050
|
-
ctx.rect(0, -textHeight
|
|
25175
|
+
ctx.rect(0, -textHeight, props.frameWidth, textHeight);
|
|
25051
25176
|
ctx.fillStrokeShape(shape);
|
|
25052
25177
|
});
|
|
25053
25178
|
});
|
|
25054
25179
|
frame.off("pointerover");
|
|
25055
25180
|
frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
|
|
25056
25181
|
background.setAttrs({
|
|
25057
|
-
|
|
25182
|
+
onTargetEnter: false,
|
|
25183
|
+
stroke: borderColor,
|
|
25058
25184
|
strokeWidth: borderWidth,
|
|
25059
|
-
fill:
|
|
25185
|
+
fill: frameParams.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
|
|
25060
25186
|
});
|
|
25061
25187
|
});
|
|
25062
25188
|
frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
|
|
25063
25189
|
background.setAttrs({
|
|
25190
|
+
onTargetEnter: true,
|
|
25064
25191
|
stroke: onTargetEnterBorderColor,
|
|
25065
25192
|
strokeWidth: borderWidth,
|
|
25066
25193
|
fill: onTargetEnterFill
|
|
@@ -25082,11 +25209,11 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
25082
25209
|
const title = stage.findOne(`#${newProps.id}-title`);
|
|
25083
25210
|
const background = stage.findOne(`#${newProps.id}-bg`);
|
|
25084
25211
|
const selectionArea = stage.findOne(`#${newProps.id}-selection-area`);
|
|
25085
|
-
if (background) background.setAttrs({ fill: newProps.frameBackground ??
|
|
25212
|
+
if (background && !newProps.onTargetEnter) background.setAttrs({ fill: newProps.frameBackground ?? WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR });
|
|
25086
25213
|
if (title && selectionArea) {
|
|
25087
25214
|
title.text(newProps.title);
|
|
25088
25215
|
const textMeasures = title.measureSize(title.getAttrs().text ?? "");
|
|
25089
|
-
const textHeight = textMeasures.height + 2 * titleMargin
|
|
25216
|
+
const textHeight = textMeasures.height + 2 * titleMargin;
|
|
25090
25217
|
title.y(-textHeight);
|
|
25091
25218
|
title.height(textHeight);
|
|
25092
25219
|
selectionArea.hitFunc(function(ctx, shape) {
|
|
@@ -25115,6 +25242,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
25115
25242
|
const realAttrs = mainNode?.getAttrs();
|
|
25116
25243
|
const cleanedAttrs = { ...realAttrs };
|
|
25117
25244
|
delete cleanedAttrs.draggable;
|
|
25245
|
+
delete cleanedAttrs.onTargetEnter;
|
|
25118
25246
|
return {
|
|
25119
25247
|
key: realAttrs?.id ?? "",
|
|
25120
25248
|
type: realAttrs?.nodeType,
|
|
@@ -26233,7 +26361,9 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26233
26361
|
id: `${id}-bg`,
|
|
26234
26362
|
fill: this.config.style.background.color,
|
|
26235
26363
|
stroke: this.config.style.background.strokeColor,
|
|
26236
|
-
strokeWidth: this.config.style.background.strokeWidth
|
|
26364
|
+
strokeWidth: this.config.style.background.strokeWidth,
|
|
26365
|
+
nodeId: id,
|
|
26366
|
+
rotation: 0
|
|
26237
26367
|
});
|
|
26238
26368
|
videoGroup.add(bg);
|
|
26239
26369
|
if (!isServer()) {
|
|
@@ -26245,7 +26375,9 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26245
26375
|
y: 0,
|
|
26246
26376
|
draggable: false,
|
|
26247
26377
|
image: void 0,
|
|
26248
|
-
name: void 0
|
|
26378
|
+
name: void 0,
|
|
26379
|
+
nodeId: id,
|
|
26380
|
+
rotation: 0
|
|
26249
26381
|
});
|
|
26250
26382
|
video.hide();
|
|
26251
26383
|
videoGroup.add(video);
|
|
@@ -26258,7 +26390,9 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26258
26390
|
height: this.config.style.track.height / this.instance.getStage().scaleY(),
|
|
26259
26391
|
strokeWidth: 0,
|
|
26260
26392
|
fill: this.config.style.track.color,
|
|
26261
|
-
name: void 0
|
|
26393
|
+
name: void 0,
|
|
26394
|
+
nodeId: id,
|
|
26395
|
+
rotation: 0
|
|
26262
26396
|
});
|
|
26263
26397
|
this.instance.addEventListener("onZoomChange", () => {
|
|
26264
26398
|
videoProgress.height(this.config.style.track.height / this.instance.getStage().scaleY());
|
|
@@ -26274,7 +26408,9 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26274
26408
|
y: 0,
|
|
26275
26409
|
draggable: false,
|
|
26276
26410
|
image: void 0,
|
|
26277
|
-
name: void 0
|
|
26411
|
+
name: void 0,
|
|
26412
|
+
nodeId: id,
|
|
26413
|
+
rotation: 0
|
|
26278
26414
|
});
|
|
26279
26415
|
videoPlaceholder.show();
|
|
26280
26416
|
videoGroup.add(videoPlaceholder);
|
|
@@ -26292,7 +26428,9 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26292
26428
|
height: this.config.style.icon.internal.paddingY * 2 + this.config.style.icon.height,
|
|
26293
26429
|
strokeWidth: this.config.style.iconBackground.strokeWidth,
|
|
26294
26430
|
stroke: this.config.style.iconBackground.strokeColor,
|
|
26295
|
-
fill: this.config.style.iconBackground.color
|
|
26431
|
+
fill: this.config.style.iconBackground.color,
|
|
26432
|
+
nodeId: id,
|
|
26433
|
+
rotation: 0
|
|
26296
26434
|
});
|
|
26297
26435
|
videoIconGroup.add(videoIconBg);
|
|
26298
26436
|
const videoIcon = new konva.default.Image({
|
|
@@ -26303,7 +26441,9 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26303
26441
|
width: this.config.style.icon.width,
|
|
26304
26442
|
height: this.config.style.icon.height,
|
|
26305
26443
|
fill: "transparent",
|
|
26306
|
-
image: this.videoIconImage
|
|
26444
|
+
image: this.videoIconImage,
|
|
26445
|
+
nodeId: id,
|
|
26446
|
+
rotation: 0
|
|
26307
26447
|
});
|
|
26308
26448
|
videoIconGroup.add(videoIcon);
|
|
26309
26449
|
videoGroup.add(videoIconGroup);
|
|
@@ -26505,6 +26645,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26505
26645
|
const videoHeight = node.getAttrs().height ?? 0;
|
|
26506
26646
|
bg.setAttrs({
|
|
26507
26647
|
...internalVideoProps,
|
|
26648
|
+
rotation: 0,
|
|
26508
26649
|
id: `${id}-bg`,
|
|
26509
26650
|
x: 0,
|
|
26510
26651
|
y: 0
|
|
@@ -26512,6 +26653,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26512
26653
|
const video = node.findOne(`#${id}-video`);
|
|
26513
26654
|
if (!isServer() && video) video.setAttrs({
|
|
26514
26655
|
...internalVideoProps,
|
|
26656
|
+
rotation: 0,
|
|
26515
26657
|
id: `${id}-video`,
|
|
26516
26658
|
x: 0,
|
|
26517
26659
|
y: 0
|
|
@@ -26519,6 +26661,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
26519
26661
|
videoPlaceholder.setAttrs({
|
|
26520
26662
|
...internalVideoProps,
|
|
26521
26663
|
id: `${id}-video-placeholder`,
|
|
26664
|
+
rotation: 0,
|
|
26522
26665
|
x: 0,
|
|
26523
26666
|
y: 0
|
|
26524
26667
|
});
|
|
@@ -28482,7 +28625,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
28482
28625
|
this.instance.addEventListener("onStageDrop", (e) => {
|
|
28483
28626
|
if (window.weaveDragImageURL) {
|
|
28484
28627
|
this.instance.getStage().setPointersPositions(e);
|
|
28485
|
-
const position = this.instance
|
|
28628
|
+
const position = getPositionRelativeToContainerOnPosition(this.instance);
|
|
28486
28629
|
this.instance.triggerAction(IMAGE_TOOL_ACTION_NAME, {
|
|
28487
28630
|
imageURL: window.weaveDragImageURL,
|
|
28488
28631
|
imageId: window.weaveDragImageId,
|
|
@@ -28537,7 +28680,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
28537
28680
|
setState(state) {
|
|
28538
28681
|
this.state = state;
|
|
28539
28682
|
}
|
|
28540
|
-
loadImage(imageURL,
|
|
28683
|
+
loadImage(imageURL, position) {
|
|
28541
28684
|
this.setCursor();
|
|
28542
28685
|
this.setFocusStage();
|
|
28543
28686
|
this.imageId = v4_default();
|
|
@@ -28671,7 +28814,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
28671
28814
|
this.forceMainContainer = params?.forceMainContainer ?? false;
|
|
28672
28815
|
if (params?.imageId) this.updateProps({ imageId: params.imageId });
|
|
28673
28816
|
if (params?.imageURL) {
|
|
28674
|
-
this.loadImage(params.imageURL, params?.
|
|
28817
|
+
this.loadImage(params.imageURL, params?.position ?? void 0);
|
|
28675
28818
|
return;
|
|
28676
28819
|
}
|
|
28677
28820
|
this.props = this.initProps();
|
|
@@ -30173,7 +30316,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
30173
30316
|
this.instance.addEventListener("onStageDrop", (e) => {
|
|
30174
30317
|
if (window.weaveDragVideoId && window.weaveDragVideoParams) {
|
|
30175
30318
|
this.instance.getStage().setPointersPositions(e);
|
|
30176
|
-
const position = this.instance
|
|
30319
|
+
const position = getPositionRelativeToContainerOnPosition(this.instance);
|
|
30177
30320
|
this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
|
|
30178
30321
|
videoId: window.weaveDragVideoId,
|
|
30179
30322
|
videoParams: window.weaveDragVideoParams,
|
|
@@ -30559,18 +30702,18 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
30559
30702
|
}
|
|
30560
30703
|
};
|
|
30561
30704
|
|
|
30562
|
-
//#endregion
|
|
30563
|
-
//#region src/plugins/stage-panning/constants.ts
|
|
30564
|
-
const WEAVE_STAGE_PANNING_KEY = "stagePanning";
|
|
30565
|
-
|
|
30566
30705
|
//#endregion
|
|
30567
30706
|
//#region src/plugins/stage-panning/stage-panning.ts
|
|
30568
30707
|
var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
30569
30708
|
panning = false;
|
|
30709
|
+
currentPointer = null;
|
|
30710
|
+
stageScrollInterval = void 0;
|
|
30711
|
+
targetScrollIntervals = {};
|
|
30570
30712
|
getLayerName = void 0;
|
|
30571
30713
|
initLayer = void 0;
|
|
30572
|
-
constructor() {
|
|
30714
|
+
constructor(params) {
|
|
30573
30715
|
super();
|
|
30716
|
+
this.config = (0, import_merge.default)(WEAVE_STAGE_PANNING_DEFAULT_CONFIG, params?.config ?? {});
|
|
30574
30717
|
this.pointers = new Map();
|
|
30575
30718
|
this.panning = false;
|
|
30576
30719
|
this.isDragging = false;
|
|
@@ -30652,6 +30795,8 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
30652
30795
|
lastPos = null;
|
|
30653
30796
|
});
|
|
30654
30797
|
const handleMouseMove = (e) => {
|
|
30798
|
+
const pos = stage.getPointerPosition();
|
|
30799
|
+
if (pos) this.currentPointer = pos;
|
|
30655
30800
|
if (["touch", "pen"].includes(e.evt.pointerType) && e.evt.buttons !== 1) return;
|
|
30656
30801
|
this.pointers.set(e.evt.pointerId, {
|
|
30657
30802
|
x: e.evt.clientX,
|
|
@@ -30661,7 +30806,6 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
30661
30806
|
if (this.isSpaceKeyPressed) stage.container().style.cursor = "grabbing";
|
|
30662
30807
|
if (!this.isDragging) return;
|
|
30663
30808
|
this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
30664
|
-
const pos = stage.getPointerPosition();
|
|
30665
30809
|
if (pos && lastPos) {
|
|
30666
30810
|
const dx = pos.x - lastPos.x;
|
|
30667
30811
|
const dy = pos.y - lastPos.y;
|
|
@@ -30697,6 +30841,65 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
30697
30841
|
this.instance.emitEvent("onStageMove");
|
|
30698
30842
|
};
|
|
30699
30843
|
window.addEventListener("wheel", handleWheel, { passive: true });
|
|
30844
|
+
stage.on("dragstart", (e) => {
|
|
30845
|
+
const duration = 1e3 / 60;
|
|
30846
|
+
if (this.targetScrollIntervals[e.target.getAttrs().id ?? ""] !== void 0) return;
|
|
30847
|
+
this.targetScrollIntervals[e.target.getAttrs().id ?? ""] = setInterval(() => {
|
|
30848
|
+
const pos = stage.getPointerPosition();
|
|
30849
|
+
const offset = this.config.edgePanOffset;
|
|
30850
|
+
const speed = this.config.edgePanSpeed;
|
|
30851
|
+
if (!pos) return;
|
|
30852
|
+
const isNearLeft = pos.x < offset / stage.scaleX();
|
|
30853
|
+
if (isNearLeft) e.target.x(e.target.x() - speed / stage.scaleX());
|
|
30854
|
+
const isNearRight = pos.x > stage.width() - offset / stage.scaleX();
|
|
30855
|
+
if (isNearRight) e.target.x(e.target.x() + speed / stage.scaleX());
|
|
30856
|
+
const isNearTop = pos.y < offset / stage.scaleY();
|
|
30857
|
+
if (isNearTop) e.target.y(e.target.y() - speed / stage.scaleX());
|
|
30858
|
+
const isNearBottom = pos.y > stage.height() - offset / stage.scaleY();
|
|
30859
|
+
if (isNearBottom) e.target.y(e.target.y() + speed / stage.scaleX());
|
|
30860
|
+
this.getStageGridPlugin()?.renderGrid();
|
|
30861
|
+
}, duration);
|
|
30862
|
+
if (this.stageScrollInterval !== void 0) return;
|
|
30863
|
+
this.stageScrollInterval = setInterval(() => {
|
|
30864
|
+
const pos = stage.getPointerPosition();
|
|
30865
|
+
const offset = this.config.edgePanOffset;
|
|
30866
|
+
const speed = this.config.edgePanSpeed;
|
|
30867
|
+
if (!pos) return;
|
|
30868
|
+
let isOnBorder = false;
|
|
30869
|
+
const isNearLeft = pos.x < offset;
|
|
30870
|
+
if (isNearLeft) {
|
|
30871
|
+
stage.x(stage.x() + speed);
|
|
30872
|
+
isOnBorder = true;
|
|
30873
|
+
}
|
|
30874
|
+
const isNearRight = pos.x > stage.width() - offset;
|
|
30875
|
+
if (isNearRight) {
|
|
30876
|
+
stage.x(stage.x() - speed);
|
|
30877
|
+
isOnBorder = true;
|
|
30878
|
+
}
|
|
30879
|
+
const isNearTop = pos.y < offset;
|
|
30880
|
+
if (isNearTop) {
|
|
30881
|
+
stage.y(stage.y() + speed);
|
|
30882
|
+
isOnBorder = true;
|
|
30883
|
+
}
|
|
30884
|
+
const isNearBottom = pos.y > stage.height() - offset;
|
|
30885
|
+
if (isNearBottom) {
|
|
30886
|
+
stage.y(stage.y() - speed);
|
|
30887
|
+
isOnBorder = true;
|
|
30888
|
+
}
|
|
30889
|
+
if (isOnBorder) {
|
|
30890
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
30891
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
30892
|
+
}
|
|
30893
|
+
if (!isOnBorder) {
|
|
30894
|
+
this.getNodesEdgeSnappingPlugin()?.enable();
|
|
30895
|
+
this.getNodesDistanceSnappingPlugin()?.enable();
|
|
30896
|
+
}
|
|
30897
|
+
this.getStageGridPlugin()?.renderGrid();
|
|
30898
|
+
}, duration);
|
|
30899
|
+
});
|
|
30900
|
+
stage.on("dragend", () => {
|
|
30901
|
+
this.cleanupEdgeMoveIntervals();
|
|
30902
|
+
});
|
|
30700
30903
|
stage.container().style.touchAction = "none";
|
|
30701
30904
|
stage.container().style.userSelect = "none";
|
|
30702
30905
|
stage.container().style.setProperty("-webkit-user-drag", "none");
|
|
@@ -30741,6 +30944,22 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
30741
30944
|
const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
|
|
30742
30945
|
return snappingPlugin;
|
|
30743
30946
|
}
|
|
30947
|
+
getStageGridPlugin() {
|
|
30948
|
+
const gridPlugin = this.instance.getPlugin("stageGrid");
|
|
30949
|
+
return gridPlugin;
|
|
30950
|
+
}
|
|
30951
|
+
getCurrentPointer() {
|
|
30952
|
+
return this.currentPointer;
|
|
30953
|
+
}
|
|
30954
|
+
cleanupEdgeMoveIntervals() {
|
|
30955
|
+
const intervals = Object.keys(this.targetScrollIntervals);
|
|
30956
|
+
for (const key of intervals) {
|
|
30957
|
+
clearInterval(this.targetScrollIntervals[key]);
|
|
30958
|
+
this.targetScrollIntervals[key] = void 0;
|
|
30959
|
+
}
|
|
30960
|
+
clearInterval(this.stageScrollInterval);
|
|
30961
|
+
this.stageScrollInterval = void 0;
|
|
30962
|
+
}
|
|
30744
30963
|
enable() {
|
|
30745
30964
|
this.enabled = true;
|
|
30746
30965
|
}
|
|
@@ -31751,6 +31970,7 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
|
|
|
31751
31970
|
this.enabled = true;
|
|
31752
31971
|
}
|
|
31753
31972
|
disable() {
|
|
31973
|
+
this.cleanupGuidelines();
|
|
31754
31974
|
this.enabled = false;
|
|
31755
31975
|
}
|
|
31756
31976
|
};
|
|
@@ -32335,6 +32555,7 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
|
|
|
32335
32555
|
this.enabled = true;
|
|
32336
32556
|
}
|
|
32337
32557
|
disable() {
|
|
32558
|
+
this.cleanupGuidelines();
|
|
32338
32559
|
this.enabled = false;
|
|
32339
32560
|
}
|
|
32340
32561
|
};
|
|
@@ -32552,6 +32773,7 @@ exports.WEAVE_COPY_PASTE_PASTE_CATCHER_ID = WEAVE_COPY_PASTE_PASTE_CATCHER_ID
|
|
|
32552
32773
|
exports.WEAVE_COPY_PASTE_PASTE_MODES = WEAVE_COPY_PASTE_PASTE_MODES
|
|
32553
32774
|
exports.WEAVE_DEFAULT_USER_INFO_FUNCTION = WEAVE_DEFAULT_USER_INFO_FUNCTION
|
|
32554
32775
|
exports.WEAVE_ELLIPSE_NODE_TYPE = WEAVE_ELLIPSE_NODE_TYPE
|
|
32776
|
+
exports.WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR = WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR
|
|
32555
32777
|
exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
|
|
32556
32778
|
exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
|
|
32557
32779
|
exports.WEAVE_FRAME_NODE_TYPE = WEAVE_FRAME_NODE_TYPE
|
|
@@ -32585,6 +32807,8 @@ exports.WEAVE_STAGE_GRID_PLUGIN_KEY = WEAVE_STAGE_GRID_PLUGIN_KEY
|
|
|
32585
32807
|
exports.WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG = WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG
|
|
32586
32808
|
exports.WEAVE_STAGE_KEYBOARD_MOVE_KEY = WEAVE_STAGE_KEYBOARD_MOVE_KEY
|
|
32587
32809
|
exports.WEAVE_STAGE_NODE_TYPE = WEAVE_STAGE_NODE_TYPE
|
|
32810
|
+
exports.WEAVE_STAGE_PANNING_DEFAULT_CONFIG = WEAVE_STAGE_PANNING_DEFAULT_CONFIG
|
|
32811
|
+
exports.WEAVE_STAGE_PANNING_KEY = WEAVE_STAGE_PANNING_KEY
|
|
32588
32812
|
exports.WEAVE_STAR_NODE_TYPE = WEAVE_STAR_NODE_TYPE
|
|
32589
32813
|
exports.WEAVE_STROKE_NODE_DEFAULT_CONFIG = WEAVE_STROKE_NODE_DEFAULT_CONFIG
|
|
32590
32814
|
exports.WEAVE_STROKE_NODE_TYPE = WEAVE_STROKE_NODE_TYPE
|
|
@@ -32659,6 +32883,7 @@ exports.containerOverCursor = containerOverCursor
|
|
|
32659
32883
|
exports.containsNodeDeep = containsNodeDeep
|
|
32660
32884
|
exports.getBoundingBox = getBoundingBox
|
|
32661
32885
|
exports.getExportBoundingBox = getExportBoundingBox
|
|
32886
|
+
exports.getPositionRelativeToContainerOnPosition = getPositionRelativeToContainerOnPosition
|
|
32662
32887
|
exports.getSelectedNodesMetadata = getSelectedNodesMetadata
|
|
32663
32888
|
exports.getTargetAndSkipNodes = getTargetAndSkipNodes
|
|
32664
32889
|
exports.getTargetedNode = getTargetedNode
|