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