@plait/draw 0.75.0-next.9 → 0.76.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/engines/basic-shapes/cloud.d.ts +2 -12
- package/engines/uml/provided-interface.d.ts +0 -5
- package/esm2022/arrow-line.component.mjs +14 -7
- package/esm2022/engines/basic-shapes/cloud.mjs +10 -11
- package/esm2022/engines/flowchart/note-curly-left.mjs +48 -12
- package/esm2022/engines/flowchart/note-curly-right.mjs +49 -10
- package/esm2022/engines/uml/actor.mjs +61 -44
- package/esm2022/engines/uml/assembly.mjs +72 -23
- package/esm2022/engines/uml/component.mjs +78 -33
- package/esm2022/engines/uml/deletion.mjs +28 -6
- package/esm2022/engines/uml/package.mjs +51 -21
- package/esm2022/engines/uml/provided-interface.mjs +53 -26
- package/esm2022/engines/uml/required-interface.mjs +51 -7
- package/esm2022/generators/arrow-line-auto-complete.generator.mjs +3 -3
- package/esm2022/generators/line-active.generator.mjs +14 -10
- package/esm2022/geometry.component.mjs +20 -10
- package/esm2022/image.component.mjs +12 -6
- package/esm2022/plugins/with-arrow-line-auto-complete-reaction.mjs +9 -7
- package/esm2022/plugins/with-arrow-line-auto-complete.mjs +9 -8
- package/esm2022/plugins/with-arrow-line-bound-reaction.mjs +4 -4
- package/esm2022/plugins/with-arrow-line-text-move.mjs +2 -2
- package/esm2022/plugins/with-draw-resize.mjs +9 -7
- package/esm2022/plugins/with-draw-rotate.mjs +23 -18
- package/esm2022/plugins/with-geometry-create.mjs +4 -4
- package/esm2022/plugins/with-swimlane-create.mjs +4 -4
- package/esm2022/plugins/with-table-resize.mjs +5 -5
- package/esm2022/plugins/with-table.mjs +3 -2
- package/esm2022/table.component.mjs +19 -11
- package/esm2022/utils/arrow-line/arrow-line-basic.mjs +3 -3
- package/esm2022/utils/common.mjs +9 -9
- package/esm2022/utils/geometry.mjs +8 -13
- package/esm2022/utils/hit.mjs +7 -7
- package/esm2022/utils/vector-line.mjs +2 -2
- package/esm2022/vector-line.component.mjs +12 -5
- package/fesm2022/plait-draw.mjs +648 -290
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/generators/line-active.generator.d.ts +5 -1
- package/package.json +1 -1
- package/utils/geometry.d.ts +1 -2
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, catmullRomFitting, PlaitBoard, createG, drawLinearPath, setStrokeLinecap, setPathStrokeLinecap, getNearestPointBetweenPointAndArc, distanceBetweenPointAndPoint, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, createDebugGenerator, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, Point, arrowPoints, createPath, rotate, findElements, createMask, createRect, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, Path, RgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
|
|
2
|
-
import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, getPointOnPolyline, buildText, Generator, getStrokeLineDash, StrokeStyle, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, RESIZE_HANDLE_DIAMETER, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage,
|
|
1
|
+
import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, catmullRomFitting, PlaitBoard, createG, drawLinearPath, setStrokeLinecap, setPathStrokeLinecap, getNearestPointBetweenPointAndArc, distanceBetweenPointAndPoint, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, createDebugGenerator, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, Point, arrowPoints, createPath, rotate, findElements, createMask, createRect, toActiveRectangleFromViewBoxRectangle, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, getNearestPointBetweenPointAndDiscreteSegments, getNearestPointBetweenPointAndSegment, Path, RgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, toActivePointFromViewBoxPoint, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, CursorClass, toActivePoint, temporaryDisableSelection, toScreenPointFromActivePoint, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
|
|
2
|
+
import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, getPointOnPolyline, buildText, Generator, getStrokeLineDash, StrokeStyle, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, RESIZE_HANDLE_DIAMETER, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, isCornerHandle, getIndexByResizeHandle, withResize, drawHandle, getSymmetricHandleIndex, getResizeHandlePointByIndex, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, createActiveGenerator, hasResizeHandle, ActiveGenerator, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
|
|
3
3
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
4
4
|
import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
|
|
5
5
|
import { Editor, Node } from 'slate';
|
|
@@ -1012,7 +1012,7 @@ const vectorLineCreating = (board, lineShape, points, movingPoint, lineShapeG) =
|
|
|
1012
1012
|
const otherPoint = points[points.length - 1];
|
|
1013
1013
|
temporaryLineElement.points[temporaryLineElement.points.length - 1] = alignPoints(otherPoint, movingPoint);
|
|
1014
1014
|
lineGenerator.processDrawing(temporaryLineElement, lineShapeG);
|
|
1015
|
-
PlaitBoard.
|
|
1015
|
+
PlaitBoard.getElementTopHost(board).append(lineShapeG);
|
|
1016
1016
|
return temporaryLineElement;
|
|
1017
1017
|
};
|
|
1018
1018
|
const drawVectorLine = (board, element) => {
|
|
@@ -1069,7 +1069,7 @@ function generateCloudPath(rectangle) {
|
|
|
1069
1069
|
const xRadius = divisionWidth / 8.5;
|
|
1070
1070
|
const yRadius = divisionHeight / 20;
|
|
1071
1071
|
const startPoint = [rectangle.x + divisionWidth, rectangle.y + divisionHeight];
|
|
1072
|
-
const
|
|
1072
|
+
const arcCommands = [
|
|
1073
1073
|
{
|
|
1074
1074
|
rx: xRadius,
|
|
1075
1075
|
ry: yRadius * 1.2,
|
|
@@ -1143,15 +1143,15 @@ function generateCloudPath(rectangle) {
|
|
|
1143
1143
|
endY: rectangle.y + divisionHeight
|
|
1144
1144
|
}
|
|
1145
1145
|
];
|
|
1146
|
-
return { startPoint,
|
|
1146
|
+
return { startPoint, arcCommands };
|
|
1147
1147
|
}
|
|
1148
1148
|
const CloudEngine = {
|
|
1149
1149
|
draw(board, rectangle, options) {
|
|
1150
1150
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
1151
|
-
const { startPoint,
|
|
1151
|
+
const { startPoint, arcCommands } = generateCloudPath(rectangle);
|
|
1152
1152
|
const pathData = `M ${startPoint[0]} ${startPoint[1]} ` +
|
|
1153
|
-
|
|
1154
|
-
.map((
|
|
1153
|
+
arcCommands
|
|
1154
|
+
.map((command) => `A ${command.rx} ${command.ry} ${command.xAxisRotation} ${command.largeArcFlag} ${command.sweepFlag} ${command.endX} ${command.endY}`)
|
|
1155
1155
|
.join('\n') +
|
|
1156
1156
|
' Z';
|
|
1157
1157
|
const svgElement = rs.path(pathData, { ...options, fillStyle: 'solid' });
|
|
@@ -1166,19 +1166,18 @@ const CloudEngine = {
|
|
|
1166
1166
|
return RectangleClient.getCornerPoints(rectangle);
|
|
1167
1167
|
},
|
|
1168
1168
|
getNearestPoint(rectangle, point) {
|
|
1169
|
-
const { startPoint,
|
|
1169
|
+
const { startPoint, arcCommands } = generateCloudPath(rectangle);
|
|
1170
1170
|
let minDistance = Infinity;
|
|
1171
1171
|
let nearestPoint = point;
|
|
1172
|
-
// 检查每个弧段
|
|
1173
1172
|
let currentStart = startPoint;
|
|
1174
|
-
for (const
|
|
1175
|
-
const arcNearestPoint = getNearestPointBetweenPointAndArc(point, currentStart,
|
|
1173
|
+
for (const arcCommand of arcCommands) {
|
|
1174
|
+
const arcNearestPoint = getNearestPointBetweenPointAndArc(point, currentStart, arcCommand);
|
|
1176
1175
|
const distance = distanceBetweenPointAndPoint(point[0], point[1], arcNearestPoint[0], arcNearestPoint[1]);
|
|
1177
1176
|
if (distance < minDistance) {
|
|
1178
1177
|
minDistance = distance;
|
|
1179
1178
|
nearestPoint = arcNearestPoint;
|
|
1180
1179
|
}
|
|
1181
|
-
currentStart = [
|
|
1180
|
+
currentStart = [arcCommand.endX, arcCommand.endY];
|
|
1182
1181
|
}
|
|
1183
1182
|
return nearestPoint;
|
|
1184
1183
|
},
|
|
@@ -1216,7 +1215,7 @@ const isHitArrowLineText = (board, element, point) => {
|
|
|
1216
1215
|
return getHitArrowLineTextIndex(board, element, point) !== -1;
|
|
1217
1216
|
};
|
|
1218
1217
|
const isHitPolyLine = (pathPoints, point) => {
|
|
1219
|
-
const distance = distanceBetweenPointAndSegments(
|
|
1218
|
+
const distance = distanceBetweenPointAndSegments(point, pathPoints);
|
|
1220
1219
|
return distance <= HIT_DISTANCE_BUFFER;
|
|
1221
1220
|
};
|
|
1222
1221
|
const isHitArrowLine = (board, element, point) => {
|
|
@@ -1345,17 +1344,17 @@ const debugGenerator$4 = createDebugGenerator(debugKey$4);
|
|
|
1345
1344
|
const shapes = [BasicShapes.cloud];
|
|
1346
1345
|
const isHitDrawElement = (board, element, point, isStrict = true) => {
|
|
1347
1346
|
const rectangle = board.getRectangle(element);
|
|
1348
|
-
point = rotateAntiPointsByElement(point, element) || point;
|
|
1347
|
+
point = rotateAntiPointsByElement(board, point, element) || point;
|
|
1349
1348
|
if (PlaitDrawElement.isGeometry(element) && rectangle) {
|
|
1350
1349
|
if (debugGenerator$4.isDebug() && shapes.includes(element.shape)) {
|
|
1351
1350
|
debugGenerator$4.clear();
|
|
1352
|
-
const { startPoint,
|
|
1353
|
-
const points = [startPoint, ...
|
|
1351
|
+
const { startPoint, arcCommands } = generateCloudPath(rectangle);
|
|
1352
|
+
const points = [startPoint, ...arcCommands.map((arc) => [arc.endX, arc.endY])];
|
|
1354
1353
|
debugGenerator$4.drawCircles(board, points, 5, false);
|
|
1355
1354
|
let minDistance = Infinity;
|
|
1356
1355
|
let nearestPoint = point;
|
|
1357
1356
|
let currentStart = startPoint;
|
|
1358
|
-
for (const arc of
|
|
1357
|
+
for (const arc of arcCommands) {
|
|
1359
1358
|
const arcNearestPoint = getNearestPointBetweenPointAndArc(point, currentStart, arc);
|
|
1360
1359
|
const distance = distanceBetweenPointAndPoint(point[0], point[1], arcNearestPoint[0], arcNearestPoint[1]);
|
|
1361
1360
|
const { center } = getEllipseArcCenter(currentStart, arc);
|
|
@@ -1406,7 +1405,7 @@ const isInsideOfShape = (board, element, point, hitDistanceBuffer) => {
|
|
|
1406
1405
|
};
|
|
1407
1406
|
const isHitElementInside = (board, element, point) => {
|
|
1408
1407
|
const rectangle = board.getRectangle(element);
|
|
1409
|
-
point = rotateAntiPointsByElement(point, element) || point;
|
|
1408
|
+
point = rotateAntiPointsByElement(board, point, element) || point;
|
|
1410
1409
|
if (PlaitDrawElement.isGeometry(element) && !PlaitDrawElement.isGeometryByTable(element)) {
|
|
1411
1410
|
const engine = getEngine(getElementShape(element));
|
|
1412
1411
|
const isHitInside = engine.isInsidePoint(rectangle, point);
|
|
@@ -1474,12 +1473,12 @@ const isDrawElementIncludeText = (element) => {
|
|
|
1474
1473
|
return editors.length > 0;
|
|
1475
1474
|
}
|
|
1476
1475
|
if (PlaitDrawElement.isElementByTable(element)) {
|
|
1477
|
-
return element.cells.some(cell => isCellIncludeText(cell));
|
|
1476
|
+
return element.cells.some((cell) => isCellIncludeText(cell));
|
|
1478
1477
|
}
|
|
1479
1478
|
return true;
|
|
1480
1479
|
};
|
|
1481
1480
|
const isDrawElementsIncludeText = (elements) => {
|
|
1482
|
-
return elements.some(item => {
|
|
1481
|
+
return elements.some((item) => {
|
|
1483
1482
|
return isDrawElementIncludeText(item);
|
|
1484
1483
|
});
|
|
1485
1484
|
};
|
|
@@ -1512,7 +1511,7 @@ const getSnappingShape = (board, point) => {
|
|
|
1512
1511
|
return null;
|
|
1513
1512
|
};
|
|
1514
1513
|
const getSnappingRef = (board, hitElement, point) => {
|
|
1515
|
-
const rotatedPoint = rotateAntiPointsByElement(point, hitElement) || point;
|
|
1514
|
+
const rotatedPoint = rotateAntiPointsByElement(board, point, hitElement) || point;
|
|
1516
1515
|
const connectorPoint = getHitConnectorPoint(rotatedPoint, hitElement);
|
|
1517
1516
|
const edgePoint = getNearestPoint(hitElement, rotatedPoint);
|
|
1518
1517
|
const isHitEdge = isHitEdgeOfShape(board, hitElement, rotatedPoint, LINE_SNAPPING_BUFFER);
|
|
@@ -1521,14 +1520,14 @@ const getSnappingRef = (board, hitElement, point) => {
|
|
|
1521
1520
|
const getHitShape = (board, point, offset = LINE_HIT_GEOMETRY_BUFFER) => {
|
|
1522
1521
|
let hitShape = null;
|
|
1523
1522
|
traverseDrawShapes(board, (element) => {
|
|
1524
|
-
if (hitShape === null && isInsideOfShape(board, element, rotateAntiPointsByElement(point, element) || point, offset * 2)) {
|
|
1523
|
+
if (hitShape === null && isInsideOfShape(board, element, rotateAntiPointsByElement(board, point, element) || point, offset * 2)) {
|
|
1525
1524
|
hitShape = element;
|
|
1526
1525
|
}
|
|
1527
1526
|
});
|
|
1528
1527
|
return hitShape;
|
|
1529
1528
|
};
|
|
1530
1529
|
const traverseDrawShapes = (board, callback) => {
|
|
1531
|
-
depthFirstRecursion(board, node => {
|
|
1530
|
+
depthFirstRecursion(board, (node) => {
|
|
1532
1531
|
if (!PlaitBoard.isBoard(node) && PlaitDrawElement.isShapeElement(node)) {
|
|
1533
1532
|
callback(node);
|
|
1534
1533
|
}
|
|
@@ -1562,7 +1561,7 @@ const drawBoundReaction = (board, element, roughOptions = { hasMask: true, hasCo
|
|
|
1562
1561
|
}
|
|
1563
1562
|
if (roughOptions.hasConnector) {
|
|
1564
1563
|
const connectorPoints = getEngine(shape).getConnectorPoints(rectangle);
|
|
1565
|
-
connectorPoints.forEach(point => {
|
|
1564
|
+
connectorPoints.forEach((point) => {
|
|
1566
1565
|
const circleG = drawCircle(PlaitBoard.getRoughSVG(board), point, 8, {
|
|
1567
1566
|
stroke: SELECTION_BORDER_COLOR,
|
|
1568
1567
|
strokeWidth: ACTIVE_STROKE_WIDTH,
|
|
@@ -1584,14 +1583,14 @@ const getTextKey = (element, text) => {
|
|
|
1584
1583
|
};
|
|
1585
1584
|
const getGeometryAlign = (board, element) => {
|
|
1586
1585
|
if (isMultipleTextGeometry(element)) {
|
|
1587
|
-
const drawShapeText = element.texts.find(item => item.id.includes(GeometryCommonTextKeys.content));
|
|
1586
|
+
const drawShapeText = element.texts.find((item) => item.id.includes(GeometryCommonTextKeys.content));
|
|
1588
1587
|
return drawShapeText?.text.align || Alignment.center;
|
|
1589
1588
|
}
|
|
1590
1589
|
if (isSingleTextGeometry(element)) {
|
|
1591
1590
|
return element.text?.align || Alignment.center;
|
|
1592
1591
|
}
|
|
1593
1592
|
if (PlaitDrawElement.isElementByTable(element)) {
|
|
1594
|
-
const firstTextCell = element.cells.find(item => item.text);
|
|
1593
|
+
const firstTextCell = element.cells.find((item) => item.text);
|
|
1595
1594
|
return firstTextCell?.text?.align || Alignment.center;
|
|
1596
1595
|
}
|
|
1597
1596
|
return Alignment.center;
|
|
@@ -2156,7 +2155,7 @@ const getHitConnectorPoint = (point, hitElement) => {
|
|
|
2156
2155
|
const rectangle = RectangleClient.getRectangleByPoints(hitElement.points);
|
|
2157
2156
|
const shape = getElementShape(hitElement);
|
|
2158
2157
|
const connectorPoints = getEngine(shape).getConnectorPoints(rectangle);
|
|
2159
|
-
return connectorPoints.find(connectorPoint => {
|
|
2158
|
+
return connectorPoints.find((connectorPoint) => {
|
|
2160
2159
|
return distanceBetweenPointAndPoint(...connectorPoint, ...point) <= LINE_SNAPPING_CONNECTOR_BUFFER;
|
|
2161
2160
|
});
|
|
2162
2161
|
};
|
|
@@ -2213,7 +2212,7 @@ const handleArrowLineCreating = (board, lineShape, sourcePoint, movingPoint, sou
|
|
|
2213
2212
|
const otherPoint = linePoints[0];
|
|
2214
2213
|
temporaryLineElement.points[1] = alignPoints(otherPoint, movingPoint);
|
|
2215
2214
|
lineGenerator.processDrawing(temporaryLineElement, lineShapeG);
|
|
2216
|
-
PlaitBoard.
|
|
2215
|
+
PlaitBoard.getElementTopHost(board).append(lineShapeG);
|
|
2217
2216
|
return temporaryLineElement;
|
|
2218
2217
|
};
|
|
2219
2218
|
function drawArrowLineMask(board, element, id) {
|
|
@@ -2450,11 +2449,12 @@ const createDefaultFlowchart = (point) => {
|
|
|
2450
2449
|
], { marker: ArrowLineMarkerType.none, connection: [0.5, 1], boundId: processElement2.id }, { marker: ArrowLineMarkerType.arrow, connection: [1, 0.5], boundId: endElement.id }, [], lineOptions);
|
|
2451
2450
|
return [startElement, processElement1, decisionElement, processElement2, endElement, line1, line2, line3, line4, line5];
|
|
2452
2451
|
};
|
|
2453
|
-
const getAutoCompletePoints = (element) => {
|
|
2452
|
+
const getAutoCompletePoints = (board, element, isToActive = false) => {
|
|
2454
2453
|
const AutoCompleteMargin = (12 + RESIZE_HANDLE_DIAMETER / 2) * 2;
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2454
|
+
const rectangle = RectangleClient.getRectangleByPoints(element.points);
|
|
2455
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
2456
|
+
const targetRectangle = isToActive ? activeRectangle : rectangle;
|
|
2457
|
+
return RectangleClient.getEdgeCenterPoints(RectangleClient.inflate(targetRectangle, AutoCompleteMargin));
|
|
2458
2458
|
};
|
|
2459
2459
|
const getHitIndexOfAutoCompletePoint = (movingPoint, points) => {
|
|
2460
2460
|
return points.findIndex((point) => {
|
|
@@ -2532,12 +2532,6 @@ const editText = (board, element, text) => {
|
|
|
2532
2532
|
textManage.edit(() => { });
|
|
2533
2533
|
}
|
|
2534
2534
|
};
|
|
2535
|
-
const rerenderGeometryActive = (board, element) => {
|
|
2536
|
-
const elementRef = PlaitElement.getElementRef(element);
|
|
2537
|
-
const activeGenerator = elementRef.getGenerator(ActiveGenerator.key);
|
|
2538
|
-
const selected = getSelectedElements(board).includes(element);
|
|
2539
|
-
activeGenerator.processDrawing(element, PlaitBoard.getElementActiveHost(board), { selected });
|
|
2540
|
-
};
|
|
2541
2535
|
const isGeometryIncludeText = (element) => {
|
|
2542
2536
|
return isSingleTextGeometry(element) || isMultipleTextGeometry(element);
|
|
2543
2537
|
};
|
|
@@ -3393,7 +3387,7 @@ function withDrawResize(board) {
|
|
|
3393
3387
|
const resizeSnapRef = getSnapResizingRef(board, resizeRef.element, resizeSnapRefOptions);
|
|
3394
3388
|
resizeActivePoints = resizeSnapRef.activePoints;
|
|
3395
3389
|
snapG = resizeSnapRef.snapG;
|
|
3396
|
-
PlaitBoard.
|
|
3390
|
+
PlaitBoard.getElementTopHost(board).append(snapG);
|
|
3397
3391
|
if (bulkRotationRef) {
|
|
3398
3392
|
const boundingBoxCornerPoints = RectangleClient.getPoints(resizeRef.rectangle);
|
|
3399
3393
|
const resizedBoundingBoxCornerPoints = boundingBoxCornerPoints.map((p) => {
|
|
@@ -3492,23 +3486,25 @@ function withDrawResize(board) {
|
|
|
3492
3486
|
const boundingRectangle = needCustomActiveRectangle
|
|
3493
3487
|
? RectangleClient.getRectangleByPoints(resizeActivePoints)
|
|
3494
3488
|
: getRectangleByElements(board, elements, false);
|
|
3495
|
-
|
|
3489
|
+
const boundingActiveRectangle = toActiveRectangleFromViewBoxRectangle(board, boundingRectangle);
|
|
3490
|
+
let corners = RectangleClient.getCornerPoints(boundingActiveRectangle);
|
|
3496
3491
|
const angle = getSelectionAngle(elements);
|
|
3497
3492
|
if (angle) {
|
|
3498
|
-
const centerPoint = RectangleClient.getCenterPoint(
|
|
3493
|
+
const centerPoint = RectangleClient.getCenterPoint(boundingActiveRectangle);
|
|
3499
3494
|
corners = rotatePoints(corners, centerPoint, angle);
|
|
3500
3495
|
}
|
|
3501
3496
|
corners.forEach((corner) => {
|
|
3502
3497
|
const g = drawHandle(board, corner);
|
|
3503
3498
|
handleG && handleG.append(g);
|
|
3504
3499
|
});
|
|
3505
|
-
PlaitBoard.
|
|
3500
|
+
PlaitBoard.getActiveHost(board).append(handleG);
|
|
3506
3501
|
}
|
|
3507
3502
|
};
|
|
3508
3503
|
board.drawSelectionRectangle = () => {
|
|
3509
3504
|
if (needCustomActiveRectangle) {
|
|
3510
3505
|
const rectangle = RectangleClient.getRectangleByPoints(resizeActivePoints);
|
|
3511
|
-
|
|
3506
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
3507
|
+
return drawRectangle(board, RectangleClient.inflate(activeRectangle, ACTIVE_STROKE_WIDTH), {
|
|
3512
3508
|
stroke: SELECTION_BORDER_COLOR,
|
|
3513
3509
|
strokeWidth: ACTIVE_STROKE_WIDTH
|
|
3514
3510
|
});
|
|
@@ -5358,19 +5354,57 @@ const InternalStorageEngine = {
|
|
|
5358
5354
|
}
|
|
5359
5355
|
};
|
|
5360
5356
|
|
|
5357
|
+
function generateNoteCurlyLeftPath(rectangle) {
|
|
5358
|
+
const curlyWidth = rectangle.width * 0.09;
|
|
5359
|
+
const rightX = rectangle.x + rectangle.width;
|
|
5360
|
+
const centerY = rectangle.y + rectangle.height / 2;
|
|
5361
|
+
return {
|
|
5362
|
+
startPoint: [rightX, rectangle.y],
|
|
5363
|
+
upperCurve: {
|
|
5364
|
+
controlPoint1: [rightX - curlyWidth, rectangle.y],
|
|
5365
|
+
controlPoint2: [rightX, centerY],
|
|
5366
|
+
endPoint: [rightX - curlyWidth, centerY]
|
|
5367
|
+
},
|
|
5368
|
+
lowerCurve: {
|
|
5369
|
+
controlPoint1: [rightX, centerY],
|
|
5370
|
+
controlPoint2: [rightX - curlyWidth, rectangle.y + rectangle.height],
|
|
5371
|
+
endPoint: [rightX, rectangle.y + rectangle.height]
|
|
5372
|
+
}
|
|
5373
|
+
};
|
|
5374
|
+
}
|
|
5361
5375
|
const NoteCurlyLeftEngine = {
|
|
5362
5376
|
draw(board, rectangle, options) {
|
|
5363
5377
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5364
|
-
const
|
|
5365
|
-
|
|
5366
|
-
${
|
|
5367
|
-
${
|
|
5368
|
-
|
|
5369
|
-
${
|
|
5370
|
-
${
|
|
5378
|
+
const { startPoint, upperCurve, lowerCurve } = generateNoteCurlyLeftPath(rectangle);
|
|
5379
|
+
const pathData = [
|
|
5380
|
+
`M${startPoint[0]} ${startPoint[1]}`,
|
|
5381
|
+
`C${upperCurve.controlPoint1[0]} ${upperCurve.controlPoint1[1]},
|
|
5382
|
+
${upperCurve.controlPoint2[0]} ${upperCurve.controlPoint2[1]},
|
|
5383
|
+
${upperCurve.endPoint[0]} ${upperCurve.endPoint[1]}`,
|
|
5384
|
+
`C${lowerCurve.controlPoint1[0]} ${lowerCurve.controlPoint1[1]},
|
|
5385
|
+
${lowerCurve.controlPoint2[0]} ${lowerCurve.controlPoint2[1]},
|
|
5386
|
+
${lowerCurve.endPoint[0]} ${lowerCurve.endPoint[1]}`
|
|
5387
|
+
].join(' ');
|
|
5388
|
+
const shape = rs.path(pathData, { ...options, fillStyle: 'solid', fill: 'transparent' });
|
|
5371
5389
|
setStrokeLinecap(shape, 'round');
|
|
5372
5390
|
return shape;
|
|
5373
5391
|
},
|
|
5392
|
+
getNearestPoint(rectangle, point) {
|
|
5393
|
+
const { startPoint, upperCurve, lowerCurve } = generateNoteCurlyLeftPath(rectangle);
|
|
5394
|
+
const upperBezierPoints = pointsOnBezierCurves([startPoint, upperCurve.controlPoint1, upperCurve.controlPoint2, upperCurve.endPoint], 0.001);
|
|
5395
|
+
const lowerBezierPoints = pointsOnBezierCurves([upperCurve.endPoint, lowerCurve.controlPoint1, lowerCurve.controlPoint2, lowerCurve.endPoint], 0.001);
|
|
5396
|
+
const allPoints = [...upperBezierPoints, ...lowerBezierPoints];
|
|
5397
|
+
let minDistance = Infinity;
|
|
5398
|
+
let nearestPoint = point;
|
|
5399
|
+
for (const curvePoint of allPoints) {
|
|
5400
|
+
const distance = distanceBetweenPointAndPoint(point[0], point[1], curvePoint[0], curvePoint[1]);
|
|
5401
|
+
if (distance < minDistance) {
|
|
5402
|
+
minDistance = distance;
|
|
5403
|
+
nearestPoint = [...curvePoint];
|
|
5404
|
+
}
|
|
5405
|
+
}
|
|
5406
|
+
return nearestPoint;
|
|
5407
|
+
},
|
|
5374
5408
|
isInsidePoint(rectangle, point) {
|
|
5375
5409
|
const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
|
|
5376
5410
|
return RectangleClient.isHit(rectangle, rangeRectangle);
|
|
@@ -5378,9 +5412,6 @@ const NoteCurlyLeftEngine = {
|
|
|
5378
5412
|
getCornerPoints(rectangle) {
|
|
5379
5413
|
return RectangleClient.getCornerPoints(rectangle);
|
|
5380
5414
|
},
|
|
5381
|
-
getNearestPoint(rectangle, point) {
|
|
5382
|
-
return getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
|
|
5383
|
-
},
|
|
5384
5415
|
getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
|
|
5385
5416
|
const corners = RectangleEngine.getCornerPoints(rectangle);
|
|
5386
5417
|
const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
|
|
@@ -5403,16 +5434,37 @@ const NoteCurlyLeftEngine = {
|
|
|
5403
5434
|
}
|
|
5404
5435
|
};
|
|
5405
5436
|
|
|
5437
|
+
function generateNoteCurlyRightPath(rectangle) {
|
|
5438
|
+
const curlyWidth = rectangle.width * 0.09;
|
|
5439
|
+
const centerY = rectangle.y + rectangle.height / 2;
|
|
5440
|
+
return {
|
|
5441
|
+
startPoint: [rectangle.x, rectangle.y],
|
|
5442
|
+
upperCurve: {
|
|
5443
|
+
controlPoint1: [rectangle.x + curlyWidth, rectangle.y],
|
|
5444
|
+
controlPoint2: [rectangle.x, centerY],
|
|
5445
|
+
endPoint: [rectangle.x + curlyWidth, centerY]
|
|
5446
|
+
},
|
|
5447
|
+
lowerCurve: {
|
|
5448
|
+
controlPoint1: [rectangle.x, centerY],
|
|
5449
|
+
controlPoint2: [rectangle.x + curlyWidth, rectangle.y + rectangle.height],
|
|
5450
|
+
endPoint: [rectangle.x, rectangle.y + rectangle.height]
|
|
5451
|
+
}
|
|
5452
|
+
};
|
|
5453
|
+
}
|
|
5406
5454
|
const NoteCurlyRightEngine = {
|
|
5407
5455
|
draw(board, rectangle, options) {
|
|
5408
5456
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5409
|
-
const
|
|
5410
|
-
|
|
5411
|
-
${
|
|
5412
|
-
${
|
|
5413
|
-
|
|
5414
|
-
${
|
|
5415
|
-
${
|
|
5457
|
+
const { startPoint, upperCurve, lowerCurve } = generateNoteCurlyRightPath(rectangle);
|
|
5458
|
+
const pathData = [
|
|
5459
|
+
`M${startPoint[0]} ${startPoint[1]}`,
|
|
5460
|
+
`C${upperCurve.controlPoint1[0]} ${upperCurve.controlPoint1[1]},
|
|
5461
|
+
${upperCurve.controlPoint2[0]} ${upperCurve.controlPoint2[1]},
|
|
5462
|
+
${upperCurve.endPoint[0]} ${upperCurve.endPoint[1]}`,
|
|
5463
|
+
`C${lowerCurve.controlPoint1[0]} ${lowerCurve.controlPoint1[1]},
|
|
5464
|
+
${lowerCurve.controlPoint2[0]} ${lowerCurve.controlPoint2[1]},
|
|
5465
|
+
${lowerCurve.endPoint[0]} ${lowerCurve.endPoint[1]}`
|
|
5466
|
+
].join(' ');
|
|
5467
|
+
const shape = rs.path(pathData, { ...options, fillStyle: 'solid', fill: 'transparent' });
|
|
5416
5468
|
setStrokeLinecap(shape, 'round');
|
|
5417
5469
|
return shape;
|
|
5418
5470
|
},
|
|
@@ -5424,7 +5476,24 @@ const NoteCurlyRightEngine = {
|
|
|
5424
5476
|
return RectangleClient.getCornerPoints(rectangle);
|
|
5425
5477
|
},
|
|
5426
5478
|
getNearestPoint(rectangle, point) {
|
|
5427
|
-
|
|
5479
|
+
const { startPoint, upperCurve, lowerCurve } = generateNoteCurlyRightPath(rectangle);
|
|
5480
|
+
// 生成上部贝塞尔曲线的点
|
|
5481
|
+
const upperBezierPoints = pointsOnBezierCurves([startPoint, upperCurve.controlPoint1, upperCurve.controlPoint2, upperCurve.endPoint], 0.001);
|
|
5482
|
+
// 生成下部贝塞尔曲线的点
|
|
5483
|
+
const lowerBezierPoints = pointsOnBezierCurves([upperCurve.endPoint, lowerCurve.controlPoint1, lowerCurve.controlPoint2, lowerCurve.endPoint], 0.001);
|
|
5484
|
+
// 合并所有点
|
|
5485
|
+
const allPoints = [...upperBezierPoints, ...lowerBezierPoints];
|
|
5486
|
+
// 找到最近的点
|
|
5487
|
+
let minDistance = Infinity;
|
|
5488
|
+
let nearestPoint = [...point];
|
|
5489
|
+
for (const curvePoint of allPoints) {
|
|
5490
|
+
const distance = distanceBetweenPointAndPoint(point[0], point[1], curvePoint[0], curvePoint[1]);
|
|
5491
|
+
if (distance < minDistance) {
|
|
5492
|
+
minDistance = distance;
|
|
5493
|
+
nearestPoint = [...curvePoint];
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
return nearestPoint;
|
|
5428
5497
|
},
|
|
5429
5498
|
getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
|
|
5430
5499
|
const corners = RectangleEngine.getCornerPoints(rectangle);
|
|
@@ -5656,24 +5725,71 @@ function getHorizontalTextRectangle(cell) {
|
|
|
5656
5725
|
};
|
|
5657
5726
|
}
|
|
5658
5727
|
|
|
5728
|
+
function generateActorPath(rectangle) {
|
|
5729
|
+
const centerX = rectangle.x + rectangle.width / 2;
|
|
5730
|
+
const headRadius = { width: rectangle.width / 3 / 2, height: rectangle.height / 4 / 2 };
|
|
5731
|
+
const centerY = rectangle.y + rectangle.height / 4 / 2;
|
|
5732
|
+
return {
|
|
5733
|
+
headArcCommand: {
|
|
5734
|
+
rx: headRadius.width,
|
|
5735
|
+
ry: headRadius.height,
|
|
5736
|
+
xAxisRotation: 0,
|
|
5737
|
+
largeArcFlag: 0,
|
|
5738
|
+
sweepFlag: 1,
|
|
5739
|
+
endX: centerX,
|
|
5740
|
+
endY: rectangle.y
|
|
5741
|
+
},
|
|
5742
|
+
bodyLine: [
|
|
5743
|
+
[centerX, rectangle.y + rectangle.height / 4],
|
|
5744
|
+
[centerX, rectangle.y + (rectangle.height / 4) * 3]
|
|
5745
|
+
],
|
|
5746
|
+
armsLine: [
|
|
5747
|
+
[rectangle.x, rectangle.y + rectangle.height / 2],
|
|
5748
|
+
[rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
|
|
5749
|
+
],
|
|
5750
|
+
leftLegLine: [
|
|
5751
|
+
[centerX, rectangle.y + (rectangle.height / 4) * 3],
|
|
5752
|
+
[rectangle.x + rectangle.width / 12, rectangle.y + rectangle.height]
|
|
5753
|
+
],
|
|
5754
|
+
rightLegLine: [
|
|
5755
|
+
[centerX, rectangle.y + (rectangle.height / 4) * 3],
|
|
5756
|
+
[rectangle.x + (rectangle.width / 12) * 11, rectangle.y + rectangle.height]
|
|
5757
|
+
]
|
|
5758
|
+
};
|
|
5759
|
+
}
|
|
5659
5760
|
const ActorEngine = {
|
|
5660
5761
|
draw(board, rectangle, options) {
|
|
5661
5762
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5662
|
-
const
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
M${
|
|
5672
|
-
|
|
5673
|
-
|
|
5763
|
+
const { headArcCommand, bodyLine, armsLine, leftLegLine, rightLegLine } = generateActorPath(rectangle);
|
|
5764
|
+
const pathData = [
|
|
5765
|
+
// 头部(从中间开始画)
|
|
5766
|
+
`M${bodyLine[0][0]} ${bodyLine[0][1]}`,
|
|
5767
|
+
`A${headArcCommand.rx} ${headArcCommand.ry} ${headArcCommand.xAxisRotation} ${headArcCommand.largeArcFlag} ${headArcCommand.sweepFlag} ${headArcCommand.endX} ${headArcCommand.endY}`,
|
|
5768
|
+
`A${headArcCommand.rx} ${headArcCommand.ry} ${headArcCommand.xAxisRotation} ${headArcCommand.largeArcFlag} ${headArcCommand.sweepFlag} ${bodyLine[0][0]} ${bodyLine[0][1]}`,
|
|
5769
|
+
// 身体
|
|
5770
|
+
`V${bodyLine[1][1]}`,
|
|
5771
|
+
// 手臂
|
|
5772
|
+
`M${armsLine[0][0]} ${armsLine[0][1]} H${armsLine[1][0]}`,
|
|
5773
|
+
// 腿
|
|
5774
|
+
`M${leftLegLine[0][0]} ${leftLegLine[0][1]} L${leftLegLine[1][0]} ${leftLegLine[1][1]}`,
|
|
5775
|
+
`M${rightLegLine[0][0]} ${rightLegLine[0][1]} L${rightLegLine[1][0]} ${rightLegLine[1][1]}`
|
|
5776
|
+
].join(' ');
|
|
5777
|
+
const shape = rs.path(pathData, { ...options, fillStyle: 'solid' });
|
|
5674
5778
|
setStrokeLinecap(shape, 'round');
|
|
5675
5779
|
return shape;
|
|
5676
5780
|
},
|
|
5781
|
+
getNearestPoint(rectangle, point) {
|
|
5782
|
+
const { headArcCommand, bodyLine, armsLine, leftLegLine, rightLegLine } = generateActorPath(rectangle);
|
|
5783
|
+
// 检查头部椭圆
|
|
5784
|
+
const headCenter = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 4 / 2];
|
|
5785
|
+
const nearestPointForHead = getNearestPointBetweenPointAndEllipse(point, headCenter, headArcCommand.rx, headArcCommand.ry);
|
|
5786
|
+
const distanceForHead = distanceBetweenPointAndPoint(...point, ...nearestPointForHead);
|
|
5787
|
+
// 检查所有线段
|
|
5788
|
+
const allSegments = [bodyLine, armsLine, leftLegLine, rightLegLine];
|
|
5789
|
+
const nearestPointForLines = getNearestPointBetweenPointAndDiscreteSegments(point, allSegments);
|
|
5790
|
+
const distanceForLines = distanceBetweenPointAndPoint(...point, ...nearestPointForLines);
|
|
5791
|
+
return distanceForHead < distanceForLines ? nearestPointForHead : nearestPointForLines;
|
|
5792
|
+
},
|
|
5677
5793
|
isInsidePoint(rectangle, point) {
|
|
5678
5794
|
const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
|
|
5679
5795
|
return RectangleClient.isHit(rectangle, rangeRectangle);
|
|
@@ -5681,35 +5797,6 @@ const ActorEngine = {
|
|
|
5681
5797
|
getCornerPoints(rectangle) {
|
|
5682
5798
|
return RectangleClient.getCornerPoints(rectangle);
|
|
5683
5799
|
},
|
|
5684
|
-
getNearestPoint(rectangle, point) {
|
|
5685
|
-
let nearestPoint = getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
|
|
5686
|
-
if (nearestPoint[1] >= rectangle.y && nearestPoint[1] <= rectangle.y + rectangle.height / 4) {
|
|
5687
|
-
const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 4 / 2];
|
|
5688
|
-
nearestPoint = getNearestPointBetweenPointAndEllipse(point, centerPoint, rectangle.width / 3 / 2, rectangle.height / 4 / 2);
|
|
5689
|
-
return nearestPoint;
|
|
5690
|
-
}
|
|
5691
|
-
if (nearestPoint[1] >= rectangle.y + rectangle.height / 4 && nearestPoint[1] < rectangle.y + (rectangle.height / 4) * 3) {
|
|
5692
|
-
if (nearestPoint[1] === rectangle.x + rectangle.width / 2) {
|
|
5693
|
-
nearestPoint = getNearestPointBetweenPointAndSegments(point, [
|
|
5694
|
-
[rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 4],
|
|
5695
|
-
[rectangle.x + rectangle.width / 2, rectangle.y + (rectangle.height / 4) * 3]
|
|
5696
|
-
]);
|
|
5697
|
-
}
|
|
5698
|
-
else {
|
|
5699
|
-
nearestPoint = getNearestPointBetweenPointAndSegments(point, [
|
|
5700
|
-
[rectangle.x, rectangle.y + rectangle.height / 2],
|
|
5701
|
-
[rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
|
|
5702
|
-
]);
|
|
5703
|
-
}
|
|
5704
|
-
return nearestPoint;
|
|
5705
|
-
}
|
|
5706
|
-
nearestPoint = getNearestPointBetweenPointAndSegments(point, [
|
|
5707
|
-
[rectangle.x + rectangle.width / 12, rectangle.y + rectangle.height],
|
|
5708
|
-
[rectangle.x + rectangle.width / 2, rectangle.y + (rectangle.height / 4) * 3],
|
|
5709
|
-
[rectangle.x + (rectangle.width / 12) * 11, rectangle.y + rectangle.height]
|
|
5710
|
-
]);
|
|
5711
|
-
return nearestPoint;
|
|
5712
|
-
},
|
|
5713
5800
|
getConnectorPoints(rectangle) {
|
|
5714
5801
|
return RectangleClient.getEdgeCenterPoints(rectangle);
|
|
5715
5802
|
},
|
|
@@ -5794,18 +5881,41 @@ const ContainerEngine = {
|
|
|
5794
5881
|
}
|
|
5795
5882
|
};
|
|
5796
5883
|
|
|
5884
|
+
function generatePackagePath(rectangle) {
|
|
5885
|
+
const headerHeight = 25;
|
|
5886
|
+
const topWidth = rectangle.width * 0.7;
|
|
5887
|
+
const cornerX = rectangle.x + rectangle.width * 0.8;
|
|
5888
|
+
return {
|
|
5889
|
+
headerHeight,
|
|
5890
|
+
points: {
|
|
5891
|
+
leftTop: [rectangle.x, rectangle.y + headerHeight],
|
|
5892
|
+
topStart: [rectangle.x, rectangle.y],
|
|
5893
|
+
topEnd: [rectangle.x + topWidth, rectangle.y],
|
|
5894
|
+
cornerPoint: [cornerX, rectangle.y + headerHeight],
|
|
5895
|
+
rightTop: [rectangle.x + rectangle.width, rectangle.y + headerHeight],
|
|
5896
|
+
rightBottom: [rectangle.x + rectangle.width, rectangle.y + rectangle.height],
|
|
5897
|
+
leftBottom: [rectangle.x, rectangle.y + rectangle.height],
|
|
5898
|
+
leftMiddle: [rectangle.x, rectangle.y + headerHeight],
|
|
5899
|
+
middlePoint: [cornerX, rectangle.y + headerHeight]
|
|
5900
|
+
}
|
|
5901
|
+
};
|
|
5902
|
+
}
|
|
5797
5903
|
const PackageEngine = {
|
|
5798
5904
|
draw(board, rectangle, options) {
|
|
5799
5905
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5800
|
-
const
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
H${
|
|
5805
|
-
|
|
5806
|
-
H${
|
|
5807
|
-
V${
|
|
5808
|
-
H${
|
|
5906
|
+
const { points } = generatePackagePath(rectangle);
|
|
5907
|
+
const pathData = [
|
|
5908
|
+
`M${points.leftTop[0]} ${points.leftTop[1]}`,
|
|
5909
|
+
`V${points.topStart[1]}`,
|
|
5910
|
+
`H${points.topEnd[0]}`,
|
|
5911
|
+
`L${points.cornerPoint[0]} ${points.cornerPoint[1]}`,
|
|
5912
|
+
`H${points.rightTop[0]}`,
|
|
5913
|
+
`V${points.rightBottom[1]}`,
|
|
5914
|
+
`H${points.leftBottom[0]}`,
|
|
5915
|
+
`V${points.leftMiddle[1]}`,
|
|
5916
|
+
`H${points.middlePoint[0]}`
|
|
5917
|
+
].join(' ');
|
|
5918
|
+
const shape = rs.path(pathData, { ...options, fillStyle: 'solid' });
|
|
5809
5919
|
setStrokeLinecap(shape, 'round');
|
|
5810
5920
|
return shape;
|
|
5811
5921
|
},
|
|
@@ -5817,15 +5927,23 @@ const PackageEngine = {
|
|
|
5817
5927
|
return RectangleClient.getCornerPoints(rectangle);
|
|
5818
5928
|
},
|
|
5819
5929
|
getNearestPoint(rectangle, point) {
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
],
|
|
5827
|
-
|
|
5828
|
-
|
|
5930
|
+
const { points } = generatePackagePath(rectangle);
|
|
5931
|
+
const segments = [
|
|
5932
|
+
// 左边竖线
|
|
5933
|
+
[points.topStart, points.leftTop],
|
|
5934
|
+
[points.leftTop, points.leftBottom],
|
|
5935
|
+
// 底边
|
|
5936
|
+
[points.leftBottom, points.rightBottom],
|
|
5937
|
+
// 右边竖线
|
|
5938
|
+
[points.rightBottom, points.rightTop],
|
|
5939
|
+
// 顶部折线
|
|
5940
|
+
[points.topStart, points.topEnd],
|
|
5941
|
+
[points.topEnd, points.cornerPoint],
|
|
5942
|
+
[points.cornerPoint, points.rightTop],
|
|
5943
|
+
// 中间横线
|
|
5944
|
+
[points.leftMiddle, points.middlePoint]
|
|
5945
|
+
];
|
|
5946
|
+
return getNearestPointBetweenPointAndDiscreteSegments(point, segments);
|
|
5829
5947
|
},
|
|
5830
5948
|
getConnectorPoints(rectangle) {
|
|
5831
5949
|
return RectangleClient.getEdgeCenterPoints(rectangle);
|
|
@@ -5923,12 +6041,23 @@ const CombinedFragmentEngine = {
|
|
|
5923
6041
|
}
|
|
5924
6042
|
};
|
|
5925
6043
|
|
|
6044
|
+
function getDeletionLines(rectangle) {
|
|
6045
|
+
return [
|
|
6046
|
+
[
|
|
6047
|
+
[rectangle.x, rectangle.y],
|
|
6048
|
+
[rectangle.x + rectangle.width, rectangle.y + rectangle.height]
|
|
6049
|
+
],
|
|
6050
|
+
[
|
|
6051
|
+
[rectangle.x + rectangle.width, rectangle.y],
|
|
6052
|
+
[rectangle.x, rectangle.y + rectangle.height]
|
|
6053
|
+
]
|
|
6054
|
+
];
|
|
6055
|
+
}
|
|
5926
6056
|
const DeletionEngine = {
|
|
5927
6057
|
draw(board, rectangle, options) {
|
|
5928
6058
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5929
|
-
const
|
|
5930
|
-
|
|
5931
|
-
`, { ...options, fillStyle: 'solid', strokeWidth: 4 });
|
|
6059
|
+
const lines = getDeletionLines(rectangle);
|
|
6060
|
+
const shape = rs.path(lines.map(([from, to]) => `M${from[0]} ${from[1]} L${to[0]} ${to[1]}`).join(' '), { ...options, fillStyle: 'solid', strokeWidth: 4 });
|
|
5932
6061
|
setStrokeLinecap(shape, 'round');
|
|
5933
6062
|
return shape;
|
|
5934
6063
|
},
|
|
@@ -5940,7 +6069,18 @@ const DeletionEngine = {
|
|
|
5940
6069
|
return RectangleClient.getCornerPoints(rectangle);
|
|
5941
6070
|
},
|
|
5942
6071
|
getNearestPoint(rectangle, point) {
|
|
5943
|
-
|
|
6072
|
+
const lines = getDeletionLines(rectangle);
|
|
6073
|
+
let minDistance = Infinity;
|
|
6074
|
+
let nearestPoint = point;
|
|
6075
|
+
lines.forEach(line => {
|
|
6076
|
+
const currentPoint = getNearestPointBetweenPointAndSegment(point, line);
|
|
6077
|
+
const distance = distanceBetweenPointAndPoint(point[0], point[1], currentPoint[0], currentPoint[1]);
|
|
6078
|
+
if (distance < minDistance) {
|
|
6079
|
+
minDistance = distance;
|
|
6080
|
+
nearestPoint = currentPoint;
|
|
6081
|
+
}
|
|
6082
|
+
});
|
|
6083
|
+
return nearestPoint;
|
|
5944
6084
|
},
|
|
5945
6085
|
getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
|
|
5946
6086
|
const corners = RectangleEngine.getCornerPoints(rectangle);
|
|
@@ -6048,24 +6188,60 @@ const NoteEngine = {
|
|
|
6048
6188
|
}
|
|
6049
6189
|
};
|
|
6050
6190
|
|
|
6191
|
+
function generateAssemblyPath(rectangle) {
|
|
6192
|
+
const centerY = rectangle.y + rectangle.height / 2;
|
|
6193
|
+
const firstLineEndX = rectangle.x + rectangle.width * 0.3;
|
|
6194
|
+
const circleWidth = rectangle.width * 0.13;
|
|
6195
|
+
const circleHeight = rectangle.height * 0.285;
|
|
6196
|
+
const verticalX = firstLineEndX + circleWidth;
|
|
6197
|
+
const verticalRadius = rectangle.width * 0.233;
|
|
6198
|
+
return {
|
|
6199
|
+
startPoint: [rectangle.x, centerY],
|
|
6200
|
+
line1: [
|
|
6201
|
+
[rectangle.x, centerY],
|
|
6202
|
+
[firstLineEndX, centerY]
|
|
6203
|
+
],
|
|
6204
|
+
circleArcCommand: {
|
|
6205
|
+
rx: circleWidth,
|
|
6206
|
+
ry: circleHeight,
|
|
6207
|
+
xAxisRotation: 0,
|
|
6208
|
+
largeArcFlag: 1,
|
|
6209
|
+
sweepFlag: 1,
|
|
6210
|
+
endX: firstLineEndX,
|
|
6211
|
+
endY: centerY
|
|
6212
|
+
},
|
|
6213
|
+
verticalArcCommand: {
|
|
6214
|
+
rx: verticalRadius,
|
|
6215
|
+
ry: rectangle.height / 2,
|
|
6216
|
+
xAxisRotation: 0,
|
|
6217
|
+
largeArcFlag: 0,
|
|
6218
|
+
sweepFlag: 1,
|
|
6219
|
+
endX: verticalX,
|
|
6220
|
+
endY: rectangle.y + rectangle.height
|
|
6221
|
+
},
|
|
6222
|
+
line2: [
|
|
6223
|
+
[verticalX + verticalRadius, centerY],
|
|
6224
|
+
[rectangle.x + rectangle.width, centerY]
|
|
6225
|
+
]
|
|
6226
|
+
};
|
|
6227
|
+
}
|
|
6051
6228
|
const AssemblyEngine = {
|
|
6052
6229
|
draw(board, rectangle, options) {
|
|
6053
6230
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
6054
|
-
const
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
`, {
|
|
6231
|
+
const { startPoint, line1, circleArcCommand, verticalArcCommand, line2 } = generateAssemblyPath(rectangle);
|
|
6232
|
+
const pathData = [
|
|
6233
|
+
`M${startPoint[0]} ${startPoint[1]}`,
|
|
6234
|
+
`H${line1[1][0]}`,
|
|
6235
|
+
// 画完整的圆形:先画一个半圆,再画另一个半圆
|
|
6236
|
+
`A${circleArcCommand.rx} ${circleArcCommand.ry} ${circleArcCommand.xAxisRotation} ${circleArcCommand.largeArcFlag} ${circleArcCommand.sweepFlag} ${line1[1][0] + circleArcCommand.rx * 2} ${circleArcCommand.endY}`,
|
|
6237
|
+
`A${circleArcCommand.rx} ${circleArcCommand.ry} ${circleArcCommand.xAxisRotation} ${circleArcCommand.largeArcFlag} ${circleArcCommand.sweepFlag} ${circleArcCommand.endX} ${circleArcCommand.endY}`,
|
|
6238
|
+
// 垂直椭圆
|
|
6239
|
+
`M${verticalArcCommand.endX} ${rectangle.y}`,
|
|
6240
|
+
`A${verticalArcCommand.rx} ${verticalArcCommand.ry} ${verticalArcCommand.xAxisRotation} ${verticalArcCommand.largeArcFlag} ${verticalArcCommand.sweepFlag} ${verticalArcCommand.endX} ${verticalArcCommand.endY}`,
|
|
6241
|
+
// 最后一条线
|
|
6242
|
+
`M${line2[0][0]} ${line2[0][1]} H${line2[1][0]}`
|
|
6243
|
+
].join(' ');
|
|
6244
|
+
const shape = rs.path(pathData, {
|
|
6069
6245
|
...options,
|
|
6070
6246
|
fillStyle: 'solid'
|
|
6071
6247
|
});
|
|
@@ -6083,11 +6259,25 @@ const AssemblyEngine = {
|
|
|
6083
6259
|
return RectangleClient.getEdgeCenterPoints(rectangle);
|
|
6084
6260
|
},
|
|
6085
6261
|
getNearestPoint(rectangle, point) {
|
|
6086
|
-
const
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6262
|
+
const { line1, line2, circleArcCommand, verticalArcCommand } = generateAssemblyPath(rectangle);
|
|
6263
|
+
// 检查直线段
|
|
6264
|
+
const nearestPointForLines = getNearestPointBetweenPointAndSegments(point, [...line1, ...line2]);
|
|
6265
|
+
const distanceForLines = distanceBetweenPointAndPoint(...point, ...nearestPointForLines);
|
|
6266
|
+
// 检查中间圆形
|
|
6267
|
+
const circleCenter = [line1[1][0] + circleArcCommand.rx, line1[1][1]];
|
|
6268
|
+
const nearestPointForCircle = getNearestPointBetweenPointAndEllipse(point, circleCenter, circleArcCommand.rx, circleArcCommand.ry);
|
|
6269
|
+
const distanceForCircle = distanceBetweenPointAndPoint(...point, ...nearestPointForCircle);
|
|
6270
|
+
// 检查垂直椭圆(使用 getNearestPointBetweenPointAndArc 处理半圆弧)
|
|
6271
|
+
const arcStartPoint = [verticalArcCommand.endX, rectangle.y];
|
|
6272
|
+
const nearestPointForEllipse = getNearestPointBetweenPointAndArc(point, arcStartPoint, verticalArcCommand);
|
|
6273
|
+
const distanceForEllipse = distanceBetweenPointAndPoint(...point, ...nearestPointForEllipse);
|
|
6274
|
+
// 返回最近的点
|
|
6275
|
+
const minDistance = Math.min(distanceForLines, distanceForCircle, distanceForEllipse);
|
|
6276
|
+
if (minDistance === distanceForLines)
|
|
6277
|
+
return nearestPointForLines;
|
|
6278
|
+
if (minDistance === distanceForCircle)
|
|
6279
|
+
return nearestPointForCircle;
|
|
6280
|
+
return nearestPointForEllipse;
|
|
6091
6281
|
},
|
|
6092
6282
|
getTangentVectorByConnectionPoint(rectangle, pointOfRectangle) {
|
|
6093
6283
|
const connectionPoint = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
|
|
@@ -6101,13 +6291,38 @@ const AssemblyEngine = {
|
|
|
6101
6291
|
}
|
|
6102
6292
|
};
|
|
6103
6293
|
|
|
6294
|
+
function generateRequiredInterfacePath(rectangle) {
|
|
6295
|
+
const arcWidth = rectangle.width * 0.39;
|
|
6296
|
+
const arcHeight = rectangle.height / 2;
|
|
6297
|
+
return {
|
|
6298
|
+
startPoint: [rectangle.x, rectangle.y],
|
|
6299
|
+
leftArcCommand: {
|
|
6300
|
+
rx: arcWidth,
|
|
6301
|
+
ry: arcHeight,
|
|
6302
|
+
xAxisRotation: 0,
|
|
6303
|
+
largeArcFlag: 0,
|
|
6304
|
+
sweepFlag: 1,
|
|
6305
|
+
endX: rectangle.x,
|
|
6306
|
+
endY: rectangle.y + rectangle.height
|
|
6307
|
+
},
|
|
6308
|
+
line: {
|
|
6309
|
+
startX: rectangle.x + rectangle.width * 0.41,
|
|
6310
|
+
startY: rectangle.y + rectangle.height / 2,
|
|
6311
|
+
endX: rectangle.x + rectangle.width,
|
|
6312
|
+
endY: rectangle.y + rectangle.height / 2
|
|
6313
|
+
}
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6104
6316
|
const RequiredInterfaceEngine = {
|
|
6105
6317
|
draw(board, rectangle, options) {
|
|
6106
6318
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
6107
|
-
const
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6319
|
+
const { startPoint, leftArcCommand, line } = generateRequiredInterfacePath(rectangle);
|
|
6320
|
+
const pathData = [
|
|
6321
|
+
`M${startPoint[0]} ${startPoint[1]}`,
|
|
6322
|
+
`A${leftArcCommand.rx} ${leftArcCommand.ry} ${leftArcCommand.xAxisRotation} ${leftArcCommand.largeArcFlag} ${leftArcCommand.sweepFlag} ${leftArcCommand.endX} ${leftArcCommand.endY}`,
|
|
6323
|
+
`M${line.startX} ${line.startY} H${line.endX}`
|
|
6324
|
+
].join(' ');
|
|
6325
|
+
const shape = rs.path(pathData, {
|
|
6111
6326
|
...options,
|
|
6112
6327
|
fillStyle: 'solid',
|
|
6113
6328
|
fill: 'transparent'
|
|
@@ -6123,7 +6338,26 @@ const RequiredInterfaceEngine = {
|
|
|
6123
6338
|
return RectangleClient.getCornerPoints(rectangle);
|
|
6124
6339
|
},
|
|
6125
6340
|
getNearestPoint(rectangle, point) {
|
|
6126
|
-
|
|
6341
|
+
const { startPoint, leftArcCommand, line } = generateRequiredInterfacePath(rectangle);
|
|
6342
|
+
let minDistance = Infinity;
|
|
6343
|
+
let nearestPoint = point;
|
|
6344
|
+
// 检查圆弧段
|
|
6345
|
+
const arcNearestPoint = getNearestPointBetweenPointAndArc(point, startPoint, leftArcCommand);
|
|
6346
|
+
const arcDistance = distanceBetweenPointAndPoint(point[0], point[1], arcNearestPoint[0], arcNearestPoint[1]);
|
|
6347
|
+
if (arcDistance < minDistance) {
|
|
6348
|
+
minDistance = arcDistance;
|
|
6349
|
+
nearestPoint = arcNearestPoint;
|
|
6350
|
+
}
|
|
6351
|
+
// 检查直线段
|
|
6352
|
+
const lineStart = [line.startX, line.startY];
|
|
6353
|
+
const lineEnd = [line.endX, line.endY];
|
|
6354
|
+
const lineNearestPoint = getNearestPointBetweenPointAndSegment(point, [lineStart, lineEnd]);
|
|
6355
|
+
const lineDistance = distanceBetweenPointAndPoint(point[0], point[1], lineNearestPoint[0], lineNearestPoint[1]);
|
|
6356
|
+
if (lineDistance < minDistance) {
|
|
6357
|
+
minDistance = lineDistance;
|
|
6358
|
+
nearestPoint = lineNearestPoint;
|
|
6359
|
+
}
|
|
6360
|
+
return nearestPoint;
|
|
6127
6361
|
},
|
|
6128
6362
|
getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
|
|
6129
6363
|
const corners = RectangleEngine.getCornerPoints(rectangle);
|
|
@@ -6136,25 +6370,52 @@ const RequiredInterfaceEngine = {
|
|
|
6136
6370
|
};
|
|
6137
6371
|
|
|
6138
6372
|
const percentage = 0.54;
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
const
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6373
|
+
function generateProvidedInterfacePath(rectangle) {
|
|
6374
|
+
const centerY = rectangle.y + rectangle.height / 2;
|
|
6375
|
+
const rx = (rectangle.width * (1 - percentage)) / 2;
|
|
6376
|
+
const ry = rectangle.height / 2;
|
|
6377
|
+
const startPoint = [rectangle.x, centerY];
|
|
6378
|
+
const lineEndX = rectangle.x + rectangle.width * percentage;
|
|
6379
|
+
return {
|
|
6380
|
+
startPoint,
|
|
6381
|
+
line: {
|
|
6382
|
+
startX: startPoint[0],
|
|
6383
|
+
startY: centerY,
|
|
6384
|
+
endX: lineEndX,
|
|
6385
|
+
endY: centerY
|
|
6386
|
+
},
|
|
6387
|
+
arcCommands: [
|
|
6388
|
+
{
|
|
6389
|
+
rx,
|
|
6390
|
+
ry,
|
|
6391
|
+
xAxisRotation: 0,
|
|
6392
|
+
largeArcFlag: 1,
|
|
6393
|
+
sweepFlag: 1,
|
|
6394
|
+
endX: rectangle.x + rectangle.width,
|
|
6395
|
+
endY: centerY
|
|
6396
|
+
},
|
|
6397
|
+
{
|
|
6398
|
+
rx,
|
|
6399
|
+
ry,
|
|
6400
|
+
xAxisRotation: 0,
|
|
6401
|
+
largeArcFlag: 1,
|
|
6402
|
+
sweepFlag: 1,
|
|
6403
|
+
endX: lineEndX,
|
|
6404
|
+
endY: centerY
|
|
6405
|
+
}
|
|
6406
|
+
]
|
|
6407
|
+
};
|
|
6408
|
+
}
|
|
6149
6409
|
const ProvidedInterfaceEngine = {
|
|
6150
6410
|
draw(board, rectangle, options) {
|
|
6151
6411
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
6152
|
-
const startPoint =
|
|
6153
|
-
const
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6412
|
+
const { startPoint, line, arcCommands } = generateProvidedInterfacePath(rectangle);
|
|
6413
|
+
const pathData = [
|
|
6414
|
+
`M${startPoint[0]} ${startPoint[1]}`,
|
|
6415
|
+
`H${line.endX}`,
|
|
6416
|
+
...arcCommands.map((command) => `A${command.rx} ${command.ry} ${command.xAxisRotation} ${command.largeArcFlag} ${command.sweepFlag} ${command.endX} ${command.endY}`)
|
|
6417
|
+
].join(' ');
|
|
6418
|
+
const shape = rs.path(pathData, {
|
|
6158
6419
|
...options,
|
|
6159
6420
|
fillStyle: 'solid'
|
|
6160
6421
|
});
|
|
@@ -6172,17 +6433,17 @@ const ProvidedInterfaceEngine = {
|
|
|
6172
6433
|
return RectangleClient.getEdgeCenterPoints(rectangle);
|
|
6173
6434
|
},
|
|
6174
6435
|
getNearestPoint(rectangle, point) {
|
|
6175
|
-
const startPoint =
|
|
6176
|
-
|
|
6177
|
-
const
|
|
6436
|
+
const { startPoint, line, arcCommands } = generateProvidedInterfacePath(rectangle);
|
|
6437
|
+
// 检查直线段
|
|
6438
|
+
const lineStart = [line.startX, line.startY];
|
|
6439
|
+
const lineEnd = [line.endX, line.endY];
|
|
6440
|
+
const nearestPointForLine = getNearestPointBetweenPointAndSegments(point, [lineStart, lineEnd]);
|
|
6178
6441
|
const distanceForLine = distanceBetweenPointAndPoint(...point, ...nearestPointForLine);
|
|
6179
|
-
|
|
6180
|
-
const
|
|
6442
|
+
// 检查圆弧段
|
|
6443
|
+
const arcCenter = [rectangle.x + (3 * rectangle.width) / 4, line.startY];
|
|
6444
|
+
const nearestPointForEllipse = getNearestPointBetweenPointAndEllipse(point, arcCenter, arcCommands[0].rx, arcCommands[0].ry);
|
|
6181
6445
|
const distanceForEllipse = distanceBetweenPointAndPoint(...point, ...nearestPointForEllipse);
|
|
6182
|
-
|
|
6183
|
-
return nearestPointForLine;
|
|
6184
|
-
}
|
|
6185
|
-
return nearestPointForEllipse;
|
|
6446
|
+
return distanceForLine < distanceForEllipse ? nearestPointForLine : nearestPointForEllipse;
|
|
6186
6447
|
},
|
|
6187
6448
|
getTangentVectorByConnectionPoint(rectangle, pointOfRectangle) {
|
|
6188
6449
|
const connectionPoint = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
|
|
@@ -6198,30 +6459,84 @@ const ProvidedInterfaceEngine = {
|
|
|
6198
6459
|
}
|
|
6199
6460
|
};
|
|
6200
6461
|
|
|
6462
|
+
function generateComponentPath(rectangle) {
|
|
6463
|
+
const mainLineX = rectangle.x + 12;
|
|
6464
|
+
const boxWidth = rectangle.width > 70 ? 24 : rectangle.width * 0.2;
|
|
6465
|
+
const boxHeight = rectangle.height - 28 - rectangle.height * 0.35 > 1 ? 14 : rectangle.height * 0.175;
|
|
6466
|
+
const topBoxY = rectangle.y + rectangle.height * 0.175;
|
|
6467
|
+
const bottomBoxY = rectangle.y + rectangle.height - rectangle.height * 0.175 - boxHeight;
|
|
6468
|
+
return {
|
|
6469
|
+
boxSize: {
|
|
6470
|
+
width: boxWidth,
|
|
6471
|
+
height: boxHeight
|
|
6472
|
+
},
|
|
6473
|
+
points: {
|
|
6474
|
+
mainStart: [mainLineX, rectangle.y],
|
|
6475
|
+
topBoxStart: [mainLineX, topBoxY],
|
|
6476
|
+
topBoxEnd: [mainLineX, topBoxY + boxHeight],
|
|
6477
|
+
bottomBoxStart: [mainLineX, bottomBoxY],
|
|
6478
|
+
bottomBoxEnd: [mainLineX, bottomBoxY + boxHeight],
|
|
6479
|
+
mainEnd: [mainLineX, rectangle.y + rectangle.height],
|
|
6480
|
+
rightTop: [rectangle.x + rectangle.width, rectangle.y],
|
|
6481
|
+
rightBottom: [rectangle.x + rectangle.width, rectangle.y + rectangle.height]
|
|
6482
|
+
}
|
|
6483
|
+
};
|
|
6484
|
+
}
|
|
6201
6485
|
const ComponentEngine = {
|
|
6202
6486
|
draw(board, rectangle, options) {
|
|
6203
6487
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
6204
|
-
const boxSize =
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
M${
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6488
|
+
const { boxSize, points } = generateComponentPath(rectangle);
|
|
6489
|
+
const pathData = [
|
|
6490
|
+
// 主矩形轮廓
|
|
6491
|
+
`M${points.mainStart[0]} ${points.mainStart[1]}`,
|
|
6492
|
+
`H${points.rightTop[0]}`,
|
|
6493
|
+
`V${points.rightBottom[1]}`,
|
|
6494
|
+
`H${points.mainEnd[0]}`,
|
|
6495
|
+
// 上方小矩形
|
|
6496
|
+
`M${points.topBoxStart[0]} ${points.topBoxStart[1]}`,
|
|
6497
|
+
`h${boxSize.width / 2} v${boxSize.height} h${-boxSize.width} v${-boxSize.height} h${boxSize.width / 2}`,
|
|
6498
|
+
// 下方小矩形
|
|
6499
|
+
`M${points.bottomBoxStart[0]} ${points.bottomBoxStart[1]}`,
|
|
6500
|
+
`h${boxSize.width / 2} v${boxSize.height} h${-boxSize.width} v${-boxSize.height} h${boxSize.width / 2}`,
|
|
6501
|
+
// 连接线
|
|
6502
|
+
`M${points.mainStart[0]} ${points.mainStart[1]}`,
|
|
6503
|
+
`V${points.topBoxStart[1]}`,
|
|
6504
|
+
`M${points.topBoxEnd[0]} ${points.topBoxEnd[1]}`,
|
|
6505
|
+
`V${points.bottomBoxStart[1]}`,
|
|
6506
|
+
`M${points.bottomBoxEnd[0]} ${points.bottomBoxEnd[1]}`,
|
|
6507
|
+
`V${points.mainEnd[1]}`
|
|
6508
|
+
].join(' ');
|
|
6509
|
+
const shape = rs.path(pathData, { ...options, fillStyle: 'solid' });
|
|
6222
6510
|
setStrokeLinecap(shape, 'round');
|
|
6223
6511
|
return shape;
|
|
6224
6512
|
},
|
|
6513
|
+
getNearestPoint(rectangle, point) {
|
|
6514
|
+
const { boxSize, points } = generateComponentPath(rectangle);
|
|
6515
|
+
const segments = [
|
|
6516
|
+
// 主矩形轮廓
|
|
6517
|
+
[points.mainStart, [points.rightTop[0], points.mainStart[1]]],
|
|
6518
|
+
[[points.rightTop[0], points.mainStart[1]], points.rightBottom],
|
|
6519
|
+
[points.rightBottom, [points.mainEnd[0], points.rightBottom[1]]],
|
|
6520
|
+
[[points.mainEnd[0], points.rightBottom[1]], points.mainStart],
|
|
6521
|
+
// 上方小矩形
|
|
6522
|
+
[points.topBoxStart, [points.topBoxStart[0] + boxSize.width / 2, points.topBoxStart[1]]],
|
|
6523
|
+
[[points.topBoxStart[0] + boxSize.width / 2, points.topBoxStart[1]], [points.topBoxStart[0] + boxSize.width / 2, points.topBoxEnd[1]]],
|
|
6524
|
+
[[points.topBoxStart[0] + boxSize.width / 2, points.topBoxEnd[1]], [points.topBoxStart[0] - boxSize.width / 2, points.topBoxEnd[1]]],
|
|
6525
|
+
[[points.topBoxStart[0] - boxSize.width / 2, points.topBoxEnd[1]], [points.topBoxStart[0] - boxSize.width / 2, points.topBoxStart[1]]],
|
|
6526
|
+
[[points.topBoxStart[0] - boxSize.width / 2, points.topBoxStart[1]], points.topBoxStart],
|
|
6527
|
+
// 下方小矩形
|
|
6528
|
+
[points.bottomBoxStart, [points.bottomBoxStart[0] + boxSize.width / 2, points.bottomBoxStart[1]]],
|
|
6529
|
+
[[points.bottomBoxStart[0] + boxSize.width / 2, points.bottomBoxStart[1]], [points.bottomBoxStart[0] + boxSize.width / 2, points.bottomBoxEnd[1]]],
|
|
6530
|
+
[[points.bottomBoxStart[0] + boxSize.width / 2, points.bottomBoxEnd[1]], [points.bottomBoxStart[0] - boxSize.width / 2, points.bottomBoxEnd[1]]],
|
|
6531
|
+
[[points.bottomBoxStart[0] - boxSize.width / 2, points.bottomBoxEnd[1]], [points.bottomBoxStart[0] - boxSize.width / 2, points.bottomBoxStart[1]]],
|
|
6532
|
+
[[points.bottomBoxStart[0] - boxSize.width / 2, points.bottomBoxStart[1]], points.bottomBoxStart],
|
|
6533
|
+
// 连接线
|
|
6534
|
+
[points.mainStart, points.topBoxStart],
|
|
6535
|
+
[points.topBoxEnd, points.bottomBoxStart],
|
|
6536
|
+
[points.bottomBoxEnd, points.mainEnd]
|
|
6537
|
+
];
|
|
6538
|
+
return getNearestPointBetweenPointAndDiscreteSegments(point, segments);
|
|
6539
|
+
},
|
|
6225
6540
|
isInsidePoint(rectangle, point) {
|
|
6226
6541
|
const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
|
|
6227
6542
|
return RectangleClient.isHit(rectangle, rangeRectangle);
|
|
@@ -6229,26 +6544,18 @@ const ComponentEngine = {
|
|
|
6229
6544
|
getCornerPoints(rectangle) {
|
|
6230
6545
|
return RectangleClient.getCornerPoints(rectangle);
|
|
6231
6546
|
},
|
|
6232
|
-
getNearestPoint(rectangle, point) {
|
|
6233
|
-
let nearestPoint = getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
|
|
6234
|
-
if (nearestPoint[1] === rectangle.y + rectangle.height / 2) {
|
|
6235
|
-
nearestPoint = getNearestPointBetweenPointAndSegments(point, [
|
|
6236
|
-
[rectangle.x + 12, rectangle.y + rectangle.height * 0.175 + 14],
|
|
6237
|
-
[rectangle.x + 12, rectangle.y + rectangle.height - rectangle.height * 0.175 - 14]
|
|
6238
|
-
], false);
|
|
6239
|
-
}
|
|
6240
|
-
return nearestPoint;
|
|
6241
|
-
},
|
|
6242
6547
|
getTangentVectorByConnectionPoint(rectangle, pointOfRectangle) {
|
|
6548
|
+
const { points } = generateComponentPath(rectangle);
|
|
6243
6549
|
const connectionPoint = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
|
|
6244
|
-
return getUnitVectorByPointAndPoint(
|
|
6550
|
+
return getUnitVectorByPointAndPoint(points.mainStart, connectionPoint);
|
|
6245
6551
|
},
|
|
6246
6552
|
getConnectorPoints(rectangle) {
|
|
6553
|
+
const { points } = generateComponentPath(rectangle);
|
|
6247
6554
|
return [
|
|
6248
6555
|
[rectangle.x + rectangle.width / 2, rectangle.y],
|
|
6249
6556
|
[rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
|
|
6250
6557
|
[rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height],
|
|
6251
|
-
[
|
|
6558
|
+
[points.mainStart[0], rectangle.y + rectangle.height / 2]
|
|
6252
6559
|
];
|
|
6253
6560
|
},
|
|
6254
6561
|
getTextRectangle(element) {
|
|
@@ -6784,7 +7091,7 @@ class GeometryShapeGenerator extends Generator {
|
|
|
6784
7091
|
class ArrowLineAutoCompleteGenerator extends Generator {
|
|
6785
7092
|
static { this.key = 'line-auto-complete-generator'; }
|
|
6786
7093
|
constructor(board) {
|
|
6787
|
-
super(board);
|
|
7094
|
+
super(board, { active: true });
|
|
6788
7095
|
this.board = board;
|
|
6789
7096
|
this.hoverElement = null;
|
|
6790
7097
|
}
|
|
@@ -6799,7 +7106,7 @@ class ArrowLineAutoCompleteGenerator extends Generator {
|
|
|
6799
7106
|
}
|
|
6800
7107
|
draw(element, data) {
|
|
6801
7108
|
this.autoCompleteG = createG();
|
|
6802
|
-
const middlePoints = getAutoCompletePoints(element);
|
|
7109
|
+
const middlePoints = getAutoCompletePoints(this.board, element, true);
|
|
6803
7110
|
middlePoints.forEach((point, index) => {
|
|
6804
7111
|
const circle = drawCircle(PlaitBoard.getRoughSVG(this.board), point, LINE_AUTO_COMPLETE_DIAMETER, {
|
|
6805
7112
|
stroke: 'none',
|
|
@@ -6842,7 +7149,7 @@ class GeometryComponent extends CommonElementFlavour {
|
|
|
6842
7149
|
super();
|
|
6843
7150
|
}
|
|
6844
7151
|
initializeGenerator() {
|
|
6845
|
-
this.activeGenerator =
|
|
7152
|
+
this.activeGenerator = createActiveGenerator(this.board, {
|
|
6846
7153
|
getStrokeWidth: () => {
|
|
6847
7154
|
const selectedElements = getSelectedElements(this.board);
|
|
6848
7155
|
if (selectedElements.length === 1 && !isSelectionMoving(this.board)) {
|
|
@@ -6875,15 +7182,23 @@ class GeometryComponent extends CommonElementFlavour {
|
|
|
6875
7182
|
}
|
|
6876
7183
|
this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
|
|
6877
7184
|
this.getRef().addGenerator(ActiveGenerator.key, this.activeGenerator);
|
|
7185
|
+
this.getRef().updateActiveSection = () => {
|
|
7186
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7187
|
+
selected: this.selected
|
|
7188
|
+
});
|
|
7189
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7190
|
+
selected: this.selected
|
|
7191
|
+
});
|
|
7192
|
+
};
|
|
6878
7193
|
}
|
|
6879
7194
|
initialize() {
|
|
6880
7195
|
super.initialize();
|
|
6881
7196
|
this.initializeGenerator();
|
|
6882
7197
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
6883
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7198
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
6884
7199
|
selected: this.selected
|
|
6885
7200
|
});
|
|
6886
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
7201
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getElementTopHost(this.board), {
|
|
6887
7202
|
selected: this.selected
|
|
6888
7203
|
});
|
|
6889
7204
|
this.textGenerator && this.textGenerator.draw(this.getElementG());
|
|
@@ -6891,8 +7206,8 @@ class GeometryComponent extends CommonElementFlavour {
|
|
|
6891
7206
|
onContextChanged(value, previous) {
|
|
6892
7207
|
if (value.element !== previous.element || value.hasThemeChanged) {
|
|
6893
7208
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
6894
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
6895
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
7209
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), { selected: this.selected });
|
|
7210
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
6896
7211
|
selected: this.selected
|
|
6897
7212
|
});
|
|
6898
7213
|
this.textGenerator && this.updateText(previous.element, value.element);
|
|
@@ -6900,9 +7215,11 @@ class GeometryComponent extends CommonElementFlavour {
|
|
|
6900
7215
|
else {
|
|
6901
7216
|
const hasSameSelected = value.selected === previous.selected;
|
|
6902
7217
|
const hasSameHandleState = this.activeGenerator.options.hasResizeHandle() === this.activeGenerator.hasResizeHandle;
|
|
6903
|
-
if (!hasSameSelected || !hasSameHandleState) {
|
|
6904
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
6905
|
-
|
|
7218
|
+
if (!hasSameSelected || !hasSameHandleState || value.selected) {
|
|
7219
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7220
|
+
selected: this.selected
|
|
7221
|
+
});
|
|
7222
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
6906
7223
|
selected: this.selected
|
|
6907
7224
|
});
|
|
6908
7225
|
}
|
|
@@ -7011,8 +7328,9 @@ function getHitPointIndex(points, movingPoint) {
|
|
|
7011
7328
|
}
|
|
7012
7329
|
|
|
7013
7330
|
class LineActiveGenerator extends Generator {
|
|
7014
|
-
constructor() {
|
|
7015
|
-
super(
|
|
7331
|
+
constructor(board, options = { active: true }) {
|
|
7332
|
+
super(board, options);
|
|
7333
|
+
this.board = board;
|
|
7016
7334
|
this.onlySelectedCurrentLine = false;
|
|
7017
7335
|
}
|
|
7018
7336
|
canDraw(element, data) {
|
|
@@ -7036,16 +7354,18 @@ class LineActiveGenerator extends Generator {
|
|
|
7036
7354
|
updatePoints = points.slice(0, 1).concat(points.slice(-1));
|
|
7037
7355
|
elbowNextRenderPoints = getNextRenderPoints(this.board, element, data.linePoints);
|
|
7038
7356
|
}
|
|
7039
|
-
updatePoints.
|
|
7357
|
+
const activePoints = updatePoints.map((point) => toActivePointFromViewBoxPoint(this.board, point));
|
|
7358
|
+
activePoints.forEach((point) => {
|
|
7040
7359
|
const updateHandle = drawPrimaryHandle(this.board, point);
|
|
7041
7360
|
activeG.appendChild(updateHandle);
|
|
7042
7361
|
});
|
|
7043
7362
|
const middlePoints = getMiddlePoints(this.board, element);
|
|
7363
|
+
const activeMiddlePoints = middlePoints.map((point) => toActivePointFromViewBoxPoint(this.board, point));
|
|
7044
7364
|
if (!PlaitBoard.hasBeenTextEditing(this.board)) {
|
|
7045
|
-
for (let i = 0; i <
|
|
7046
|
-
const point =
|
|
7365
|
+
for (let i = 0; i < activeMiddlePoints.length; i++) {
|
|
7366
|
+
const point = activeMiddlePoints[i];
|
|
7047
7367
|
if (element.shape === ArrowLineShape.elbow && elbowNextRenderPoints.length) {
|
|
7048
|
-
const handleIndex = getHitPointIndex(
|
|
7368
|
+
const handleIndex = getHitPointIndex(activeMiddlePoints, point);
|
|
7049
7369
|
const isUpdateHandleIndex = isUpdatedHandleIndex(this.board, element, [...points], elbowNextRenderPoints, handleIndex);
|
|
7050
7370
|
if (isUpdateHandleIndex) {
|
|
7051
7371
|
const updateHandle = drawPrimaryHandle(this.board, point);
|
|
@@ -7059,8 +7379,9 @@ class LineActiveGenerator extends Generator {
|
|
|
7059
7379
|
}
|
|
7060
7380
|
}
|
|
7061
7381
|
else {
|
|
7062
|
-
const
|
|
7063
|
-
if (
|
|
7382
|
+
const rectangle = this.board.getRectangle(element);
|
|
7383
|
+
if (rectangle) {
|
|
7384
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(this.board, rectangle);
|
|
7064
7385
|
let opacity = '0.5';
|
|
7065
7386
|
if (activeRectangle.height === 0 || activeRectangle.width === 0) {
|
|
7066
7387
|
opacity = '0.8';
|
|
@@ -7098,13 +7419,20 @@ class ArrowLineComponent extends CommonElementFlavour {
|
|
|
7098
7419
|
this.initializeGenerator();
|
|
7099
7420
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
7100
7421
|
const linePoints = getArrowLinePoints(this.board, this.element);
|
|
7101
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7422
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7102
7423
|
selected: this.selected,
|
|
7103
7424
|
linePoints
|
|
7104
7425
|
});
|
|
7105
7426
|
super.initialize();
|
|
7106
7427
|
this.boundedElements = this.getBoundedElements();
|
|
7107
7428
|
this.drawText();
|
|
7429
|
+
this.getRef().updateActiveSection = () => {
|
|
7430
|
+
const linePoints = getArrowLinePoints(this.board, this.element);
|
|
7431
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7432
|
+
selected: this.selected,
|
|
7433
|
+
linePoints
|
|
7434
|
+
});
|
|
7435
|
+
};
|
|
7108
7436
|
debugGenerator.isDebug() && debugGenerator.drawCircles(this.board, this.element.points.slice(1, -1), 4, true);
|
|
7109
7437
|
}
|
|
7110
7438
|
getBoundedElements() {
|
|
@@ -7130,7 +7458,7 @@ class ArrowLineComponent extends CommonElementFlavour {
|
|
|
7130
7458
|
const linePoints = getArrowLinePoints(this.board, this.element);
|
|
7131
7459
|
if (value.element !== previous.element || value.hasThemeChanged) {
|
|
7132
7460
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
7133
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7461
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7134
7462
|
selected: this.selected,
|
|
7135
7463
|
linePoints
|
|
7136
7464
|
});
|
|
@@ -7139,8 +7467,8 @@ class ArrowLineComponent extends CommonElementFlavour {
|
|
|
7139
7467
|
}
|
|
7140
7468
|
else {
|
|
7141
7469
|
const needUpdate = value.selected !== previous.selected || this.activeGenerator.needUpdate();
|
|
7142
|
-
if (needUpdate) {
|
|
7143
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7470
|
+
if (needUpdate || value.selected) {
|
|
7471
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7144
7472
|
selected: this.selected,
|
|
7145
7473
|
linePoints
|
|
7146
7474
|
});
|
|
@@ -7148,7 +7476,7 @@ class ArrowLineComponent extends CommonElementFlavour {
|
|
|
7148
7476
|
}
|
|
7149
7477
|
if (isBoundedElementsChanged) {
|
|
7150
7478
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
7151
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7479
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7152
7480
|
selected: this.selected,
|
|
7153
7481
|
linePoints
|
|
7154
7482
|
});
|
|
@@ -7220,7 +7548,7 @@ class ArrowLineComponent extends CommonElementFlavour {
|
|
|
7220
7548
|
}
|
|
7221
7549
|
updateTextRectangle() {
|
|
7222
7550
|
const textManages = this.getRef().getTextManages();
|
|
7223
|
-
textManages.forEach(manage => {
|
|
7551
|
+
textManages.forEach((manage) => {
|
|
7224
7552
|
manage.updateRectangle();
|
|
7225
7553
|
});
|
|
7226
7554
|
}
|
|
@@ -7238,12 +7566,19 @@ class VectorLineComponent extends CommonElementFlavour {
|
|
|
7238
7566
|
initializeGenerator() {
|
|
7239
7567
|
this.shapeGenerator = new VectorLineShapeGenerator(this.board);
|
|
7240
7568
|
this.activeGenerator = new LineActiveGenerator(this.board);
|
|
7569
|
+
this.getRef().updateActiveSection = () => {
|
|
7570
|
+
const linePoints = getVectorLinePoints(this.board, this.element);
|
|
7571
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7572
|
+
selected: this.selected,
|
|
7573
|
+
linePoints
|
|
7574
|
+
});
|
|
7575
|
+
};
|
|
7241
7576
|
}
|
|
7242
7577
|
initialize() {
|
|
7243
7578
|
this.initializeGenerator();
|
|
7244
7579
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
7245
7580
|
const linePoints = getVectorLinePoints(this.board, this.element);
|
|
7246
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7581
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7247
7582
|
selected: this.selected,
|
|
7248
7583
|
linePoints
|
|
7249
7584
|
});
|
|
@@ -7253,15 +7588,15 @@ class VectorLineComponent extends CommonElementFlavour {
|
|
|
7253
7588
|
const linePoints = getVectorLinePoints(this.board, this.element);
|
|
7254
7589
|
if (value.element !== previous.element || value.hasThemeChanged) {
|
|
7255
7590
|
this.shapeGenerator.processDrawing(this.element, this.getElementG());
|
|
7256
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7591
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7257
7592
|
selected: this.selected,
|
|
7258
7593
|
linePoints
|
|
7259
7594
|
});
|
|
7260
7595
|
}
|
|
7261
7596
|
else {
|
|
7262
|
-
const needUpdate = value.selected !== previous.selected || this.activeGenerator.needUpdate();
|
|
7597
|
+
const needUpdate = value.selected !== previous.selected || this.activeGenerator.needUpdate() || value.selected;
|
|
7263
7598
|
if (needUpdate) {
|
|
7264
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
7599
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7265
7600
|
selected: this.selected,
|
|
7266
7601
|
linePoints
|
|
7267
7602
|
});
|
|
@@ -7397,7 +7732,7 @@ const withGeometryCreateByDrag = (board) => {
|
|
|
7397
7732
|
const points = getDefaultGeometryPoints(pointer, movingPoint);
|
|
7398
7733
|
temporaryElement = createDefaultGeometry(board, points, pointer);
|
|
7399
7734
|
geometryGenerator.processDrawing(temporaryElement, geometryShapeG);
|
|
7400
|
-
PlaitBoard.
|
|
7735
|
+
PlaitBoard.getElementTopHost(board).append(geometryShapeG);
|
|
7401
7736
|
}
|
|
7402
7737
|
}
|
|
7403
7738
|
pointerMove(event);
|
|
@@ -7473,11 +7808,11 @@ const withGeometryCreateByDrawing = (board) => {
|
|
|
7473
7808
|
isCreate: true
|
|
7474
7809
|
});
|
|
7475
7810
|
snapG = resizeSnapRef.snapG;
|
|
7476
|
-
PlaitBoard.
|
|
7811
|
+
PlaitBoard.getElementTopHost(board).append(snapG);
|
|
7477
7812
|
points = normalizeShapePoints(resizeSnapRef.activePoints, isShift);
|
|
7478
7813
|
temporaryElement = createDefaultGeometry(board, points, pointer);
|
|
7479
7814
|
geometryGenerator.processDrawing(temporaryElement, geometryShapeG);
|
|
7480
|
-
PlaitBoard.
|
|
7815
|
+
PlaitBoard.getElementTopHost(board).append(geometryShapeG);
|
|
7481
7816
|
}
|
|
7482
7817
|
pointerMove(event);
|
|
7483
7818
|
};
|
|
@@ -7802,7 +8137,7 @@ const withArrowLineBoundReaction = (board) => {
|
|
|
7802
8137
|
const linePointers = Object.keys(ArrowLineShape);
|
|
7803
8138
|
const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
|
|
7804
8139
|
const movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
7805
|
-
const isLineResizing = isResizingByCondition(board, resizeRef => {
|
|
8140
|
+
const isLineResizing = isResizingByCondition(board, (resizeRef) => {
|
|
7806
8141
|
const { element, handle } = resizeRef;
|
|
7807
8142
|
const isSourceOrTarget = handle === LineResizeHandle.target || handle === LineResizeHandle.source;
|
|
7808
8143
|
return PlaitDrawElement.isArrowLine(element) && isSourceOrTarget;
|
|
@@ -7825,12 +8160,12 @@ const withArrowLineBoundReaction = (board) => {
|
|
|
7825
8160
|
if (hasValidAngle(hitElement)) {
|
|
7826
8161
|
setAngleForG(boundShapeG, RectangleClient.getCenterPointByPoints(hitElement.points), hitElement.angle);
|
|
7827
8162
|
}
|
|
7828
|
-
PlaitBoard.
|
|
8163
|
+
PlaitBoard.getElementTopHost(board).append(boundShapeG);
|
|
7829
8164
|
}
|
|
7830
8165
|
}
|
|
7831
8166
|
pointerMove(event);
|
|
7832
8167
|
};
|
|
7833
|
-
board.pointerUp = event => {
|
|
8168
|
+
board.pointerUp = (event) => {
|
|
7834
8169
|
boundShapeG?.remove();
|
|
7835
8170
|
boundShapeG = null;
|
|
7836
8171
|
pointerUp(event);
|
|
@@ -7904,7 +8239,7 @@ class ImageComponent extends CommonElementFlavour {
|
|
|
7904
8239
|
height: element.points[1][1] - element.points[0][1]
|
|
7905
8240
|
};
|
|
7906
8241
|
},
|
|
7907
|
-
getImageItem: element => {
|
|
8242
|
+
getImageItem: (element) => {
|
|
7908
8243
|
return {
|
|
7909
8244
|
url: element.url,
|
|
7910
8245
|
width: element.points[1][0] - element.points[0][0],
|
|
@@ -7914,12 +8249,18 @@ class ImageComponent extends CommonElementFlavour {
|
|
|
7914
8249
|
});
|
|
7915
8250
|
this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
|
|
7916
8251
|
this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
|
|
8252
|
+
this.getRef().updateActiveSection = () => {
|
|
8253
|
+
this.imageGenerator.setFocus(this.element, this.selected);
|
|
8254
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
8255
|
+
selected: this.selected
|
|
8256
|
+
});
|
|
8257
|
+
};
|
|
7917
8258
|
}
|
|
7918
8259
|
initialize() {
|
|
7919
8260
|
super.initialize();
|
|
7920
8261
|
this.initializeGenerator();
|
|
7921
8262
|
this.imageGenerator.processDrawing(this.element, this.getElementG());
|
|
7922
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
8263
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7923
8264
|
selected: this.selected
|
|
7924
8265
|
});
|
|
7925
8266
|
}
|
|
@@ -7927,7 +8268,7 @@ class ImageComponent extends CommonElementFlavour {
|
|
|
7927
8268
|
if (value.element !== previous.element) {
|
|
7928
8269
|
this.imageGenerator.updateImage(this.getElementG(), previous.element, value.element);
|
|
7929
8270
|
this.imageGenerator.setFocus(this.element, this.selected);
|
|
7930
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
8271
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7931
8272
|
selected: this.selected
|
|
7932
8273
|
});
|
|
7933
8274
|
}
|
|
@@ -7935,9 +8276,9 @@ class ImageComponent extends CommonElementFlavour {
|
|
|
7935
8276
|
const hasSameSelected = value.selected === previous.selected;
|
|
7936
8277
|
const hasSameHandleState = this.imageGenerator.activeGenerator &&
|
|
7937
8278
|
this.imageGenerator.activeGenerator.options.hasResizeHandle() === this.imageGenerator.activeGenerator.hasResizeHandle;
|
|
7938
|
-
if (!hasSameSelected || !hasSameHandleState) {
|
|
8279
|
+
if (!hasSameSelected || !hasSameHandleState || value.selected) {
|
|
7939
8280
|
this.imageGenerator.setFocus(this.element, this.selected);
|
|
7940
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
8281
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
7941
8282
|
selected: this.selected
|
|
7942
8283
|
});
|
|
7943
8284
|
}
|
|
@@ -7958,10 +8299,10 @@ const withArrowLineAutoCompleteReaction = (board) => {
|
|
|
7958
8299
|
PlaitBoard.getBoardContainer(board).classList.remove(CursorClass.crosshair);
|
|
7959
8300
|
const selectedElements = getSelectedDrawElements(board);
|
|
7960
8301
|
const targetElement = selectedElements.length === 1 && selectedElements[0];
|
|
7961
|
-
const
|
|
8302
|
+
const activePoint = toActivePoint(board, event.x, event.y);
|
|
7962
8303
|
if (!PlaitBoard.isReadonly(board) && !isSelectionMoving(board) && targetElement && PlaitDrawElement.isShapeElement(targetElement)) {
|
|
7963
|
-
const points = getAutoCompletePoints(targetElement);
|
|
7964
|
-
const hitIndex = getHitIndexOfAutoCompletePoint(rotateAntiPointsByElement(
|
|
8304
|
+
const points = getAutoCompletePoints(board, targetElement, true);
|
|
8305
|
+
const hitIndex = getHitIndexOfAutoCompletePoint(rotateAntiPointsByElement(board, activePoint, targetElement, true) || activePoint, points);
|
|
7965
8306
|
const hitPoint = points[hitIndex];
|
|
7966
8307
|
const ref = PlaitElement.getElementRef(targetElement);
|
|
7967
8308
|
const lineAutoCompleteGenerator = ref.getGenerator(ArrowLineAutoCompleteGenerator.key);
|
|
@@ -7973,10 +8314,12 @@ const withArrowLineAutoCompleteReaction = (board) => {
|
|
|
7973
8314
|
fill: RgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_HOVERED_OPACITY),
|
|
7974
8315
|
fillStyle: 'solid'
|
|
7975
8316
|
});
|
|
7976
|
-
PlaitBoard.
|
|
8317
|
+
PlaitBoard.getActiveHost(board).append(reactionG);
|
|
7977
8318
|
PlaitBoard.getBoardContainer(board).classList.add(CursorClass.crosshair);
|
|
7978
8319
|
if (hasValidAngle(targetElement)) {
|
|
7979
|
-
|
|
8320
|
+
const rectangle = board.getRectangle(targetElement);
|
|
8321
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
8322
|
+
setAngleForG(reactionG, RectangleClient.getCenterPoint(activeRectangle), targetElement.angle);
|
|
7980
8323
|
}
|
|
7981
8324
|
}
|
|
7982
8325
|
}
|
|
@@ -7995,14 +8338,15 @@ const withArrowLineAutoComplete = (board) => {
|
|
|
7995
8338
|
board.pointerDown = (event) => {
|
|
7996
8339
|
const selectedElements = getSelectedDrawElements(board);
|
|
7997
8340
|
const targetElement = selectedElements.length === 1 && selectedElements[0];
|
|
7998
|
-
const
|
|
8341
|
+
const activePoint = toActivePoint(board, event.x, event.y);
|
|
7999
8342
|
if (!PlaitBoard.isReadonly(board) && targetElement && PlaitDrawElement.isShapeElement(targetElement)) {
|
|
8000
|
-
const points = getAutoCompletePoints(targetElement);
|
|
8001
|
-
const index = getHitIndexOfAutoCompletePoint(rotateAntiPointsByElement(
|
|
8343
|
+
const points = getAutoCompletePoints(board, targetElement, true);
|
|
8344
|
+
const index = getHitIndexOfAutoCompletePoint(rotateAntiPointsByElement(board, activePoint, targetElement, true) || activePoint, points);
|
|
8002
8345
|
const hitPoint = points[index];
|
|
8003
8346
|
if (hitPoint) {
|
|
8004
8347
|
temporaryDisableSelection(board);
|
|
8005
|
-
|
|
8348
|
+
const screenPoint = toScreenPointFromActivePoint(board, hitPoint);
|
|
8349
|
+
autoCompletePoint = toViewBoxPoint(board, toHostPoint(board, screenPoint[0], screenPoint[1]));
|
|
8006
8350
|
sourceElement = targetElement;
|
|
8007
8351
|
BoardTransforms.updatePointerType(board, ArrowLineShape.elbow);
|
|
8008
8352
|
}
|
|
@@ -8014,7 +8358,7 @@ const withArrowLineAutoComplete = (board) => {
|
|
|
8014
8358
|
lineShapeG = createG();
|
|
8015
8359
|
let movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
8016
8360
|
if (autoCompletePoint && sourceElement) {
|
|
8017
|
-
const distance = distanceBetweenPointAndPoint(...(rotateAntiPointsByElement(movingPoint, sourceElement) || movingPoint), ...autoCompletePoint);
|
|
8361
|
+
const distance = distanceBetweenPointAndPoint(...(rotateAntiPointsByElement(board, movingPoint, sourceElement) || movingPoint), ...autoCompletePoint);
|
|
8018
8362
|
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
8019
8363
|
const rectangle = RectangleClient.getRectangleByPoints(sourceElement.points);
|
|
8020
8364
|
const shape = getElementShape(sourceElement);
|
|
@@ -8032,7 +8376,7 @@ const withArrowLineAutoComplete = (board) => {
|
|
|
8032
8376
|
}
|
|
8033
8377
|
pointerMove(event);
|
|
8034
8378
|
};
|
|
8035
|
-
board.globalPointerUp = event => {
|
|
8379
|
+
board.globalPointerUp = (event) => {
|
|
8036
8380
|
if (temporaryElement) {
|
|
8037
8381
|
Transforms.insertNode(board, temporaryElement, [board.children.length]);
|
|
8038
8382
|
clearSelectedElement(board);
|
|
@@ -8082,7 +8426,7 @@ const withArrowLineTextMove = (board) => {
|
|
|
8082
8426
|
if (element) {
|
|
8083
8427
|
const movingPoint = resizeState.endPoint;
|
|
8084
8428
|
const points = getArrowLinePoints(board, element);
|
|
8085
|
-
const distance = distanceBetweenPointAndSegments(
|
|
8429
|
+
const distance = distanceBetweenPointAndSegments(movingPoint, points);
|
|
8086
8430
|
if (distance <= movableBuffer) {
|
|
8087
8431
|
const point = getNearestPointBetweenPointAndSegments(movingPoint, points, false);
|
|
8088
8432
|
const position = getRatioByPoint(points, point);
|
|
@@ -8108,7 +8452,7 @@ const withDrawRotate = (board) => {
|
|
|
8108
8452
|
const canRotate = () => {
|
|
8109
8453
|
const elements = getSelectedElements(board);
|
|
8110
8454
|
return (elements.length > 0 &&
|
|
8111
|
-
elements.every(el => (PlaitDrawElement.isDrawElement(el) && !PlaitDrawElement.isArrowLine(el)) ||
|
|
8455
|
+
elements.every((el) => (PlaitDrawElement.isDrawElement(el) && !PlaitDrawElement.isArrowLine(el)) ||
|
|
8112
8456
|
PlaitDrawElement.isCustomGeometryElement(board, el)));
|
|
8113
8457
|
};
|
|
8114
8458
|
board.pointerDown = (event) => {
|
|
@@ -8116,16 +8460,17 @@ const withDrawRotate = (board) => {
|
|
|
8116
8460
|
pointerDown(event);
|
|
8117
8461
|
return;
|
|
8118
8462
|
}
|
|
8119
|
-
const
|
|
8463
|
+
const activePoint = toActivePoint(board, event.x, event.y);
|
|
8120
8464
|
const elements = getSelectedElements(board);
|
|
8121
|
-
const
|
|
8122
|
-
const
|
|
8465
|
+
const rectangle = getRectangleByElements(board, elements, false);
|
|
8466
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
8467
|
+
const handleRectangle = getRotateHandleRectangle(activeRectangle);
|
|
8123
8468
|
const angle = getSelectionAngle(elements);
|
|
8124
|
-
const rotatedPoint = angle ? rotatePoints(
|
|
8469
|
+
const rotatedPoint = angle ? rotatePoints(activePoint, RectangleClient.getCenterPoint(activeRectangle), -angle) : activePoint;
|
|
8125
8470
|
if (handleRectangle && RectangleClient.isHit(RectangleClient.getRectangleByPoints([rotatedPoint, rotatedPoint]), handleRectangle)) {
|
|
8126
8471
|
rotateRef = {
|
|
8127
8472
|
elements: [...elements],
|
|
8128
|
-
startPoint:
|
|
8473
|
+
startPoint: activePoint
|
|
8129
8474
|
};
|
|
8130
8475
|
}
|
|
8131
8476
|
pointerDown(event);
|
|
@@ -8135,9 +8480,10 @@ const withDrawRotate = (board) => {
|
|
|
8135
8480
|
event.preventDefault();
|
|
8136
8481
|
const isShift = !!event.shiftKey;
|
|
8137
8482
|
addRotating(board, rotateRef);
|
|
8138
|
-
const endPoint =
|
|
8139
|
-
const
|
|
8140
|
-
const
|
|
8483
|
+
const endPoint = toActivePoint(board, event.x, event.y);
|
|
8484
|
+
const rectangle = getRectangleByElements(board, rotateRef.elements, false);
|
|
8485
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
8486
|
+
const selectionCenterPoint = RectangleClient.getCenterPoint(activeRectangle);
|
|
8141
8487
|
if (!getSelectionAngle(rotateRef.elements) && rotateRef.elements.length > 1) {
|
|
8142
8488
|
needCustomActiveRectangle = true;
|
|
8143
8489
|
}
|
|
@@ -8189,32 +8535,35 @@ const withDrawRotate = (board) => {
|
|
|
8189
8535
|
if (canRotate() && !isSelectionMoving(board)) {
|
|
8190
8536
|
if (needCustomActiveRectangle && rotateRef) {
|
|
8191
8537
|
const boundingRectangle = getRectangleByElements(board, rotateRef.elements, false);
|
|
8192
|
-
|
|
8538
|
+
const boundingActiveRectangle = toActiveRectangleFromViewBoxRectangle(board, boundingRectangle);
|
|
8539
|
+
rotateHandleG = drawRotateHandle(board, boundingActiveRectangle);
|
|
8193
8540
|
rotateHandleG.classList.add(ROTATE_HANDLE_CLASS_NAME);
|
|
8194
8541
|
if (rotateRef.angle) {
|
|
8195
|
-
setAngleForG(rotateHandleG, RectangleClient.getCenterPoint(
|
|
8542
|
+
setAngleForG(rotateHandleG, RectangleClient.getCenterPoint(boundingActiveRectangle), rotateRef.angle);
|
|
8196
8543
|
}
|
|
8197
8544
|
}
|
|
8198
8545
|
else {
|
|
8199
8546
|
const elements = getSelectedElements(board);
|
|
8200
8547
|
const boundingRectangle = getRectangleByElements(board, elements, false);
|
|
8201
|
-
|
|
8548
|
+
const boundingActiveRectangle = toActiveRectangleFromViewBoxRectangle(board, boundingRectangle);
|
|
8549
|
+
rotateHandleG = drawRotateHandle(board, boundingActiveRectangle);
|
|
8202
8550
|
rotateHandleG.classList.add(ROTATE_HANDLE_CLASS_NAME);
|
|
8203
|
-
setAngleForG(rotateHandleG, RectangleClient.getCenterPoint(
|
|
8551
|
+
setAngleForG(rotateHandleG, RectangleClient.getCenterPoint(boundingActiveRectangle), getSelectionAngle(elements));
|
|
8204
8552
|
}
|
|
8205
|
-
PlaitBoard.
|
|
8553
|
+
PlaitBoard.getActiveHost(board).append(rotateHandleG);
|
|
8206
8554
|
}
|
|
8207
8555
|
};
|
|
8208
8556
|
board.drawSelectionRectangle = () => {
|
|
8209
8557
|
if (needCustomActiveRectangle && rotateRef) {
|
|
8210
8558
|
const rectangle = getRectangleByElements(board, rotateRef.elements, false);
|
|
8211
|
-
const
|
|
8559
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
8560
|
+
const rectangleG = drawRectangle(board, RectangleClient.inflate(activeRectangle, ACTIVE_STROKE_WIDTH), {
|
|
8212
8561
|
stroke: SELECTION_BORDER_COLOR,
|
|
8213
8562
|
strokeWidth: ACTIVE_STROKE_WIDTH
|
|
8214
8563
|
});
|
|
8215
8564
|
rectangleG.classList.add(SELECTION_RECTANGLE_CLASS_NAME);
|
|
8216
8565
|
if (rotateRef.angle) {
|
|
8217
|
-
setAngleForG(rectangleG, RectangleClient.getCenterPoint(
|
|
8566
|
+
setAngleForG(rectangleG, RectangleClient.getCenterPoint(activeRectangle), rotateRef.angle);
|
|
8218
8567
|
}
|
|
8219
8568
|
return rectangleG;
|
|
8220
8569
|
}
|
|
@@ -8228,7 +8577,7 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8228
8577
|
super();
|
|
8229
8578
|
}
|
|
8230
8579
|
initializeGenerator() {
|
|
8231
|
-
this.activeGenerator =
|
|
8580
|
+
this.activeGenerator = createActiveGenerator(this.board, {
|
|
8232
8581
|
getStrokeWidth: () => {
|
|
8233
8582
|
return ACTIVE_STROKE_WIDTH;
|
|
8234
8583
|
},
|
|
@@ -8254,6 +8603,14 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8254
8603
|
this.initializeTextManage();
|
|
8255
8604
|
this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
|
|
8256
8605
|
this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
|
|
8606
|
+
this.getRef().updateActiveSection = () => {
|
|
8607
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
8608
|
+
selected: this.selected
|
|
8609
|
+
});
|
|
8610
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
8611
|
+
selected: this.selected
|
|
8612
|
+
});
|
|
8613
|
+
};
|
|
8257
8614
|
}
|
|
8258
8615
|
initialize() {
|
|
8259
8616
|
super.initialize();
|
|
@@ -8264,13 +8621,13 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8264
8621
|
this.tableGenerator.processDrawing(this.element, this.getElementG());
|
|
8265
8622
|
this.textGenerator.draw(this.getElementG());
|
|
8266
8623
|
this.rotateVerticalText();
|
|
8267
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
8624
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
8268
8625
|
selected: this.selected
|
|
8269
8626
|
});
|
|
8270
8627
|
}
|
|
8271
8628
|
rotateVerticalText() {
|
|
8272
8629
|
const table = this.board.buildTable(this.element);
|
|
8273
|
-
table.cells.forEach(item => {
|
|
8630
|
+
table.cells.forEach((item) => {
|
|
8274
8631
|
if (PlaitTableElement.isVerticalText(item)) {
|
|
8275
8632
|
const textManage = getTextManageByCell(this.board, item);
|
|
8276
8633
|
if (textManage) {
|
|
@@ -8284,8 +8641,8 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8284
8641
|
}
|
|
8285
8642
|
getDrawShapeTexts(cells) {
|
|
8286
8643
|
return cells
|
|
8287
|
-
.filter(item => isCellIncludeText(item))
|
|
8288
|
-
.map(item => {
|
|
8644
|
+
.filter((item) => isCellIncludeText(item))
|
|
8645
|
+
.map((item) => {
|
|
8289
8646
|
return {
|
|
8290
8647
|
id: item.id,
|
|
8291
8648
|
text: item.text,
|
|
@@ -8333,7 +8690,7 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8333
8690
|
setSelectedCells(value.element, previousSelectedCells);
|
|
8334
8691
|
}
|
|
8335
8692
|
this.tableGenerator.processDrawing(value.element, this.getElementG());
|
|
8336
|
-
this.activeGenerator.processDrawing(value.element, PlaitBoard.
|
|
8693
|
+
this.activeGenerator.processDrawing(value.element, PlaitBoard.getActiveHost(this.board), { selected: this.selected });
|
|
8337
8694
|
const previousTexts = this.getDrawShapeTexts(previous.element.cells);
|
|
8338
8695
|
const currentTexts = this.getDrawShapeTexts(value.element.cells);
|
|
8339
8696
|
this.textGenerator.update(value.element, previousTexts, currentTexts, this.getElementG());
|
|
@@ -8343,8 +8700,8 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8343
8700
|
const hasSameSelected = value.selected === previous.selected;
|
|
8344
8701
|
const hasSameHandleState = this.activeGenerator.options.hasResizeHandle() === this.activeGenerator.hasResizeHandle;
|
|
8345
8702
|
const currentSelectedCells = getSelectedCells(value.element);
|
|
8346
|
-
if (!hasSameSelected || !hasSameHandleState || currentSelectedCells?.length) {
|
|
8347
|
-
this.activeGenerator.processDrawing(value.element, PlaitBoard.
|
|
8703
|
+
if (!hasSameSelected || !hasSameHandleState || currentSelectedCells?.length || value.selected) {
|
|
8704
|
+
this.activeGenerator.processDrawing(value.element, PlaitBoard.getActiveHost(this.board), {
|
|
8348
8705
|
selected: this.selected
|
|
8349
8706
|
});
|
|
8350
8707
|
}
|
|
@@ -8352,7 +8709,7 @@ class TableComponent extends CommonElementFlavour {
|
|
|
8352
8709
|
clearSelectedCells(value.element);
|
|
8353
8710
|
}
|
|
8354
8711
|
}
|
|
8355
|
-
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.
|
|
8712
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
8356
8713
|
selected: this.selected
|
|
8357
8714
|
});
|
|
8358
8715
|
}
|
|
@@ -8418,7 +8775,7 @@ function withTableResize(board) {
|
|
|
8418
8775
|
const resizePoints = [resizeState.startPoint, resizeState.endPoint];
|
|
8419
8776
|
const { xZoom, yZoom } = getResizeZoom(resizePoints, originPoint, handlePoint, false, false);
|
|
8420
8777
|
const originPoints = resizeRef.options?.cell.points;
|
|
8421
|
-
const targetPoints = originPoints.map(p => {
|
|
8778
|
+
const targetPoints = originPoints.map((p) => {
|
|
8422
8779
|
return movePointByZoomAndOriginPoint(p, originPoint, xZoom, yZoom);
|
|
8423
8780
|
});
|
|
8424
8781
|
const offsetX = targetPoints[1][0] - originPoints[1][0];
|
|
@@ -8445,7 +8802,7 @@ function withTableResize(board) {
|
|
|
8445
8802
|
}, isAspectRatio, isFromCorner);
|
|
8446
8803
|
const resizeSnapRef = getSnapResizingRef(board, [resizeRef.element], resizeSnapRefOptions);
|
|
8447
8804
|
snapG = resizeSnapRef.snapG;
|
|
8448
|
-
PlaitBoard.
|
|
8805
|
+
PlaitBoard.getElementTopHost(board).append(snapG);
|
|
8449
8806
|
const points = resizeSnapRef.activePoints;
|
|
8450
8807
|
const originPoints = resizeRef.element.points;
|
|
8451
8808
|
const originRect = RectangleClient.getRectangleByPoints(originPoints);
|
|
@@ -8455,7 +8812,7 @@ function withTableResize(board) {
|
|
|
8455
8812
|
let columns = [...resizeRef.element.columns];
|
|
8456
8813
|
let rows = [...resizeRef.element.rows];
|
|
8457
8814
|
if (offsetWidth !== 0) {
|
|
8458
|
-
columns = columns.map(item => {
|
|
8815
|
+
columns = columns.map((item) => {
|
|
8459
8816
|
if (item.width) {
|
|
8460
8817
|
return {
|
|
8461
8818
|
...item,
|
|
@@ -8466,7 +8823,7 @@ function withTableResize(board) {
|
|
|
8466
8823
|
});
|
|
8467
8824
|
}
|
|
8468
8825
|
if (offsetHeight !== 0) {
|
|
8469
|
-
rows = rows.map(item => {
|
|
8826
|
+
rows = rows.map((item) => {
|
|
8470
8827
|
if (item.height) {
|
|
8471
8828
|
return {
|
|
8472
8829
|
...item,
|
|
@@ -8519,7 +8876,8 @@ const withTable = (board) => {
|
|
|
8519
8876
|
tableBoard.isRectangleHit = (element, selection) => {
|
|
8520
8877
|
if (PlaitDrawElement.isElementByTable(element)) {
|
|
8521
8878
|
const rangeRectangle = RectangleClient.getRectangleByPoints([selection.anchor, selection.focus]);
|
|
8522
|
-
|
|
8879
|
+
const client = RectangleClient.getRectangleByPoints(element.points);
|
|
8880
|
+
return isLineHitRectangle(RectangleClient.getCornerPoints(client), rangeRectangle);
|
|
8523
8881
|
}
|
|
8524
8882
|
return isRectangleHit(element, selection);
|
|
8525
8883
|
};
|
|
@@ -8611,7 +8969,7 @@ const withSwimlaneCreateByDrag = (board) => {
|
|
|
8611
8969
|
const points = getDefaultSwimlanePoints(pointer, movingPoint);
|
|
8612
8970
|
temporaryElement = createDefaultSwimlane(pointer, points);
|
|
8613
8971
|
tableGenerator.processDrawing(temporaryElement, swimlaneG);
|
|
8614
|
-
PlaitBoard.
|
|
8972
|
+
PlaitBoard.getElementTopHost(board).append(swimlaneG);
|
|
8615
8973
|
}
|
|
8616
8974
|
pointerMove(event);
|
|
8617
8975
|
};
|
|
@@ -8674,11 +9032,11 @@ const withSwimlaneCreateByDrawing = (board) => {
|
|
|
8674
9032
|
isCreate: true
|
|
8675
9033
|
});
|
|
8676
9034
|
snapG = resizeSnapRef.snapG;
|
|
8677
|
-
PlaitBoard.
|
|
9035
|
+
PlaitBoard.getElementTopHost(board).append(snapG);
|
|
8678
9036
|
points = normalizeShapePoints(resizeSnapRef.activePoints, isShift);
|
|
8679
9037
|
temporaryElement = createDefaultSwimlane(pointer, points);
|
|
8680
9038
|
tableGenerator.processDrawing(temporaryElement, swimlaneG);
|
|
8681
|
-
PlaitBoard.
|
|
9039
|
+
PlaitBoard.getElementTopHost(board).append(swimlaneG);
|
|
8682
9040
|
}
|
|
8683
9041
|
pointerMove(event);
|
|
8684
9042
|
};
|
|
@@ -8980,5 +9338,5 @@ const withDraw = (board) => {
|
|
|
8980
9338
|
* Generated bundle index. Do not edit.
|
|
8981
9339
|
*/
|
|
8982
9340
|
|
|
8983
|
-
export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedCustomGeometry, isClosedDrawElement, isClosedPoints, isDrawElementIncludeText, isDrawElementsIncludeText, isEmptyTextElement, isFilledDrawElement, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectElementByTable, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText,
|
|
9341
|
+
export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedCustomGeometry, isClosedDrawElement, isClosedPoints, isDrawElementIncludeText, isDrawElementsIncludeText, isEmptyTextElement, isFilledDrawElement, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectElementByTable, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
|
|
8984
9342
|
//# sourceMappingURL=plait-draw.mjs.map
|