@plait/draw 0.92.1 → 0.92.2
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/fesm2022/plait-draw.mjs +56 -23
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/index.d.ts +16 -16
- package/package.json +1 -1
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1473,8 +1473,9 @@ const Q2C = (points) => {
|
|
|
1473
1473
|
return result;
|
|
1474
1474
|
};
|
|
1475
1475
|
const handleArrowLineCreating = (board, lineShape, sourcePoint, movingPoint, sourceElement, lineShapeG, options) => {
|
|
1476
|
-
const
|
|
1477
|
-
const
|
|
1476
|
+
const alignedMovingPoint = alignPoints(sourcePoint, movingPoint);
|
|
1477
|
+
const hitElement = getSnappingShape(board, alignedMovingPoint);
|
|
1478
|
+
const targetConnection = hitElement ? getHitConnection(board, alignedMovingPoint, hitElement) : undefined;
|
|
1478
1479
|
const sourceConnection = sourceElement ? getHitConnection(board, sourcePoint, sourceElement) : undefined;
|
|
1479
1480
|
const targetBoundId = hitElement ? hitElement.id : undefined;
|
|
1480
1481
|
const lineGenerator = new ArrowLineShapeGenerator(board);
|
|
@@ -1484,14 +1485,14 @@ const handleArrowLineCreating = (board, lineShape, sourcePoint, movingPoint, sou
|
|
|
1484
1485
|
targetMarker = memorizedLatest.target;
|
|
1485
1486
|
sourceMarker && delete memorizedLatest.source;
|
|
1486
1487
|
targetMarker && delete memorizedLatest.target;
|
|
1487
|
-
const temporaryLineElement = createArrowLineElement(lineShape, [sourcePoint,
|
|
1488
|
+
const temporaryLineElement = createArrowLineElement(lineShape, [sourcePoint, alignedMovingPoint], { marker: sourceMarker || ArrowLineMarkerType.none, connection: sourceConnection, boundId: sourceElement?.id }, { marker: targetMarker || ArrowLineMarkerType.arrow, connection: targetConnection, boundId: targetBoundId }, [], {
|
|
1488
1489
|
strokeWidth: DefaultLineStyle.strokeWidth,
|
|
1489
1490
|
...memorizedLatest,
|
|
1490
1491
|
...options
|
|
1491
1492
|
});
|
|
1492
1493
|
const linePoints = getArrowLinePoints(board, temporaryLineElement);
|
|
1493
1494
|
const otherPoint = linePoints[0];
|
|
1494
|
-
temporaryLineElement.points[1] = alignPoints(otherPoint,
|
|
1495
|
+
temporaryLineElement.points[1] = alignPoints(otherPoint, alignedMovingPoint);
|
|
1495
1496
|
lineGenerator.processDrawing(temporaryLineElement, lineShapeG);
|
|
1496
1497
|
PlaitBoard.getElementTopHost(board).append(lineShapeG);
|
|
1497
1498
|
return temporaryLineElement;
|
|
@@ -7518,6 +7519,7 @@ const withDrawHotkey = (board) => {
|
|
|
7518
7519
|
else {
|
|
7519
7520
|
editText(board, hitElement);
|
|
7520
7521
|
}
|
|
7522
|
+
return;
|
|
7521
7523
|
}
|
|
7522
7524
|
}
|
|
7523
7525
|
dblClick(event);
|
|
@@ -7896,9 +7898,32 @@ const withArrowLineResize = (board) => {
|
|
|
7896
7898
|
const hitElement = getSnappingShape(board, resizeState.endPoint);
|
|
7897
7899
|
if (resizeRef.handle === LineResizeHandle.source || resizeRef.handle === LineResizeHandle.target) {
|
|
7898
7900
|
const object = resizeRef.handle === LineResizeHandle.source ? source : target;
|
|
7899
|
-
|
|
7901
|
+
// axis alignment relative to adjacent point, even when snapping to a shape
|
|
7902
|
+
const neighborPoint = handleIndex === 0 ? points[1] : points[points.length - 2];
|
|
7903
|
+
// TODO: need handle the neighbor point is not key point(it will moving along moving point)
|
|
7904
|
+
// such as below case
|
|
7905
|
+
// [
|
|
7906
|
+
// [
|
|
7907
|
+
// 341.2536906953894,
|
|
7908
|
+
// 83.94690212817761
|
|
7909
|
+
// ],
|
|
7910
|
+
// [
|
|
7911
|
+
// 492.8570148670465,
|
|
7912
|
+
// 43.86424319286277
|
|
7913
|
+
// ],
|
|
7914
|
+
// [
|
|
7915
|
+
// 492.8570148670465,
|
|
7916
|
+
// 175.99593084572632
|
|
7917
|
+
// ],
|
|
7918
|
+
// [
|
|
7919
|
+
// 661.8118177564218,
|
|
7920
|
+
// 175.99593084572632
|
|
7921
|
+
// ]
|
|
7922
|
+
// ]
|
|
7923
|
+
const alignedEndPoint = neighborPoint ? alignPoints(neighborPoint, resizeState.endPoint) : resizeState.endPoint;
|
|
7924
|
+
points[handleIndex] = alignedEndPoint;
|
|
7900
7925
|
if (hitElement) {
|
|
7901
|
-
object.connection = getHitConnection(board,
|
|
7926
|
+
object.connection = getHitConnection(board, alignedEndPoint, hitElement);
|
|
7902
7927
|
object.boundId = hitElement.id;
|
|
7903
7928
|
}
|
|
7904
7929
|
else {
|
|
@@ -7934,23 +7959,6 @@ const withArrowLineResize = (board) => {
|
|
|
7934
7959
|
}
|
|
7935
7960
|
}
|
|
7936
7961
|
}
|
|
7937
|
-
if (!hitElement) {
|
|
7938
|
-
handleIndex = resizeRef.handle === LineResizeHandle.addHandle ? handleIndex + 1 : handleIndex;
|
|
7939
|
-
const drawPoints = getArrowLinePoints(board, resizeRef.element);
|
|
7940
|
-
const newPoints = [...points];
|
|
7941
|
-
newPoints[0] = drawPoints[0];
|
|
7942
|
-
newPoints[newPoints.length - 1] = drawPoints[drawPoints.length - 1];
|
|
7943
|
-
if (resizeRef.element.shape !== ArrowLineShape.elbow ||
|
|
7944
|
-
(resizeRef.element.shape === ArrowLineShape.elbow && newPoints.length === 2)) {
|
|
7945
|
-
newPoints.forEach((point, index) => {
|
|
7946
|
-
if (index === handleIndex)
|
|
7947
|
-
return;
|
|
7948
|
-
if (points[handleIndex]) {
|
|
7949
|
-
points[handleIndex] = alignPoints(point, points[handleIndex]);
|
|
7950
|
-
}
|
|
7951
|
-
});
|
|
7952
|
-
}
|
|
7953
|
-
}
|
|
7954
7962
|
DrawTransforms.resizeArrowLine(board, { points, source, target }, resizeRef.path);
|
|
7955
7963
|
},
|
|
7956
7964
|
afterResize: (resizeRef) => {
|
|
@@ -7987,6 +7995,14 @@ const withArrowLineResize = (board) => {
|
|
|
7987
7995
|
return board;
|
|
7988
7996
|
};
|
|
7989
7997
|
|
|
7998
|
+
/*
|
|
7999
|
+
Purpose: Visual feedback for snapping/binding arrow-line endpoints to shapes.
|
|
8000
|
+
- Active when using arrow-line pointers or resizing source/target handles.
|
|
8001
|
+
- Detects target shape under cursor and whether edge/connector snapping applies.
|
|
8002
|
+
- Draws bound outline/mask and a connector marker at the snap point.
|
|
8003
|
+
- Applies rotation to reaction graphics for angled (rotated) shapes.
|
|
8004
|
+
Lifecycle: pointerMove → detect hit/snapping → render reaction → pointerUp cleanup.
|
|
8005
|
+
*/
|
|
7990
8006
|
const withArrowLineBoundReaction = (board) => {
|
|
7991
8007
|
const { pointerMove, pointerUp } = board;
|
|
7992
8008
|
let boundShapeG = null;
|
|
@@ -8072,6 +8088,7 @@ const withArrowLineText = (board) => {
|
|
|
8072
8088
|
}
|
|
8073
8089
|
});
|
|
8074
8090
|
}
|
|
8091
|
+
return;
|
|
8075
8092
|
}
|
|
8076
8093
|
}
|
|
8077
8094
|
dblClick(event);
|
|
@@ -8157,6 +8174,14 @@ class ImageComponent extends CommonElementFlavour {
|
|
|
8157
8174
|
|
|
8158
8175
|
const WithArrowLineAutoCompletePluginKey = 'plait-arrow-line-auto-complete-plugin-key';
|
|
8159
8176
|
const BOARD_TO_PRE_COMMIT = new WeakMap();
|
|
8177
|
+
/*
|
|
8178
|
+
Purpose: Create arrow line via auto-complete drag from a shape edge.
|
|
8179
|
+
- On pointerDown at an auto-complete point, set elbow mode and capture source.
|
|
8180
|
+
- On drag (beyond buffer), choose nearest crossing on the source edge if available.
|
|
8181
|
+
- Rotate source point; build temporary elbow arrow while moving.
|
|
8182
|
+
- On release, insert the arrow and select; otherwise commit preview pair if present.
|
|
8183
|
+
Lifecycle: pointerDown → pointerMove (create temp) → pointerUp insert/commit → reset.
|
|
8184
|
+
*/
|
|
8160
8185
|
const withArrowLineAutoComplete = (board) => {
|
|
8161
8186
|
const { pointerDown, pointerMove, globalPointerUp, touchMove } = board;
|
|
8162
8187
|
let autoCompletePoint = null;
|
|
@@ -8240,6 +8265,14 @@ const withArrowLineAutoComplete = (board) => {
|
|
|
8240
8265
|
};
|
|
8241
8266
|
|
|
8242
8267
|
const PREVIEW_ARROW_LINE_DISTANCE = 100;
|
|
8268
|
+
/*
|
|
8269
|
+
Purpose: Hover-driven auto-complete preview for arrow lines.
|
|
8270
|
+
- When hovering a selected shape’s auto-complete point, show a hint circle.
|
|
8271
|
+
- Offset a temporary shape and build an elbow arrow from the hit edge.
|
|
8272
|
+
- Rotate points by element angle; compute target connection; bind target id.
|
|
8273
|
+
- Store temporary arrow/shape for pre-commit; commit on click via auto-complete plugin.
|
|
8274
|
+
Lifecycle: pointerMove (hit/preview) → pointerLeave/globalPointerUp cleanup.
|
|
8275
|
+
*/
|
|
8243
8276
|
const withArrowLineAutoCompleteReaction = (board) => {
|
|
8244
8277
|
const { pointerMove, pointerLeave, globalPointerUp } = board;
|
|
8245
8278
|
let reactionG = null;
|