@plait/draw 0.34.0 → 0.36.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/constants/line.d.ts +4 -0
- package/esm2022/constants/line.mjs +5 -1
- package/esm2022/generators/line-active.generator.mjs +10 -7
- package/esm2022/generators/line-auto-complete.generator.mjs +45 -0
- package/esm2022/geometry.component.mjs +20 -10
- package/esm2022/interfaces/element.mjs +2 -1
- package/esm2022/interfaces/index.mjs +2 -2
- package/esm2022/line.component.mjs +10 -15
- package/esm2022/plugins/with-draw-hotkey.mjs +5 -4
- package/esm2022/plugins/with-draw.mjs +4 -4
- package/esm2022/plugins/with-geometry-create.mjs +14 -8
- package/esm2022/plugins/with-line-auto-complete-reaction.mjs +35 -0
- package/esm2022/plugins/with-line-auto-complete.mjs +60 -0
- package/esm2022/plugins/with-line-bound-reaction.mjs +5 -1
- package/esm2022/plugins/with-line-create.mjs +2 -2
- package/esm2022/plugins/with-line-resize.mjs +2 -2
- package/esm2022/plugins/with-line-text.mjs +29 -27
- package/esm2022/transforms/index.mjs +2 -2
- package/esm2022/transforms/property.mjs +15 -0
- package/esm2022/utils/geometry.mjs +6 -3
- package/esm2022/utils/index.mjs +2 -1
- package/esm2022/utils/line-arrow.mjs +10 -6
- package/esm2022/utils/line.mjs +12 -5
- package/esm2022/utils/memorize.mjs +75 -0
- package/fesm2022/plait-draw.mjs +201 -110
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/generators/line-active.generator.d.ts +0 -1
- package/generators/{auto-complete.generator.d.ts → line-auto-complete.generator.d.ts} +1 -1
- package/geometry.component.d.ts +2 -2
- package/interfaces/element.d.ts +1 -0
- package/interfaces/index.d.ts +1 -1
- package/line.component.d.ts +0 -1
- package/package.json +1 -1
- package/plugins/with-line-auto-complete-reaction.d.ts +2 -0
- package/plugins/with-line-auto-complete.d.ts +7 -0
- package/styles/styles.scss +1 -2
- package/transforms/{common.d.ts → property.d.ts} +1 -2
- package/utils/geometry.d.ts +6 -1
- package/utils/index.d.ts +1 -0
- package/utils/memorize.d.ts +19 -0
- package/utils/position/geometry.d.ts +1 -1
- package/esm2022/generators/auto-complete.generator.mjs +0 -44
- package/esm2022/plugins/with-auto-complete-reaction.mjs +0 -35
- package/esm2022/plugins/with-auto-complete.mjs +0 -61
- package/esm2022/transforms/common.mjs +0 -33
- package/plugins/with-auto-complete-reaction.d.ts +0 -2
- package/plugins/with-auto-complete.d.ts +0 -7
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PlaitElement, ACTIVE_STROKE_WIDTH, ThemeColorMode, PlaitBoard, setStrokeLinecap, isPointInPolygon, getNearestPointBetweenPointAndSegments, RectangleClient, isPointInEllipse, drawRectangle, drawRoundRectangle, isPointInRoundRectangle, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Point, BOARD_TO_HOST, transformPoint, toPoint, idCreator, createG, BoardTransforms, PlaitPointerType, preventTouchMove, createForeignObject, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, distanceBetweenPointAndSegment, arrowPoints, createPath,
|
|
2
|
-
import { getRectangleByPoints, Generator, PropertyTransforms, normalizeShapePoints,
|
|
1
|
+
import { PlaitElement, ACTIVE_STROKE_WIDTH, ThemeColorMode, PlaitBoard, setStrokeLinecap, isPointInPolygon, getNearestPointBetweenPointAndSegments, RectangleClient, isPointInEllipse, drawRectangle, drawRoundRectangle, isPointInRoundRectangle, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Point, BOARD_TO_HOST, transformPoint, toPoint, idCreator, createG, BoardTransforms, PlaitPointerType, preventTouchMove, createForeignObject, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, distanceBetweenPointAndSegment, arrowPoints, createPath, distanceBetweenPointAndPoint, drawLinearPath, rotate, depthFirstRecursion, getIsRecursionFunc, getElementById, Direction, catmullRomFitting, distanceBetweenPointAndSegments, createMask, createRect, findElements, getSelectedElements, isPolylineHitRectangle, isSelectionMoving, RgbaToHEX, PlaitPluginElementComponent, setClipboardData, getDataFromClipboard, getHitElementByPoint, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER } from '@plait/core';
|
|
2
|
+
import { getRectangleByPoints, Generator, getMemorizedLatest, memorizeLatest, PropertyTransforms, normalizeShapePoints, isDndMode, isDrawingMode, RESIZE_HANDLE_DIAMETER, getExtendPoint, getFactorByPoints, getRectangleResizeHandleRefs, getDirectionByVector, getOppositeDirection, getDirectionFactor, DEFAULT_ROUTE_MARGIN, reduceRouteMargin, getNextPoint, generateElbowLineRoute, getPoints, removeDuplicatePoints, getPointByVector, getPointOnPolyline, getDirectionByPointOfRectangle, rotateVectorAnti90, TRANSPARENT, PRIMARY_COLOR, CommonPluginElement, ActiveGenerator, WithTextPluginKey, isVirtualKey, isDelete, isSpaceHotkey, acceptImageTypes, getElementOfFocusedImage, buildImage, ResizeHandle, withResize, isResizingByCondition, getRatioByPoint, ImageGenerator } from '@plait/common';
|
|
3
3
|
import { AlignEditor, Alignment, DEFAULT_FONT_SIZE, buildText, TextManage, getTextFromClipboard, getTextSize } from '@plait/text';
|
|
4
4
|
import { isKeyHotkey } from 'is-hotkey';
|
|
5
5
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
@@ -1223,22 +1223,16 @@ class GeometryShapeGenerator extends Generator {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
}
|
|
1225
1225
|
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
};
|
|
1229
|
-
const setStrokeWidth = (board, strokeWidth) => {
|
|
1230
|
-
PropertyTransforms.setProperty(board, { strokeWidth }, { getMemorizeKey });
|
|
1231
|
-
};
|
|
1232
|
-
const setFillColor = (board, fill) => {
|
|
1233
|
-
PropertyTransforms.setProperty(board, { fill }, { getMemorizeKey });
|
|
1234
|
-
};
|
|
1235
|
-
const setStrokeStyle = (board, strokeStyle) => {
|
|
1236
|
-
PropertyTransforms.setProperty(board, { strokeStyle }, { getMemorizeKey });
|
|
1237
|
-
};
|
|
1226
|
+
const SHAPE_MAX_LENGTH = 6;
|
|
1227
|
+
const memorizedShape = new WeakMap();
|
|
1238
1228
|
const getMemorizeKey = (element) => {
|
|
1239
1229
|
let key = '';
|
|
1240
1230
|
switch (true) {
|
|
1241
|
-
case PlaitDrawElement.
|
|
1231
|
+
case PlaitDrawElement.isText(element): {
|
|
1232
|
+
key = MemorizeKey.text;
|
|
1233
|
+
break;
|
|
1234
|
+
}
|
|
1235
|
+
case PlaitDrawElement.isBasicShape(element): {
|
|
1242
1236
|
key = MemorizeKey.basicShape;
|
|
1243
1237
|
break;
|
|
1244
1238
|
}
|
|
@@ -1253,6 +1247,67 @@ const getMemorizeKey = (element) => {
|
|
|
1253
1247
|
}
|
|
1254
1248
|
return key;
|
|
1255
1249
|
};
|
|
1250
|
+
const getLineMemorizedLatest = () => {
|
|
1251
|
+
const properties = getMemorizedLatest(MemorizeKey.line);
|
|
1252
|
+
delete properties?.text;
|
|
1253
|
+
return properties || {};
|
|
1254
|
+
};
|
|
1255
|
+
const getMemorizedLatestByPointer = (pointer) => {
|
|
1256
|
+
let memorizeKey = '';
|
|
1257
|
+
if (PlaitDrawElement.isBasicShape({ shape: pointer })) {
|
|
1258
|
+
memorizeKey = pointer === BasicShapes.text ? MemorizeKey.text : MemorizeKey.basicShape;
|
|
1259
|
+
}
|
|
1260
|
+
else {
|
|
1261
|
+
memorizeKey = MemorizeKey.flowchart;
|
|
1262
|
+
}
|
|
1263
|
+
const properties = { ...getMemorizedLatest(memorizeKey) } || {};
|
|
1264
|
+
const textProperties = properties.text || {};
|
|
1265
|
+
delete properties.text;
|
|
1266
|
+
return { textProperties, geometryProperties: properties };
|
|
1267
|
+
};
|
|
1268
|
+
const memorizeLatestText = (element, operations) => {
|
|
1269
|
+
const memorizeKey = getMemorizeKey(element);
|
|
1270
|
+
let textMemory = getMemorizedLatest(memorizeKey)?.text || {};
|
|
1271
|
+
const setNodeOperation = operations.find(operation => operation.type === 'set_node');
|
|
1272
|
+
if (setNodeOperation) {
|
|
1273
|
+
const newProperties = setNodeOperation.newProperties;
|
|
1274
|
+
textMemory = { ...textMemory, ...newProperties };
|
|
1275
|
+
memorizeLatest(memorizeKey, 'text', textMemory);
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
const memorizeLatestShape = (board, shape) => {
|
|
1279
|
+
const shapes = memorizedShape.has(board) ? memorizedShape.get(board) : [];
|
|
1280
|
+
const shapeIndex = shapes.indexOf(shape);
|
|
1281
|
+
if (shape === BasicShapes.text || shapeIndex === 0) {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
if (shapeIndex !== -1) {
|
|
1285
|
+
shapes.splice(shapeIndex, 1);
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
if (shapes.length === SHAPE_MAX_LENGTH) {
|
|
1289
|
+
shapes.pop();
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
shapes.unshift(shape);
|
|
1293
|
+
memorizedShape.set(board, shapes);
|
|
1294
|
+
};
|
|
1295
|
+
const getMemorizedLatestShape = (board) => {
|
|
1296
|
+
return memorizedShape.get(board);
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
const setStrokeColor = (board, strokeColor) => {
|
|
1300
|
+
PropertyTransforms.setProperty(board, { strokeColor }, { getMemorizeKey });
|
|
1301
|
+
};
|
|
1302
|
+
const setStrokeWidth = (board, strokeWidth) => {
|
|
1303
|
+
PropertyTransforms.setProperty(board, { strokeWidth }, { getMemorizeKey });
|
|
1304
|
+
};
|
|
1305
|
+
const setFillColor = (board, fill) => {
|
|
1306
|
+
PropertyTransforms.setProperty(board, { fill }, { getMemorizeKey });
|
|
1307
|
+
};
|
|
1308
|
+
const setStrokeStyle = (board, strokeStyle) => {
|
|
1309
|
+
PropertyTransforms.setProperty(board, { strokeStyle }, { getMemorizeKey });
|
|
1310
|
+
};
|
|
1256
1311
|
|
|
1257
1312
|
const insertGeometry = (board, points, shape) => {
|
|
1258
1313
|
let newElement = createGeometryElement(shape, points, '', {
|
|
@@ -1464,14 +1519,15 @@ const withGeometryCreateByDrawing = (board) => {
|
|
|
1464
1519
|
board.pointerDown = (event) => {
|
|
1465
1520
|
const geometryPointers = getGeometryPointers();
|
|
1466
1521
|
const isGeometryPointer = PlaitBoard.isInPointer(board, geometryPointers);
|
|
1467
|
-
if (isGeometryPointer && isDrawingMode(board)) {
|
|
1522
|
+
if (!PlaitBoard.isReadonly(board) && isGeometryPointer && isDrawingMode(board)) {
|
|
1468
1523
|
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
1469
1524
|
start = point;
|
|
1470
1525
|
const pointer = PlaitBoard.getPointer(board);
|
|
1471
1526
|
preventTouchMove(board, event, true);
|
|
1472
1527
|
if (pointer === BasicShapes.text) {
|
|
1528
|
+
const memorizedLatest = getMemorizedLatestByPointer(pointer);
|
|
1473
1529
|
const points = getDefaultGeometryPoints(pointer, point);
|
|
1474
|
-
const textElement = createGeometryElement(BasicShapes.text, points, DefaultTextProperty.text);
|
|
1530
|
+
const textElement = createGeometryElement(BasicShapes.text, points, DefaultTextProperty.text, memorizedLatest.geometryProperties, memorizedLatest.textProperties);
|
|
1475
1531
|
Transforms.insertNode(board, textElement, [board.children.length]);
|
|
1476
1532
|
clearSelectedElement(board);
|
|
1477
1533
|
addSelectedElement(board, textElement);
|
|
@@ -1490,9 +1546,11 @@ const withGeometryCreateByDrawing = (board) => {
|
|
|
1490
1546
|
const pointer = PlaitBoard.getPointer(board);
|
|
1491
1547
|
if (drawMode && pointer !== BasicShapes.text) {
|
|
1492
1548
|
const points = normalizeShapePoints([start, movingPoint], isShift);
|
|
1549
|
+
const memorizedLatest = getMemorizedLatestByPointer(pointer);
|
|
1493
1550
|
temporaryElement = createGeometryElement(pointer, points, '', {
|
|
1494
|
-
strokeWidth: DefaultBasicShapeProperty.strokeWidth
|
|
1495
|
-
|
|
1551
|
+
strokeWidth: DefaultBasicShapeProperty.strokeWidth,
|
|
1552
|
+
...memorizedLatest.geometryProperties
|
|
1553
|
+
}, memorizedLatest.textProperties);
|
|
1496
1554
|
geometryGenerator.processDrawing(temporaryElement, geometryShapeG);
|
|
1497
1555
|
PlaitBoard.getElementActiveHost(board).append(geometryShapeG);
|
|
1498
1556
|
}
|
|
@@ -1507,13 +1565,16 @@ const withGeometryCreateByDrawing = (board) => {
|
|
|
1507
1565
|
const pointer = PlaitBoard.getPointer(board);
|
|
1508
1566
|
const points = getDefaultGeometryPoints(pointer, targetPoint);
|
|
1509
1567
|
if (pointer !== BasicShapes.text) {
|
|
1568
|
+
const memorizedLatest = getMemorizedLatestByPointer(pointer);
|
|
1510
1569
|
temporaryElement = createGeometryElement(pointer, points, '', {
|
|
1511
|
-
strokeWidth: DefaultBasicShapeProperty.strokeWidth
|
|
1512
|
-
|
|
1570
|
+
strokeWidth: DefaultBasicShapeProperty.strokeWidth,
|
|
1571
|
+
...memorizedLatest.geometryProperties
|
|
1572
|
+
}, memorizedLatest.textProperties);
|
|
1513
1573
|
}
|
|
1514
1574
|
}
|
|
1515
1575
|
}
|
|
1516
1576
|
if (temporaryElement) {
|
|
1577
|
+
memorizeLatestShape(board, temporaryElement.shape);
|
|
1517
1578
|
Transforms.insertNode(board, temporaryElement, [board.children.length]);
|
|
1518
1579
|
clearSelectedElement(board);
|
|
1519
1580
|
addSelectedElement(board, temporaryElement);
|
|
@@ -1563,14 +1624,21 @@ const DefaultLineStyle = {
|
|
|
1563
1624
|
strokeColor: '#000'
|
|
1564
1625
|
};
|
|
1565
1626
|
const LINE_TEXT_SPACE = 4;
|
|
1627
|
+
const LINE_AUTO_COMPLETE_DIAMETER = 6;
|
|
1628
|
+
const LINE_AUTO_COMPLETE_OPACITY = 0.6;
|
|
1629
|
+
const LINE_AUTO_COMPLETE_HOVERED_OPACITY = 0.8;
|
|
1630
|
+
const LINE_AUTO_COMPLETE_HOVERED_DIAMETER = 10;
|
|
1566
1631
|
|
|
1567
|
-
const createGeometryElement = (shape, points, text, options) => {
|
|
1632
|
+
const createGeometryElement = (shape, points, text, options = {}, textProperties = {}) => {
|
|
1568
1633
|
let textOptions = {};
|
|
1569
1634
|
let alignment = Alignment.center;
|
|
1570
1635
|
if (shape === BasicShapes.text) {
|
|
1571
1636
|
textOptions = { autoSize: true };
|
|
1572
1637
|
alignment = undefined;
|
|
1573
1638
|
}
|
|
1639
|
+
textProperties = { ...textProperties };
|
|
1640
|
+
textProperties?.align && (alignment = textProperties?.align);
|
|
1641
|
+
delete textProperties?.align;
|
|
1574
1642
|
return {
|
|
1575
1643
|
id: idCreator(),
|
|
1576
1644
|
type: 'geometry',
|
|
@@ -1578,7 +1646,7 @@ const createGeometryElement = (shape, points, text, options) => {
|
|
|
1578
1646
|
angle: 0,
|
|
1579
1647
|
opacity: 1,
|
|
1580
1648
|
textHeight: DefaultTextProperty.height,
|
|
1581
|
-
text: buildText(text, alignment),
|
|
1649
|
+
text: buildText(text, alignment, textProperties),
|
|
1582
1650
|
points,
|
|
1583
1651
|
...textOptions,
|
|
1584
1652
|
...options
|
|
@@ -1732,7 +1800,7 @@ const getFlowchartDefaultFill = (theme) => {
|
|
|
1732
1800
|
return DrawThemeColors[theme].fill;
|
|
1733
1801
|
};
|
|
1734
1802
|
|
|
1735
|
-
const
|
|
1803
|
+
const ARROW_LENGTH = 20;
|
|
1736
1804
|
const drawLineArrow = (element, points, options) => {
|
|
1737
1805
|
const arrowG = createG();
|
|
1738
1806
|
if (PlaitLine.isSourceMark(element, LineMarkerType.none) && PlaitLine.isTargetMark(element, LineMarkerType.none)) {
|
|
@@ -1740,13 +1808,16 @@ const drawLineArrow = (element, points, options) => {
|
|
|
1740
1808
|
}
|
|
1741
1809
|
const strokeWidth = getStrokeWidthByElement(element);
|
|
1742
1810
|
const offset = (strokeWidth * strokeWidth) / 3;
|
|
1811
|
+
if (points.length === 1) {
|
|
1812
|
+
points = [points[0], [points[0][0] + 0.1, points[0][1]]];
|
|
1813
|
+
}
|
|
1743
1814
|
if (!PlaitLine.isSourceMark(element, LineMarkerType.none)) {
|
|
1744
|
-
const source = getExtendPoint(points[0], points[1],
|
|
1815
|
+
const source = getExtendPoint(points[0], points[1], ARROW_LENGTH + offset);
|
|
1745
1816
|
const sourceArrow = getArrow(element, { marker: element.source.marker, source, target: points[0], isSource: true }, options);
|
|
1746
1817
|
sourceArrow && arrowG.appendChild(sourceArrow);
|
|
1747
1818
|
}
|
|
1748
1819
|
if (!PlaitLine.isTargetMark(element, LineMarkerType.none)) {
|
|
1749
|
-
const source = getExtendPoint(points[points.length - 1], points[points.length - 2],
|
|
1820
|
+
const source = getExtendPoint(points[points.length - 1], points[points.length - 2], ARROW_LENGTH + offset);
|
|
1750
1821
|
const arrow = getArrow(element, { marker: element.target.marker, source, target: points[points.length - 1], isSource: false }, options);
|
|
1751
1822
|
arrow && arrowG.appendChild(arrow);
|
|
1752
1823
|
}
|
|
@@ -1808,9 +1879,10 @@ const drawArrow = (element, source, target, options) => {
|
|
|
1808
1879
|
const directionFactor = getFactorByPoints(source, target);
|
|
1809
1880
|
const strokeWidth = getStrokeWidthByElement(element);
|
|
1810
1881
|
const endPoint = [target[0] + (strokeWidth * directionFactor.x) / 2, target[1] + (strokeWidth * directionFactor.y) / 2];
|
|
1882
|
+
const distance = distanceBetweenPointAndPoint(...source, ...endPoint);
|
|
1811
1883
|
const middlePoint = [
|
|
1812
|
-
endPoint[0] - (
|
|
1813
|
-
endPoint[1] - (
|
|
1884
|
+
endPoint[0] - (((distance * 3) / 5 + strokeWidth) / 2) * directionFactor.x,
|
|
1885
|
+
endPoint[1] - (((distance * 3) / 5 + strokeWidth) / 2) * directionFactor.y
|
|
1814
1886
|
];
|
|
1815
1887
|
const { pointLeft, pointRight } = arrowPoints(source, endPoint, 30);
|
|
1816
1888
|
const arrowG = drawLinearPath([pointLeft, endPoint, pointRight, middlePoint], { ...options, fill: options.stroke }, true);
|
|
@@ -2079,7 +2151,6 @@ const drawLine = (board, element) => {
|
|
|
2079
2151
|
let points = getLinePoints(board, element);
|
|
2080
2152
|
let line;
|
|
2081
2153
|
if (element.shape === LineShape.curve) {
|
|
2082
|
-
//TODO element.points 应为曲线拐点
|
|
2083
2154
|
line = PlaitBoard.getRoughSVG(board).curve(points, options);
|
|
2084
2155
|
}
|
|
2085
2156
|
else {
|
|
@@ -2142,7 +2213,7 @@ const transformPointToConnection = (board, point, hitElement) => {
|
|
|
2142
2213
|
const getHitConnectorPoint = (movingPoint, hitElement, rectangle) => {
|
|
2143
2214
|
const shape = getShape(hitElement);
|
|
2144
2215
|
const connector = getEngine(shape).getConnectorPoints(rectangle);
|
|
2145
|
-
const points = getPointsByCenterPoint(movingPoint,
|
|
2216
|
+
const points = getPointsByCenterPoint(movingPoint, 10, 10);
|
|
2146
2217
|
const pointRectangle = getRectangleByPoints(points);
|
|
2147
2218
|
return connector.find(point => {
|
|
2148
2219
|
return RectangleClient.isHit(pointRectangle, RectangleClient.toRectangleClient([point, point]));
|
|
@@ -2223,8 +2294,15 @@ const handleLineCreating = (board, lineShape, startPoint, movingPoint, sourceEle
|
|
|
2223
2294
|
const connection = sourceElement ? transformPointToConnection(board, startPoint, sourceElement) : undefined;
|
|
2224
2295
|
const targetBoundId = hitElement ? hitElement.id : undefined;
|
|
2225
2296
|
const lineGenerator = new LineShapeGenerator(board);
|
|
2226
|
-
const
|
|
2227
|
-
|
|
2297
|
+
const memorizedLatest = getLineMemorizedLatest();
|
|
2298
|
+
let sourceMarker, targetMarker;
|
|
2299
|
+
sourceMarker = memorizedLatest.source;
|
|
2300
|
+
targetMarker = memorizedLatest.target;
|
|
2301
|
+
sourceMarker && delete memorizedLatest.source;
|
|
2302
|
+
targetMarker && delete memorizedLatest.target;
|
|
2303
|
+
const temporaryLineElement = createLineElement(lineShape, [startPoint, movingPoint], { marker: sourceMarker || LineMarkerType.none, connection: connection, boundId: sourceElement?.id }, { marker: targetMarker || LineMarkerType.arrow, connection: targetConnection, boundId: targetBoundId }, [], {
|
|
2304
|
+
strokeWidth: DefaultLineStyle.strokeWidth,
|
|
2305
|
+
...memorizedLatest
|
|
2228
2306
|
});
|
|
2229
2307
|
const linePoints = getLinePoints(board, temporaryLineElement);
|
|
2230
2308
|
const otherPoint = linePoints[0];
|
|
@@ -2392,6 +2470,7 @@ var MemorizeKey;
|
|
|
2392
2470
|
(function (MemorizeKey) {
|
|
2393
2471
|
MemorizeKey["basicShape"] = "basicShape";
|
|
2394
2472
|
MemorizeKey["flowchart"] = "flowchart";
|
|
2473
|
+
MemorizeKey["text"] = "text";
|
|
2395
2474
|
MemorizeKey["line"] = "line";
|
|
2396
2475
|
})(MemorizeKey || (MemorizeKey = {}));
|
|
2397
2476
|
|
|
@@ -2419,7 +2498,7 @@ const PlaitDrawElement = {
|
|
|
2419
2498
|
isShape: (value) => {
|
|
2420
2499
|
return PlaitDrawElement.isImage(value) || PlaitDrawElement.isGeometry(value);
|
|
2421
2500
|
},
|
|
2422
|
-
|
|
2501
|
+
isBasicShape: (value) => {
|
|
2423
2502
|
return Object.keys(BasicShapes).includes(value.shape);
|
|
2424
2503
|
},
|
|
2425
2504
|
isFlowchart: (value) => {
|
|
@@ -2427,7 +2506,7 @@ const PlaitDrawElement = {
|
|
|
2427
2506
|
}
|
|
2428
2507
|
};
|
|
2429
2508
|
|
|
2430
|
-
class
|
|
2509
|
+
class LineAutoCompleteGenerator extends Generator {
|
|
2431
2510
|
constructor(board) {
|
|
2432
2511
|
super(board);
|
|
2433
2512
|
this.board = board;
|
|
@@ -2446,18 +2525,18 @@ class AutoCompleteGenerator extends Generator {
|
|
|
2446
2525
|
this.autoCompleteG = createG();
|
|
2447
2526
|
const middlePoints = getAutoCompletePoints(element);
|
|
2448
2527
|
middlePoints.forEach((point, index) => {
|
|
2449
|
-
const circle = drawCircle(PlaitBoard.getRoughSVG(this.board), point,
|
|
2528
|
+
const circle = drawCircle(PlaitBoard.getRoughSVG(this.board), point, LINE_AUTO_COMPLETE_DIAMETER, {
|
|
2450
2529
|
stroke: 'none',
|
|
2451
|
-
fill:
|
|
2530
|
+
fill: RgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_OPACITY),
|
|
2452
2531
|
fillStyle: 'solid'
|
|
2453
2532
|
});
|
|
2454
|
-
circle.classList.add(`
|
|
2533
|
+
circle.classList.add(`line-auto-complete-${index}`);
|
|
2455
2534
|
this.autoCompleteG.appendChild(circle);
|
|
2456
2535
|
});
|
|
2457
2536
|
return this.autoCompleteG;
|
|
2458
2537
|
}
|
|
2459
2538
|
removeAutoCompleteG(index) {
|
|
2460
|
-
this.hoverElement = this.autoCompleteG.querySelector(`.
|
|
2539
|
+
this.hoverElement = this.autoCompleteG.querySelector(`.line-auto-complete-${index}`);
|
|
2461
2540
|
this.hoverElement.style.visibility = 'hidden';
|
|
2462
2541
|
}
|
|
2463
2542
|
recoverAutoCompleteG() {
|
|
@@ -2509,7 +2588,7 @@ class GeometryComponent extends CommonPluginElement {
|
|
|
2509
2588
|
return selectedElements.length === 1 && !isSelectionMoving(this.board);
|
|
2510
2589
|
}
|
|
2511
2590
|
});
|
|
2512
|
-
this.
|
|
2591
|
+
this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
|
|
2513
2592
|
this.shapeGenerator = new GeometryShapeGenerator(this.board);
|
|
2514
2593
|
this.initializeTextManage();
|
|
2515
2594
|
}
|
|
@@ -2517,30 +2596,36 @@ class GeometryComponent extends CommonPluginElement {
|
|
|
2517
2596
|
super.ngOnInit();
|
|
2518
2597
|
this.initializeGenerator();
|
|
2519
2598
|
this.shapeGenerator.processDrawing(this.element, this.g);
|
|
2520
|
-
this.activeGenerator.processDrawing(this.element, this.
|
|
2521
|
-
this.
|
|
2599
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2600
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
2601
|
+
selected: this.selected
|
|
2602
|
+
});
|
|
2522
2603
|
this.drawText();
|
|
2523
2604
|
}
|
|
2524
2605
|
onContextChanged(value, previous) {
|
|
2525
2606
|
const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
|
|
2526
2607
|
if (value.element !== previous.element || isChangeTheme) {
|
|
2527
2608
|
this.shapeGenerator.processDrawing(this.element, this.g);
|
|
2528
|
-
this.activeGenerator.processDrawing(this.element, this.
|
|
2529
|
-
this.
|
|
2609
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2610
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
2611
|
+
selected: this.selected
|
|
2612
|
+
});
|
|
2530
2613
|
this.updateText();
|
|
2531
2614
|
}
|
|
2532
2615
|
else {
|
|
2533
2616
|
const hasSameSelected = value.selected === previous.selected;
|
|
2534
2617
|
const hasSameHandleState = this.activeGenerator.options.hasResizeHandle() === this.activeGenerator.hasResizeHandle;
|
|
2535
2618
|
if (!hasSameSelected || !hasSameHandleState) {
|
|
2536
|
-
this.activeGenerator.processDrawing(this.element, this.
|
|
2537
|
-
this.
|
|
2619
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2620
|
+
this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
2621
|
+
selected: this.selected
|
|
2622
|
+
});
|
|
2538
2623
|
}
|
|
2539
2624
|
}
|
|
2540
2625
|
}
|
|
2541
2626
|
editText() {
|
|
2542
2627
|
this.textManage.edit();
|
|
2543
|
-
this.activeGenerator.processDrawing(this.element, this.
|
|
2628
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2544
2629
|
}
|
|
2545
2630
|
drawText() {
|
|
2546
2631
|
this.textManage.draw(this.element.text);
|
|
@@ -2569,6 +2654,7 @@ class GeometryComponent extends CommonPluginElement {
|
|
|
2569
2654
|
else {
|
|
2570
2655
|
DrawTransforms.setTextSize(this.board, this.element, width, height);
|
|
2571
2656
|
}
|
|
2657
|
+
textManageRef.operations && memorizeLatestText(this.element, textManageRef.operations);
|
|
2572
2658
|
},
|
|
2573
2659
|
getMaxWidth: () => {
|
|
2574
2660
|
let width = getTextRectangle(this.element).width;
|
|
@@ -2587,6 +2673,8 @@ class GeometryComponent extends CommonPluginElement {
|
|
|
2587
2673
|
this.textManage.destroy();
|
|
2588
2674
|
this.destroy$.next();
|
|
2589
2675
|
this.destroy$.complete();
|
|
2676
|
+
this.activeGenerator.destroy();
|
|
2677
|
+
this.lineAutoCompleteGenerator;
|
|
2590
2678
|
}
|
|
2591
2679
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GeometryComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2592
2680
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: GeometryComponent, isStandalone: true, selector: "plait-draw-geometry", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
@@ -2602,10 +2690,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
2602
2690
|
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; } });
|
|
2603
2691
|
|
|
2604
2692
|
class LineActiveGenerator extends Generator {
|
|
2605
|
-
constructor() {
|
|
2606
|
-
super(...arguments);
|
|
2607
|
-
this.hasResizeHandle = false;
|
|
2608
|
-
}
|
|
2609
2693
|
canDraw(element, data) {
|
|
2610
2694
|
if (data.selected) {
|
|
2611
2695
|
return true;
|
|
@@ -2616,7 +2700,9 @@ class LineActiveGenerator extends Generator {
|
|
|
2616
2700
|
}
|
|
2617
2701
|
draw(element, data) {
|
|
2618
2702
|
const activeG = createG();
|
|
2619
|
-
|
|
2703
|
+
const selectedElements = getSelectedElements(this.board);
|
|
2704
|
+
const isSingleSelection = selectedElements.length === 1;
|
|
2705
|
+
if (isSingleSelection) {
|
|
2620
2706
|
activeG.classList.add('active');
|
|
2621
2707
|
activeG.classList.add('line-handle');
|
|
2622
2708
|
const points = PlaitLine.getPoints(this.board, element);
|
|
@@ -2642,10 +2728,15 @@ class LineActiveGenerator extends Generator {
|
|
|
2642
2728
|
else {
|
|
2643
2729
|
const points = getLinePoints(this.board, element);
|
|
2644
2730
|
const activeRectangle = getRectangleByPoints(points);
|
|
2731
|
+
let opacity = '0.5';
|
|
2732
|
+
if (activeRectangle.height === 0 || activeRectangle.width === 0) {
|
|
2733
|
+
opacity = '0.8';
|
|
2734
|
+
}
|
|
2645
2735
|
const strokeG = drawRectangle(this.board, activeRectangle, {
|
|
2646
2736
|
stroke: PRIMARY_COLOR,
|
|
2647
2737
|
strokeWidth: DefaultGeometryActiveStyle.selectionStrokeWidth
|
|
2648
2738
|
});
|
|
2739
|
+
strokeG.style.opacity = opacity;
|
|
2649
2740
|
activeG.appendChild(strokeG);
|
|
2650
2741
|
}
|
|
2651
2742
|
return activeG;
|
|
@@ -2730,23 +2821,18 @@ class LineComponent extends PlaitPluginElementComponent {
|
|
|
2730
2821
|
this.updateText(previous.element.texts, value.element.texts);
|
|
2731
2822
|
this.updateTextRectangle();
|
|
2732
2823
|
}
|
|
2824
|
+
else {
|
|
2825
|
+
const hasSameSelected = value.selected === previous.selected;
|
|
2826
|
+
if (!hasSameSelected || (value.selected && isSelectionMoving(this.board))) {
|
|
2827
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2733
2830
|
if (isBoundedElementsChanged) {
|
|
2734
2831
|
this.shapeGenerator.processDrawing(this.element, this.g);
|
|
2735
2832
|
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2736
2833
|
this.updateTextRectangle();
|
|
2737
2834
|
return;
|
|
2738
2835
|
}
|
|
2739
|
-
if (!isSelectionMoving(this.board)) {
|
|
2740
|
-
this.activeGenerator.hasResizeHandle = this.hasResizeHandle();
|
|
2741
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
hasResizeHandle() {
|
|
2745
|
-
const selectedElements = getSelectedElements(this.board);
|
|
2746
|
-
if (PlaitBoard.hasBeenTextEditing(this.board) && PlaitDrawElement.isText(this.element)) {
|
|
2747
|
-
return false;
|
|
2748
|
-
}
|
|
2749
|
-
return selectedElements.length === 1 && !isSelectionMoving(this.board);
|
|
2750
2836
|
}
|
|
2751
2837
|
initializeTextManages() {
|
|
2752
2838
|
if (this.element.texts?.length) {
|
|
@@ -2785,6 +2871,7 @@ class LineComponent extends PlaitPluginElementComponent {
|
|
|
2785
2871
|
height
|
|
2786
2872
|
});
|
|
2787
2873
|
DrawTransforms.setLineTexts(this.board, this.element, texts);
|
|
2874
|
+
textManageRef.operations && memorizeLatestText(this.element, textManageRef.operations);
|
|
2788
2875
|
},
|
|
2789
2876
|
getMaxWidth: () => GeometryThreshold.defaultTextMaxWidth
|
|
2790
2877
|
});
|
|
@@ -2838,7 +2925,8 @@ const withDrawHotkey = (board) => {
|
|
|
2838
2925
|
const selectedElements = getSelectedElements(board);
|
|
2839
2926
|
const isSingleSelection = selectedElements.length === 1;
|
|
2840
2927
|
const targetElement = selectedElements[0];
|
|
2841
|
-
if (!
|
|
2928
|
+
if (!PlaitBoard.isReadonly(board) &&
|
|
2929
|
+
!isVirtualKey(event) &&
|
|
2842
2930
|
!isDelete(event) &&
|
|
2843
2931
|
!isSpaceHotkey(event) &&
|
|
2844
2932
|
isSingleSelection &&
|
|
@@ -2852,7 +2940,7 @@ const withDrawHotkey = (board) => {
|
|
|
2852
2940
|
board.dblclick = (event) => {
|
|
2853
2941
|
event.preventDefault();
|
|
2854
2942
|
const geometries = getSelectedGeometryElements(board);
|
|
2855
|
-
if (geometries.length === 1) {
|
|
2943
|
+
if (!PlaitBoard.isReadonly(board) && geometries.length === 1) {
|
|
2856
2944
|
const component = PlaitElement.getComponent(geometries[0]);
|
|
2857
2945
|
component.editText();
|
|
2858
2946
|
}
|
|
@@ -2996,7 +3084,7 @@ const withLineCreateByDraw = (board) => {
|
|
|
2996
3084
|
board.pointerDown = (event) => {
|
|
2997
3085
|
const linePointers = getLinePointers();
|
|
2998
3086
|
const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
|
|
2999
|
-
if (isLinePointer && isDrawingMode(board)) {
|
|
3087
|
+
if (!PlaitBoard.isReadonly(board) && isLinePointer && isDrawingMode(board)) {
|
|
3000
3088
|
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3001
3089
|
start = point;
|
|
3002
3090
|
const hitElement = getHitOutlineGeometry(board, point, REACTION_MARGIN);
|
|
@@ -3224,7 +3312,7 @@ const withLineResize = (board) => {
|
|
|
3224
3312
|
if (points.length === 2) {
|
|
3225
3313
|
let movingPoint = points[pointIndex];
|
|
3226
3314
|
const drawPoints = getLinePoints(board, resizeRef.element);
|
|
3227
|
-
const index = pointIndex === 0 ? drawPoints.length - 1 :
|
|
3315
|
+
const index = pointIndex === 0 ? drawPoints.length - 1 : 0;
|
|
3228
3316
|
const otherPoint = drawPoints[index];
|
|
3229
3317
|
points[pointIndex] = alignPoints(otherPoint, movingPoint);
|
|
3230
3318
|
}
|
|
@@ -3248,6 +3336,10 @@ const withLineBoundReaction = (board) => {
|
|
|
3248
3336
|
let boundShapeG = null;
|
|
3249
3337
|
board.pointerMove = (event) => {
|
|
3250
3338
|
boundShapeG?.remove();
|
|
3339
|
+
if (PlaitBoard.isReadonly(board)) {
|
|
3340
|
+
pointerMove(event);
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3251
3343
|
const linePointers = Object.keys(LineShape);
|
|
3252
3344
|
const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
|
|
3253
3345
|
const movingPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
@@ -3288,32 +3380,34 @@ const withLineBoundReaction = (board) => {
|
|
|
3288
3380
|
const withLineText = (board) => {
|
|
3289
3381
|
const { dblclick } = board;
|
|
3290
3382
|
board.dblclick = (event) => {
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3383
|
+
if (!PlaitBoard.isReadonly(board)) {
|
|
3384
|
+
const clickPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3385
|
+
const hitTarget = getHitElementByPoint(board, clickPoint, (element) => {
|
|
3386
|
+
return PlaitDrawElement.isLine(element);
|
|
3387
|
+
});
|
|
3388
|
+
if (hitTarget) {
|
|
3389
|
+
const points = getLinePoints(board, hitTarget);
|
|
3390
|
+
const point = getNearestPointBetweenPointAndSegments(clickPoint, points);
|
|
3391
|
+
const texts = hitTarget.texts?.length ? [...hitTarget.texts] : [];
|
|
3392
|
+
const textIndex = getHitLineTextIndex(board, hitTarget, clickPoint);
|
|
3393
|
+
const isHitText = isHitLineText(board, hitTarget, clickPoint);
|
|
3394
|
+
if (isHitText) {
|
|
3395
|
+
editHandle(board, hitTarget, textIndex);
|
|
3396
|
+
}
|
|
3397
|
+
else {
|
|
3398
|
+
const ratio = getRatioByPoint(points, point);
|
|
3399
|
+
texts.push({
|
|
3400
|
+
text: buildText('文本'),
|
|
3401
|
+
position: ratio,
|
|
3402
|
+
width: 28,
|
|
3403
|
+
height: 20
|
|
3404
|
+
});
|
|
3405
|
+
DrawTransforms.setLineTexts(board, hitTarget, texts);
|
|
3406
|
+
setTimeout(() => {
|
|
3407
|
+
const hitComponent = PlaitElement.getComponent(hitTarget);
|
|
3408
|
+
editHandle(board, hitTarget, hitComponent.textManages.length - 1, true);
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3317
3411
|
}
|
|
3318
3412
|
}
|
|
3319
3413
|
dblclick(event);
|
|
@@ -3399,31 +3493,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
3399
3493
|
}]
|
|
3400
3494
|
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; } });
|
|
3401
3495
|
|
|
3402
|
-
const
|
|
3496
|
+
const withLineAutoCompleteReaction = (board) => {
|
|
3403
3497
|
const { pointerMove } = board;
|
|
3404
3498
|
let reactionG = null;
|
|
3405
3499
|
board.pointerMove = (event) => {
|
|
3406
3500
|
reactionG?.remove();
|
|
3407
|
-
|
|
3408
|
-
pointerMove(event);
|
|
3409
|
-
return;
|
|
3410
|
-
}
|
|
3501
|
+
PlaitBoard.getBoardContainer(board).classList.remove(CursorClass.crosshair);
|
|
3411
3502
|
const selectedElements = getSelectedDrawElements(board);
|
|
3412
3503
|
const movingPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3413
|
-
if (selectedElements.length === 1 && PlaitDrawElement.isGeometry(selectedElements[0])) {
|
|
3504
|
+
if (!PlaitBoard.isReadonly(board) && !isSelectionMoving(board) && selectedElements.length === 1 && PlaitDrawElement.isGeometry(selectedElements[0])) {
|
|
3414
3505
|
const points = getAutoCompletePoints(selectedElements[0]);
|
|
3415
3506
|
const hitIndex = getHitIndexOfAutoCompletePoint(movingPoint, points);
|
|
3416
3507
|
const hitPoint = points[hitIndex];
|
|
3417
3508
|
const component = PlaitElement.getComponent(selectedElements[0]);
|
|
3418
|
-
component.
|
|
3509
|
+
component.lineAutoCompleteGenerator.recoverAutoCompleteG();
|
|
3419
3510
|
if (hitPoint) {
|
|
3420
|
-
component.
|
|
3421
|
-
reactionG = drawCircle(PlaitBoard.getRoughSVG(board), hitPoint,
|
|
3511
|
+
component.lineAutoCompleteGenerator.removeAutoCompleteG(hitIndex);
|
|
3512
|
+
reactionG = drawCircle(PlaitBoard.getRoughSVG(board), hitPoint, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, {
|
|
3422
3513
|
stroke: 'none',
|
|
3423
|
-
fill:
|
|
3514
|
+
fill: RgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_HOVERED_OPACITY),
|
|
3424
3515
|
fillStyle: 'solid'
|
|
3425
3516
|
});
|
|
3426
3517
|
PlaitBoard.getElementActiveHost(board).append(reactionG);
|
|
3518
|
+
PlaitBoard.getBoardContainer(board).classList.add(CursorClass.crosshair);
|
|
3427
3519
|
}
|
|
3428
3520
|
}
|
|
3429
3521
|
pointerMove(event);
|
|
@@ -3431,10 +3523,9 @@ const withAutoCompleteReaction = (board) => {
|
|
|
3431
3523
|
return board;
|
|
3432
3524
|
};
|
|
3433
3525
|
|
|
3434
|
-
const
|
|
3435
|
-
const
|
|
3526
|
+
const withLineAutoCompletePluginKey = 'plait-line-auto-complete-plugin-key';
|
|
3527
|
+
const withLineAutoComplete = (board) => {
|
|
3436
3528
|
const { pointerDown, pointerMove, pointerUp } = board;
|
|
3437
|
-
const tolerance = 3;
|
|
3438
3529
|
let startPoint = null;
|
|
3439
3530
|
let lineShapeG = null;
|
|
3440
3531
|
let sourceElement;
|
|
@@ -3442,7 +3533,7 @@ const withAutoComplete = (board) => {
|
|
|
3442
3533
|
board.pointerDown = (event) => {
|
|
3443
3534
|
const selectedElements = getSelectedDrawElements(board);
|
|
3444
3535
|
const clickPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3445
|
-
if (selectedElements.length === 1 && PlaitDrawElement.isGeometry(selectedElements[0])) {
|
|
3536
|
+
if (!PlaitBoard.isReadonly(board) && selectedElements.length === 1 && PlaitDrawElement.isGeometry(selectedElements[0])) {
|
|
3446
3537
|
const points = getAutoCompletePoints(selectedElements[0]);
|
|
3447
3538
|
const index = getHitIndexOfAutoCompletePoint(clickPoint, points);
|
|
3448
3539
|
const hitPoint = points[index];
|
|
@@ -3461,7 +3552,7 @@ const withAutoComplete = (board) => {
|
|
|
3461
3552
|
let movingPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3462
3553
|
if (startPoint && sourceElement) {
|
|
3463
3554
|
const distance = distanceBetweenPointAndPoint(...movingPoint, ...startPoint);
|
|
3464
|
-
if (distance >
|
|
3555
|
+
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
3465
3556
|
temporaryElement = handleLineCreating(board, LineShape.elbow, startPoint, movingPoint, sourceElement, lineShapeG);
|
|
3466
3557
|
}
|
|
3467
3558
|
}
|
|
@@ -3472,7 +3563,7 @@ const withAutoComplete = (board) => {
|
|
|
3472
3563
|
Transforms.insertNode(board, temporaryElement, [board.children.length]);
|
|
3473
3564
|
clearSelectedElement(board);
|
|
3474
3565
|
addSelectedElement(board, temporaryElement);
|
|
3475
|
-
const afterComplete = board.getPluginOptions(
|
|
3566
|
+
const afterComplete = board.getPluginOptions(withLineAutoCompletePluginKey)
|
|
3476
3567
|
?.afterComplete;
|
|
3477
3568
|
afterComplete && afterComplete(temporaryElement);
|
|
3478
3569
|
}
|
|
@@ -3558,12 +3649,12 @@ const withDraw = (board) => {
|
|
|
3558
3649
|
}
|
|
3559
3650
|
return isAlign(element);
|
|
3560
3651
|
};
|
|
3561
|
-
return
|
|
3652
|
+
return withLineAutoCompleteReaction(withLineText(withLineBoundReaction(withLineResize(withGeometryResize(withLineCreateByDraw(withLineAutoComplete(withGeometryCreateByDrag(withGeometryCreateByDrawing(withDrawFragment(withDrawHotkey(board)))))))))));
|
|
3562
3653
|
};
|
|
3563
3654
|
|
|
3564
3655
|
/**
|
|
3565
3656
|
* Generated bundle index. Do not edit.
|
|
3566
3657
|
*/
|
|
3567
3658
|
|
|
3568
|
-
export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultBasicShapeProperty, DefaultConnectorProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultGeometryActiveStyle, DefaultGeometryStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultTextProperty, DrawThemeColors, DrawTransforms, FlowchartSymbols, GeometryComponent, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, MemorizeKey, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, REACTION_MARGIN, ShapeDefaultSpace, StrokeStyle, alignPoints, createDefaultFlowchart, createGeometryElement, createLineElement, drawBoundMask, drawGeometry, drawLine, getAutoCompletePoints, getBasicPointers, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultFlowchartProperty, getDrawDefaultStrokeColor, getEdgeOnPolygonByPoint, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryPointers, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitLineTextIndex, getLineDashByElement, getLineHandleRefPair, getLinePointers, getLinePoints, getLineTextRectangle, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTextRectangle, getVectorByConnection, handleLineCreating, isHitDrawElement, isHitLineText, isHitPolyLine, isRectangleHitDrawElement, isTextExceedingBounds, transformOpsToPoints, transformPointToConnection, withDraw };
|
|
3659
|
+
export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultBasicShapeProperty, DefaultConnectorProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultGeometryActiveStyle, DefaultGeometryStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultTextProperty, DrawThemeColors, DrawTransforms, FlowchartSymbols, GeometryComponent, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, MemorizeKey, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, REACTION_MARGIN, ShapeDefaultSpace, StrokeStyle, alignPoints, createDefaultFlowchart, createGeometryElement, createLineElement, drawBoundMask, drawGeometry, drawLine, getAutoCompletePoints, getBasicPointers, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultFlowchartProperty, getDrawDefaultStrokeColor, getEdgeOnPolygonByPoint, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryPointers, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitLineTextIndex, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTextRectangle, getVectorByConnection, handleLineCreating, isHitDrawElement, isHitLineText, isHitPolyLine, isRectangleHitDrawElement, isTextExceedingBounds, memorizeLatestShape, memorizeLatestText, transformOpsToPoints, transformPointToConnection, withDraw };
|
|
3569
3660
|
//# sourceMappingURL=plait-draw.mjs.map
|