@inditextech/weave-sdk 0.13.1 → 0.14.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.cjs CHANGED
@@ -15886,21 +15886,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15886
15886
  ...this.config.transformer
15887
15887
  });
15888
15888
  selectionLayer?.add(tr);
15889
- tr.on("transform", (e) => {
15890
- const node = e.target;
15891
- const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
15892
- if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node)) nodesSnappingPlugin.evaluateGuidelines(e);
15893
- if (this.isSelecting() && this.isNodeSelected(node)) {
15894
- const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
15895
- this.instance.updateNode(nodeHandler.serialize(node));
15896
- e.cancelBubble = true;
15897
- }
15898
- });
15899
- tr.on("transformend", (e) => {
15900
- const node = e.target;
15901
- const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
15902
- if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node)) nodesSnappingPlugin.cleanupEvaluateGuidelines();
15903
- });
15904
15889
  tr.on("mouseenter", (e) => {
15905
15890
  if (!this.isPasting()) {
15906
15891
  const stage$1 = this.instance.getStage();
@@ -16415,6 +16400,25 @@ var WeaveNode = class {
16415
16400
  if (selectionPlugin.getSelectedNodes().length === 1 && selectionPlugin.getSelectedNodes()[0].getAttrs().id === ele.getAttrs().id) selected = true;
16416
16401
  return selected;
16417
16402
  }
16403
+ scaleReset(node) {
16404
+ if (node.getAttrs().nodeType === "line") {
16405
+ const lineNode = node;
16406
+ const oldPoints = lineNode.points();
16407
+ const newPoints = [];
16408
+ for (let i = 0; i < oldPoints.length / 2; i++) {
16409
+ const point = {
16410
+ x: oldPoints[i * 2] * lineNode.scaleX(),
16411
+ y: oldPoints[i * 2 + 1] * lineNode.scaleY()
16412
+ };
16413
+ newPoints.push(point.x, point.y);
16414
+ }
16415
+ lineNode.points(newPoints);
16416
+ }
16417
+ node.width(Math.max(5, node.width() * node.scaleX()));
16418
+ node.height(Math.max(5, node.height() * node.scaleY()));
16419
+ node.scaleX(1);
16420
+ node.scaleY(1);
16421
+ }
16418
16422
  setupDefaultNodeEvents(node) {
16419
16423
  this.previousPointer = null;
16420
16424
  this.instance.addEventListener("onNodesChange", () => {
@@ -16424,6 +16428,22 @@ var WeaveNode = class {
16424
16428
  }
16425
16429
  node.draggable(false);
16426
16430
  });
16431
+ node.on("transform", (e) => {
16432
+ const node$1 = e.target;
16433
+ const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16434
+ if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.evaluateGuidelines(e);
16435
+ if (this.isSelecting() && this.isNodeSelected(node$1)) {
16436
+ this.scaleReset(node$1);
16437
+ const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16438
+ this.instance.updateNode(nodeHandler.serialize(node$1));
16439
+ e.cancelBubble = true;
16440
+ }
16441
+ });
16442
+ node.on("transformend", (e) => {
16443
+ const node$1 = e.target;
16444
+ const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16445
+ if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.cleanupEvaluateGuidelines();
16446
+ });
16427
16447
  node.on("dragmove", (e) => {
16428
16448
  if (this.isSelecting() && this.isNodeSelected(node)) {
16429
16449
  clearContainerTargets(this.instance);
@@ -17883,7 +17903,7 @@ var WeaveRegisterManager = class {
17883
17903
 
17884
17904
  //#endregion
17885
17905
  //#region package.json
17886
- var version = "0.13.1";
17906
+ var version = "0.14.0";
17887
17907
 
17888
17908
  //#endregion
17889
17909
  //#region src/managers/setup.ts
@@ -20512,6 +20532,7 @@ var WeavePenToolAction = class extends WeaveAction {
20512
20532
  ...this.props,
20513
20533
  x: this.clickPoint?.x ?? 0,
20514
20534
  y: this.clickPoint?.y ?? 0,
20535
+ strokeScaleEnabled: false,
20515
20536
  points: [0, 0]
20516
20537
  });
20517
20538
  this.instance.addNode(tempLine, this.container?.getAttrs().id);
package/dist/sdk.d.cts CHANGED
@@ -280,6 +280,7 @@ declare abstract class WeaveNode implements WeaveNodeBase {
280
280
  isSelecting(): boolean;
281
281
  isPasting(): boolean;
282
282
  isNodeSelected(ele: Konva.Node): boolean;
283
+ private scaleReset;
283
284
  setupDefaultNodeEvents(node: Konva.Node): void;
284
285
  create(key: string, props: WeaveElementAttributes): WeaveStateElement;
285
286
  abstract onRender(props: WeaveElementAttributes): WeaveElementInstance;
package/dist/sdk.d.ts CHANGED
@@ -280,6 +280,7 @@ declare abstract class WeaveNode implements WeaveNodeBase {
280
280
  isSelecting(): boolean;
281
281
  isPasting(): boolean;
282
282
  isNodeSelected(ele: Konva.Node): boolean;
283
+ private scaleReset;
283
284
  setupDefaultNodeEvents(node: Konva.Node): void;
284
285
  create(key: string, props: WeaveElementAttributes): WeaveStateElement;
285
286
  abstract onRender(props: WeaveElementAttributes): WeaveElementInstance;
package/dist/sdk.js CHANGED
@@ -15886,21 +15886,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15886
15886
  ...this.config.transformer
15887
15887
  });
15888
15888
  selectionLayer?.add(tr);
15889
- tr.on("transform", (e) => {
15890
- const node = e.target;
15891
- const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
15892
- if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node)) nodesSnappingPlugin.evaluateGuidelines(e);
15893
- if (this.isSelecting() && this.isNodeSelected(node)) {
15894
- const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
15895
- this.instance.updateNode(nodeHandler.serialize(node));
15896
- e.cancelBubble = true;
15897
- }
15898
- });
15899
- tr.on("transformend", (e) => {
15900
- const node = e.target;
15901
- const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
15902
- if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node)) nodesSnappingPlugin.cleanupEvaluateGuidelines();
15903
- });
15904
15889
  tr.on("mouseenter", (e) => {
15905
15890
  if (!this.isPasting()) {
15906
15891
  const stage$1 = this.instance.getStage();
@@ -16415,6 +16400,25 @@ var WeaveNode = class {
16415
16400
  if (selectionPlugin.getSelectedNodes().length === 1 && selectionPlugin.getSelectedNodes()[0].getAttrs().id === ele.getAttrs().id) selected = true;
16416
16401
  return selected;
16417
16402
  }
16403
+ scaleReset(node) {
16404
+ if (node.getAttrs().nodeType === "line") {
16405
+ const lineNode = node;
16406
+ const oldPoints = lineNode.points();
16407
+ const newPoints = [];
16408
+ for (let i = 0; i < oldPoints.length / 2; i++) {
16409
+ const point = {
16410
+ x: oldPoints[i * 2] * lineNode.scaleX(),
16411
+ y: oldPoints[i * 2 + 1] * lineNode.scaleY()
16412
+ };
16413
+ newPoints.push(point.x, point.y);
16414
+ }
16415
+ lineNode.points(newPoints);
16416
+ }
16417
+ node.width(Math.max(5, node.width() * node.scaleX()));
16418
+ node.height(Math.max(5, node.height() * node.scaleY()));
16419
+ node.scaleX(1);
16420
+ node.scaleY(1);
16421
+ }
16418
16422
  setupDefaultNodeEvents(node) {
16419
16423
  this.previousPointer = null;
16420
16424
  this.instance.addEventListener("onNodesChange", () => {
@@ -16424,6 +16428,22 @@ var WeaveNode = class {
16424
16428
  }
16425
16429
  node.draggable(false);
16426
16430
  });
16431
+ node.on("transform", (e) => {
16432
+ const node$1 = e.target;
16433
+ const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16434
+ if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.evaluateGuidelines(e);
16435
+ if (this.isSelecting() && this.isNodeSelected(node$1)) {
16436
+ this.scaleReset(node$1);
16437
+ const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16438
+ this.instance.updateNode(nodeHandler.serialize(node$1));
16439
+ e.cancelBubble = true;
16440
+ }
16441
+ });
16442
+ node.on("transformend", (e) => {
16443
+ const node$1 = e.target;
16444
+ const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
16445
+ if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.cleanupEvaluateGuidelines();
16446
+ });
16427
16447
  node.on("dragmove", (e) => {
16428
16448
  if (this.isSelecting() && this.isNodeSelected(node)) {
16429
16449
  clearContainerTargets(this.instance);
@@ -17883,7 +17903,7 @@ var WeaveRegisterManager = class {
17883
17903
 
17884
17904
  //#endregion
17885
17905
  //#region package.json
17886
- var version = "0.13.1";
17906
+ var version = "0.14.0";
17887
17907
 
17888
17908
  //#endregion
17889
17909
  //#region src/managers/setup.ts
@@ -20512,6 +20532,7 @@ var WeavePenToolAction = class extends WeaveAction {
20512
20532
  ...this.props,
20513
20533
  x: this.clickPoint?.x ?? 0,
20514
20534
  y: this.clickPoint?.y ?? 0,
20535
+ strokeScaleEnabled: false,
20515
20536
  points: [0, 0]
20516
20537
  });
20517
20538
  this.instance.addNode(tempLine, this.container?.getAttrs().id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-sdk",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
@@ -43,7 +43,7 @@
43
43
  "version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
44
44
  },
45
45
  "dependencies": {
46
- "@inditextech/weave-types": "0.13.1",
46
+ "@inditextech/weave-types": "0.14.0",
47
47
  "@syncedstore/core": "0.6.0",
48
48
  "canvas": "3.1.0",
49
49
  "konva": "9.3.20",