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