@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/types.js
CHANGED
|
@@ -18834,7 +18834,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18834
18834
|
const nodesSelected = tr.nodes();
|
|
18835
18835
|
if (nodesSelected.length === 1) {
|
|
18836
18836
|
const node = nodesSelected[0];
|
|
18837
|
-
stage.container().style.cursor = node.defineMousePointer() ?? "grab";
|
|
18837
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
18838
18838
|
} else stage.container().style.cursor = "grab";
|
|
18839
18839
|
});
|
|
18840
18840
|
tr.on("mouseout", (e) => {
|
|
@@ -18891,8 +18891,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18891
18891
|
let selectedNodes = [];
|
|
18892
18892
|
tr.on("dragstart", (e) => {
|
|
18893
18893
|
this.dragInProcess = true;
|
|
18894
|
+
if (!e?.evt) return;
|
|
18894
18895
|
let isWheelMousePressed = false;
|
|
18895
|
-
if (e.evt
|
|
18896
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
18896
18897
|
const mainLayer = this.instance.getMainLayer();
|
|
18897
18898
|
if (!mainLayer) return;
|
|
18898
18899
|
initialPos = {
|
|
@@ -18929,7 +18930,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18929
18930
|
y: e.target.y()
|
|
18930
18931
|
};
|
|
18931
18932
|
let isWheelMousePressed = false;
|
|
18932
|
-
if (e.evt
|
|
18933
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
18933
18934
|
e.cancelBubble = true;
|
|
18934
18935
|
if (initialPos) {
|
|
18935
18936
|
const moved = this.checkMovedDrag(initialPos, actualPos);
|
|
@@ -19272,8 +19273,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19272
19273
|
this.handledClickOrTap = false;
|
|
19273
19274
|
this.pointers[e.evt.pointerId] = e.evt;
|
|
19274
19275
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19275
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19276
|
-
if (e.evt.pointerType === "pen" && e.evt
|
|
19276
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
19277
|
+
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
19277
19278
|
if (!this.initialized) return;
|
|
19278
19279
|
if (!this.active) return;
|
|
19279
19280
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
@@ -19326,8 +19327,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19326
19327
|
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19327
19328
|
});
|
|
19328
19329
|
const handleMouseMove = (e) => {
|
|
19330
|
+
if (!e?.evt) return;
|
|
19329
19331
|
const moved = this.checkMoved(e);
|
|
19330
|
-
if (e.evt
|
|
19332
|
+
if (e.evt?.buttons === 0) return;
|
|
19331
19333
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19332
19334
|
if (!this.initialized) return;
|
|
19333
19335
|
if (!this.active) return;
|
|
@@ -19497,7 +19499,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19497
19499
|
this.hideHoverState();
|
|
19498
19500
|
const selectedGroup = getTargetedNode(this.instance);
|
|
19499
19501
|
if (!this.initialized) return;
|
|
19500
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19502
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
|
|
19501
19503
|
let areNodesSelected = false;
|
|
19502
19504
|
let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
|
|
19503
19505
|
if (e.target === this.instance.getStage()) {
|
|
@@ -19560,7 +19562,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19560
19562
|
if (areNodesSelected) {
|
|
19561
19563
|
stage.container().tabIndex = 1;
|
|
19562
19564
|
stage.container().focus();
|
|
19563
|
-
stage.container().style.cursor = nodeTargeted.defineMousePointer() ?? "grab";
|
|
19565
|
+
stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
|
|
19564
19566
|
}
|
|
19565
19567
|
this.triggerSelectedNodesEvent();
|
|
19566
19568
|
}
|
|
@@ -19728,6 +19730,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
|
|
|
19728
19730
|
}
|
|
19729
19731
|
};
|
|
19730
19732
|
|
|
19733
|
+
//#endregion
|
|
19734
|
+
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
19735
|
+
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
19736
|
+
|
|
19731
19737
|
//#endregion
|
|
19732
19738
|
//#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
|
|
19733
19739
|
var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
@@ -19939,8 +19945,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
19939
19945
|
}
|
|
19940
19946
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
19941
19947
|
nodesSelectionPlugin?.setSelectedNodes(realNodes);
|
|
19942
|
-
this.instance?.triggerAction(
|
|
19943
|
-
previousAction:
|
|
19948
|
+
this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
|
|
19949
|
+
previousAction: SELECTION_TOOL_ACTION_NAME,
|
|
19944
19950
|
smartZoom: true
|
|
19945
19951
|
});
|
|
19946
19952
|
this.instance.emitEvent("onPaste", {
|
|
@@ -20215,6 +20221,33 @@ const augmentKonvaNodeClass = (config) => {
|
|
|
20215
20221
|
Konva.Node.prototype.closeCrop = function() {};
|
|
20216
20222
|
Konva.Node.prototype.resetCrop = function() {};
|
|
20217
20223
|
Konva.Node.prototype.dblClick = function() {};
|
|
20224
|
+
Konva.Node.prototype.allowedAnchors = function() {
|
|
20225
|
+
return [];
|
|
20226
|
+
};
|
|
20227
|
+
Konva.Node.prototype.isSelectable = function() {
|
|
20228
|
+
return true;
|
|
20229
|
+
};
|
|
20230
|
+
Konva.Node.prototype.handleMouseover = function() {};
|
|
20231
|
+
Konva.Node.prototype.handleMouseout = function() {};
|
|
20232
|
+
Konva.Node.prototype.handleSelectNode = function() {};
|
|
20233
|
+
Konva.Node.prototype.handleDeselectNode = function() {};
|
|
20234
|
+
Konva.Node.prototype.defineMousePointer = function() {
|
|
20235
|
+
return "default";
|
|
20236
|
+
};
|
|
20237
|
+
Konva.Node.prototype.canBeHovered = function() {
|
|
20238
|
+
return false;
|
|
20239
|
+
};
|
|
20240
|
+
Konva.Node.prototype.canDrag = function() {
|
|
20241
|
+
return false;
|
|
20242
|
+
};
|
|
20243
|
+
Konva.Node.prototype.canMoveToContainer = function() {
|
|
20244
|
+
return false;
|
|
20245
|
+
};
|
|
20246
|
+
Konva.Node.prototype.getNodeAnchors = function() {
|
|
20247
|
+
return [];
|
|
20248
|
+
};
|
|
20249
|
+
Konva.Node.prototype.lockMutex = function() {};
|
|
20250
|
+
Konva.Node.prototype.releaseMutex = function() {};
|
|
20218
20251
|
};
|
|
20219
20252
|
var WeaveNode = class {
|
|
20220
20253
|
async register(instance) {
|
|
@@ -20506,10 +20539,11 @@ var WeaveNode = class {
|
|
|
20506
20539
|
node.off("dragstart");
|
|
20507
20540
|
node.on("dragstart", (e) => {
|
|
20508
20541
|
const nodeTarget = e.target;
|
|
20542
|
+
if (!e.evt) return;
|
|
20509
20543
|
let isWheelMousePressed = false;
|
|
20510
|
-
if (e.evt
|
|
20544
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20511
20545
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
20512
|
-
const canMove = nodeTarget?.canDrag()
|
|
20546
|
+
const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
|
|
20513
20547
|
if (!canMove) {
|
|
20514
20548
|
nodeTarget.stopDrag();
|
|
20515
20549
|
return;
|
|
@@ -20561,7 +20595,7 @@ var WeaveNode = class {
|
|
|
20561
20595
|
nodesSelectionPlugin?.setSelectedNodes([]);
|
|
20562
20596
|
requestAnimationFrame(() => {
|
|
20563
20597
|
nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
|
|
20564
|
-
clone?.startDrag(e.evt);
|
|
20598
|
+
if (clone?.getStage()) clone.startDrag(e.evt);
|
|
20565
20599
|
});
|
|
20566
20600
|
}
|
|
20567
20601
|
if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
|
|
@@ -20572,7 +20606,7 @@ var WeaveNode = class {
|
|
|
20572
20606
|
const handleDragMove = (e) => {
|
|
20573
20607
|
const nodeTarget = e.target;
|
|
20574
20608
|
let isWheelMousePressed = false;
|
|
20575
|
-
if (e.evt
|
|
20609
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20576
20610
|
e.cancelBubble = true;
|
|
20577
20611
|
if (e.evt?.buttons === 0) {
|
|
20578
20612
|
nodeTarget.stopDrag();
|
|
@@ -20764,12 +20798,12 @@ var WeaveNode = class {
|
|
|
20764
20798
|
}
|
|
20765
20799
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20766
20800
|
showHover = true;
|
|
20767
|
-
stage.container().style.cursor =
|
|
20801
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
|
|
20768
20802
|
cancelBubble = true;
|
|
20769
20803
|
}
|
|
20770
20804
|
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20771
20805
|
showHover = true;
|
|
20772
|
-
stage.container().style.cursor =
|
|
20806
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
20773
20807
|
cancelBubble = true;
|
|
20774
20808
|
}
|
|
20775
20809
|
if (!isTargetable) cancelBubble = true;
|
|
@@ -22052,7 +22086,7 @@ var WeaveRegisterManager = class {
|
|
|
22052
22086
|
|
|
22053
22087
|
//#endregion
|
|
22054
22088
|
//#region package.json
|
|
22055
|
-
var version = "3.9.
|
|
22089
|
+
var version = "3.9.2";
|
|
22056
22090
|
|
|
22057
22091
|
//#endregion
|
|
22058
22092
|
//#region src/managers/setup.ts
|
|
@@ -24230,6 +24264,7 @@ function loadImageSource(image, options) {
|
|
|
24230
24264
|
}
|
|
24231
24265
|
async function downscaleImageFile(file, ratio) {
|
|
24232
24266
|
const bitmap = await createImageBitmap(file);
|
|
24267
|
+
if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
|
|
24233
24268
|
const width = Math.round(bitmap.width * ratio);
|
|
24234
24269
|
const height = Math.round(bitmap.height * ratio);
|
|
24235
24270
|
const canvas = document.createElement("canvas");
|
|
@@ -24246,13 +24281,19 @@ function getImageSizeFromFile(file) {
|
|
|
24246
24281
|
const img = new Image();
|
|
24247
24282
|
const url = URL.createObjectURL(file);
|
|
24248
24283
|
img.onload = () => {
|
|
24284
|
+
if (img.naturalWidth === 0) {
|
|
24285
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24286
|
+
return;
|
|
24287
|
+
}
|
|
24249
24288
|
resolve({
|
|
24250
24289
|
width: img.naturalWidth,
|
|
24251
24290
|
height: img.naturalHeight
|
|
24252
24291
|
});
|
|
24253
24292
|
URL.revokeObjectURL(url);
|
|
24254
24293
|
};
|
|
24255
|
-
img.onerror =
|
|
24294
|
+
img.onerror = () => {
|
|
24295
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24296
|
+
};
|
|
24256
24297
|
img.src = url;
|
|
24257
24298
|
});
|
|
24258
24299
|
}
|
|
@@ -24276,6 +24317,10 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24276
24317
|
const img = new Image();
|
|
24277
24318
|
img.crossOrigin = crossOrigin;
|
|
24278
24319
|
img.onload = () => {
|
|
24320
|
+
if (img.naturalWidth === 0) {
|
|
24321
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24322
|
+
return;
|
|
24323
|
+
}
|
|
24279
24324
|
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
|
|
24280
24325
|
const width = Math.round(img.width * ratio);
|
|
24281
24326
|
const height = Math.round(img.height * ratio);
|
|
@@ -24286,7 +24331,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24286
24331
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24287
24332
|
resolve(canvas.toDataURL(type));
|
|
24288
24333
|
};
|
|
24289
|
-
img.onerror =
|
|
24334
|
+
img.onerror = () => {
|
|
24335
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24336
|
+
};
|
|
24290
24337
|
img.src = url;
|
|
24291
24338
|
});
|
|
24292
24339
|
};
|
|
@@ -27044,15 +27091,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27044
27091
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27045
27092
|
this.imageFallback[imageId] = Konva.Util.createImageElement();
|
|
27046
27093
|
this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
|
|
27047
|
-
this.imageFallback[imageId].onerror = (
|
|
27094
|
+
this.imageFallback[imageId].onerror = () => {
|
|
27048
27095
|
this.imageState[imageId] = {
|
|
27049
27096
|
status: "error-fallback",
|
|
27050
27097
|
loaded: false,
|
|
27051
27098
|
error: true
|
|
27052
27099
|
};
|
|
27053
|
-
onError(
|
|
27100
|
+
onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
|
|
27054
27101
|
};
|
|
27055
27102
|
this.imageFallback[imageId].onload = async () => {
|
|
27103
|
+
if (this.imageFallback[imageId].width === 0) {
|
|
27104
|
+
this.imageState[imageId] = {
|
|
27105
|
+
status: "error-fallback",
|
|
27106
|
+
loaded: false,
|
|
27107
|
+
error: true
|
|
27108
|
+
};
|
|
27109
|
+
onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
|
|
27110
|
+
return;
|
|
27111
|
+
}
|
|
27056
27112
|
this.imageState[imageId] = {
|
|
27057
27113
|
status: "loading",
|
|
27058
27114
|
loaded: true,
|
|
@@ -27079,15 +27135,19 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27079
27135
|
}
|
|
27080
27136
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
27081
27137
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
27082
|
-
this.imageSource[imageId].onerror = (
|
|
27138
|
+
this.imageSource[imageId].onerror = () => {
|
|
27083
27139
|
if (!loadingTryout) {
|
|
27084
27140
|
const stage = this.instance.getStage();
|
|
27085
27141
|
const image = stage.findOne(`#${imageId}`);
|
|
27086
27142
|
if (image) this.setErrorState(imageId, image);
|
|
27087
27143
|
}
|
|
27088
|
-
onError(
|
|
27144
|
+
onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
|
|
27089
27145
|
};
|
|
27090
27146
|
this.imageSource[imageId].onload = async () => {
|
|
27147
|
+
if (this.imageSource[imageId].width === 0) {
|
|
27148
|
+
onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
|
|
27149
|
+
return;
|
|
27150
|
+
}
|
|
27091
27151
|
const stage = this.instance.getStage();
|
|
27092
27152
|
if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
|
|
27093
27153
|
this.imageState[imageId] = {
|
|
@@ -27179,14 +27239,16 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27179
27239
|
}
|
|
27180
27240
|
},
|
|
27181
27241
|
onError: (error) => {
|
|
27182
|
-
|
|
27242
|
+
let isInvalidImage = false;
|
|
27243
|
+
if (error.cause === "InvalidImage") isInvalidImage = true;
|
|
27244
|
+
if (!this.config.useFallbackImage && !isInvalidImage) {
|
|
27183
27245
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27184
27246
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27185
27247
|
this.loadImageTryout(id);
|
|
27186
27248
|
return;
|
|
27187
27249
|
} else this.setErrorState(id, image);
|
|
27188
27250
|
}
|
|
27189
|
-
if (loadTryout) {
|
|
27251
|
+
if (loadTryout && !isInvalidImage) {
|
|
27190
27252
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27191
27253
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27192
27254
|
this.loadImageTryout(id);
|
|
@@ -27199,12 +27261,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27199
27261
|
return;
|
|
27200
27262
|
}
|
|
27201
27263
|
this.setErrorState(id, image);
|
|
27202
|
-
image.setAttrs({ image: void 0 });
|
|
27203
|
-
console.error("Error loading image", error);
|
|
27204
27264
|
this.resolveAsyncElement(id);
|
|
27205
|
-
imagePlaceholder?.setAttrs({ visible: true });
|
|
27206
|
-
internalImage?.setAttrs({ visible: false });
|
|
27207
|
-
this.cacheNode(image);
|
|
27208
27265
|
}
|
|
27209
27266
|
}, loadTryout);
|
|
27210
27267
|
}
|
|
@@ -29696,8 +29753,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
29696
29753
|
this.videoPlaceholder[id] = Konva.Util.createImageElement();
|
|
29697
29754
|
this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
|
|
29698
29755
|
this.videoPlaceholder[id].src = realVideoPlaceholderURL;
|
|
29699
|
-
this.videoPlaceholder[id].onerror = (
|
|
29700
|
-
console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
|
|
29756
|
+
this.videoPlaceholder[id].onerror = () => {
|
|
29701
29757
|
this.resolveAsyncElement(id);
|
|
29702
29758
|
};
|
|
29703
29759
|
this.videoPlaceholder[id].onload = () => {
|
|
@@ -32735,13 +32791,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
|
32735
32791
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32736
32792
|
if (!stageZoomPlugin.canZoomOut()) return;
|
|
32737
32793
|
stageZoomPlugin.zoomOut();
|
|
32738
|
-
this.previousAction = params
|
|
32794
|
+
this.previousAction = params?.previousAction;
|
|
32739
32795
|
this.cancelAction = cancelAction;
|
|
32740
32796
|
this.cancelAction();
|
|
32741
32797
|
}
|
|
32742
32798
|
cleanup() {
|
|
32743
32799
|
const stage = this.instance.getStage();
|
|
32744
|
-
if (this.previousAction
|
|
32800
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32745
32801
|
stage.container().style.cursor = "default";
|
|
32746
32802
|
}
|
|
32747
32803
|
};
|
|
@@ -32773,13 +32829,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
|
|
|
32773
32829
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32774
32830
|
if (!stageZoomPlugin.canZoomIn()) return;
|
|
32775
32831
|
stageZoomPlugin.zoomIn();
|
|
32776
|
-
this.previousAction = params
|
|
32832
|
+
this.previousAction = params?.previousAction;
|
|
32777
32833
|
this.cancelAction = cancelAction;
|
|
32778
32834
|
this.cancelAction();
|
|
32779
32835
|
}
|
|
32780
32836
|
cleanup() {
|
|
32781
32837
|
const stage = this.instance.getStage();
|
|
32782
|
-
if (this.previousAction
|
|
32838
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32783
32839
|
stage.container().style.cursor = "default";
|
|
32784
32840
|
}
|
|
32785
32841
|
};
|
|
@@ -32810,21 +32866,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
|
32810
32866
|
trigger(cancelAction, params) {
|
|
32811
32867
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32812
32868
|
if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
|
|
32813
|
-
this.previousAction = params
|
|
32869
|
+
this.previousAction = params?.previousAction;
|
|
32814
32870
|
this.cancelAction = cancelAction;
|
|
32815
32871
|
this.cancelAction();
|
|
32816
32872
|
}
|
|
32817
32873
|
cleanup() {
|
|
32818
32874
|
const stage = this.instance.getStage();
|
|
32819
|
-
if (this.previousAction
|
|
32875
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32820
32876
|
stage.container().style.cursor = "default";
|
|
32821
32877
|
}
|
|
32822
32878
|
};
|
|
32823
32879
|
|
|
32824
|
-
//#endregion
|
|
32825
|
-
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
32826
|
-
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
32827
|
-
|
|
32828
32880
|
//#endregion
|
|
32829
32881
|
//#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
|
|
32830
32882
|
var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
@@ -32856,13 +32908,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
|
32856
32908
|
smartZoom: params?.smartZoom ?? false,
|
|
32857
32909
|
overrideZoom: params?.overrideZoom ?? true
|
|
32858
32910
|
});
|
|
32859
|
-
this.previousAction = params
|
|
32911
|
+
this.previousAction = params?.previousAction;
|
|
32860
32912
|
this.cancelAction = cancelAction;
|
|
32861
32913
|
this.cancelAction();
|
|
32862
32914
|
}
|
|
32863
32915
|
cleanup() {
|
|
32864
32916
|
const stage = this.instance.getStage();
|
|
32865
|
-
if (this.previousAction
|
|
32917
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32866
32918
|
stage.container().style.cursor = "default";
|
|
32867
32919
|
}
|
|
32868
32920
|
};
|
|
@@ -34146,7 +34198,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34146
34198
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
34147
34199
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34148
34200
|
if (this.isSpacePressed) return;
|
|
34149
|
-
if (e
|
|
34201
|
+
if (e?.evt?.button !== 0) return;
|
|
34150
34202
|
const pointPressure = this.getEventPressure(e);
|
|
34151
34203
|
this.handleStartStroke(pointPressure);
|
|
34152
34204
|
e.evt.stopPropagation();
|
|
@@ -38003,13 +38055,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
38003
38055
|
});
|
|
38004
38056
|
stage.on("pointerdown", (e) => {
|
|
38005
38057
|
const activeAction = this.instance.getActiveAction();
|
|
38006
|
-
if (e && e
|
|
38007
|
-
if (e && (e
|
|
38058
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
38059
|
+
if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
|
|
38008
38060
|
});
|
|
38009
38061
|
stage.on("pointerup", (e) => {
|
|
38010
38062
|
const activeAction = this.instance.getActiveAction();
|
|
38011
|
-
if (e && e
|
|
38012
|
-
if (e && (e
|
|
38063
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
|
|
38064
|
+
if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
|
|
38013
38065
|
});
|
|
38014
38066
|
const handleMouseMove = () => {
|
|
38015
38067
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
@@ -38330,16 +38382,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
38330
38382
|
let lastPos = null;
|
|
38331
38383
|
stage.on("pointerdown", (e) => {
|
|
38332
38384
|
this.pointers.set(e.evt.pointerId, {
|
|
38333
|
-
x: e
|
|
38334
|
-
y: e
|
|
38385
|
+
x: e?.evt?.clientX ?? 0,
|
|
38386
|
+
y: e?.evt?.clientY ?? 0
|
|
38335
38387
|
});
|
|
38336
38388
|
if (this.pointers.size > 1) return;
|
|
38337
38389
|
const activeAction = this.instance.getActiveAction();
|
|
38338
38390
|
this.enableMove = false;
|
|
38339
38391
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
38340
|
-
if (e.evt.pointerType === "mouse" && e
|
|
38341
|
-
if (e.evt.pointerType === "mouse" && e
|
|
38342
|
-
const isTouchOrPen = ["touch", "pen"].includes(e
|
|
38392
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
38393
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
38394
|
+
const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
|
|
38343
38395
|
if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
|
|
38344
38396
|
if (this.enableMove) {
|
|
38345
38397
|
this.isDragging = true;
|
|
@@ -38348,7 +38400,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
38348
38400
|
}
|
|
38349
38401
|
});
|
|
38350
38402
|
stage.on("pointercancel", (e) => {
|
|
38351
|
-
this.pointers.delete(e.evt.pointerId);
|
|
38403
|
+
if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
|
|
38352
38404
|
lastPos = null;
|
|
38353
38405
|
});
|
|
38354
38406
|
const handleMouseMove = (e) => {
|