@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/types.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;
|
|
@@ -22164,7 +22198,7 @@ var WeaveRegisterManager = class {
|
|
|
22164
22198
|
|
|
22165
22199
|
//#endregion
|
|
22166
22200
|
//#region package.json
|
|
22167
|
-
var version = "4.0.
|
|
22201
|
+
var version = "4.0.1";
|
|
22168
22202
|
|
|
22169
22203
|
//#endregion
|
|
22170
22204
|
//#region src/managers/setup.ts
|
|
@@ -24305,6 +24339,7 @@ function loadImageSource(image, options) {
|
|
|
24305
24339
|
}
|
|
24306
24340
|
async function downscaleImageFile(file, ratio) {
|
|
24307
24341
|
const bitmap = await createImageBitmap(file);
|
|
24342
|
+
if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
|
|
24308
24343
|
const width = Math.round(bitmap.width * ratio);
|
|
24309
24344
|
const height = Math.round(bitmap.height * ratio);
|
|
24310
24345
|
const canvas = document.createElement("canvas");
|
|
@@ -24321,13 +24356,19 @@ function getImageSizeFromFile(file) {
|
|
|
24321
24356
|
const img = new Image();
|
|
24322
24357
|
const url = URL.createObjectURL(file);
|
|
24323
24358
|
img.onload = () => {
|
|
24359
|
+
if (img.naturalWidth === 0) {
|
|
24360
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24361
|
+
return;
|
|
24362
|
+
}
|
|
24324
24363
|
resolve({
|
|
24325
24364
|
width: img.naturalWidth,
|
|
24326
24365
|
height: img.naturalHeight
|
|
24327
24366
|
});
|
|
24328
24367
|
URL.revokeObjectURL(url);
|
|
24329
24368
|
};
|
|
24330
|
-
img.onerror =
|
|
24369
|
+
img.onerror = () => {
|
|
24370
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24371
|
+
};
|
|
24331
24372
|
img.src = url;
|
|
24332
24373
|
});
|
|
24333
24374
|
}
|
|
@@ -24351,6 +24392,10 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24351
24392
|
const img = new Image();
|
|
24352
24393
|
img.crossOrigin = crossOrigin;
|
|
24353
24394
|
img.onload = () => {
|
|
24395
|
+
if (img.naturalWidth === 0) {
|
|
24396
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24397
|
+
return;
|
|
24398
|
+
}
|
|
24354
24399
|
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
|
|
24355
24400
|
const width = Math.round(img.width * ratio);
|
|
24356
24401
|
const height = Math.round(img.height * ratio);
|
|
@@ -24361,7 +24406,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24361
24406
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24362
24407
|
resolve(canvas.toDataURL(type));
|
|
24363
24408
|
};
|
|
24364
|
-
img.onerror =
|
|
24409
|
+
img.onerror = () => {
|
|
24410
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24411
|
+
};
|
|
24365
24412
|
img.src = url;
|
|
24366
24413
|
});
|
|
24367
24414
|
};
|
|
@@ -27241,15 +27288,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27241
27288
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27242
27289
|
this.imageFallback[imageId] = Konva.Util.createImageElement();
|
|
27243
27290
|
this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
|
|
27244
|
-
this.imageFallback[imageId].onerror = (
|
|
27291
|
+
this.imageFallback[imageId].onerror = () => {
|
|
27245
27292
|
this.imageState[imageId] = {
|
|
27246
27293
|
status: "error-fallback",
|
|
27247
27294
|
loaded: false,
|
|
27248
27295
|
error: true
|
|
27249
27296
|
};
|
|
27250
|
-
onError(
|
|
27297
|
+
onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
|
|
27251
27298
|
};
|
|
27252
27299
|
this.imageFallback[imageId].onload = async () => {
|
|
27300
|
+
if (this.imageFallback[imageId].width === 0) {
|
|
27301
|
+
this.imageState[imageId] = {
|
|
27302
|
+
status: "error-fallback",
|
|
27303
|
+
loaded: false,
|
|
27304
|
+
error: true
|
|
27305
|
+
};
|
|
27306
|
+
onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
|
|
27307
|
+
return;
|
|
27308
|
+
}
|
|
27253
27309
|
this.imageState[imageId] = {
|
|
27254
27310
|
status: "loading",
|
|
27255
27311
|
loaded: true,
|
|
@@ -27276,15 +27332,19 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27276
27332
|
}
|
|
27277
27333
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
27278
27334
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
27279
|
-
this.imageSource[imageId].onerror = (
|
|
27335
|
+
this.imageSource[imageId].onerror = () => {
|
|
27280
27336
|
if (!loadingTryout) {
|
|
27281
27337
|
const stage = this.instance.getStage();
|
|
27282
27338
|
const image = stage.findOne(`#${imageId}`);
|
|
27283
27339
|
if (image) this.setErrorState(imageId, image);
|
|
27284
27340
|
}
|
|
27285
|
-
onError(
|
|
27341
|
+
onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
|
|
27286
27342
|
};
|
|
27287
27343
|
this.imageSource[imageId].onload = async () => {
|
|
27344
|
+
if (this.imageSource[imageId].width === 0) {
|
|
27345
|
+
onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
|
|
27346
|
+
return;
|
|
27347
|
+
}
|
|
27288
27348
|
const stage = this.instance.getStage();
|
|
27289
27349
|
if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
|
|
27290
27350
|
this.imageState[imageId] = {
|
|
@@ -27376,14 +27436,16 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27376
27436
|
}
|
|
27377
27437
|
},
|
|
27378
27438
|
onError: (error) => {
|
|
27379
|
-
|
|
27439
|
+
let isInvalidImage = false;
|
|
27440
|
+
if (error.cause === "InvalidImage") isInvalidImage = true;
|
|
27441
|
+
if (!this.config.useFallbackImage && !isInvalidImage) {
|
|
27380
27442
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27381
27443
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27382
27444
|
this.loadImageTryout(id);
|
|
27383
27445
|
return;
|
|
27384
27446
|
} else this.setErrorState(id, image);
|
|
27385
27447
|
}
|
|
27386
|
-
if (loadTryout) {
|
|
27448
|
+
if (loadTryout && !isInvalidImage) {
|
|
27387
27449
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27388
27450
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27389
27451
|
this.loadImageTryout(id);
|
|
@@ -27396,12 +27458,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27396
27458
|
return;
|
|
27397
27459
|
}
|
|
27398
27460
|
this.setErrorState(id, image);
|
|
27399
|
-
image.setAttrs({ image: void 0 });
|
|
27400
|
-
console.error("Error loading image", error);
|
|
27401
27461
|
this.resolveAsyncElement(id);
|
|
27402
|
-
imagePlaceholder?.setAttrs({ visible: true });
|
|
27403
|
-
internalImage?.setAttrs({ visible: false });
|
|
27404
|
-
this.cacheNode(image);
|
|
27405
27462
|
}
|
|
27406
27463
|
}, loadTryout);
|
|
27407
27464
|
}
|
|
@@ -30087,8 +30144,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
30087
30144
|
this.videoPlaceholder[id] = Konva.Util.createImageElement();
|
|
30088
30145
|
this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
|
|
30089
30146
|
this.videoPlaceholder[id].src = realVideoPlaceholderURL;
|
|
30090
|
-
this.videoPlaceholder[id].onerror = (
|
|
30091
|
-
console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
|
|
30147
|
+
this.videoPlaceholder[id].onerror = () => {
|
|
30092
30148
|
this.resolveAsyncElement(id);
|
|
30093
30149
|
};
|
|
30094
30150
|
this.videoPlaceholder[id].onload = () => {
|
|
@@ -33127,13 +33183,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
|
33127
33183
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
33128
33184
|
if (!stageZoomPlugin.canZoomOut()) return;
|
|
33129
33185
|
stageZoomPlugin.zoomOut();
|
|
33130
|
-
this.previousAction = params
|
|
33186
|
+
this.previousAction = params?.previousAction;
|
|
33131
33187
|
this.cancelAction = cancelAction;
|
|
33132
33188
|
this.cancelAction();
|
|
33133
33189
|
}
|
|
33134
33190
|
cleanup() {
|
|
33135
33191
|
const stage = this.instance.getStage();
|
|
33136
|
-
if (this.previousAction
|
|
33192
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33137
33193
|
stage.container().style.cursor = "default";
|
|
33138
33194
|
}
|
|
33139
33195
|
};
|
|
@@ -33165,13 +33221,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
|
|
|
33165
33221
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
33166
33222
|
if (!stageZoomPlugin.canZoomIn()) return;
|
|
33167
33223
|
stageZoomPlugin.zoomIn();
|
|
33168
|
-
this.previousAction = params
|
|
33224
|
+
this.previousAction = params?.previousAction;
|
|
33169
33225
|
this.cancelAction = cancelAction;
|
|
33170
33226
|
this.cancelAction();
|
|
33171
33227
|
}
|
|
33172
33228
|
cleanup() {
|
|
33173
33229
|
const stage = this.instance.getStage();
|
|
33174
|
-
if (this.previousAction
|
|
33230
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33175
33231
|
stage.container().style.cursor = "default";
|
|
33176
33232
|
}
|
|
33177
33233
|
};
|
|
@@ -33202,21 +33258,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
|
33202
33258
|
trigger(cancelAction, params) {
|
|
33203
33259
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
33204
33260
|
if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
|
|
33205
|
-
this.previousAction = params
|
|
33261
|
+
this.previousAction = params?.previousAction;
|
|
33206
33262
|
this.cancelAction = cancelAction;
|
|
33207
33263
|
this.cancelAction();
|
|
33208
33264
|
}
|
|
33209
33265
|
cleanup() {
|
|
33210
33266
|
const stage = this.instance.getStage();
|
|
33211
|
-
if (this.previousAction
|
|
33267
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33212
33268
|
stage.container().style.cursor = "default";
|
|
33213
33269
|
}
|
|
33214
33270
|
};
|
|
33215
33271
|
|
|
33216
|
-
//#endregion
|
|
33217
|
-
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
33218
|
-
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
33219
|
-
|
|
33220
33272
|
//#endregion
|
|
33221
33273
|
//#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
|
|
33222
33274
|
var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
@@ -33248,13 +33300,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
|
33248
33300
|
smartZoom: params?.smartZoom ?? false,
|
|
33249
33301
|
overrideZoom: params?.overrideZoom ?? true
|
|
33250
33302
|
});
|
|
33251
|
-
this.previousAction = params
|
|
33303
|
+
this.previousAction = params?.previousAction;
|
|
33252
33304
|
this.cancelAction = cancelAction;
|
|
33253
33305
|
this.cancelAction();
|
|
33254
33306
|
}
|
|
33255
33307
|
cleanup() {
|
|
33256
33308
|
const stage = this.instance.getStage();
|
|
33257
|
-
if (this.previousAction
|
|
33309
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
33258
33310
|
stage.container().style.cursor = "default";
|
|
33259
33311
|
}
|
|
33260
33312
|
};
|
|
@@ -34538,7 +34590,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34538
34590
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
34539
34591
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34540
34592
|
if (this.isSpacePressed) return;
|
|
34541
|
-
if (e
|
|
34593
|
+
if (e?.evt?.button !== 0) return;
|
|
34542
34594
|
const pointPressure = this.getEventPressure(e);
|
|
34543
34595
|
this.handleStartStroke(pointPressure);
|
|
34544
34596
|
e.evt.stopPropagation();
|
|
@@ -39147,13 +39199,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
39147
39199
|
});
|
|
39148
39200
|
stage.on("pointerdown", (e) => {
|
|
39149
39201
|
const activeAction = this.instance.getActiveAction();
|
|
39150
|
-
if (e && e
|
|
39151
|
-
if (e && (e
|
|
39202
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
39203
|
+
if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
|
|
39152
39204
|
});
|
|
39153
39205
|
stage.on("pointerup", (e) => {
|
|
39154
39206
|
const activeAction = this.instance.getActiveAction();
|
|
39155
|
-
if (e && e
|
|
39156
|
-
if (e && (e
|
|
39207
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
|
|
39208
|
+
if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
|
|
39157
39209
|
});
|
|
39158
39210
|
const handleMouseMove = () => {
|
|
39159
39211
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
@@ -39470,16 +39522,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
39470
39522
|
let lastPos = null;
|
|
39471
39523
|
stage.on("pointerdown", (e) => {
|
|
39472
39524
|
this.pointers.set(e.evt.pointerId, {
|
|
39473
|
-
x: e
|
|
39474
|
-
y: e
|
|
39525
|
+
x: e?.evt?.clientX ?? 0,
|
|
39526
|
+
y: e?.evt?.clientY ?? 0
|
|
39475
39527
|
});
|
|
39476
39528
|
if (this.pointers.size > 1) return;
|
|
39477
39529
|
const activeAction = this.instance.getActiveAction();
|
|
39478
39530
|
this.enableMove = false;
|
|
39479
39531
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
39480
|
-
if (e.evt.pointerType === "mouse" && e
|
|
39481
|
-
if (e.evt.pointerType === "mouse" && e
|
|
39482
|
-
const isTouchOrPen = ["touch", "pen"].includes(e
|
|
39532
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
39533
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
39534
|
+
const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
|
|
39483
39535
|
if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
|
|
39484
39536
|
if (this.enableMove) {
|
|
39485
39537
|
this.isDragging = true;
|
|
@@ -39488,7 +39540,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
39488
39540
|
}
|
|
39489
39541
|
});
|
|
39490
39542
|
stage.on("pointercancel", (e) => {
|
|
39491
|
-
this.pointers.delete(e.evt.pointerId);
|
|
39543
|
+
if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
|
|
39492
39544
|
lastPos = null;
|
|
39493
39545
|
});
|
|
39494
39546
|
const handleMouseMove = (e) => {
|