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