@inditextech/weave-sdk 3.2.4 → 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/types.js CHANGED
@@ -21982,7 +21982,7 @@ var WeaveRegisterManager = class {
21982
21982
 
21983
21983
  //#endregion
21984
21984
  //#region package.json
21985
- var version = "3.2.4";
21985
+ var version = "3.3.0";
21986
21986
 
21987
21987
  //#endregion
21988
21988
  //#region src/managers/setup.ts
@@ -24150,11 +24150,15 @@ var GreedySnapper = class {
24150
24150
  reset() {
24151
24151
  this.snappedAngle = null;
24152
24152
  }
24153
+ angleDiff(a, b) {
24154
+ const diff = Math.abs(a - b) % 360;
24155
+ return diff > 180 ? 360 - diff : diff;
24156
+ }
24153
24157
  apply(angleDeg) {
24154
24158
  const { snapAngles, activateThreshold, releaseThreshold } = this.config;
24155
24159
  const normalized = (angleDeg % 360 + 360) % 360;
24156
24160
  if (this.snappedAngle !== null) {
24157
- const diff = Math.abs(normalized - this.snappedAngle);
24161
+ const diff = this.angleDiff(normalized, this.snappedAngle);
24158
24162
  if (diff > releaseThreshold) {
24159
24163
  this.snappedAngle = null;
24160
24164
  return normalized;
@@ -25762,12 +25766,14 @@ const doPreloadCursors = async (cursorsToPreload, setCursor, getFallbackCursor,
25762
25766
  const cursorUrls = [];
25763
25767
  for (const cursorKey of cursors) {
25764
25768
  const cursorValue = cursorsToPreload[cursorKey];
25765
- const { preload, cursor } = extractCursorUrl(cursorValue);
25766
- if (preload) cursorUrls.push({
25767
- state: cursorKey,
25768
- value: cursorValue,
25769
- src: cursor
25770
- });
25769
+ if (hasValidUrl(cursorValue)) {
25770
+ const { preload, cursor } = extractCursorUrl(cursorValue);
25771
+ if (preload) cursorUrls.push({
25772
+ state: cursorKey,
25773
+ value: cursorValue,
25774
+ src: cursor
25775
+ });
25776
+ } else setCursor(cursorKey, cursorValue);
25771
25777
  }
25772
25778
  if (cursorUrls.length > 0) {
25773
25779
  const cursorsPreloading = [];
@@ -25816,6 +25822,9 @@ const extractCursorUrl = (cursor) => {
25816
25822
  cursor: url
25817
25823
  };
25818
25824
  };
25825
+ const hasValidUrl = (value) => {
25826
+ return /url\(["']?.+?["']?\)/i.test(value);
25827
+ };
25819
25828
  const isAllowedUrl = (value) => {
25820
25829
  if (/^https?:\/\//i.test(value)) return true;
25821
25830
  if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
@@ -27472,8 +27481,8 @@ const WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG = { snapAngles: {
27472
27481
  270,
27473
27482
  315
27474
27483
  ],
27475
- activateThreshold: 5,
27476
- releaseThreshold: 10
27484
+ activateThreshold: 3,
27485
+ releaseThreshold: 4
27477
27486
  } };
27478
27487
  const WEAVE_STROKE_SINGLE_NODE_TIP_TYPE = {
27479
27488
  NONE: "none",
@@ -27595,7 +27604,7 @@ var WeaveArrowLineTipManager = class extends WeaveBaseLineTipManager {
27595
27604
  const height = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Height`] ?? Math.sqrt(3) / 2 * 3;
27596
27605
  const triangle = new Konva.Line({
27597
27606
  id: `${instance.getAttrs().id}-tip-${point}`,
27598
- name: "lineTip",
27607
+ name: "lineTip stroke-internal",
27599
27608
  nodeId: instance.getAttrs().id,
27600
27609
  closed: true,
27601
27610
  stroke,
@@ -27661,7 +27670,7 @@ var WeaveCircleLineTipManager = class extends WeaveBaseLineTipManager {
27661
27670
  const radius = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Radius`] ?? 1.5;
27662
27671
  const circle = new Konva.Circle({
27663
27672
  id: `${instance.getAttrs().id}-tip-${point}`,
27664
- name: "lineTip",
27673
+ name: "lineTip stroke-internal",
27665
27674
  nodeId: instance.getAttrs().id,
27666
27675
  radius,
27667
27676
  stroke: "black",
@@ -27775,7 +27784,7 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
27775
27784
  const width = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Width`] ?? 3;
27776
27785
  const square = new Konva.Rect({
27777
27786
  id: `${instance.getAttrs().id}-tip-${point}`,
27778
- name: "lineTip",
27787
+ name: "lineTip stroke-internal",
27779
27788
  nodeId: instance.getAttrs().id,
27780
27789
  width,
27781
27790
  height: width,
@@ -27824,13 +27833,26 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27824
27833
  this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
27825
27834
  this.handleNodeChanges = null;
27826
27835
  this.handleZoomChanges = null;
27836
+ this.shiftPressed = false;
27827
27837
  this.snapper = new GreedySnapper({
27828
27838
  snapAngles: this.config.snapAngles.angles,
27829
27839
  activateThreshold: this.config.snapAngles.activateThreshold,
27830
27840
  releaseThreshold: this.config.snapAngles.releaseThreshold
27831
27841
  });
27842
+ this.eventsInitialized = false;
27843
+ }
27844
+ initEvents() {
27845
+ if (this.eventsInitialized) return;
27846
+ window.addEventListener("keydown", (e) => {
27847
+ if (e.key === "Shift") this.shiftPressed = true;
27848
+ });
27849
+ window.addEventListener("keyup", (e) => {
27850
+ if (e.key === "Shift") this.shiftPressed = false;
27851
+ });
27852
+ this.eventsInitialized = true;
27832
27853
  }
27833
27854
  onRender(props) {
27855
+ this.initEvents();
27834
27856
  const stroke = new Konva.Group({
27835
27857
  ...props,
27836
27858
  name: `node ${WEAVE_STROKE_SINGLE_NODE_TYPE}`,
@@ -27842,7 +27864,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27842
27864
  ...props,
27843
27865
  id: `${stroke.getAttrs().id}-line`,
27844
27866
  nodeId: stroke.getAttrs().id,
27845
- name: void 0,
27867
+ name: "stroke-internal",
27846
27868
  x: 0,
27847
27869
  y: 0,
27848
27870
  strokeScaleEnabled: true,
@@ -27864,6 +27886,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27864
27886
  shouldOverdrawWholeArea: points.length !== 4
27865
27887
  };
27866
27888
  };
27889
+ this.setupDefaultNodeEvents(stroke);
27867
27890
  let originalStartHandleVisibility = null;
27868
27891
  let originalEndHandleVisibility = null;
27869
27892
  stroke.on("dragstart", () => {
@@ -27878,7 +27901,6 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27878
27901
  originalStartHandleVisibility = null;
27879
27902
  originalEndHandleVisibility = null;
27880
27903
  });
27881
- this.setupDefaultNodeEvents(stroke);
27882
27904
  if (!this.handleZoomChanges) {
27883
27905
  this.handleZoomChanges = () => {
27884
27906
  if (this.startHandle) this.startHandle.scale({
@@ -27895,12 +27917,10 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27895
27917
  if (!this.handleNodeChanges) {
27896
27918
  this.handleNodeChanges = (nodes) => {
27897
27919
  this.teardownSelection();
27898
- if (nodes.length === 1 && nodes[0].instance.getAttrs().nodeType === WEAVE_STROKE_SINGLE_NODE_TYPE) {
27899
- const strokeSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
27900
- if (!strokeSelected) return;
27920
+ if (nodes.length === 1 && nodes[0].node?.type === WEAVE_STROKE_SINGLE_NODE_TYPE) {
27901
27921
  this.setupHandles();
27902
- this.showHandles(strokeSelected);
27903
- this.setupSelection(strokeSelected, true);
27922
+ this.showHandles(nodes[0].instance);
27923
+ this.setupSelection(nodes[0].instance, true);
27904
27924
  } else {
27905
27925
  this.startHandle?.setAttr("strokeId", void 0);
27906
27926
  this.startHandle?.visible(false);
@@ -27943,175 +27963,92 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27943
27963
  return stroke;
27944
27964
  }
27945
27965
  setupHandles() {
27946
- if (!this.startHandle) {
27947
- const startHandle = new Konva.Circle({
27948
- id: "line-start-handle",
27949
- radius: 5,
27950
- fill: "#ffffff",
27951
- stroke: "#000000",
27952
- strokeWidth: 1,
27953
- edgeDistanceDisableOnDrag: true,
27954
- scaleX: 1 / this.instance.getStage().scaleX(),
27955
- scaleY: 1 / this.instance.getStage().scaleY(),
27956
- draggable: true
27957
- });
27958
- startHandle.on("pointerover", () => {
27959
- this.instance.getStage().container().style.cursor = "move";
27960
- });
27961
- startHandle.on("pointerout", () => {
27962
- this.instance.getStage().container().style.cursor = "default";
27963
- });
27964
- startHandle.on("dragstart", (e) => {
27965
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27966
- if (tr) tr.hide();
27967
- const strokeId = e.target.getAttr("strokeId");
27968
- const stroke = this.instance.getStage().findOne(`#${strokeId}`);
27969
- if (!stroke) return;
27970
- const points = stroke.getAttrs().linePoints;
27971
- if (points.length === 4) stroke.setAttr("eventTarget", true);
27972
- this.instance.emitEvent("onDrag", e.target);
27973
- });
27974
- startHandle.on("dragmove", (e) => {
27975
- const draggedTarget = e.target;
27976
- const strokeId = draggedTarget.getAttr("strokeId");
27977
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27978
- if (!draggedStroke) return;
27979
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27980
- if (!internalLine) return;
27981
- const points = draggedStroke.getAttrs().linePoints;
27982
- if (points.length !== 4) return;
27983
- this.teardownSelection();
27984
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
27985
- draggedStroke.setAttrs({ linePoints: [
27986
- newLinePoint.x,
27987
- newLinePoint.y,
27988
- points[2],
27989
- points[3]
27990
- ] });
27991
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27992
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
27993
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27994
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
27995
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
27996
- this.setupSelection(draggedStroke);
27997
- });
27998
- startHandle.on("dragend", (e) => {
27999
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28000
- if (tr) tr.show();
28001
- const draggedTarget = e.target;
28002
- const strokeId = draggedTarget.getAttr("strokeId");
28003
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28004
- if (!draggedStroke) return;
28005
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28006
- if (!internalLine) return;
28007
- const points = draggedStroke.getAttrs().linePoints;
28008
- if (points.length !== 4) return;
28009
- this.teardownSelection();
28010
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28011
- draggedStroke.setAttrs({ linePoints: [
28012
- newLinePoint.x,
28013
- newLinePoint.y,
28014
- points[2],
28015
- points[3]
28016
- ] });
28017
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28018
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28019
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28020
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28021
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28022
- this.setupSelection(draggedStroke);
28023
- this.instance.updateNode(this.serialize(draggedStroke));
28024
- this.instance.emitEvent("onDrag", null);
28025
- });
28026
- this.startHandle = startHandle;
27966
+ if (!this.startHandle) this.setupHandle("start");
27967
+ if (!this.endHandle) this.setupHandle("end");
27968
+ }
27969
+ setupHandle(side) {
27970
+ const handleDragStart = (e) => {
27971
+ const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27972
+ if (tr) tr.hide();
27973
+ const strokeId = e.target.getAttr("strokeId");
27974
+ const stroke = this.instance.getStage().findOne(`#${strokeId}`);
27975
+ if (!stroke) return;
27976
+ const points = stroke.getAttrs().linePoints;
27977
+ if (points.length === 4) stroke.setAttr("eventTarget", true);
27978
+ this.instance.emitEvent("onDrag", e.target);
27979
+ };
27980
+ const handleDragPosition = (side$1) => (e) => {
27981
+ const draggedTarget = e.target;
27982
+ const strokeId = draggedTarget.getAttr("strokeId");
27983
+ const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27984
+ if (!draggedStroke) return;
27985
+ const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27986
+ if (!internalLine) return;
27987
+ const points = draggedStroke.getAttrs().linePoints;
27988
+ if (points.length !== 4) return;
27989
+ this.teardownSelection();
27990
+ const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
27991
+ const pos = this.getDragPoint(draggedStroke, newLinePoint, side$1);
27992
+ if (side$1 === "start") draggedStroke.setAttrs({ linePoints: [
27993
+ pos.x,
27994
+ pos.y,
27995
+ points[2],
27996
+ points[3]
27997
+ ] });
27998
+ else draggedStroke.setAttrs({ linePoints: [
27999
+ points[0],
28000
+ points[1],
28001
+ pos.x,
28002
+ pos.y
28003
+ ] });
28004
+ this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28005
+ this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28006
+ const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28007
+ this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28008
+ const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28009
+ this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28010
+ this.setupSelection(draggedStroke);
28011
+ };
28012
+ const handleDragMove = (side$1) => (e) => {
28013
+ handleDragPosition(side$1)(e);
28014
+ };
28015
+ const handleDragEnd = (side$1) => (e) => {
28016
+ handleDragPosition(side$1)(e);
28017
+ const draggedTarget = e.target;
28018
+ const strokeId = draggedTarget.getAttr("strokeId");
28019
+ const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28020
+ if (!draggedStroke) return;
28021
+ this.instance.updateNode(this.serialize(draggedStroke));
28022
+ this.instance.emitEvent("onDrag", null);
28023
+ };
28024
+ const handle = new Konva.Circle({
28025
+ id: `line-${side}-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
+ handle.on("pointerover", () => {
28036
+ this.instance.getStage().container().style.cursor = "move";
28037
+ });
28038
+ handle.on("pointerout", () => {
28039
+ this.instance.getStage().container().style.cursor = "default";
28040
+ });
28041
+ handle.on("dragstart", handleDragStart);
28042
+ handle.on("dragmove", handleDragMove(side));
28043
+ handle.on("dragend", handleDragEnd(side));
28044
+ if (side === "start") {
28045
+ this.startHandle = handle;
28027
28046
  this.startHandle.visible(false);
28028
- this.instance.getSelectionLayer()?.add(this.startHandle);
28029
- }
28030
- if (!this.endHandle) {
28031
- const endHandle = new Konva.Circle({
28032
- id: "line-end-handle",
28033
- radius: 5,
28034
- fill: "#ffffff",
28035
- stroke: "#000000",
28036
- strokeWidth: 1,
28037
- edgeDistanceDisableOnDrag: true,
28038
- scaleX: 1 / this.instance.getStage().scaleX(),
28039
- scaleY: 1 / this.instance.getStage().scaleY(),
28040
- draggable: true
28041
- });
28042
- endHandle.on("pointerover", () => {
28043
- this.instance.getStage().container().style.cursor = "move";
28044
- });
28045
- endHandle.on("pointerout", () => {
28046
- this.instance.getStage().container().style.cursor = "default";
28047
- });
28048
- endHandle.on("dragstart", (e) => {
28049
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28050
- if (tr) tr.hide();
28051
- const strokeId = e.target.getAttr("strokeId");
28052
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28053
- if (!draggedStroke) return;
28054
- const points = draggedStroke.getAttrs().linePoints;
28055
- if (points.length !== 4) return;
28056
- if (points.length === 4) draggedStroke.setAttr("eventTarget", true);
28057
- this.instance.emitEvent("onDrag", e.target);
28058
- });
28059
- endHandle.on("dragmove", (e) => {
28060
- const draggedTarget = e.target;
28061
- const strokeId = draggedTarget.getAttr("strokeId");
28062
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28063
- if (!draggedStroke) return;
28064
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28065
- if (!internalLine) return;
28066
- const points = draggedStroke.getAttrs().linePoints;
28067
- if (points.length !== 4) return;
28068
- this.teardownSelection();
28069
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28070
- draggedStroke.setAttrs({ linePoints: [
28071
- points[0],
28072
- points[1],
28073
- newLinePoint.x,
28074
- newLinePoint.y
28075
- ] });
28076
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28077
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28078
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28079
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28080
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28081
- this.setupSelection(draggedStroke);
28082
- });
28083
- endHandle.on("dragend", (e) => {
28084
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28085
- if (tr) tr.show();
28086
- const draggedTarget = e.target;
28087
- const strokeId = draggedTarget.getAttr("strokeId");
28088
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28089
- if (!draggedStroke) return;
28090
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28091
- if (!internalLine) return;
28092
- const points = draggedStroke.getAttrs().linePoints;
28093
- if (points.length !== 4) return;
28094
- this.teardownSelection();
28095
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28096
- draggedStroke.setAttrs({ linePoints: [
28097
- points[0],
28098
- points[1],
28099
- newLinePoint.x,
28100
- newLinePoint.y
28101
- ] });
28102
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28103
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28104
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28105
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28106
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28107
- this.setupSelection(draggedStroke);
28108
- this.instance.updateNode(this.serialize(draggedStroke));
28109
- this.instance.emitEvent("onDrag", null);
28110
- });
28111
- this.endHandle = endHandle;
28047
+ } else {
28048
+ this.endHandle = handle;
28112
28049
  this.endHandle.visible(false);
28113
- this.instance.getSelectionLayer()?.add(this.endHandle);
28114
28050
  }
28051
+ this.instance.getSelectionLayer()?.add(handle);
28115
28052
  }
28116
28053
  showHandles(stroke) {
28117
28054
  if (this.startHandle === null || this.endHandle === null) return;
@@ -28135,7 +28072,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28135
28072
  this.tipManagers[tipEndStyle]?.render(stroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28136
28073
  const internalLine = stroke.findOne(`#${stroke.getAttrs().id}-line`);
28137
28074
  if (internalLine) internalLine.setAttrs({
28138
- name: void 0,
28075
+ name: "stroke-internal",
28139
28076
  dash: nextProps.dash,
28140
28077
  fill: nextProps.fill,
28141
28078
  stroke: nextProps.stroke,
@@ -28195,20 +28132,19 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28195
28132
  if (markSelected) instance.setAttrs({ isSelected: true });
28196
28133
  const hoverClone = instance.findOne(".hoverClone");
28197
28134
  if (hoverClone) return;
28198
- const internalLine = instance.findOne(`#${instance.getAttrs().id}-line`);
28199
- if (!internalLine) return;
28200
- const internalLineHover = internalLine.clone();
28201
- internalLineHover.setAttrs({
28202
- name: "hoverClone",
28203
- stroke: "#1a1aff",
28204
- listening: false,
28205
- draggable: false,
28206
- strokeWidth: 1,
28207
- points: instance.getAttrs().linePoints,
28208
- strokeScaleEnabled: false
28209
- });
28210
- instance.add(internalLineHover);
28211
- internalLineHover.moveToTop();
28135
+ const internalNodes = instance.find(".stroke-internal");
28136
+ for (const node of internalNodes) {
28137
+ const internalNode = node.clone();
28138
+ internalNode.setAttrs({
28139
+ name: "hoverClone",
28140
+ fill: "#1a1aff",
28141
+ stroke: "#1a1aff",
28142
+ listening: false,
28143
+ draggable: false
28144
+ });
28145
+ instance.add(internalNode);
28146
+ internalNode.moveToTop();
28147
+ }
28212
28148
  }
28213
28149
  teardownSelection() {
28214
28150
  const stage = this.instance.getStage();
@@ -28226,6 +28162,37 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28226
28162
  const tipEndStyle = instance.getAttrs().tipEndStyle ?? "none";
28227
28163
  this.tipManagers[tipEndStyle]?.update(instance, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28228
28164
  }
28165
+ getDragPoint(draggedStroke, newLinePoint, dragFrom) {
28166
+ const pos = {
28167
+ x: 0,
28168
+ y: 0
28169
+ };
28170
+ const linePoints = draggedStroke.getAttrs().linePoints;
28171
+ const fixed = dragFrom === "start" ? {
28172
+ x: linePoints[2],
28173
+ y: linePoints[3]
28174
+ } : {
28175
+ x: linePoints[0],
28176
+ y: linePoints[1]
28177
+ };
28178
+ if (this.shiftPressed) {
28179
+ let dx = newLinePoint.x - fixed.x;
28180
+ let dy = newLinePoint.y - fixed.y;
28181
+ const angle = Math.atan2(dy, dx);
28182
+ const angleDeg = angle * 180 / Math.PI;
28183
+ const snapped = this.snapper.apply(angleDeg);
28184
+ const dist = Math.hypot(dx, dy);
28185
+ const rad = snapped * Math.PI / 180;
28186
+ dx = Math.cos(rad) * dist;
28187
+ dy = Math.sin(rad) * dist;
28188
+ pos.x = fixed.x + dx;
28189
+ pos.y = fixed.y + dy;
28190
+ } else {
28191
+ pos.x = newLinePoint.x;
28192
+ pos.y = newLinePoint.y;
28193
+ }
28194
+ return pos;
28195
+ }
28229
28196
  };
28230
28197
 
28231
28198
  //#endregion