@inditextech/weave-sdk 3.9.0-SNAPSHOT.184.1 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.js +193 -111
- package/dist/sdk.node.js +193 -111
- package/dist/types.d.ts +27 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +193 -111
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -18875,7 +18875,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18875
18875
|
this.didMove = false;
|
|
18876
18876
|
const stage$1 = this.instance.getStage();
|
|
18877
18877
|
this.saveDragSelectedNodes();
|
|
18878
|
-
|
|
18878
|
+
this.setNodesOpacityOnDrag();
|
|
18879
18879
|
selectedNodes = tr.nodes();
|
|
18880
18880
|
if (isWheelMousePressed) {
|
|
18881
18881
|
e.cancelBubble = true;
|
|
@@ -18950,7 +18950,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18950
18950
|
if (!mainLayer) return;
|
|
18951
18951
|
this.instance.getSelectionLayer()?.hitGraphEnabled(true);
|
|
18952
18952
|
this.instance.getMainLayer()?.hitGraphEnabled(true);
|
|
18953
|
-
if (this.getDragSelectedNodes().length > 1) this.restoreNodesOpacityOnDrag();
|
|
18954
18953
|
if (!this.didMove) return;
|
|
18955
18954
|
if (selectedNodes.length > 1) this.instance.releaseMutexLock();
|
|
18956
18955
|
e.cancelBubble = true;
|
|
@@ -20483,8 +20482,6 @@ var WeaveNode = class {
|
|
|
20483
20482
|
let isWheelMousePressed = false;
|
|
20484
20483
|
if (e.evt.button === 1) isWheelMousePressed = true;
|
|
20485
20484
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
20486
|
-
this.getSelectionPlugin()?.saveDragSelectedNodes();
|
|
20487
|
-
if (this.getSelectionPlugin()?.getDragSelectedNodes().length === 1) this.getSelectionPlugin()?.setNodesOpacityOnDrag();
|
|
20488
20485
|
const canMove = nodeTarget?.canDrag() ?? false;
|
|
20489
20486
|
if (!canMove) {
|
|
20490
20487
|
nodeTarget.stopDrag();
|
|
@@ -20613,7 +20610,7 @@ var WeaveNode = class {
|
|
|
20613
20610
|
startPosition = null;
|
|
20614
20611
|
lockedAxis = null;
|
|
20615
20612
|
isShiftPressed = false;
|
|
20616
|
-
|
|
20613
|
+
this.getSelectionPlugin()?.restoreNodesOpacityOnDrag();
|
|
20617
20614
|
if (this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20618
20615
|
this.instance.releaseMutexLock();
|
|
20619
20616
|
this.getNodesSelectionFeedbackPlugin()?.showSelectionHalo(nodeTarget);
|
|
@@ -20758,8 +20755,8 @@ var WeaveNode = class {
|
|
|
20758
20755
|
return cancelBubble;
|
|
20759
20756
|
}
|
|
20760
20757
|
handleMouseout(e, node) {
|
|
20761
|
-
const isCtrlOrMetaPressed = e.evt
|
|
20762
|
-
if (isCtrlOrMetaPressed) return;
|
|
20758
|
+
const isCtrlOrMetaPressed = e.evt?.ctrlKey || e.evt?.metaKey;
|
|
20759
|
+
if (isCtrlOrMetaPressed) return false;
|
|
20763
20760
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
20764
20761
|
if (realNode) this.hideHoverState();
|
|
20765
20762
|
}
|
|
@@ -21413,10 +21410,16 @@ var WeaveTargetingManager = class {
|
|
|
21413
21410
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21414
21411
|
if (utilityLayer) utilityLayer.visible(false);
|
|
21415
21412
|
let containerAlt = containerOverCursor(this.instance, [], relativeMousePointer);
|
|
21416
|
-
if (!containerAlt) containerAlt = this.instance.getMainLayer();
|
|
21417
21413
|
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
21418
21414
|
if (nodesSelection) nodesSelection.getTransformer().visible(false);
|
|
21419
|
-
relativeMousePointer = containerAlt
|
|
21415
|
+
if (containerAlt && point === void 0) relativeMousePointer = containerAlt.getRelativePointerPosition() ?? relativeMousePointer;
|
|
21416
|
+
if (!containerAlt && point === void 0) {
|
|
21417
|
+
containerAlt = this.instance.getMainLayer();
|
|
21418
|
+
relativeMousePointer = containerAlt?.getRelativePointerPosition() ?? {
|
|
21419
|
+
x: 0,
|
|
21420
|
+
y: 0
|
|
21421
|
+
};
|
|
21422
|
+
}
|
|
21420
21423
|
if (utilityLayer) utilityLayer.visible(true);
|
|
21421
21424
|
if (nodesSelection) nodesSelection.getTransformer().visible(true);
|
|
21422
21425
|
return {
|
|
@@ -22011,7 +22014,7 @@ var WeaveRegisterManager = class {
|
|
|
22011
22014
|
|
|
22012
22015
|
//#endregion
|
|
22013
22016
|
//#region package.json
|
|
22014
|
-
var version = "3.9.0
|
|
22017
|
+
var version = "3.9.0";
|
|
22015
22018
|
|
|
22016
22019
|
//#endregion
|
|
22017
22020
|
//#region src/managers/setup.ts
|
|
@@ -25712,7 +25715,7 @@ const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
|
25712
25715
|
cursor: { loading: "wait" }
|
|
25713
25716
|
},
|
|
25714
25717
|
imageLoading: {
|
|
25715
|
-
maxRetryAttempts:
|
|
25718
|
+
maxRetryAttempts: 3,
|
|
25716
25719
|
retryDelayMs: 2e3
|
|
25717
25720
|
},
|
|
25718
25721
|
crossOrigin: "anonymous",
|
|
@@ -25762,19 +25765,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25762
25765
|
this.onClose = () => {};
|
|
25763
25766
|
this.handleHide = this.hide.bind(this);
|
|
25764
25767
|
}
|
|
25765
|
-
|
|
25766
|
-
this.onClose = onClose;
|
|
25767
|
-
const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
25768
|
-
if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
|
|
25769
|
-
const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
|
|
25770
|
-
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
25771
|
-
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
25772
|
-
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
25773
|
-
this.node.clearCache(this.image);
|
|
25774
|
-
this.image.setAttrs({ cropping: true });
|
|
25775
|
-
this.image.listening(false);
|
|
25776
|
-
const imageAttrs = this.image.getAttrs();
|
|
25777
|
-
this.internalImage.hide();
|
|
25768
|
+
setupCropImage(imageAttrs, visible) {
|
|
25778
25769
|
this.cropGroup.destroyChildren();
|
|
25779
25770
|
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
25780
25771
|
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
@@ -25788,10 +25779,26 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25788
25779
|
scaleY: 1,
|
|
25789
25780
|
image: this.internalImage.image(),
|
|
25790
25781
|
crop: void 0,
|
|
25791
|
-
visible
|
|
25782
|
+
visible,
|
|
25792
25783
|
listening: false,
|
|
25793
25784
|
draggable: false
|
|
25794
25785
|
});
|
|
25786
|
+
return { realScale };
|
|
25787
|
+
}
|
|
25788
|
+
show(onClose, options) {
|
|
25789
|
+
this.onClose = onClose;
|
|
25790
|
+
const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
25791
|
+
if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
|
|
25792
|
+
const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
|
|
25793
|
+
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
25794
|
+
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
25795
|
+
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
25796
|
+
this.node.clearCache(this.image);
|
|
25797
|
+
this.image.setAttrs({ cropping: true });
|
|
25798
|
+
this.image.listening(false);
|
|
25799
|
+
const imageAttrs = this.image.getAttrs();
|
|
25800
|
+
this.internalImage.hide();
|
|
25801
|
+
const { realScale } = this.setupCropImage(imageAttrs, true);
|
|
25795
25802
|
this.imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
|
|
25796
25803
|
this.imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
|
|
25797
25804
|
const cropModeConfiguration = this.node.getConfiguration().cropMode;
|
|
@@ -26168,23 +26175,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
26168
26175
|
}
|
|
26169
26176
|
unCrop() {
|
|
26170
26177
|
const imageAttrs = this.image.getAttrs();
|
|
26171
|
-
this.
|
|
26172
|
-
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
26173
|
-
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
26174
|
-
const realScale = actualScale / cropScale;
|
|
26175
|
-
this.cropImage = new Konva.Image({
|
|
26176
|
-
x: imageAttrs.cropInfo ? -imageAttrs.cropInfo.x * realScale : 0,
|
|
26177
|
-
y: imageAttrs.cropInfo ? -imageAttrs.cropInfo.y * realScale : 0,
|
|
26178
|
-
width: imageAttrs.uncroppedImage.width,
|
|
26179
|
-
height: imageAttrs.uncroppedImage.height,
|
|
26180
|
-
scaleX: 1,
|
|
26181
|
-
scaleY: 1,
|
|
26182
|
-
image: this.internalImage.image(),
|
|
26183
|
-
crop: void 0,
|
|
26184
|
-
visible: false,
|
|
26185
|
-
listening: false,
|
|
26186
|
-
draggable: false
|
|
26187
|
-
});
|
|
26178
|
+
this.setupCropImage(imageAttrs, false);
|
|
26188
26179
|
this.cropGroup.add(this.cropImage);
|
|
26189
26180
|
const cropImageStage = this.cropImage.getAbsolutePosition();
|
|
26190
26181
|
this.image.setAttrs({
|
|
@@ -26233,12 +26224,80 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
26233
26224
|
this.instance.updateNode(this.node.serialize(this.image));
|
|
26234
26225
|
}
|
|
26235
26226
|
}
|
|
26227
|
+
handleClipExternal(image, reference) {
|
|
26228
|
+
const stage = this.instance.getStage();
|
|
26229
|
+
const originalRotation = image.getAbsoluteRotation();
|
|
26230
|
+
if (image.getAbsoluteRotation() !== reference.getAbsoluteRotation()) throw new Error("Image and reference must have the same rotation", { cause: "RotationNotAligned" });
|
|
26231
|
+
const originalContainer = image.getParent();
|
|
26232
|
+
const group = new Konva.Group();
|
|
26233
|
+
image.moveTo(group);
|
|
26234
|
+
reference.moveTo(group);
|
|
26235
|
+
originalContainer?.add(group);
|
|
26236
|
+
group.rotate(-originalRotation);
|
|
26237
|
+
const dImage = group.findOne("#" + image.getAttrs().id);
|
|
26238
|
+
const dReference = group.findOne("#" + reference.getAttrs().id);
|
|
26239
|
+
const intersectionRectAbs = this.getIntersectionRect(dImage, dReference);
|
|
26240
|
+
const intersectionRect = this.getIntersectionRect(dImage, dReference, stage);
|
|
26241
|
+
const imageRect = dImage.getClientRect({
|
|
26242
|
+
relativeTo: stage,
|
|
26243
|
+
skipStroke: true
|
|
26244
|
+
});
|
|
26245
|
+
if (!intersectionRect || !intersectionRectAbs) return;
|
|
26246
|
+
const imageAttrs = this.image.getAttrs();
|
|
26247
|
+
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
26248
|
+
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
26249
|
+
const realScale = actualScale / cropScale;
|
|
26250
|
+
const imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
|
|
26251
|
+
const imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
|
|
26252
|
+
const diffX = intersectionRect.x - imageRect.x;
|
|
26253
|
+
const diffY = intersectionRect.y - imageRect.y;
|
|
26254
|
+
const realClipRect = {
|
|
26255
|
+
scaleX: actualScale,
|
|
26256
|
+
scaleY: actualScale,
|
|
26257
|
+
x: WeaveImageCrop.roundTo6Decimals(diffX + imageOffsetX),
|
|
26258
|
+
y: WeaveImageCrop.roundTo6Decimals(diffY + imageOffsetY),
|
|
26259
|
+
width: WeaveImageCrop.roundTo6Decimals(intersectionRect.width),
|
|
26260
|
+
height: WeaveImageCrop.roundTo6Decimals(intersectionRect.height)
|
|
26261
|
+
};
|
|
26262
|
+
if (dImage) {
|
|
26263
|
+
const cropSize = {
|
|
26264
|
+
x: diffX,
|
|
26265
|
+
y: diffY,
|
|
26266
|
+
width: intersectionRect.width,
|
|
26267
|
+
height: intersectionRect.height
|
|
26268
|
+
};
|
|
26269
|
+
dImage.setAttrs({
|
|
26270
|
+
width: intersectionRect.width,
|
|
26271
|
+
height: intersectionRect.height,
|
|
26272
|
+
cropInfo: realClipRect,
|
|
26273
|
+
cropSize,
|
|
26274
|
+
uncroppedImage: {
|
|
26275
|
+
width: imageAttrs.uncroppedImage.width,
|
|
26276
|
+
height: imageAttrs.uncroppedImage.height
|
|
26277
|
+
}
|
|
26278
|
+
});
|
|
26279
|
+
dImage.setAbsolutePosition(intersectionRectAbs);
|
|
26280
|
+
group.rotate(originalRotation);
|
|
26281
|
+
group.getChildren().forEach((child) => {
|
|
26282
|
+
child.moveTo(originalContainer);
|
|
26283
|
+
});
|
|
26284
|
+
group.destroy();
|
|
26285
|
+
const fImage = stage.findOne("#" + image.getAttrs().id);
|
|
26286
|
+
if (fImage) this.instance.updateNodeNT(this.node.serialize(fImage));
|
|
26287
|
+
}
|
|
26288
|
+
}
|
|
26236
26289
|
static roundTo6Decimals(value) {
|
|
26237
26290
|
return parseFloat(value.toFixed(6));
|
|
26238
26291
|
}
|
|
26239
|
-
getIntersectionRect(a, b) {
|
|
26240
|
-
const rectA = a.getClientRect({
|
|
26241
|
-
|
|
26292
|
+
getIntersectionRect(a, b, relativeTo) {
|
|
26293
|
+
const rectA = a.getClientRect({
|
|
26294
|
+
skipStroke: true,
|
|
26295
|
+
relativeTo
|
|
26296
|
+
});
|
|
26297
|
+
const rectB = b.getClientRect({
|
|
26298
|
+
skipStroke: true,
|
|
26299
|
+
relativeTo
|
|
26300
|
+
});
|
|
26242
26301
|
const x1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.x, rectB.x));
|
|
26243
26302
|
const y1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.y, rectB.y));
|
|
26244
26303
|
const x2 = WeaveImageCrop.roundTo6Decimals(Math.min(rectA.x + rectA.width, rectB.x + rectB.width));
|
|
@@ -26730,8 +26789,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26730
26789
|
y: p.y - offsetY
|
|
26731
26790
|
}));
|
|
26732
26791
|
const rect = new Konva.Rect({
|
|
26733
|
-
width: absoluteCorners[1].x - absoluteCorners[0].x,
|
|
26734
|
-
height: absoluteCorners[
|
|
26792
|
+
width: Math.hypot(absoluteCorners[1].x - absoluteCorners[0].x, absoluteCorners[1].y - absoluteCorners[0].y),
|
|
26793
|
+
height: Math.hypot(absoluteCorners[3].x - absoluteCorners[0].x, absoluteCorners[3].y - absoluteCorners[0].y),
|
|
26735
26794
|
fill: "transparent",
|
|
26736
26795
|
strokeScaleEnabled: false,
|
|
26737
26796
|
strokeWidth: 2,
|
|
@@ -26856,7 +26915,11 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26856
26915
|
onUpdate(nodeInstance, nextProps) {
|
|
26857
26916
|
const id = nodeInstance.getAttrs().id;
|
|
26858
26917
|
const node = nodeInstance;
|
|
26859
|
-
nodeInstance.setAttrs({
|
|
26918
|
+
nodeInstance.setAttrs({
|
|
26919
|
+
...nextProps,
|
|
26920
|
+
...nextProps.cropInfo ? { cropInfo: nextProps.cropInfo } : { cropInfo: void 0 },
|
|
26921
|
+
...nextProps.cropSize ? { cropSize: nextProps.cropSize } : { cropSize: void 0 }
|
|
26922
|
+
});
|
|
26860
26923
|
const imagePlaceholder = node.findOne(`#${id}-placeholder`);
|
|
26861
26924
|
const internalImage = node.findOne(`#${id}-image`);
|
|
26862
26925
|
const nodeAttrs = node.getAttrs();
|
|
@@ -26900,29 +26963,12 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26900
26963
|
});
|
|
26901
26964
|
}
|
|
26902
26965
|
if (this.imageState[id ?? ""]?.loaded && this.imageState[id ?? ""]?.error) {
|
|
26903
|
-
imagePlaceholder?.setAttrs({
|
|
26904
|
-
...internalImageProps,
|
|
26905
|
-
...nodeAttrs.imageProperties ?? {},
|
|
26906
|
-
name: void 0,
|
|
26907
|
-
id: `${id}-placeholder`,
|
|
26908
|
-
nodeId: id,
|
|
26909
|
-
x: 0,
|
|
26910
|
-
y: 0,
|
|
26911
|
-
scaleX: 1,
|
|
26912
|
-
scaleY: 1,
|
|
26913
|
-
rotation: 0,
|
|
26914
|
-
visible: true,
|
|
26915
|
-
fill: this.config.style.placeholder.fill,
|
|
26916
|
-
strokeWidth: 0,
|
|
26917
|
-
draggable: false,
|
|
26918
|
-
zIndex: 0
|
|
26919
|
-
});
|
|
26920
26966
|
internalImage?.setAttrs({
|
|
26921
26967
|
...internalImageProps,
|
|
26922
26968
|
...nodeAttrs.imageProperties ?? {},
|
|
26923
26969
|
name: void 0,
|
|
26924
26970
|
id: `${id}-image`,
|
|
26925
|
-
image:
|
|
26971
|
+
image: this.imageFallback[id ?? ""],
|
|
26926
26972
|
nodeId: id,
|
|
26927
26973
|
x: 0,
|
|
26928
26974
|
y: 0,
|
|
@@ -26933,6 +26979,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26933
26979
|
draggable: false,
|
|
26934
26980
|
zIndex: 1
|
|
26935
26981
|
});
|
|
26982
|
+
internalImage?.visible(true);
|
|
26983
|
+
this.updateImageCrop(nodeInstance);
|
|
26936
26984
|
}
|
|
26937
26985
|
if (this.imageState[id ?? ""]?.loaded && !this.imageState[id ?? ""]?.error) {
|
|
26938
26986
|
internalImage?.setAttrs({
|
|
@@ -26987,14 +27035,18 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26987
27035
|
}
|
|
26988
27036
|
preloadImage(imageId, imageURL, { onLoad, onError }, loadingTryout = false) {
|
|
26989
27037
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27038
|
+
if (imageURLToLoad === "") {
|
|
27039
|
+
this.setErrorState(imageId);
|
|
27040
|
+
return;
|
|
27041
|
+
}
|
|
26990
27042
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
26991
27043
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
26992
27044
|
this.imageSource[imageId].onerror = (error) => {
|
|
26993
|
-
if (!loadingTryout)
|
|
26994
|
-
|
|
26995
|
-
|
|
26996
|
-
|
|
26997
|
-
}
|
|
27045
|
+
if (!loadingTryout) {
|
|
27046
|
+
const stage = this.instance.getStage();
|
|
27047
|
+
const image = stage.findOne(`#${imageId}`);
|
|
27048
|
+
if (image) this.setErrorState(imageId, image);
|
|
27049
|
+
}
|
|
26998
27050
|
onError(error);
|
|
26999
27051
|
};
|
|
27000
27052
|
this.imageSource[imageId].onload = async () => {
|
|
@@ -27089,36 +27141,29 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27089
27141
|
}
|
|
27090
27142
|
},
|
|
27091
27143
|
onError: (error) => {
|
|
27092
|
-
if (!this.config.useFallbackImage)
|
|
27093
|
-
const
|
|
27094
|
-
if (
|
|
27095
|
-
this.
|
|
27096
|
-
|
|
27097
|
-
}
|
|
27098
|
-
}
|
|
27144
|
+
if (!this.config.useFallbackImage) {
|
|
27145
|
+
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27146
|
+
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27147
|
+
this.loadImageTryout(id);
|
|
27148
|
+
return;
|
|
27149
|
+
} else this.setErrorState(id, image);
|
|
27150
|
+
}
|
|
27099
27151
|
if (loadTryout) {
|
|
27100
27152
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27101
|
-
if (tryoutAttempts < this.config.imageLoading.maxRetryAttempts)
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
this.loadImage(node.getAttrs(), node, false, true);
|
|
27106
|
-
}
|
|
27107
|
-
}, this.config.imageLoading.retryDelayMs);
|
|
27153
|
+
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27154
|
+
this.loadImageTryout(id);
|
|
27155
|
+
return;
|
|
27156
|
+
} else this.setErrorState(id, image);
|
|
27108
27157
|
return;
|
|
27109
27158
|
}
|
|
27110
27159
|
if (this.config.useFallbackImage && !useFallback && !loadTryout && imageProps.imageFallback) {
|
|
27111
27160
|
this.loadImage({ ...params }, image, true);
|
|
27112
27161
|
return;
|
|
27113
27162
|
}
|
|
27114
|
-
this.
|
|
27115
|
-
status: "error",
|
|
27116
|
-
loaded: false,
|
|
27117
|
-
error: true
|
|
27118
|
-
};
|
|
27163
|
+
this.setErrorState(id, image);
|
|
27119
27164
|
image.setAttrs({ image: void 0 });
|
|
27165
|
+
console.error("Error loading image", error);
|
|
27120
27166
|
this.resolveAsyncElement(id);
|
|
27121
|
-
console.error("Error loading image", realImageURL, error);
|
|
27122
27167
|
imagePlaceholder?.setAttrs({ visible: true });
|
|
27123
27168
|
internalImage?.setAttrs({ visible: false });
|
|
27124
27169
|
this.cacheNode(image);
|
|
@@ -27248,6 +27293,41 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27248
27293
|
}
|
|
27249
27294
|
nodeInstance.destroy();
|
|
27250
27295
|
}
|
|
27296
|
+
loadImageTryout(imageId) {
|
|
27297
|
+
this.imageTryoutIds[imageId] = setTimeout(() => {
|
|
27298
|
+
const node = this.instance.getStage().findOne(`#${imageId}`);
|
|
27299
|
+
if (node) {
|
|
27300
|
+
const tryoutAttempts = this.imageTryoutAttempts[imageId] ?? 0;
|
|
27301
|
+
this.imageTryoutAttempts[imageId] = tryoutAttempts + 1;
|
|
27302
|
+
this.loadImage(node.getAttrs(), node, false, true);
|
|
27303
|
+
}
|
|
27304
|
+
}, this.config.imageLoading.retryDelayMs);
|
|
27305
|
+
}
|
|
27306
|
+
setErrorState(imageId, image) {
|
|
27307
|
+
this.imageState[imageId] = {
|
|
27308
|
+
status: "loaded",
|
|
27309
|
+
loaded: true,
|
|
27310
|
+
error: true
|
|
27311
|
+
};
|
|
27312
|
+
this.resolveAsyncElement(imageId);
|
|
27313
|
+
if (image) this.cacheNode(image);
|
|
27314
|
+
}
|
|
27315
|
+
cropImageWithReference(image, reference) {
|
|
27316
|
+
const internalImage = image?.findOne(`#${image.getAttrs().id}-image`);
|
|
27317
|
+
const cropGroup = image?.findOne(`#${image.getAttrs().id}-cropGroup`);
|
|
27318
|
+
if (!internalImage || !cropGroup) throw new Error("Provided element is not a valid image node.", { cause: "InvalidImageNode" });
|
|
27319
|
+
this.imageCrop = new WeaveImageCrop(this.instance, this, image, internalImage, cropGroup);
|
|
27320
|
+
this.instance.stateTransactional(() => {
|
|
27321
|
+
this.imageCrop?.handleClipExternal(image, reference);
|
|
27322
|
+
const nodeHandler = this.instance.getNodeHandler(reference.getAttrs().nodeType);
|
|
27323
|
+
if (nodeHandler) {
|
|
27324
|
+
const rectangleState = nodeHandler.serialize(reference);
|
|
27325
|
+
this.instance.removeNodeNT(rectangleState);
|
|
27326
|
+
}
|
|
27327
|
+
});
|
|
27328
|
+
this.getNodesSelectionPlugin()?.setSelectedNodes([image]);
|
|
27329
|
+
this.getNodesSelectionPlugin()?.getHoverTransformer().forceUpdate();
|
|
27330
|
+
}
|
|
27251
27331
|
};
|
|
27252
27332
|
|
|
27253
27333
|
//#endregion
|
|
@@ -34420,14 +34500,15 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34420
34500
|
const dragProperties = this.instance.getDragProperties();
|
|
34421
34501
|
if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
|
|
34422
34502
|
this.instance.getStage().setPointersPositions(e);
|
|
34423
|
-
const
|
|
34424
|
-
if (!
|
|
34503
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
34504
|
+
if (!mousePoint) return;
|
|
34425
34505
|
this.instance.triggerAction(WEAVE_IMAGE_TOOL_ACTION_NAME, {
|
|
34426
34506
|
type: WEAVE_IMAGE_TOOL_UPLOAD_TYPE.IMAGE_URL,
|
|
34427
34507
|
image: dragProperties.imageURL,
|
|
34428
34508
|
...dragProperties.imageId ? { imageId: dragProperties.imageId } : {},
|
|
34429
34509
|
...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer },
|
|
34430
|
-
|
|
34510
|
+
container,
|
|
34511
|
+
position: mousePoint
|
|
34431
34512
|
});
|
|
34432
34513
|
}
|
|
34433
34514
|
});
|
|
@@ -34594,7 +34675,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34594
34675
|
}
|
|
34595
34676
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
34596
34677
|
this.imageAction[nodeId].clickPoint = mousePoint;
|
|
34597
|
-
this.imageAction[nodeId].container = container;
|
|
34678
|
+
this.imageAction[nodeId].container = this.imageAction[nodeId].container ?? container;
|
|
34598
34679
|
const nodeHandler = this.instance.getNodeHandler("image");
|
|
34599
34680
|
const imageWidth = this.imageAction[nodeId].props.width ? this.imageAction[nodeId].props.width : imageSource?.width;
|
|
34600
34681
|
const imageHeight = this.imageAction[nodeId].props.height ? this.imageAction[nodeId].props.height : imageSource?.height;
|
|
@@ -34661,9 +34742,9 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34661
34742
|
props: this.initProps(),
|
|
34662
34743
|
imageId: nodeId,
|
|
34663
34744
|
clickPoint: null,
|
|
34664
|
-
container: void 0,
|
|
34665
34745
|
imageFile: null,
|
|
34666
34746
|
imageURL: null,
|
|
34747
|
+
container: params?.container,
|
|
34667
34748
|
forceMainContainer: params?.forceMainContainer ?? false,
|
|
34668
34749
|
uploadType: null,
|
|
34669
34750
|
uploadImageFunction: null
|
|
@@ -34870,12 +34951,13 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
34870
34951
|
const dragProperties = this.instance.getDragProperties();
|
|
34871
34952
|
if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
|
|
34872
34953
|
this.instance.getStage().setPointersPositions(e);
|
|
34873
|
-
const
|
|
34874
|
-
if (!
|
|
34954
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
34955
|
+
if (!mousePoint) return;
|
|
34875
34956
|
this.instance.triggerAction(WEAVE_IMAGES_TOOL_ACTION_NAME, {
|
|
34876
34957
|
type: WEAVE_IMAGES_TOOL_UPLOAD_TYPE.IMAGE_URL,
|
|
34877
34958
|
images: dragProperties.imagesURL,
|
|
34878
|
-
|
|
34959
|
+
container,
|
|
34960
|
+
position: mousePoint,
|
|
34879
34961
|
...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
|
|
34880
34962
|
});
|
|
34881
34963
|
}
|
|
@@ -35036,7 +35118,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35036
35118
|
stage.container().style.cursor = "default";
|
|
35037
35119
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
35038
35120
|
this.clickPoint = mousePoint;
|
|
35039
|
-
this.container = container;
|
|
35121
|
+
this.container = this.container ?? container;
|
|
35040
35122
|
const originPoint = {
|
|
35041
35123
|
x: this.clickPoint?.x ?? 0,
|
|
35042
35124
|
y: this.clickPoint?.y ?? 0
|
|
@@ -35091,10 +35173,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35091
35173
|
},
|
|
35092
35174
|
uploadImageFunction: uploadImageFunctionInternal,
|
|
35093
35175
|
...imageId && { imageId },
|
|
35094
|
-
position:
|
|
35095
|
-
|
|
35096
|
-
y: position$1.y
|
|
35097
|
-
},
|
|
35176
|
+
position: position$1,
|
|
35177
|
+
container: this.container,
|
|
35098
35178
|
forceMainContainer: this.forceMainContainer,
|
|
35099
35179
|
nodeId: nodeId$1
|
|
35100
35180
|
}, true);
|
|
@@ -35128,10 +35208,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35128
35208
|
},
|
|
35129
35209
|
...imageId && { imageId },
|
|
35130
35210
|
...options && { options },
|
|
35131
|
-
position:
|
|
35132
|
-
|
|
35133
|
-
y: position$1.y
|
|
35134
|
-
},
|
|
35211
|
+
position: position$1,
|
|
35212
|
+
container: this.container,
|
|
35135
35213
|
forceMainContainer: this.forceMainContainer,
|
|
35136
35214
|
nodeId: nodeId$1
|
|
35137
35215
|
}, true);
|
|
@@ -35164,6 +35242,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35164
35242
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
35165
35243
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
35166
35244
|
if (params?.position) this.setState(WEAVE_IMAGES_TOOL_STATE.SELECTED_POSITION);
|
|
35245
|
+
if (params?.container) this.container = params.container;
|
|
35167
35246
|
this.nodesIds = [];
|
|
35168
35247
|
this.forceMainContainer = params.forceMainContainer ?? false;
|
|
35169
35248
|
if (params.type === WEAVE_IMAGES_TOOL_UPLOAD_TYPE.FILE) {
|
|
@@ -36981,11 +37060,13 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
36981
37060
|
const dragProperties = this.instance.getDragProperties();
|
|
36982
37061
|
if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
|
|
36983
37062
|
this.instance.getStage().setPointersPositions(e);
|
|
36984
|
-
const
|
|
37063
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
37064
|
+
if (!mousePoint) return;
|
|
36985
37065
|
this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
|
|
36986
37066
|
videoId: dragProperties.videoId,
|
|
36987
37067
|
videoParams: dragProperties.videoParams,
|
|
36988
|
-
|
|
37068
|
+
container,
|
|
37069
|
+
position: mousePoint
|
|
36989
37070
|
});
|
|
36990
37071
|
}
|
|
36991
37072
|
});
|
|
@@ -37036,7 +37117,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
37036
37117
|
if (this.videoId && this.videoParams) {
|
|
37037
37118
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
37038
37119
|
this.clickPoint = mousePoint;
|
|
37039
|
-
this.container = container;
|
|
37120
|
+
this.container = this.container ?? container;
|
|
37040
37121
|
const nodeHandler = this.instance.getNodeHandler("video");
|
|
37041
37122
|
if (nodeHandler) {
|
|
37042
37123
|
const node = nodeHandler.create(this.videoId, {
|
|
@@ -37067,6 +37148,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
37067
37148
|
this.cancelAction = cancelAction;
|
|
37068
37149
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
37069
37150
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
37151
|
+
this.container = params?.container;
|
|
37070
37152
|
this.forceMainContainer = params?.forceMainContainer ?? false;
|
|
37071
37153
|
if (params?.videoId) this.updateProps({ videoId: params.videoId });
|
|
37072
37154
|
if (params?.videoParams) {
|