@inditextech/weave-sdk 3.9.0-SNAPSHOT.186.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 +191 -106
- package/dist/sdk.node.js +191 -106
- package/dist/types.d.ts +27 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +191 -106
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -20755,8 +20755,8 @@ var WeaveNode = class {
|
|
|
20755
20755
|
return cancelBubble;
|
|
20756
20756
|
}
|
|
20757
20757
|
handleMouseout(e, node) {
|
|
20758
|
-
const isCtrlOrMetaPressed = e.evt
|
|
20759
|
-
if (isCtrlOrMetaPressed) return;
|
|
20758
|
+
const isCtrlOrMetaPressed = e.evt?.ctrlKey || e.evt?.metaKey;
|
|
20759
|
+
if (isCtrlOrMetaPressed) return false;
|
|
20760
20760
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
20761
20761
|
if (realNode) this.hideHoverState();
|
|
20762
20762
|
}
|
|
@@ -21410,10 +21410,16 @@ var WeaveTargetingManager = class {
|
|
|
21410
21410
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21411
21411
|
if (utilityLayer) utilityLayer.visible(false);
|
|
21412
21412
|
let containerAlt = containerOverCursor(this.instance, [], relativeMousePointer);
|
|
21413
|
-
if (!containerAlt) containerAlt = this.instance.getMainLayer();
|
|
21414
21413
|
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
21415
21414
|
if (nodesSelection) nodesSelection.getTransformer().visible(false);
|
|
21416
|
-
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
|
+
}
|
|
21417
21423
|
if (utilityLayer) utilityLayer.visible(true);
|
|
21418
21424
|
if (nodesSelection) nodesSelection.getTransformer().visible(true);
|
|
21419
21425
|
return {
|
|
@@ -22008,7 +22014,7 @@ var WeaveRegisterManager = class {
|
|
|
22008
22014
|
|
|
22009
22015
|
//#endregion
|
|
22010
22016
|
//#region package.json
|
|
22011
|
-
var version = "3.9.0
|
|
22017
|
+
var version = "3.9.0";
|
|
22012
22018
|
|
|
22013
22019
|
//#endregion
|
|
22014
22020
|
//#region src/managers/setup.ts
|
|
@@ -25709,7 +25715,7 @@ const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
|
25709
25715
|
cursor: { loading: "wait" }
|
|
25710
25716
|
},
|
|
25711
25717
|
imageLoading: {
|
|
25712
|
-
maxRetryAttempts:
|
|
25718
|
+
maxRetryAttempts: 3,
|
|
25713
25719
|
retryDelayMs: 2e3
|
|
25714
25720
|
},
|
|
25715
25721
|
crossOrigin: "anonymous",
|
|
@@ -25759,19 +25765,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25759
25765
|
this.onClose = () => {};
|
|
25760
25766
|
this.handleHide = this.hide.bind(this);
|
|
25761
25767
|
}
|
|
25762
|
-
|
|
25763
|
-
this.onClose = onClose;
|
|
25764
|
-
const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
25765
|
-
if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
|
|
25766
|
-
const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
|
|
25767
|
-
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
25768
|
-
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
25769
|
-
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
25770
|
-
this.node.clearCache(this.image);
|
|
25771
|
-
this.image.setAttrs({ cropping: true });
|
|
25772
|
-
this.image.listening(false);
|
|
25773
|
-
const imageAttrs = this.image.getAttrs();
|
|
25774
|
-
this.internalImage.hide();
|
|
25768
|
+
setupCropImage(imageAttrs, visible) {
|
|
25775
25769
|
this.cropGroup.destroyChildren();
|
|
25776
25770
|
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
25777
25771
|
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
@@ -25785,10 +25779,26 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25785
25779
|
scaleY: 1,
|
|
25786
25780
|
image: this.internalImage.image(),
|
|
25787
25781
|
crop: void 0,
|
|
25788
|
-
visible
|
|
25782
|
+
visible,
|
|
25789
25783
|
listening: false,
|
|
25790
25784
|
draggable: false
|
|
25791
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);
|
|
25792
25802
|
this.imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
|
|
25793
25803
|
this.imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
|
|
25794
25804
|
const cropModeConfiguration = this.node.getConfiguration().cropMode;
|
|
@@ -26165,23 +26175,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
26165
26175
|
}
|
|
26166
26176
|
unCrop() {
|
|
26167
26177
|
const imageAttrs = this.image.getAttrs();
|
|
26168
|
-
this.
|
|
26169
|
-
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
26170
|
-
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
26171
|
-
const realScale = actualScale / cropScale;
|
|
26172
|
-
this.cropImage = new Konva.Image({
|
|
26173
|
-
x: imageAttrs.cropInfo ? -imageAttrs.cropInfo.x * realScale : 0,
|
|
26174
|
-
y: imageAttrs.cropInfo ? -imageAttrs.cropInfo.y * realScale : 0,
|
|
26175
|
-
width: imageAttrs.uncroppedImage.width,
|
|
26176
|
-
height: imageAttrs.uncroppedImage.height,
|
|
26177
|
-
scaleX: 1,
|
|
26178
|
-
scaleY: 1,
|
|
26179
|
-
image: this.internalImage.image(),
|
|
26180
|
-
crop: void 0,
|
|
26181
|
-
visible: false,
|
|
26182
|
-
listening: false,
|
|
26183
|
-
draggable: false
|
|
26184
|
-
});
|
|
26178
|
+
this.setupCropImage(imageAttrs, false);
|
|
26185
26179
|
this.cropGroup.add(this.cropImage);
|
|
26186
26180
|
const cropImageStage = this.cropImage.getAbsolutePosition();
|
|
26187
26181
|
this.image.setAttrs({
|
|
@@ -26230,12 +26224,80 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
26230
26224
|
this.instance.updateNode(this.node.serialize(this.image));
|
|
26231
26225
|
}
|
|
26232
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
|
+
}
|
|
26233
26289
|
static roundTo6Decimals(value) {
|
|
26234
26290
|
return parseFloat(value.toFixed(6));
|
|
26235
26291
|
}
|
|
26236
|
-
getIntersectionRect(a, b) {
|
|
26237
|
-
const rectA = a.getClientRect({
|
|
26238
|
-
|
|
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
|
+
});
|
|
26239
26301
|
const x1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.x, rectB.x));
|
|
26240
26302
|
const y1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.y, rectB.y));
|
|
26241
26303
|
const x2 = WeaveImageCrop.roundTo6Decimals(Math.min(rectA.x + rectA.width, rectB.x + rectB.width));
|
|
@@ -26727,8 +26789,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26727
26789
|
y: p.y - offsetY
|
|
26728
26790
|
}));
|
|
26729
26791
|
const rect = new Konva.Rect({
|
|
26730
|
-
width: absoluteCorners[1].x - absoluteCorners[0].x,
|
|
26731
|
-
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),
|
|
26732
26794
|
fill: "transparent",
|
|
26733
26795
|
strokeScaleEnabled: false,
|
|
26734
26796
|
strokeWidth: 2,
|
|
@@ -26853,7 +26915,11 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26853
26915
|
onUpdate(nodeInstance, nextProps) {
|
|
26854
26916
|
const id = nodeInstance.getAttrs().id;
|
|
26855
26917
|
const node = nodeInstance;
|
|
26856
|
-
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
|
+
});
|
|
26857
26923
|
const imagePlaceholder = node.findOne(`#${id}-placeholder`);
|
|
26858
26924
|
const internalImage = node.findOne(`#${id}-image`);
|
|
26859
26925
|
const nodeAttrs = node.getAttrs();
|
|
@@ -26897,29 +26963,12 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26897
26963
|
});
|
|
26898
26964
|
}
|
|
26899
26965
|
if (this.imageState[id ?? ""]?.loaded && this.imageState[id ?? ""]?.error) {
|
|
26900
|
-
imagePlaceholder?.setAttrs({
|
|
26901
|
-
...internalImageProps,
|
|
26902
|
-
...nodeAttrs.imageProperties ?? {},
|
|
26903
|
-
name: void 0,
|
|
26904
|
-
id: `${id}-placeholder`,
|
|
26905
|
-
nodeId: id,
|
|
26906
|
-
x: 0,
|
|
26907
|
-
y: 0,
|
|
26908
|
-
scaleX: 1,
|
|
26909
|
-
scaleY: 1,
|
|
26910
|
-
rotation: 0,
|
|
26911
|
-
visible: true,
|
|
26912
|
-
fill: this.config.style.placeholder.fill,
|
|
26913
|
-
strokeWidth: 0,
|
|
26914
|
-
draggable: false,
|
|
26915
|
-
zIndex: 0
|
|
26916
|
-
});
|
|
26917
26966
|
internalImage?.setAttrs({
|
|
26918
26967
|
...internalImageProps,
|
|
26919
26968
|
...nodeAttrs.imageProperties ?? {},
|
|
26920
26969
|
name: void 0,
|
|
26921
26970
|
id: `${id}-image`,
|
|
26922
|
-
image:
|
|
26971
|
+
image: this.imageFallback[id ?? ""],
|
|
26923
26972
|
nodeId: id,
|
|
26924
26973
|
x: 0,
|
|
26925
26974
|
y: 0,
|
|
@@ -26930,6 +26979,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26930
26979
|
draggable: false,
|
|
26931
26980
|
zIndex: 1
|
|
26932
26981
|
});
|
|
26982
|
+
internalImage?.visible(true);
|
|
26983
|
+
this.updateImageCrop(nodeInstance);
|
|
26933
26984
|
}
|
|
26934
26985
|
if (this.imageState[id ?? ""]?.loaded && !this.imageState[id ?? ""]?.error) {
|
|
26935
26986
|
internalImage?.setAttrs({
|
|
@@ -26984,14 +27035,18 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26984
27035
|
}
|
|
26985
27036
|
preloadImage(imageId, imageURL, { onLoad, onError }, loadingTryout = false) {
|
|
26986
27037
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27038
|
+
if (imageURLToLoad === "") {
|
|
27039
|
+
this.setErrorState(imageId);
|
|
27040
|
+
return;
|
|
27041
|
+
}
|
|
26987
27042
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
26988
27043
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
26989
27044
|
this.imageSource[imageId].onerror = (error) => {
|
|
26990
|
-
if (!loadingTryout)
|
|
26991
|
-
|
|
26992
|
-
|
|
26993
|
-
|
|
26994
|
-
}
|
|
27045
|
+
if (!loadingTryout) {
|
|
27046
|
+
const stage = this.instance.getStage();
|
|
27047
|
+
const image = stage.findOne(`#${imageId}`);
|
|
27048
|
+
if (image) this.setErrorState(imageId, image);
|
|
27049
|
+
}
|
|
26995
27050
|
onError(error);
|
|
26996
27051
|
};
|
|
26997
27052
|
this.imageSource[imageId].onload = async () => {
|
|
@@ -27086,36 +27141,29 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27086
27141
|
}
|
|
27087
27142
|
},
|
|
27088
27143
|
onError: (error) => {
|
|
27089
|
-
if (!this.config.useFallbackImage)
|
|
27090
|
-
const
|
|
27091
|
-
if (
|
|
27092
|
-
this.
|
|
27093
|
-
|
|
27094
|
-
}
|
|
27095
|
-
}
|
|
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
|
+
}
|
|
27096
27151
|
if (loadTryout) {
|
|
27097
27152
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27098
|
-
if (tryoutAttempts < this.config.imageLoading.maxRetryAttempts)
|
|
27099
|
-
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
this.loadImage(node.getAttrs(), node, false, true);
|
|
27103
|
-
}
|
|
27104
|
-
}, this.config.imageLoading.retryDelayMs);
|
|
27153
|
+
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27154
|
+
this.loadImageTryout(id);
|
|
27155
|
+
return;
|
|
27156
|
+
} else this.setErrorState(id, image);
|
|
27105
27157
|
return;
|
|
27106
27158
|
}
|
|
27107
27159
|
if (this.config.useFallbackImage && !useFallback && !loadTryout && imageProps.imageFallback) {
|
|
27108
27160
|
this.loadImage({ ...params }, image, true);
|
|
27109
27161
|
return;
|
|
27110
27162
|
}
|
|
27111
|
-
this.
|
|
27112
|
-
status: "error",
|
|
27113
|
-
loaded: false,
|
|
27114
|
-
error: true
|
|
27115
|
-
};
|
|
27163
|
+
this.setErrorState(id, image);
|
|
27116
27164
|
image.setAttrs({ image: void 0 });
|
|
27165
|
+
console.error("Error loading image", error);
|
|
27117
27166
|
this.resolveAsyncElement(id);
|
|
27118
|
-
console.error("Error loading image", realImageURL, error);
|
|
27119
27167
|
imagePlaceholder?.setAttrs({ visible: true });
|
|
27120
27168
|
internalImage?.setAttrs({ visible: false });
|
|
27121
27169
|
this.cacheNode(image);
|
|
@@ -27245,6 +27293,41 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27245
27293
|
}
|
|
27246
27294
|
nodeInstance.destroy();
|
|
27247
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
|
+
}
|
|
27248
27331
|
};
|
|
27249
27332
|
|
|
27250
27333
|
//#endregion
|
|
@@ -34417,14 +34500,15 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34417
34500
|
const dragProperties = this.instance.getDragProperties();
|
|
34418
34501
|
if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
|
|
34419
34502
|
this.instance.getStage().setPointersPositions(e);
|
|
34420
|
-
const
|
|
34421
|
-
if (!
|
|
34503
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
34504
|
+
if (!mousePoint) return;
|
|
34422
34505
|
this.instance.triggerAction(WEAVE_IMAGE_TOOL_ACTION_NAME, {
|
|
34423
34506
|
type: WEAVE_IMAGE_TOOL_UPLOAD_TYPE.IMAGE_URL,
|
|
34424
34507
|
image: dragProperties.imageURL,
|
|
34425
34508
|
...dragProperties.imageId ? { imageId: dragProperties.imageId } : {},
|
|
34426
34509
|
...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer },
|
|
34427
|
-
|
|
34510
|
+
container,
|
|
34511
|
+
position: mousePoint
|
|
34428
34512
|
});
|
|
34429
34513
|
}
|
|
34430
34514
|
});
|
|
@@ -34591,7 +34675,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34591
34675
|
}
|
|
34592
34676
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
34593
34677
|
this.imageAction[nodeId].clickPoint = mousePoint;
|
|
34594
|
-
this.imageAction[nodeId].container = container;
|
|
34678
|
+
this.imageAction[nodeId].container = this.imageAction[nodeId].container ?? container;
|
|
34595
34679
|
const nodeHandler = this.instance.getNodeHandler("image");
|
|
34596
34680
|
const imageWidth = this.imageAction[nodeId].props.width ? this.imageAction[nodeId].props.width : imageSource?.width;
|
|
34597
34681
|
const imageHeight = this.imageAction[nodeId].props.height ? this.imageAction[nodeId].props.height : imageSource?.height;
|
|
@@ -34658,9 +34742,9 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34658
34742
|
props: this.initProps(),
|
|
34659
34743
|
imageId: nodeId,
|
|
34660
34744
|
clickPoint: null,
|
|
34661
|
-
container: void 0,
|
|
34662
34745
|
imageFile: null,
|
|
34663
34746
|
imageURL: null,
|
|
34747
|
+
container: params?.container,
|
|
34664
34748
|
forceMainContainer: params?.forceMainContainer ?? false,
|
|
34665
34749
|
uploadType: null,
|
|
34666
34750
|
uploadImageFunction: null
|
|
@@ -34867,12 +34951,13 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
34867
34951
|
const dragProperties = this.instance.getDragProperties();
|
|
34868
34952
|
if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
|
|
34869
34953
|
this.instance.getStage().setPointersPositions(e);
|
|
34870
|
-
const
|
|
34871
|
-
if (!
|
|
34954
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
34955
|
+
if (!mousePoint) return;
|
|
34872
34956
|
this.instance.triggerAction(WEAVE_IMAGES_TOOL_ACTION_NAME, {
|
|
34873
34957
|
type: WEAVE_IMAGES_TOOL_UPLOAD_TYPE.IMAGE_URL,
|
|
34874
34958
|
images: dragProperties.imagesURL,
|
|
34875
|
-
|
|
34959
|
+
container,
|
|
34960
|
+
position: mousePoint,
|
|
34876
34961
|
...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
|
|
34877
34962
|
});
|
|
34878
34963
|
}
|
|
@@ -35033,7 +35118,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35033
35118
|
stage.container().style.cursor = "default";
|
|
35034
35119
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
35035
35120
|
this.clickPoint = mousePoint;
|
|
35036
|
-
this.container = container;
|
|
35121
|
+
this.container = this.container ?? container;
|
|
35037
35122
|
const originPoint = {
|
|
35038
35123
|
x: this.clickPoint?.x ?? 0,
|
|
35039
35124
|
y: this.clickPoint?.y ?? 0
|
|
@@ -35088,10 +35173,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35088
35173
|
},
|
|
35089
35174
|
uploadImageFunction: uploadImageFunctionInternal,
|
|
35090
35175
|
...imageId && { imageId },
|
|
35091
|
-
position:
|
|
35092
|
-
|
|
35093
|
-
y: position$1.y
|
|
35094
|
-
},
|
|
35176
|
+
position: position$1,
|
|
35177
|
+
container: this.container,
|
|
35095
35178
|
forceMainContainer: this.forceMainContainer,
|
|
35096
35179
|
nodeId: nodeId$1
|
|
35097
35180
|
}, true);
|
|
@@ -35125,10 +35208,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35125
35208
|
},
|
|
35126
35209
|
...imageId && { imageId },
|
|
35127
35210
|
...options && { options },
|
|
35128
|
-
position:
|
|
35129
|
-
|
|
35130
|
-
y: position$1.y
|
|
35131
|
-
},
|
|
35211
|
+
position: position$1,
|
|
35212
|
+
container: this.container,
|
|
35132
35213
|
forceMainContainer: this.forceMainContainer,
|
|
35133
35214
|
nodeId: nodeId$1
|
|
35134
35215
|
}, true);
|
|
@@ -35161,6 +35242,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35161
35242
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
35162
35243
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
35163
35244
|
if (params?.position) this.setState(WEAVE_IMAGES_TOOL_STATE.SELECTED_POSITION);
|
|
35245
|
+
if (params?.container) this.container = params.container;
|
|
35164
35246
|
this.nodesIds = [];
|
|
35165
35247
|
this.forceMainContainer = params.forceMainContainer ?? false;
|
|
35166
35248
|
if (params.type === WEAVE_IMAGES_TOOL_UPLOAD_TYPE.FILE) {
|
|
@@ -36978,11 +37060,13 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
36978
37060
|
const dragProperties = this.instance.getDragProperties();
|
|
36979
37061
|
if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
|
|
36980
37062
|
this.instance.getStage().setPointersPositions(e);
|
|
36981
|
-
const
|
|
37063
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
37064
|
+
if (!mousePoint) return;
|
|
36982
37065
|
this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
|
|
36983
37066
|
videoId: dragProperties.videoId,
|
|
36984
37067
|
videoParams: dragProperties.videoParams,
|
|
36985
|
-
|
|
37068
|
+
container,
|
|
37069
|
+
position: mousePoint
|
|
36986
37070
|
});
|
|
36987
37071
|
}
|
|
36988
37072
|
});
|
|
@@ -37033,7 +37117,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
37033
37117
|
if (this.videoId && this.videoParams) {
|
|
37034
37118
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
37035
37119
|
this.clickPoint = mousePoint;
|
|
37036
|
-
this.container = container;
|
|
37120
|
+
this.container = this.container ?? container;
|
|
37037
37121
|
const nodeHandler = this.instance.getNodeHandler("video");
|
|
37038
37122
|
if (nodeHandler) {
|
|
37039
37123
|
const node = nodeHandler.create(this.videoId, {
|
|
@@ -37064,6 +37148,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
37064
37148
|
this.cancelAction = cancelAction;
|
|
37065
37149
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
37066
37150
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
37151
|
+
this.container = params?.container;
|
|
37067
37152
|
this.forceMainContainer = params?.forceMainContainer ?? false;
|
|
37068
37153
|
if (params?.videoId) this.updateProps({ videoId: params.videoId });
|
|
37069
37154
|
if (params?.videoParams) {
|