@inditextech/weave-sdk 0.57.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.cjs +204 -116
- package/dist/sdk.d.cts +218 -163
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +218 -163
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +204 -117
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -17945,6 +17945,73 @@ var WeavePlugin = class {
|
|
|
17945
17945
|
//#region src/plugins/nodes-selection/constants.ts
|
|
17946
17946
|
const WEAVE_NODES_SELECTION_KEY = "nodesSelection";
|
|
17947
17947
|
const WEAVE_NODES_SELECTION_LAYER_ID = "selectionLayer";
|
|
17948
|
+
const WEAVE_NODES_SELECTION_DEFAULT_CONFIG = {
|
|
17949
|
+
selection: {
|
|
17950
|
+
rotationSnaps: [
|
|
17951
|
+
0,
|
|
17952
|
+
45,
|
|
17953
|
+
90,
|
|
17954
|
+
135,
|
|
17955
|
+
180,
|
|
17956
|
+
225,
|
|
17957
|
+
270,
|
|
17958
|
+
315,
|
|
17959
|
+
360
|
|
17960
|
+
],
|
|
17961
|
+
rotationSnapTolerance: 3,
|
|
17962
|
+
ignoreStroke: true,
|
|
17963
|
+
rotateEnabled: true,
|
|
17964
|
+
resizeEnabled: true,
|
|
17965
|
+
flipEnabled: false,
|
|
17966
|
+
keepRatio: true,
|
|
17967
|
+
useSingleNodeRotation: true,
|
|
17968
|
+
shouldOverdrawWholeArea: true,
|
|
17969
|
+
enabledAnchors: [
|
|
17970
|
+
"top-left",
|
|
17971
|
+
"top-center",
|
|
17972
|
+
"top-right",
|
|
17973
|
+
"middle-right",
|
|
17974
|
+
"middle-left",
|
|
17975
|
+
"bottom-left",
|
|
17976
|
+
"bottom-center",
|
|
17977
|
+
"bottom-right"
|
|
17978
|
+
],
|
|
17979
|
+
anchorStyleFunc: (anchor) => {
|
|
17980
|
+
anchor.stroke("#27272aff");
|
|
17981
|
+
anchor.cornerRadius(12);
|
|
17982
|
+
if (anchor.hasName("top-center") || anchor.hasName("bottom-center")) {
|
|
17983
|
+
anchor.height(8);
|
|
17984
|
+
anchor.offsetY(4);
|
|
17985
|
+
anchor.width(32);
|
|
17986
|
+
anchor.offsetX(16);
|
|
17987
|
+
}
|
|
17988
|
+
if (anchor.hasName("middle-left") || anchor.hasName("middle-right")) {
|
|
17989
|
+
anchor.height(32);
|
|
17990
|
+
anchor.offsetY(16);
|
|
17991
|
+
anchor.width(8);
|
|
17992
|
+
anchor.offsetX(4);
|
|
17993
|
+
}
|
|
17994
|
+
},
|
|
17995
|
+
borderStroke: "#1a1aff",
|
|
17996
|
+
borderStrokeWidth: 2
|
|
17997
|
+
},
|
|
17998
|
+
hover: { borderStrokeWidth: 2 },
|
|
17999
|
+
selectionArea: {
|
|
18000
|
+
fill: "#1a1aff11",
|
|
18001
|
+
stroke: "#1a1aff",
|
|
18002
|
+
strokeWidth: 1,
|
|
18003
|
+
dash: [12, 4]
|
|
18004
|
+
},
|
|
18005
|
+
panningWhenSelection: {
|
|
18006
|
+
edgeThreshold: 50,
|
|
18007
|
+
minScrollSpeed: 1,
|
|
18008
|
+
maxScrollSpeed: 15
|
|
18009
|
+
},
|
|
18010
|
+
behaviors: {
|
|
18011
|
+
singleSelection: { enabled: true },
|
|
18012
|
+
multipleSelection: { enabled: false }
|
|
18013
|
+
}
|
|
18014
|
+
};
|
|
17948
18015
|
|
|
17949
18016
|
//#endregion
|
|
17950
18017
|
//#region src/plugins/context-menu/constants.ts
|
|
@@ -18220,10 +18287,6 @@ function getVisibleNodes(instance, stage, nodeParent, skipNodes, referenceLayer)
|
|
|
18220
18287
|
if (skipNodes.includes(node.getParent()?.getAttrs().nodeId)) return;
|
|
18221
18288
|
if (skipNodes.includes(node.getAttrs().id ?? "")) return;
|
|
18222
18289
|
if (node.getParent() !== referenceLayer && !node.getParent()?.getAttrs().nodeId) return;
|
|
18223
|
-
if (node.getParent() !== referenceLayer && node.getParent()?.getAttrs().nodeId) {
|
|
18224
|
-
const realNode = stage.findOne(`#${node.getParent()?.getAttrs().nodeId}`);
|
|
18225
|
-
if (realNode && realNode !== referenceLayer) return;
|
|
18226
|
-
}
|
|
18227
18290
|
finalVisibleNodes.push(node);
|
|
18228
18291
|
});
|
|
18229
18292
|
if (nodesSelection) nodesSelection.getTransformer().show();
|
|
@@ -18856,77 +18919,19 @@ const NODE_SNAP_VERTICAL = {
|
|
|
18856
18919
|
//#endregion
|
|
18857
18920
|
//#region src/plugins/nodes-selection/nodes-selection.ts
|
|
18858
18921
|
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
18922
|
+
selectionStart = null;
|
|
18923
|
+
panSpeed = {
|
|
18924
|
+
x: 0,
|
|
18925
|
+
y: 0
|
|
18926
|
+
};
|
|
18927
|
+
panDirection = {
|
|
18928
|
+
x: 0,
|
|
18929
|
+
y: 0
|
|
18930
|
+
};
|
|
18931
|
+
panLoopId = null;
|
|
18859
18932
|
constructor(params) {
|
|
18860
18933
|
super();
|
|
18861
|
-
|
|
18862
|
-
this.config = {
|
|
18863
|
-
selection: {
|
|
18864
|
-
rotationSnaps: [
|
|
18865
|
-
0,
|
|
18866
|
-
45,
|
|
18867
|
-
90,
|
|
18868
|
-
135,
|
|
18869
|
-
180,
|
|
18870
|
-
225,
|
|
18871
|
-
270,
|
|
18872
|
-
315,
|
|
18873
|
-
360
|
|
18874
|
-
],
|
|
18875
|
-
rotationSnapTolerance: 3,
|
|
18876
|
-
ignoreStroke: true,
|
|
18877
|
-
rotateEnabled: true,
|
|
18878
|
-
resizeEnabled: true,
|
|
18879
|
-
flipEnabled: false,
|
|
18880
|
-
keepRatio: true,
|
|
18881
|
-
useSingleNodeRotation: true,
|
|
18882
|
-
shouldOverdrawWholeArea: true,
|
|
18883
|
-
enabledAnchors: [
|
|
18884
|
-
"top-left",
|
|
18885
|
-
"top-center",
|
|
18886
|
-
"top-right",
|
|
18887
|
-
"middle-right",
|
|
18888
|
-
"middle-left",
|
|
18889
|
-
"bottom-left",
|
|
18890
|
-
"bottom-center",
|
|
18891
|
-
"bottom-right"
|
|
18892
|
-
],
|
|
18893
|
-
anchorStyleFunc: (anchor) => {
|
|
18894
|
-
anchor.stroke("#27272aff");
|
|
18895
|
-
anchor.cornerRadius(12);
|
|
18896
|
-
if (anchor.hasName("top-center") || anchor.hasName("bottom-center")) {
|
|
18897
|
-
anchor.height(8);
|
|
18898
|
-
anchor.offsetY(4);
|
|
18899
|
-
anchor.width(32);
|
|
18900
|
-
anchor.offsetX(16);
|
|
18901
|
-
}
|
|
18902
|
-
if (anchor.hasName("middle-left") || anchor.hasName("middle-right")) {
|
|
18903
|
-
anchor.height(32);
|
|
18904
|
-
anchor.offsetY(16);
|
|
18905
|
-
anchor.width(8);
|
|
18906
|
-
anchor.offsetX(4);
|
|
18907
|
-
}
|
|
18908
|
-
},
|
|
18909
|
-
borderStroke: "#1a1aff",
|
|
18910
|
-
borderStrokeWidth: 2,
|
|
18911
|
-
...config?.selection
|
|
18912
|
-
},
|
|
18913
|
-
hover: {
|
|
18914
|
-
borderStrokeWidth: 2,
|
|
18915
|
-
...config?.hover
|
|
18916
|
-
},
|
|
18917
|
-
selectionArea: {
|
|
18918
|
-
fill: "#1a1aff11",
|
|
18919
|
-
stroke: "#1a1aff",
|
|
18920
|
-
strokeWidth: 1,
|
|
18921
|
-
dash: [12, 4],
|
|
18922
|
-
...config?.selectionArea
|
|
18923
|
-
},
|
|
18924
|
-
behaviors: {
|
|
18925
|
-
singleSelection: { enabled: true },
|
|
18926
|
-
multipleSelection: { enabled: false },
|
|
18927
|
-
...config?.behaviors
|
|
18928
|
-
}
|
|
18929
|
-
};
|
|
18934
|
+
this.config = (0, import_merge.default)(WEAVE_NODES_SELECTION_DEFAULT_CONFIG, params?.config ?? {});
|
|
18930
18935
|
this.defaultEnabledAnchors = this.config.selection?.enabledAnchors ?? [
|
|
18931
18936
|
"top-left",
|
|
18932
18937
|
"top-center",
|
|
@@ -18952,6 +18957,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18952
18957
|
this.initialized = false;
|
|
18953
18958
|
this.enabled = false;
|
|
18954
18959
|
this.pointers = {};
|
|
18960
|
+
this.panLoopId = null;
|
|
18955
18961
|
}
|
|
18956
18962
|
getName() {
|
|
18957
18963
|
return WEAVE_NODES_SELECTION_KEY;
|
|
@@ -19206,6 +19212,79 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19206
19212
|
this.tr.nodes([]);
|
|
19207
19213
|
this.triggerSelectedNodesEvent();
|
|
19208
19214
|
}
|
|
19215
|
+
updateSelectionRect() {
|
|
19216
|
+
const stage = this.instance.getStage();
|
|
19217
|
+
this.x2 = stage.getRelativePointerPosition()?.x ?? 0;
|
|
19218
|
+
this.y2 = stage.getRelativePointerPosition()?.y ?? 0;
|
|
19219
|
+
this.getTransformer().nodes([]);
|
|
19220
|
+
this.selectionRectangle.setAttrs({
|
|
19221
|
+
visible: true,
|
|
19222
|
+
x: Math.min(this.x1, this.x2),
|
|
19223
|
+
y: Math.min(this.y1, this.y2),
|
|
19224
|
+
width: Math.abs(this.x2 - this.x1),
|
|
19225
|
+
height: Math.abs(this.y2 - this.y1)
|
|
19226
|
+
});
|
|
19227
|
+
}
|
|
19228
|
+
getSpeedFromEdge(distanceFromEdge) {
|
|
19229
|
+
if (distanceFromEdge < this.config.panningWhenSelection.edgeThreshold) {
|
|
19230
|
+
const factor = 1 - distanceFromEdge / this.config.panningWhenSelection.edgeThreshold;
|
|
19231
|
+
return this.config.panningWhenSelection.minScrollSpeed + (this.config.panningWhenSelection.maxScrollSpeed - this.config.panningWhenSelection.minScrollSpeed) * factor;
|
|
19232
|
+
}
|
|
19233
|
+
return 0;
|
|
19234
|
+
}
|
|
19235
|
+
updatePanDirection() {
|
|
19236
|
+
const stage = this.instance.getStage();
|
|
19237
|
+
const pos = stage.getPointerPosition();
|
|
19238
|
+
const viewWidth = stage.width();
|
|
19239
|
+
const viewHeight = stage.height();
|
|
19240
|
+
if (!pos) return;
|
|
19241
|
+
const distLeft = pos.x;
|
|
19242
|
+
const distRight = viewWidth - pos.x;
|
|
19243
|
+
const distTop = pos.y;
|
|
19244
|
+
const distBottom = viewHeight - pos.y;
|
|
19245
|
+
this.panDirection.x = 0;
|
|
19246
|
+
this.panDirection.y = 0;
|
|
19247
|
+
this.panSpeed = {
|
|
19248
|
+
x: 0,
|
|
19249
|
+
y: 0
|
|
19250
|
+
};
|
|
19251
|
+
if (distLeft < this.config.panningWhenSelection.edgeThreshold) {
|
|
19252
|
+
this.panDirection.x = 1;
|
|
19253
|
+
this.panSpeed.x = this.getSpeedFromEdge(distLeft);
|
|
19254
|
+
} else if (distRight < this.config.panningWhenSelection.edgeThreshold) {
|
|
19255
|
+
this.panDirection.x = -1;
|
|
19256
|
+
this.panSpeed.x = this.getSpeedFromEdge(distRight);
|
|
19257
|
+
}
|
|
19258
|
+
if (distTop < this.config.panningWhenSelection.edgeThreshold) {
|
|
19259
|
+
this.panDirection.y = 1;
|
|
19260
|
+
this.panSpeed.y = this.getSpeedFromEdge(distTop);
|
|
19261
|
+
} else if (distBottom < this.config.panningWhenSelection.edgeThreshold) {
|
|
19262
|
+
this.panDirection.y = -1;
|
|
19263
|
+
this.panSpeed.y = this.getSpeedFromEdge(distBottom);
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
19266
|
+
stopPanLoop() {
|
|
19267
|
+
if (this.panLoopId) {
|
|
19268
|
+
cancelAnimationFrame(this.panLoopId);
|
|
19269
|
+
this.panLoopId = null;
|
|
19270
|
+
}
|
|
19271
|
+
}
|
|
19272
|
+
panLoop() {
|
|
19273
|
+
const stage = this.instance.getStage();
|
|
19274
|
+
if (this.isAreaSelecting() && (this.panDirection.x !== 0 || this.panDirection.y !== 0)) {
|
|
19275
|
+
const scale = stage.scaleX();
|
|
19276
|
+
const stepX = (this.panSpeed.x || 0) / scale;
|
|
19277
|
+
const stepY = (this.panSpeed.y || 0) / scale;
|
|
19278
|
+
stage.x(stage.x() + this.panDirection.x * stepX);
|
|
19279
|
+
stage.y(stage.y() + this.panDirection.y * stepY);
|
|
19280
|
+
if (this.selectionStart) {
|
|
19281
|
+
this.selectionStart.x += this.panDirection.x * stepX;
|
|
19282
|
+
this.selectionStart.y += this.panDirection.y * stepY;
|
|
19283
|
+
}
|
|
19284
|
+
this.updateSelectionRect();
|
|
19285
|
+
}
|
|
19286
|
+
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19287
|
+
}
|
|
19209
19288
|
setTapStart(e) {
|
|
19210
19289
|
this.tapStart = {
|
|
19211
19290
|
x: e.evt.clientX,
|
|
@@ -19264,18 +19343,17 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19264
19343
|
});
|
|
19265
19344
|
}
|
|
19266
19345
|
initEvents() {
|
|
19267
|
-
let x1, y1, x2, y2;
|
|
19268
19346
|
this.selecting = false;
|
|
19269
19347
|
const stage = this.instance.getStage();
|
|
19270
19348
|
stage.container().addEventListener("keydown", (e) => {
|
|
19271
19349
|
if (e.code === "Space") this.isSpaceKeyPressed = true;
|
|
19272
|
-
if ((e.
|
|
19350
|
+
if ((e.code === "Backspace" || e.code === "Delete") && Object.keys(window.weaveTextEditing).length === 0) {
|
|
19273
19351
|
this.removeSelectedNodes();
|
|
19274
19352
|
return;
|
|
19275
19353
|
}
|
|
19276
19354
|
});
|
|
19277
19355
|
stage.container().addEventListener("keyup", (e) => {
|
|
19278
|
-
if (e.
|
|
19356
|
+
if (e.code === "Space") this.isSpaceKeyPressed = false;
|
|
19279
19357
|
});
|
|
19280
19358
|
stage.on("pointerdown", (e) => {
|
|
19281
19359
|
this.setTapStart(e);
|
|
@@ -19289,6 +19367,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19289
19367
|
const selectedGroup = getTargetedNode(this.instance);
|
|
19290
19368
|
if (selectedGroup?.getParent() instanceof konva.default.Transformer) {
|
|
19291
19369
|
this.selecting = false;
|
|
19370
|
+
this.stopPanLoop();
|
|
19292
19371
|
this.hideSelectorArea();
|
|
19293
19372
|
return;
|
|
19294
19373
|
}
|
|
@@ -19299,15 +19378,26 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19299
19378
|
if (isTransformer) return;
|
|
19300
19379
|
if (!isStage && !isContainerEmptyArea && isTargetable) {
|
|
19301
19380
|
this.selecting = false;
|
|
19381
|
+
this.stopPanLoop();
|
|
19302
19382
|
this.hideSelectorArea();
|
|
19303
19383
|
this.handleClickOrTap(e);
|
|
19304
19384
|
return;
|
|
19305
19385
|
}
|
|
19386
|
+
this.panDirection.x = 0;
|
|
19387
|
+
this.panDirection.y = 0;
|
|
19388
|
+
this.panSpeed = {
|
|
19389
|
+
x: 0,
|
|
19390
|
+
y: 0
|
|
19391
|
+
};
|
|
19306
19392
|
const intStage = this.instance.getStage();
|
|
19307
|
-
x1 = intStage.getRelativePointerPosition()?.x ?? 0;
|
|
19308
|
-
y1 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
19309
|
-
x2 = intStage.getRelativePointerPosition()?.x ?? 0;
|
|
19310
|
-
y2 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
19393
|
+
this.x1 = intStage.getRelativePointerPosition()?.x ?? 0;
|
|
19394
|
+
this.y1 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
19395
|
+
this.x2 = intStage.getRelativePointerPosition()?.x ?? 0;
|
|
19396
|
+
this.y2 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
19397
|
+
this.selectionStart = {
|
|
19398
|
+
x: this.x1,
|
|
19399
|
+
y: this.y1
|
|
19400
|
+
};
|
|
19311
19401
|
this.selectionRectangle.strokeWidth(this.config.selectionArea.strokeWidth / stage.scaleX());
|
|
19312
19402
|
this.selectionRectangle.dash(this.config.selectionArea.dash?.map((d) => d / stage.scaleX()) ?? []);
|
|
19313
19403
|
this.selectionRectangle.width(0);
|
|
@@ -19315,6 +19405,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19315
19405
|
this.selecting = true;
|
|
19316
19406
|
this.tr.nodes([]);
|
|
19317
19407
|
this.instance.emitEvent("onSelectionState", true);
|
|
19408
|
+
if (!this.panLoopId) this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19318
19409
|
});
|
|
19319
19410
|
const handleMouseMove = (e) => {
|
|
19320
19411
|
const moved = this.checkMoved(e);
|
|
@@ -19327,25 +19418,20 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19327
19418
|
else this.hideSelectorArea();
|
|
19328
19419
|
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
|
|
19329
19420
|
this.selecting = false;
|
|
19421
|
+
this.stopPanLoop();
|
|
19330
19422
|
return;
|
|
19331
19423
|
}
|
|
19332
19424
|
if (this.isSpaceKeyPressed) return;
|
|
19333
19425
|
if (!this.selecting) return;
|
|
19334
|
-
|
|
19335
|
-
|
|
19336
|
-
y2 = intStage.getRelativePointerPosition()?.y ?? 0;
|
|
19337
|
-
this.getTransformer().nodes([]);
|
|
19338
|
-
this.selectionRectangle.setAttrs({
|
|
19339
|
-
visible: true,
|
|
19340
|
-
x: Math.min(x1, x2),
|
|
19341
|
-
y: Math.min(y1, y2),
|
|
19342
|
-
width: Math.abs(x2 - x1),
|
|
19343
|
-
height: Math.abs(y2 - y1)
|
|
19344
|
-
});
|
|
19426
|
+
this.updateSelectionRect();
|
|
19427
|
+
this.updatePanDirection();
|
|
19345
19428
|
};
|
|
19346
19429
|
stage.on("pointermove", handleMouseMove);
|
|
19430
|
+
this.panLoop();
|
|
19347
19431
|
stage.on("pointerup", (e) => {
|
|
19348
19432
|
this.tr.setAttrs({ listening: true });
|
|
19433
|
+
this.selecting = false;
|
|
19434
|
+
this.stopPanLoop();
|
|
19349
19435
|
const moved = this.checkMoved(e);
|
|
19350
19436
|
this.checkDoubleTap(e);
|
|
19351
19437
|
delete this.pointers[e.evt.pointerId];
|
|
@@ -19362,7 +19448,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19362
19448
|
this.hideSelectorArea();
|
|
19363
19449
|
return;
|
|
19364
19450
|
}
|
|
19365
|
-
this.selecting = false;
|
|
19366
19451
|
this.instance.emitEvent("onSelectionState", false);
|
|
19367
19452
|
if (this.isDoubleTap) {
|
|
19368
19453
|
this.taps = 0;
|
|
@@ -19380,6 +19465,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19380
19465
|
const isContainerEmptyArea = typeof e.target.getAttrs().isContainerPrincipal !== "undefined" && !e.target.getAttrs().isContainerPrincipal;
|
|
19381
19466
|
if ((isStage || isContainerEmptyArea) && !moved) {
|
|
19382
19467
|
this.selecting = false;
|
|
19468
|
+
this.stopPanLoop();
|
|
19383
19469
|
this.hideSelectorArea();
|
|
19384
19470
|
this.getSelectionPlugin()?.setSelectedNodes([]);
|
|
19385
19471
|
return;
|
|
@@ -19390,6 +19476,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19390
19476
|
}
|
|
19391
19477
|
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
|
|
19392
19478
|
this.selecting = false;
|
|
19479
|
+
this.stopPanLoop();
|
|
19393
19480
|
return;
|
|
19394
19481
|
}
|
|
19395
19482
|
if (!this.selectionRectangle.visible()) {
|
|
@@ -19433,6 +19520,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19433
19520
|
if (!frameNode.getAttrs().locked) selectedNodes.add(node);
|
|
19434
19521
|
});
|
|
19435
19522
|
this.selecting = false;
|
|
19523
|
+
this.stopPanLoop();
|
|
19436
19524
|
this.tr.nodes([...selectedNodes]);
|
|
19437
19525
|
this.handleBehaviors();
|
|
19438
19526
|
this.triggerSelectedNodesEvent();
|
|
@@ -19474,6 +19562,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19474
19562
|
const contextMenuPlugin = this.getContextMenuPlugin();
|
|
19475
19563
|
if (contextMenuPlugin?.isContextMenuVisible()) {
|
|
19476
19564
|
this.selecting = false;
|
|
19565
|
+
this.stopPanLoop();
|
|
19477
19566
|
return;
|
|
19478
19567
|
}
|
|
19479
19568
|
this.hideHoverState();
|
|
@@ -19543,11 +19632,13 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19543
19632
|
if (nodesSelected > 1 && !this.config.behaviors.multipleSelection.enabled || nodesSelected === 1 && !this.config.behaviors.singleSelection.enabled) this.tr.enabledAnchors([]);
|
|
19544
19633
|
if (nodesSelected > 1 && this.config.behaviors.multipleSelection.enabled || nodesSelected === 1 && this.config.behaviors.singleSelection.enabled) this.tr.enabledAnchors(this.defaultEnabledAnchors);
|
|
19545
19634
|
let transformerAttrs = { ...this.config.selection };
|
|
19546
|
-
|
|
19547
|
-
|
|
19548
|
-
|
|
19549
|
-
|
|
19550
|
-
|
|
19635
|
+
if (this.tr && this.tr.nodes().length > 0) {
|
|
19636
|
+
const currentAttrs = this.tr.getAttrs();
|
|
19637
|
+
Object.keys(currentAttrs).forEach((key) => {
|
|
19638
|
+
if (["rotationSnaps", "enabledAnchors"].includes(key)) this.tr.setAttr(key, []);
|
|
19639
|
+
else this.tr.setAttr(key, void 0);
|
|
19640
|
+
});
|
|
19641
|
+
}
|
|
19551
19642
|
if (nodesSelected === 1) {
|
|
19552
19643
|
transformerAttrs = (0, import_merge.default)(transformerAttrs, nodes[0].getTransformerProperties());
|
|
19553
19644
|
transformerAttrs.enabledAnchors = nodes[0].allowedAnchors();
|
|
@@ -19557,8 +19648,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19557
19648
|
for (const node of nodes) anchorsArrays.push(node.allowedAnchors());
|
|
19558
19649
|
transformerAttrs.enabledAnchors = intersectArrays(anchorsArrays);
|
|
19559
19650
|
}
|
|
19560
|
-
this.tr
|
|
19561
|
-
|
|
19651
|
+
if (this.tr && this.tr.nodes().length > 0) {
|
|
19652
|
+
this.tr.setAttrs(transformerAttrs);
|
|
19653
|
+
this.tr.forceUpdate();
|
|
19654
|
+
}
|
|
19562
19655
|
}
|
|
19563
19656
|
setSelectedNodes(nodes) {
|
|
19564
19657
|
this.tr.setNodes(nodes);
|
|
@@ -21930,7 +22023,7 @@ var WeaveRegisterManager = class {
|
|
|
21930
22023
|
|
|
21931
22024
|
//#endregion
|
|
21932
22025
|
//#region package.json
|
|
21933
|
-
var version = "0.
|
|
22026
|
+
var version = "0.58.0";
|
|
21934
22027
|
|
|
21935
22028
|
//#endregion
|
|
21936
22029
|
//#region src/managers/setup.ts
|
|
@@ -25095,8 +25188,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
25095
25188
|
const WEAVE_STROKE_NODE_TYPE = "stroke";
|
|
25096
25189
|
const WEAVE_STROKE_NODE_DEFAULT_CONFIG = {
|
|
25097
25190
|
splineResolution: 8,
|
|
25098
|
-
resamplingSpacing: 2
|
|
25099
|
-
cachePixelRatio: 4
|
|
25191
|
+
resamplingSpacing: 2
|
|
25100
25192
|
};
|
|
25101
25193
|
|
|
25102
25194
|
//#endregion
|
|
@@ -25258,7 +25350,6 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
25258
25350
|
context.fillStrokeShape(shape);
|
|
25259
25351
|
}
|
|
25260
25352
|
});
|
|
25261
|
-
if (props.cacheStroke) stroke.cache({ pixelRatio: this.config.cachePixelRatio });
|
|
25262
25353
|
this.setupDefaultNodeAugmentation(stroke);
|
|
25263
25354
|
const defaultTransformerProperties = this.defaultGetTransformerProperties(this.config.transform);
|
|
25264
25355
|
stroke.getTransformerProperties = function() {
|
|
@@ -25268,18 +25359,14 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
25268
25359
|
return stroke;
|
|
25269
25360
|
}
|
|
25270
25361
|
onUpdate(nodeInstance, nextProps) {
|
|
25271
|
-
const actAttrs = nodeInstance.getAttrs();
|
|
25272
|
-
if (actAttrs.stroke !== nextProps.stroke || actAttrs.strokeWidth !== nextProps.strokeWidth || actAttrs.dash !== nextProps.dash) nodeInstance.clearCache();
|
|
25273
25362
|
nodeInstance.setAttrs({ ...nextProps });
|
|
25274
|
-
if (nextProps.cacheStroke) {
|
|
25275
|
-
nodeInstance.sceneFunc((ctx, shape) => {
|
|
25276
|
-
this.drawShape(ctx, shape);
|
|
25277
|
-
});
|
|
25278
|
-
nodeInstance.cache({ pixelRatio: this.config.cachePixelRatio });
|
|
25279
|
-
}
|
|
25280
25363
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
25281
25364
|
if (nodesSelectionPlugin) nodesSelectionPlugin.getTransformer().forceUpdate();
|
|
25282
25365
|
}
|
|
25366
|
+
getZoomPlugin() {
|
|
25367
|
+
const zoomPlugin = this.instance.getPlugin("stageZoom");
|
|
25368
|
+
return zoomPlugin;
|
|
25369
|
+
}
|
|
25283
25370
|
scaleReset(node) {
|
|
25284
25371
|
const strokeNode = node;
|
|
25285
25372
|
const oldPoints = [...strokeNode.getAttrs().strokeElements];
|
|
@@ -26909,8 +26996,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26909
26996
|
y: 0,
|
|
26910
26997
|
width: 0,
|
|
26911
26998
|
height: 0,
|
|
26912
|
-
strokeElements: newStrokeElements
|
|
26913
|
-
cacheStroke: false
|
|
26999
|
+
strokeElements: newStrokeElements
|
|
26914
27000
|
});
|
|
26915
27001
|
const nodeInstance = nodeHandler.onRender(node.props);
|
|
26916
27002
|
this.measureContainer?.add(nodeInstance);
|
|
@@ -26958,8 +27044,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
26958
27044
|
height: box.height,
|
|
26959
27045
|
x: box.x,
|
|
26960
27046
|
y: box.y,
|
|
26961
|
-
strokeElements: newStrokeElements
|
|
26962
|
-
cacheStroke: true
|
|
27047
|
+
strokeElements: newStrokeElements
|
|
26963
27048
|
});
|
|
26964
27049
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
26965
27050
|
if (realNode) realNode.destroy();
|
|
@@ -28571,7 +28656,8 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
28571
28656
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
28572
28657
|
if (e.evt.pointerType === "mouse" && e.evt.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
28573
28658
|
if (e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
28574
|
-
|
|
28659
|
+
const isTouchOrPen = ["touch", "pen"].includes(e.evt.pointerType);
|
|
28660
|
+
if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
|
|
28575
28661
|
if (this.enableMove) {
|
|
28576
28662
|
this.isDragging = true;
|
|
28577
28663
|
lastPos = stage.getPointerPosition();
|
|
@@ -28583,6 +28669,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
28583
28669
|
lastPos = null;
|
|
28584
28670
|
});
|
|
28585
28671
|
const handleMouseMove = (e) => {
|
|
28672
|
+
if (["touch", "pen"].includes(e.evt.pointerType) && e.evt.buttons !== 1) return;
|
|
28586
28673
|
this.pointers.set(e.evt.pointerId, {
|
|
28587
28674
|
x: e.evt.clientX,
|
|
28588
28675
|
y: e.evt.clientY
|
|
@@ -30071,6 +30158,7 @@ exports.WEAVE_LAYER_NODE_TYPE = WEAVE_LAYER_NODE_TYPE
|
|
|
30071
30158
|
exports.WEAVE_LINE_NODE_TYPE = WEAVE_LINE_NODE_TYPE
|
|
30072
30159
|
exports.WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY = WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY
|
|
30073
30160
|
exports.WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY = WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY
|
|
30161
|
+
exports.WEAVE_NODES_SELECTION_DEFAULT_CONFIG = WEAVE_NODES_SELECTION_DEFAULT_CONFIG
|
|
30074
30162
|
exports.WEAVE_NODES_SELECTION_KEY = WEAVE_NODES_SELECTION_KEY
|
|
30075
30163
|
exports.WEAVE_NODES_SELECTION_LAYER_ID = WEAVE_NODES_SELECTION_LAYER_ID
|
|
30076
30164
|
exports.WEAVE_RECTANGLE_NODE_TYPE = WEAVE_RECTANGLE_NODE_TYPE
|