@inditextech/weave-sdk 0.23.1 → 0.24.1

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.cjs CHANGED
@@ -16362,11 +16362,13 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16362
16362
  if (!this.enabled) return;
16363
16363
  try {
16364
16364
  const continueToPaste = await this.readClipboardData();
16365
- if (!continueToPaste) {
16366
- this.instance.emitEvent("onPaste", new Error("Invalid elements to paste"));
16367
- return;
16365
+ if (continueToPaste) {
16366
+ const position = this.instance.getStage().getPointerPosition();
16367
+ if (position) {
16368
+ this.state = COPY_PASTE_NODES_PLUGIN_STATE.PASTING;
16369
+ this.handlePaste(position);
16370
+ }
16368
16371
  }
16369
- this.performPaste();
16370
16372
  } catch (ex) {
16371
16373
  this.instance.emitEvent("onPaste", ex);
16372
16374
  }
@@ -16374,11 +16376,16 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16374
16376
  const items = await navigator.clipboard.read();
16375
16377
  if (items && items.length === 1) {
16376
16378
  const item = items[0];
16377
- this.instance.emitEvent("onPasteExternal", item);
16379
+ const position = this.instance.getStage().getPointerPosition();
16380
+ if (position) this.instance.emitEvent("onPasteExternal", {
16381
+ position,
16382
+ item
16383
+ });
16378
16384
  }
16379
16385
  } catch (ex) {
16380
16386
  this.instance.emitEvent("onPaste", ex);
16381
16387
  }
16388
+ stage.container().focus();
16382
16389
  return;
16383
16390
  }
16384
16391
  if (e.key === "Escape") {
@@ -16386,14 +16393,6 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16386
16393
  return;
16387
16394
  }
16388
16395
  });
16389
- stage.on("click tap", (e) => {
16390
- e.evt.preventDefault();
16391
- if (this.state === COPY_PASTE_NODES_PLUGIN_STATE.IDLE) return;
16392
- if (this.state === COPY_PASTE_NODES_PLUGIN_STATE.PASTING) {
16393
- this.handlePaste();
16394
- return;
16395
- }
16396
- });
16397
16396
  }
16398
16397
  mapToPasteNodes() {
16399
16398
  const nodesSelectionPlugin = this.getNodesSelectionPlugin();
@@ -16414,9 +16413,9 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16414
16413
  if (child.props.children) this.recursivelyUpdateKeys(child.props.children);
16415
16414
  }
16416
16415
  }
16417
- handlePaste() {
16416
+ handlePaste(position) {
16418
16417
  if (this.toPaste) {
16419
- const { mousePoint, container } = this.instance.getMousePointer();
16418
+ const { mousePoint, container } = this.instance.getMousePointer(position);
16420
16419
  for (const element of Object.keys(this.toPaste.weave)) {
16421
16420
  const node = this.toPaste.weave[element];
16422
16421
  if (node.props.children) this.recursivelyUpdateKeys(node.props.children);
@@ -16463,23 +16462,28 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16463
16462
  }
16464
16463
  }
16465
16464
  }
16466
- performPaste() {
16467
- if (!this.enabled) return;
16468
- const stage = this.instance.getStage();
16469
- stage.container().style.cursor = "crosshair";
16470
- stage.container().focus();
16471
- this.state = COPY_PASTE_NODES_PLUGIN_STATE.PASTING;
16472
- }
16473
16465
  async copy() {
16474
16466
  await this.performCopy();
16475
16467
  }
16476
- async paste() {
16477
- const continueToPaste = await this.readClipboardData();
16478
- if (!continueToPaste) {
16479
- this.instance.emitEvent("onPaste", new Error("Invalid elements to paste"));
16480
- return;
16468
+ async paste(position) {
16469
+ try {
16470
+ const continueToPaste = await this.readClipboardData();
16471
+ if (continueToPaste) this.handlePaste(position);
16472
+ } catch (ex) {
16473
+ this.instance.emitEvent("onPaste", ex);
16474
+ }
16475
+ try {
16476
+ const items = await navigator.clipboard.read();
16477
+ if (items && items.length === 1) {
16478
+ const item = items[0];
16479
+ if (position) this.instance.emitEvent("onPasteExternal", {
16480
+ position,
16481
+ item
16482
+ });
16483
+ }
16484
+ } catch (ex) {
16485
+ this.instance.emitEvent("onPaste", ex);
16481
16486
  }
16482
- this.performPaste();
16483
16487
  }
16484
16488
  getSelectedNodes() {
16485
16489
  return this.mapToPasteNodes();
@@ -16509,12 +16513,12 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16509
16513
 
16510
16514
  //#endregion
16511
16515
  //#region src/nodes/node.ts
16512
- const setStageDefaultConfiguration = () => {
16516
+ const augmentKonvaStageClass = () => {
16513
16517
  konva.default.Stage.prototype.isMouseWheelPressed = function() {
16514
16518
  return false;
16515
16519
  };
16516
16520
  };
16517
- const setNodesDefaultConfiguration = (config) => {
16521
+ const augmentKonvaNodeClass = (config) => {
16518
16522
  const { transform } = config ?? {};
16519
16523
  konva.default.Node.prototype.getTransformerProperties = function() {
16520
16524
  return {
@@ -16550,6 +16554,14 @@ var WeaveNode = class {
16550
16554
  const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
16551
16555
  return copyPastePlugin.isPasting();
16552
16556
  }
16557
+ setupDefaultNodeAugmentation(node) {
16558
+ node.getTransformerProperties = () => {
16559
+ return __inditextech_weave_types.WEAVE_DEFAULT_TRANSFORM_PROPERTIES;
16560
+ };
16561
+ node.movedToContainer = () => {};
16562
+ node.updatePosition = () => {};
16563
+ node.resetCrop = () => {};
16564
+ }
16553
16565
  isNodeSelected(ele) {
16554
16566
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
16555
16567
  let selected = false;
@@ -17399,32 +17411,8 @@ var WeaveCloningManager = class {
17399
17411
  this.logger = this.instance.getChildLogger("cloning-manager");
17400
17412
  this.logger.debug("Cloning manager created");
17401
17413
  }
17402
- allInstancesInSameParent(nodes) {
17403
- if (nodes.length === 0) return {
17404
- allInSame: false,
17405
- nodeId: void 0,
17406
- parentId: void 0
17407
- };
17408
- let allInSame = true;
17409
- const parentId = nodes[0]?.getParent()?.getAttrs().id;
17410
- const nodeId = nodes[0]?.getParent()?.getAttrs().nodeId;
17411
- for (const node of nodes) {
17412
- const nodeParentId = node?.getParent()?.getAttrs().id;
17413
- if (nodeParentId !== parentId) {
17414
- allInSame = false;
17415
- break;
17416
- }
17417
- }
17418
- return {
17419
- allInSame,
17420
- nodeId,
17421
- parentId
17422
- };
17423
- }
17424
17414
  nodesToGroupSerialized(instancesToClone) {
17425
17415
  if (instancesToClone.length === 0) return;
17426
- const { allInSame } = this.allInstancesInSameParent(instancesToClone);
17427
- if (!allInSame) return;
17428
17416
  const groupId = v4_default();
17429
17417
  const newGroup = new konva.default.Group({ id: groupId });
17430
17418
  const nodesWithZIndex = instancesToClone.map((node) => ({
@@ -17441,6 +17429,21 @@ var WeaveCloningManager = class {
17441
17429
  });
17442
17430
  const nodePos$1 = clonedNode$1.getAbsolutePosition();
17443
17431
  const nodeRotation$1 = clonedNode$1.getAbsoluteRotation();
17432
+ const parent$1 = node.getParent();
17433
+ if (node.getAttrs().nodeId) {
17434
+ const realParent = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
17435
+ if (realParent) {
17436
+ nodePos$1.x += realParent.x();
17437
+ nodePos$1.y += realParent.y();
17438
+ }
17439
+ }
17440
+ if (parent$1 && parent$1.getAttrs().nodeId) {
17441
+ const realParent = this.instance.getStage().findOne(`#${parent$1.getAttrs().nodeId}`);
17442
+ if (realParent) {
17443
+ nodePos$1.x += realParent.x();
17444
+ nodePos$1.y += realParent.y();
17445
+ }
17446
+ }
17444
17447
  clonedNode$1.moveTo(newGroup);
17445
17448
  clonedNode$1.zIndex(index);
17446
17449
  clonedNode$1.setAbsolutePosition(nodePos$1);
@@ -17450,6 +17453,21 @@ var WeaveCloningManager = class {
17450
17453
  const clonedNode = node.clone({ id: v4_default() });
17451
17454
  const nodePos = clonedNode.getAbsolutePosition();
17452
17455
  const nodeRotation = clonedNode.getAbsoluteRotation();
17456
+ const parent = node.getParent();
17457
+ if (node.getAttrs().nodeId) {
17458
+ const realParent = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
17459
+ if (realParent) {
17460
+ nodePos.x += realParent.x();
17461
+ nodePos.y += realParent.y();
17462
+ }
17463
+ }
17464
+ if (parent && parent.getAttrs().nodeId) {
17465
+ const realParent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
17466
+ if (realParent) {
17467
+ nodePos.x += realParent.x();
17468
+ nodePos.y += realParent.y();
17469
+ }
17470
+ }
17453
17471
  clonedNode.moveTo(newGroup);
17454
17472
  clonedNode.zIndex(index);
17455
17473
  clonedNode.setAbsolutePosition(nodePos);
@@ -17463,10 +17481,8 @@ var WeaveCloningManager = class {
17463
17481
  newGroup.getChildren().forEach((node) => {
17464
17482
  const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
17465
17483
  const nodePos = node.getClientRect();
17466
- if (nodePos.x < minPoint.x || nodePos.y < minPoint.y) {
17467
- minPoint.x = nodePos.x;
17468
- minPoint.y = nodePos.y;
17469
- }
17484
+ if (nodePos.x < minPoint.x) minPoint.x = nodePos.x;
17485
+ if (nodePos.y < minPoint.y) minPoint.y = nodePos.y;
17470
17486
  const serialized = nodeHandler.serialize(node);
17471
17487
  serializedNodes.push(serialized);
17472
17488
  });
@@ -17479,8 +17495,6 @@ var WeaveCloningManager = class {
17479
17495
  cloneNodes(instancesToClone, targetContainer, onPoint) {
17480
17496
  if (instancesToClone.length === 0) return;
17481
17497
  if (!targetContainer) return;
17482
- const { allInSame } = this.allInstancesInSameParent(instancesToClone);
17483
- if (!allInSame) return;
17484
17498
  const groupId = v4_default();
17485
17499
  const newGroup = new konva.default.Group({ id: groupId });
17486
17500
  targetContainer.add(newGroup);
@@ -17498,6 +17512,14 @@ var WeaveCloningManager = class {
17498
17512
  });
17499
17513
  const nodePos$1 = clonedNode$1.getAbsolutePosition();
17500
17514
  const nodeRotation$1 = clonedNode$1.getAbsoluteRotation();
17515
+ const parent$1 = node.getParent();
17516
+ if (parent$1 && parent$1.getAttrs().nodeId && !parent$1.getAttrs().containerId) {
17517
+ const realParent = this.instance.getStage().findOne(`#${parent$1.getAttrs().nodeId}`);
17518
+ if (realParent) {
17519
+ nodePos$1.x += realParent.x();
17520
+ nodePos$1.y += realParent.y();
17521
+ }
17522
+ }
17501
17523
  clonedNode$1.moveTo(newGroup);
17502
17524
  clonedNode$1.zIndex(index);
17503
17525
  clonedNode$1.setAbsolutePosition(nodePos$1);
@@ -17507,6 +17529,14 @@ var WeaveCloningManager = class {
17507
17529
  const clonedNode = node.clone({ id: v4_default() });
17508
17530
  const nodePos = clonedNode.getAbsolutePosition();
17509
17531
  const nodeRotation = clonedNode.getAbsoluteRotation();
17532
+ const parent = node.getParent();
17533
+ if (parent && parent.getAttrs().nodeId && !parent.getAttrs().containerId) {
17534
+ const realParent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
17535
+ if (realParent) {
17536
+ nodePos.x += realParent.x();
17537
+ nodePos.y += realParent.y();
17538
+ }
17539
+ }
17510
17540
  clonedNode.moveTo(newGroup);
17511
17541
  clonedNode.zIndex(index);
17512
17542
  clonedNode.setAbsolutePosition(nodePos);
@@ -18102,7 +18132,7 @@ var WeaveRegisterManager = class {
18102
18132
 
18103
18133
  //#endregion
18104
18134
  //#region package.json
18105
- var version = "0.23.1";
18135
+ var version = "0.24.1";
18106
18136
 
18107
18137
  //#endregion
18108
18138
  //#region src/managers/setup.ts
@@ -18513,7 +18543,8 @@ var Weave = class extends Emittery {
18513
18543
  this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.STARTING;
18514
18544
  this.emitEvent("onInstanceStatus", this.status);
18515
18545
  this.registerManager.registerNodesHandlers();
18516
- this.setNodesDefaultConfiguration();
18546
+ this.augmentKonvaStageClass();
18547
+ this.augmentKonvaNodeClass();
18517
18548
  this.registerManager.registerPlugins();
18518
18549
  this.registerManager.registerActionsHandlers();
18519
18550
  this.storeManager.registerStore(this.config.store);
@@ -18543,11 +18574,11 @@ var Weave = class extends Emittery {
18543
18574
  getConfiguration() {
18544
18575
  return this.config;
18545
18576
  }
18546
- setStageDefaultConfiguration() {
18547
- setStageDefaultConfiguration();
18577
+ augmentKonvaStageClass() {
18578
+ augmentKonvaStageClass();
18548
18579
  }
18549
- setNodesDefaultConfiguration(config) {
18550
- setNodesDefaultConfiguration(config);
18580
+ augmentKonvaNodeClass(config) {
18581
+ augmentKonvaNodeClass(config);
18551
18582
  }
18552
18583
  emitEvent(event, payload) {
18553
18584
  this.moduleLogger.debug({ payload }, `Emitted event [${event}]`);
@@ -18848,6 +18879,7 @@ var WeaveGroupNode = class extends WeaveNode {
18848
18879
  ...props,
18849
18880
  name: "node"
18850
18881
  });
18882
+ this.setupDefaultNodeAugmentation(group);
18851
18883
  group.getTransformerProperties = () => {
18852
18884
  return this.config.transform;
18853
18885
  };
@@ -18901,6 +18933,7 @@ var WeaveRectangleNode = class extends WeaveNode {
18901
18933
  ...props,
18902
18934
  name: "node"
18903
18935
  });
18936
+ this.setupDefaultNodeAugmentation(rectangle);
18904
18937
  rectangle.getTransformerProperties = () => {
18905
18938
  return this.config.transform;
18906
18939
  };
@@ -18931,13 +18964,14 @@ var WeaveEllipseNode = class extends WeaveNode {
18931
18964
  } };
18932
18965
  }
18933
18966
  onRender(props) {
18934
- const rectangle = new konva.default.Ellipse({
18967
+ const ellipse = new konva.default.Ellipse({
18935
18968
  ...props,
18936
18969
  name: "node",
18937
18970
  radiusX: props.radiusX,
18938
18971
  radiusY: props.radiusY
18939
18972
  });
18940
- rectangle.getTransformerProperties = () => {
18973
+ this.setupDefaultNodeAugmentation(ellipse);
18974
+ ellipse.getTransformerProperties = () => {
18941
18975
  const stage = this.instance.getStage();
18942
18976
  const node = stage.findOne(`#${props.id}`);
18943
18977
  if (node && node.getAttrs().keepAspectRatio) return {
@@ -18952,8 +18986,8 @@ var WeaveEllipseNode = class extends WeaveNode {
18952
18986
  };
18953
18987
  return this.config.transform;
18954
18988
  };
18955
- this.setupDefaultNodeEvents(rectangle);
18956
- return rectangle;
18989
+ this.setupDefaultNodeEvents(ellipse);
18990
+ return ellipse;
18957
18991
  }
18958
18992
  onUpdate(nodeInstance, nextProps) {
18959
18993
  nodeInstance.setAttrs({ ...nextProps });
@@ -18994,6 +19028,7 @@ var WeaveLineNode = class extends WeaveNode {
18994
19028
  ...props,
18995
19029
  name: "node"
18996
19030
  });
19031
+ this.setupDefaultNodeAugmentation(line);
18997
19032
  line.getTransformerProperties = () => {
18998
19033
  return this.config.transform;
18999
19034
  };
@@ -19077,6 +19112,7 @@ var WeaveTextNode = class extends WeaveNode {
19077
19112
  ...props,
19078
19113
  name: "node"
19079
19114
  });
19115
+ this.setupDefaultNodeAugmentation(text);
19080
19116
  text.getTransformerProperties = () => {
19081
19117
  const stage = this.instance.getStage();
19082
19118
  const actualText = stage.findOne(`#${text.id()}`);
@@ -19482,9 +19518,14 @@ var WeaveImageToolAction = class extends WeaveAction {
19482
19518
  };
19483
19519
  }
19484
19520
  onInit() {
19485
- this.instance.addEventListener("onStageDrop", () => {
19521
+ this.instance.addEventListener("onStageDrop", (e) => {
19486
19522
  if (window.weaveDragImageURL) {
19487
- this.instance.triggerAction("imageTool", { imageURL: window.weaveDragImageURL });
19523
+ this.instance.getStage().setPointersPositions(e);
19524
+ const position = this.instance.getStage().getPointerPosition();
19525
+ this.instance.triggerAction("imageTool", {
19526
+ imageURL: window.weaveDragImageURL,
19527
+ position
19528
+ });
19488
19529
  window.weaveDragImageURL = void 0;
19489
19530
  }
19490
19531
  });
@@ -19524,7 +19565,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19524
19565
  setState(state) {
19525
19566
  this.state = state;
19526
19567
  }
19527
- loadImage(imageURL) {
19568
+ loadImage(imageURL, position) {
19528
19569
  const stage = this.instance.getStage();
19529
19570
  stage.container().style.cursor = "crosshair";
19530
19571
  stage.container().focus();
@@ -19542,7 +19583,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19542
19583
  width: this.preloadImgs[this.imageId].width,
19543
19584
  height: this.preloadImgs[this.imageId].height
19544
19585
  };
19545
- this.addImageNode();
19586
+ this.addImageNode(position);
19546
19587
  };
19547
19588
  this.preloadImgs[this.imageId].onerror = () => {
19548
19589
  this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
@@ -19551,10 +19592,15 @@ var WeaveImageToolAction = class extends WeaveAction {
19551
19592
  this.preloadImgs[this.imageId].src = imageURL;
19552
19593
  this.instance.emitEvent("onImageLoadStart");
19553
19594
  }
19554
- addImageNode() {
19595
+ addImageNode(position) {
19555
19596
  const stage = this.instance.getStage();
19556
19597
  stage.container().style.cursor = "crosshair";
19557
19598
  stage.container().focus();
19599
+ if (position) {
19600
+ this.handleAdding(position);
19601
+ this.setState(IMAGE_TOOL_STATE.ADDING);
19602
+ return;
19603
+ }
19558
19604
  if (this.imageId) {
19559
19605
  const mousePos = stage.getRelativePointerPosition();
19560
19606
  const nodeHandler = this.instance.getNodeHandler("image");
@@ -19578,13 +19624,14 @@ var WeaveImageToolAction = class extends WeaveAction {
19578
19624
  this.clickPoint = null;
19579
19625
  this.setState(IMAGE_TOOL_STATE.ADDING);
19580
19626
  }
19581
- addImage() {
19627
+ addImage(position) {
19628
+ if (position) this.clickPoint = position;
19582
19629
  this.setState(IMAGE_TOOL_STATE.UPLOADING);
19583
19630
  }
19584
- handleAdding() {
19631
+ handleAdding(position) {
19585
19632
  const tempImage = this.instance.getStage().findOne(`#${this.tempImageId}`);
19586
- if (this.imageId && this.imageURL && this.preloadImgs[this.imageId] && tempImage) {
19587
- const { mousePoint, container } = this.instance.getMousePointer();
19633
+ if (this.imageId && this.imageURL && this.preloadImgs[this.imageId] && (!position && tempImage || position)) {
19634
+ const { mousePoint, container } = this.instance.getMousePointer(position);
19588
19635
  this.clickPoint = mousePoint;
19589
19636
  this.container = container;
19590
19637
  const nodeHandler = this.instance.getNodeHandler("image");
@@ -19606,8 +19653,10 @@ var WeaveImageToolAction = class extends WeaveAction {
19606
19653
  }
19607
19654
  });
19608
19655
  this.instance.addNode(node, this.container?.getAttrs().id);
19609
- const imageNodeHandler = this.instance.getNodeHandler("image");
19610
- this.instance.removeNode(imageNodeHandler.serialize(tempImage));
19656
+ if (!position) {
19657
+ const imageNodeHandler = this.instance.getNodeHandler("image");
19658
+ this.instance.removeNode(imageNodeHandler.serialize(tempImage));
19659
+ }
19611
19660
  this.setState(IMAGE_TOOL_STATE.FINISHED);
19612
19661
  }
19613
19662
  this.cancelAction();
@@ -19619,7 +19668,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19619
19668
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
19620
19669
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
19621
19670
  if (params?.imageURL) {
19622
- this.loadImage(params.imageURL);
19671
+ this.loadImage(params.imageURL, params?.position ?? void 0);
19623
19672
  return;
19624
19673
  }
19625
19674
  this.props = this.initProps();
@@ -20001,6 +20050,7 @@ var WeaveImageNode = class extends WeaveNode {
20001
20050
  id,
20002
20051
  name: "node"
20003
20052
  });
20053
+ this.setupDefaultNodeAugmentation(image);
20004
20054
  image.movedToContainer = () => {
20005
20055
  const stage = this.instance.getStage();
20006
20056
  const image$1 = stage.findOne(`#${id}`);
@@ -20307,6 +20357,7 @@ var WeaveStarNode = class extends WeaveNode {
20307
20357
  innerRadius: props.innerRadius,
20308
20358
  outerRadius: props.outerRadius
20309
20359
  });
20360
+ this.setupDefaultNodeAugmentation(star);
20310
20361
  star.getTransformerProperties = () => {
20311
20362
  const stage = this.instance.getStage();
20312
20363
  const node = stage.findOne(`#${props.id}`);
@@ -20365,6 +20416,7 @@ var WeaveArrowNode = class extends WeaveNode {
20365
20416
  name: "node",
20366
20417
  points: props.points
20367
20418
  });
20419
+ this.setupDefaultNodeAugmentation(line);
20368
20420
  line.getTransformerProperties = () => {
20369
20421
  return this.config.transform;
20370
20422
  };
@@ -20420,6 +20472,7 @@ var WeaveRegularPolygonNode = class extends WeaveNode {
20420
20472
  sides: props.sides,
20421
20473
  radius: props.radius
20422
20474
  });
20475
+ this.setupDefaultNodeAugmentation(regularPolygon);
20423
20476
  regularPolygon.getTransformerProperties = () => {
20424
20477
  return {
20425
20478
  ...this.config.transform,
@@ -20593,6 +20646,7 @@ var WeaveFrameNode = class extends WeaveNode {
20593
20646
  draggable: false,
20594
20647
  clip: void 0
20595
20648
  });
20649
+ this.setupDefaultNodeAugmentation(frame);
20596
20650
  const frameInternalGroup = new konva.default.Group({
20597
20651
  id: `${id}-selector`,
20598
20652
  x: 0,
@@ -23429,7 +23483,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
23429
23483
  }
23430
23484
  });
23431
23485
  window.addEventListener("keyup", (e) => {
23432
- if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = false;
23486
+ if (e.key === "Meta" || e.key === "Control") this.isCtrlOrMetaPressed = false;
23433
23487
  if (e.code === "Space") {
23434
23488
  this.isSpaceKeyPressed = false;
23435
23489
  this.disableMove();
@@ -23510,12 +23564,13 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
23510
23564
  stage.y(stage.y() - deltaY);
23511
23565
  this.instance.emit("onStageMove", void 0);
23512
23566
  });
23513
- window.addEventListener("wheel", (e) => {
23567
+ const handleWheel = (e) => {
23514
23568
  if (!this.enabled || !this.overStage || this.isCtrlOrMetaPressed || this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed) return;
23515
23569
  stage.x(stage.x() - e.deltaX);
23516
23570
  stage.y(stage.y() - e.deltaY);
23517
23571
  this.instance.emit("onStageMove", void 0);
23518
- });
23572
+ };
23573
+ window.addEventListener("wheel", (0, import_lodash.throttle)(handleWheel, 10));
23519
23574
  }
23520
23575
  enable() {
23521
23576
  this.enabled = true;
@@ -23840,6 +23895,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
23840
23895
  onInit() {
23841
23896
  const store = this.instance.getStore();
23842
23897
  const stage = this.instance.getStage();
23898
+ this.instance.addEventListener("onConnectionStatusChange", (status) => {
23899
+ if (status === "disconnected") store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, void 0);
23900
+ });
23843
23901
  this.instance.addEventListener("onAwarenessChange", (changes) => {
23844
23902
  const selfUser = this.config.getUser();
23845
23903
  const allActiveUsers = [];
@@ -23858,6 +23916,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
23858
23916
  };
23859
23917
  }
23860
23918
  }
23919
+ const allPointers = Object.keys(this.usersPointers);
23920
+ const inactiveUsers = allPointers.filter((user) => !allActiveUsers.includes(user));
23921
+ for (let i = 0; i < inactiveUsers.length; i++) delete this.usersPointers[inactiveUsers[i]];
23861
23922
  this.renderPointers();
23862
23923
  });
23863
23924
  stage.on("dragmove", (e) => {
package/dist/sdk.d.cts CHANGED
@@ -291,6 +291,7 @@ declare abstract class WeaveNode implements WeaveNodeBase {
291
291
  getSelectionPlugin(): WeaveNodesSelectionPlugin;
292
292
  isSelecting(): boolean;
293
293
  isPasting(): boolean;
294
+ setupDefaultNodeAugmentation(node: Konva.Node): void;
294
295
  isNodeSelected(ele: Konva.Node): boolean;
295
296
  protected scaleReset(node: Konva.Node): void;
296
297
  setupDefaultNodeEvents(node: Konva.Node): void;
@@ -413,8 +414,8 @@ declare class Weave extends Emittery {
413
414
  destroy(): void;
414
415
  getId(): string;
415
416
  getConfiguration(): WeaveConfig;
416
- setStageDefaultConfiguration(): void;
417
- setNodesDefaultConfiguration(config?: WeaveNodeConfiguration): void;
417
+ augmentKonvaStageClass(): void;
418
+ augmentKonvaNodeClass(config?: WeaveNodeConfiguration): void;
418
419
  emitEvent<T>(event: string, payload?: T): void;
419
420
  addEventListener<T>(event: string, callback: (payload: T) => void): void;
420
421
  removeEventListener<T>(event: string, callback: (payload: T) => void): void;
@@ -1364,6 +1365,7 @@ type WeaveImageToolActionOnStartLoadImageEvent = undefined;
1364
1365
  type WeaveImageToolActionOnEndLoadImageEvent = Error | undefined;
1365
1366
  type WeaveImageToolActionTriggerParams = {
1366
1367
  imageURL?: string;
1368
+ position?: Vector2d;
1367
1369
  };
1368
1370
  type WeaveImageToolActionTriggerReturn = {
1369
1371
  finishUploadCallback: (imageURL: string) => void;
@@ -2050,7 +2052,10 @@ type WeaveCopyPasteNodesPluginStateKeys = keyof typeof COPY_PASTE_NODES_PLUGIN_S
2050
2052
  type WeaveCopyPasteNodesPluginState = (typeof COPY_PASTE_NODES_PLUGIN_STATE)[WeaveCopyPasteNodesPluginStateKeys];
2051
2053
  type WeaveCopyPasteNodesPluginOnCopyEvent = Error | undefined;
2052
2054
  type WeaveCopyPasteNodesPluginOnPasteEvent = Error | undefined;
2053
- type WeaveCopyPasteNodesPluginOnPasteExternalEvent = ClipboardItem;
2055
+ type WeaveCopyPasteNodesPluginOnPasteExternalEvent = {
2056
+ item: ClipboardItem;
2057
+ position: Vector2d;
2058
+ };
2054
2059
  type WeavePasteModel = {
2055
2060
  weaveInstanceId: string;
2056
2061
  weave: Record<string, WeaveStateElement>;
@@ -2081,9 +2086,8 @@ declare class WeaveCopyPasteNodesPlugin extends WeavePlugin {
2081
2086
  private recursivelyUpdateKeys;
2082
2087
  private handlePaste;
2083
2088
  private performCopy;
2084
- private performPaste;
2085
2089
  copy(): Promise<void>;
2086
- paste(): Promise<void>;
2090
+ paste(position: Vector2d): Promise<void>;
2087
2091
  getSelectedNodes(): WeaveToPasteNode[];
2088
2092
  isPasting(): boolean;
2089
2093
  private cancel;