@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/sdk.js +168 -201
- package/dist/sdk.node.js +168 -201
- package/dist/types.d.ts +21 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +168 -201
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
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.
|
|
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 =
|
|
24149
|
+
const diff = this.angleDiff(normalized, this.snappedAngle);
|
|
24146
24150
|
if (diff > releaseThreshold) {
|
|
24147
24151
|
this.snappedAngle = null;
|
|
24148
24152
|
return normalized;
|
|
@@ -25750,12 +25754,14 @@ const doPreloadCursors = async (cursorsToPreload, setCursor, getFallbackCursor,
|
|
|
25750
25754
|
const cursorUrls = [];
|
|
25751
25755
|
for (const cursorKey of cursors) {
|
|
25752
25756
|
const cursorValue = cursorsToPreload[cursorKey];
|
|
25753
|
-
|
|
25754
|
-
|
|
25755
|
-
|
|
25756
|
-
|
|
25757
|
-
|
|
25758
|
-
|
|
25757
|
+
if (hasValidUrl(cursorValue)) {
|
|
25758
|
+
const { preload, cursor } = extractCursorUrl(cursorValue);
|
|
25759
|
+
if (preload) cursorUrls.push({
|
|
25760
|
+
state: cursorKey,
|
|
25761
|
+
value: cursorValue,
|
|
25762
|
+
src: cursor
|
|
25763
|
+
});
|
|
25764
|
+
} else setCursor(cursorKey, cursorValue);
|
|
25759
25765
|
}
|
|
25760
25766
|
if (cursorUrls.length > 0) {
|
|
25761
25767
|
const cursorsPreloading = [];
|
|
@@ -25804,6 +25810,9 @@ const extractCursorUrl = (cursor) => {
|
|
|
25804
25810
|
cursor: url
|
|
25805
25811
|
};
|
|
25806
25812
|
};
|
|
25813
|
+
const hasValidUrl = (value) => {
|
|
25814
|
+
return /url\(["']?.+?["']?\)/i.test(value);
|
|
25815
|
+
};
|
|
25807
25816
|
const isAllowedUrl = (value) => {
|
|
25808
25817
|
if (/^https?:\/\//i.test(value)) return true;
|
|
25809
25818
|
if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
|
|
@@ -27460,8 +27469,8 @@ const WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG = { snapAngles: {
|
|
|
27460
27469
|
270,
|
|
27461
27470
|
315
|
|
27462
27471
|
],
|
|
27463
|
-
activateThreshold:
|
|
27464
|
-
releaseThreshold:
|
|
27472
|
+
activateThreshold: 3,
|
|
27473
|
+
releaseThreshold: 4
|
|
27465
27474
|
} };
|
|
27466
27475
|
const WEAVE_STROKE_SINGLE_NODE_TIP_TYPE = {
|
|
27467
27476
|
NONE: "none",
|
|
@@ -27583,7 +27592,7 @@ var WeaveArrowLineTipManager = class extends WeaveBaseLineTipManager {
|
|
|
27583
27592
|
const height = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Height`] ?? Math.sqrt(3) / 2 * 3;
|
|
27584
27593
|
const triangle = new Konva.Line({
|
|
27585
27594
|
id: `${instance.getAttrs().id}-tip-${point}`,
|
|
27586
|
-
name: "lineTip",
|
|
27595
|
+
name: "lineTip stroke-internal",
|
|
27587
27596
|
nodeId: instance.getAttrs().id,
|
|
27588
27597
|
closed: true,
|
|
27589
27598
|
stroke,
|
|
@@ -27649,7 +27658,7 @@ var WeaveCircleLineTipManager = class extends WeaveBaseLineTipManager {
|
|
|
27649
27658
|
const radius = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Radius`] ?? 1.5;
|
|
27650
27659
|
const circle = new Konva.Circle({
|
|
27651
27660
|
id: `${instance.getAttrs().id}-tip-${point}`,
|
|
27652
|
-
name: "lineTip",
|
|
27661
|
+
name: "lineTip stroke-internal",
|
|
27653
27662
|
nodeId: instance.getAttrs().id,
|
|
27654
27663
|
radius,
|
|
27655
27664
|
stroke: "black",
|
|
@@ -27763,7 +27772,7 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
|
|
|
27763
27772
|
const width = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Width`] ?? 3;
|
|
27764
27773
|
const square = new Konva.Rect({
|
|
27765
27774
|
id: `${instance.getAttrs().id}-tip-${point}`,
|
|
27766
|
-
name: "lineTip",
|
|
27775
|
+
name: "lineTip stroke-internal",
|
|
27767
27776
|
nodeId: instance.getAttrs().id,
|
|
27768
27777
|
width,
|
|
27769
27778
|
height: width,
|
|
@@ -27812,13 +27821,26 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27812
27821
|
this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
|
|
27813
27822
|
this.handleNodeChanges = null;
|
|
27814
27823
|
this.handleZoomChanges = null;
|
|
27824
|
+
this.shiftPressed = false;
|
|
27815
27825
|
this.snapper = new GreedySnapper({
|
|
27816
27826
|
snapAngles: this.config.snapAngles.angles,
|
|
27817
27827
|
activateThreshold: this.config.snapAngles.activateThreshold,
|
|
27818
27828
|
releaseThreshold: this.config.snapAngles.releaseThreshold
|
|
27819
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;
|
|
27820
27841
|
}
|
|
27821
27842
|
onRender(props) {
|
|
27843
|
+
this.initEvents();
|
|
27822
27844
|
const stroke = new Konva.Group({
|
|
27823
27845
|
...props,
|
|
27824
27846
|
name: `node ${WEAVE_STROKE_SINGLE_NODE_TYPE}`,
|
|
@@ -27830,7 +27852,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27830
27852
|
...props,
|
|
27831
27853
|
id: `${stroke.getAttrs().id}-line`,
|
|
27832
27854
|
nodeId: stroke.getAttrs().id,
|
|
27833
|
-
name:
|
|
27855
|
+
name: "stroke-internal",
|
|
27834
27856
|
x: 0,
|
|
27835
27857
|
y: 0,
|
|
27836
27858
|
strokeScaleEnabled: true,
|
|
@@ -27852,6 +27874,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27852
27874
|
shouldOverdrawWholeArea: points.length !== 4
|
|
27853
27875
|
};
|
|
27854
27876
|
};
|
|
27877
|
+
this.setupDefaultNodeEvents(stroke);
|
|
27855
27878
|
let originalStartHandleVisibility = null;
|
|
27856
27879
|
let originalEndHandleVisibility = null;
|
|
27857
27880
|
stroke.on("dragstart", () => {
|
|
@@ -27866,7 +27889,6 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27866
27889
|
originalStartHandleVisibility = null;
|
|
27867
27890
|
originalEndHandleVisibility = null;
|
|
27868
27891
|
});
|
|
27869
|
-
this.setupDefaultNodeEvents(stroke);
|
|
27870
27892
|
if (!this.handleZoomChanges) {
|
|
27871
27893
|
this.handleZoomChanges = () => {
|
|
27872
27894
|
if (this.startHandle) this.startHandle.scale({
|
|
@@ -27883,12 +27905,10 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27883
27905
|
if (!this.handleNodeChanges) {
|
|
27884
27906
|
this.handleNodeChanges = (nodes) => {
|
|
27885
27907
|
this.teardownSelection();
|
|
27886
|
-
if (nodes.length === 1 && nodes[0].
|
|
27887
|
-
const strokeSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
|
|
27888
|
-
if (!strokeSelected) return;
|
|
27908
|
+
if (nodes.length === 1 && nodes[0].node?.type === WEAVE_STROKE_SINGLE_NODE_TYPE) {
|
|
27889
27909
|
this.setupHandles();
|
|
27890
|
-
this.showHandles(
|
|
27891
|
-
this.setupSelection(
|
|
27910
|
+
this.showHandles(nodes[0].instance);
|
|
27911
|
+
this.setupSelection(nodes[0].instance, true);
|
|
27892
27912
|
} else {
|
|
27893
27913
|
this.startHandle?.setAttr("strokeId", void 0);
|
|
27894
27914
|
this.startHandle?.visible(false);
|
|
@@ -27931,175 +27951,92 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
27931
27951
|
return stroke;
|
|
27932
27952
|
}
|
|
27933
27953
|
setupHandles() {
|
|
27934
|
-
if (!this.startHandle)
|
|
27935
|
-
|
|
27936
|
-
|
|
27937
|
-
|
|
27938
|
-
|
|
27939
|
-
|
|
27940
|
-
|
|
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
|
-
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;
|
|
28015
28034
|
this.startHandle.visible(false);
|
|
28016
|
-
|
|
28017
|
-
|
|
28018
|
-
if (!this.endHandle) {
|
|
28019
|
-
const endHandle = new Konva.Circle({
|
|
28020
|
-
id: "line-end-handle",
|
|
28021
|
-
radius: 5,
|
|
28022
|
-
fill: "#ffffff",
|
|
28023
|
-
stroke: "#000000",
|
|
28024
|
-
strokeWidth: 1,
|
|
28025
|
-
edgeDistanceDisableOnDrag: true,
|
|
28026
|
-
scaleX: 1 / this.instance.getStage().scaleX(),
|
|
28027
|
-
scaleY: 1 / this.instance.getStage().scaleY(),
|
|
28028
|
-
draggable: true
|
|
28029
|
-
});
|
|
28030
|
-
endHandle.on("pointerover", () => {
|
|
28031
|
-
this.instance.getStage().container().style.cursor = "move";
|
|
28032
|
-
});
|
|
28033
|
-
endHandle.on("pointerout", () => {
|
|
28034
|
-
this.instance.getStage().container().style.cursor = "default";
|
|
28035
|
-
});
|
|
28036
|
-
endHandle.on("dragstart", (e) => {
|
|
28037
|
-
const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
|
|
28038
|
-
if (tr) tr.hide();
|
|
28039
|
-
const strokeId = e.target.getAttr("strokeId");
|
|
28040
|
-
const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
|
|
28041
|
-
if (!draggedStroke) return;
|
|
28042
|
-
const points = draggedStroke.getAttrs().linePoints;
|
|
28043
|
-
if (points.length !== 4) return;
|
|
28044
|
-
if (points.length === 4) draggedStroke.setAttr("eventTarget", true);
|
|
28045
|
-
this.instance.emitEvent("onDrag", e.target);
|
|
28046
|
-
});
|
|
28047
|
-
endHandle.on("dragmove", (e) => {
|
|
28048
|
-
const draggedTarget = e.target;
|
|
28049
|
-
const strokeId = draggedTarget.getAttr("strokeId");
|
|
28050
|
-
const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
|
|
28051
|
-
if (!draggedStroke) return;
|
|
28052
|
-
const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
|
|
28053
|
-
if (!internalLine) return;
|
|
28054
|
-
const points = draggedStroke.getAttrs().linePoints;
|
|
28055
|
-
if (points.length !== 4) return;
|
|
28056
|
-
this.teardownSelection();
|
|
28057
|
-
const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
|
|
28058
|
-
draggedStroke.setAttrs({ linePoints: [
|
|
28059
|
-
points[0],
|
|
28060
|
-
points[1],
|
|
28061
|
-
newLinePoint.x,
|
|
28062
|
-
newLinePoint.y
|
|
28063
|
-
] });
|
|
28064
|
-
this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28065
|
-
const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
|
|
28066
|
-
this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
|
|
28067
|
-
const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
|
|
28068
|
-
this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28069
|
-
this.setupSelection(draggedStroke);
|
|
28070
|
-
});
|
|
28071
|
-
endHandle.on("dragend", (e) => {
|
|
28072
|
-
const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
|
|
28073
|
-
if (tr) tr.show();
|
|
28074
|
-
const draggedTarget = e.target;
|
|
28075
|
-
const strokeId = draggedTarget.getAttr("strokeId");
|
|
28076
|
-
const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
|
|
28077
|
-
if (!draggedStroke) return;
|
|
28078
|
-
const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
|
|
28079
|
-
if (!internalLine) return;
|
|
28080
|
-
const points = draggedStroke.getAttrs().linePoints;
|
|
28081
|
-
if (points.length !== 4) return;
|
|
28082
|
-
this.teardownSelection();
|
|
28083
|
-
const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
|
|
28084
|
-
draggedStroke.setAttrs({ linePoints: [
|
|
28085
|
-
points[0],
|
|
28086
|
-
points[1],
|
|
28087
|
-
newLinePoint.x,
|
|
28088
|
-
newLinePoint.y
|
|
28089
|
-
] });
|
|
28090
|
-
this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28091
|
-
const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
|
|
28092
|
-
this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
|
|
28093
|
-
const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
|
|
28094
|
-
this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28095
|
-
this.setupSelection(draggedStroke);
|
|
28096
|
-
this.instance.updateNode(this.serialize(draggedStroke));
|
|
28097
|
-
this.instance.emitEvent("onDrag", null);
|
|
28098
|
-
});
|
|
28099
|
-
this.endHandle = endHandle;
|
|
28035
|
+
} else {
|
|
28036
|
+
this.endHandle = handle;
|
|
28100
28037
|
this.endHandle.visible(false);
|
|
28101
|
-
this.instance.getSelectionLayer()?.add(this.endHandle);
|
|
28102
28038
|
}
|
|
28039
|
+
this.instance.getSelectionLayer()?.add(handle);
|
|
28103
28040
|
}
|
|
28104
28041
|
showHandles(stroke) {
|
|
28105
28042
|
if (this.startHandle === null || this.endHandle === null) return;
|
|
@@ -28123,7 +28060,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
28123
28060
|
this.tipManagers[tipEndStyle]?.render(stroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28124
28061
|
const internalLine = stroke.findOne(`#${stroke.getAttrs().id}-line`);
|
|
28125
28062
|
if (internalLine) internalLine.setAttrs({
|
|
28126
|
-
name:
|
|
28063
|
+
name: "stroke-internal",
|
|
28127
28064
|
dash: nextProps.dash,
|
|
28128
28065
|
fill: nextProps.fill,
|
|
28129
28066
|
stroke: nextProps.stroke,
|
|
@@ -28183,20 +28120,19 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
28183
28120
|
if (markSelected) instance.setAttrs({ isSelected: true });
|
|
28184
28121
|
const hoverClone = instance.findOne(".hoverClone");
|
|
28185
28122
|
if (hoverClone) return;
|
|
28186
|
-
const
|
|
28187
|
-
|
|
28188
|
-
|
|
28189
|
-
|
|
28190
|
-
|
|
28191
|
-
|
|
28192
|
-
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
|
|
28197
|
-
|
|
28198
|
-
|
|
28199
|
-
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
|
+
}
|
|
28200
28136
|
}
|
|
28201
28137
|
teardownSelection() {
|
|
28202
28138
|
const stage = this.instance.getStage();
|
|
@@ -28214,6 +28150,37 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
|
|
|
28214
28150
|
const tipEndStyle = instance.getAttrs().tipEndStyle ?? "none";
|
|
28215
28151
|
this.tipManagers[tipEndStyle]?.update(instance, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
|
|
28216
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
|
+
}
|
|
28217
28184
|
};
|
|
28218
28185
|
|
|
28219
28186
|
//#endregion
|
package/dist/types.d.ts
CHANGED
|
@@ -5,15 +5,15 @@ import * as Y$1 from "yjs";
|
|
|
5
5
|
import * as Y from "yjs";
|
|
6
6
|
import { Doc } from "yjs";
|
|
7
7
|
import * as konva_lib_types8 from "konva/lib/types";
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
8
|
+
import * as konva_lib_types22 from "konva/lib/types";
|
|
9
|
+
import * as konva_lib_types23 from "konva/lib/types";
|
|
10
10
|
import { Vector2d } from "konva/lib/types";
|
|
11
|
+
import * as konva_lib_Node14 from "konva/lib/Node";
|
|
12
|
+
import * as konva_lib_Node15 from "konva/lib/Node";
|
|
13
|
+
import * as konva_lib_Node16 from "konva/lib/Node";
|
|
14
|
+
import * as konva_lib_Node17 from "konva/lib/Node";
|
|
11
15
|
import * as konva_lib_Node18 from "konva/lib/Node";
|
|
12
16
|
import * as konva_lib_Node19 from "konva/lib/Node";
|
|
13
|
-
import * as konva_lib_Node20 from "konva/lib/Node";
|
|
14
|
-
import * as konva_lib_Node21 from "konva/lib/Node";
|
|
15
|
-
import * as konva_lib_Node22 from "konva/lib/Node";
|
|
16
|
-
import * as konva_lib_Node23 from "konva/lib/Node";
|
|
17
17
|
import * as konva_lib_Node0 from "konva/lib/Node";
|
|
18
18
|
import * as konva_lib_Node1 from "konva/lib/Node";
|
|
19
19
|
import * as konva_lib_Node2 from "konva/lib/Node";
|
|
@@ -29,8 +29,8 @@ import { Stage, StageConfig } from "konva/lib/Stage";
|
|
|
29
29
|
import * as konva_lib_shapes_Transformer4 from "konva/lib/shapes/Transformer";
|
|
30
30
|
import { TransformerConfig } from "konva/lib/shapes/Transformer";
|
|
31
31
|
import * as konva_lib_shapes_Rect12 from "konva/lib/shapes/Rect";
|
|
32
|
-
import * as
|
|
33
|
-
import * as
|
|
32
|
+
import * as konva_lib_shapes_Line20 from "konva/lib/shapes/Line";
|
|
33
|
+
import * as konva_lib_shapes_Line21 from "konva/lib/shapes/Line";
|
|
34
34
|
import * as konva_lib_Layer13 from "konva/lib/Layer";
|
|
35
35
|
|
|
36
36
|
//#region src/stores/store.d.ts
|
|
@@ -928,7 +928,7 @@ declare class WeaveTargetingManager {
|
|
|
928
928
|
nodeIntersectsContainerElement(node: Konva.Node | Konva.Transformer, actualLayer?: Konva.Layer | Konva.Group): Konva.Node | undefined;
|
|
929
929
|
getMousePointer(point?: Konva.Vector2d): WeaveMousePointInfo;
|
|
930
930
|
getMousePointerRelativeToContainer(container: Konva.Node | Konva.Layer): WeaveMousePointInfoSimple;
|
|
931
|
-
getRealSelectedNode: (nodeTarget: Konva.Node) =>
|
|
931
|
+
getRealSelectedNode: (nodeTarget: Konva.Node) => konva_lib_Node15.Node<konva_lib_Node14.NodeConfig>;
|
|
932
932
|
}
|
|
933
933
|
|
|
934
934
|
//#endregion
|
|
@@ -947,8 +947,8 @@ declare class WeaveCloningManager {
|
|
|
947
947
|
cloneNode(targetNode: Konva.Node): Konva.Node | undefined;
|
|
948
948
|
addClone(node: Konva.Node): void;
|
|
949
949
|
removeClone(node: Konva.Node): void;
|
|
950
|
-
getClones():
|
|
951
|
-
isClone(node: Konva.Node):
|
|
950
|
+
getClones(): konva_lib_Node17.Node<konva_lib_Node16.NodeConfig>[];
|
|
951
|
+
isClone(node: Konva.Node): konva_lib_Node19.Node<konva_lib_Node18.NodeConfig> | undefined;
|
|
952
952
|
cleanupClones(): void;
|
|
953
953
|
}
|
|
954
954
|
|
|
@@ -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
|
|
|
@@ -2110,10 +2111,10 @@ declare class WeaveBaseLineTipManager {
|
|
|
2110
2111
|
render(instance: Konva.Group, point: WeaveStrokeSingleNodeTipSide): void;
|
|
2111
2112
|
update(instance: Konva.Group, point: WeaveStrokeSingleNodeTipSide): void;
|
|
2112
2113
|
protected getTip(instance: Konva.Group, point: WeaveStrokeSingleNodeTipSide): Konva.Node | undefined;
|
|
2113
|
-
protected getInternalLine(instance: Konva.Group):
|
|
2114
|
+
protected getInternalLine(instance: Konva.Group): konva_lib_shapes_Line21.Line<konva_lib_shapes_Line20.LineConfig> | undefined;
|
|
2114
2115
|
protected getLinePoints(instance: Konva.Group): {
|
|
2115
|
-
lineStartPoint:
|
|
2116
|
-
lineEndPoint:
|
|
2116
|
+
lineStartPoint: konva_lib_types22.Vector2d;
|
|
2117
|
+
lineEndPoint: konva_lib_types23.Vector2d;
|
|
2117
2118
|
};
|
|
2118
2119
|
}
|
|
2119
2120
|
|
|
@@ -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
|