@inditextech/weave-sdk 3.2.5 → 3.3.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
@@ -21970,7 +21970,7 @@ var WeaveRegisterManager = class {
21970
21970
 
21971
21971
  //#endregion
21972
21972
  //#region package.json
21973
- var version = "3.2.5";
21973
+ var version = "3.3.0";
21974
21974
 
21975
21975
  //#endregion
21976
21976
  //#region src/managers/setup.ts
@@ -24138,11 +24138,15 @@ var GreedySnapper = class {
24138
24138
  reset() {
24139
24139
  this.snappedAngle = null;
24140
24140
  }
24141
+ angleDiff(a, b) {
24142
+ const diff = Math.abs(a - b) % 360;
24143
+ return diff > 180 ? 360 - diff : diff;
24144
+ }
24141
24145
  apply(angleDeg) {
24142
24146
  const { snapAngles, activateThreshold, releaseThreshold } = this.config;
24143
24147
  const normalized = (angleDeg % 360 + 360) % 360;
24144
24148
  if (this.snappedAngle !== null) {
24145
- const diff = Math.abs(normalized - this.snappedAngle);
24149
+ const diff = this.angleDiff(normalized, this.snappedAngle);
24146
24150
  if (diff > releaseThreshold) {
24147
24151
  this.snappedAngle = null;
24148
24152
  return normalized;
@@ -27465,8 +27469,8 @@ const WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG = { snapAngles: {
27465
27469
  270,
27466
27470
  315
27467
27471
  ],
27468
- activateThreshold: 5,
27469
- releaseThreshold: 10
27472
+ activateThreshold: 3,
27473
+ releaseThreshold: 4
27470
27474
  } };
27471
27475
  const WEAVE_STROKE_SINGLE_NODE_TIP_TYPE = {
27472
27476
  NONE: "none",
@@ -27588,7 +27592,7 @@ var WeaveArrowLineTipManager = class extends WeaveBaseLineTipManager {
27588
27592
  const height = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Height`] ?? Math.sqrt(3) / 2 * 3;
27589
27593
  const triangle = new Konva.Line({
27590
27594
  id: `${instance.getAttrs().id}-tip-${point}`,
27591
- name: "lineTip",
27595
+ name: "lineTip stroke-internal",
27592
27596
  nodeId: instance.getAttrs().id,
27593
27597
  closed: true,
27594
27598
  stroke,
@@ -27654,7 +27658,7 @@ var WeaveCircleLineTipManager = class extends WeaveBaseLineTipManager {
27654
27658
  const radius = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Radius`] ?? 1.5;
27655
27659
  const circle = new Konva.Circle({
27656
27660
  id: `${instance.getAttrs().id}-tip-${point}`,
27657
- name: "lineTip",
27661
+ name: "lineTip stroke-internal",
27658
27662
  nodeId: instance.getAttrs().id,
27659
27663
  radius,
27660
27664
  stroke: "black",
@@ -27768,7 +27772,7 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
27768
27772
  const width = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Width`] ?? 3;
27769
27773
  const square = new Konva.Rect({
27770
27774
  id: `${instance.getAttrs().id}-tip-${point}`,
27771
- name: "lineTip",
27775
+ name: "lineTip stroke-internal",
27772
27776
  nodeId: instance.getAttrs().id,
27773
27777
  width,
27774
27778
  height: width,
@@ -27817,13 +27821,26 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27817
27821
  this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
27818
27822
  this.handleNodeChanges = null;
27819
27823
  this.handleZoomChanges = null;
27824
+ this.shiftPressed = false;
27820
27825
  this.snapper = new GreedySnapper({
27821
27826
  snapAngles: this.config.snapAngles.angles,
27822
27827
  activateThreshold: this.config.snapAngles.activateThreshold,
27823
27828
  releaseThreshold: this.config.snapAngles.releaseThreshold
27824
27829
  });
27830
+ this.eventsInitialized = false;
27831
+ }
27832
+ initEvents() {
27833
+ if (this.eventsInitialized) return;
27834
+ window.addEventListener("keydown", (e) => {
27835
+ if (e.key === "Shift") this.shiftPressed = true;
27836
+ });
27837
+ window.addEventListener("keyup", (e) => {
27838
+ if (e.key === "Shift") this.shiftPressed = false;
27839
+ });
27840
+ this.eventsInitialized = true;
27825
27841
  }
27826
27842
  onRender(props) {
27843
+ this.initEvents();
27827
27844
  const stroke = new Konva.Group({
27828
27845
  ...props,
27829
27846
  name: `node ${WEAVE_STROKE_SINGLE_NODE_TYPE}`,
@@ -27835,7 +27852,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27835
27852
  ...props,
27836
27853
  id: `${stroke.getAttrs().id}-line`,
27837
27854
  nodeId: stroke.getAttrs().id,
27838
- name: void 0,
27855
+ name: "stroke-internal",
27839
27856
  x: 0,
27840
27857
  y: 0,
27841
27858
  strokeScaleEnabled: true,
@@ -27857,6 +27874,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27857
27874
  shouldOverdrawWholeArea: points.length !== 4
27858
27875
  };
27859
27876
  };
27877
+ this.setupDefaultNodeEvents(stroke);
27860
27878
  let originalStartHandleVisibility = null;
27861
27879
  let originalEndHandleVisibility = null;
27862
27880
  stroke.on("dragstart", () => {
@@ -27871,7 +27889,6 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27871
27889
  originalStartHandleVisibility = null;
27872
27890
  originalEndHandleVisibility = null;
27873
27891
  });
27874
- this.setupDefaultNodeEvents(stroke);
27875
27892
  if (!this.handleZoomChanges) {
27876
27893
  this.handleZoomChanges = () => {
27877
27894
  if (this.startHandle) this.startHandle.scale({
@@ -27888,12 +27905,10 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27888
27905
  if (!this.handleNodeChanges) {
27889
27906
  this.handleNodeChanges = (nodes) => {
27890
27907
  this.teardownSelection();
27891
- if (nodes.length === 1 && nodes[0].instance.getAttrs().nodeType === WEAVE_STROKE_SINGLE_NODE_TYPE) {
27892
- const strokeSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
27893
- if (!strokeSelected) return;
27908
+ if (nodes.length === 1 && nodes[0].node?.type === WEAVE_STROKE_SINGLE_NODE_TYPE) {
27894
27909
  this.setupHandles();
27895
- this.showHandles(strokeSelected);
27896
- this.setupSelection(strokeSelected, true);
27910
+ this.showHandles(nodes[0].instance);
27911
+ this.setupSelection(nodes[0].instance, true);
27897
27912
  } else {
27898
27913
  this.startHandle?.setAttr("strokeId", void 0);
27899
27914
  this.startHandle?.visible(false);
@@ -27936,175 +27951,92 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27936
27951
  return stroke;
27937
27952
  }
27938
27953
  setupHandles() {
27939
- if (!this.startHandle) {
27940
- const startHandle = new Konva.Circle({
27941
- id: "line-start-handle",
27942
- radius: 5,
27943
- fill: "#ffffff",
27944
- stroke: "#000000",
27945
- strokeWidth: 1,
27946
- edgeDistanceDisableOnDrag: true,
27947
- scaleX: 1 / this.instance.getStage().scaleX(),
27948
- scaleY: 1 / this.instance.getStage().scaleY(),
27949
- draggable: true
27950
- });
27951
- startHandle.on("pointerover", () => {
27952
- this.instance.getStage().container().style.cursor = "move";
27953
- });
27954
- startHandle.on("pointerout", () => {
27955
- this.instance.getStage().container().style.cursor = "default";
27956
- });
27957
- startHandle.on("dragstart", (e) => {
27958
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27959
- if (tr) tr.hide();
27960
- const strokeId = e.target.getAttr("strokeId");
27961
- const stroke = this.instance.getStage().findOne(`#${strokeId}`);
27962
- if (!stroke) return;
27963
- const points = stroke.getAttrs().linePoints;
27964
- if (points.length === 4) stroke.setAttr("eventTarget", true);
27965
- this.instance.emitEvent("onDrag", e.target);
27966
- });
27967
- startHandle.on("dragmove", (e) => {
27968
- const draggedTarget = e.target;
27969
- const strokeId = draggedTarget.getAttr("strokeId");
27970
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27971
- if (!draggedStroke) return;
27972
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27973
- if (!internalLine) return;
27974
- const points = draggedStroke.getAttrs().linePoints;
27975
- if (points.length !== 4) return;
27976
- this.teardownSelection();
27977
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
27978
- draggedStroke.setAttrs({ linePoints: [
27979
- newLinePoint.x,
27980
- newLinePoint.y,
27981
- points[2],
27982
- points[3]
27983
- ] });
27984
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27985
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
27986
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27987
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
27988
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
27989
- this.setupSelection(draggedStroke);
27990
- });
27991
- startHandle.on("dragend", (e) => {
27992
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27993
- if (tr) tr.show();
27994
- const draggedTarget = e.target;
27995
- const strokeId = draggedTarget.getAttr("strokeId");
27996
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27997
- if (!draggedStroke) return;
27998
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27999
- if (!internalLine) return;
28000
- const points = draggedStroke.getAttrs().linePoints;
28001
- if (points.length !== 4) return;
28002
- this.teardownSelection();
28003
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28004
- draggedStroke.setAttrs({ linePoints: [
28005
- newLinePoint.x,
28006
- newLinePoint.y,
28007
- points[2],
28008
- points[3]
28009
- ] });
28010
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28011
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28012
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28013
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28014
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28015
- this.setupSelection(draggedStroke);
28016
- this.instance.updateNode(this.serialize(draggedStroke));
28017
- this.instance.emitEvent("onDrag", null);
28018
- });
28019
- this.startHandle = startHandle;
27954
+ if (!this.startHandle) this.setupHandle("start");
27955
+ if (!this.endHandle) this.setupHandle("end");
27956
+ }
27957
+ setupHandle(side) {
27958
+ const handleDragStart = (e) => {
27959
+ const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27960
+ if (tr) tr.hide();
27961
+ const strokeId = e.target.getAttr("strokeId");
27962
+ const stroke = this.instance.getStage().findOne(`#${strokeId}`);
27963
+ if (!stroke) return;
27964
+ const points = stroke.getAttrs().linePoints;
27965
+ if (points.length === 4) stroke.setAttr("eventTarget", true);
27966
+ this.instance.emitEvent("onDrag", e.target);
27967
+ };
27968
+ const handleDragPosition = (side$1) => (e) => {
27969
+ const draggedTarget = e.target;
27970
+ const strokeId = draggedTarget.getAttr("strokeId");
27971
+ const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27972
+ if (!draggedStroke) return;
27973
+ const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27974
+ if (!internalLine) return;
27975
+ const points = draggedStroke.getAttrs().linePoints;
27976
+ if (points.length !== 4) return;
27977
+ this.teardownSelection();
27978
+ const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
27979
+ const pos = this.getDragPoint(draggedStroke, newLinePoint, side$1);
27980
+ if (side$1 === "start") draggedStroke.setAttrs({ linePoints: [
27981
+ pos.x,
27982
+ pos.y,
27983
+ points[2],
27984
+ points[3]
27985
+ ] });
27986
+ else draggedStroke.setAttrs({ linePoints: [
27987
+ points[0],
27988
+ points[1],
27989
+ pos.x,
27990
+ pos.y
27991
+ ] });
27992
+ this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27993
+ this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
27994
+ const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
27995
+ this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27996
+ const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
27997
+ this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
27998
+ this.setupSelection(draggedStroke);
27999
+ };
28000
+ const handleDragMove = (side$1) => (e) => {
28001
+ handleDragPosition(side$1)(e);
28002
+ };
28003
+ const handleDragEnd = (side$1) => (e) => {
28004
+ handleDragPosition(side$1)(e);
28005
+ const draggedTarget = e.target;
28006
+ const strokeId = draggedTarget.getAttr("strokeId");
28007
+ const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28008
+ if (!draggedStroke) return;
28009
+ this.instance.updateNode(this.serialize(draggedStroke));
28010
+ this.instance.emitEvent("onDrag", null);
28011
+ };
28012
+ const handle = new Konva.Circle({
28013
+ id: `line-${side}-handle`,
28014
+ radius: 5,
28015
+ fill: "#ffffff",
28016
+ stroke: "#000000",
28017
+ strokeWidth: 1,
28018
+ edgeDistanceDisableOnDrag: true,
28019
+ scaleX: 1 / this.instance.getStage().scaleX(),
28020
+ scaleY: 1 / this.instance.getStage().scaleY(),
28021
+ draggable: true
28022
+ });
28023
+ handle.on("pointerover", () => {
28024
+ this.instance.getStage().container().style.cursor = "move";
28025
+ });
28026
+ handle.on("pointerout", () => {
28027
+ this.instance.getStage().container().style.cursor = "default";
28028
+ });
28029
+ handle.on("dragstart", handleDragStart);
28030
+ handle.on("dragmove", handleDragMove(side));
28031
+ handle.on("dragend", handleDragEnd(side));
28032
+ if (side === "start") {
28033
+ this.startHandle = handle;
28020
28034
  this.startHandle.visible(false);
28021
- this.instance.getSelectionLayer()?.add(this.startHandle);
28022
- }
28023
- if (!this.endHandle) {
28024
- const endHandle = new Konva.Circle({
28025
- id: "line-end-handle",
28026
- radius: 5,
28027
- fill: "#ffffff",
28028
- stroke: "#000000",
28029
- strokeWidth: 1,
28030
- edgeDistanceDisableOnDrag: true,
28031
- scaleX: 1 / this.instance.getStage().scaleX(),
28032
- scaleY: 1 / this.instance.getStage().scaleY(),
28033
- draggable: true
28034
- });
28035
- endHandle.on("pointerover", () => {
28036
- this.instance.getStage().container().style.cursor = "move";
28037
- });
28038
- endHandle.on("pointerout", () => {
28039
- this.instance.getStage().container().style.cursor = "default";
28040
- });
28041
- endHandle.on("dragstart", (e) => {
28042
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28043
- if (tr) tr.hide();
28044
- const strokeId = e.target.getAttr("strokeId");
28045
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28046
- if (!draggedStroke) return;
28047
- const points = draggedStroke.getAttrs().linePoints;
28048
- if (points.length !== 4) return;
28049
- if (points.length === 4) draggedStroke.setAttr("eventTarget", true);
28050
- this.instance.emitEvent("onDrag", e.target);
28051
- });
28052
- endHandle.on("dragmove", (e) => {
28053
- const draggedTarget = e.target;
28054
- const strokeId = draggedTarget.getAttr("strokeId");
28055
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28056
- if (!draggedStroke) return;
28057
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28058
- if (!internalLine) return;
28059
- const points = draggedStroke.getAttrs().linePoints;
28060
- if (points.length !== 4) return;
28061
- this.teardownSelection();
28062
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28063
- draggedStroke.setAttrs({ linePoints: [
28064
- points[0],
28065
- points[1],
28066
- newLinePoint.x,
28067
- newLinePoint.y
28068
- ] });
28069
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28070
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28071
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28072
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28073
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28074
- this.setupSelection(draggedStroke);
28075
- });
28076
- endHandle.on("dragend", (e) => {
28077
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28078
- if (tr) tr.show();
28079
- const draggedTarget = e.target;
28080
- const strokeId = draggedTarget.getAttr("strokeId");
28081
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28082
- if (!draggedStroke) return;
28083
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28084
- if (!internalLine) return;
28085
- const points = draggedStroke.getAttrs().linePoints;
28086
- if (points.length !== 4) return;
28087
- this.teardownSelection();
28088
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28089
- draggedStroke.setAttrs({ linePoints: [
28090
- points[0],
28091
- points[1],
28092
- newLinePoint.x,
28093
- newLinePoint.y
28094
- ] });
28095
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28096
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28097
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28098
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28099
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28100
- this.setupSelection(draggedStroke);
28101
- this.instance.updateNode(this.serialize(draggedStroke));
28102
- this.instance.emitEvent("onDrag", null);
28103
- });
28104
- this.endHandle = endHandle;
28035
+ } else {
28036
+ this.endHandle = handle;
28105
28037
  this.endHandle.visible(false);
28106
- this.instance.getSelectionLayer()?.add(this.endHandle);
28107
28038
  }
28039
+ this.instance.getSelectionLayer()?.add(handle);
28108
28040
  }
28109
28041
  showHandles(stroke) {
28110
28042
  if (this.startHandle === null || this.endHandle === null) return;
@@ -28128,7 +28060,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28128
28060
  this.tipManagers[tipEndStyle]?.render(stroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28129
28061
  const internalLine = stroke.findOne(`#${stroke.getAttrs().id}-line`);
28130
28062
  if (internalLine) internalLine.setAttrs({
28131
- name: void 0,
28063
+ name: "stroke-internal",
28132
28064
  dash: nextProps.dash,
28133
28065
  fill: nextProps.fill,
28134
28066
  stroke: nextProps.stroke,
@@ -28188,20 +28120,19 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28188
28120
  if (markSelected) instance.setAttrs({ isSelected: true });
28189
28121
  const hoverClone = instance.findOne(".hoverClone");
28190
28122
  if (hoverClone) return;
28191
- const internalLine = instance.findOne(`#${instance.getAttrs().id}-line`);
28192
- if (!internalLine) return;
28193
- const internalLineHover = internalLine.clone();
28194
- internalLineHover.setAttrs({
28195
- name: "hoverClone",
28196
- stroke: "#1a1aff",
28197
- listening: false,
28198
- draggable: false,
28199
- strokeWidth: 1,
28200
- points: instance.getAttrs().linePoints,
28201
- strokeScaleEnabled: false
28202
- });
28203
- instance.add(internalLineHover);
28204
- internalLineHover.moveToTop();
28123
+ const internalNodes = instance.find(".stroke-internal");
28124
+ for (const node of internalNodes) {
28125
+ const internalNode = node.clone();
28126
+ internalNode.setAttrs({
28127
+ name: "hoverClone",
28128
+ fill: "#1a1aff",
28129
+ stroke: "#1a1aff",
28130
+ listening: false,
28131
+ draggable: false
28132
+ });
28133
+ instance.add(internalNode);
28134
+ internalNode.moveToTop();
28135
+ }
28205
28136
  }
28206
28137
  teardownSelection() {
28207
28138
  const stage = this.instance.getStage();
@@ -28219,6 +28150,37 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28219
28150
  const tipEndStyle = instance.getAttrs().tipEndStyle ?? "none";
28220
28151
  this.tipManagers[tipEndStyle]?.update(instance, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28221
28152
  }
28153
+ getDragPoint(draggedStroke, newLinePoint, dragFrom) {
28154
+ const pos = {
28155
+ x: 0,
28156
+ y: 0
28157
+ };
28158
+ const linePoints = draggedStroke.getAttrs().linePoints;
28159
+ const fixed = dragFrom === "start" ? {
28160
+ x: linePoints[2],
28161
+ y: linePoints[3]
28162
+ } : {
28163
+ x: linePoints[0],
28164
+ y: linePoints[1]
28165
+ };
28166
+ if (this.shiftPressed) {
28167
+ let dx = newLinePoint.x - fixed.x;
28168
+ let dy = newLinePoint.y - fixed.y;
28169
+ const angle = Math.atan2(dy, dx);
28170
+ const angleDeg = angle * 180 / Math.PI;
28171
+ const snapped = this.snapper.apply(angleDeg);
28172
+ const dist = Math.hypot(dx, dy);
28173
+ const rad = snapped * Math.PI / 180;
28174
+ dx = Math.cos(rad) * dist;
28175
+ dy = Math.sin(rad) * dist;
28176
+ pos.x = fixed.x + dx;
28177
+ pos.y = fixed.y + dy;
28178
+ } else {
28179
+ pos.x = newLinePoint.x;
28180
+ pos.y = newLinePoint.y;
28181
+ }
28182
+ return pos;
28183
+ }
28222
28184
  };
28223
28185
 
28224
28186
  //#endregion
package/dist/types.d.ts CHANGED
@@ -1546,6 +1546,7 @@ declare class GreedySnapper {
1546
1546
  private readonly config;
1547
1547
  constructor(config: GreedySnapConfig);
1548
1548
  reset(): void;
1549
+ angleDiff(a: number, b: number): number;
1549
1550
  apply(angleDeg: number): number;
1550
1551
  }
1551
1552
 
@@ -2122,16 +2123,20 @@ declare class WeaveBaseLineTipManager {
2122
2123
  //# sourceMappingURL=base.line-tip-manager.d.ts.map
2123
2124
  declare class WeaveStrokeSingleNode extends WeaveNode {
2124
2125
  private config;
2125
- protected snapper: GreedySnapper;
2126
2126
  protected startHandle: Konva.Circle | null;
2127
2127
  protected endHandle: Konva.Circle | null;
2128
2128
  protected handleNodeChanges: ((nodes: WeaveSelection[]) => void) | null;
2129
2129
  protected handleZoomChanges: (() => void) | null;
2130
2130
  protected nodeType: string;
2131
2131
  protected tipManagers: Record<string, WeaveBaseLineTipManager>;
2132
+ private readonly snapper;
2133
+ private shiftPressed;
2134
+ private eventsInitialized;
2132
2135
  constructor(params?: WeaveStrokeSingleNodeParams);
2136
+ initEvents(): void;
2133
2137
  onRender(props: WeaveElementAttributes): WeaveElementInstance;
2134
2138
  private setupHandles;
2139
+ private setupHandle;
2135
2140
  private showHandles;
2136
2141
  onUpdate(nodeInstance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
2137
2142
  scaleReset(node: Konva.Line): void;
@@ -2140,6 +2145,7 @@ declare class WeaveStrokeSingleNode extends WeaveNode {
2140
2145
  private setupSelection;
2141
2146
  private teardownSelection;
2142
2147
  updateLine(instance: Konva.Group): void;
2148
+ private getDragPoint;
2143
2149
  }
2144
2150
 
2145
2151
  //#endregion