@inditextech/weave-sdk 0.57.1 → 0.59.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 +206 -109
- package/dist/sdk.d.cts +66 -6
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +66 -6
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +205 -110
- 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.59.0";
|
|
21934
22027
|
|
|
21935
22028
|
//#endregion
|
|
21936
22029
|
//#region src/managers/setup.ts
|
|
@@ -23635,9 +23728,11 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23635
23728
|
const position = this.instance.getStage().getRelativePointerPosition();
|
|
23636
23729
|
this.instance.triggerAction(IMAGE_TOOL_ACTION_NAME, {
|
|
23637
23730
|
imageURL: window.weaveDragImageURL,
|
|
23731
|
+
imageId: window.weaveDragImageId,
|
|
23638
23732
|
position
|
|
23639
23733
|
});
|
|
23640
23734
|
window.weaveDragImageURL = void 0;
|
|
23735
|
+
window.weaveDragImageId = void 0;
|
|
23641
23736
|
}
|
|
23642
23737
|
});
|
|
23643
23738
|
}
|
|
@@ -23797,6 +23892,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
23797
23892
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
23798
23893
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
23799
23894
|
this.forceMainContainer = params?.forceMainContainer ?? false;
|
|
23895
|
+
if (params?.imageId) this.updateProps({ imageId: params.imageId });
|
|
23800
23896
|
if (params?.imageURL) {
|
|
23801
23897
|
this.loadImage(params.imageURL, params?.options ?? void 0, params?.position ?? void 0);
|
|
23802
23898
|
return;
|
|
@@ -24183,6 +24279,7 @@ const WEAVE_IMAGE_CROP_END_TYPE = {
|
|
|
24183
24279
|
["ACCEPT"]: "accept",
|
|
24184
24280
|
["CANCEL"]: "cancel"
|
|
24185
24281
|
};
|
|
24282
|
+
const WEAVE_IMAGE_DEFAULT_CONFIG = { crossOrigin: "anonymous" };
|
|
24186
24283
|
|
|
24187
24284
|
//#endregion
|
|
24188
24285
|
//#region src/nodes/image/image.ts
|
|
@@ -24197,16 +24294,15 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
24197
24294
|
time: 0
|
|
24198
24295
|
};
|
|
24199
24296
|
this.lastTapTime = 0;
|
|
24200
|
-
this.config =
|
|
24201
|
-
crossOrigin: config?.crossOrigin ?? "anonymous",
|
|
24202
|
-
transform: { ...config?.transform }
|
|
24203
|
-
};
|
|
24297
|
+
this.config = (0, import_lodash.merge)(WEAVE_IMAGE_DEFAULT_CONFIG, config);
|
|
24204
24298
|
this.imageCrop = null;
|
|
24205
24299
|
this.cachedCropInfo = {};
|
|
24206
24300
|
this.imageLoaded = false;
|
|
24207
24301
|
}
|
|
24208
24302
|
triggerCrop(imageNode) {
|
|
24209
24303
|
const stage = this.instance.getStage();
|
|
24304
|
+
if (imageNode.getAttrs().cropping ?? false) return;
|
|
24305
|
+
if (!(this.isSelecting() && this.isNodeSelected(imageNode))) return;
|
|
24210
24306
|
stage.mode("cropping");
|
|
24211
24307
|
const image = stage.findOne(`#${imageNode.getAttrs().id}`);
|
|
24212
24308
|
const internalImage = image?.findOne(`#${image.getAttrs().id}-image`);
|
|
@@ -24338,10 +24434,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
24338
24434
|
image.add(cropGroup);
|
|
24339
24435
|
this.setupDefaultNodeEvents(image);
|
|
24340
24436
|
image.dblClick = () => {
|
|
24341
|
-
|
|
24342
|
-
if (!internalImage.getAttr("image")) return;
|
|
24343
|
-
if (!(this.isSelecting() && this.isNodeSelected(image))) return;
|
|
24344
|
-
this.triggerCrop(image);
|
|
24437
|
+
this.config.onDblClick?.(this, image);
|
|
24345
24438
|
};
|
|
24346
24439
|
const imageActionTool = this.getImageToolAction();
|
|
24347
24440
|
const preloadImg = imageActionTool.getPreloadedImage(imageProps.id);
|
|
@@ -28563,7 +28656,8 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
28563
28656
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
28564
28657
|
if (e.evt.pointerType === "mouse" && e.evt.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
28565
28658
|
if (e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
28566
|
-
|
|
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;
|
|
28567
28661
|
if (this.enableMove) {
|
|
28568
28662
|
this.isDragging = true;
|
|
28569
28663
|
lastPos = stage.getPointerPosition();
|
|
@@ -28575,6 +28669,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
28575
28669
|
lastPos = null;
|
|
28576
28670
|
});
|
|
28577
28671
|
const handleMouseMove = (e) => {
|
|
28672
|
+
if (["touch", "pen"].includes(e.evt.pointerType) && e.evt.buttons !== 1) return;
|
|
28578
28673
|
this.pointers.set(e.evt.pointerId, {
|
|
28579
28674
|
x: e.evt.clientX,
|
|
28580
28675
|
y: e.evt.clientY
|
|
@@ -30058,11 +30153,13 @@ exports.WEAVE_GRID_LAYER_ID = WEAVE_GRID_LAYER_ID
|
|
|
30058
30153
|
exports.WEAVE_GRID_TYPES = WEAVE_GRID_TYPES
|
|
30059
30154
|
exports.WEAVE_GROUP_NODE_TYPE = WEAVE_GROUP_NODE_TYPE
|
|
30060
30155
|
exports.WEAVE_IMAGE_CROP_END_TYPE = WEAVE_IMAGE_CROP_END_TYPE
|
|
30156
|
+
exports.WEAVE_IMAGE_DEFAULT_CONFIG = WEAVE_IMAGE_DEFAULT_CONFIG
|
|
30061
30157
|
exports.WEAVE_IMAGE_NODE_TYPE = WEAVE_IMAGE_NODE_TYPE
|
|
30062
30158
|
exports.WEAVE_LAYER_NODE_TYPE = WEAVE_LAYER_NODE_TYPE
|
|
30063
30159
|
exports.WEAVE_LINE_NODE_TYPE = WEAVE_LINE_NODE_TYPE
|
|
30064
30160
|
exports.WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY = WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY
|
|
30065
30161
|
exports.WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY = WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY
|
|
30162
|
+
exports.WEAVE_NODES_SELECTION_DEFAULT_CONFIG = WEAVE_NODES_SELECTION_DEFAULT_CONFIG
|
|
30066
30163
|
exports.WEAVE_NODES_SELECTION_KEY = WEAVE_NODES_SELECTION_KEY
|
|
30067
30164
|
exports.WEAVE_NODES_SELECTION_LAYER_ID = WEAVE_NODES_SELECTION_LAYER_ID
|
|
30068
30165
|
exports.WEAVE_RECTANGLE_NODE_TYPE = WEAVE_RECTANGLE_NODE_TYPE
|