@inditextech/weave-sdk 3.9.1 → 3.9.2
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.js +107 -55
- package/dist/sdk.node.js +107 -55
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +27 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +107 -55
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +2 -2
package/dist/sdk.node.js
CHANGED
|
@@ -18833,7 +18833,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18833
18833
|
const nodesSelected = tr.nodes();
|
|
18834
18834
|
if (nodesSelected.length === 1) {
|
|
18835
18835
|
const node = nodesSelected[0];
|
|
18836
|
-
stage.container().style.cursor = node.defineMousePointer() ?? "grab";
|
|
18836
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
18837
18837
|
} else stage.container().style.cursor = "grab";
|
|
18838
18838
|
});
|
|
18839
18839
|
tr.on("mouseout", (e) => {
|
|
@@ -18890,8 +18890,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18890
18890
|
let selectedNodes = [];
|
|
18891
18891
|
tr.on("dragstart", (e) => {
|
|
18892
18892
|
this.dragInProcess = true;
|
|
18893
|
+
if (!e?.evt) return;
|
|
18893
18894
|
let isWheelMousePressed = false;
|
|
18894
|
-
if (e.evt
|
|
18895
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
18895
18896
|
const mainLayer = this.instance.getMainLayer();
|
|
18896
18897
|
if (!mainLayer) return;
|
|
18897
18898
|
initialPos = {
|
|
@@ -18928,7 +18929,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18928
18929
|
y: e.target.y()
|
|
18929
18930
|
};
|
|
18930
18931
|
let isWheelMousePressed = false;
|
|
18931
|
-
if (e.evt
|
|
18932
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
18932
18933
|
e.cancelBubble = true;
|
|
18933
18934
|
if (initialPos) {
|
|
18934
18935
|
const moved = this.checkMovedDrag(initialPos, actualPos);
|
|
@@ -19271,8 +19272,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19271
19272
|
this.handledClickOrTap = false;
|
|
19272
19273
|
this.pointers[e.evt.pointerId] = e.evt;
|
|
19273
19274
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19274
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19275
|
-
if (e.evt.pointerType === "pen" && e.evt
|
|
19275
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
19276
|
+
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
19276
19277
|
if (!this.initialized) return;
|
|
19277
19278
|
if (!this.active) return;
|
|
19278
19279
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
@@ -19325,8 +19326,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19325
19326
|
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19326
19327
|
});
|
|
19327
19328
|
const handleMouseMove = (e) => {
|
|
19329
|
+
if (!e?.evt) return;
|
|
19328
19330
|
const moved = this.checkMoved(e);
|
|
19329
|
-
if (e.evt
|
|
19331
|
+
if (e.evt?.buttons === 0) return;
|
|
19330
19332
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19331
19333
|
if (!this.initialized) return;
|
|
19332
19334
|
if (!this.active) return;
|
|
@@ -19496,7 +19498,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19496
19498
|
this.hideHoverState();
|
|
19497
19499
|
const selectedGroup = getTargetedNode(this.instance);
|
|
19498
19500
|
if (!this.initialized) return;
|
|
19499
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19501
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
|
|
19500
19502
|
let areNodesSelected = false;
|
|
19501
19503
|
let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
|
|
19502
19504
|
if (e.target === this.instance.getStage()) {
|
|
@@ -19559,7 +19561,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19559
19561
|
if (areNodesSelected) {
|
|
19560
19562
|
stage.container().tabIndex = 1;
|
|
19561
19563
|
stage.container().focus();
|
|
19562
|
-
stage.container().style.cursor = nodeTargeted.defineMousePointer() ?? "grab";
|
|
19564
|
+
stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
|
|
19563
19565
|
}
|
|
19564
19566
|
this.triggerSelectedNodesEvent();
|
|
19565
19567
|
}
|
|
@@ -19727,6 +19729,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
|
|
|
19727
19729
|
}
|
|
19728
19730
|
};
|
|
19729
19731
|
|
|
19732
|
+
//#endregion
|
|
19733
|
+
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
19734
|
+
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
19735
|
+
|
|
19730
19736
|
//#endregion
|
|
19731
19737
|
//#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
|
|
19732
19738
|
var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
@@ -19938,8 +19944,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
19938
19944
|
}
|
|
19939
19945
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
19940
19946
|
nodesSelectionPlugin?.setSelectedNodes(realNodes);
|
|
19941
|
-
this.instance?.triggerAction(
|
|
19942
|
-
previousAction:
|
|
19947
|
+
this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
|
|
19948
|
+
previousAction: SELECTION_TOOL_ACTION_NAME,
|
|
19943
19949
|
smartZoom: true
|
|
19944
19950
|
});
|
|
19945
19951
|
this.instance.emitEvent("onPaste", {
|
|
@@ -20214,6 +20220,33 @@ const augmentKonvaNodeClass = (config) => {
|
|
|
20214
20220
|
Konva.Node.prototype.closeCrop = function() {};
|
|
20215
20221
|
Konva.Node.prototype.resetCrop = function() {};
|
|
20216
20222
|
Konva.Node.prototype.dblClick = function() {};
|
|
20223
|
+
Konva.Node.prototype.allowedAnchors = function() {
|
|
20224
|
+
return [];
|
|
20225
|
+
};
|
|
20226
|
+
Konva.Node.prototype.isSelectable = function() {
|
|
20227
|
+
return true;
|
|
20228
|
+
};
|
|
20229
|
+
Konva.Node.prototype.handleMouseover = function() {};
|
|
20230
|
+
Konva.Node.prototype.handleMouseout = function() {};
|
|
20231
|
+
Konva.Node.prototype.handleSelectNode = function() {};
|
|
20232
|
+
Konva.Node.prototype.handleDeselectNode = function() {};
|
|
20233
|
+
Konva.Node.prototype.defineMousePointer = function() {
|
|
20234
|
+
return "default";
|
|
20235
|
+
};
|
|
20236
|
+
Konva.Node.prototype.canBeHovered = function() {
|
|
20237
|
+
return false;
|
|
20238
|
+
};
|
|
20239
|
+
Konva.Node.prototype.canDrag = function() {
|
|
20240
|
+
return false;
|
|
20241
|
+
};
|
|
20242
|
+
Konva.Node.prototype.canMoveToContainer = function() {
|
|
20243
|
+
return false;
|
|
20244
|
+
};
|
|
20245
|
+
Konva.Node.prototype.getNodeAnchors = function() {
|
|
20246
|
+
return [];
|
|
20247
|
+
};
|
|
20248
|
+
Konva.Node.prototype.lockMutex = function() {};
|
|
20249
|
+
Konva.Node.prototype.releaseMutex = function() {};
|
|
20217
20250
|
};
|
|
20218
20251
|
var WeaveNode = class {
|
|
20219
20252
|
async register(instance) {
|
|
@@ -20505,10 +20538,11 @@ var WeaveNode = class {
|
|
|
20505
20538
|
node.off("dragstart");
|
|
20506
20539
|
node.on("dragstart", (e) => {
|
|
20507
20540
|
const nodeTarget = e.target;
|
|
20541
|
+
if (!e.evt) return;
|
|
20508
20542
|
let isWheelMousePressed = false;
|
|
20509
|
-
if (e.evt
|
|
20543
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20510
20544
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
20511
|
-
const canMove = nodeTarget?.canDrag()
|
|
20545
|
+
const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
|
|
20512
20546
|
if (!canMove) {
|
|
20513
20547
|
nodeTarget.stopDrag();
|
|
20514
20548
|
return;
|
|
@@ -20560,7 +20594,7 @@ var WeaveNode = class {
|
|
|
20560
20594
|
nodesSelectionPlugin?.setSelectedNodes([]);
|
|
20561
20595
|
requestAnimationFrame(() => {
|
|
20562
20596
|
nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
|
|
20563
|
-
clone?.startDrag(e.evt);
|
|
20597
|
+
if (clone?.getStage()) clone.startDrag(e.evt);
|
|
20564
20598
|
});
|
|
20565
20599
|
}
|
|
20566
20600
|
if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
|
|
@@ -20571,7 +20605,7 @@ var WeaveNode = class {
|
|
|
20571
20605
|
const handleDragMove = (e) => {
|
|
20572
20606
|
const nodeTarget = e.target;
|
|
20573
20607
|
let isWheelMousePressed = false;
|
|
20574
|
-
if (e.evt
|
|
20608
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20575
20609
|
e.cancelBubble = true;
|
|
20576
20610
|
if (e.evt?.buttons === 0) {
|
|
20577
20611
|
nodeTarget.stopDrag();
|
|
@@ -20763,12 +20797,12 @@ var WeaveNode = class {
|
|
|
20763
20797
|
}
|
|
20764
20798
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20765
20799
|
showHover = true;
|
|
20766
|
-
stage.container().style.cursor =
|
|
20800
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
|
|
20767
20801
|
cancelBubble = true;
|
|
20768
20802
|
}
|
|
20769
20803
|
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20770
20804
|
showHover = true;
|
|
20771
|
-
stage.container().style.cursor =
|
|
20805
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
20772
20806
|
cancelBubble = true;
|
|
20773
20807
|
}
|
|
20774
20808
|
if (!isTargetable) cancelBubble = true;
|
|
@@ -22040,7 +22074,7 @@ var WeaveRegisterManager = class {
|
|
|
22040
22074
|
|
|
22041
22075
|
//#endregion
|
|
22042
22076
|
//#region package.json
|
|
22043
|
-
var version = "3.9.
|
|
22077
|
+
var version = "3.9.2";
|
|
22044
22078
|
|
|
22045
22079
|
//#endregion
|
|
22046
22080
|
//#region src/managers/setup.ts
|
|
@@ -24218,6 +24252,7 @@ function loadImageSource(image, options) {
|
|
|
24218
24252
|
}
|
|
24219
24253
|
async function downscaleImageFile(file, ratio) {
|
|
24220
24254
|
const bitmap = await createImageBitmap(file);
|
|
24255
|
+
if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
|
|
24221
24256
|
const width = Math.round(bitmap.width * ratio);
|
|
24222
24257
|
const height = Math.round(bitmap.height * ratio);
|
|
24223
24258
|
const canvas = document.createElement("canvas");
|
|
@@ -24234,13 +24269,19 @@ function getImageSizeFromFile(file) {
|
|
|
24234
24269
|
const img = new Image();
|
|
24235
24270
|
const url = URL.createObjectURL(file);
|
|
24236
24271
|
img.onload = () => {
|
|
24272
|
+
if (img.naturalWidth === 0) {
|
|
24273
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24274
|
+
return;
|
|
24275
|
+
}
|
|
24237
24276
|
resolve({
|
|
24238
24277
|
width: img.naturalWidth,
|
|
24239
24278
|
height: img.naturalHeight
|
|
24240
24279
|
});
|
|
24241
24280
|
URL.revokeObjectURL(url);
|
|
24242
24281
|
};
|
|
24243
|
-
img.onerror =
|
|
24282
|
+
img.onerror = () => {
|
|
24283
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24284
|
+
};
|
|
24244
24285
|
img.src = url;
|
|
24245
24286
|
});
|
|
24246
24287
|
}
|
|
@@ -24264,6 +24305,10 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24264
24305
|
const img = new Image();
|
|
24265
24306
|
img.crossOrigin = crossOrigin;
|
|
24266
24307
|
img.onload = () => {
|
|
24308
|
+
if (img.naturalWidth === 0) {
|
|
24309
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24310
|
+
return;
|
|
24311
|
+
}
|
|
24267
24312
|
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
|
|
24268
24313
|
const width = Math.round(img.width * ratio);
|
|
24269
24314
|
const height = Math.round(img.height * ratio);
|
|
@@ -24274,7 +24319,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24274
24319
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24275
24320
|
resolve(canvas.toDataURL(type));
|
|
24276
24321
|
};
|
|
24277
|
-
img.onerror =
|
|
24322
|
+
img.onerror = () => {
|
|
24323
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24324
|
+
};
|
|
24278
24325
|
img.src = url;
|
|
24279
24326
|
});
|
|
24280
24327
|
};
|
|
@@ -27032,15 +27079,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27032
27079
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27033
27080
|
this.imageFallback[imageId] = Konva.Util.createImageElement();
|
|
27034
27081
|
this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
|
|
27035
|
-
this.imageFallback[imageId].onerror = (
|
|
27082
|
+
this.imageFallback[imageId].onerror = () => {
|
|
27036
27083
|
this.imageState[imageId] = {
|
|
27037
27084
|
status: "error-fallback",
|
|
27038
27085
|
loaded: false,
|
|
27039
27086
|
error: true
|
|
27040
27087
|
};
|
|
27041
|
-
onError(
|
|
27088
|
+
onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
|
|
27042
27089
|
};
|
|
27043
27090
|
this.imageFallback[imageId].onload = async () => {
|
|
27091
|
+
if (this.imageFallback[imageId].width === 0) {
|
|
27092
|
+
this.imageState[imageId] = {
|
|
27093
|
+
status: "error-fallback",
|
|
27094
|
+
loaded: false,
|
|
27095
|
+
error: true
|
|
27096
|
+
};
|
|
27097
|
+
onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
|
|
27098
|
+
return;
|
|
27099
|
+
}
|
|
27044
27100
|
this.imageState[imageId] = {
|
|
27045
27101
|
status: "loading",
|
|
27046
27102
|
loaded: true,
|
|
@@ -27067,15 +27123,19 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27067
27123
|
}
|
|
27068
27124
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
27069
27125
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
27070
|
-
this.imageSource[imageId].onerror = (
|
|
27126
|
+
this.imageSource[imageId].onerror = () => {
|
|
27071
27127
|
if (!loadingTryout) {
|
|
27072
27128
|
const stage = this.instance.getStage();
|
|
27073
27129
|
const image = stage.findOne(`#${imageId}`);
|
|
27074
27130
|
if (image) this.setErrorState(imageId, image);
|
|
27075
27131
|
}
|
|
27076
|
-
onError(
|
|
27132
|
+
onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
|
|
27077
27133
|
};
|
|
27078
27134
|
this.imageSource[imageId].onload = async () => {
|
|
27135
|
+
if (this.imageSource[imageId].width === 0) {
|
|
27136
|
+
onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
|
|
27137
|
+
return;
|
|
27138
|
+
}
|
|
27079
27139
|
const stage = this.instance.getStage();
|
|
27080
27140
|
if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
|
|
27081
27141
|
this.imageState[imageId] = {
|
|
@@ -27167,14 +27227,16 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27167
27227
|
}
|
|
27168
27228
|
},
|
|
27169
27229
|
onError: (error) => {
|
|
27170
|
-
|
|
27230
|
+
let isInvalidImage = false;
|
|
27231
|
+
if (error.cause === "InvalidImage") isInvalidImage = true;
|
|
27232
|
+
if (!this.config.useFallbackImage && !isInvalidImage) {
|
|
27171
27233
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27172
27234
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27173
27235
|
this.loadImageTryout(id);
|
|
27174
27236
|
return;
|
|
27175
27237
|
} else this.setErrorState(id, image);
|
|
27176
27238
|
}
|
|
27177
|
-
if (loadTryout) {
|
|
27239
|
+
if (loadTryout && !isInvalidImage) {
|
|
27178
27240
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27179
27241
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27180
27242
|
this.loadImageTryout(id);
|
|
@@ -27187,12 +27249,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27187
27249
|
return;
|
|
27188
27250
|
}
|
|
27189
27251
|
this.setErrorState(id, image);
|
|
27190
|
-
image.setAttrs({ image: void 0 });
|
|
27191
|
-
console.error("Error loading image", error);
|
|
27192
27252
|
this.resolveAsyncElement(id);
|
|
27193
|
-
imagePlaceholder?.setAttrs({ visible: true });
|
|
27194
|
-
internalImage?.setAttrs({ visible: false });
|
|
27195
|
-
this.cacheNode(image);
|
|
27196
27253
|
}
|
|
27197
27254
|
}, loadTryout);
|
|
27198
27255
|
}
|
|
@@ -29684,8 +29741,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
29684
29741
|
this.videoPlaceholder[id] = Konva.Util.createImageElement();
|
|
29685
29742
|
this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
|
|
29686
29743
|
this.videoPlaceholder[id].src = realVideoPlaceholderURL;
|
|
29687
|
-
this.videoPlaceholder[id].onerror = (
|
|
29688
|
-
console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
|
|
29744
|
+
this.videoPlaceholder[id].onerror = () => {
|
|
29689
29745
|
this.resolveAsyncElement(id);
|
|
29690
29746
|
};
|
|
29691
29747
|
this.videoPlaceholder[id].onload = () => {
|
|
@@ -32723,13 +32779,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
|
32723
32779
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32724
32780
|
if (!stageZoomPlugin.canZoomOut()) return;
|
|
32725
32781
|
stageZoomPlugin.zoomOut();
|
|
32726
|
-
this.previousAction = params
|
|
32782
|
+
this.previousAction = params?.previousAction;
|
|
32727
32783
|
this.cancelAction = cancelAction;
|
|
32728
32784
|
this.cancelAction();
|
|
32729
32785
|
}
|
|
32730
32786
|
cleanup() {
|
|
32731
32787
|
const stage = this.instance.getStage();
|
|
32732
|
-
if (this.previousAction
|
|
32788
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32733
32789
|
stage.container().style.cursor = "default";
|
|
32734
32790
|
}
|
|
32735
32791
|
};
|
|
@@ -32761,13 +32817,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
|
|
|
32761
32817
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32762
32818
|
if (!stageZoomPlugin.canZoomIn()) return;
|
|
32763
32819
|
stageZoomPlugin.zoomIn();
|
|
32764
|
-
this.previousAction = params
|
|
32820
|
+
this.previousAction = params?.previousAction;
|
|
32765
32821
|
this.cancelAction = cancelAction;
|
|
32766
32822
|
this.cancelAction();
|
|
32767
32823
|
}
|
|
32768
32824
|
cleanup() {
|
|
32769
32825
|
const stage = this.instance.getStage();
|
|
32770
|
-
if (this.previousAction
|
|
32826
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32771
32827
|
stage.container().style.cursor = "default";
|
|
32772
32828
|
}
|
|
32773
32829
|
};
|
|
@@ -32798,21 +32854,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
|
32798
32854
|
trigger(cancelAction, params) {
|
|
32799
32855
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32800
32856
|
if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
|
|
32801
|
-
this.previousAction = params
|
|
32857
|
+
this.previousAction = params?.previousAction;
|
|
32802
32858
|
this.cancelAction = cancelAction;
|
|
32803
32859
|
this.cancelAction();
|
|
32804
32860
|
}
|
|
32805
32861
|
cleanup() {
|
|
32806
32862
|
const stage = this.instance.getStage();
|
|
32807
|
-
if (this.previousAction
|
|
32863
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32808
32864
|
stage.container().style.cursor = "default";
|
|
32809
32865
|
}
|
|
32810
32866
|
};
|
|
32811
32867
|
|
|
32812
|
-
//#endregion
|
|
32813
|
-
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
32814
|
-
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
32815
|
-
|
|
32816
32868
|
//#endregion
|
|
32817
32869
|
//#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
|
|
32818
32870
|
var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
@@ -32844,13 +32896,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
|
32844
32896
|
smartZoom: params?.smartZoom ?? false,
|
|
32845
32897
|
overrideZoom: params?.overrideZoom ?? true
|
|
32846
32898
|
});
|
|
32847
|
-
this.previousAction = params
|
|
32899
|
+
this.previousAction = params?.previousAction;
|
|
32848
32900
|
this.cancelAction = cancelAction;
|
|
32849
32901
|
this.cancelAction();
|
|
32850
32902
|
}
|
|
32851
32903
|
cleanup() {
|
|
32852
32904
|
const stage = this.instance.getStage();
|
|
32853
|
-
if (this.previousAction
|
|
32905
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32854
32906
|
stage.container().style.cursor = "default";
|
|
32855
32907
|
}
|
|
32856
32908
|
};
|
|
@@ -34134,7 +34186,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34134
34186
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
34135
34187
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34136
34188
|
if (this.isSpacePressed) return;
|
|
34137
|
-
if (e
|
|
34189
|
+
if (e?.evt?.button !== 0) return;
|
|
34138
34190
|
const pointPressure = this.getEventPressure(e);
|
|
34139
34191
|
this.handleStartStroke(pointPressure);
|
|
34140
34192
|
e.evt.stopPropagation();
|
|
@@ -37945,13 +37997,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
37945
37997
|
});
|
|
37946
37998
|
stage.on("pointerdown", (e) => {
|
|
37947
37999
|
const activeAction = this.instance.getActiveAction();
|
|
37948
|
-
if (e && e
|
|
37949
|
-
if (e && (e
|
|
38000
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
38001
|
+
if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
|
|
37950
38002
|
});
|
|
37951
38003
|
stage.on("pointerup", (e) => {
|
|
37952
38004
|
const activeAction = this.instance.getActiveAction();
|
|
37953
|
-
if (e && e
|
|
37954
|
-
if (e && (e
|
|
38005
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
|
|
38006
|
+
if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
|
|
37955
38007
|
});
|
|
37956
38008
|
const handleMouseMove = () => {
|
|
37957
38009
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
@@ -38272,16 +38324,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
38272
38324
|
let lastPos = null;
|
|
38273
38325
|
stage.on("pointerdown", (e) => {
|
|
38274
38326
|
this.pointers.set(e.evt.pointerId, {
|
|
38275
|
-
x: e
|
|
38276
|
-
y: e
|
|
38327
|
+
x: e?.evt?.clientX ?? 0,
|
|
38328
|
+
y: e?.evt?.clientY ?? 0
|
|
38277
38329
|
});
|
|
38278
38330
|
if (this.pointers.size > 1) return;
|
|
38279
38331
|
const activeAction = this.instance.getActiveAction();
|
|
38280
38332
|
this.enableMove = false;
|
|
38281
38333
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
38282
|
-
if (e.evt.pointerType === "mouse" && e
|
|
38283
|
-
if (e.evt.pointerType === "mouse" && e
|
|
38284
|
-
const isTouchOrPen = ["touch", "pen"].includes(e
|
|
38334
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
38335
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
38336
|
+
const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
|
|
38285
38337
|
if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
|
|
38286
38338
|
if (this.enableMove) {
|
|
38287
38339
|
this.isDragging = true;
|
|
@@ -38290,7 +38342,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
38290
38342
|
}
|
|
38291
38343
|
});
|
|
38292
38344
|
stage.on("pointercancel", (e) => {
|
|
38293
|
-
this.pointers.delete(e.evt.pointerId);
|
|
38345
|
+
if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
|
|
38294
38346
|
lastPos = null;
|
|
38295
38347
|
});
|
|
38296
38348
|
const handleMouseMove = (e) => {
|