@inditextech/weave-sdk 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.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 +2 -2
- 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.js
CHANGED
|
@@ -18953,7 +18953,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18953
18953
|
const nodesSelected = tr.nodes();
|
|
18954
18954
|
if (nodesSelected.length === 1) {
|
|
18955
18955
|
const node = nodesSelected[0];
|
|
18956
|
-
stage.container().style.cursor = node.defineMousePointer
|
|
18956
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
18957
18957
|
} else stage.container().style.cursor = "grab";
|
|
18958
18958
|
});
|
|
18959
18959
|
tr.on("mouseout", (e) => {
|
|
@@ -19016,8 +19016,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19016
19016
|
let selectedNodes = [];
|
|
19017
19017
|
tr.on("dragstart", (e) => {
|
|
19018
19018
|
this.dragInProcess = true;
|
|
19019
|
+
if (!e?.evt) return;
|
|
19019
19020
|
let isWheelMousePressed = false;
|
|
19020
|
-
if (e.evt
|
|
19021
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
19021
19022
|
const mainLayer = this.instance.getMainLayer();
|
|
19022
19023
|
if (!mainLayer) return;
|
|
19023
19024
|
initialPos = {
|
|
@@ -19058,7 +19059,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19058
19059
|
y: e.target.y()
|
|
19059
19060
|
};
|
|
19060
19061
|
let isWheelMousePressed = false;
|
|
19061
|
-
if (e.evt
|
|
19062
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
19062
19063
|
e.cancelBubble = true;
|
|
19063
19064
|
this.instance.getHooks().callHook("weave:onTransformerDragMove", {
|
|
19064
19065
|
e,
|
|
@@ -19415,8 +19416,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19415
19416
|
this.handledClickOrTap = false;
|
|
19416
19417
|
this.pointers[e.evt.pointerId] = e.evt;
|
|
19417
19418
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19418
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19419
|
-
if (e.evt.pointerType === "pen" && e.evt
|
|
19419
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
19420
|
+
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
19420
19421
|
if (!this.initialized) return;
|
|
19421
19422
|
if (!this.active) return;
|
|
19422
19423
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
@@ -19469,8 +19470,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19469
19470
|
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19470
19471
|
});
|
|
19471
19472
|
const handleMouseMove = (e) => {
|
|
19473
|
+
if (!e?.evt) return;
|
|
19472
19474
|
const moved = this.checkMoved(e);
|
|
19473
|
-
if (e.evt
|
|
19475
|
+
if (e.evt?.buttons === 0) return;
|
|
19474
19476
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19475
19477
|
if (!this.initialized) return;
|
|
19476
19478
|
if (!this.active) return;
|
|
@@ -19636,7 +19638,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19636
19638
|
this.hideHoverState();
|
|
19637
19639
|
const selectedGroup = getTargetedNode(this.instance);
|
|
19638
19640
|
if (!this.initialized) return;
|
|
19639
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19641
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
|
|
19640
19642
|
let areNodesSelected = false;
|
|
19641
19643
|
let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
|
|
19642
19644
|
if (e.target === this.instance.getStage()) {
|
|
@@ -19699,7 +19701,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19699
19701
|
if (areNodesSelected) {
|
|
19700
19702
|
stage.container().tabIndex = 1;
|
|
19701
19703
|
stage.container().focus();
|
|
19702
|
-
stage.container().style.cursor = nodeTargeted.defineMousePointer
|
|
19704
|
+
stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
|
|
19703
19705
|
}
|
|
19704
19706
|
this.triggerSelectedNodesEvent();
|
|
19705
19707
|
}
|
|
@@ -19859,6 +19861,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
|
|
|
19859
19861
|
}
|
|
19860
19862
|
};
|
|
19861
19863
|
|
|
19864
|
+
//#endregion
|
|
19865
|
+
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
19866
|
+
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
19867
|
+
|
|
19862
19868
|
//#endregion
|
|
19863
19869
|
//#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
|
|
19864
19870
|
var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
@@ -20070,8 +20076,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
20070
20076
|
}
|
|
20071
20077
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
20072
20078
|
nodesSelectionPlugin?.setSelectedNodes(realNodes);
|
|
20073
|
-
this.instance?.triggerAction(
|
|
20074
|
-
previousAction:
|
|
20079
|
+
this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
|
|
20080
|
+
previousAction: SELECTION_TOOL_ACTION_NAME,
|
|
20075
20081
|
smartZoom: true
|
|
20076
20082
|
});
|
|
20077
20083
|
this.instance.emitEvent("onPaste", {
|
|
@@ -20346,6 +20352,33 @@ const augmentKonvaNodeClass = (config) => {
|
|
|
20346
20352
|
Konva.Node.prototype.closeCrop = function() {};
|
|
20347
20353
|
Konva.Node.prototype.resetCrop = function() {};
|
|
20348
20354
|
Konva.Node.prototype.dblClick = function() {};
|
|
20355
|
+
Konva.Node.prototype.allowedAnchors = function() {
|
|
20356
|
+
return [];
|
|
20357
|
+
};
|
|
20358
|
+
Konva.Node.prototype.isSelectable = function() {
|
|
20359
|
+
return true;
|
|
20360
|
+
};
|
|
20361
|
+
Konva.Node.prototype.handleMouseover = function() {};
|
|
20362
|
+
Konva.Node.prototype.handleMouseout = function() {};
|
|
20363
|
+
Konva.Node.prototype.handleSelectNode = function() {};
|
|
20364
|
+
Konva.Node.prototype.handleDeselectNode = function() {};
|
|
20365
|
+
Konva.Node.prototype.defineMousePointer = function() {
|
|
20366
|
+
return "default";
|
|
20367
|
+
};
|
|
20368
|
+
Konva.Node.prototype.canBeHovered = function() {
|
|
20369
|
+
return false;
|
|
20370
|
+
};
|
|
20371
|
+
Konva.Node.prototype.canDrag = function() {
|
|
20372
|
+
return false;
|
|
20373
|
+
};
|
|
20374
|
+
Konva.Node.prototype.canMoveToContainer = function() {
|
|
20375
|
+
return false;
|
|
20376
|
+
};
|
|
20377
|
+
Konva.Node.prototype.getNodeAnchors = function() {
|
|
20378
|
+
return [];
|
|
20379
|
+
};
|
|
20380
|
+
Konva.Node.prototype.lockMutex = function() {};
|
|
20381
|
+
Konva.Node.prototype.releaseMutex = function() {};
|
|
20349
20382
|
};
|
|
20350
20383
|
var WeaveNode = class {
|
|
20351
20384
|
async register(instance) {
|
|
@@ -20630,10 +20663,11 @@ var WeaveNode = class {
|
|
|
20630
20663
|
node.off("dragstart");
|
|
20631
20664
|
node.on("dragstart", (e) => {
|
|
20632
20665
|
const nodeTarget = e.target;
|
|
20666
|
+
if (!e.evt) return;
|
|
20633
20667
|
let isWheelMousePressed = false;
|
|
20634
|
-
if (e.evt
|
|
20668
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20635
20669
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
20636
|
-
const canMove = nodeTarget?.canDrag()
|
|
20670
|
+
const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
|
|
20637
20671
|
if (!canMove) {
|
|
20638
20672
|
nodeTarget.stopDrag();
|
|
20639
20673
|
return;
|
|
@@ -20685,7 +20719,7 @@ var WeaveNode = class {
|
|
|
20685
20719
|
nodesSelectionPlugin?.setSelectedNodes([]);
|
|
20686
20720
|
requestAnimationFrame(() => {
|
|
20687
20721
|
nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
|
|
20688
|
-
clone?.startDrag(e.evt);
|
|
20722
|
+
if (clone?.getStage()) clone.startDrag(e.evt);
|
|
20689
20723
|
});
|
|
20690
20724
|
}
|
|
20691
20725
|
if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
|
|
@@ -20696,7 +20730,7 @@ var WeaveNode = class {
|
|
|
20696
20730
|
const handleDragMove = (e) => {
|
|
20697
20731
|
const nodeTarget = e.target;
|
|
20698
20732
|
let isWheelMousePressed = false;
|
|
20699
|
-
if (e.evt
|
|
20733
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20700
20734
|
e.cancelBubble = true;
|
|
20701
20735
|
if (e.evt?.buttons === 0) {
|
|
20702
20736
|
nodeTarget.stopDrag();
|
|
@@ -20884,12 +20918,12 @@ var WeaveNode = class {
|
|
|
20884
20918
|
}
|
|
20885
20919
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20886
20920
|
showHover = true;
|
|
20887
|
-
stage.container().style.cursor =
|
|
20921
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
|
|
20888
20922
|
cancelBubble = true;
|
|
20889
20923
|
}
|
|
20890
20924
|
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20891
20925
|
showHover = true;
|
|
20892
|
-
stage.container().style.cursor =
|
|
20926
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
20893
20927
|
cancelBubble = true;
|
|
20894
20928
|
}
|
|
20895
20929
|
if (!isTargetable) cancelBubble = true;
|
|
@@ -22153,7 +22187,7 @@ var WeaveRegisterManager = class {
|
|
|
22153
22187
|
|
|
22154
22188
|
//#endregion
|
|
22155
22189
|
//#region package.json
|
|
22156
|
-
var version = "4.0.
|
|
22190
|
+
var version = "4.0.1";
|
|
22157
22191
|
|
|
22158
22192
|
//#endregion
|
|
22159
22193
|
//#region src/managers/setup.ts
|
|
@@ -24294,6 +24328,7 @@ function loadImageSource(image, options) {
|
|
|
24294
24328
|
}
|
|
24295
24329
|
async function downscaleImageFile(file, ratio) {
|
|
24296
24330
|
const bitmap = await createImageBitmap(file);
|
|
24331
|
+
if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
|
|
24297
24332
|
const width = Math.round(bitmap.width * ratio);
|
|
24298
24333
|
const height = Math.round(bitmap.height * ratio);
|
|
24299
24334
|
const canvas = document.createElement("canvas");
|
|
@@ -24310,13 +24345,19 @@ function getImageSizeFromFile(file) {
|
|
|
24310
24345
|
const img = new Image();
|
|
24311
24346
|
const url = URL.createObjectURL(file);
|
|
24312
24347
|
img.onload = () => {
|
|
24348
|
+
if (img.naturalWidth === 0) {
|
|
24349
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24350
|
+
return;
|
|
24351
|
+
}
|
|
24313
24352
|
resolve({
|
|
24314
24353
|
width: img.naturalWidth,
|
|
24315
24354
|
height: img.naturalHeight
|
|
24316
24355
|
});
|
|
24317
24356
|
URL.revokeObjectURL(url);
|
|
24318
24357
|
};
|
|
24319
|
-
img.onerror =
|
|
24358
|
+
img.onerror = () => {
|
|
24359
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24360
|
+
};
|
|
24320
24361
|
img.src = url;
|
|
24321
24362
|
});
|
|
24322
24363
|
}
|
|
@@ -24340,6 +24381,10 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24340
24381
|
const img = new Image();
|
|
24341
24382
|
img.crossOrigin = crossOrigin;
|
|
24342
24383
|
img.onload = () => {
|
|
24384
|
+
if (img.naturalWidth === 0) {
|
|
24385
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24386
|
+
return;
|
|
24387
|
+
}
|
|
24343
24388
|
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
|
|
24344
24389
|
const width = Math.round(img.width * ratio);
|
|
24345
24390
|
const height = Math.round(img.height * ratio);
|
|
@@ -24350,7 +24395,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24350
24395
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24351
24396
|
resolve(canvas.toDataURL(type));
|
|
24352
24397
|
};
|
|
24353
|
-
img.onerror =
|
|
24398
|
+
img.onerror = () => {
|
|
24399
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24400
|
+
};
|
|
24354
24401
|
img.src = url;
|
|
24355
24402
|
});
|
|
24356
24403
|
};
|
|
@@ -27230,15 +27277,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27230
27277
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27231
27278
|
this.imageFallback[imageId] = Konva.Util.createImageElement();
|
|
27232
27279
|
this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
|
|
27233
|
-
this.imageFallback[imageId].onerror = (
|
|
27280
|
+
this.imageFallback[imageId].onerror = () => {
|
|
27234
27281
|
this.imageState[imageId] = {
|
|
27235
27282
|
status: "error-fallback",
|
|
27236
27283
|
loaded: false,
|
|
27237
27284
|
error: true
|
|
27238
27285
|
};
|
|
27239
|
-
onError(
|
|
27286
|
+
onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
|
|
27240
27287
|
};
|
|
27241
27288
|
this.imageFallback[imageId].onload = async () => {
|
|
27289
|
+
if (this.imageFallback[imageId].width === 0) {
|
|
27290
|
+
this.imageState[imageId] = {
|
|
27291
|
+
status: "error-fallback",
|
|
27292
|
+
loaded: false,
|
|
27293
|
+
error: true
|
|
27294
|
+
};
|
|
27295
|
+
onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
|
|
27296
|
+
return;
|
|
27297
|
+
}
|
|
27242
27298
|
this.imageState[imageId] = {
|
|
27243
27299
|
status: "loading",
|
|
27244
27300
|
loaded: true,
|
|
@@ -27265,15 +27321,19 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27265
27321
|
}
|
|
27266
27322
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
27267
27323
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
27268
|
-
this.imageSource[imageId].onerror = (
|
|
27324
|
+
this.imageSource[imageId].onerror = () => {
|
|
27269
27325
|
if (!loadingTryout) {
|
|
27270
27326
|
const stage = this.instance.getStage();
|
|
27271
27327
|
const image = stage.findOne(`#${imageId}`);
|
|
27272
27328
|
if (image) this.setErrorState(imageId, image);
|
|
27273
27329
|
}
|
|
27274
|
-
onError(
|
|
27330
|
+
onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
|
|
27275
27331
|
};
|
|
27276
27332
|
this.imageSource[imageId].onload = async () => {
|
|
27333
|
+
if (this.imageSource[imageId].width === 0) {
|
|
27334
|
+
onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
|
|
27335
|
+
return;
|
|
27336
|
+
}
|
|
27277
27337
|
const stage = this.instance.getStage();
|
|
27278
27338
|
if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
|
|
27279
27339
|
this.imageState[imageId] = {
|
|
@@ -27365,14 +27425,16 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27365
27425
|
}
|
|
27366
27426
|
},
|
|
27367
27427
|
onError: (error) => {
|
|
27368
|
-
|
|
27428
|
+
let isInvalidImage = false;
|
|
27429
|
+
if (error.cause === "InvalidImage") isInvalidImage = true;
|
|
27430
|
+
if (!this.config.useFallbackImage && !isInvalidImage) {
|
|
27369
27431
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27370
27432
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27371
27433
|
this.loadImageTryout(id);
|
|
27372
27434
|
return;
|
|
27373
27435
|
} else this.setErrorState(id, image);
|
|
27374
27436
|
}
|
|
27375
|
-
if (loadTryout) {
|
|
27437
|
+
if (loadTryout && !isInvalidImage) {
|
|
27376
27438
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27377
27439
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27378
27440
|
this.loadImageTryout(id);
|
|
@@ -27385,12 +27447,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27385
27447
|
return;
|
|
27386
27448
|
}
|
|
27387
27449
|
this.setErrorState(id, image);
|
|
27388
|
-
image.setAttrs({ image: void 0 });
|
|
27389
|
-
console.error("Error loading image", error);
|
|
27390
27450
|
this.resolveAsyncElement(id);
|
|
27391
|
-
imagePlaceholder?.setAttrs({ visible: true });
|
|
27392
|
-
internalImage?.setAttrs({ visible: false });
|
|
27393
|
-
this.cacheNode(image);
|
|
27394
27451
|
}
|
|
27395
27452
|
}, loadTryout);
|
|
27396
27453
|
}
|
|
@@ -30076,8 +30133,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
30076
30133
|
this.videoPlaceholder[id] = Konva.Util.createImageElement();
|
|
30077
30134
|
this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
|
|
30078
30135
|
this.videoPlaceholder[id].src = realVideoPlaceholderURL;
|
|
30079
|
-
this.videoPlaceholder[id].onerror = (
|
|
30080
|
-
console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
|
|
30136
|
+
this.videoPlaceholder[id].onerror = () => {
|
|
30081
30137
|
this.resolveAsyncElement(id);
|
|
30082
30138
|
};
|
|
30083
30139
|
this.videoPlaceholder[id].onload = () => {
|
|
@@ -33116,13 +33172,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
|
33116
33172
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
33117
33173
|
if (!stageZoomPlugin.canZoomOut()) return;
|
|
33118
33174
|
stageZoomPlugin.zoomOut();
|
|
33119
|
-
this.previousAction = params
|
|
33175
|
+
this.previousAction = params?.previousAction;
|
|
33120
33176
|
this.cancelAction = cancelAction;
|
|
33121
33177
|
this.cancelAction();
|
|
33122
33178
|
}
|
|
33123
33179
|
cleanup() {
|
|
33124
33180
|
const stage = this.instance.getStage();
|
|
33125
|
-
if (this.previousAction
|
|
33181
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33126
33182
|
stage.container().style.cursor = "default";
|
|
33127
33183
|
}
|
|
33128
33184
|
};
|
|
@@ -33154,13 +33210,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
|
|
|
33154
33210
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
33155
33211
|
if (!stageZoomPlugin.canZoomIn()) return;
|
|
33156
33212
|
stageZoomPlugin.zoomIn();
|
|
33157
|
-
this.previousAction = params
|
|
33213
|
+
this.previousAction = params?.previousAction;
|
|
33158
33214
|
this.cancelAction = cancelAction;
|
|
33159
33215
|
this.cancelAction();
|
|
33160
33216
|
}
|
|
33161
33217
|
cleanup() {
|
|
33162
33218
|
const stage = this.instance.getStage();
|
|
33163
|
-
if (this.previousAction
|
|
33219
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33164
33220
|
stage.container().style.cursor = "default";
|
|
33165
33221
|
}
|
|
33166
33222
|
};
|
|
@@ -33191,21 +33247,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
|
33191
33247
|
trigger(cancelAction, params) {
|
|
33192
33248
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
33193
33249
|
if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
|
|
33194
|
-
this.previousAction = params
|
|
33250
|
+
this.previousAction = params?.previousAction;
|
|
33195
33251
|
this.cancelAction = cancelAction;
|
|
33196
33252
|
this.cancelAction();
|
|
33197
33253
|
}
|
|
33198
33254
|
cleanup() {
|
|
33199
33255
|
const stage = this.instance.getStage();
|
|
33200
|
-
if (this.previousAction
|
|
33256
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33201
33257
|
stage.container().style.cursor = "default";
|
|
33202
33258
|
}
|
|
33203
33259
|
};
|
|
33204
33260
|
|
|
33205
|
-
//#endregion
|
|
33206
|
-
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
33207
|
-
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
33208
|
-
|
|
33209
33261
|
//#endregion
|
|
33210
33262
|
//#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
|
|
33211
33263
|
var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
@@ -33237,13 +33289,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
|
33237
33289
|
smartZoom: params?.smartZoom ?? false,
|
|
33238
33290
|
overrideZoom: params?.overrideZoom ?? true
|
|
33239
33291
|
});
|
|
33240
|
-
this.previousAction = params
|
|
33292
|
+
this.previousAction = params?.previousAction;
|
|
33241
33293
|
this.cancelAction = cancelAction;
|
|
33242
33294
|
this.cancelAction();
|
|
33243
33295
|
}
|
|
33244
33296
|
cleanup() {
|
|
33245
33297
|
const stage = this.instance.getStage();
|
|
33246
|
-
if (this.previousAction
|
|
33298
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33247
33299
|
stage.container().style.cursor = "default";
|
|
33248
33300
|
}
|
|
33249
33301
|
};
|
|
@@ -34527,7 +34579,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34527
34579
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
34528
34580
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34529
34581
|
if (this.isSpacePressed) return;
|
|
34530
|
-
if (e
|
|
34582
|
+
if (e?.evt?.button !== 0) return;
|
|
34531
34583
|
const pointPressure = this.getEventPressure(e);
|
|
34532
34584
|
this.handleStartStroke(pointPressure);
|
|
34533
34585
|
e.evt.stopPropagation();
|
|
@@ -39090,13 +39142,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
39090
39142
|
});
|
|
39091
39143
|
stage.on("pointerdown", (e) => {
|
|
39092
39144
|
const activeAction = this.instance.getActiveAction();
|
|
39093
|
-
if (e && e
|
|
39094
|
-
if (e && (e
|
|
39145
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
39146
|
+
if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
|
|
39095
39147
|
});
|
|
39096
39148
|
stage.on("pointerup", (e) => {
|
|
39097
39149
|
const activeAction = this.instance.getActiveAction();
|
|
39098
|
-
if (e && e
|
|
39099
|
-
if (e && (e
|
|
39150
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
|
|
39151
|
+
if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
|
|
39100
39152
|
});
|
|
39101
39153
|
const handleMouseMove = () => {
|
|
39102
39154
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
@@ -39413,16 +39465,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
39413
39465
|
let lastPos = null;
|
|
39414
39466
|
stage.on("pointerdown", (e) => {
|
|
39415
39467
|
this.pointers.set(e.evt.pointerId, {
|
|
39416
|
-
x: e
|
|
39417
|
-
y: e
|
|
39468
|
+
x: e?.evt?.clientX ?? 0,
|
|
39469
|
+
y: e?.evt?.clientY ?? 0
|
|
39418
39470
|
});
|
|
39419
39471
|
if (this.pointers.size > 1) return;
|
|
39420
39472
|
const activeAction = this.instance.getActiveAction();
|
|
39421
39473
|
this.enableMove = false;
|
|
39422
39474
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
39423
|
-
if (e.evt.pointerType === "mouse" && e
|
|
39424
|
-
if (e.evt.pointerType === "mouse" && e
|
|
39425
|
-
const isTouchOrPen = ["touch", "pen"].includes(e
|
|
39475
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
39476
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
39477
|
+
const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
|
|
39426
39478
|
if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
|
|
39427
39479
|
if (this.enableMove) {
|
|
39428
39480
|
this.isDragging = true;
|
|
@@ -39431,7 +39483,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
39431
39483
|
}
|
|
39432
39484
|
});
|
|
39433
39485
|
stage.on("pointercancel", (e) => {
|
|
39434
|
-
this.pointers.delete(e.evt.pointerId);
|
|
39486
|
+
if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
|
|
39435
39487
|
lastPos = null;
|
|
39436
39488
|
});
|
|
39437
39489
|
const handleMouseMove = (e) => {
|