@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/types.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
|
}
|
|
@@ -21421,10 +21421,16 @@ var WeaveTargetingManager = class {
|
|
|
21421
21421
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21422
21422
|
if (utilityLayer) utilityLayer.visible(false);
|
|
21423
21423
|
let containerAlt = containerOverCursor(this.instance, [], relativeMousePointer);
|
|
21424
|
-
if (!containerAlt) containerAlt = this.instance.getMainLayer();
|
|
21425
21424
|
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
21426
21425
|
if (nodesSelection) nodesSelection.getTransformer().visible(false);
|
|
21427
|
-
relativeMousePointer = containerAlt
|
|
21426
|
+
if (containerAlt && point === void 0) relativeMousePointer = containerAlt.getRelativePointerPosition() ?? relativeMousePointer;
|
|
21427
|
+
if (!containerAlt && point === void 0) {
|
|
21428
|
+
containerAlt = this.instance.getMainLayer();
|
|
21429
|
+
relativeMousePointer = containerAlt?.getRelativePointerPosition() ?? {
|
|
21430
|
+
x: 0,
|
|
21431
|
+
y: 0
|
|
21432
|
+
};
|
|
21433
|
+
}
|
|
21428
21434
|
if (utilityLayer) utilityLayer.visible(true);
|
|
21429
21435
|
if (nodesSelection) nodesSelection.getTransformer().visible(true);
|
|
21430
21436
|
return {
|
|
@@ -22019,7 +22025,7 @@ var WeaveRegisterManager = class {
|
|
|
22019
22025
|
|
|
22020
22026
|
//#endregion
|
|
22021
22027
|
//#region package.json
|
|
22022
|
-
var version = "3.9.0
|
|
22028
|
+
var version = "3.9.0";
|
|
22023
22029
|
|
|
22024
22030
|
//#endregion
|
|
22025
22031
|
//#region src/managers/setup.ts
|
|
@@ -25720,7 +25726,7 @@ const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
|
25720
25726
|
cursor: { loading: "wait" }
|
|
25721
25727
|
},
|
|
25722
25728
|
imageLoading: {
|
|
25723
|
-
maxRetryAttempts:
|
|
25729
|
+
maxRetryAttempts: 3,
|
|
25724
25730
|
retryDelayMs: 2e3
|
|
25725
25731
|
},
|
|
25726
25732
|
crossOrigin: "anonymous",
|
|
@@ -25770,19 +25776,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25770
25776
|
this.onClose = () => {};
|
|
25771
25777
|
this.handleHide = this.hide.bind(this);
|
|
25772
25778
|
}
|
|
25773
|
-
|
|
25774
|
-
this.onClose = onClose;
|
|
25775
|
-
const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
25776
|
-
if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
|
|
25777
|
-
const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
|
|
25778
|
-
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
25779
|
-
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
25780
|
-
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
25781
|
-
this.node.clearCache(this.image);
|
|
25782
|
-
this.image.setAttrs({ cropping: true });
|
|
25783
|
-
this.image.listening(false);
|
|
25784
|
-
const imageAttrs = this.image.getAttrs();
|
|
25785
|
-
this.internalImage.hide();
|
|
25779
|
+
setupCropImage(imageAttrs, visible) {
|
|
25786
25780
|
this.cropGroup.destroyChildren();
|
|
25787
25781
|
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
25788
25782
|
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
@@ -25796,10 +25790,26 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25796
25790
|
scaleY: 1,
|
|
25797
25791
|
image: this.internalImage.image(),
|
|
25798
25792
|
crop: void 0,
|
|
25799
|
-
visible
|
|
25793
|
+
visible,
|
|
25800
25794
|
listening: false,
|
|
25801
25795
|
draggable: false
|
|
25802
25796
|
});
|
|
25797
|
+
return { realScale };
|
|
25798
|
+
}
|
|
25799
|
+
show(onClose, options) {
|
|
25800
|
+
this.onClose = onClose;
|
|
25801
|
+
const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
25802
|
+
if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
|
|
25803
|
+
const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
|
|
25804
|
+
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
25805
|
+
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
25806
|
+
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
25807
|
+
this.node.clearCache(this.image);
|
|
25808
|
+
this.image.setAttrs({ cropping: true });
|
|
25809
|
+
this.image.listening(false);
|
|
25810
|
+
const imageAttrs = this.image.getAttrs();
|
|
25811
|
+
this.internalImage.hide();
|
|
25812
|
+
const { realScale } = this.setupCropImage(imageAttrs, true);
|
|
25803
25813
|
this.imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
|
|
25804
25814
|
this.imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
|
|
25805
25815
|
const cropModeConfiguration = this.node.getConfiguration().cropMode;
|
|
@@ -26176,23 +26186,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
26176
26186
|
}
|
|
26177
26187
|
unCrop() {
|
|
26178
26188
|
const imageAttrs = this.image.getAttrs();
|
|
26179
|
-
this.
|
|
26180
|
-
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
26181
|
-
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
26182
|
-
const realScale = actualScale / cropScale;
|
|
26183
|
-
this.cropImage = new Konva.Image({
|
|
26184
|
-
x: imageAttrs.cropInfo ? -imageAttrs.cropInfo.x * realScale : 0,
|
|
26185
|
-
y: imageAttrs.cropInfo ? -imageAttrs.cropInfo.y * realScale : 0,
|
|
26186
|
-
width: imageAttrs.uncroppedImage.width,
|
|
26187
|
-
height: imageAttrs.uncroppedImage.height,
|
|
26188
|
-
scaleX: 1,
|
|
26189
|
-
scaleY: 1,
|
|
26190
|
-
image: this.internalImage.image(),
|
|
26191
|
-
crop: void 0,
|
|
26192
|
-
visible: false,
|
|
26193
|
-
listening: false,
|
|
26194
|
-
draggable: false
|
|
26195
|
-
});
|
|
26189
|
+
this.setupCropImage(imageAttrs, false);
|
|
26196
26190
|
this.cropGroup.add(this.cropImage);
|
|
26197
26191
|
const cropImageStage = this.cropImage.getAbsolutePosition();
|
|
26198
26192
|
this.image.setAttrs({
|
|
@@ -26241,12 +26235,80 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
26241
26235
|
this.instance.updateNode(this.node.serialize(this.image));
|
|
26242
26236
|
}
|
|
26243
26237
|
}
|
|
26238
|
+
handleClipExternal(image, reference) {
|
|
26239
|
+
const stage = this.instance.getStage();
|
|
26240
|
+
const originalRotation = image.getAbsoluteRotation();
|
|
26241
|
+
if (image.getAbsoluteRotation() !== reference.getAbsoluteRotation()) throw new Error("Image and reference must have the same rotation", { cause: "RotationNotAligned" });
|
|
26242
|
+
const originalContainer = image.getParent();
|
|
26243
|
+
const group = new Konva.Group();
|
|
26244
|
+
image.moveTo(group);
|
|
26245
|
+
reference.moveTo(group);
|
|
26246
|
+
originalContainer?.add(group);
|
|
26247
|
+
group.rotate(-originalRotation);
|
|
26248
|
+
const dImage = group.findOne("#" + image.getAttrs().id);
|
|
26249
|
+
const dReference = group.findOne("#" + reference.getAttrs().id);
|
|
26250
|
+
const intersectionRectAbs = this.getIntersectionRect(dImage, dReference);
|
|
26251
|
+
const intersectionRect = this.getIntersectionRect(dImage, dReference, stage);
|
|
26252
|
+
const imageRect = dImage.getClientRect({
|
|
26253
|
+
relativeTo: stage,
|
|
26254
|
+
skipStroke: true
|
|
26255
|
+
});
|
|
26256
|
+
if (!intersectionRect || !intersectionRectAbs) return;
|
|
26257
|
+
const imageAttrs = this.image.getAttrs();
|
|
26258
|
+
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
26259
|
+
const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
|
|
26260
|
+
const realScale = actualScale / cropScale;
|
|
26261
|
+
const imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
|
|
26262
|
+
const imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
|
|
26263
|
+
const diffX = intersectionRect.x - imageRect.x;
|
|
26264
|
+
const diffY = intersectionRect.y - imageRect.y;
|
|
26265
|
+
const realClipRect = {
|
|
26266
|
+
scaleX: actualScale,
|
|
26267
|
+
scaleY: actualScale,
|
|
26268
|
+
x: WeaveImageCrop.roundTo6Decimals(diffX + imageOffsetX),
|
|
26269
|
+
y: WeaveImageCrop.roundTo6Decimals(diffY + imageOffsetY),
|
|
26270
|
+
width: WeaveImageCrop.roundTo6Decimals(intersectionRect.width),
|
|
26271
|
+
height: WeaveImageCrop.roundTo6Decimals(intersectionRect.height)
|
|
26272
|
+
};
|
|
26273
|
+
if (dImage) {
|
|
26274
|
+
const cropSize = {
|
|
26275
|
+
x: diffX,
|
|
26276
|
+
y: diffY,
|
|
26277
|
+
width: intersectionRect.width,
|
|
26278
|
+
height: intersectionRect.height
|
|
26279
|
+
};
|
|
26280
|
+
dImage.setAttrs({
|
|
26281
|
+
width: intersectionRect.width,
|
|
26282
|
+
height: intersectionRect.height,
|
|
26283
|
+
cropInfo: realClipRect,
|
|
26284
|
+
cropSize,
|
|
26285
|
+
uncroppedImage: {
|
|
26286
|
+
width: imageAttrs.uncroppedImage.width,
|
|
26287
|
+
height: imageAttrs.uncroppedImage.height
|
|
26288
|
+
}
|
|
26289
|
+
});
|
|
26290
|
+
dImage.setAbsolutePosition(intersectionRectAbs);
|
|
26291
|
+
group.rotate(originalRotation);
|
|
26292
|
+
group.getChildren().forEach((child) => {
|
|
26293
|
+
child.moveTo(originalContainer);
|
|
26294
|
+
});
|
|
26295
|
+
group.destroy();
|
|
26296
|
+
const fImage = stage.findOne("#" + image.getAttrs().id);
|
|
26297
|
+
if (fImage) this.instance.updateNodeNT(this.node.serialize(fImage));
|
|
26298
|
+
}
|
|
26299
|
+
}
|
|
26244
26300
|
static roundTo6Decimals(value) {
|
|
26245
26301
|
return parseFloat(value.toFixed(6));
|
|
26246
26302
|
}
|
|
26247
|
-
getIntersectionRect(a, b) {
|
|
26248
|
-
const rectA = a.getClientRect({
|
|
26249
|
-
|
|
26303
|
+
getIntersectionRect(a, b, relativeTo) {
|
|
26304
|
+
const rectA = a.getClientRect({
|
|
26305
|
+
skipStroke: true,
|
|
26306
|
+
relativeTo
|
|
26307
|
+
});
|
|
26308
|
+
const rectB = b.getClientRect({
|
|
26309
|
+
skipStroke: true,
|
|
26310
|
+
relativeTo
|
|
26311
|
+
});
|
|
26250
26312
|
const x1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.x, rectB.x));
|
|
26251
26313
|
const y1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.y, rectB.y));
|
|
26252
26314
|
const x2 = WeaveImageCrop.roundTo6Decimals(Math.min(rectA.x + rectA.width, rectB.x + rectB.width));
|
|
@@ -26738,8 +26800,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26738
26800
|
y: p.y - offsetY
|
|
26739
26801
|
}));
|
|
26740
26802
|
const rect = new Konva.Rect({
|
|
26741
|
-
width: absoluteCorners[1].x - absoluteCorners[0].x,
|
|
26742
|
-
height: absoluteCorners[
|
|
26803
|
+
width: Math.hypot(absoluteCorners[1].x - absoluteCorners[0].x, absoluteCorners[1].y - absoluteCorners[0].y),
|
|
26804
|
+
height: Math.hypot(absoluteCorners[3].x - absoluteCorners[0].x, absoluteCorners[3].y - absoluteCorners[0].y),
|
|
26743
26805
|
fill: "transparent",
|
|
26744
26806
|
strokeScaleEnabled: false,
|
|
26745
26807
|
strokeWidth: 2,
|
|
@@ -26864,7 +26926,11 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26864
26926
|
onUpdate(nodeInstance, nextProps) {
|
|
26865
26927
|
const id = nodeInstance.getAttrs().id;
|
|
26866
26928
|
const node = nodeInstance;
|
|
26867
|
-
nodeInstance.setAttrs({
|
|
26929
|
+
nodeInstance.setAttrs({
|
|
26930
|
+
...nextProps,
|
|
26931
|
+
...nextProps.cropInfo ? { cropInfo: nextProps.cropInfo } : { cropInfo: void 0 },
|
|
26932
|
+
...nextProps.cropSize ? { cropSize: nextProps.cropSize } : { cropSize: void 0 }
|
|
26933
|
+
});
|
|
26868
26934
|
const imagePlaceholder = node.findOne(`#${id}-placeholder`);
|
|
26869
26935
|
const internalImage = node.findOne(`#${id}-image`);
|
|
26870
26936
|
const nodeAttrs = node.getAttrs();
|
|
@@ -26908,29 +26974,12 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26908
26974
|
});
|
|
26909
26975
|
}
|
|
26910
26976
|
if (this.imageState[id ?? ""]?.loaded && this.imageState[id ?? ""]?.error) {
|
|
26911
|
-
imagePlaceholder?.setAttrs({
|
|
26912
|
-
...internalImageProps,
|
|
26913
|
-
...nodeAttrs.imageProperties ?? {},
|
|
26914
|
-
name: void 0,
|
|
26915
|
-
id: `${id}-placeholder`,
|
|
26916
|
-
nodeId: id,
|
|
26917
|
-
x: 0,
|
|
26918
|
-
y: 0,
|
|
26919
|
-
scaleX: 1,
|
|
26920
|
-
scaleY: 1,
|
|
26921
|
-
rotation: 0,
|
|
26922
|
-
visible: true,
|
|
26923
|
-
fill: this.config.style.placeholder.fill,
|
|
26924
|
-
strokeWidth: 0,
|
|
26925
|
-
draggable: false,
|
|
26926
|
-
zIndex: 0
|
|
26927
|
-
});
|
|
26928
26977
|
internalImage?.setAttrs({
|
|
26929
26978
|
...internalImageProps,
|
|
26930
26979
|
...nodeAttrs.imageProperties ?? {},
|
|
26931
26980
|
name: void 0,
|
|
26932
26981
|
id: `${id}-image`,
|
|
26933
|
-
image:
|
|
26982
|
+
image: this.imageFallback[id ?? ""],
|
|
26934
26983
|
nodeId: id,
|
|
26935
26984
|
x: 0,
|
|
26936
26985
|
y: 0,
|
|
@@ -26941,6 +26990,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26941
26990
|
draggable: false,
|
|
26942
26991
|
zIndex: 1
|
|
26943
26992
|
});
|
|
26993
|
+
internalImage?.visible(true);
|
|
26994
|
+
this.updateImageCrop(nodeInstance);
|
|
26944
26995
|
}
|
|
26945
26996
|
if (this.imageState[id ?? ""]?.loaded && !this.imageState[id ?? ""]?.error) {
|
|
26946
26997
|
internalImage?.setAttrs({
|
|
@@ -26995,14 +27046,18 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
26995
27046
|
}
|
|
26996
27047
|
preloadImage(imageId, imageURL, { onLoad, onError }, loadingTryout = false) {
|
|
26997
27048
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27049
|
+
if (imageURLToLoad === "") {
|
|
27050
|
+
this.setErrorState(imageId);
|
|
27051
|
+
return;
|
|
27052
|
+
}
|
|
26998
27053
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
26999
27054
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
27000
27055
|
this.imageSource[imageId].onerror = (error) => {
|
|
27001
|
-
if (!loadingTryout)
|
|
27002
|
-
|
|
27003
|
-
|
|
27004
|
-
|
|
27005
|
-
}
|
|
27056
|
+
if (!loadingTryout) {
|
|
27057
|
+
const stage = this.instance.getStage();
|
|
27058
|
+
const image = stage.findOne(`#${imageId}`);
|
|
27059
|
+
if (image) this.setErrorState(imageId, image);
|
|
27060
|
+
}
|
|
27006
27061
|
onError(error);
|
|
27007
27062
|
};
|
|
27008
27063
|
this.imageSource[imageId].onload = async () => {
|
|
@@ -27097,36 +27152,29 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27097
27152
|
}
|
|
27098
27153
|
},
|
|
27099
27154
|
onError: (error) => {
|
|
27100
|
-
if (!this.config.useFallbackImage)
|
|
27101
|
-
const
|
|
27102
|
-
if (
|
|
27103
|
-
this.
|
|
27104
|
-
|
|
27105
|
-
}
|
|
27106
|
-
}
|
|
27155
|
+
if (!this.config.useFallbackImage) {
|
|
27156
|
+
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27157
|
+
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27158
|
+
this.loadImageTryout(id);
|
|
27159
|
+
return;
|
|
27160
|
+
} else this.setErrorState(id, image);
|
|
27161
|
+
}
|
|
27107
27162
|
if (loadTryout) {
|
|
27108
27163
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27109
|
-
if (tryoutAttempts < this.config.imageLoading.maxRetryAttempts)
|
|
27110
|
-
|
|
27111
|
-
|
|
27112
|
-
|
|
27113
|
-
this.loadImage(node.getAttrs(), node, false, true);
|
|
27114
|
-
}
|
|
27115
|
-
}, this.config.imageLoading.retryDelayMs);
|
|
27164
|
+
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27165
|
+
this.loadImageTryout(id);
|
|
27166
|
+
return;
|
|
27167
|
+
} else this.setErrorState(id, image);
|
|
27116
27168
|
return;
|
|
27117
27169
|
}
|
|
27118
27170
|
if (this.config.useFallbackImage && !useFallback && !loadTryout && imageProps.imageFallback) {
|
|
27119
27171
|
this.loadImage({ ...params }, image, true);
|
|
27120
27172
|
return;
|
|
27121
27173
|
}
|
|
27122
|
-
this.
|
|
27123
|
-
status: "error",
|
|
27124
|
-
loaded: false,
|
|
27125
|
-
error: true
|
|
27126
|
-
};
|
|
27174
|
+
this.setErrorState(id, image);
|
|
27127
27175
|
image.setAttrs({ image: void 0 });
|
|
27176
|
+
console.error("Error loading image", error);
|
|
27128
27177
|
this.resolveAsyncElement(id);
|
|
27129
|
-
console.error("Error loading image", realImageURL, error);
|
|
27130
27178
|
imagePlaceholder?.setAttrs({ visible: true });
|
|
27131
27179
|
internalImage?.setAttrs({ visible: false });
|
|
27132
27180
|
this.cacheNode(image);
|
|
@@ -27256,6 +27304,41 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27256
27304
|
}
|
|
27257
27305
|
nodeInstance.destroy();
|
|
27258
27306
|
}
|
|
27307
|
+
loadImageTryout(imageId) {
|
|
27308
|
+
this.imageTryoutIds[imageId] = setTimeout(() => {
|
|
27309
|
+
const node = this.instance.getStage().findOne(`#${imageId}`);
|
|
27310
|
+
if (node) {
|
|
27311
|
+
const tryoutAttempts = this.imageTryoutAttempts[imageId] ?? 0;
|
|
27312
|
+
this.imageTryoutAttempts[imageId] = tryoutAttempts + 1;
|
|
27313
|
+
this.loadImage(node.getAttrs(), node, false, true);
|
|
27314
|
+
}
|
|
27315
|
+
}, this.config.imageLoading.retryDelayMs);
|
|
27316
|
+
}
|
|
27317
|
+
setErrorState(imageId, image) {
|
|
27318
|
+
this.imageState[imageId] = {
|
|
27319
|
+
status: "loaded",
|
|
27320
|
+
loaded: true,
|
|
27321
|
+
error: true
|
|
27322
|
+
};
|
|
27323
|
+
this.resolveAsyncElement(imageId);
|
|
27324
|
+
if (image) this.cacheNode(image);
|
|
27325
|
+
}
|
|
27326
|
+
cropImageWithReference(image, reference) {
|
|
27327
|
+
const internalImage = image?.findOne(`#${image.getAttrs().id}-image`);
|
|
27328
|
+
const cropGroup = image?.findOne(`#${image.getAttrs().id}-cropGroup`);
|
|
27329
|
+
if (!internalImage || !cropGroup) throw new Error("Provided element is not a valid image node.", { cause: "InvalidImageNode" });
|
|
27330
|
+
this.imageCrop = new WeaveImageCrop(this.instance, this, image, internalImage, cropGroup);
|
|
27331
|
+
this.instance.stateTransactional(() => {
|
|
27332
|
+
this.imageCrop?.handleClipExternal(image, reference);
|
|
27333
|
+
const nodeHandler = this.instance.getNodeHandler(reference.getAttrs().nodeType);
|
|
27334
|
+
if (nodeHandler) {
|
|
27335
|
+
const rectangleState = nodeHandler.serialize(reference);
|
|
27336
|
+
this.instance.removeNodeNT(rectangleState);
|
|
27337
|
+
}
|
|
27338
|
+
});
|
|
27339
|
+
this.getNodesSelectionPlugin()?.setSelectedNodes([image]);
|
|
27340
|
+
this.getNodesSelectionPlugin()?.getHoverTransformer().forceUpdate();
|
|
27341
|
+
}
|
|
27259
27342
|
};
|
|
27260
27343
|
|
|
27261
27344
|
//#endregion
|
|
@@ -34428,14 +34511,15 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34428
34511
|
const dragProperties = this.instance.getDragProperties();
|
|
34429
34512
|
if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
|
|
34430
34513
|
this.instance.getStage().setPointersPositions(e);
|
|
34431
|
-
const
|
|
34432
|
-
if (!
|
|
34514
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
34515
|
+
if (!mousePoint) return;
|
|
34433
34516
|
this.instance.triggerAction(WEAVE_IMAGE_TOOL_ACTION_NAME, {
|
|
34434
34517
|
type: WEAVE_IMAGE_TOOL_UPLOAD_TYPE.IMAGE_URL,
|
|
34435
34518
|
image: dragProperties.imageURL,
|
|
34436
34519
|
...dragProperties.imageId ? { imageId: dragProperties.imageId } : {},
|
|
34437
34520
|
...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer },
|
|
34438
|
-
|
|
34521
|
+
container,
|
|
34522
|
+
position: mousePoint
|
|
34439
34523
|
});
|
|
34440
34524
|
}
|
|
34441
34525
|
});
|
|
@@ -34602,7 +34686,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34602
34686
|
}
|
|
34603
34687
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
34604
34688
|
this.imageAction[nodeId].clickPoint = mousePoint;
|
|
34605
|
-
this.imageAction[nodeId].container = container;
|
|
34689
|
+
this.imageAction[nodeId].container = this.imageAction[nodeId].container ?? container;
|
|
34606
34690
|
const nodeHandler = this.instance.getNodeHandler("image");
|
|
34607
34691
|
const imageWidth = this.imageAction[nodeId].props.width ? this.imageAction[nodeId].props.width : imageSource?.width;
|
|
34608
34692
|
const imageHeight = this.imageAction[nodeId].props.height ? this.imageAction[nodeId].props.height : imageSource?.height;
|
|
@@ -34669,9 +34753,9 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
34669
34753
|
props: this.initProps(),
|
|
34670
34754
|
imageId: nodeId,
|
|
34671
34755
|
clickPoint: null,
|
|
34672
|
-
container: void 0,
|
|
34673
34756
|
imageFile: null,
|
|
34674
34757
|
imageURL: null,
|
|
34758
|
+
container: params?.container,
|
|
34675
34759
|
forceMainContainer: params?.forceMainContainer ?? false,
|
|
34676
34760
|
uploadType: null,
|
|
34677
34761
|
uploadImageFunction: null
|
|
@@ -34878,12 +34962,13 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
34878
34962
|
const dragProperties = this.instance.getDragProperties();
|
|
34879
34963
|
if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
|
|
34880
34964
|
this.instance.getStage().setPointersPositions(e);
|
|
34881
|
-
const
|
|
34882
|
-
if (!
|
|
34965
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
34966
|
+
if (!mousePoint) return;
|
|
34883
34967
|
this.instance.triggerAction(WEAVE_IMAGES_TOOL_ACTION_NAME, {
|
|
34884
34968
|
type: WEAVE_IMAGES_TOOL_UPLOAD_TYPE.IMAGE_URL,
|
|
34885
34969
|
images: dragProperties.imagesURL,
|
|
34886
|
-
|
|
34970
|
+
container,
|
|
34971
|
+
position: mousePoint,
|
|
34887
34972
|
...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
|
|
34888
34973
|
});
|
|
34889
34974
|
}
|
|
@@ -35044,7 +35129,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35044
35129
|
stage.container().style.cursor = "default";
|
|
35045
35130
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
35046
35131
|
this.clickPoint = mousePoint;
|
|
35047
|
-
this.container = container;
|
|
35132
|
+
this.container = this.container ?? container;
|
|
35048
35133
|
const originPoint = {
|
|
35049
35134
|
x: this.clickPoint?.x ?? 0,
|
|
35050
35135
|
y: this.clickPoint?.y ?? 0
|
|
@@ -35099,10 +35184,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35099
35184
|
},
|
|
35100
35185
|
uploadImageFunction: uploadImageFunctionInternal,
|
|
35101
35186
|
...imageId && { imageId },
|
|
35102
|
-
position:
|
|
35103
|
-
|
|
35104
|
-
y: position$1.y
|
|
35105
|
-
},
|
|
35187
|
+
position: position$1,
|
|
35188
|
+
container: this.container,
|
|
35106
35189
|
forceMainContainer: this.forceMainContainer,
|
|
35107
35190
|
nodeId: nodeId$1
|
|
35108
35191
|
}, true);
|
|
@@ -35136,10 +35219,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35136
35219
|
},
|
|
35137
35220
|
...imageId && { imageId },
|
|
35138
35221
|
...options && { options },
|
|
35139
|
-
position:
|
|
35140
|
-
|
|
35141
|
-
y: position$1.y
|
|
35142
|
-
},
|
|
35222
|
+
position: position$1,
|
|
35223
|
+
container: this.container,
|
|
35143
35224
|
forceMainContainer: this.forceMainContainer,
|
|
35144
35225
|
nodeId: nodeId$1
|
|
35145
35226
|
}, true);
|
|
@@ -35172,6 +35253,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
|
|
|
35172
35253
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
35173
35254
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
35174
35255
|
if (params?.position) this.setState(WEAVE_IMAGES_TOOL_STATE.SELECTED_POSITION);
|
|
35256
|
+
if (params?.container) this.container = params.container;
|
|
35175
35257
|
this.nodesIds = [];
|
|
35176
35258
|
this.forceMainContainer = params.forceMainContainer ?? false;
|
|
35177
35259
|
if (params.type === WEAVE_IMAGES_TOOL_UPLOAD_TYPE.FILE) {
|
|
@@ -36989,11 +37071,13 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
36989
37071
|
const dragProperties = this.instance.getDragProperties();
|
|
36990
37072
|
if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
|
|
36991
37073
|
this.instance.getStage().setPointersPositions(e);
|
|
36992
|
-
const
|
|
37074
|
+
const { mousePoint, container } = this.instance.getMousePointer();
|
|
37075
|
+
if (!mousePoint) return;
|
|
36993
37076
|
this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
|
|
36994
37077
|
videoId: dragProperties.videoId,
|
|
36995
37078
|
videoParams: dragProperties.videoParams,
|
|
36996
|
-
|
|
37079
|
+
container,
|
|
37080
|
+
position: mousePoint
|
|
36997
37081
|
});
|
|
36998
37082
|
}
|
|
36999
37083
|
});
|
|
@@ -37044,7 +37128,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
37044
37128
|
if (this.videoId && this.videoParams) {
|
|
37045
37129
|
const { mousePoint, container } = this.instance.getMousePointer(position);
|
|
37046
37130
|
this.clickPoint = mousePoint;
|
|
37047
|
-
this.container = container;
|
|
37131
|
+
this.container = this.container ?? container;
|
|
37048
37132
|
const nodeHandler = this.instance.getNodeHandler("video");
|
|
37049
37133
|
if (nodeHandler) {
|
|
37050
37134
|
const node = nodeHandler.create(this.videoId, {
|
|
@@ -37075,6 +37159,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
|
|
|
37075
37159
|
this.cancelAction = cancelAction;
|
|
37076
37160
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
37077
37161
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
37162
|
+
this.container = params?.container;
|
|
37078
37163
|
this.forceMainContainer = params?.forceMainContainer ?? false;
|
|
37079
37164
|
if (params?.videoId) this.updateProps({ videoId: params.videoId });
|
|
37080
37165
|
if (params?.videoParams) {
|