@plait/draw 0.83.0 → 0.84.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/pointer.d.ts +1 -0
- package/fesm2022/plait-draw.mjs +502 -491
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/package.json +1 -1
- package/plugins/with-geometry-create.d.ts +0 -5
- package/utils/hit.d.ts +1 -1
- package/utils/shape.d.ts +5 -1
- package/utils/swimlane.d.ts +2 -1
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, createDebugGenerator, Point, createG, arrowPoints, createPath, distanceBetweenPointAndPoint, drawLinearPath, rotate, catmullRomFitting, PlaitBoard, setStrokeLinecap, findElements, createMask, createRect, getNearestPointBetweenPointAndArc, setPathStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, getI18nValue, toActiveRectangleFromViewBoxRectangle, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, getRectangleByElements,
|
|
2
|
-
import { DEFAULT_FILL, Alignment,
|
|
1
|
+
import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, createDebugGenerator, Point, createG, arrowPoints, createPath, distanceBetweenPointAndPoint, drawLinearPath, rotate, catmullRomFitting, PlaitBoard, setStrokeLinecap, findElements, createMask, createRect, getNearestPointBetweenPointAndArc, setPathStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, getI18nValue, SELECTION_RECTANGLE_CLASS_NAME, toActivePointFromViewBoxPoint, toActiveRectangleFromViewBoxRectangle, drawRectangle, isSelectionMoving, rgbaToHEX, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, getRectangleByElements, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, getEllipseTangentSlope, getVectorFromPointAndSlope, getNearestPointBetweenPointAndEllipse, isPointInEllipse, isPointInRoundRectangle, drawRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, getNearestPointBetweenPointAndDiscreteSegments, getNearestPointBetweenPointAndSegment, Path, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, toActivePoint, temporaryDisableSelection, toScreenPointFromActivePoint, PRESS_AND_MOVE_BUFFER, CursorClass, isHorizontalDirection, 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, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, Generator, getPointByVectorComponent, getStrokeLineDash, StrokeStyle, getPointOnPolyline, buildText, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, RESIZE_HANDLE_DIAMETER, drawPrimaryHandle, drawFillPrimaryHandle, PRIMARY_COLOR, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_SIZE, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, isCornerHandle, getIndexByResizeHandle, withResize, getSymmetricHandleIndex, getResizeHandlePointByIndex, drawHandle, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, CommonElementFlavour, createActiveGenerator, hasResizeHandle, ActiveGenerator, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, getDirectionByIndex, moveXOfPoint, getXDistanceBetweenPoint, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
|
|
3
3
|
import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
|
|
4
4
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
5
5
|
import { Editor, Node } from 'slate';
|
|
@@ -395,6 +395,9 @@ const getGeometryPointers = () => {
|
|
|
395
395
|
const getSwimlanePointers = () => {
|
|
396
396
|
return Object.keys(SwimlaneDrawSymbols);
|
|
397
397
|
};
|
|
398
|
+
const getSwimlaneShapes = () => {
|
|
399
|
+
return Object.keys(SwimlaneSymbols);
|
|
400
|
+
};
|
|
398
401
|
const getBasicPointers = () => {
|
|
399
402
|
return Object.keys(BasicShapes);
|
|
400
403
|
};
|
|
@@ -478,107 +481,6 @@ const LINE_AUTO_COMPLETE_HOVERED_DIAMETER = 12;
|
|
|
478
481
|
const LINE_ALIGN_TOLERANCE = 3;
|
|
479
482
|
const LINE_TEXT = '文本';
|
|
480
483
|
|
|
481
|
-
const getElementShape = (value) => {
|
|
482
|
-
if (PlaitDrawElement.isImage(value)) {
|
|
483
|
-
return BasicShapes.rectangle;
|
|
484
|
-
}
|
|
485
|
-
if (PlaitDrawElement.isTable(value)) {
|
|
486
|
-
return TableSymbols.table;
|
|
487
|
-
}
|
|
488
|
-
return value.shape;
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
const SHAPE_MAX_LENGTH = 6;
|
|
492
|
-
const memorizedShape = new WeakMap();
|
|
493
|
-
const getMemorizeKey = (element) => {
|
|
494
|
-
let key = '';
|
|
495
|
-
switch (true) {
|
|
496
|
-
case PlaitDrawElement.isText(element): {
|
|
497
|
-
key = MemorizeKey.text;
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
case PlaitDrawElement.isBasicShape(element): {
|
|
501
|
-
key = MemorizeKey.basicShape;
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
case PlaitDrawElement.isFlowchart(element): {
|
|
505
|
-
key = MemorizeKey.flowchart;
|
|
506
|
-
break;
|
|
507
|
-
}
|
|
508
|
-
case PlaitDrawElement.isArrowLine(element): {
|
|
509
|
-
key = MemorizeKey.arrowLine;
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
case PlaitDrawElement.isUML(element): {
|
|
513
|
-
key = MemorizeKey.UML;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return key;
|
|
517
|
-
};
|
|
518
|
-
const getLineMemorizedLatest = () => {
|
|
519
|
-
const properties = getMemorizedLatest(MemorizeKey.arrowLine);
|
|
520
|
-
return { ...properties } || {};
|
|
521
|
-
};
|
|
522
|
-
const getMemorizedLatestByPointer = (pointer) => {
|
|
523
|
-
let memorizeKey = '';
|
|
524
|
-
if (PlaitDrawElement.isBasicShape({ shape: pointer })) {
|
|
525
|
-
memorizeKey = pointer === BasicShapes.text ? MemorizeKey.text : MemorizeKey.basicShape;
|
|
526
|
-
}
|
|
527
|
-
else if (PlaitDrawElement.isUML({ shape: pointer })) {
|
|
528
|
-
memorizeKey = MemorizeKey.UML;
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
memorizeKey = MemorizeKey.flowchart;
|
|
532
|
-
}
|
|
533
|
-
const properties = { ...getMemorizedLatest(memorizeKey) } || {};
|
|
534
|
-
const textProperties = { ...properties.text } || {};
|
|
535
|
-
delete properties.text;
|
|
536
|
-
return { textProperties, geometryProperties: properties };
|
|
537
|
-
};
|
|
538
|
-
const memorizeLatestText = (element, operations) => {
|
|
539
|
-
const memorizeKey = getMemorizeKey(element);
|
|
540
|
-
let textMemory = getMemorizedLatest(memorizeKey)?.text || {};
|
|
541
|
-
const setNodeOperation = operations.find(operation => operation.type === 'set_node');
|
|
542
|
-
if (setNodeOperation) {
|
|
543
|
-
const { properties, newProperties } = setNodeOperation;
|
|
544
|
-
for (const key in newProperties) {
|
|
545
|
-
const value = newProperties[key];
|
|
546
|
-
if (value == null) {
|
|
547
|
-
delete textMemory[key];
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
textMemory[key] = value;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
for (const key in properties) {
|
|
554
|
-
if (!newProperties.hasOwnProperty(key)) {
|
|
555
|
-
delete textMemory[key];
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
memorizeLatest(memorizeKey, 'text', textMemory);
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
const memorizeLatestShape = (board, shape) => {
|
|
562
|
-
const shapes = memorizedShape.has(board) ? memorizedShape.get(board) : [];
|
|
563
|
-
const shapeIndex = shapes.indexOf(shape);
|
|
564
|
-
if (shape === BasicShapes.text || shapeIndex === 0) {
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
if (shapeIndex !== -1) {
|
|
568
|
-
shapes.splice(shapeIndex, 1);
|
|
569
|
-
}
|
|
570
|
-
else {
|
|
571
|
-
if (shapes.length === SHAPE_MAX_LENGTH) {
|
|
572
|
-
shapes.pop();
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
shapes.unshift(shape);
|
|
576
|
-
memorizedShape.set(board, shapes);
|
|
577
|
-
};
|
|
578
|
-
const getMemorizedLatestShape = (board) => {
|
|
579
|
-
return memorizedShape.get(board);
|
|
580
|
-
};
|
|
581
|
-
|
|
582
484
|
// TODO: 是否可以完全基于位置定位 TextManager,实现 line 和 多文本 geometry 统一
|
|
583
485
|
// 一个元素有多个文本时,单纯通过位置无法获取 TextManage,因此这里单独通过 Map 保存关键字 key 和 TextManage 的对应关系
|
|
584
486
|
// 1. 单文本元素 key 就是元素的 id
|
|
@@ -892,20 +794,95 @@ const getSelectedTableCellsEditor = (board) => {
|
|
|
892
794
|
return undefined;
|
|
893
795
|
};
|
|
894
796
|
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
797
|
+
const SHAPE_MAX_LENGTH = 6;
|
|
798
|
+
const memorizedShape = new WeakMap();
|
|
799
|
+
const getMemorizeKey = (element) => {
|
|
800
|
+
let key = '';
|
|
801
|
+
switch (true) {
|
|
802
|
+
case PlaitDrawElement.isText(element): {
|
|
803
|
+
key = MemorizeKey.text;
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
case PlaitDrawElement.isBasicShape(element): {
|
|
807
|
+
key = MemorizeKey.basicShape;
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
case PlaitDrawElement.isFlowchart(element): {
|
|
811
|
+
key = MemorizeKey.flowchart;
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
case PlaitDrawElement.isArrowLine(element): {
|
|
815
|
+
key = MemorizeKey.arrowLine;
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
case PlaitDrawElement.isUML(element): {
|
|
819
|
+
key = MemorizeKey.UML;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return key;
|
|
899
823
|
};
|
|
900
|
-
const
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
: DefaultDrawStyle.fill;
|
|
904
|
-
const fill = element.fill || defaultFill;
|
|
905
|
-
return fill;
|
|
824
|
+
const getLineMemorizedLatest = () => {
|
|
825
|
+
const properties = getMemorizedLatest(MemorizeKey.arrowLine);
|
|
826
|
+
return { ...properties } || {};
|
|
906
827
|
};
|
|
907
|
-
const
|
|
908
|
-
|
|
828
|
+
const getMemorizedLatestByPointer = (pointer) => {
|
|
829
|
+
let memorizeKey = '';
|
|
830
|
+
if (PlaitDrawElement.isBasicShape({ shape: pointer })) {
|
|
831
|
+
memorizeKey = pointer === BasicShapes.text ? MemorizeKey.text : MemorizeKey.basicShape;
|
|
832
|
+
}
|
|
833
|
+
else if (PlaitDrawElement.isUML({ shape: pointer })) {
|
|
834
|
+
memorizeKey = MemorizeKey.UML;
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
memorizeKey = MemorizeKey.flowchart;
|
|
838
|
+
}
|
|
839
|
+
const properties = { ...getMemorizedLatest(memorizeKey) } || {};
|
|
840
|
+
const textProperties = { ...properties.text } || {};
|
|
841
|
+
delete properties.text;
|
|
842
|
+
return { textProperties, geometryProperties: properties };
|
|
843
|
+
};
|
|
844
|
+
const memorizeLatestText = (element, operations) => {
|
|
845
|
+
const memorizeKey = getMemorizeKey(element);
|
|
846
|
+
let textMemory = getMemorizedLatest(memorizeKey)?.text || {};
|
|
847
|
+
const setNodeOperation = operations.find(operation => operation.type === 'set_node');
|
|
848
|
+
if (setNodeOperation) {
|
|
849
|
+
const { properties, newProperties } = setNodeOperation;
|
|
850
|
+
for (const key in newProperties) {
|
|
851
|
+
const value = newProperties[key];
|
|
852
|
+
if (value == null) {
|
|
853
|
+
delete textMemory[key];
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
textMemory[key] = value;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
for (const key in properties) {
|
|
860
|
+
if (!newProperties.hasOwnProperty(key)) {
|
|
861
|
+
delete textMemory[key];
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
memorizeLatest(memorizeKey, 'text', textMemory);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
const memorizeLatestShape = (board, shape) => {
|
|
868
|
+
const shapes = memorizedShape.has(board) ? memorizedShape.get(board) : [];
|
|
869
|
+
const shapeIndex = shapes.indexOf(shape);
|
|
870
|
+
if (shape === BasicShapes.text || shapeIndex === 0) {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
if (shapeIndex !== -1) {
|
|
874
|
+
shapes.splice(shapeIndex, 1);
|
|
875
|
+
}
|
|
876
|
+
else {
|
|
877
|
+
if (shapes.length === SHAPE_MAX_LENGTH) {
|
|
878
|
+
shapes.pop();
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
shapes.unshift(shape);
|
|
882
|
+
memorizedShape.set(board, shapes);
|
|
883
|
+
};
|
|
884
|
+
const getMemorizedLatestShape = (board) => {
|
|
885
|
+
return memorizedShape.get(board);
|
|
909
886
|
};
|
|
910
887
|
|
|
911
888
|
const debugKey$4 = 'debug:plait:line-mirror';
|
|
@@ -2245,43 +2222,360 @@ const getDefaultGeometryText = (board) => {
|
|
|
2245
2222
|
return getI18nValue(board, DrawI18nKey.geometryText, DefaultTextProperty.text);
|
|
2246
2223
|
};
|
|
2247
2224
|
|
|
2248
|
-
const
|
|
2249
|
-
const
|
|
2250
|
-
const
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
{
|
|
2268
|
-
id: idCreator()
|
|
2269
|
-
},
|
|
2270
|
-
{
|
|
2271
|
-
id: idCreator()
|
|
2272
|
-
}
|
|
2273
|
-
];
|
|
2274
|
-
columns = [
|
|
2275
|
-
{
|
|
2276
|
-
id: idCreator()
|
|
2277
|
-
}
|
|
2278
|
-
];
|
|
2225
|
+
const getStrokeColorByElement = (board, element) => {
|
|
2226
|
+
const defaultColor = getDrawDefaultStrokeColor(board.theme.themeColorMode);
|
|
2227
|
+
const strokeColor = element.strokeColor || defaultColor;
|
|
2228
|
+
return strokeColor;
|
|
2229
|
+
};
|
|
2230
|
+
const getFillByElement = (board, element) => {
|
|
2231
|
+
const defaultFill = PlaitDrawElement.isFlowchart(element) && isClosedDrawElement(element)
|
|
2232
|
+
? getFlowchartDefaultFill(board.theme.themeColorMode)
|
|
2233
|
+
: DefaultDrawStyle.fill;
|
|
2234
|
+
const fill = element.fill || defaultFill;
|
|
2235
|
+
return fill;
|
|
2236
|
+
};
|
|
2237
|
+
const getStrokeStyleByElement = (board, element) => {
|
|
2238
|
+
return element.strokeStyle || StrokeStyle.solid;
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2241
|
+
class GeometryShapeGenerator extends Generator {
|
|
2242
|
+
canDraw(element, data) {
|
|
2243
|
+
return true;
|
|
2279
2244
|
}
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2245
|
+
draw(element, data) {
|
|
2246
|
+
const rectangle = RectangleClient.getRectangleByPoints(element.points);
|
|
2247
|
+
const shape = element.shape;
|
|
2248
|
+
if (shape === BasicShapes.text) {
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
const fill = getFillByElement(this.board, element);
|
|
2252
|
+
const strokeWidth = getStrokeWidthByElement(element);
|
|
2253
|
+
const strokeColor = getStrokeColorByElement(this.board, element);
|
|
2254
|
+
const strokeStyle = getStrokeStyleByElement(this.board, element);
|
|
2255
|
+
const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
|
|
2256
|
+
return drawGeometry(this.board, RectangleClient.inflate(rectangle, -strokeWidth), shape, {
|
|
2257
|
+
stroke: strokeColor,
|
|
2258
|
+
strokeWidth,
|
|
2259
|
+
fill,
|
|
2260
|
+
strokeLineDash
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
function getMiddlePoints(board, element) {
|
|
2266
|
+
const result = [];
|
|
2267
|
+
const shape = element.shape;
|
|
2268
|
+
const hideBuffer = 10;
|
|
2269
|
+
if (shape === ArrowLineShape.straight) {
|
|
2270
|
+
const points = PlaitDrawElement.isArrowLine(element)
|
|
2271
|
+
? PlaitArrowLine.getPoints(board, element)
|
|
2272
|
+
: element.points;
|
|
2273
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
2274
|
+
const distance = distanceBetweenPointAndPoint(...points[i], ...points[i + 1]);
|
|
2275
|
+
if (distance < hideBuffer)
|
|
2276
|
+
continue;
|
|
2277
|
+
result.push([(points[i][0] + points[i + 1][0]) / 2, (points[i][1] + points[i + 1][1]) / 2]);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
if (shape === ArrowLineShape.curve) {
|
|
2281
|
+
const points = PlaitDrawElement.isArrowLine(element)
|
|
2282
|
+
? PlaitArrowLine.getPoints(board, element)
|
|
2283
|
+
: element.points;
|
|
2284
|
+
const pointsOnBezier = PlaitDrawElement.isArrowLine(element)
|
|
2285
|
+
? getCurvePoints(board, element)
|
|
2286
|
+
: getVectorLinePoints(board, element);
|
|
2287
|
+
if (points.length === 2) {
|
|
2288
|
+
const start = 0;
|
|
2289
|
+
const endIndex = pointsOnBezier.length - 1;
|
|
2290
|
+
const middleIndex = Math.round((start + endIndex) / 2);
|
|
2291
|
+
result.push(pointsOnBezier[middleIndex]);
|
|
2292
|
+
}
|
|
2293
|
+
else {
|
|
2294
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
2295
|
+
const startIndex = pointsOnBezier.findIndex(point => point[0] === points[i][0] && point[1] === points[i][1]);
|
|
2296
|
+
const endIndex = pointsOnBezier.findIndex(point => point[0] === points[i + 1][0] && point[1] === points[i + 1][1]);
|
|
2297
|
+
const middleIndex = Math.round((startIndex + endIndex) / 2);
|
|
2298
|
+
const distance = distanceBetweenPointAndPoint(...points[i], ...points[i + 1]);
|
|
2299
|
+
if (distance < hideBuffer)
|
|
2300
|
+
continue;
|
|
2301
|
+
result.push(pointsOnBezier[middleIndex]);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
if (shape === ArrowLineShape.elbow) {
|
|
2306
|
+
const renderPoints = getElbowPoints(board, element);
|
|
2307
|
+
const options = getElbowLineRouteOptions(board, element);
|
|
2308
|
+
if (!isUseDefaultOrthogonalRoute(element, options)) {
|
|
2309
|
+
const [nextSourcePoint, nextTargetPoint] = getNextSourceAndTargetPoints(board, element);
|
|
2310
|
+
for (let i = 0; i < renderPoints.length - 1; i++) {
|
|
2311
|
+
if ((i == 0 && Point.isEquals(renderPoints[i + 1], nextSourcePoint)) ||
|
|
2312
|
+
(i === renderPoints.length - 2 && Point.isEquals(renderPoints[renderPoints.length - 2], nextTargetPoint))) {
|
|
2313
|
+
continue;
|
|
2314
|
+
}
|
|
2315
|
+
const [currentX, currentY] = renderPoints[i];
|
|
2316
|
+
const [nextX, nextY] = renderPoints[i + 1];
|
|
2317
|
+
const middlePoint = [(currentX + nextX) / 2, (currentY + nextY) / 2];
|
|
2318
|
+
result.push(middlePoint);
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
return result;
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
var LineResizeHandle;
|
|
2326
|
+
(function (LineResizeHandle) {
|
|
2327
|
+
LineResizeHandle["source"] = "source";
|
|
2328
|
+
LineResizeHandle["target"] = "target";
|
|
2329
|
+
LineResizeHandle["addHandle"] = "addHandle";
|
|
2330
|
+
})(LineResizeHandle || (LineResizeHandle = {}));
|
|
2331
|
+
const getHitLineResizeHandleRef = (board, element, point) => {
|
|
2332
|
+
let dataPoints = PlaitDrawElement.isArrowLine(element) ? PlaitArrowLine.getPoints(board, element) : element.points;
|
|
2333
|
+
const index = getHitPointIndex(dataPoints, point);
|
|
2334
|
+
if (index !== -1) {
|
|
2335
|
+
const handleIndex = index;
|
|
2336
|
+
if (index === 0) {
|
|
2337
|
+
return { handle: LineResizeHandle.source, handleIndex };
|
|
2338
|
+
}
|
|
2339
|
+
if (index === dataPoints.length - 1) {
|
|
2340
|
+
return { handle: LineResizeHandle.target, handleIndex };
|
|
2341
|
+
}
|
|
2342
|
+
// elbow line, data points only verify source connection point and target connection point
|
|
2343
|
+
if (element.shape !== ArrowLineShape.elbow) {
|
|
2344
|
+
return { handleIndex };
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
const middlePoints = getMiddlePoints(board, element);
|
|
2348
|
+
const indexOfMiddlePoints = getHitPointIndex(middlePoints, point);
|
|
2349
|
+
if (indexOfMiddlePoints !== -1) {
|
|
2350
|
+
return {
|
|
2351
|
+
handle: LineResizeHandle.addHandle,
|
|
2352
|
+
handleIndex: indexOfMiddlePoints
|
|
2353
|
+
};
|
|
2354
|
+
}
|
|
2355
|
+
return undefined;
|
|
2356
|
+
};
|
|
2357
|
+
function getHitPointIndex(points, movingPoint) {
|
|
2358
|
+
const rectangles = points.map(point => {
|
|
2359
|
+
return {
|
|
2360
|
+
x: point[0] - RESIZE_HANDLE_DIAMETER / 2,
|
|
2361
|
+
y: point[1] - RESIZE_HANDLE_DIAMETER / 2,
|
|
2362
|
+
width: RESIZE_HANDLE_DIAMETER,
|
|
2363
|
+
height: RESIZE_HANDLE_DIAMETER
|
|
2364
|
+
};
|
|
2365
|
+
});
|
|
2366
|
+
const rectangle = rectangles.find(rectangle => {
|
|
2367
|
+
return RectangleClient.isHit(RectangleClient.getRectangleByPoints([movingPoint, movingPoint]), rectangle);
|
|
2368
|
+
});
|
|
2369
|
+
return rectangle ? rectangles.indexOf(rectangle) : -1;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
class LineActiveGenerator extends Generator {
|
|
2373
|
+
constructor(board, options = { active: true }) {
|
|
2374
|
+
super(board, options);
|
|
2375
|
+
this.board = board;
|
|
2376
|
+
this.onlySelectedCurrentLine = false;
|
|
2377
|
+
}
|
|
2378
|
+
canDraw(element, data) {
|
|
2379
|
+
if (data.selected) {
|
|
2380
|
+
return true;
|
|
2381
|
+
}
|
|
2382
|
+
else {
|
|
2383
|
+
return false;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
draw(element, data) {
|
|
2387
|
+
const activeG = createG();
|
|
2388
|
+
const selectedElements = getSelectedElements(this.board);
|
|
2389
|
+
this.onlySelectedCurrentLine = selectedElements.length === 1;
|
|
2390
|
+
if (this.onlySelectedCurrentLine) {
|
|
2391
|
+
activeG.classList.add(SELECTION_RECTANGLE_CLASS_NAME);
|
|
2392
|
+
const points = PlaitDrawElement.isArrowLine(element) ? PlaitArrowLine.getPoints(this.board, element) : element.points;
|
|
2393
|
+
let updatePoints = [...points];
|
|
2394
|
+
let elbowNextRenderPoints = [];
|
|
2395
|
+
if (element.shape === ArrowLineShape.elbow) {
|
|
2396
|
+
updatePoints = points.slice(0, 1).concat(points.slice(-1));
|
|
2397
|
+
elbowNextRenderPoints = getNextRenderPoints(this.board, element, data.linePoints);
|
|
2398
|
+
}
|
|
2399
|
+
const activePoints = updatePoints.map((point) => toActivePointFromViewBoxPoint(this.board, point));
|
|
2400
|
+
activePoints.forEach((point) => {
|
|
2401
|
+
const updateHandle = drawPrimaryHandle(this.board, point);
|
|
2402
|
+
activeG.appendChild(updateHandle);
|
|
2403
|
+
});
|
|
2404
|
+
const middlePoints = getMiddlePoints(this.board, element);
|
|
2405
|
+
const activeMiddlePoints = middlePoints.map((point) => toActivePointFromViewBoxPoint(this.board, point));
|
|
2406
|
+
if (!PlaitBoard.hasBeenTextEditing(this.board)) {
|
|
2407
|
+
for (let i = 0; i < activeMiddlePoints.length; i++) {
|
|
2408
|
+
const point = activeMiddlePoints[i];
|
|
2409
|
+
if (element.shape === ArrowLineShape.elbow && elbowNextRenderPoints.length) {
|
|
2410
|
+
const handleIndex = getHitPointIndex(activeMiddlePoints, point);
|
|
2411
|
+
const isUpdateHandleIndex = isUpdatedHandleIndex(this.board, element, [...points], elbowNextRenderPoints, handleIndex);
|
|
2412
|
+
if (isUpdateHandleIndex) {
|
|
2413
|
+
const updateHandle = drawPrimaryHandle(this.board, point);
|
|
2414
|
+
activeG.appendChild(updateHandle);
|
|
2415
|
+
continue;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
const circle = drawFillPrimaryHandle(this.board, point);
|
|
2419
|
+
activeG.appendChild(circle);
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
else {
|
|
2424
|
+
const rectangle = this.board.getRectangle(element);
|
|
2425
|
+
if (rectangle) {
|
|
2426
|
+
const activeRectangle = toActiveRectangleFromViewBoxRectangle(this.board, rectangle);
|
|
2427
|
+
let opacity = '0.5';
|
|
2428
|
+
if (activeRectangle.height === 0 || activeRectangle.width === 0) {
|
|
2429
|
+
opacity = '0.8';
|
|
2430
|
+
}
|
|
2431
|
+
const strokeG = drawRectangle(this.board, activeRectangle, {
|
|
2432
|
+
stroke: PRIMARY_COLOR,
|
|
2433
|
+
strokeWidth: DefaultDrawActiveStyle.selectionStrokeWidth
|
|
2434
|
+
});
|
|
2435
|
+
strokeG.style.opacity = opacity;
|
|
2436
|
+
activeG.appendChild(strokeG);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
return activeG;
|
|
2440
|
+
}
|
|
2441
|
+
needUpdate() {
|
|
2442
|
+
const selectedElements = getSelectedElements(this.board);
|
|
2443
|
+
const onlySelectedCurrentLine = selectedElements.length === 1;
|
|
2444
|
+
return onlySelectedCurrentLine !== this.onlySelectedCurrentLine;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
class ArrowLineAutoCompleteGenerator extends Generator {
|
|
2449
|
+
static { this.key = 'line-auto-complete-generator'; }
|
|
2450
|
+
constructor(board) {
|
|
2451
|
+
super(board, { active: true });
|
|
2452
|
+
this.board = board;
|
|
2453
|
+
this.hoverElement = null;
|
|
2454
|
+
}
|
|
2455
|
+
canDraw(element, data) {
|
|
2456
|
+
const selectedElements = getSelectedElements(this.board);
|
|
2457
|
+
if (data.selected && selectedElements.length === 1 && !isSelectionMoving(this.board)) {
|
|
2458
|
+
return true;
|
|
2459
|
+
}
|
|
2460
|
+
else {
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
draw(element, data) {
|
|
2465
|
+
this.autoCompleteG = createG();
|
|
2466
|
+
const middlePoints = getAutoCompletePoints(this.board, element, true);
|
|
2467
|
+
middlePoints.forEach((point, index) => {
|
|
2468
|
+
const circle = drawCircle(PlaitBoard.getRoughSVG(this.board), point, LINE_AUTO_COMPLETE_DIAMETER, {
|
|
2469
|
+
stroke: 'none',
|
|
2470
|
+
fill: rgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_OPACITY),
|
|
2471
|
+
fillStyle: 'solid'
|
|
2472
|
+
});
|
|
2473
|
+
circle.classList.add(`line-auto-complete-${index}`);
|
|
2474
|
+
this.autoCompleteG.appendChild(circle);
|
|
2475
|
+
});
|
|
2476
|
+
return this.autoCompleteG;
|
|
2477
|
+
}
|
|
2478
|
+
removeAutoCompleteG(index) {
|
|
2479
|
+
this.hoverElement = this.autoCompleteG.querySelector(`.line-auto-complete-${index}`);
|
|
2480
|
+
this.hoverElement.style.visibility = 'hidden';
|
|
2481
|
+
}
|
|
2482
|
+
recoverAutoCompleteG() {
|
|
2483
|
+
if (this.hoverElement) {
|
|
2484
|
+
this.hoverElement.style.visibility = 'visible';
|
|
2485
|
+
this.hoverElement = null;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
class SingleTextGenerator extends TextGenerator {
|
|
2491
|
+
get textManage() {
|
|
2492
|
+
return this.textManages[0];
|
|
2493
|
+
}
|
|
2494
|
+
constructor(board, element, text, options) {
|
|
2495
|
+
super(board, element, [{ id: element.id, text: text, textHeight: element.textHeight }], options);
|
|
2496
|
+
}
|
|
2497
|
+
update(element, previousText, currentText, elementG) {
|
|
2498
|
+
if (!isMultipleTextGeometry(element)) {
|
|
2499
|
+
super.update(element, [{ text: previousText, id: element.id, textHeight: element.textHeight }], [{ text: currentText, id: element.id, textHeight: element.textHeight }], elementG);
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
class TableGenerator extends Generator {
|
|
2505
|
+
canDraw(element, data) {
|
|
2506
|
+
return true;
|
|
2507
|
+
}
|
|
2508
|
+
draw(element, data) {
|
|
2509
|
+
const rectangle = RectangleClient.getRectangleByPoints(element.points);
|
|
2510
|
+
const strokeWidth = getStrokeWidthByElement(element);
|
|
2511
|
+
const strokeColor = getStrokeColorByElement(this.board, element);
|
|
2512
|
+
const strokeStyle = getStrokeStyleByElement(this.board, element);
|
|
2513
|
+
const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
|
|
2514
|
+
return getEngine(TableSymbols.table).draw(this.board, rectangle, {
|
|
2515
|
+
strokeWidth,
|
|
2516
|
+
stroke: strokeColor,
|
|
2517
|
+
strokeLineDash
|
|
2518
|
+
}, {
|
|
2519
|
+
element: element
|
|
2520
|
+
});
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
const getElementShape = (value) => {
|
|
2525
|
+
if (PlaitDrawElement.isImage(value)) {
|
|
2526
|
+
return BasicShapes.rectangle;
|
|
2527
|
+
}
|
|
2528
|
+
if (PlaitDrawElement.isTable(value)) {
|
|
2529
|
+
return TableSymbols.table;
|
|
2530
|
+
}
|
|
2531
|
+
return value.shape;
|
|
2532
|
+
};
|
|
2533
|
+
const getGeometryGeneratorByShape = (board, shape) => {
|
|
2534
|
+
if (PlaitDrawElement.isUMLClassOrInterface({ shape: shape })) {
|
|
2535
|
+
return new TableGenerator(board);
|
|
2536
|
+
}
|
|
2537
|
+
else {
|
|
2538
|
+
return new GeometryShapeGenerator(board);
|
|
2539
|
+
}
|
|
2540
|
+
};
|
|
2541
|
+
|
|
2542
|
+
const createUMLClassOrInterfaceGeometryElement = (board, shape, points) => {
|
|
2543
|
+
const memorizedLatest = getMemorizedLatestByPointer(shape);
|
|
2544
|
+
const element = {
|
|
2545
|
+
id: idCreator(),
|
|
2546
|
+
type: 'geometry',
|
|
2547
|
+
angle: 0,
|
|
2548
|
+
opacity: 1,
|
|
2549
|
+
points,
|
|
2550
|
+
strokeWidth: DefaultBasicShapeProperty.strokeWidth,
|
|
2551
|
+
...memorizedLatest.geometryProperties
|
|
2552
|
+
};
|
|
2553
|
+
let rows;
|
|
2554
|
+
let columns;
|
|
2555
|
+
if (shape === UMLSymbols.class) {
|
|
2556
|
+
rows = [
|
|
2557
|
+
{
|
|
2558
|
+
id: idCreator(),
|
|
2559
|
+
height: 30
|
|
2560
|
+
},
|
|
2561
|
+
{
|
|
2562
|
+
id: idCreator()
|
|
2563
|
+
},
|
|
2564
|
+
{
|
|
2565
|
+
id: idCreator()
|
|
2566
|
+
}
|
|
2567
|
+
];
|
|
2568
|
+
columns = [
|
|
2569
|
+
{
|
|
2570
|
+
id: idCreator()
|
|
2571
|
+
}
|
|
2572
|
+
];
|
|
2573
|
+
}
|
|
2574
|
+
else {
|
|
2575
|
+
rows = [
|
|
2576
|
+
{
|
|
2577
|
+
id: idCreator(),
|
|
2578
|
+
height: 50
|
|
2285
2579
|
},
|
|
2286
2580
|
{
|
|
2287
2581
|
id: idCreator()
|
|
@@ -2935,13 +3229,16 @@ const getSwimlaneCount = (swimlane) => {
|
|
|
2935
3229
|
const isSwimlaneWithHeader = (shape) => {
|
|
2936
3230
|
return [SwimlaneDrawSymbols.swimlaneHorizontalWithHeader, SwimlaneDrawSymbols.swimlaneVerticalWithHeader].includes(shape);
|
|
2937
3231
|
};
|
|
3232
|
+
const isSwimlaneShape = (shape) => {
|
|
3233
|
+
return getSwimlaneShapes().includes(shape);
|
|
3234
|
+
};
|
|
2938
3235
|
const adjustSwimlaneShape = (shape) => {
|
|
2939
3236
|
return [SwimlaneDrawSymbols.swimlaneHorizontalWithHeader, SwimlaneDrawSymbols.swimlaneHorizontal].includes(shape)
|
|
2940
3237
|
? SwimlaneSymbols.swimlaneHorizontal
|
|
2941
3238
|
: SwimlaneSymbols.swimlaneVertical;
|
|
2942
3239
|
};
|
|
2943
|
-
const isSwimlanePointers = (board) => {
|
|
2944
|
-
return
|
|
3240
|
+
const isSwimlanePointers = (board, pointer = board.pointer) => {
|
|
3241
|
+
return getSwimlanePointers().includes(pointer);
|
|
2945
3242
|
};
|
|
2946
3243
|
|
|
2947
3244
|
const updateSwimlaneCount = (board, swimlane, count) => {
|
|
@@ -3708,87 +4005,27 @@ function drawResizingPointSnapLines(board, activePoints, snapRectangles, resizeS
|
|
|
3708
4005
|
}
|
|
3709
4006
|
function drawIsometricSnapLines(board, activePoints, snapRectangles, resizeSnapOptions, angle) {
|
|
3710
4007
|
let widthIsometricPoints = [];
|
|
3711
|
-
let heightIsometricPoints = [];
|
|
3712
|
-
const drawHorizontalLine = resizeSnapOptions.directionFactors[0] !== 0 || resizeSnapOptions.isAspectRatio;
|
|
3713
|
-
const drawVerticalLine = resizeSnapOptions.directionFactors[1] !== 0 || resizeSnapOptions.isAspectRatio;
|
|
3714
|
-
const rectangle = RectangleClient.getRectangleByPoints(activePoints);
|
|
3715
|
-
const activeRectangle = getRectangleByAngle(rectangle, angle);
|
|
3716
|
-
for (let snapRectangle of snapRectangles) {
|
|
3717
|
-
if (activeRectangle.width === snapRectangle.width && drawHorizontalLine) {
|
|
3718
|
-
widthIsometricPoints.push(getIsometricLinePoints(snapRectangle, true));
|
|
3719
|
-
}
|
|
3720
|
-
if (activeRectangle.height === snapRectangle.height && drawVerticalLine) {
|
|
3721
|
-
heightIsometricPoints.push(getIsometricLinePoints(snapRectangle, false));
|
|
3722
|
-
}
|
|
3723
|
-
}
|
|
3724
|
-
if (widthIsometricPoints.length && drawHorizontalLine) {
|
|
3725
|
-
widthIsometricPoints.push(getIsometricLinePoints(activeRectangle, true));
|
|
3726
|
-
}
|
|
3727
|
-
if (heightIsometricPoints.length && drawVerticalLine) {
|
|
3728
|
-
heightIsometricPoints.push(getIsometricLinePoints(activeRectangle, false));
|
|
3729
|
-
}
|
|
3730
|
-
const isometricLines = [...widthIsometricPoints, ...heightIsometricPoints];
|
|
3731
|
-
return drawSolidLines(board, isometricLines);
|
|
3732
|
-
}
|
|
3733
|
-
|
|
3734
|
-
function getMiddlePoints(board, element) {
|
|
3735
|
-
const result = [];
|
|
3736
|
-
const shape = element.shape;
|
|
3737
|
-
const hideBuffer = 10;
|
|
3738
|
-
if (shape === ArrowLineShape.straight) {
|
|
3739
|
-
const points = PlaitDrawElement.isArrowLine(element)
|
|
3740
|
-
? PlaitArrowLine.getPoints(board, element)
|
|
3741
|
-
: element.points;
|
|
3742
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
3743
|
-
const distance = distanceBetweenPointAndPoint(...points[i], ...points[i + 1]);
|
|
3744
|
-
if (distance < hideBuffer)
|
|
3745
|
-
continue;
|
|
3746
|
-
result.push([(points[i][0] + points[i + 1][0]) / 2, (points[i][1] + points[i + 1][1]) / 2]);
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
if (shape === ArrowLineShape.curve) {
|
|
3750
|
-
const points = PlaitDrawElement.isArrowLine(element)
|
|
3751
|
-
? PlaitArrowLine.getPoints(board, element)
|
|
3752
|
-
: element.points;
|
|
3753
|
-
const pointsOnBezier = PlaitDrawElement.isArrowLine(element)
|
|
3754
|
-
? getCurvePoints(board, element)
|
|
3755
|
-
: getVectorLinePoints(board, element);
|
|
3756
|
-
if (points.length === 2) {
|
|
3757
|
-
const start = 0;
|
|
3758
|
-
const endIndex = pointsOnBezier.length - 1;
|
|
3759
|
-
const middleIndex = Math.round((start + endIndex) / 2);
|
|
3760
|
-
result.push(pointsOnBezier[middleIndex]);
|
|
3761
|
-
}
|
|
3762
|
-
else {
|
|
3763
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
3764
|
-
const startIndex = pointsOnBezier.findIndex(point => point[0] === points[i][0] && point[1] === points[i][1]);
|
|
3765
|
-
const endIndex = pointsOnBezier.findIndex(point => point[0] === points[i + 1][0] && point[1] === points[i + 1][1]);
|
|
3766
|
-
const middleIndex = Math.round((startIndex + endIndex) / 2);
|
|
3767
|
-
const distance = distanceBetweenPointAndPoint(...points[i], ...points[i + 1]);
|
|
3768
|
-
if (distance < hideBuffer)
|
|
3769
|
-
continue;
|
|
3770
|
-
result.push(pointsOnBezier[middleIndex]);
|
|
3771
|
-
}
|
|
3772
|
-
}
|
|
3773
|
-
}
|
|
3774
|
-
if (shape === ArrowLineShape.elbow) {
|
|
3775
|
-
const renderPoints = getElbowPoints(board, element);
|
|
3776
|
-
const options = getElbowLineRouteOptions(board, element);
|
|
3777
|
-
if (!isUseDefaultOrthogonalRoute(element, options)) {
|
|
3778
|
-
const [nextSourcePoint, nextTargetPoint] = getNextSourceAndTargetPoints(board, element);
|
|
3779
|
-
for (let i = 0; i < renderPoints.length - 1; i++) {
|
|
3780
|
-
if ((i == 0 && Point.isEquals(renderPoints[i + 1], nextSourcePoint)) ||
|
|
3781
|
-
(i === renderPoints.length - 2 && Point.isEquals(renderPoints[renderPoints.length - 2], nextTargetPoint))) {
|
|
3782
|
-
continue;
|
|
3783
|
-
}
|
|
3784
|
-
const [currentX, currentY] = renderPoints[i];
|
|
3785
|
-
const [nextX, nextY] = renderPoints[i + 1];
|
|
3786
|
-
const middlePoint = [(currentX + nextX) / 2, (currentY + nextY) / 2];
|
|
3787
|
-
result.push(middlePoint);
|
|
3788
|
-
}
|
|
4008
|
+
let heightIsometricPoints = [];
|
|
4009
|
+
const drawHorizontalLine = resizeSnapOptions.directionFactors[0] !== 0 || resizeSnapOptions.isAspectRatio;
|
|
4010
|
+
const drawVerticalLine = resizeSnapOptions.directionFactors[1] !== 0 || resizeSnapOptions.isAspectRatio;
|
|
4011
|
+
const rectangle = RectangleClient.getRectangleByPoints(activePoints);
|
|
4012
|
+
const activeRectangle = getRectangleByAngle(rectangle, angle);
|
|
4013
|
+
for (let snapRectangle of snapRectangles) {
|
|
4014
|
+
if (activeRectangle.width === snapRectangle.width && drawHorizontalLine) {
|
|
4015
|
+
widthIsometricPoints.push(getIsometricLinePoints(snapRectangle, true));
|
|
4016
|
+
}
|
|
4017
|
+
if (activeRectangle.height === snapRectangle.height && drawVerticalLine) {
|
|
4018
|
+
heightIsometricPoints.push(getIsometricLinePoints(snapRectangle, false));
|
|
3789
4019
|
}
|
|
3790
4020
|
}
|
|
3791
|
-
|
|
4021
|
+
if (widthIsometricPoints.length && drawHorizontalLine) {
|
|
4022
|
+
widthIsometricPoints.push(getIsometricLinePoints(activeRectangle, true));
|
|
4023
|
+
}
|
|
4024
|
+
if (heightIsometricPoints.length && drawVerticalLine) {
|
|
4025
|
+
heightIsometricPoints.push(getIsometricLinePoints(activeRectangle, false));
|
|
4026
|
+
}
|
|
4027
|
+
const isometricLines = [...widthIsometricPoints, ...heightIsometricPoints];
|
|
4028
|
+
return drawSolidLines(board, isometricLines);
|
|
3792
4029
|
}
|
|
3793
4030
|
|
|
3794
4031
|
const buildClipboardData = (board, elements, startPoint) => {
|
|
@@ -7030,86 +7267,6 @@ const PlaitDrawElement = {
|
|
|
7030
7267
|
}
|
|
7031
7268
|
};
|
|
7032
7269
|
|
|
7033
|
-
class GeometryShapeGenerator extends Generator {
|
|
7034
|
-
canDraw(element, data) {
|
|
7035
|
-
return true;
|
|
7036
|
-
}
|
|
7037
|
-
draw(element, data) {
|
|
7038
|
-
const rectangle = RectangleClient.getRectangleByPoints(element.points);
|
|
7039
|
-
const shape = element.shape;
|
|
7040
|
-
if (shape === BasicShapes.text) {
|
|
7041
|
-
return;
|
|
7042
|
-
}
|
|
7043
|
-
const fill = getFillByElement(this.board, element);
|
|
7044
|
-
const strokeWidth = getStrokeWidthByElement(element);
|
|
7045
|
-
const strokeColor = getStrokeColorByElement(this.board, element);
|
|
7046
|
-
const strokeStyle = getStrokeStyleByElement(this.board, element);
|
|
7047
|
-
const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
|
|
7048
|
-
return drawGeometry(this.board, RectangleClient.inflate(rectangle, -strokeWidth), shape, {
|
|
7049
|
-
stroke: strokeColor,
|
|
7050
|
-
strokeWidth,
|
|
7051
|
-
fill,
|
|
7052
|
-
strokeLineDash
|
|
7053
|
-
});
|
|
7054
|
-
}
|
|
7055
|
-
}
|
|
7056
|
-
|
|
7057
|
-
class ArrowLineAutoCompleteGenerator extends Generator {
|
|
7058
|
-
static { this.key = 'line-auto-complete-generator'; }
|
|
7059
|
-
constructor(board) {
|
|
7060
|
-
super(board, { active: true });
|
|
7061
|
-
this.board = board;
|
|
7062
|
-
this.hoverElement = null;
|
|
7063
|
-
}
|
|
7064
|
-
canDraw(element, data) {
|
|
7065
|
-
const selectedElements = getSelectedElements(this.board);
|
|
7066
|
-
if (data.selected && selectedElements.length === 1 && !isSelectionMoving(this.board)) {
|
|
7067
|
-
return true;
|
|
7068
|
-
}
|
|
7069
|
-
else {
|
|
7070
|
-
return false;
|
|
7071
|
-
}
|
|
7072
|
-
}
|
|
7073
|
-
draw(element, data) {
|
|
7074
|
-
this.autoCompleteG = createG();
|
|
7075
|
-
const middlePoints = getAutoCompletePoints(this.board, element, true);
|
|
7076
|
-
middlePoints.forEach((point, index) => {
|
|
7077
|
-
const circle = drawCircle(PlaitBoard.getRoughSVG(this.board), point, LINE_AUTO_COMPLETE_DIAMETER, {
|
|
7078
|
-
stroke: 'none',
|
|
7079
|
-
fill: rgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_OPACITY),
|
|
7080
|
-
fillStyle: 'solid'
|
|
7081
|
-
});
|
|
7082
|
-
circle.classList.add(`line-auto-complete-${index}`);
|
|
7083
|
-
this.autoCompleteG.appendChild(circle);
|
|
7084
|
-
});
|
|
7085
|
-
return this.autoCompleteG;
|
|
7086
|
-
}
|
|
7087
|
-
removeAutoCompleteG(index) {
|
|
7088
|
-
this.hoverElement = this.autoCompleteG.querySelector(`.line-auto-complete-${index}`);
|
|
7089
|
-
this.hoverElement.style.visibility = 'hidden';
|
|
7090
|
-
}
|
|
7091
|
-
recoverAutoCompleteG() {
|
|
7092
|
-
if (this.hoverElement) {
|
|
7093
|
-
this.hoverElement.style.visibility = 'visible';
|
|
7094
|
-
this.hoverElement = null;
|
|
7095
|
-
}
|
|
7096
|
-
}
|
|
7097
|
-
}
|
|
7098
|
-
|
|
7099
|
-
class SingleTextGenerator extends TextGenerator {
|
|
7100
|
-
get textManage() {
|
|
7101
|
-
return this.textManages[0];
|
|
7102
|
-
}
|
|
7103
|
-
constructor(board, element, text, options) {
|
|
7104
|
-
super(board, element, [{ id: element.id, text: text, textHeight: element.textHeight }], options);
|
|
7105
|
-
}
|
|
7106
|
-
update(element, previousText, currentText, elementG) {
|
|
7107
|
-
if (!isMultipleTextGeometry(element)) {
|
|
7108
|
-
super.update(element, [{ text: previousText, id: element.id, textHeight: element.textHeight }], [{ text: currentText, id: element.id, textHeight: element.textHeight }], elementG);
|
|
7109
|
-
}
|
|
7110
|
-
}
|
|
7111
|
-
}
|
|
7112
|
-
|
|
7113
7270
|
class GeometryComponent extends CommonElementFlavour {
|
|
7114
7271
|
constructor() {
|
|
7115
7272
|
super();
|
|
@@ -7245,129 +7402,6 @@ class GeometryComponent extends CommonElementFlavour {
|
|
|
7245
7402
|
}
|
|
7246
7403
|
}
|
|
7247
7404
|
|
|
7248
|
-
var LineResizeHandle;
|
|
7249
|
-
(function (LineResizeHandle) {
|
|
7250
|
-
LineResizeHandle["source"] = "source";
|
|
7251
|
-
LineResizeHandle["target"] = "target";
|
|
7252
|
-
LineResizeHandle["addHandle"] = "addHandle";
|
|
7253
|
-
})(LineResizeHandle || (LineResizeHandle = {}));
|
|
7254
|
-
const getHitLineResizeHandleRef = (board, element, point) => {
|
|
7255
|
-
let dataPoints = PlaitDrawElement.isArrowLine(element) ? PlaitArrowLine.getPoints(board, element) : element.points;
|
|
7256
|
-
const index = getHitPointIndex(dataPoints, point);
|
|
7257
|
-
if (index !== -1) {
|
|
7258
|
-
const handleIndex = index;
|
|
7259
|
-
if (index === 0) {
|
|
7260
|
-
return { handle: LineResizeHandle.source, handleIndex };
|
|
7261
|
-
}
|
|
7262
|
-
if (index === dataPoints.length - 1) {
|
|
7263
|
-
return { handle: LineResizeHandle.target, handleIndex };
|
|
7264
|
-
}
|
|
7265
|
-
// elbow line, data points only verify source connection point and target connection point
|
|
7266
|
-
if (element.shape !== ArrowLineShape.elbow) {
|
|
7267
|
-
return { handleIndex };
|
|
7268
|
-
}
|
|
7269
|
-
}
|
|
7270
|
-
const middlePoints = getMiddlePoints(board, element);
|
|
7271
|
-
const indexOfMiddlePoints = getHitPointIndex(middlePoints, point);
|
|
7272
|
-
if (indexOfMiddlePoints !== -1) {
|
|
7273
|
-
return {
|
|
7274
|
-
handle: LineResizeHandle.addHandle,
|
|
7275
|
-
handleIndex: indexOfMiddlePoints
|
|
7276
|
-
};
|
|
7277
|
-
}
|
|
7278
|
-
return undefined;
|
|
7279
|
-
};
|
|
7280
|
-
function getHitPointIndex(points, movingPoint) {
|
|
7281
|
-
const rectangles = points.map(point => {
|
|
7282
|
-
return {
|
|
7283
|
-
x: point[0] - RESIZE_HANDLE_DIAMETER / 2,
|
|
7284
|
-
y: point[1] - RESIZE_HANDLE_DIAMETER / 2,
|
|
7285
|
-
width: RESIZE_HANDLE_DIAMETER,
|
|
7286
|
-
height: RESIZE_HANDLE_DIAMETER
|
|
7287
|
-
};
|
|
7288
|
-
});
|
|
7289
|
-
const rectangle = rectangles.find(rectangle => {
|
|
7290
|
-
return RectangleClient.isHit(RectangleClient.getRectangleByPoints([movingPoint, movingPoint]), rectangle);
|
|
7291
|
-
});
|
|
7292
|
-
return rectangle ? rectangles.indexOf(rectangle) : -1;
|
|
7293
|
-
}
|
|
7294
|
-
|
|
7295
|
-
class LineActiveGenerator extends Generator {
|
|
7296
|
-
constructor(board, options = { active: true }) {
|
|
7297
|
-
super(board, options);
|
|
7298
|
-
this.board = board;
|
|
7299
|
-
this.onlySelectedCurrentLine = false;
|
|
7300
|
-
}
|
|
7301
|
-
canDraw(element, data) {
|
|
7302
|
-
if (data.selected) {
|
|
7303
|
-
return true;
|
|
7304
|
-
}
|
|
7305
|
-
else {
|
|
7306
|
-
return false;
|
|
7307
|
-
}
|
|
7308
|
-
}
|
|
7309
|
-
draw(element, data) {
|
|
7310
|
-
const activeG = createG();
|
|
7311
|
-
const selectedElements = getSelectedElements(this.board);
|
|
7312
|
-
this.onlySelectedCurrentLine = selectedElements.length === 1;
|
|
7313
|
-
if (this.onlySelectedCurrentLine) {
|
|
7314
|
-
activeG.classList.add(SELECTION_RECTANGLE_CLASS_NAME);
|
|
7315
|
-
const points = PlaitDrawElement.isArrowLine(element) ? PlaitArrowLine.getPoints(this.board, element) : element.points;
|
|
7316
|
-
let updatePoints = [...points];
|
|
7317
|
-
let elbowNextRenderPoints = [];
|
|
7318
|
-
if (element.shape === ArrowLineShape.elbow) {
|
|
7319
|
-
updatePoints = points.slice(0, 1).concat(points.slice(-1));
|
|
7320
|
-
elbowNextRenderPoints = getNextRenderPoints(this.board, element, data.linePoints);
|
|
7321
|
-
}
|
|
7322
|
-
const activePoints = updatePoints.map((point) => toActivePointFromViewBoxPoint(this.board, point));
|
|
7323
|
-
activePoints.forEach((point) => {
|
|
7324
|
-
const updateHandle = drawPrimaryHandle(this.board, point);
|
|
7325
|
-
activeG.appendChild(updateHandle);
|
|
7326
|
-
});
|
|
7327
|
-
const middlePoints = getMiddlePoints(this.board, element);
|
|
7328
|
-
const activeMiddlePoints = middlePoints.map((point) => toActivePointFromViewBoxPoint(this.board, point));
|
|
7329
|
-
if (!PlaitBoard.hasBeenTextEditing(this.board)) {
|
|
7330
|
-
for (let i = 0; i < activeMiddlePoints.length; i++) {
|
|
7331
|
-
const point = activeMiddlePoints[i];
|
|
7332
|
-
if (element.shape === ArrowLineShape.elbow && elbowNextRenderPoints.length) {
|
|
7333
|
-
const handleIndex = getHitPointIndex(activeMiddlePoints, point);
|
|
7334
|
-
const isUpdateHandleIndex = isUpdatedHandleIndex(this.board, element, [...points], elbowNextRenderPoints, handleIndex);
|
|
7335
|
-
if (isUpdateHandleIndex) {
|
|
7336
|
-
const updateHandle = drawPrimaryHandle(this.board, point);
|
|
7337
|
-
activeG.appendChild(updateHandle);
|
|
7338
|
-
continue;
|
|
7339
|
-
}
|
|
7340
|
-
}
|
|
7341
|
-
const circle = drawFillPrimaryHandle(this.board, point);
|
|
7342
|
-
activeG.appendChild(circle);
|
|
7343
|
-
}
|
|
7344
|
-
}
|
|
7345
|
-
}
|
|
7346
|
-
else {
|
|
7347
|
-
const rectangle = this.board.getRectangle(element);
|
|
7348
|
-
if (rectangle) {
|
|
7349
|
-
const activeRectangle = toActiveRectangleFromViewBoxRectangle(this.board, rectangle);
|
|
7350
|
-
let opacity = '0.5';
|
|
7351
|
-
if (activeRectangle.height === 0 || activeRectangle.width === 0) {
|
|
7352
|
-
opacity = '0.8';
|
|
7353
|
-
}
|
|
7354
|
-
const strokeG = drawRectangle(this.board, activeRectangle, {
|
|
7355
|
-
stroke: PRIMARY_COLOR,
|
|
7356
|
-
strokeWidth: DefaultDrawActiveStyle.selectionStrokeWidth
|
|
7357
|
-
});
|
|
7358
|
-
strokeG.style.opacity = opacity;
|
|
7359
|
-
activeG.appendChild(strokeG);
|
|
7360
|
-
}
|
|
7361
|
-
}
|
|
7362
|
-
return activeG;
|
|
7363
|
-
}
|
|
7364
|
-
needUpdate() {
|
|
7365
|
-
const selectedElements = getSelectedElements(this.board);
|
|
7366
|
-
const onlySelectedCurrentLine = selectedElements.length === 1;
|
|
7367
|
-
return onlySelectedCurrentLine !== this.onlySelectedCurrentLine;
|
|
7368
|
-
}
|
|
7369
|
-
}
|
|
7370
|
-
|
|
7371
7405
|
const debugKey = 'debug:plait:line-turning';
|
|
7372
7406
|
const debugGenerator = createDebugGenerator(debugKey);
|
|
7373
7407
|
class ArrowLineComponent extends CommonElementFlavour {
|
|
@@ -7614,26 +7648,6 @@ const withDrawHotkey = (board) => {
|
|
|
7614
7648
|
return board;
|
|
7615
7649
|
};
|
|
7616
7650
|
|
|
7617
|
-
class TableGenerator extends Generator {
|
|
7618
|
-
canDraw(element, data) {
|
|
7619
|
-
return true;
|
|
7620
|
-
}
|
|
7621
|
-
draw(element, data) {
|
|
7622
|
-
const rectangle = RectangleClient.getRectangleByPoints(element.points);
|
|
7623
|
-
const strokeWidth = getStrokeWidthByElement(element);
|
|
7624
|
-
const strokeColor = getStrokeColorByElement(this.board, element);
|
|
7625
|
-
const strokeStyle = getStrokeStyleByElement(this.board, element);
|
|
7626
|
-
const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
|
|
7627
|
-
return getEngine(TableSymbols.table).draw(this.board, rectangle, {
|
|
7628
|
-
strokeWidth,
|
|
7629
|
-
stroke: strokeColor,
|
|
7630
|
-
strokeLineDash
|
|
7631
|
-
}, {
|
|
7632
|
-
element: element
|
|
7633
|
-
});
|
|
7634
|
-
}
|
|
7635
|
-
}
|
|
7636
|
-
|
|
7637
7651
|
const isGeometryDndMode = (board) => {
|
|
7638
7652
|
const geometryPointers = getGeometryPointers();
|
|
7639
7653
|
const isGeometryPointer = PlaitBoard.isInPointer(board, geometryPointers);
|
|
@@ -7646,14 +7660,6 @@ const isGeometryDrawingMode = (board) => {
|
|
|
7646
7660
|
const drawingMode = isGeometryPointer && isDrawingMode(board);
|
|
7647
7661
|
return drawingMode;
|
|
7648
7662
|
};
|
|
7649
|
-
const getGeometryGeneratorByShape = (board, shape) => {
|
|
7650
|
-
if (PlaitDrawElement.isUMLClassOrInterface({ shape: shape })) {
|
|
7651
|
-
return new TableGenerator(board);
|
|
7652
|
-
}
|
|
7653
|
-
else {
|
|
7654
|
-
return new GeometryShapeGenerator(board);
|
|
7655
|
-
}
|
|
7656
|
-
};
|
|
7657
7663
|
const withGeometryCreateByDrag = (board) => {
|
|
7658
7664
|
const { pointerMove, globalPointerUp, pointerUp } = board;
|
|
7659
7665
|
let geometryShapeG = null;
|
|
@@ -8366,37 +8372,12 @@ const withArrowLineAutoCompleteReaction = (board) => {
|
|
|
8366
8372
|
const lineAutoCompleteGenerator = ref.getGenerator(ArrowLineAutoCompleteGenerator.key);
|
|
8367
8373
|
lineAutoCompleteGenerator.recoverAutoCompleteG();
|
|
8368
8374
|
if (hitPoint) {
|
|
8375
|
+
// function 1: dnd
|
|
8369
8376
|
reactionG = drawCircle(PlaitBoard.getRoughSVG(board), hitPoint, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, {
|
|
8370
8377
|
stroke: 'none',
|
|
8371
8378
|
fill: rgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_HOVERED_OPACITY),
|
|
8372
8379
|
fillStyle: 'solid'
|
|
8373
8380
|
});
|
|
8374
|
-
const originRect = RectangleClient.getRectangleByPoints(originElement.points);
|
|
8375
|
-
let arrowLineStartPoint = RectangleClient.getEdgeCenterPoints(originRect)[hitIndex];
|
|
8376
|
-
const arrowLineDirection = getDirectionByIndex(hitIndex);
|
|
8377
|
-
let arrowLineEndPoint = moveXOfPoint(arrowLineStartPoint, PREVIEW_ARROW_LINE_DISTANCE, arrowLineDirection);
|
|
8378
|
-
const pointer = PlaitBoard.getPointer(board);
|
|
8379
|
-
const geometryGenerator = getGeometryGeneratorByShape(board, pointer);
|
|
8380
|
-
const temporaryShapePoints = originElement.points.map((point) => moveXOfPoint(point, PREVIEW_ARROW_LINE_DISTANCE +
|
|
8381
|
-
getXDistanceBetweenPoint(originElement.points[0], originElement.points[1], isHorizontalDirection(arrowLineDirection)), arrowLineDirection));
|
|
8382
|
-
temporaryArrowLineG = createG();
|
|
8383
|
-
temporaryShapeG = createG();
|
|
8384
|
-
temporaryArrowLineG.style.opacity = '0.6';
|
|
8385
|
-
temporaryShapeG.style.opacity = '0.6';
|
|
8386
|
-
temporaryShapeElement = {
|
|
8387
|
-
...originElement,
|
|
8388
|
-
points: temporaryShapePoints,
|
|
8389
|
-
id: idCreator()
|
|
8390
|
-
};
|
|
8391
|
-
const rotatedArrowLineStartPoint = rotatePointsByElement(arrowLineStartPoint, originElement) || arrowLineStartPoint;
|
|
8392
|
-
const rotatedArrowLineEndPoint = rotatePointsByElement(arrowLineEndPoint, temporaryShapeElement) || arrowLineEndPoint;
|
|
8393
|
-
temporaryArrowLineElement = handleArrowLineCreating(board, ArrowLineShape.elbow, rotatedArrowLineStartPoint, rotatedArrowLineEndPoint, originElement, temporaryArrowLineG);
|
|
8394
|
-
BOARD_TO_PRE_COMMIT.set(board, { temporaryArrowLineElement, temporaryShapeElement });
|
|
8395
|
-
const connectionInfo = getHitConnection(board, rotatedArrowLineEndPoint, temporaryShapeElement);
|
|
8396
|
-
temporaryArrowLineElement.target.boundId = temporaryShapeElement.id;
|
|
8397
|
-
temporaryArrowLineElement.target.connection = connectionInfo;
|
|
8398
|
-
geometryGenerator.processDrawing(temporaryShapeElement, temporaryShapeG);
|
|
8399
|
-
PlaitBoard.getElementTopHost(board).append(temporaryShapeG);
|
|
8400
8381
|
PlaitBoard.getActiveHost(board).append(reactionG);
|
|
8401
8382
|
PlaitBoard.getBoardContainer(board).classList.add(CursorClass.crosshair);
|
|
8402
8383
|
if (hasValidAngle(originElement)) {
|
|
@@ -8404,6 +8385,36 @@ const withArrowLineAutoCompleteReaction = (board) => {
|
|
|
8404
8385
|
const activeRectangle = toActiveRectangleFromViewBoxRectangle(board, rectangle);
|
|
8405
8386
|
setAngleForG(reactionG, RectangleClient.getCenterPoint(activeRectangle), originElement.angle);
|
|
8406
8387
|
}
|
|
8388
|
+
// function 2: hover to preview and click to commit
|
|
8389
|
+
if (PlaitDrawElement.isGeometry(originElement) && !PlaitDrawElement.isText(originElement)) {
|
|
8390
|
+
const originRect = RectangleClient.getRectangleByPoints(originElement.points);
|
|
8391
|
+
let arrowLineStartPoint = RectangleClient.getEdgeCenterPoints(originRect)[hitIndex];
|
|
8392
|
+
const arrowLineDirection = getDirectionByIndex(hitIndex);
|
|
8393
|
+
let arrowLineEndPoint = moveXOfPoint(arrowLineStartPoint, PREVIEW_ARROW_LINE_DISTANCE, arrowLineDirection);
|
|
8394
|
+
const geometryGenerator = getGeometryGeneratorByShape(board, originElement.shape);
|
|
8395
|
+
const temporaryShapePoints = originElement.points.map((point) => moveXOfPoint(point, PREVIEW_ARROW_LINE_DISTANCE +
|
|
8396
|
+
getXDistanceBetweenPoint(originElement.points[0], originElement.points[1], isHorizontalDirection(arrowLineDirection)), arrowLineDirection));
|
|
8397
|
+
temporaryArrowLineG = createG();
|
|
8398
|
+
temporaryShapeG = createG();
|
|
8399
|
+
temporaryArrowLineG.style.opacity = '0.6';
|
|
8400
|
+
temporaryShapeG.style.opacity = '0.6';
|
|
8401
|
+
temporaryShapeElement = createDefaultGeometry(board, temporaryShapePoints, originElement.shape);
|
|
8402
|
+
temporaryShapeElement.angle = originElement.angle;
|
|
8403
|
+
temporaryShapeElement.fill = originElement.fill;
|
|
8404
|
+
temporaryShapeElement.strokeColor = originElement.strokeColor;
|
|
8405
|
+
temporaryShapeElement.strokeStyle = originElement.strokeStyle;
|
|
8406
|
+
temporaryShapeElement.strokeWidth = originElement.strokeWidth;
|
|
8407
|
+
temporaryShapeElement.groupId = originElement.groupId;
|
|
8408
|
+
const rotatedArrowLineStartPoint = rotatePointsByElement(arrowLineStartPoint, originElement) || arrowLineStartPoint;
|
|
8409
|
+
const rotatedArrowLineEndPoint = rotatePointsByElement(arrowLineEndPoint, temporaryShapeElement) || arrowLineEndPoint;
|
|
8410
|
+
temporaryArrowLineElement = handleArrowLineCreating(board, ArrowLineShape.elbow, rotatedArrowLineStartPoint, rotatedArrowLineEndPoint, originElement, temporaryArrowLineG);
|
|
8411
|
+
BOARD_TO_PRE_COMMIT.set(board, { temporaryArrowLineElement, temporaryShapeElement });
|
|
8412
|
+
const connectionInfo = getHitConnection(board, rotatedArrowLineEndPoint, temporaryShapeElement);
|
|
8413
|
+
temporaryArrowLineElement.target.boundId = temporaryShapeElement.id;
|
|
8414
|
+
temporaryArrowLineElement.target.connection = connectionInfo;
|
|
8415
|
+
geometryGenerator.processDrawing(temporaryShapeElement, temporaryShapeG);
|
|
8416
|
+
PlaitBoard.getElementTopHost(board).append(temporaryShapeG);
|
|
8417
|
+
}
|
|
8407
8418
|
return;
|
|
8408
8419
|
}
|
|
8409
8420
|
}
|
|
@@ -9003,9 +9014,9 @@ const withSwimlaneCreateByDrag = (board) => {
|
|
|
9003
9014
|
swimlaneG?.remove();
|
|
9004
9015
|
swimlaneG = createG();
|
|
9005
9016
|
const tableGenerator = new TableGenerator(board);
|
|
9017
|
+
const pointer = PlaitBoard.getPointer(board);
|
|
9006
9018
|
const dragMode = isSwimlaneDndMode(board);
|
|
9007
9019
|
const movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
9008
|
-
const pointer = PlaitBoard.getPointer(board);
|
|
9009
9020
|
if (dragMode) {
|
|
9010
9021
|
const points = getDefaultSwimlanePoints(pointer, movingPoint);
|
|
9011
9022
|
temporaryElement = createDefaultSwimlane(pointer, points);
|
|
@@ -9379,5 +9390,5 @@ const withDraw = (board) => {
|
|
|
9379
9390
|
* Generated bundle index. Do not edit.
|
|
9380
9391
|
*/
|
|
9381
9392
|
|
|
9382
|
-
export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BOARD_TO_PRE_COMMIT, 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, DefaultLineStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawI18nKey, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_ALIGN_TOLERANCE, LINE_AUTO_COMPLETE_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_OPACITY, LINE_AUTO_COMPLETE_OPACITY, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LINE_TEXT, LINE_TEXT_SPACE, 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, 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, getDefaultGeometryText, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectionFromConnectionPoint, 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, getSolidElements, 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, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
|
|
9393
|
+
export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BOARD_TO_PRE_COMMIT, 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, DefaultLineStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawI18nKey, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_ALIGN_TOLERANCE, LINE_AUTO_COMPLETE_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_OPACITY, LINE_AUTO_COMPLETE_OPACITY, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LINE_TEXT, LINE_TEXT_SPACE, 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, 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, getDefaultGeometryText, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectionFromConnectionPoint, 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, getSolidElements, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getSwimlaneShapes, 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, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneShape, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
|
|
9383
9394
|
//# sourceMappingURL=plait-draw.mjs.map
|