@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/types.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
- if (this.getDragSelectedNodes().length > 1) this.setNodesOpacityOnDrag();
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
- if (this.getSelectionPlugin()?.getDragSelectedNodes().length === 1) this.getSelectionPlugin()?.restoreNodesOpacityOnDrag();
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.ctrlKey || e.evt.metaKey;
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
  }
@@ -21424,10 +21421,16 @@ var WeaveTargetingManager = class {
21424
21421
  const utilityLayer = this.instance.getUtilityLayer();
21425
21422
  if (utilityLayer) utilityLayer.visible(false);
21426
21423
  let containerAlt = containerOverCursor(this.instance, [], relativeMousePointer);
21427
- if (!containerAlt) containerAlt = this.instance.getMainLayer();
21428
21424
  const nodesSelection = this.instance.getPlugin("nodesSelection");
21429
21425
  if (nodesSelection) nodesSelection.getTransformer().visible(false);
21430
- relativeMousePointer = containerAlt?.getRelativePointerPosition() ?? relativeMousePointer;
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
+ }
21431
21434
  if (utilityLayer) utilityLayer.visible(true);
21432
21435
  if (nodesSelection) nodesSelection.getTransformer().visible(true);
21433
21436
  return {
@@ -22022,7 +22025,7 @@ var WeaveRegisterManager = class {
22022
22025
 
22023
22026
  //#endregion
22024
22027
  //#region package.json
22025
- var version = "3.9.0-SNAPSHOT.184.1";
22028
+ var version = "3.9.0";
22026
22029
 
22027
22030
  //#endregion
22028
22031
  //#region src/managers/setup.ts
@@ -25723,7 +25726,7 @@ const WEAVE_IMAGE_DEFAULT_CONFIG = {
25723
25726
  cursor: { loading: "wait" }
25724
25727
  },
25725
25728
  imageLoading: {
25726
- maxRetryAttempts: 15,
25729
+ maxRetryAttempts: 3,
25727
25730
  retryDelayMs: 2e3
25728
25731
  },
25729
25732
  crossOrigin: "anonymous",
@@ -25773,19 +25776,7 @@ var WeaveImageCrop = class WeaveImageCrop {
25773
25776
  this.onClose = () => {};
25774
25777
  this.handleHide = this.hide.bind(this);
25775
25778
  }
25776
- show(onClose, options) {
25777
- this.onClose = onClose;
25778
- const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
25779
- if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
25780
- const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
25781
- if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
25782
- const nodesSelectionPlugin = this.getNodesSelectionPlugin();
25783
- if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
25784
- this.node.clearCache(this.image);
25785
- this.image.setAttrs({ cropping: true });
25786
- this.image.listening(false);
25787
- const imageAttrs = this.image.getAttrs();
25788
- this.internalImage.hide();
25779
+ setupCropImage(imageAttrs, visible) {
25789
25780
  this.cropGroup.destroyChildren();
25790
25781
  const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
25791
25782
  const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
@@ -25799,10 +25790,26 @@ var WeaveImageCrop = class WeaveImageCrop {
25799
25790
  scaleY: 1,
25800
25791
  image: this.internalImage.image(),
25801
25792
  crop: void 0,
25802
- visible: true,
25793
+ visible,
25803
25794
  listening: false,
25804
25795
  draggable: false
25805
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);
25806
25813
  this.imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
25807
25814
  this.imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
25808
25815
  const cropModeConfiguration = this.node.getConfiguration().cropMode;
@@ -26179,23 +26186,7 @@ var WeaveImageCrop = class WeaveImageCrop {
26179
26186
  }
26180
26187
  unCrop() {
26181
26188
  const imageAttrs = this.image.getAttrs();
26182
- this.cropGroup.destroyChildren();
26183
- const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
26184
- const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
26185
- const realScale = actualScale / cropScale;
26186
- this.cropImage = new Konva.Image({
26187
- x: imageAttrs.cropInfo ? -imageAttrs.cropInfo.x * realScale : 0,
26188
- y: imageAttrs.cropInfo ? -imageAttrs.cropInfo.y * realScale : 0,
26189
- width: imageAttrs.uncroppedImage.width,
26190
- height: imageAttrs.uncroppedImage.height,
26191
- scaleX: 1,
26192
- scaleY: 1,
26193
- image: this.internalImage.image(),
26194
- crop: void 0,
26195
- visible: false,
26196
- listening: false,
26197
- draggable: false
26198
- });
26189
+ this.setupCropImage(imageAttrs, false);
26199
26190
  this.cropGroup.add(this.cropImage);
26200
26191
  const cropImageStage = this.cropImage.getAbsolutePosition();
26201
26192
  this.image.setAttrs({
@@ -26244,12 +26235,80 @@ var WeaveImageCrop = class WeaveImageCrop {
26244
26235
  this.instance.updateNode(this.node.serialize(this.image));
26245
26236
  }
26246
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
+ }
26247
26300
  static roundTo6Decimals(value) {
26248
26301
  return parseFloat(value.toFixed(6));
26249
26302
  }
26250
- getIntersectionRect(a, b) {
26251
- const rectA = a.getClientRect({ skipStroke: true });
26252
- const rectB = b.getClientRect({ skipStroke: true });
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
+ });
26253
26312
  const x1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.x, rectB.x));
26254
26313
  const y1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.y, rectB.y));
26255
26314
  const x2 = WeaveImageCrop.roundTo6Decimals(Math.min(rectA.x + rectA.width, rectB.x + rectB.width));
@@ -26741,8 +26800,8 @@ var WeaveImageNode = class extends WeaveNode {
26741
26800
  y: p.y - offsetY
26742
26801
  }));
26743
26802
  const rect = new Konva.Rect({
26744
- width: absoluteCorners[1].x - absoluteCorners[0].x,
26745
- height: absoluteCorners[2].y - absoluteCorners[0].y,
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),
26746
26805
  fill: "transparent",
26747
26806
  strokeScaleEnabled: false,
26748
26807
  strokeWidth: 2,
@@ -26867,7 +26926,11 @@ var WeaveImageNode = class extends WeaveNode {
26867
26926
  onUpdate(nodeInstance, nextProps) {
26868
26927
  const id = nodeInstance.getAttrs().id;
26869
26928
  const node = nodeInstance;
26870
- nodeInstance.setAttrs({ ...nextProps });
26929
+ nodeInstance.setAttrs({
26930
+ ...nextProps,
26931
+ ...nextProps.cropInfo ? { cropInfo: nextProps.cropInfo } : { cropInfo: void 0 },
26932
+ ...nextProps.cropSize ? { cropSize: nextProps.cropSize } : { cropSize: void 0 }
26933
+ });
26871
26934
  const imagePlaceholder = node.findOne(`#${id}-placeholder`);
26872
26935
  const internalImage = node.findOne(`#${id}-image`);
26873
26936
  const nodeAttrs = node.getAttrs();
@@ -26911,29 +26974,12 @@ var WeaveImageNode = class extends WeaveNode {
26911
26974
  });
26912
26975
  }
26913
26976
  if (this.imageState[id ?? ""]?.loaded && this.imageState[id ?? ""]?.error) {
26914
- imagePlaceholder?.setAttrs({
26915
- ...internalImageProps,
26916
- ...nodeAttrs.imageProperties ?? {},
26917
- name: void 0,
26918
- id: `${id}-placeholder`,
26919
- nodeId: id,
26920
- x: 0,
26921
- y: 0,
26922
- scaleX: 1,
26923
- scaleY: 1,
26924
- rotation: 0,
26925
- visible: true,
26926
- fill: this.config.style.placeholder.fill,
26927
- strokeWidth: 0,
26928
- draggable: false,
26929
- zIndex: 0
26930
- });
26931
26977
  internalImage?.setAttrs({
26932
26978
  ...internalImageProps,
26933
26979
  ...nodeAttrs.imageProperties ?? {},
26934
26980
  name: void 0,
26935
26981
  id: `${id}-image`,
26936
- image: void 0,
26982
+ image: this.imageFallback[id ?? ""],
26937
26983
  nodeId: id,
26938
26984
  x: 0,
26939
26985
  y: 0,
@@ -26944,6 +26990,8 @@ var WeaveImageNode = class extends WeaveNode {
26944
26990
  draggable: false,
26945
26991
  zIndex: 1
26946
26992
  });
26993
+ internalImage?.visible(true);
26994
+ this.updateImageCrop(nodeInstance);
26947
26995
  }
26948
26996
  if (this.imageState[id ?? ""]?.loaded && !this.imageState[id ?? ""]?.error) {
26949
26997
  internalImage?.setAttrs({
@@ -26998,14 +27046,18 @@ var WeaveImageNode = class extends WeaveNode {
26998
27046
  }
26999
27047
  preloadImage(imageId, imageURL, { onLoad, onError }, loadingTryout = false) {
27000
27048
  const imageURLToLoad = imageURL ?? "http://localhost/false-image";
27049
+ if (imageURLToLoad === "") {
27050
+ this.setErrorState(imageId);
27051
+ return;
27052
+ }
27001
27053
  this.imageSource[imageId] = Konva.Util.createImageElement();
27002
27054
  this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
27003
27055
  this.imageSource[imageId].onerror = (error) => {
27004
- if (!loadingTryout) this.imageState[imageId] = {
27005
- status: "error",
27006
- loaded: false,
27007
- error: true
27008
- };
27056
+ if (!loadingTryout) {
27057
+ const stage = this.instance.getStage();
27058
+ const image = stage.findOne(`#${imageId}`);
27059
+ if (image) this.setErrorState(imageId, image);
27060
+ }
27009
27061
  onError(error);
27010
27062
  };
27011
27063
  this.imageSource[imageId].onload = async () => {
@@ -27100,36 +27152,29 @@ var WeaveImageNode = class extends WeaveNode {
27100
27152
  }
27101
27153
  },
27102
27154
  onError: (error) => {
27103
- if (!this.config.useFallbackImage) this.imageTryoutIds[id] = setTimeout(() => {
27104
- const node = this.instance.getStage().findOne(`#${id}`);
27105
- if (node) {
27106
- this.imageTryoutAttempts[id] = (this.imageTryoutAttempts[id] ?? 0) + 1;
27107
- this.loadImage(node.getAttrs(), node, false, true);
27108
- }
27109
- }, this.config.imageLoading.retryDelayMs);
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
+ }
27110
27162
  if (loadTryout) {
27111
27163
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27112
- if (tryoutAttempts < this.config.imageLoading.maxRetryAttempts) this.imageTryoutIds[id] = setTimeout(() => {
27113
- const node = this.instance.getStage().findOne(`#${id}`);
27114
- if (node) {
27115
- this.imageTryoutAttempts[id] = tryoutAttempts + 1;
27116
- this.loadImage(node.getAttrs(), node, false, true);
27117
- }
27118
- }, this.config.imageLoading.retryDelayMs);
27164
+ if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27165
+ this.loadImageTryout(id);
27166
+ return;
27167
+ } else this.setErrorState(id, image);
27119
27168
  return;
27120
27169
  }
27121
27170
  if (this.config.useFallbackImage && !useFallback && !loadTryout && imageProps.imageFallback) {
27122
27171
  this.loadImage({ ...params }, image, true);
27123
27172
  return;
27124
27173
  }
27125
- this.imageState[id] = {
27126
- status: "error",
27127
- loaded: false,
27128
- error: true
27129
- };
27174
+ this.setErrorState(id, image);
27130
27175
  image.setAttrs({ image: void 0 });
27176
+ console.error("Error loading image", error);
27131
27177
  this.resolveAsyncElement(id);
27132
- console.error("Error loading image", realImageURL, error);
27133
27178
  imagePlaceholder?.setAttrs({ visible: true });
27134
27179
  internalImage?.setAttrs({ visible: false });
27135
27180
  this.cacheNode(image);
@@ -27259,6 +27304,41 @@ var WeaveImageNode = class extends WeaveNode {
27259
27304
  }
27260
27305
  nodeInstance.destroy();
27261
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
+ }
27262
27342
  };
27263
27343
 
27264
27344
  //#endregion
@@ -34431,14 +34511,15 @@ var WeaveImageToolAction = class extends WeaveAction {
34431
34511
  const dragProperties = this.instance.getDragProperties();
34432
34512
  if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
34433
34513
  this.instance.getStage().setPointersPositions(e);
34434
- const position = this.instance.getStage().getRelativePointerPosition();
34435
- if (!position) return;
34514
+ const { mousePoint, container } = this.instance.getMousePointer();
34515
+ if (!mousePoint) return;
34436
34516
  this.instance.triggerAction(WEAVE_IMAGE_TOOL_ACTION_NAME, {
34437
34517
  type: WEAVE_IMAGE_TOOL_UPLOAD_TYPE.IMAGE_URL,
34438
34518
  image: dragProperties.imageURL,
34439
34519
  ...dragProperties.imageId ? { imageId: dragProperties.imageId } : {},
34440
34520
  ...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer },
34441
- position
34521
+ container,
34522
+ position: mousePoint
34442
34523
  });
34443
34524
  }
34444
34525
  });
@@ -34605,7 +34686,7 @@ var WeaveImageToolAction = class extends WeaveAction {
34605
34686
  }
34606
34687
  const { mousePoint, container } = this.instance.getMousePointer(position);
34607
34688
  this.imageAction[nodeId].clickPoint = mousePoint;
34608
- this.imageAction[nodeId].container = container;
34689
+ this.imageAction[nodeId].container = this.imageAction[nodeId].container ?? container;
34609
34690
  const nodeHandler = this.instance.getNodeHandler("image");
34610
34691
  const imageWidth = this.imageAction[nodeId].props.width ? this.imageAction[nodeId].props.width : imageSource?.width;
34611
34692
  const imageHeight = this.imageAction[nodeId].props.height ? this.imageAction[nodeId].props.height : imageSource?.height;
@@ -34672,9 +34753,9 @@ var WeaveImageToolAction = class extends WeaveAction {
34672
34753
  props: this.initProps(),
34673
34754
  imageId: nodeId,
34674
34755
  clickPoint: null,
34675
- container: void 0,
34676
34756
  imageFile: null,
34677
34757
  imageURL: null,
34758
+ container: params?.container,
34678
34759
  forceMainContainer: params?.forceMainContainer ?? false,
34679
34760
  uploadType: null,
34680
34761
  uploadImageFunction: null
@@ -34881,12 +34962,13 @@ var WeaveImagesToolAction = class extends WeaveAction {
34881
34962
  const dragProperties = this.instance.getDragProperties();
34882
34963
  if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
34883
34964
  this.instance.getStage().setPointersPositions(e);
34884
- const position = this.instance.getStage().getRelativePointerPosition();
34885
- if (!position) return;
34965
+ const { mousePoint, container } = this.instance.getMousePointer();
34966
+ if (!mousePoint) return;
34886
34967
  this.instance.triggerAction(WEAVE_IMAGES_TOOL_ACTION_NAME, {
34887
34968
  type: WEAVE_IMAGES_TOOL_UPLOAD_TYPE.IMAGE_URL,
34888
34969
  images: dragProperties.imagesURL,
34889
- position,
34970
+ container,
34971
+ position: mousePoint,
34890
34972
  ...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
34891
34973
  });
34892
34974
  }
@@ -35047,7 +35129,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
35047
35129
  stage.container().style.cursor = "default";
35048
35130
  const { mousePoint, container } = this.instance.getMousePointer(position);
35049
35131
  this.clickPoint = mousePoint;
35050
- this.container = container;
35132
+ this.container = this.container ?? container;
35051
35133
  const originPoint = {
35052
35134
  x: this.clickPoint?.x ?? 0,
35053
35135
  y: this.clickPoint?.y ?? 0
@@ -35102,10 +35184,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
35102
35184
  },
35103
35185
  uploadImageFunction: uploadImageFunctionInternal,
35104
35186
  ...imageId && { imageId },
35105
- position: {
35106
- x: position$1.x,
35107
- y: position$1.y
35108
- },
35187
+ position: position$1,
35188
+ container: this.container,
35109
35189
  forceMainContainer: this.forceMainContainer,
35110
35190
  nodeId: nodeId$1
35111
35191
  }, true);
@@ -35139,10 +35219,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
35139
35219
  },
35140
35220
  ...imageId && { imageId },
35141
35221
  ...options && { options },
35142
- position: {
35143
- x: position$1.x,
35144
- y: position$1.y
35145
- },
35222
+ position: position$1,
35223
+ container: this.container,
35146
35224
  forceMainContainer: this.forceMainContainer,
35147
35225
  nodeId: nodeId$1
35148
35226
  }, true);
@@ -35175,6 +35253,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
35175
35253
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
35176
35254
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
35177
35255
  if (params?.position) this.setState(WEAVE_IMAGES_TOOL_STATE.SELECTED_POSITION);
35256
+ if (params?.container) this.container = params.container;
35178
35257
  this.nodesIds = [];
35179
35258
  this.forceMainContainer = params.forceMainContainer ?? false;
35180
35259
  if (params.type === WEAVE_IMAGES_TOOL_UPLOAD_TYPE.FILE) {
@@ -36992,11 +37071,13 @@ var WeaveVideoToolAction = class extends WeaveAction {
36992
37071
  const dragProperties = this.instance.getDragProperties();
36993
37072
  if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
36994
37073
  this.instance.getStage().setPointersPositions(e);
36995
- const position = this.instance.getStage().getRelativePointerPosition();
37074
+ const { mousePoint, container } = this.instance.getMousePointer();
37075
+ if (!mousePoint) return;
36996
37076
  this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
36997
37077
  videoId: dragProperties.videoId,
36998
37078
  videoParams: dragProperties.videoParams,
36999
- position
37079
+ container,
37080
+ position: mousePoint
37000
37081
  });
37001
37082
  }
37002
37083
  });
@@ -37047,7 +37128,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
37047
37128
  if (this.videoId && this.videoParams) {
37048
37129
  const { mousePoint, container } = this.instance.getMousePointer(position);
37049
37130
  this.clickPoint = mousePoint;
37050
- this.container = container;
37131
+ this.container = this.container ?? container;
37051
37132
  const nodeHandler = this.instance.getNodeHandler("video");
37052
37133
  if (nodeHandler) {
37053
37134
  const node = nodeHandler.create(this.videoId, {
@@ -37078,6 +37159,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
37078
37159
  this.cancelAction = cancelAction;
37079
37160
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
37080
37161
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
37162
+ this.container = params?.container;
37081
37163
  this.forceMainContainer = params?.forceMainContainer ?? false;
37082
37164
  if (params?.videoId) this.updateProps({ videoId: params.videoId });
37083
37165
  if (params?.videoParams) {