@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.js +157 -195
- package/dist/sdk.node.js +157 -195
- package/dist/types.d.ts +7 -1
- 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/types.js
CHANGED
|
@@ -21982,7 +21982,7 @@ var WeaveRegisterManager = class {
|
|
|
21982
21982
|
|
|
21983
21983
|
//#endregion
|
|
21984
21984
|
//#region package.json
|
|
21985
|
-
var version = "3.
|
|
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 =
|
|
24161
|
+
const diff = this.angleDiff(normalized, this.snappedAngle);
|
|
24158
24162
|
if (diff > releaseThreshold) {
|
|
24159
24163
|
this.snappedAngle = null;
|
|
24160
24164
|
return normalized;
|
|
@@ -27477,8 +27481,8 @@ const WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG = { snapAngles: {
|
|
|
27477
27481
|
270,
|
|
27478
27482
|
315
|
|
27479
27483
|
],
|
|
27480
|
-
activateThreshold:
|
|
27481
|
-
releaseThreshold:
|
|
27484
|
+
activateThreshold: 3,
|
|
27485
|
+
releaseThreshold: 4
|
|
27482
27486
|
} };
|
|
27483
27487
|
const WEAVE_STROKE_SINGLE_NODE_TIP_TYPE = {
|
|
27484
27488
|
NONE: "none",
|
|
@@ -27600,7 +27604,7 @@ var WeaveArrowLineTipManager = class extends WeaveBaseLineTipManager {
|
|
|
27600
27604
|
const height = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Height`] ?? Math.sqrt(3) / 2 * 3;
|
|
27601
27605
|
const triangle = new Konva.Line({
|
|
27602
27606
|
id: `${instance.getAttrs().id}-tip-${point}`,
|
|
27603
|
-
name: "lineTip",
|
|
27607
|
+
name: "lineTip stroke-internal",
|
|
27604
27608
|
nodeId: instance.getAttrs().id,
|
|
27605
27609
|
closed: true,
|
|
27606
27610
|
stroke,
|
|
@@ -27666,7 +27670,7 @@ var WeaveCircleLineTipManager = class extends WeaveBaseLineTipManager {
|
|
|
27666
27670
|
const radius = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Radius`] ?? 1.5;
|
|
27667
27671
|
const circle = new Konva.Circle({
|
|
27668
27672
|
id: `${instance.getAttrs().id}-tip-${point}`,
|
|
27669
|
-
name: "lineTip",
|
|
27673
|
+
name: "lineTip stroke-internal",
|
|
27670
27674
|
nodeId: instance.getAttrs().id,
|
|
27671
27675
|
radius,
|
|
27672
27676
|
stroke: "black",
|
|
@@ -27780,7 +27784,7 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
|
|
|
27780
27784
|
const width = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Width`] ?? 3;
|
|
27781
27785
|
const square = new Konva.Rect({
|
|
27782
27786
|
id: `${instance.getAttrs().id}-tip-${point}`,
|
|
27783
|
-
name: "lineTip",
|
|
27787
|
+
name: "lineTip stroke-internal",
|
|
27784
27788
|
nodeId: instance.getAttrs().id,
|
|
27785
27789
|
width,
|
|
27786
27790
|
height: width,
|
|
@@ -27829,13 +27833,26 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27829
27833
|
this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
|
|
27830
27834
|
this.handleNodeChanges = null;
|
|
27831
27835
|
this.handleZoomChanges = null;
|
|
27836
|
+
this.shiftPressed = false;
|
|
27832
27837
|
this.snapper = new GreedySnapper({
|
|
27833
27838
|
snapAngles: this.config.snapAngles.angles,
|
|
27834
27839
|
activateThreshold: this.config.snapAngles.activateThreshold,
|
|
27835
27840
|
releaseThreshold: this.config.snapAngles.releaseThreshold
|
|
27836
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;
|
|
27837
27853
|
}
|
|
27838
27854
|
onRender(props) {
|
|
27855
|
+
this.initEvents();
|
|
27839
27856
|
const stroke = new Konva.Group({
|
|
27840
27857
|
...props,
|
|
27841
27858
|
name: `node ${WEAVE_STROKE_SINGLE_NODE_TYPE}`,
|
|
@@ -27847,7 +27864,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27847
27864
|
...props,
|
|
27848
27865
|
id: `${stroke.getAttrs().id}-line`,
|
|
27849
27866
|
nodeId: stroke.getAttrs().id,
|
|
27850
|
-
name:
|
|
27867
|
+
name: "stroke-internal",
|
|
27851
27868
|
x: 0,
|
|
27852
27869
|
y: 0,
|
|
27853
27870
|
strokeScaleEnabled: true,
|
|
@@ -27869,6 +27886,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27869
27886
|
shouldOverdrawWholeArea: points.length !== 4
|
|
27870
27887
|
};
|
|
27871
27888
|
};
|
|
27889
|
+
this.setupDefaultNodeEvents(stroke);
|
|
27872
27890
|
let originalStartHandleVisibility = null;
|
|
27873
27891
|
let originalEndHandleVisibility = null;
|
|
27874
27892
|
stroke.on("dragstart", () => {
|
|
@@ -27883,7 +27901,6 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27883
27901
|
originalStartHandleVisibility = null;
|
|
27884
27902
|
originalEndHandleVisibility = null;
|
|
27885
27903
|
});
|
|
27886
|
-
this.setupDefaultNodeEvents(stroke);
|
|
27887
27904
|
if (!this.handleZoomChanges) {
|
|
27888
27905
|
this.handleZoomChanges = () => {
|
|
27889
27906
|
if (this.startHandle) this.startHandle.scale({
|
|
@@ -27900,12 +27917,10 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27900
27917
|
if (!this.handleNodeChanges) {
|
|
27901
27918
|
this.handleNodeChanges = (nodes) => {
|
|
27902
27919
|
this.teardownSelection();
|
|
27903
|
-
if (nodes.length === 1 && nodes[0].
|
|
27904
|
-
const strokeSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
|
|
27905
|
-
if (!strokeSelected) return;
|
|
27920
|
+
if (nodes.length === 1 && nodes[0].node?.type === WEAVE_STROKE_SINGLE_NODE_TYPE) {
|
|
27906
27921
|
this.setupHandles();
|
|
27907
|
-
this.showHandles(
|
|
27908
|
-
this.setupSelection(
|
|
27922
|
+
this.showHandles(nodes[0].instance);
|
|
27923
|
+
this.setupSelection(nodes[0].instance, true);
|
|
27909
27924
|
} else {
|
|
27910
27925
|
this.startHandle?.setAttr("strokeId", void 0);
|
|
27911
27926
|
this.startHandle?.visible(false);
|
|
@@ -27948,175 +27963,92 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27948
27963
|
return stroke;
|
|
27949
27964
|
}
|
|
27950
27965
|
setupHandles() {
|
|
27951
|
-
if (!this.startHandle)
|
|
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
|
-
|
|
28021
|
-
|
|
28022
|
-
|
|
28023
|
-
|
|
28024
|
-
|
|
28025
|
-
|
|
28026
|
-
|
|
28027
|
-
|
|
28028
|
-
|
|
28029
|
-
|
|
28030
|
-
|
|
28031
|
-
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;
|
|
28032
28046
|
this.startHandle.visible(false);
|
|
28033
|
-
|
|
28034
|
-
|
|
28035
|
-
if (!this.endHandle) {
|
|
28036
|
-
const endHandle = new Konva.Circle({
|
|
28037
|
-
id: "line-end-handle",
|
|
28038
|
-
radius: 5,
|
|
28039
|
-
fill: "#ffffff",
|
|
28040
|
-
stroke: "#000000",
|
|
28041
|
-
strokeWidth: 1,
|
|
28042
|
-
edgeDistanceDisableOnDrag: true,
|
|
28043
|
-
scaleX: 1 / this.instance.getStage().scaleX(),
|
|
28044
|
-
scaleY: 1 / this.instance.getStage().scaleY(),
|
|
28045
|
-
draggable: true
|
|
28046
|
-
});
|
|
28047
|
-
endHandle.on("pointerover", () => {
|
|
28048
|
-
this.instance.getStage().container().style.cursor = "move";
|
|
28049
|
-
});
|
|
28050
|
-
endHandle.on("pointerout", () => {
|
|
28051
|
-
this.instance.getStage().container().style.cursor = "default";
|
|
28052
|
-
});
|
|
28053
|
-
endHandle.on("dragstart", (e) => {
|
|
28054
|
-
const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
|
|
28055
|
-
if (tr) tr.hide();
|
|
28056
|
-
const strokeId = e.target.getAttr("strokeId");
|
|
28057
|
-
const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
|
|
28058
|
-
if (!draggedStroke) return;
|
|
28059
|
-
const points = draggedStroke.getAttrs().linePoints;
|
|
28060
|
-
if (points.length !== 4) return;
|
|
28061
|
-
if (points.length === 4) draggedStroke.setAttr("eventTarget", true);
|
|
28062
|
-
this.instance.emitEvent("onDrag", e.target);
|
|
28063
|
-
});
|
|
28064
|
-
endHandle.on("dragmove", (e) => {
|
|
28065
|
-
const draggedTarget = e.target;
|
|
28066
|
-
const strokeId = draggedTarget.getAttr("strokeId");
|
|
28067
|
-
const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
|
|
28068
|
-
if (!draggedStroke) return;
|
|
28069
|
-
const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
|
|
28070
|
-
if (!internalLine) return;
|
|
28071
|
-
const points = draggedStroke.getAttrs().linePoints;
|
|
28072
|
-
if (points.length !== 4) return;
|
|
28073
|
-
this.teardownSelection();
|
|
28074
|
-
const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
|
|
28075
|
-
draggedStroke.setAttrs({ linePoints: [
|
|
28076
|
-
points[0],
|
|
28077
|
-
points[1],
|
|
28078
|
-
newLinePoint.x,
|
|
28079
|
-
newLinePoint.y
|
|
28080
|
-
] });
|
|
28081
|
-
this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28082
|
-
const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
|
|
28083
|
-
this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
|
|
28084
|
-
const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
|
|
28085
|
-
this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28086
|
-
this.setupSelection(draggedStroke);
|
|
28087
|
-
});
|
|
28088
|
-
endHandle.on("dragend", (e) => {
|
|
28089
|
-
const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
|
|
28090
|
-
if (tr) tr.show();
|
|
28091
|
-
const draggedTarget = e.target;
|
|
28092
|
-
const strokeId = draggedTarget.getAttr("strokeId");
|
|
28093
|
-
const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
|
|
28094
|
-
if (!draggedStroke) return;
|
|
28095
|
-
const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
|
|
28096
|
-
if (!internalLine) return;
|
|
28097
|
-
const points = draggedStroke.getAttrs().linePoints;
|
|
28098
|
-
if (points.length !== 4) return;
|
|
28099
|
-
this.teardownSelection();
|
|
28100
|
-
const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
|
|
28101
|
-
draggedStroke.setAttrs({ linePoints: [
|
|
28102
|
-
points[0],
|
|
28103
|
-
points[1],
|
|
28104
|
-
newLinePoint.x,
|
|
28105
|
-
newLinePoint.y
|
|
28106
|
-
] });
|
|
28107
|
-
this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28108
|
-
const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
|
|
28109
|
-
this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
|
|
28110
|
-
const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
|
|
28111
|
-
this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28112
|
-
this.setupSelection(draggedStroke);
|
|
28113
|
-
this.instance.updateNode(this.serialize(draggedStroke));
|
|
28114
|
-
this.instance.emitEvent("onDrag", null);
|
|
28115
|
-
});
|
|
28116
|
-
this.endHandle = endHandle;
|
|
28047
|
+
} else {
|
|
28048
|
+
this.endHandle = handle;
|
|
28117
28049
|
this.endHandle.visible(false);
|
|
28118
|
-
this.instance.getSelectionLayer()?.add(this.endHandle);
|
|
28119
28050
|
}
|
|
28051
|
+
this.instance.getSelectionLayer()?.add(handle);
|
|
28120
28052
|
}
|
|
28121
28053
|
showHandles(stroke) {
|
|
28122
28054
|
if (this.startHandle === null || this.endHandle === null) return;
|
|
@@ -28140,7 +28072,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
28140
28072
|
this.tipManagers[tipEndStyle]?.render(stroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28141
28073
|
const internalLine = stroke.findOne(`#${stroke.getAttrs().id}-line`);
|
|
28142
28074
|
if (internalLine) internalLine.setAttrs({
|
|
28143
|
-
name:
|
|
28075
|
+
name: "stroke-internal",
|
|
28144
28076
|
dash: nextProps.dash,
|
|
28145
28077
|
fill: nextProps.fill,
|
|
28146
28078
|
stroke: nextProps.stroke,
|
|
@@ -28200,20 +28132,19 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
28200
28132
|
if (markSelected) instance.setAttrs({ isSelected: true });
|
|
28201
28133
|
const hoverClone = instance.findOne(".hoverClone");
|
|
28202
28134
|
if (hoverClone) return;
|
|
28203
|
-
const
|
|
28204
|
-
|
|
28205
|
-
|
|
28206
|
-
|
|
28207
|
-
|
|
28208
|
-
|
|
28209
|
-
|
|
28210
|
-
|
|
28211
|
-
|
|
28212
|
-
|
|
28213
|
-
|
|
28214
|
-
|
|
28215
|
-
|
|
28216
|
-
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
|
+
}
|
|
28217
28148
|
}
|
|
28218
28149
|
teardownSelection() {
|
|
28219
28150
|
const stage = this.instance.getStage();
|
|
@@ -28231,6 +28162,37 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
28231
28162
|
const tipEndStyle = instance.getAttrs().tipEndStyle ?? "none";
|
|
28232
28163
|
this.tipManagers[tipEndStyle]?.update(instance, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28233
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
|
+
}
|
|
28234
28196
|
};
|
|
28235
28197
|
|
|
28236
28198
|
//#endregion
|