@plait/draw 0.62.0-next.0 → 0.62.0-next.10

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.
Files changed (152) hide show
  1. package/arrow-line.component.d.ts +26 -0
  2. package/constants/geometry.d.ts +1 -0
  3. package/constants/pointer.d.ts +3 -3
  4. package/esm2022/arrow-line.component.mjs +157 -0
  5. package/esm2022/constants/geometry.mjs +10 -3
  6. package/esm2022/constants/pointer.mjs +4 -4
  7. package/esm2022/engines/basic-shapes/ellipse.mjs +5 -3
  8. package/esm2022/engines/basic-shapes/round-comment.mjs +5 -3
  9. package/esm2022/engines/flowchart/note-curly-left.mjs +2 -2
  10. package/esm2022/engines/flowchart/note-curly-right.mjs +7 -7
  11. package/esm2022/engines/flowchart/note-square.mjs +2 -2
  12. package/esm2022/engines/flowchart/or.mjs +5 -3
  13. package/esm2022/engines/flowchart/summing-junction.mjs +5 -3
  14. package/esm2022/engines/table/table.mjs +48 -26
  15. package/esm2022/engines/uml/deletion.mjs +3 -2
  16. package/esm2022/engines/uml/required-interface.mjs +3 -2
  17. package/esm2022/generators/arrow-line-active.generator.mjs +81 -0
  18. package/esm2022/generators/arrow-line-auto-complete.generator.mjs +46 -0
  19. package/esm2022/generators/arrow-line.generator.mjs +13 -0
  20. package/esm2022/generators/index.mjs +3 -3
  21. package/esm2022/generators/table.generator.mjs +8 -4
  22. package/esm2022/geometry.component.mjs +4 -4
  23. package/esm2022/image.component.mjs +4 -4
  24. package/esm2022/interfaces/arrow-line.mjs +70 -0
  25. package/esm2022/interfaces/element.mjs +2 -2
  26. package/esm2022/interfaces/index.mjs +14 -7
  27. package/esm2022/interfaces/vector-line.mjs +6 -0
  28. package/esm2022/plugins/with-arrow-line-auto-complete-reaction.mjs +41 -0
  29. package/esm2022/plugins/with-arrow-line-auto-complete.mjs +74 -0
  30. package/esm2022/plugins/with-arrow-line-bound-reaction.mjs +53 -0
  31. package/esm2022/plugins/with-arrow-line-create.mjs +53 -0
  32. package/esm2022/plugins/with-arrow-line-resize.mjs +158 -0
  33. package/esm2022/plugins/with-arrow-line-text-move.mjs +53 -0
  34. package/esm2022/plugins/with-arrow-line-text.mjs +63 -0
  35. package/esm2022/plugins/with-draw-fragment.mjs +13 -13
  36. package/esm2022/plugins/with-draw-resize.mjs +12 -5
  37. package/esm2022/plugins/with-draw.mjs +27 -20
  38. package/esm2022/plugins/with-geometry-resize.mjs +1 -1
  39. package/esm2022/plugins/with-swimlane-create.mjs +4 -7
  40. package/esm2022/plugins/with-swimlane.mjs +1 -20
  41. package/esm2022/plugins/with-table.mjs +34 -7
  42. package/esm2022/public-api.mjs +3 -3
  43. package/esm2022/table.component.mjs +6 -6
  44. package/esm2022/transforms/arrow-line.mjs +66 -0
  45. package/esm2022/transforms/common.mjs +36 -0
  46. package/esm2022/transforms/geometry.mjs +6 -28
  47. package/esm2022/transforms/index.mjs +15 -13
  48. package/esm2022/transforms/swimlane.mjs +1 -29
  49. package/esm2022/transforms/table-text.mjs +5 -5
  50. package/esm2022/transforms/table.mjs +30 -0
  51. package/esm2022/utils/arrow-line/arrow-line-arrow.mjs +123 -0
  52. package/esm2022/utils/arrow-line/arrow-line-basic.mjs +257 -0
  53. package/esm2022/utils/arrow-line/arrow-line-common.mjs +162 -0
  54. package/esm2022/utils/arrow-line/arrow-line-resize.mjs +309 -0
  55. package/esm2022/utils/arrow-line/elbow.mjs +114 -0
  56. package/esm2022/utils/arrow-line/index.mjs +6 -0
  57. package/esm2022/utils/clipboard.mjs +10 -10
  58. package/esm2022/utils/common.mjs +14 -5
  59. package/esm2022/utils/geometry.mjs +17 -14
  60. package/esm2022/utils/hit.mjs +67 -44
  61. package/esm2022/utils/index.mjs +2 -2
  62. package/esm2022/utils/memorize.mjs +4 -5
  63. package/esm2022/utils/position/arrow-line.mjs +67 -0
  64. package/esm2022/utils/position/geometry.mjs +1 -1
  65. package/esm2022/utils/selected.mjs +3 -3
  66. package/esm2022/utils/style/stroke.mjs +4 -4
  67. package/esm2022/utils/swimlane.mjs +17 -8
  68. package/esm2022/utils/table-selected.mjs +3 -4
  69. package/esm2022/utils/table.mjs +28 -5
  70. package/fesm2022/plait-draw.mjs +673 -514
  71. package/fesm2022/plait-draw.mjs.map +1 -1
  72. package/generators/arrow-line-active.generator.d.ts +13 -0
  73. package/generators/{line-auto-complete.generator.d.ts → arrow-line-auto-complete.generator.d.ts} +1 -1
  74. package/generators/arrow-line.generator.d.ts +8 -0
  75. package/generators/index.d.ts +2 -2
  76. package/geometry.component.d.ts +2 -2
  77. package/image.component.d.ts +2 -2
  78. package/interfaces/arrow-line.d.ts +75 -0
  79. package/interfaces/element.d.ts +1 -1
  80. package/interfaces/index.d.ts +6 -4
  81. package/interfaces/vector-line.d.ts +16 -0
  82. package/package.json +12 -4
  83. package/plugins/with-arrow-line-auto-complete-reaction.d.ts +2 -0
  84. package/plugins/with-arrow-line-auto-complete.d.ts +7 -0
  85. package/plugins/with-arrow-line-bound-reaction.d.ts +2 -0
  86. package/plugins/with-arrow-line-create.d.ts +2 -0
  87. package/plugins/with-arrow-line-resize.d.ts +2 -0
  88. package/plugins/with-arrow-line-text-move.d.ts +2 -0
  89. package/plugins/with-arrow-line-text.d.ts +2 -0
  90. package/plugins/with-draw-fragment.d.ts +2 -2
  91. package/plugins/with-swimlane.d.ts +1 -2
  92. package/public-api.d.ts +2 -2
  93. package/table.component.d.ts +2 -2
  94. package/transforms/arrow-line.d.ts +8 -0
  95. package/transforms/common.d.ts +3 -0
  96. package/transforms/geometry.d.ts +1 -2
  97. package/transforms/index.d.ts +9 -9
  98. package/transforms/swimlane.d.ts +1 -3
  99. package/transforms/table-text.d.ts +2 -3
  100. package/transforms/table.d.ts +3 -0
  101. package/utils/arrow-line/arrow-line-arrow.d.ts +4 -0
  102. package/utils/arrow-line/arrow-line-basic.d.ts +13 -0
  103. package/utils/{line/line-common.d.ts → arrow-line/arrow-line-common.d.ts} +8 -4
  104. package/utils/{line/line-resize.d.ts → arrow-line/arrow-line-resize.d.ts} +3 -3
  105. package/utils/{line → arrow-line}/elbow.d.ts +7 -7
  106. package/utils/arrow-line/index.d.ts +5 -0
  107. package/utils/clipboard.d.ts +4 -4
  108. package/utils/common.d.ts +1 -0
  109. package/utils/geometry.d.ts +2 -1
  110. package/utils/hit.d.ts +7 -4
  111. package/utils/index.d.ts +1 -1
  112. package/utils/position/arrow-line.d.ts +16 -0
  113. package/utils/selected.d.ts +2 -2
  114. package/utils/style/stroke.d.ts +3 -4
  115. package/utils/swimlane.d.ts +3 -2
  116. package/utils/table.d.ts +2 -0
  117. package/esm2022/generators/line-active.generator.mjs +0 -81
  118. package/esm2022/generators/line-auto-complete.generator.mjs +0 -46
  119. package/esm2022/generators/line.generator.mjs +0 -13
  120. package/esm2022/interfaces/line.mjs +0 -70
  121. package/esm2022/line.component.mjs +0 -155
  122. package/esm2022/plugins/with-line-auto-complete-reaction.mjs +0 -41
  123. package/esm2022/plugins/with-line-auto-complete.mjs +0 -75
  124. package/esm2022/plugins/with-line-bound-reaction.mjs +0 -53
  125. package/esm2022/plugins/with-line-create.mjs +0 -53
  126. package/esm2022/plugins/with-line-resize.mjs +0 -158
  127. package/esm2022/plugins/with-line-text-move.mjs +0 -53
  128. package/esm2022/plugins/with-line-text.mjs +0 -62
  129. package/esm2022/transforms/line.mjs +0 -100
  130. package/esm2022/utils/line/elbow.mjs +0 -114
  131. package/esm2022/utils/line/index.mjs +0 -6
  132. package/esm2022/utils/line/line-arrow.mjs +0 -123
  133. package/esm2022/utils/line/line-basic.mjs +0 -257
  134. package/esm2022/utils/line/line-common.mjs +0 -123
  135. package/esm2022/utils/line/line-resize.mjs +0 -309
  136. package/esm2022/utils/position/line.mjs +0 -67
  137. package/generators/line-active.generator.d.ts +0 -13
  138. package/generators/line.generator.d.ts +0 -8
  139. package/interfaces/line.d.ts +0 -75
  140. package/line.component.d.ts +0 -26
  141. package/plugins/with-line-auto-complete-reaction.d.ts +0 -2
  142. package/plugins/with-line-auto-complete.d.ts +0 -7
  143. package/plugins/with-line-bound-reaction.d.ts +0 -2
  144. package/plugins/with-line-create.d.ts +0 -2
  145. package/plugins/with-line-resize.d.ts +0 -2
  146. package/plugins/with-line-text-move.d.ts +0 -2
  147. package/plugins/with-line-text.d.ts +0 -2
  148. package/transforms/line.d.ts +0 -12
  149. package/utils/line/index.d.ts +0 -5
  150. package/utils/line/line-arrow.d.ts +0 -4
  151. package/utils/line/line-basic.d.ts +0 -13
  152. package/utils/position/line.d.ts +0 -16
@@ -1,5 +1,5 @@
1
- import { ACTIVE_STROKE_WIDTH, ThemeColorMode, RectangleClient, idCreator, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, rotatePointsByElement, isPolylineHitRectangle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, PlaitBoard, getIsRecursionFunc, createG, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, drawLinearPath, rotate, catmullRomFitting, setStrokeLinecap, findElements, createMask, createRect, PlaitElement, getSelectedElements, getElementById, Path, Direction, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, isPointInPolygon, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, setPathStrokeLinecap, getCrossingPointsBetweenEllipseAndSegment, drawLine as drawLine$1, RgbaToHEX, getHitElementByPoint, preventTouchMove, WritableClipboardOperationType, createClipboardContext, WritableClipboardType, addClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, SELECTION_RECTANGLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
- import { Alignment, WithTextPluginKey, ELEMENT_TO_TEXT_MANAGES, TextManage, getMemorizedLatest, memorizeLatest, RESIZE_HANDLE_DIAMETER, getPointOnPolyline, buildText, TRANSPARENT, getTextEditorsByElement, Generator, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, ActiveGenerator, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, getDirectionByVector, normalizeShapePoints, getFirstTextEditor, resetPointsAfterResize, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, isCornerHandle, getIndexByResizeHandle, withResize, drawHandle, getSymmetricHandleIndex, getResizeHandlePointByIndex, getDirectionFactorByDirectionComponent, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, canResize, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
1
+ import { ACTIVE_STROKE_WIDTH, ThemeColorMode, RectangleClient, getSelectedElements, idCreator, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, rotatePointsByElement, isPolylineHitRectangle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, PlaitBoard, getIsRecursionFunc, createG, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, drawLinearPath, rotate, catmullRomFitting, setStrokeLinecap, findElements, createMask, createRect, PlaitElement, getElementById, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, isPointInPolygon, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, setPathStrokeLinecap, getCrossingPointsBetweenEllipseAndSegment, drawLine, Path, RgbaToHEX, getHitElementByPoint, preventTouchMove, WritableClipboardOperationType, createClipboardContext, WritableClipboardType, addClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, SELECTION_RECTANGLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
+ import { DEFAULT_FILL, Alignment, WithTextPluginKey, ELEMENT_TO_TEXT_MANAGES, TextManage, getMemorizedLatest, memorizeLatest, RESIZE_HANDLE_DIAMETER, getPointOnPolyline, buildText, sortElementsByArea, isFilled, getTextEditorsByElement, Generator, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, ActiveGenerator, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, getFirstTextEditor, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, isCornerHandle, getIndexByResizeHandle, withResize, drawHandle, getSymmetricHandleIndex, getResizeHandlePointByIndex, getDirectionFactorByDirectionComponent, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, canResize, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
3
3
  import { pointsOnBezierCurves } from 'points-on-curve';
4
4
  import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
5
5
  import { isKeyHotkey } from 'is-hotkey';
@@ -120,7 +120,7 @@ const DefaultDrawStyle = {
120
120
  strokeWidth: 2,
121
121
  defaultRadius: 4,
122
122
  strokeColor: '#000',
123
- fill: 'none'
123
+ fill: DEFAULT_FILL
124
124
  };
125
125
  const DefaultDrawActiveStyle = {
126
126
  strokeWidth: ACTIVE_STROKE_WIDTH,
@@ -374,6 +374,13 @@ const GEOMETRY_WITHOUT_TEXT = [
374
374
  UMLSymbols.requiredInterface
375
375
  ];
376
376
  const GEOMETRY_WITH_MULTIPLE_TEXT = [UMLSymbols.package, UMLSymbols.combinedFragment];
377
+ const GEOMETRY_NOT_CLOSED = [
378
+ FlowchartSymbols.noteCurlyLeft,
379
+ FlowchartSymbols.noteCurlyRight,
380
+ FlowchartSymbols.noteSquare,
381
+ UMLSymbols.requiredInterface,
382
+ UMLSymbols.deletion
383
+ ];
377
384
 
378
385
  const getGeometryPointers = () => {
379
386
  return [...Object.keys(BasicShapes), ...Object.keys(FlowchartSymbols), ...Object.keys(UMLSymbols)];
@@ -390,8 +397,8 @@ const getFlowchartPointers = () => {
390
397
  const getUMLPointers = () => {
391
398
  return Object.keys(UMLSymbols);
392
399
  };
393
- const getLinePointers = () => {
394
- return Object.keys(LineShape);
400
+ const getArrowLinePointers = () => {
401
+ return Object.keys(ArrowLineShape);
395
402
  };
396
403
 
397
404
  const DEFAULT_IMAGE_WIDTH = 1000;
@@ -578,8 +585,34 @@ class TextGenerator {
578
585
  }
579
586
  }
580
587
 
588
+ const isSingleSelectTable = (board) => {
589
+ const selectedElements = getSelectedElements(board);
590
+ return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
591
+ };
592
+ const isSingleSelectElementByTable = (board) => {
593
+ const selectedElements = getSelectedElements(board);
594
+ return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
595
+ };
596
+ const getSelectedTableElements = (board, elements) => {
597
+ const selectedElements = elements?.length ? elements : getSelectedElements(board);
598
+ return selectedElements.filter(value => PlaitDrawElement.isElementByTable(value));
599
+ };
600
+ const SELECTED_CELLS = new WeakMap();
601
+ function getSelectedCells(element) {
602
+ return SELECTED_CELLS.get(element);
603
+ }
604
+ function setSelectedCells(element, cells) {
605
+ return SELECTED_CELLS.set(element, cells);
606
+ }
607
+ function clearSelectedCells(element) {
608
+ return SELECTED_CELLS.delete(element);
609
+ }
610
+
581
611
  function getCellsWithPoints(board, element) {
582
- const table = board.buildTable(element);
612
+ const table = board?.buildTable(element);
613
+ if (!table || !table.points || !table.columns || !table.rows) {
614
+ throw new Error('can not get table cells points');
615
+ }
583
616
  const rectangle = RectangleClient.getRectangleByPoints(table.points);
584
617
  const columnsCount = table.columns.length;
585
618
  const rowsCount = table.rows.length;
@@ -611,9 +644,14 @@ function getCellsWithPoints(board, element) {
611
644
  return cells;
612
645
  }
613
646
  function getCellWithPoints(board, table, cellId) {
614
- const cells = getCellsWithPoints(board, table);
615
- const cellIndex = table.cells.findIndex(item => item.id === cellId);
616
- return cells[cellIndex];
647
+ try {
648
+ const cells = getCellsWithPoints(board, table);
649
+ const cellIndex = cells && table.cells.findIndex(item => item.id === cellId);
650
+ return cells[cellIndex];
651
+ }
652
+ catch (error) {
653
+ throw new Error('can not get table cell points');
654
+ }
617
655
  }
618
656
  function calculateCellsSize(items, tableSize, count, isWidth) {
619
657
  const cellSizes = [];
@@ -722,6 +760,20 @@ const createCell = (rowId, columnId, text = null) => {
722
760
  }
723
761
  return cell;
724
762
  };
763
+ const getSelectedTableCellsEditor = (board) => {
764
+ if (isSingleSelectElementByTable(board)) {
765
+ const elements = getSelectedTableElements(board);
766
+ const selectedCells = getSelectedCells(elements[0]);
767
+ const selectedCellsEditor = selectedCells?.map(cell => {
768
+ const textManage = getTextManageByCell(cell);
769
+ return textManage?.editor;
770
+ });
771
+ if (selectedCellsEditor?.length) {
772
+ return selectedCellsEditor;
773
+ }
774
+ }
775
+ return undefined;
776
+ };
725
777
 
726
778
  const SHAPE_MAX_LENGTH = 6;
727
779
  const memorizedShape = new WeakMap();
@@ -740,8 +792,8 @@ const getMemorizeKey = (element) => {
740
792
  key = MemorizeKey.flowchart;
741
793
  break;
742
794
  }
743
- case PlaitDrawElement.isLine(element): {
744
- key = MemorizeKey.line;
795
+ case PlaitDrawElement.isArrowLine(element): {
796
+ key = MemorizeKey.arrowLine;
745
797
  break;
746
798
  }
747
799
  case PlaitDrawElement.isUML(element): {
@@ -751,8 +803,7 @@ const getMemorizeKey = (element) => {
751
803
  return key;
752
804
  };
753
805
  const getLineMemorizedLatest = () => {
754
- const properties = getMemorizedLatest(MemorizeKey.line);
755
- delete properties?.text;
806
+ const properties = getMemorizedLatest(MemorizeKey.arrowLine);
756
807
  return { ...properties } || {};
757
808
  };
758
809
  const getMemorizedLatestByPointer = (pointer) => {
@@ -815,25 +866,25 @@ const getMemorizedLatestShape = (board) => {
815
866
  return memorizedShape.get(board);
816
867
  };
817
868
 
818
- var LineResizeHandle;
819
- (function (LineResizeHandle) {
820
- LineResizeHandle["source"] = "source";
821
- LineResizeHandle["target"] = "target";
822
- LineResizeHandle["addHandle"] = "addHandle";
823
- })(LineResizeHandle || (LineResizeHandle = {}));
824
- const getHitLineResizeHandleRef = (board, element, point) => {
825
- let dataPoints = PlaitLine.getPoints(board, element);
869
+ var ArrowLineResizeHandle;
870
+ (function (ArrowLineResizeHandle) {
871
+ ArrowLineResizeHandle["source"] = "source";
872
+ ArrowLineResizeHandle["target"] = "target";
873
+ ArrowLineResizeHandle["addHandle"] = "addHandle";
874
+ })(ArrowLineResizeHandle || (ArrowLineResizeHandle = {}));
875
+ const getHitArrowLineResizeHandleRef = (board, element, point) => {
876
+ let dataPoints = PlaitArrowLine.getPoints(board, element);
826
877
  const index = getHitPointIndex(dataPoints, point);
827
878
  if (index !== -1) {
828
879
  const handleIndex = index;
829
880
  if (index === 0) {
830
- return { handle: LineResizeHandle.source, handleIndex };
881
+ return { handle: ArrowLineResizeHandle.source, handleIndex };
831
882
  }
832
883
  if (index === dataPoints.length - 1) {
833
- return { handle: LineResizeHandle.target, handleIndex };
884
+ return { handle: ArrowLineResizeHandle.target, handleIndex };
834
885
  }
835
886
  // elbow line, data points only verify source connection point and target connection point
836
- if (element.shape !== LineShape.elbow) {
887
+ if (element.shape !== ArrowLineShape.elbow) {
837
888
  return { handleIndex };
838
889
  }
839
890
  }
@@ -841,7 +892,7 @@ const getHitLineResizeHandleRef = (board, element, point) => {
841
892
  const indexOfMiddlePoints = getHitPointIndex(middlePoints, point);
842
893
  if (indexOfMiddlePoints !== -1) {
843
894
  return {
844
- handle: LineResizeHandle.addHandle,
895
+ handle: ArrowLineResizeHandle.addHandle,
845
896
  handleIndex: indexOfMiddlePoints
846
897
  };
847
898
  }
@@ -861,11 +912,11 @@ function getHitPointIndex(points, movingPoint) {
861
912
  });
862
913
  return rectangle ? rectangles.indexOf(rectangle) : -1;
863
914
  }
864
- const getHitLineTextIndex = (board, element, point) => {
915
+ const getHitArrowLineTextIndex = (board, element, point) => {
865
916
  const texts = element.texts;
866
917
  if (!texts.length)
867
918
  return -1;
868
- const points = getLinePoints(board, element);
919
+ const points = getArrowLinePoints(board, element);
869
920
  return texts.findIndex(text => {
870
921
  const center = getPointOnPolyline(points, text.position);
871
922
  const rectangle = {
@@ -939,46 +990,46 @@ const isTextExceedingBounds = (geometry) => {
939
990
  }
940
991
  return false;
941
992
  };
942
- const isHitLineText = (board, element, point) => {
943
- return getHitLineTextIndex(board, element, point) !== -1;
993
+ const isHitArrowLineText = (board, element, point) => {
994
+ return getHitArrowLineTextIndex(board, element, point) !== -1;
944
995
  };
945
996
  const isHitPolyLine = (pathPoints, point) => {
946
997
  const distance = distanceBetweenPointAndSegments(pathPoints, point);
947
998
  return distance <= HIT_DISTANCE_BUFFER;
948
999
  };
949
- const isHitLine = (board, element, point) => {
950
- const points = getLinePoints(board, element);
951
- const isHitText = isHitLineText(board, element, point);
1000
+ const isHitArrowLine = (board, element, point) => {
1001
+ const points = getArrowLinePoints(board, element);
1002
+ const isHitText = isHitArrowLineText(board, element, point);
952
1003
  return isHitText || isHitPolyLine(points, point);
953
1004
  };
954
- const isHitElementText = (element, point) => {
1005
+ const isRectangleHitElementText = (element, rectangle) => {
955
1006
  const engine = getEngine(element.shape);
956
1007
  if (isMultipleTextGeometry(element)) {
957
1008
  const texts = element.texts;
958
1009
  return texts.some(item => {
959
1010
  const textClient = engine.getTextRectangle(element, { key: item.key });
960
- return RectangleClient.isPointInRectangle(textClient, point);
1011
+ const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
1012
+ return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
961
1013
  });
962
1014
  }
963
1015
  else {
964
1016
  const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
965
- return RectangleClient.isPointInRectangle(textClient, point);
1017
+ const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
1018
+ return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
966
1019
  }
967
1020
  };
968
- const isRectangleHitElementText = (element, rectangle) => {
1021
+ const isHitElementText = (element, point) => {
969
1022
  const engine = getEngine(element.shape);
970
1023
  if (isMultipleTextGeometry(element)) {
971
1024
  const texts = element.texts;
972
1025
  return texts.some(item => {
973
1026
  const textClient = engine.getTextRectangle(element, { key: item.key });
974
- const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
975
- return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
1027
+ return RectangleClient.isPointInRectangle(textClient, point);
976
1028
  });
977
1029
  }
978
1030
  else {
979
1031
  const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
980
- const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
981
- return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
1032
+ return RectangleClient.isPointInRectangle(textClient, point);
982
1033
  }
983
1034
  };
984
1035
  const isRectangleHitDrawElement = (board, element, selection) => {
@@ -997,48 +1048,72 @@ const isRectangleHitDrawElement = (board, element, selection) => {
997
1048
  const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(client), element) || RectangleClient.getCornerPoints(client);
998
1049
  return isPolylineHitRectangle(rotatedCornerPoints, rangeRectangle);
999
1050
  }
1000
- if (PlaitDrawElement.isLine(element)) {
1001
- const points = getLinePoints(board, element);
1051
+ if (PlaitDrawElement.isArrowLine(element)) {
1052
+ const points = getArrowLinePoints(board, element);
1002
1053
  return isPolylineHitRectangle(points, rangeRectangle);
1003
1054
  }
1004
1055
  return null;
1005
1056
  };
1057
+ const getDrawHitElement = (board, elements) => {
1058
+ let firstFilledElement = getFirstFilledDrawElement(board, elements);
1059
+ let endIndex = elements.length;
1060
+ if (firstFilledElement) {
1061
+ endIndex = elements.indexOf(firstFilledElement) + 1;
1062
+ }
1063
+ const newElements = elements.slice(0, endIndex);
1064
+ const element = getFirstTextOrLineElement(newElements);
1065
+ if (element) {
1066
+ return element;
1067
+ }
1068
+ const sortElements = sortElementsByArea(board, newElements, 'asc');
1069
+ return sortElements[0];
1070
+ };
1071
+ const getFirstFilledDrawElement = (board, elements) => {
1072
+ let filledElement = null;
1073
+ for (let i = 0; i < elements.length; i++) {
1074
+ const element = elements[i];
1075
+ if (PlaitDrawElement.isGeometry(element) && !PlaitDrawElement.isText(element)) {
1076
+ const fill = getFillByElement(board, element);
1077
+ if (isFilled(fill)) {
1078
+ filledElement = element;
1079
+ break;
1080
+ }
1081
+ }
1082
+ }
1083
+ return filledElement;
1084
+ };
1085
+ const getFirstTextOrLineElement = (elements) => {
1086
+ const texts = elements.filter(item => PlaitDrawElement.isText(item));
1087
+ if (texts.length) {
1088
+ return texts[0];
1089
+ }
1090
+ const lines = elements.filter(item => PlaitDrawElement.isArrowLine(item));
1091
+ if (lines.length) {
1092
+ return lines[0];
1093
+ }
1094
+ return null;
1095
+ };
1006
1096
  const isHitDrawElement = (board, element, point) => {
1007
1097
  const rectangle = board.getRectangle(element);
1008
1098
  point = rotateAntiPointsByElement(point, element) || point;
1009
1099
  if (PlaitDrawElement.isGeometry(element)) {
1010
- const fill = getFillByElement(board, element);
1011
1100
  if (isHitEdgeOfShape(board, element, point, HIT_DISTANCE_BUFFER)) {
1012
1101
  return true;
1013
1102
  }
1014
1103
  const engine = getEngine(getElementShape(element));
1015
- // when shape equals text, fill is not allowed
1016
- if (fill !== DefaultDrawStyle.fill && fill !== TRANSPARENT && !PlaitDrawElement.isText(element)) {
1017
- const isHitInside = engine.isInsidePoint(rectangle, point);
1018
- if (isHitInside) {
1019
- return isHitInside;
1020
- }
1021
- }
1022
- else {
1023
- // if shape equals text, only check text rectangle
1024
- if (PlaitDrawElement.isText(element)) {
1025
- const textClient = getTextRectangle(element);
1026
- let isHitText = RectangleClient.isPointInRectangle(textClient, point);
1027
- return isHitText;
1028
- }
1029
- // check textRectangle of element
1030
- const isHitText = isHitElementText(element, point);
1031
- if (isHitText) {
1032
- return isHitText;
1033
- }
1104
+ if (PlaitDrawElement.isText(element)) {
1105
+ const textClient = getTextRectangle(element);
1106
+ return RectangleClient.isPointInRectangle(textClient, point);
1034
1107
  }
1108
+ const isHitText = isHitElementText(element, point);
1109
+ return isHitText || engine.isInsidePoint(rectangle, point);
1035
1110
  }
1036
1111
  if (PlaitDrawElement.isImage(element)) {
1037
1112
  const client = RectangleClient.getRectangleByPoints(element.points);
1038
1113
  return RectangleClient.isPointInRectangle(client, point);
1039
1114
  }
1040
- if (PlaitDrawElement.isLine(element)) {
1041
- return isHitLine(board, element, point);
1115
+ if (PlaitDrawElement.isArrowLine(element)) {
1116
+ return isHitArrowLine(board, element, point);
1042
1117
  }
1043
1118
  return null;
1044
1119
  };
@@ -1071,8 +1146,8 @@ const isHitElementInside = (board, element, point) => {
1071
1146
  const client = RectangleClient.getRectangleByPoints(element.points);
1072
1147
  return RectangleClient.isPointInRectangle(client, point);
1073
1148
  }
1074
- if (PlaitDrawElement.isLine(element)) {
1075
- return isHitLine(board, element, point);
1149
+ if (PlaitDrawElement.isArrowLine(element)) {
1150
+ return isHitArrowLine(board, element, point);
1076
1151
  }
1077
1152
  return null;
1078
1153
  };
@@ -1113,7 +1188,7 @@ const isDrawElementIncludeText = (element) => {
1113
1188
  if (PlaitDrawElement.isGeometry(element)) {
1114
1189
  return isGeometryIncludeText(element);
1115
1190
  }
1116
- if (PlaitDrawElement.isLine(element)) {
1191
+ if (PlaitDrawElement.isArrowLine(element)) {
1117
1192
  const editors = getTextEditorsByElement(element);
1118
1193
  return editors.length > 0;
1119
1194
  }
@@ -1127,6 +1202,15 @@ const isDrawElementsIncludeText = (elements) => {
1127
1202
  return isDrawElementIncludeText(item);
1128
1203
  });
1129
1204
  };
1205
+ const isDrawElementClosed = (element) => {
1206
+ if (PlaitDrawElement.isText(element) || PlaitDrawElement.isArrowLine(element) || PlaitDrawElement.isImage(element)) {
1207
+ return false;
1208
+ }
1209
+ if (PlaitDrawElement.isGeometry(element)) {
1210
+ return isGeometryClosed(element);
1211
+ }
1212
+ return true;
1213
+ };
1130
1214
  const getSnappingShape = (board, point) => {
1131
1215
  let hitElement = getHitShape(board, point);
1132
1216
  if (hitElement) {
@@ -1181,7 +1265,7 @@ const drawBoundReaction = (board, element, roughOptions = { hasMask: true, hasCo
1181
1265
  const maskG = drawShape(board, activeRectangle, shape, {
1182
1266
  stroke: SELECTION_BORDER_COLOR,
1183
1267
  strokeWidth: 0,
1184
- fill: SELECTION_FILL_COLOR,
1268
+ fill: isDrawElementClosed(element) ? SELECTION_FILL_COLOR : DefaultDrawStyle.fill,
1185
1269
  fillStyle: 'solid'
1186
1270
  }, drawOptions);
1187
1271
  g.appendChild(maskG);
@@ -1229,7 +1313,7 @@ const getStrokeColorByElement = (board, element) => {
1229
1313
  return strokeColor;
1230
1314
  };
1231
1315
  const getFillByElement = (board, element) => {
1232
- const defaultFill = PlaitDrawElement.isFlowchart(element)
1316
+ const defaultFill = PlaitDrawElement.isFlowchart(element) && isDrawElementClosed(element)
1233
1317
  ? getFlowchartDefaultFill(board.theme.themeColorMode)
1234
1318
  : DefaultDrawStyle.fill;
1235
1319
  const fill = element.fill || defaultFill;
@@ -1240,7 +1324,7 @@ const getLineDashByElement = (element) => {
1240
1324
  case StrokeStyle.dashed:
1241
1325
  return [8, 8 + getStrokeWidthByElement(element)];
1242
1326
  case StrokeStyle.dotted:
1243
- return [0, 4 + getStrokeWidthByElement(element)];
1327
+ return [2, 4 + getStrokeWidthByElement(element)];
1244
1328
  default:
1245
1329
  return undefined;
1246
1330
  }
@@ -1261,13 +1345,13 @@ const LINE_AUTO_COMPLETE_HOVERED_DIAMETER = 10;
1261
1345
  const LINE_ALIGN_TOLERANCE = 3;
1262
1346
  const LINE_TEXT = '文本';
1263
1347
 
1264
- class LineShapeGenerator extends Generator {
1348
+ class ArrowLineShapeGenerator extends Generator {
1265
1349
  canDraw(element, data) {
1266
1350
  return true;
1267
1351
  }
1268
1352
  draw(element, data) {
1269
1353
  let lineG;
1270
- lineG = drawLine(this.board, element);
1354
+ lineG = drawArrowLine(this.board, element);
1271
1355
  return lineG;
1272
1356
  }
1273
1357
  }
@@ -1408,7 +1492,7 @@ function getIndexAndDeleteCountByKeyPoint(board, element, dataPoints, nextRender
1408
1492
  if (index === null) {
1409
1493
  deleteCount = 0;
1410
1494
  if (midDataPoints.length > 0) {
1411
- const handleRefPair = getLineHandleRefPair(board, element);
1495
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
1412
1496
  const params = getElbowLineRouteOptions(board, element, handleRefPair);
1413
1497
  const keyPoints = removeDuplicatePoints(generateElbowLineRoute(params, board));
1414
1498
  const nextKeyPoints = simplifyOrthogonalPoints(keyPoints.slice(1, keyPoints.length - 1));
@@ -1578,9 +1662,9 @@ const hasIllegalElbowPoint = (midDataPoints) => {
1578
1662
  };
1579
1663
 
1580
1664
  const ARROW_LENGTH = 20;
1581
- const drawLineArrow = (element, points, options) => {
1665
+ const drawArrowLineArrow = (element, points, options) => {
1582
1666
  const arrowG = createG();
1583
- if (PlaitLine.isSourceMark(element, LineMarkerType.none) && PlaitLine.isTargetMark(element, LineMarkerType.none)) {
1667
+ if (PlaitArrowLine.isSourceMark(element, ArrowLineMarkerType.none) && PlaitArrowLine.isTargetMark(element, ArrowLineMarkerType.none)) {
1584
1668
  return null;
1585
1669
  }
1586
1670
  const strokeWidth = getStrokeWidthByElement(element);
@@ -1588,12 +1672,12 @@ const drawLineArrow = (element, points, options) => {
1588
1672
  if (points.length === 1) {
1589
1673
  points = [points[0], [points[0][0] + 0.1, points[0][1]]];
1590
1674
  }
1591
- if (!PlaitLine.isSourceMark(element, LineMarkerType.none)) {
1675
+ if (!PlaitArrowLine.isSourceMark(element, ArrowLineMarkerType.none)) {
1592
1676
  const source = getExtendPoint(points[0], points[1], ARROW_LENGTH + offset);
1593
1677
  const sourceArrow = getArrow(element, { marker: element.source.marker, source, target: points[0], isSource: true }, options);
1594
1678
  sourceArrow && arrowG.appendChild(sourceArrow);
1595
1679
  }
1596
- if (!PlaitLine.isTargetMark(element, LineMarkerType.none)) {
1680
+ if (!PlaitArrowLine.isTargetMark(element, ArrowLineMarkerType.none)) {
1597
1681
  const source = getExtendPoint(points[points.length - 1], points[points.length - 2], ARROW_LENGTH + offset);
1598
1682
  const arrow = getArrow(element, { marker: element.target.marker, source, target: points[points.length - 1], isSource: false }, options);
1599
1683
  arrow && arrowG.appendChild(arrow);
@@ -1604,35 +1688,35 @@ const getArrow = (element, arrowOptions, options) => {
1604
1688
  const { marker, target, source, isSource } = arrowOptions;
1605
1689
  let targetArrow;
1606
1690
  switch (marker) {
1607
- case LineMarkerType.openTriangle: {
1691
+ case ArrowLineMarkerType.openTriangle: {
1608
1692
  targetArrow = drawOpenTriangle(element, source, target, options);
1609
1693
  break;
1610
1694
  }
1611
- case LineMarkerType.solidTriangle: {
1695
+ case ArrowLineMarkerType.solidTriangle: {
1612
1696
  targetArrow = drawSolidTriangle(source, target, options);
1613
1697
  break;
1614
1698
  }
1615
- case LineMarkerType.arrow: {
1699
+ case ArrowLineMarkerType.arrow: {
1616
1700
  targetArrow = drawArrow(element, source, target, options);
1617
1701
  break;
1618
1702
  }
1619
- case LineMarkerType.sharpArrow: {
1703
+ case ArrowLineMarkerType.sharpArrow: {
1620
1704
  targetArrow = drawSharpArrow(source, target, options);
1621
1705
  break;
1622
1706
  }
1623
- case LineMarkerType.oneSideUp: {
1707
+ case ArrowLineMarkerType.oneSideUp: {
1624
1708
  targetArrow = drawOneSideArrow(source, target, isSource ? 'down' : 'up', options);
1625
1709
  break;
1626
1710
  }
1627
- case LineMarkerType.oneSideDown: {
1711
+ case ArrowLineMarkerType.oneSideDown: {
1628
1712
  targetArrow = drawOneSideArrow(source, target, isSource ? 'up' : 'down', options);
1629
1713
  break;
1630
1714
  }
1631
- case LineMarkerType.hollowTriangle: {
1715
+ case ArrowLineMarkerType.hollowTriangle: {
1632
1716
  targetArrow = drawHollowTriangleArrow(source, target, options);
1633
1717
  break;
1634
1718
  }
1635
- case LineMarkerType.singleSlash: {
1719
+ case ArrowLineMarkerType.singleSlash: {
1636
1720
  targetArrow = drawSingleSlash(source, target, isSource, options);
1637
1721
  break;
1638
1722
  }
@@ -1696,10 +1780,10 @@ const drawHollowTriangleArrow = (source, target, options) => {
1696
1780
  return drawLinearPath([pointLeft, pointRight, target], { ...options, fill: 'white' }, true);
1697
1781
  };
1698
1782
 
1699
- const createLineElement = (shape, points, source, target, texts, options) => {
1783
+ const createArrowLineElement = (shape, points, source, target, texts, options) => {
1700
1784
  return {
1701
1785
  id: idCreator(),
1702
- type: 'line',
1786
+ type: 'arrow-line',
1703
1787
  shape,
1704
1788
  source,
1705
1789
  texts: texts ? texts : [],
@@ -1709,17 +1793,17 @@ const createLineElement = (shape, points, source, target, texts, options) => {
1709
1793
  ...options
1710
1794
  };
1711
1795
  };
1712
- const getLinePoints = (board, element) => {
1796
+ const getArrowLinePoints = (board, element) => {
1713
1797
  switch (element.shape) {
1714
- case LineShape.elbow: {
1798
+ case ArrowLineShape.elbow: {
1715
1799
  return getElbowPoints(board, element);
1716
1800
  }
1717
- case LineShape.curve: {
1801
+ case ArrowLineShape.curve: {
1718
1802
  return getCurvePoints(board, element);
1719
1803
  }
1720
1804
  default: {
1721
- const points = PlaitLine.getPoints(board, element);
1722
- const handleRefPair = getLineHandleRefPair(board, element);
1805
+ const points = PlaitArrowLine.getPoints(board, element);
1806
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
1723
1807
  points[0] = handleRefPair.source.point;
1724
1808
  points[points.length - 1] = handleRefPair.target.point;
1725
1809
  return points;
@@ -1728,7 +1812,7 @@ const getLinePoints = (board, element) => {
1728
1812
  };
1729
1813
  const getCurvePoints = (board, element) => {
1730
1814
  if (element.points.length === 2) {
1731
- const handleRefPair = getLineHandleRefPair(board, element);
1815
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
1732
1816
  const { source, target } = handleRefPair;
1733
1817
  const sourceBoundElement = handleRefPair.source.boundElement;
1734
1818
  const targetBoundElement = handleRefPair.target.boundElement;
@@ -1755,7 +1839,7 @@ const getCurvePoints = (board, element) => {
1755
1839
  return pointsOnBezierCurves(curvePoints);
1756
1840
  }
1757
1841
  else {
1758
- let dataPoints = PlaitLine.getPoints(board, element);
1842
+ let dataPoints = PlaitArrowLine.getPoints(board, element);
1759
1843
  dataPoints = removeDuplicatePoints(dataPoints);
1760
1844
  const points = catmullRomFitting(dataPoints);
1761
1845
  return pointsOnBezierCurves(points);
@@ -1765,8 +1849,8 @@ function getMiddlePoints(board, element) {
1765
1849
  const result = [];
1766
1850
  const shape = element.shape;
1767
1851
  const hideBuffer = 10;
1768
- if (shape === LineShape.straight) {
1769
- const points = PlaitLine.getPoints(board, element);
1852
+ if (shape === ArrowLineShape.straight) {
1853
+ const points = PlaitArrowLine.getPoints(board, element);
1770
1854
  for (let i = 0; i < points.length - 1; i++) {
1771
1855
  const distance = distanceBetweenPointAndPoint(...points[i], ...points[i + 1]);
1772
1856
  if (distance < hideBuffer)
@@ -1774,8 +1858,8 @@ function getMiddlePoints(board, element) {
1774
1858
  result.push([(points[i][0] + points[i + 1][0]) / 2, (points[i][1] + points[i + 1][1]) / 2]);
1775
1859
  }
1776
1860
  }
1777
- if (shape === LineShape.curve) {
1778
- const points = PlaitLine.getPoints(board, element);
1861
+ if (shape === ArrowLineShape.curve) {
1862
+ const points = PlaitArrowLine.getPoints(board, element);
1779
1863
  const pointsOnBezier = getCurvePoints(board, element);
1780
1864
  if (points.length === 2) {
1781
1865
  const start = 0;
@@ -1795,7 +1879,7 @@ function getMiddlePoints(board, element) {
1795
1879
  }
1796
1880
  }
1797
1881
  }
1798
- if (shape === LineShape.elbow) {
1882
+ if (shape === ArrowLineShape.elbow) {
1799
1883
  const renderPoints = getElbowPoints(board, element);
1800
1884
  const options = getElbowLineRouteOptions(board, element);
1801
1885
  if (!isUseDefaultOrthogonalRoute(element, options)) {
@@ -1814,15 +1898,15 @@ function getMiddlePoints(board, element) {
1814
1898
  }
1815
1899
  return result;
1816
1900
  }
1817
- const drawLine = (board, element) => {
1901
+ const drawArrowLine = (board, element) => {
1818
1902
  const strokeWidth = getStrokeWidthByElement(element);
1819
1903
  const strokeColor = getStrokeColorByElement(board, element);
1820
1904
  const strokeLineDash = getLineDashByElement(element);
1821
1905
  const options = { stroke: strokeColor, strokeWidth, strokeLineDash };
1822
1906
  const lineG = createG();
1823
- let points = getLinePoints(board, element);
1907
+ let points = getArrowLinePoints(board, element);
1824
1908
  let line;
1825
- if (element.shape === LineShape.curve) {
1909
+ if (element.shape === ArrowLineShape.curve) {
1826
1910
  line = PlaitBoard.getRoughSVG(board).curve(points, options);
1827
1911
  }
1828
1912
  else {
@@ -1834,10 +1918,10 @@ const drawLine = (board, element) => {
1834
1918
  setStrokeLinecap(line, 'round');
1835
1919
  }
1836
1920
  lineG.appendChild(line);
1837
- const { mask, maskTargetFillRect } = drawMask(board, element, id);
1921
+ const { mask, maskTargetFillRect } = drawArrowLineMask(board, element, id);
1838
1922
  lineG.appendChild(mask);
1839
1923
  line.appendChild(maskTargetFillRect);
1840
- const arrow = drawLineArrow(element, points, { stroke: strokeColor, strokeWidth });
1924
+ const arrow = drawArrowLineArrow(element, points, { stroke: strokeColor, strokeWidth });
1841
1925
  arrow && lineG.appendChild(arrow);
1842
1926
  return lineG;
1843
1927
  };
@@ -1855,9 +1939,9 @@ const getHitConnectorPoint = (point, hitElement) => {
1855
1939
  return distanceBetweenPointAndPoint(...connectorPoint, ...point) <= LINE_SNAPPING_CONNECTOR_BUFFER;
1856
1940
  });
1857
1941
  };
1858
- const getLineTextRectangle = (board, element, index) => {
1942
+ const getArrowLineTextRectangle = (board, element, index) => {
1859
1943
  const text = element.texts[index];
1860
- const elbowPoints = getLinePoints(board, element);
1944
+ const elbowPoints = getArrowLinePoints(board, element);
1861
1945
  const point = getPointOnPolyline(elbowPoints, text.position);
1862
1946
  return {
1863
1947
  x: point[0] - text.width / 2,
@@ -1866,9 +1950,9 @@ const getLineTextRectangle = (board, element, index) => {
1866
1950
  height: text.height
1867
1951
  };
1868
1952
  };
1869
- const getLines = (board) => {
1953
+ const getArrowLines = (board) => {
1870
1954
  return findElements(board, {
1871
- match: (element) => PlaitDrawElement.isLine(element),
1955
+ match: (element) => PlaitDrawElement.isArrowLine(element),
1872
1956
  recursion: (element) => PlaitDrawElement.isDrawElement(element)
1873
1957
  });
1874
1958
  };
@@ -1888,33 +1972,33 @@ const Q2C = (points) => {
1888
1972
  }
1889
1973
  return result;
1890
1974
  };
1891
- const handleLineCreating = (board, lineShape, sourcePoint, movingPoint, sourceElement, lineShapeG) => {
1975
+ const handleArrowLineCreating = (board, lineShape, sourcePoint, movingPoint, sourceElement, lineShapeG) => {
1892
1976
  const hitElement = getSnappingShape(board, movingPoint);
1893
1977
  const targetConnection = hitElement ? getHitConnection(board, movingPoint, hitElement) : undefined;
1894
1978
  const sourceConnection = sourceElement ? getHitConnection(board, sourcePoint, sourceElement) : undefined;
1895
1979
  const targetBoundId = hitElement ? hitElement.id : undefined;
1896
- const lineGenerator = new LineShapeGenerator(board);
1980
+ const lineGenerator = new ArrowLineShapeGenerator(board);
1897
1981
  const memorizedLatest = getLineMemorizedLatest();
1898
1982
  let sourceMarker, targetMarker;
1899
1983
  sourceMarker = memorizedLatest.source;
1900
1984
  targetMarker = memorizedLatest.target;
1901
1985
  sourceMarker && delete memorizedLatest.source;
1902
1986
  targetMarker && delete memorizedLatest.target;
1903
- const temporaryLineElement = createLineElement(lineShape, [sourcePoint, movingPoint], { marker: sourceMarker || LineMarkerType.none, connection: sourceConnection, boundId: sourceElement?.id }, { marker: targetMarker || LineMarkerType.arrow, connection: targetConnection, boundId: targetBoundId }, [], {
1987
+ const temporaryLineElement = createArrowLineElement(lineShape, [sourcePoint, movingPoint], { marker: sourceMarker || ArrowLineMarkerType.none, connection: sourceConnection, boundId: sourceElement?.id }, { marker: targetMarker || ArrowLineMarkerType.arrow, connection: targetConnection, boundId: targetBoundId }, [], {
1904
1988
  strokeWidth: DefaultLineStyle.strokeWidth,
1905
1989
  ...memorizedLatest
1906
1990
  });
1907
- const linePoints = getLinePoints(board, temporaryLineElement);
1991
+ const linePoints = getArrowLinePoints(board, temporaryLineElement);
1908
1992
  const otherPoint = linePoints[0];
1909
1993
  temporaryLineElement.points[1] = alignPoints(otherPoint, movingPoint);
1910
1994
  lineGenerator.processDrawing(temporaryLineElement, lineShapeG);
1911
1995
  PlaitBoard.getElementActiveHost(board).append(lineShapeG);
1912
1996
  return temporaryLineElement;
1913
1997
  };
1914
- function drawMask(board, element, id) {
1998
+ function drawArrowLineMask(board, element, id) {
1915
1999
  const mask = createMask();
1916
2000
  mask.setAttribute('id', id);
1917
- const points = getLinePoints(board, element);
2001
+ const points = getArrowLinePoints(board, element);
1918
2002
  let rectangle = RectangleClient.getRectangleByPoints(points);
1919
2003
  rectangle = RectangleClient.getOutlineRectangle(rectangle, -30);
1920
2004
  const maskFillRect = createRect(rectangle, {
@@ -1923,7 +2007,7 @@ function drawMask(board, element, id) {
1923
2007
  mask.appendChild(maskFillRect);
1924
2008
  const texts = element.texts;
1925
2009
  texts.forEach((text, index) => {
1926
- let textRectangle = getLineTextRectangle(board, element, index);
2010
+ let textRectangle = getArrowLineTextRectangle(board, element, index);
1927
2011
  textRectangle = RectangleClient.inflate(textRectangle, LINE_TEXT_SPACE * 2);
1928
2012
  const rect = createRect(textRectangle, {
1929
2013
  fill: 'black'
@@ -2109,18 +2193,18 @@ const createDefaultFlowchart = (point) => {
2109
2193
  const processElement2 = createGeometryElement(FlowchartSymbols.process, getDefaultGeometryPoints(FlowchartSymbols.process, processPoint2), '过程', options);
2110
2194
  const endPoint = [decisionPoint[0], decisionPoint[1] + decisionProperty.height / 2 + 95 + terminalProperty.height / 2];
2111
2195
  const endElement = createGeometryElement(FlowchartSymbols.terminal, getDefaultGeometryPoints(FlowchartSymbols.terminal, endPoint), '结束', options);
2112
- const line1 = createLineElement(LineShape.elbow, [
2196
+ const line1 = createArrowLineElement(ArrowLineShape.elbow, [
2113
2197
  [0, 0],
2114
2198
  [0, 0]
2115
- ], { marker: LineMarkerType.none, connection: [0.5, 1], boundId: startElement.id }, { marker: LineMarkerType.arrow, connection: [0.5, 0], boundId: processElement1.id }, [], lineOptions);
2116
- const line2 = createLineElement(LineShape.elbow, [
2199
+ ], { marker: ArrowLineMarkerType.none, connection: [0.5, 1], boundId: startElement.id }, { marker: ArrowLineMarkerType.arrow, connection: [0.5, 0], boundId: processElement1.id }, [], lineOptions);
2200
+ const line2 = createArrowLineElement(ArrowLineShape.elbow, [
2117
2201
  [0, 0],
2118
2202
  [0, 0]
2119
- ], { marker: LineMarkerType.none, connection: [0.5, 1], boundId: processElement1.id }, { marker: LineMarkerType.arrow, connection: [0.5, 0], boundId: decisionElement.id }, [], lineOptions);
2120
- const line3 = createLineElement(LineShape.elbow, [
2203
+ ], { marker: ArrowLineMarkerType.none, connection: [0.5, 1], boundId: processElement1.id }, { marker: ArrowLineMarkerType.arrow, connection: [0.5, 0], boundId: decisionElement.id }, [], lineOptions);
2204
+ const line3 = createArrowLineElement(ArrowLineShape.elbow, [
2121
2205
  [0, 0],
2122
2206
  [0, 0]
2123
- ], { marker: LineMarkerType.none, connection: [0.5, 1], boundId: decisionElement.id }, { marker: LineMarkerType.arrow, connection: [0.5, 0], boundId: endElement.id }, [
2207
+ ], { marker: ArrowLineMarkerType.none, connection: [0.5, 1], boundId: decisionElement.id }, { marker: ArrowLineMarkerType.arrow, connection: [0.5, 0], boundId: endElement.id }, [
2124
2208
  {
2125
2209
  text: buildText('是'),
2126
2210
  position: 0.5,
@@ -2128,10 +2212,10 @@ const createDefaultFlowchart = (point) => {
2128
2212
  height: 20
2129
2213
  }
2130
2214
  ], lineOptions);
2131
- const line4 = createLineElement(LineShape.elbow, [
2215
+ const line4 = createArrowLineElement(ArrowLineShape.elbow, [
2132
2216
  [0, 0],
2133
2217
  [0, 0]
2134
- ], { marker: LineMarkerType.none, connection: [1, 0.5], boundId: decisionElement.id }, { marker: LineMarkerType.arrow, connection: [0, 0.5], boundId: processElement2.id }, [
2218
+ ], { marker: ArrowLineMarkerType.none, connection: [1, 0.5], boundId: decisionElement.id }, { marker: ArrowLineMarkerType.arrow, connection: [0, 0.5], boundId: processElement2.id }, [
2135
2219
  {
2136
2220
  text: buildText('否'),
2137
2221
  position: 0.5,
@@ -2139,10 +2223,10 @@ const createDefaultFlowchart = (point) => {
2139
2223
  height: 20
2140
2224
  }
2141
2225
  ], lineOptions);
2142
- const line5 = createLineElement(LineShape.elbow, [
2226
+ const line5 = createArrowLineElement(ArrowLineShape.elbow, [
2143
2227
  [0, 0],
2144
2228
  [0, 0]
2145
- ], { marker: LineMarkerType.none, connection: [0.5, 1], boundId: processElement2.id }, { marker: LineMarkerType.arrow, connection: [1, 0.5], boundId: endElement.id }, [], lineOptions);
2229
+ ], { marker: ArrowLineMarkerType.none, connection: [0.5, 1], boundId: processElement2.id }, { marker: ArrowLineMarkerType.arrow, connection: [1, 0.5], boundId: endElement.id }, [], lineOptions);
2146
2230
  return [startElement, processElement1, decisionElement, processElement2, endElement, line1, line2, line3, line4, line5];
2147
2231
  };
2148
2232
  const getAutoCompletePoints = (element) => {
@@ -2248,6 +2332,9 @@ const isSingleTextShape = (shape) => {
2248
2332
  const isSingleTextGeometry = (element) => {
2249
2333
  return PlaitDrawElement.isGeometry(element) && isSingleTextShape(element.shape);
2250
2334
  };
2335
+ const isGeometryClosed = (element) => {
2336
+ return !GEOMETRY_NOT_CLOSED.includes(element.shape);
2337
+ };
2251
2338
 
2252
2339
  const isSelfLoop = (element) => {
2253
2340
  return element.source.boundId && element.source.boundId === element.target.boundId;
@@ -2256,7 +2343,7 @@ const isUseDefaultOrthogonalRoute = (element, options) => {
2256
2343
  return isSourceAndTargetIntersect(options) && !isSelfLoop(element);
2257
2344
  };
2258
2345
  const getElbowPoints = (board, element) => {
2259
- const handleRefPair = getLineHandleRefPair(board, element);
2346
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
2260
2347
  const params = getElbowLineRouteOptions(board, element, handleRefPair);
2261
2348
  // console.log(params, 'params');
2262
2349
  if (isUseDefaultOrthogonalRoute(element, params)) {
@@ -2269,7 +2356,7 @@ const getElbowPoints = (board, element) => {
2269
2356
  }
2270
2357
  else {
2271
2358
  const simplifiedNextKeyPoints = simplifyOrthogonalPoints(nextKeyPoints);
2272
- const dataPoints = removeDuplicatePoints(PlaitLine.getPoints(board, element));
2359
+ const dataPoints = removeDuplicatePoints(PlaitArrowLine.getPoints(board, element));
2273
2360
  const midDataPoints = dataPoints.slice(1, -1);
2274
2361
  if (hasIllegalElbowPoint(midDataPoints)) {
2275
2362
  return simplifyOrthogonalPoints(keyPoints);
@@ -2364,8 +2451,8 @@ const getSelectedGeometryElements = (board) => {
2364
2451
  const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isGeometry(value));
2365
2452
  return selectedElements;
2366
2453
  };
2367
- const getSelectedLineElements = (board) => {
2368
- const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isLine(value));
2454
+ const getSelectedArrowLineElements = (board) => {
2455
+ const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isArrowLine(value));
2369
2456
  return selectedElements;
2370
2457
  };
2371
2458
  const getSelectedImageElements = (board) => {
@@ -2381,126 +2468,11 @@ const getSelectedSwimlane = (board) => {
2381
2468
  return selectedElements.find(item => PlaitDrawElement.isSwimlane(item));
2382
2469
  };
2383
2470
 
2384
- const resizeLine = (board, options, path) => {
2385
- Transforms.setNode(board, options, path);
2386
- };
2387
- const setLineTexts = (board, element, texts) => {
2388
- const path = PlaitBoard.findPath(board, element);
2389
- Transforms.setNode(board, { texts }, path);
2390
- };
2391
- const removeLineText = (board, element, index) => {
2392
- const path = PlaitBoard.findPath(board, element);
2393
- const texts = element.texts?.length ? [...element.texts] : [];
2394
- const newTexts = [...texts];
2395
- newTexts.splice(index, 1);
2396
- Transforms.setNode(board, { texts: newTexts }, path);
2397
- };
2398
- const setLineMark = (board, handleKey, marker) => {
2399
- memorizeLatest(MemorizeKey.line, handleKey, marker);
2400
- const selectedElements = getSelectedLineElements(board);
2401
- selectedElements.forEach((element) => {
2402
- const path = PlaitBoard.findPath(board, element);
2403
- let handle = handleKey === LineHandleKey.source ? element.source : element.target;
2404
- handle = { ...handle, marker };
2405
- Transforms.setNode(board, { [handleKey]: handle }, path);
2406
- });
2407
- };
2408
- const setLineShape = (board, newProperties) => {
2409
- const elements = getSelectedLineElements(board);
2410
- elements.map(element => {
2411
- const _properties = { ...newProperties };
2412
- if (element.shape === newProperties.shape) {
2413
- return;
2414
- }
2415
- const path = PlaitBoard.findPath(board, element);
2416
- Transforms.setNode(board, _properties, path);
2417
- });
2418
- };
2419
- const collectLineUpdatedRefsByGeometry = (board, geometry, refs) => {
2420
- const lines = findElements(board, {
2421
- match: (element) => {
2422
- if (PlaitDrawElement.isLine(element)) {
2423
- return element.source.boundId === geometry.id || element.target.boundId === geometry.id;
2424
- }
2425
- return false;
2426
- },
2427
- recursion: element => true
2428
- });
2429
- if (lines.length) {
2430
- lines.forEach(line => {
2431
- const isSourceBound = line.source.boundId === geometry.id;
2432
- const handle = isSourceBound ? 'source' : 'target';
2433
- const object = { ...line[handle] };
2434
- const linePoints = getLinePoints(board, line);
2435
- const point = isSourceBound ? linePoints[0] : linePoints[linePoints.length - 1];
2436
- object.connection = getHitConnection(board, point, geometry);
2437
- const path = PlaitBoard.findPath(board, line);
2438
- const index = refs.findIndex(obj => Path.equals(obj.path, path));
2439
- if (index === -1) {
2440
- refs.push({
2441
- property: {
2442
- [handle]: object
2443
- },
2444
- path
2445
- });
2446
- }
2447
- else {
2448
- refs[index].property = { ...refs[index].property, [handle]: object };
2449
- }
2450
- });
2451
- }
2452
- };
2453
- const connectLineToGeometry = (board, lineElement, handle, geometryElement) => {
2454
- const linePoints = PlaitLine.getPoints(board, lineElement);
2455
- const point = handle === LineHandleKey.source ? linePoints[0] : linePoints[linePoints.length - 1];
2456
- const connection = getHitConnection(board, point, geometryElement);
2457
- if (connection) {
2458
- let source = lineElement.source;
2459
- let target = lineElement.target;
2460
- if (handle === LineHandleKey.source) {
2461
- source = {
2462
- ...source,
2463
- boundId: geometryElement.id,
2464
- connection
2465
- };
2466
- }
2467
- else {
2468
- target = {
2469
- ...target,
2470
- boundId: geometryElement.id,
2471
- connection
2472
- };
2473
- }
2474
- const path = PlaitBoard.findPath(board, lineElement);
2475
- resizeLine(board, { source, target }, path);
2476
- }
2477
- };
2478
-
2479
2471
  const insertGeometry = (board, points, shape) => {
2480
2472
  const newElement = createDefaultGeometry(board, points, shape);
2481
2473
  insertElement(board, newElement);
2482
2474
  return newElement;
2483
2475
  };
2484
- const insertGeometryByVector = (board, point, shape, vector) => {
2485
- const shapeProperty = DefaultFlowchartPropertyMap[shape] ||
2486
- DefaultBasicShapePropertyMap[shape] ||
2487
- DefaultUMLPropertyMap[shape] ||
2488
- DefaultBasicShapeProperty;
2489
- const direction = getDirectionByVector(vector);
2490
- if (direction) {
2491
- let offset = 0;
2492
- if ([Direction.left, Direction.right].includes(direction)) {
2493
- offset = -shapeProperty.width / 2;
2494
- }
2495
- else {
2496
- offset = -shapeProperty.height / 2;
2497
- }
2498
- const vectorPoint = getPointByVectorComponent(point, vector, offset);
2499
- const points = RectangleClient.getPoints(RectangleClient.getRectangleByCenterPoint(vectorPoint, shapeProperty.width, shapeProperty.height));
2500
- return insertGeometry(board, points, shape);
2501
- }
2502
- return null;
2503
- };
2504
2476
  const insertText = (board, point, text) => {
2505
2477
  const memorizedLatest = getMemorizedLatestByPointer(BasicShapes.text);
2506
2478
  const property = getTextShapeProperty(board, text, memorizedLatest.textProperties['font-size']);
@@ -2525,12 +2497,12 @@ const switchGeometryShape = (board, shape) => {
2525
2497
  if (PlaitDrawElement.isGeometry(item) && !PlaitDrawElement.isText(item)) {
2526
2498
  const path = PlaitBoard.findPath(board, item);
2527
2499
  Transforms.setNode(board, { shape }, path);
2528
- collectLineUpdatedRefsByGeometry(board, { ...item, shape }, refs);
2500
+ collectArrowLineUpdatedRefsByGeometry(board, { ...item, shape }, refs);
2529
2501
  }
2530
2502
  });
2531
2503
  if (refs.length) {
2532
2504
  refs.forEach(ref => {
2533
- DrawTransforms.resizeLine(board, ref.property, ref.path);
2505
+ DrawTransforms.resizeArrowLine(board, ref.property, ref.path);
2534
2506
  });
2535
2507
  }
2536
2508
  };
@@ -2610,6 +2582,67 @@ const insertImage = (board, imageItem, startPoint) => {
2610
2582
  Transforms.addSelectionWithTemporaryElements(board, [imageElement]);
2611
2583
  };
2612
2584
 
2585
+ const resizeArrowLine = (board, options, path) => {
2586
+ Transforms.setNode(board, options, path);
2587
+ };
2588
+ const setArrowLineTexts = (board, element, texts) => {
2589
+ const path = PlaitBoard.findPath(board, element);
2590
+ Transforms.setNode(board, { texts }, path);
2591
+ };
2592
+ const removeArrowLineText = (board, element, index) => {
2593
+ const path = PlaitBoard.findPath(board, element);
2594
+ const texts = element.texts?.length ? [...element.texts] : [];
2595
+ const newTexts = [...texts];
2596
+ newTexts.splice(index, 1);
2597
+ Transforms.setNode(board, { texts: newTexts }, path);
2598
+ };
2599
+ const setArrowLineMark = (board, handleKey, marker) => {
2600
+ memorizeLatest(MemorizeKey.arrowLine, handleKey, marker);
2601
+ const selectedElements = getSelectedArrowLineElements(board);
2602
+ selectedElements.forEach((element) => {
2603
+ const path = PlaitBoard.findPath(board, element);
2604
+ let handle = handleKey === ArrowLineHandleKey.source ? element.source : element.target;
2605
+ handle = { ...handle, marker };
2606
+ Transforms.setNode(board, { [handleKey]: handle }, path);
2607
+ });
2608
+ };
2609
+ const setArrowLineShape = (board, newProperties) => {
2610
+ const elements = getSelectedArrowLineElements(board);
2611
+ elements.map(element => {
2612
+ const _properties = { ...newProperties };
2613
+ if (element.shape === newProperties.shape) {
2614
+ return;
2615
+ }
2616
+ const path = PlaitBoard.findPath(board, element);
2617
+ Transforms.setNode(board, _properties, path);
2618
+ });
2619
+ };
2620
+ const connectArrowLineToDraw = (board, lineElement, handle, geometryElement) => {
2621
+ const linePoints = PlaitArrowLine.getPoints(board, lineElement);
2622
+ const point = handle === ArrowLineHandleKey.source ? linePoints[0] : linePoints[linePoints.length - 1];
2623
+ const connection = getHitConnection(board, point, geometryElement);
2624
+ if (connection) {
2625
+ let source = lineElement.source;
2626
+ let target = lineElement.target;
2627
+ if (handle === ArrowLineHandleKey.source) {
2628
+ source = {
2629
+ ...source,
2630
+ boundId: geometryElement.id,
2631
+ connection
2632
+ };
2633
+ }
2634
+ else {
2635
+ target = {
2636
+ ...target,
2637
+ boundId: geometryElement.id,
2638
+ connection
2639
+ };
2640
+ }
2641
+ const path = PlaitBoard.findPath(board, lineElement);
2642
+ resizeArrowLine(board, { source, target }, path);
2643
+ }
2644
+ };
2645
+
2613
2646
  function buildSwimlaneTable(element) {
2614
2647
  const swimlaneElement = { ...element };
2615
2648
  if (PlaitDrawElement.isHorizontalSwimlane(element)) {
@@ -2651,8 +2684,10 @@ const getDefaultSwimlanePoints = (pointer, centerPoint) => {
2651
2684
  const createDefaultSwimlane = (shape, points) => {
2652
2685
  const header = isSwimlaneWithHeader(shape);
2653
2686
  const dataShape = adjustSwimlaneShape(shape);
2654
- const rows = createDefaultRowsOrColumns(dataShape, 'row', header);
2655
- const columns = createDefaultRowsOrColumns(dataShape, 'column', header);
2687
+ const width = points[1][0] - points[0][0];
2688
+ const height = points[1][1] - points[0][1];
2689
+ const rows = createDefaultRowsOrColumns(dataShape, 'row', header, height);
2690
+ const columns = createDefaultRowsOrColumns(dataShape, 'column', header, width);
2656
2691
  const swimlane = {
2657
2692
  id: idCreator(),
2658
2693
  type: 'swimlane',
@@ -2665,18 +2700,22 @@ const createDefaultSwimlane = (shape, points) => {
2665
2700
  };
2666
2701
  return swimlane;
2667
2702
  };
2668
- const createDefaultRowsOrColumns = (shape, type, header) => {
2703
+ const createDefaultRowsOrColumns = (shape, type, header, size) => {
2669
2704
  const createItems = (count) => new Array(count).fill('').map(() => ({ id: idCreator() }));
2670
2705
  let data = createItems(3);
2671
2706
  if ((type === 'row' && shape === SwimlaneSymbols.swimlaneVertical) ||
2672
2707
  (type === 'column' && shape === SwimlaneSymbols.swimlaneHorizontal)) {
2673
2708
  data = header ? data : createItems(2);
2674
2709
  const dimension = type === 'row' ? 'height' : 'width';
2710
+ let defaultSize = SWIMLANE_HEADER_SIZE;
2711
+ if (size < SWIMLANE_HEADER_SIZE * data.length) {
2712
+ defaultSize = Math.min((size / data.length / SWIMLANE_HEADER_SIZE) * SWIMLANE_HEADER_SIZE, SWIMLANE_HEADER_SIZE);
2713
+ }
2675
2714
  data = data.map((item, index) => {
2676
2715
  if (index === 0 || (index === 1 && header)) {
2677
2716
  return {
2678
2717
  ...item,
2679
- [dimension]: SWIMLANE_HEADER_SIZE
2718
+ [dimension]: defaultSize
2680
2719
  };
2681
2720
  }
2682
2721
  return item;
@@ -2695,7 +2734,7 @@ const createDefaultCells = (shape, rows, columns, header) => {
2695
2734
  if (index < 3) {
2696
2735
  const rowId = shape === SwimlaneSymbols.swimlaneVertical ? rows[startIndex].id : rows[index].id;
2697
2736
  const columnId = shape === SwimlaneSymbols.swimlaneVertical ? columns[index].id : columns[startIndex].id;
2698
- return createCell(rowId, columnId, 'Lane');
2737
+ return createCell(rowId, columnId, header ? 'Lane' : 'New Swimlane');
2699
2738
  }
2700
2739
  const rowId = shape === SwimlaneSymbols.swimlaneVertical ? rows[startIndex + 1].id : rows[index - 3].id;
2701
2740
  const columnId = shape === SwimlaneSymbols.swimlaneVertical ? columns[index - 3].id : columns[startIndex + 1].id;
@@ -2720,6 +2759,9 @@ const adjustSwimlaneShape = (shape) => {
2720
2759
  ? SwimlaneSymbols.swimlaneHorizontal
2721
2760
  : SwimlaneSymbols.swimlaneVertical;
2722
2761
  };
2762
+ const isSwimlanePointers = (board) => {
2763
+ return PlaitBoard.isInPointer(board, getSwimlanePointers());
2764
+ };
2723
2765
 
2724
2766
  const updateSwimlaneCount = (board, swimlane, count) => {
2725
2767
  if (count > 0 && PlaitDrawElement.isSwimlane(swimlane)) {
@@ -2879,33 +2921,6 @@ const updateSwimlane = (board, swimlane, newColumns, newRows, newCells, newPoint
2879
2921
  points: newPoints
2880
2922
  }, path);
2881
2923
  };
2882
- const setSwimlaneFill = (board, element, fill, path) => {
2883
- const selectedCells = getSelectedCells(element);
2884
- let newCells = element.cells;
2885
- if (selectedCells?.length) {
2886
- newCells = element.cells.map(cell => {
2887
- if (selectedCells.map(item => item.id).includes(cell.id)) {
2888
- return {
2889
- ...cell,
2890
- fill
2891
- };
2892
- }
2893
- return cell;
2894
- });
2895
- }
2896
- else {
2897
- newCells = element.cells.map(cell => {
2898
- if (cell.text && cell.textHeight) {
2899
- return {
2900
- ...cell,
2901
- fill
2902
- };
2903
- }
2904
- return cell;
2905
- });
2906
- }
2907
- Transforms.setNode(board, { cells: newCells }, path);
2908
- };
2909
2924
 
2910
2925
  const setDrawShapeText = (board, element, text) => {
2911
2926
  const newTexts = element.texts?.map(item => {
@@ -2921,7 +2936,8 @@ const setDrawShapeText = (board, element, text) => {
2921
2936
  Transforms.setNode(board, newElement, [path]);
2922
2937
  };
2923
2938
 
2924
- const setTableText = (board, table, cellId, text, textWidth, textHeight) => {
2939
+ const setTableText = (board, path, cellId, text, textHeight) => {
2940
+ const table = PlaitNode.get(board, path);
2925
2941
  const cell = getCellWithPoints(board, table, cellId);
2926
2942
  const cellIndex = table.cells.findIndex(item => item.id === cell.id);
2927
2943
  let rows = [...table.rows];
@@ -2957,8 +2973,66 @@ const setTableText = (board, table, cellId, text, textWidth, textHeight) => {
2957
2973
  textHeight: textHeight,
2958
2974
  text
2959
2975
  };
2960
- const path = board.children.findIndex(child => child.id === table.id);
2961
- Transforms.setNode(board, { rows, columns, cells, points }, [path]);
2976
+ Transforms.setNode(board, { rows, columns, cells, points }, path);
2977
+ };
2978
+
2979
+ const setTableFill = (board, element, fill, path) => {
2980
+ const selectedCells = getSelectedCells(element);
2981
+ let newCells = element.cells;
2982
+ if (selectedCells?.length) {
2983
+ newCells = element.cells.map(cell => {
2984
+ if (selectedCells.map(item => item.id).includes(cell.id)) {
2985
+ return {
2986
+ ...cell,
2987
+ fill
2988
+ };
2989
+ }
2990
+ return cell;
2991
+ });
2992
+ }
2993
+ else {
2994
+ newCells = element.cells.map(cell => {
2995
+ if (cell.text && cell.textHeight) {
2996
+ return {
2997
+ ...cell,
2998
+ fill
2999
+ };
3000
+ }
3001
+ return cell;
3002
+ });
3003
+ }
3004
+ Transforms.setNode(board, { cells: newCells }, path);
3005
+ };
3006
+
3007
+ const insertDrawByVector = (board, point, shape, vector) => {
3008
+ const swimlanePointers = getSwimlanePointers();
3009
+ const isSwimlanePointer = swimlanePointers.includes(shape);
3010
+ let shapeProperty = DefaultFlowchartPropertyMap[shape] ||
3011
+ DefaultBasicShapePropertyMap[shape] ||
3012
+ DefaultUMLPropertyMap[shape] ||
3013
+ DefaultBasicShapeProperty;
3014
+ if (isSwimlanePointer) {
3015
+ shapeProperty = DefaultSwimlanePropertyMap[shape];
3016
+ }
3017
+ const direction = getDirectionByVector(vector);
3018
+ if (direction) {
3019
+ let offset = 0;
3020
+ if ([Direction.left, Direction.right].includes(direction)) {
3021
+ offset = -shapeProperty.width / 2;
3022
+ }
3023
+ else {
3024
+ offset = -shapeProperty.height / 2;
3025
+ }
3026
+ const vectorPoint = getPointByVectorComponent(point, vector, offset);
3027
+ const points = RectangleClient.getPoints(RectangleClient.getRectangleByCenterPoint(vectorPoint, shapeProperty.width, shapeProperty.height));
3028
+ if (isSwimlanePointer) {
3029
+ const swimlane = createDefaultSwimlane(shape, points);
3030
+ insertElement(board, swimlane);
3031
+ return swimlane;
3032
+ }
3033
+ return insertGeometry(board, points, shape);
3034
+ }
3035
+ return null;
2962
3036
  };
2963
3037
 
2964
3038
  const DrawTransforms = {
@@ -2968,22 +3042,22 @@ const DrawTransforms = {
2968
3042
  resizeGeometry,
2969
3043
  insertText,
2970
3044
  setTextSize,
2971
- resizeLine,
2972
- setLineTexts,
2973
- removeLineText,
2974
- setLineMark,
2975
- setLineShape,
3045
+ resizeArrowLine,
3046
+ setArrowLineTexts,
3047
+ removeArrowLineText,
3048
+ setArrowLineMark,
3049
+ setArrowLineShape,
2976
3050
  insertImage,
3051
+ connectArrowLineToDraw,
2977
3052
  switchGeometryShape,
2978
- connectLineToGeometry,
2979
- insertGeometryByVector,
2980
3053
  setTableText,
2981
3054
  addSwimlaneRow,
2982
3055
  addSwimlaneColumn,
2983
3056
  removeSwimlaneRow,
2984
3057
  removeSwimlaneColumn,
2985
- setSwimlaneFill,
2986
- updateSwimlaneCount
3058
+ updateSwimlaneCount,
3059
+ setTableFill,
3060
+ insertDrawByVector
2987
3061
  };
2988
3062
 
2989
3063
  const getHitRectangleResizeHandleRef = (board, rectangle, point, angle = 0) => {
@@ -3118,10 +3192,16 @@ function withDrawResize(board) {
3118
3192
  }
3119
3193
  }
3120
3194
  if (PlaitDrawElement.isGeometry(target)) {
3121
- const { height: textHeight } = getFirstTextManage(target).getSize();
3122
- DrawTransforms.resizeGeometry(board, points, textHeight, path);
3195
+ if (isGeometryIncludeText(target)) {
3196
+ const { height: textHeight } = getFirstTextManage(target).getSize();
3197
+ DrawTransforms.resizeGeometry(board, points, textHeight, path);
3198
+ }
3199
+ else {
3200
+ points = normalizeShapePoints(points);
3201
+ Transforms.setNode(board, { points }, path);
3202
+ }
3123
3203
  }
3124
- else if (PlaitDrawElement.isLine(target)) {
3204
+ else if (PlaitDrawElement.isArrowLine(target)) {
3125
3205
  Transforms.setNode(board, { points }, path);
3126
3206
  }
3127
3207
  else if (PlaitDrawElement.isImage(target)) {
@@ -3440,29 +3520,6 @@ function drawIsometricSnapLines(board, activePoints, snapRectangles, resizeSnapO
3440
3520
  return drawSolidLines(board, isometricLines);
3441
3521
  }
3442
3522
 
3443
- const isSingleSelectTable = (board) => {
3444
- const selectedElements = getSelectedElements(board);
3445
- return selectedElements && selectedElements.length === 1 && PlaitTableElement.isTable(selectedElements[0]);
3446
- };
3447
- const isSingleSelectElementByTable = (board) => {
3448
- const selectedElements = getSelectedElements(board);
3449
- return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
3450
- };
3451
- const getSelectedTableElements = (board, elements) => {
3452
- const selectedElements = elements?.length ? elements : getSelectedElements(board);
3453
- return selectedElements.filter(value => PlaitTableElement.isTable(value));
3454
- };
3455
- const SELECTED_CELLS = new WeakMap();
3456
- function getSelectedCells(element) {
3457
- return SELECTED_CELLS.get(element);
3458
- }
3459
- function setSelectedCells(element, cells) {
3460
- return SELECTED_CELLS.set(element, cells);
3461
- }
3462
- function clearSelectedCells(element) {
3463
- return SELECTED_CELLS.delete(element);
3464
- }
3465
-
3466
3523
  const getCenterPointsOnPolygon = (points) => {
3467
3524
  const centerPoints = [];
3468
3525
  for (let i = 0; i < points.length; i++) {
@@ -3646,7 +3703,9 @@ function createEllipseEngine(createOptions) {
3646
3703
  draw(board, rectangle, options) {
3647
3704
  const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
3648
3705
  const rs = PlaitBoard.getRoughSVG(board);
3649
- return rs.ellipse(centerPoint[0], centerPoint[1], rectangle.width, rectangle.height, { ...options, fillStyle: 'solid' });
3706
+ const shape = rs.ellipse(centerPoint[0], centerPoint[1], rectangle.width, rectangle.height, { ...options, fillStyle: 'solid' });
3707
+ setStrokeLinecap(shape, 'round');
3708
+ return shape;
3650
3709
  },
3651
3710
  isInsidePoint(rectangle, point) {
3652
3711
  const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
@@ -3989,7 +4048,9 @@ const RoundCommentEngine = {
3989
4048
  const point9 = [x1 + rectangle.width / 4, y2];
3990
4049
  const point10 = [x1 + rectangle.width / 4, rectangle.y + rectangle.height];
3991
4050
  const point11 = [x1 + rectangle.width / 2, y2];
3992
- return rs.path(`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point11[0]} ${point11[1]} ${point10[0]} ${point10[1]} ${point9[0]} ${point9[1]} ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`, { ...options, fillStyle: 'solid' });
4051
+ const shape = rs.path(`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point11[0]} ${point11[1]} ${point10[0]} ${point10[1]} ${point9[0]} ${point9[1]} ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`, { ...options, fillStyle: 'solid' });
4052
+ setStrokeLinecap(shape, 'round');
4053
+ return shape;
3993
4054
  },
3994
4055
  isInsidePoint(rectangle, point) {
3995
4056
  const points = [
@@ -4573,13 +4634,15 @@ const OrEngine = createEllipseEngine({
4573
4634
  const rx = rectangle.width / 2;
4574
4635
  const ry = rectangle.height / 2;
4575
4636
  const startPoint = [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2];
4576
- return rs.path(`M${startPoint[0]} ${startPoint[1]}
4637
+ const shape = rs.path(`M${startPoint[0]} ${startPoint[1]}
4577
4638
  A${rx},${ry} 0 1,1 ${startPoint[0]} ${startPoint[1] - 0.01}
4578
4639
  M${rectangle.x} ${rectangle.y + rectangle.height / 2}
4579
4640
  L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height / 2}
4580
4641
  M${rectangle.x + rectangle.width / 2} ${rectangle.y}
4581
4642
  L${rectangle.x + rectangle.width / 2} ${rectangle.y + rectangle.height}
4582
4643
  `, { ...options, fillStyle: 'solid' });
4644
+ setStrokeLinecap(shape, 'round');
4645
+ return shape;
4583
4646
  }
4584
4647
  });
4585
4648
 
@@ -4592,13 +4655,15 @@ const SummingJunctionEngine = createEllipseEngine({
4592
4655
  const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
4593
4656
  const line1Points = getCrossingPointsBetweenEllipseAndSegment([rectangle.x, rectangle.y], [rectangle.x + rectangle.width, rectangle.y + rectangle.height], centerPoint[0], centerPoint[1], rx, ry);
4594
4657
  const line2Points = getCrossingPointsBetweenEllipseAndSegment([rectangle.x + rectangle.width, rectangle.y], [rectangle.x, rectangle.y + rectangle.height], centerPoint[0], centerPoint[1], rx, ry);
4595
- return rs.path(`M${startPoint[0]} ${startPoint[1]}
4658
+ const shape = rs.path(`M${startPoint[0]} ${startPoint[1]}
4596
4659
  A${rx},${ry} 0 1,1 ${startPoint[0]} ${startPoint[1] - 0.01}
4597
4660
  M${line1Points[0][0]} ${line1Points[0][1]}
4598
4661
  L${line1Points[1][0]} ${line1Points[1][1]}
4599
4662
  M${line2Points[0][0]} ${line2Points[0][1]}
4600
4663
  L${line2Points[1][0]} ${line2Points[1][1]}
4601
4664
  `, { ...options, fillStyle: 'solid' });
4665
+ setStrokeLinecap(shape, 'round');
4666
+ return shape;
4602
4667
  }
4603
4668
  });
4604
4669
 
@@ -5025,7 +5090,7 @@ const NoteCurlyLeftEngine = {
5025
5090
  ${rectangle.x + rectangle.width - rectangle.width * 0.09} ${rectangle.y + rectangle.height / 2}
5026
5091
  C${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height / 2},
5027
5092
  ${rectangle.x + rectangle.width - rectangle.width * 0.09} ${rectangle.y + rectangle.height},
5028
- ${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid' });
5093
+ ${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid', fill: 'transparent' });
5029
5094
  setStrokeLinecap(shape, 'round');
5030
5095
  return shape;
5031
5096
  },
@@ -5064,13 +5129,13 @@ const NoteCurlyLeftEngine = {
5064
5129
  const NoteCurlyRightEngine = {
5065
5130
  draw(board, rectangle, options) {
5066
5131
  const rs = PlaitBoard.getRoughSVG(board);
5067
- const shape = rs.path(`M${rectangle.x} ${rectangle.y}
5068
- C${rectangle.x + rectangle.width * 0.09} ${rectangle.y},
5069
- ${rectangle.x} ${rectangle.y + rectangle.height / 2},
5132
+ const shape = rs.path(`M${rectangle.x} ${rectangle.y}
5133
+ C${rectangle.x + rectangle.width * 0.09} ${rectangle.y},
5134
+ ${rectangle.x} ${rectangle.y + rectangle.height / 2},
5070
5135
  ${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height / 2}
5071
- C${rectangle.x} ${rectangle.y + rectangle.height / 2},
5072
- ${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height},
5073
- ${rectangle.x} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid' });
5136
+ C${rectangle.x} ${rectangle.y + rectangle.height / 2},
5137
+ ${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height},
5138
+ ${rectangle.x} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid', fill: 'transparent' });
5074
5139
  setStrokeLinecap(shape, 'round');
5075
5140
  return shape;
5076
5141
  },
@@ -5111,7 +5176,7 @@ const NoteSquareEngine = {
5111
5176
  const rs = PlaitBoard.getRoughSVG(board);
5112
5177
  const shape = rs.path(`M${rectangle.x + rectangle.width * 0.075} ${rectangle.y + rectangle.height} H${rectangle.x} V${rectangle.y} H${rectangle.x +
5113
5178
  rectangle.width * 0.075}
5114
- `, { ...options, fillStyle: 'solid' });
5179
+ `, { ...options, fillStyle: 'solid', fill: 'transparent' });
5115
5180
  setStrokeLinecap(shape, 'round');
5116
5181
  return shape;
5117
5182
  },
@@ -5221,27 +5286,34 @@ const DisplayEngine = {
5221
5286
 
5222
5287
  const TableEngine = {
5223
5288
  draw(board, rectangle, roughOptions, options) {
5224
- const rs = PlaitBoard.getRoughSVG(board);
5225
5289
  const g = createG();
5226
- const { x, y, width, height } = rectangle;
5227
- const tableTopBorder = drawLine$1(rs, [x, y], [x + width, y], roughOptions);
5228
- const tableLeftBorder = drawLine$1(rs, [x, y], [x, y + height], roughOptions);
5229
- g.append(tableTopBorder, tableLeftBorder);
5230
- const pointCells = getCellsWithPoints(board, { ...options?.element });
5231
- pointCells.forEach(cell => {
5232
- const rectangle = RectangleClient.getRectangleByPoints(cell.points);
5233
- const { x, y, width, height } = rectangle;
5234
- const cellRectangle = drawRectangle(board, {
5235
- x: x + ACTIVE_STROKE_WIDTH,
5236
- y: y + ACTIVE_STROKE_WIDTH,
5237
- width: width - ACTIVE_STROKE_WIDTH * 2,
5238
- height: height - ACTIVE_STROKE_WIDTH * 2
5239
- }, { fill: cell.fill, fillStyle: 'solid', strokeWidth: 0 });
5240
- const cellRightBorder = drawLine$1(rs, [x + width, y], [x + width, y + height], roughOptions);
5241
- const cellBottomBorder = drawLine$1(rs, [x, y + height], [x + width, y + height], roughOptions);
5242
- g.append(cellRectangle, cellRightBorder, cellBottomBorder);
5243
- });
5244
- setStrokeLinecap(g, 'round');
5290
+ try {
5291
+ const pointCells = getCellsWithPoints(board, { ...options?.element });
5292
+ if (pointCells) {
5293
+ const rs = PlaitBoard.getRoughSVG(board);
5294
+ const { x, y, width, height } = rectangle;
5295
+ const tableTopBorder = drawLine(rs, [x, y], [x + width, y], roughOptions);
5296
+ const tableLeftBorder = drawLine(rs, [x, y], [x, y + height], roughOptions);
5297
+ g.append(tableTopBorder, tableLeftBorder);
5298
+ pointCells.forEach(cell => {
5299
+ const rectangle = RectangleClient.getRectangleByPoints(cell.points);
5300
+ const { x, y, width, height } = rectangle;
5301
+ const cellRectangle = drawRectangle(board, {
5302
+ x: x + ACTIVE_STROKE_WIDTH,
5303
+ y: y + ACTIVE_STROKE_WIDTH,
5304
+ width: width - ACTIVE_STROKE_WIDTH * 2,
5305
+ height: height - ACTIVE_STROKE_WIDTH * 2
5306
+ }, { fill: cell.fill, fillStyle: 'solid', strokeWidth: 0 });
5307
+ const cellRightBorder = drawLine(rs, [x + width, y], [x + width, y + height], roughOptions);
5308
+ const cellBottomBorder = drawLine(rs, [x, y + height], [x + width, y + height], roughOptions);
5309
+ g.append(cellRectangle, cellRightBorder, cellBottomBorder);
5310
+ });
5311
+ setStrokeLinecap(g, 'round');
5312
+ }
5313
+ }
5314
+ catch (error) {
5315
+ console.error(error);
5316
+ }
5245
5317
  return g;
5246
5318
  },
5247
5319
  isInsidePoint(rectangle, point) {
@@ -5258,13 +5330,28 @@ const TableEngine = {
5258
5330
  return RectangleClient.getEdgeCenterPoints(rectangle);
5259
5331
  },
5260
5332
  getTextRectangle(element, options) {
5261
- const cell = getCellWithPoints(options?.board, element, options.key);
5262
- if (PlaitTableElement.isVerticalText(cell)) {
5263
- return getVerticalTextRectangle(cell);
5333
+ try {
5334
+ if (options && options.key) {
5335
+ const cell = getCellWithPoints(options?.board, element, options.key);
5336
+ if (cell) {
5337
+ if (PlaitTableElement.isVerticalText(cell)) {
5338
+ return getVerticalTextRectangle(cell);
5339
+ }
5340
+ else {
5341
+ return getHorizontalTextRectangle(cell);
5342
+ }
5343
+ }
5344
+ }
5264
5345
  }
5265
- else {
5266
- return getHorizontalTextRectangle(cell);
5346
+ catch (error) {
5347
+ console.error(error);
5267
5348
  }
5349
+ return {
5350
+ x: 0,
5351
+ y: 0,
5352
+ width: 0,
5353
+ height: 0
5354
+ };
5268
5355
  }
5269
5356
  };
5270
5357
  function getVerticalTextRectangle(cell) {
@@ -5565,6 +5652,7 @@ const DeletionEngine = {
5565
5652
  const shape = rs.path(`M${rectangle.x} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}
5566
5653
  M${rectangle.x + rectangle.width} ${rectangle.y} L${rectangle.x} ${rectangle.y + rectangle.height}
5567
5654
  `, { ...options, fillStyle: 'solid', strokeWidth: 4 });
5655
+ setStrokeLinecap(shape, 'round');
5568
5656
  return shape;
5569
5657
  },
5570
5658
  isInsidePoint(rectangle, point) {
@@ -5744,7 +5832,8 @@ const RequiredInterfaceEngine = {
5744
5832
  M${rectangle.x + rectangle.width * 0.41} ${rectangle.y + rectangle.height / 2} H${rectangle.x + rectangle.width}
5745
5833
  `, {
5746
5834
  ...options,
5747
- fillStyle: 'solid'
5835
+ fillStyle: 'solid',
5836
+ fill: 'transparent'
5748
5837
  });
5749
5838
  setStrokeLinecap(shape, 'round');
5750
5839
  return shape;
@@ -6052,7 +6141,7 @@ const getEngine = (shape) => {
6052
6141
  return ShapeEngineMap[shape];
6053
6142
  };
6054
6143
 
6055
- const getLineHandleRefPair = (board, element) => {
6144
+ const getArrowLineHandleRefPair = (board, element) => {
6056
6145
  const strokeWidth = getStrokeWidthByElement(element);
6057
6146
  const sourceBoundElement = element.source.boundId ? getElementById(board, element.source.boundId) : undefined;
6058
6147
  const targetBoundElement = element.target.boundId ? getElementById(board, element.target.boundId) : undefined;
@@ -6065,19 +6154,21 @@ const getLineHandleRefPair = (board, element) => {
6065
6154
  const sourceFactor = getDirectionFactor(sourceDirection);
6066
6155
  const targetFactor = getDirectionFactor(targetDirection);
6067
6156
  const sourceHandleRef = {
6068
- key: LineHandleKey.source,
6157
+ key: ArrowLineHandleKey.source,
6069
6158
  point: sourcePoint,
6070
6159
  direction: sourceDirection,
6071
6160
  vector: [sourceFactor.x, sourceFactor.y]
6072
6161
  };
6073
6162
  const targetHandleRef = {
6074
- key: LineHandleKey.target,
6163
+ key: ArrowLineHandleKey.target,
6075
6164
  point: targetPoint,
6076
6165
  direction: targetDirection,
6077
6166
  vector: [targetFactor.x, targetFactor.y]
6078
6167
  };
6079
6168
  if (sourceBoundElement) {
6080
- const connectionOffset = PlaitLine.isSourceMarkOrTargetMark(element, LineMarkerType.none, LineHandleKey.source) ? 0 : strokeWidth;
6169
+ const connectionOffset = PlaitArrowLine.isSourceMarkOrTargetMark(element, ArrowLineMarkerType.none, ArrowLineHandleKey.source)
6170
+ ? 0
6171
+ : strokeWidth;
6081
6172
  const sourceVector = getVectorByConnection(sourceBoundElement, element.source.connection);
6082
6173
  sourceHandleRef.vector = sourceVector;
6083
6174
  sourceHandleRef.boundElement = sourceBoundElement;
@@ -6094,7 +6185,9 @@ const getLineHandleRefPair = (board, element) => {
6094
6185
  sourceHandleRef.point = rotatePointsByElement(sourcePoint, sourceBoundElement) || sourcePoint;
6095
6186
  }
6096
6187
  if (targetBoundElement) {
6097
- const connectionOffset = PlaitLine.isSourceMarkOrTargetMark(element, LineMarkerType.none, LineHandleKey.target) ? 0 : strokeWidth;
6188
+ const connectionOffset = PlaitArrowLine.isSourceMarkOrTargetMark(element, ArrowLineMarkerType.none, ArrowLineHandleKey.target)
6189
+ ? 0
6190
+ : strokeWidth;
6098
6191
  const targetVector = getVectorByConnection(targetBoundElement, element.target.connection);
6099
6192
  targetHandleRef.vector = targetVector;
6100
6193
  targetHandleRef.boundElement = targetBoundElement;
@@ -6149,7 +6242,7 @@ const getVectorByConnection = (boundElement, connection) => {
6149
6242
  return vector;
6150
6243
  };
6151
6244
  const getElbowLineRouteOptions = (board, element, handleRefPair) => {
6152
- handleRefPair = handleRefPair ?? getLineHandleRefPair(board, element);
6245
+ handleRefPair = handleRefPair ?? getArrowLineHandleRefPair(board, element);
6153
6246
  const { sourceRectangle, targetRectangle } = getSourceAndTargetRectangle(board, element, handleRefPair);
6154
6247
  const { sourceOuterRectangle, targetOuterRectangle } = getSourceAndTargetOuterRectangle(sourceRectangle, targetRectangle);
6155
6248
  const sourcePoint = handleRefPair.source.point;
@@ -6167,33 +6260,67 @@ const getElbowLineRouteOptions = (board, element, handleRefPair) => {
6167
6260
  targetOuterRectangle
6168
6261
  };
6169
6262
  };
6263
+ const collectArrowLineUpdatedRefsByGeometry = (board, element, refs) => {
6264
+ const lines = findElements(board, {
6265
+ match: (element) => {
6266
+ if (PlaitDrawElement.isArrowLine(element)) {
6267
+ return element.source.boundId === element.id || element.target.boundId === element.id;
6268
+ }
6269
+ return false;
6270
+ },
6271
+ recursion: element => true
6272
+ });
6273
+ if (lines.length) {
6274
+ lines.forEach(line => {
6275
+ const isSourceBound = line.source.boundId === element.id;
6276
+ const handle = isSourceBound ? 'source' : 'target';
6277
+ const object = { ...line[handle] };
6278
+ const linePoints = getArrowLinePoints(board, line);
6279
+ const point = isSourceBound ? linePoints[0] : linePoints[linePoints.length - 1];
6280
+ object.connection = getHitConnection(board, point, element);
6281
+ const path = PlaitBoard.findPath(board, line);
6282
+ const index = refs.findIndex(obj => Path.equals(obj.path, path));
6283
+ if (index === -1) {
6284
+ refs.push({
6285
+ property: {
6286
+ [handle]: object
6287
+ },
6288
+ path
6289
+ });
6290
+ }
6291
+ else {
6292
+ refs[index].property = { ...refs[index].property, [handle]: object };
6293
+ }
6294
+ });
6295
+ }
6296
+ };
6170
6297
 
6171
- var LineMarkerType;
6172
- (function (LineMarkerType) {
6173
- LineMarkerType["arrow"] = "arrow";
6174
- LineMarkerType["none"] = "none";
6175
- LineMarkerType["openTriangle"] = "open-triangle";
6176
- LineMarkerType["solidTriangle"] = "solid-triangle";
6177
- LineMarkerType["sharpArrow"] = "sharp-arrow";
6178
- LineMarkerType["oneSideUp"] = "one-side-up";
6179
- LineMarkerType["oneSideDown"] = "one-side-down";
6180
- LineMarkerType["hollowTriangle"] = "hollow-triangle";
6181
- LineMarkerType["singleSlash"] = "single-slash";
6182
- })(LineMarkerType || (LineMarkerType = {}));
6183
- var LineShape;
6184
- (function (LineShape) {
6185
- LineShape["straight"] = "straight";
6186
- LineShape["curve"] = "curve";
6187
- LineShape["elbow"] = "elbow";
6188
- })(LineShape || (LineShape = {}));
6189
- var LineHandleKey;
6190
- (function (LineHandleKey) {
6191
- LineHandleKey["source"] = "source";
6192
- LineHandleKey["target"] = "target";
6193
- })(LineHandleKey || (LineHandleKey = {}));
6194
- const PlaitLine = {
6298
+ var ArrowLineMarkerType;
6299
+ (function (ArrowLineMarkerType) {
6300
+ ArrowLineMarkerType["arrow"] = "arrow";
6301
+ ArrowLineMarkerType["none"] = "none";
6302
+ ArrowLineMarkerType["openTriangle"] = "open-triangle";
6303
+ ArrowLineMarkerType["solidTriangle"] = "solid-triangle";
6304
+ ArrowLineMarkerType["sharpArrow"] = "sharp-arrow";
6305
+ ArrowLineMarkerType["oneSideUp"] = "one-side-up";
6306
+ ArrowLineMarkerType["oneSideDown"] = "one-side-down";
6307
+ ArrowLineMarkerType["hollowTriangle"] = "hollow-triangle";
6308
+ ArrowLineMarkerType["singleSlash"] = "single-slash";
6309
+ })(ArrowLineMarkerType || (ArrowLineMarkerType = {}));
6310
+ var ArrowLineShape;
6311
+ (function (ArrowLineShape) {
6312
+ ArrowLineShape["straight"] = "straight";
6313
+ ArrowLineShape["curve"] = "curve";
6314
+ ArrowLineShape["elbow"] = "elbow";
6315
+ })(ArrowLineShape || (ArrowLineShape = {}));
6316
+ var ArrowLineHandleKey;
6317
+ (function (ArrowLineHandleKey) {
6318
+ ArrowLineHandleKey["source"] = "source";
6319
+ ArrowLineHandleKey["target"] = "target";
6320
+ })(ArrowLineHandleKey || (ArrowLineHandleKey = {}));
6321
+ const PlaitArrowLine = {
6195
6322
  isSourceMarkOrTargetMark(line, markType, handleKey) {
6196
- if (handleKey === LineHandleKey.source) {
6323
+ if (handleKey === ArrowLineHandleKey.source) {
6197
6324
  return line.source.marker === markType;
6198
6325
  }
6199
6326
  else {
@@ -6201,10 +6328,10 @@ const PlaitLine = {
6201
6328
  }
6202
6329
  },
6203
6330
  isSourceMark(line, markType) {
6204
- return PlaitLine.isSourceMarkOrTargetMark(line, markType, LineHandleKey.source);
6331
+ return PlaitArrowLine.isSourceMarkOrTargetMark(line, markType, ArrowLineHandleKey.source);
6205
6332
  },
6206
6333
  isTargetMark(line, markType) {
6207
- return PlaitLine.isSourceMarkOrTargetMark(line, markType, LineHandleKey.target);
6334
+ return PlaitArrowLine.isSourceMarkOrTargetMark(line, markType, ArrowLineHandleKey.target);
6208
6335
  },
6209
6336
  isBoundElementOfSource(line, element) {
6210
6337
  return line.source.boundId === element.id;
@@ -6247,16 +6374,25 @@ var MemorizeKey;
6247
6374
  MemorizeKey["basicShape"] = "basicShape";
6248
6375
  MemorizeKey["flowchart"] = "flowchart";
6249
6376
  MemorizeKey["text"] = "text";
6250
- MemorizeKey["line"] = "line";
6377
+ MemorizeKey["arrowLine"] = "arrow-line";
6251
6378
  MemorizeKey["UML"] = "UML";
6252
6379
  })(MemorizeKey || (MemorizeKey = {}));
6253
6380
 
6381
+ var VectorLineShape;
6382
+ (function (VectorLineShape) {
6383
+ VectorLineShape["straight"] = "straight";
6384
+ VectorLineShape["curve"] = "curve";
6385
+ })(VectorLineShape || (VectorLineShape = {}));
6386
+
6254
6387
  const PlaitDrawElement = {
6255
6388
  isGeometry: (value) => {
6256
6389
  return value.type === 'geometry';
6257
6390
  },
6258
- isLine: (value) => {
6259
- return value.type === 'line';
6391
+ // isLine: (value: any): value is PlaitArrowLine => {
6392
+ // return value.type === 'arrow-line' || value.type === 'line' || value.type === 'vector-line';
6393
+ // },
6394
+ isArrowLine: (value) => {
6395
+ return value.type === 'arrow-line' || value.type === 'line';
6260
6396
  },
6261
6397
  isText: (value) => {
6262
6398
  return value.type === 'geometry' && value.shape === BasicShapes.text;
@@ -6269,7 +6405,7 @@ const PlaitDrawElement = {
6269
6405
  },
6270
6406
  isDrawElement: (value) => {
6271
6407
  if (PlaitDrawElement.isGeometry(value) ||
6272
- PlaitDrawElement.isLine(value) ||
6408
+ PlaitDrawElement.isArrowLine(value) ||
6273
6409
  PlaitDrawElement.isImage(value) ||
6274
6410
  PlaitDrawElement.isTable(value) ||
6275
6411
  PlaitDrawElement.isSwimlane(value)) {
@@ -6280,7 +6416,10 @@ const PlaitDrawElement = {
6280
6416
  }
6281
6417
  },
6282
6418
  isShapeElement: (value) => {
6283
- return PlaitDrawElement.isImage(value) || PlaitDrawElement.isGeometry(value) || PlaitDrawElement.isTable(value) || PlaitDrawElement.isSwimlane(value);
6419
+ return (PlaitDrawElement.isImage(value) ||
6420
+ PlaitDrawElement.isGeometry(value) ||
6421
+ PlaitDrawElement.isTable(value) ||
6422
+ PlaitDrawElement.isSwimlane(value));
6284
6423
  },
6285
6424
  isBasicShape: (value) => {
6286
6425
  return Object.keys(BasicShapes).includes(value.shape);
@@ -6308,7 +6447,7 @@ const PlaitDrawElement = {
6308
6447
  },
6309
6448
  isElementByTable: (value) => {
6310
6449
  return PlaitDrawElement.isTable(value) || PlaitDrawElement.isSwimlane(value) || PlaitDrawElement.isGeometryByTable(value);
6311
- },
6450
+ }
6312
6451
  };
6313
6452
 
6314
6453
  class GeometryShapeGenerator extends Generator {
@@ -6334,7 +6473,7 @@ class GeometryShapeGenerator extends Generator {
6334
6473
  }
6335
6474
  }
6336
6475
 
6337
- class LineAutoCompleteGenerator extends Generator {
6476
+ class ArrowLineAutoCompleteGenerator extends Generator {
6338
6477
  static { this.key = 'line-auto-complete-generator'; }
6339
6478
  constructor(board) {
6340
6479
  super(board);
@@ -6421,12 +6560,12 @@ class GeometryComponent extends CommonElementFlavour {
6421
6560
  return canResize(this.board, this.element);
6422
6561
  }
6423
6562
  });
6424
- this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
6563
+ this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
6425
6564
  this.shapeGenerator = new GeometryShapeGenerator(this.board);
6426
6565
  if (isGeometryIncludeText(this.element)) {
6427
6566
  this.initializeTextManage();
6428
6567
  }
6429
- this.getRef().addGenerator(LineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
6568
+ this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
6430
6569
  this.getRef().addGenerator(ActiveGenerator.key, this.activeGenerator);
6431
6570
  }
6432
6571
  initialize() {
@@ -6517,7 +6656,7 @@ class GeometryComponent extends CommonElementFlavour {
6517
6656
  }
6518
6657
  }
6519
6658
 
6520
- class LineActiveGenerator extends Generator {
6659
+ class ArrowLineActiveGenerator extends Generator {
6521
6660
  constructor() {
6522
6661
  super(...arguments);
6523
6662
  this.onlySelectedCurrentLine = false;
@@ -6537,10 +6676,10 @@ class LineActiveGenerator extends Generator {
6537
6676
  if (this.onlySelectedCurrentLine) {
6538
6677
  activeG.classList.add('active');
6539
6678
  activeG.classList.add('line-handle');
6540
- const points = PlaitLine.getPoints(this.board, element);
6679
+ const points = PlaitArrowLine.getPoints(this.board, element);
6541
6680
  let updatePoints = [...points];
6542
6681
  let elbowNextRenderPoints = [];
6543
- if (element.shape === LineShape.elbow) {
6682
+ if (element.shape === ArrowLineShape.elbow) {
6544
6683
  updatePoints = points.slice(0, 1).concat(points.slice(-1));
6545
6684
  elbowNextRenderPoints = getNextRenderPoints(this.board, element, data.linePoints);
6546
6685
  }
@@ -6552,7 +6691,7 @@ class LineActiveGenerator extends Generator {
6552
6691
  if (!PlaitBoard.hasBeenTextEditing(this.board)) {
6553
6692
  for (let i = 0; i < middlePoints.length; i++) {
6554
6693
  const point = middlePoints[i];
6555
- if (element.shape === LineShape.elbow && elbowNextRenderPoints.length) {
6694
+ if (element.shape === ArrowLineShape.elbow && elbowNextRenderPoints.length) {
6556
6695
  const handleIndex = getHitPointIndex(middlePoints, point);
6557
6696
  const isUpdateHandleIndex = isUpdatedHandleIndex(this.board, element, [...points], elbowNextRenderPoints, handleIndex);
6558
6697
  if (isUpdateHandleIndex) {
@@ -6592,20 +6731,20 @@ class LineActiveGenerator extends Generator {
6592
6731
 
6593
6732
  const debugKey = 'debug:plait:line-turning';
6594
6733
  const debugGenerator = createDebugGenerator(debugKey);
6595
- class LineComponent extends CommonElementFlavour {
6734
+ class ArrowLineComponent extends CommonElementFlavour {
6596
6735
  constructor() {
6597
6736
  super();
6598
6737
  this.boundedElements = {};
6599
6738
  }
6600
6739
  initializeGenerator() {
6601
- this.shapeGenerator = new LineShapeGenerator(this.board);
6602
- this.activeGenerator = new LineActiveGenerator(this.board);
6740
+ this.shapeGenerator = new ArrowLineShapeGenerator(this.board);
6741
+ this.activeGenerator = new ArrowLineActiveGenerator(this.board);
6603
6742
  this.initializeTextManagesByElement();
6604
6743
  }
6605
6744
  initialize() {
6606
6745
  this.initializeGenerator();
6607
6746
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
6608
- const linePoints = getLinePoints(this.board, this.element);
6747
+ const linePoints = getArrowLinePoints(this.board, this.element);
6609
6748
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
6610
6749
  selected: this.selected,
6611
6750
  linePoints
@@ -6637,7 +6776,7 @@ class LineComponent extends CommonElementFlavour {
6637
6776
  const isBoundedElementsChanged = boundedElements.source !== this.boundedElements.source || boundedElements.target !== this.boundedElements.target;
6638
6777
  this.boundedElements = boundedElements;
6639
6778
  const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
6640
- const linePoints = getLinePoints(this.board, this.element);
6779
+ const linePoints = getArrowLinePoints(this.board, this.element);
6641
6780
  if (value.element !== previous.element || isChangeTheme) {
6642
6781
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
6643
6782
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
@@ -6687,10 +6826,12 @@ class LineComponent extends CommonElementFlavour {
6687
6826
  createTextManage(text, index) {
6688
6827
  return new TextManage(this.board, {
6689
6828
  getRectangle: () => {
6690
- return getLineTextRectangle(this.board, this.element, index);
6829
+ return getArrowLineTextRectangle(this.board, this.element, index);
6691
6830
  },
6692
6831
  onChange: (textManageChangeData) => {
6693
- const texts = [...this.element.texts];
6832
+ const path = PlaitBoard.findPath(this.board, this.element);
6833
+ const node = PlaitNode.get(this.board, path);
6834
+ const texts = [...node.texts];
6694
6835
  const newWidth = textManageChangeData.width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : textManageChangeData.width;
6695
6836
  texts.splice(index, 1, {
6696
6837
  text: textManageChangeData.newText ? textManageChangeData.newText : this.element.texts[index].text,
@@ -6698,7 +6839,7 @@ class LineComponent extends CommonElementFlavour {
6698
6839
  width: newWidth,
6699
6840
  height: textManageChangeData.height
6700
6841
  });
6701
- DrawTransforms.setLineTexts(this.board, this.element, texts);
6842
+ DrawTransforms.setArrowLineTexts(this.board, this.element, texts);
6702
6843
  textManageChangeData.operations && memorizeLatestText(this.element, textManageChangeData.operations);
6703
6844
  },
6704
6845
  getMaxWidth: () => GeometryThreshold.defaultTextMaxWidth,
@@ -6783,9 +6924,13 @@ class TableGenerator extends Generator {
6783
6924
  }
6784
6925
  draw(element, data) {
6785
6926
  const rectangle = RectangleClient.getRectangleByPoints(element.points);
6927
+ const strokeLineDash = getLineDashByElement(element);
6928
+ const strokeWidth = getStrokeWidthByElement(element);
6929
+ const strokeColor = getStrokeColorByElement(this.board, element);
6786
6930
  return getEngine(TableSymbols.table).draw(this.board, rectangle, {
6787
- strokeWidth: 2,
6788
- stroke: getDrawDefaultStrokeColor(this.board.theme.themeColorMode),
6931
+ strokeWidth,
6932
+ stroke: strokeColor,
6933
+ strokeLineDash,
6789
6934
  }, {
6790
6935
  element: element
6791
6936
  });
@@ -6974,7 +7119,7 @@ const buildClipboardData = (board, elements, startPoint) => {
6974
7119
  const points = element.points.map(point => [point[0] - startPoint[0], point[1] - startPoint[1]]);
6975
7120
  return { ...element, points };
6976
7121
  }
6977
- if (PlaitDrawElement.isLine(element)) {
7122
+ if (PlaitDrawElement.isArrowLine(element)) {
6978
7123
  let source = { ...element.source };
6979
7124
  let target = { ...element.target };
6980
7125
  let points = [...element.points];
@@ -6999,12 +7144,12 @@ const buildClipboardData = (board, elements, startPoint) => {
6999
7144
  });
7000
7145
  };
7001
7146
  const insertClipboardData = (board, elements, startPoint) => {
7002
- const lines = elements.filter(value => PlaitDrawElement.isLine(value));
7147
+ const lines = elements.filter(value => PlaitDrawElement.isArrowLine(value));
7003
7148
  const geometries = elements.filter(value => (PlaitDrawElement.isGeometry(value) && !PlaitDrawElement.isGeometryByTable(value)) || PlaitDrawElement.isImage(value));
7004
7149
  const tables = elements.filter(value => PlaitDrawElement.isElementByTable(value));
7005
7150
  geometries.forEach(element => {
7006
7151
  const newId = idCreator();
7007
- updateBoundLinesId(element, lines, newId);
7152
+ updateBoundArrowLinesId(element, lines, newId);
7008
7153
  element.id = newId;
7009
7154
  element.points = element.points.map(point => [startPoint[0] + point[0], startPoint[1] + point[1]]);
7010
7155
  Transforms.insertNode(board, element, [board.children.length]);
@@ -7020,7 +7165,7 @@ const insertClipboardData = (board, elements, startPoint) => {
7020
7165
  const insertClipboardTableData = (board, elements, startPoint, lines) => {
7021
7166
  elements.forEach(element => {
7022
7167
  const newId = idCreator();
7023
- updateBoundLinesId(element, lines, newId);
7168
+ updateBoundArrowLinesId(element, lines, newId);
7024
7169
  element.id = newId;
7025
7170
  updateRowOrColumnIds(element, 'row');
7026
7171
  updateRowOrColumnIds(element, 'column');
@@ -7029,14 +7174,14 @@ const insertClipboardTableData = (board, elements, startPoint, lines) => {
7029
7174
  Transforms.insertNode(board, element, [board.children.length]);
7030
7175
  });
7031
7176
  };
7032
- const updateBoundLinesId = (element, lines, newId) => {
7177
+ const updateBoundArrowLinesId = (element, lines, newId) => {
7033
7178
  const sourceLines = [];
7034
7179
  const targetLines = [];
7035
7180
  lines.forEach(line => {
7036
- if (PlaitLine.isBoundElementOfSource(line, element)) {
7181
+ if (PlaitArrowLine.isBoundElementOfSource(line, element)) {
7037
7182
  sourceLines.push(line);
7038
7183
  }
7039
- if (PlaitLine.isBoundElementOfTarget(line, element)) {
7184
+ if (PlaitArrowLine.isBoundElementOfTarget(line, element)) {
7040
7185
  targetLines.push(line);
7041
7186
  }
7042
7187
  });
@@ -7052,15 +7197,15 @@ const withDrawFragment = (baseBoard) => {
7052
7197
  const drawElements = getSelectedDrawElements(board);
7053
7198
  if (drawElements.length) {
7054
7199
  const geometryElements = drawElements.filter(value => PlaitDrawElement.isGeometry(value));
7055
- const lineElements = drawElements.filter(value => PlaitDrawElement.isLine(value));
7200
+ const lineElements = drawElements.filter(value => PlaitDrawElement.isArrowLine(value));
7056
7201
  const imageElements = drawElements.filter(value => PlaitDrawElement.isImage(value));
7057
7202
  const tableElements = drawElements.filter(value => PlaitDrawElement.isTable(value));
7058
7203
  const swimlaneElements = drawElements.filter(value => PlaitDrawElement.isSwimlane(value));
7059
7204
  const boundLineElements = [
7060
- ...getBoundedLineElements(board, geometryElements),
7061
- ...getBoundedLineElements(board, imageElements),
7062
- ...getBoundedLineElements(board, tableElements),
7063
- ...getBoundedLineElements(board, swimlaneElements)
7205
+ ...getBoundedArrowLineElements(board, geometryElements),
7206
+ ...getBoundedArrowLineElements(board, imageElements),
7207
+ ...getBoundedArrowLineElements(board, tableElements),
7208
+ ...getBoundedArrowLineElements(board, swimlaneElements)
7064
7209
  ].filter(line => !lineElements.includes(line));
7065
7210
  data.push(...[
7066
7211
  ...geometryElements,
@@ -7079,8 +7224,8 @@ const withDrawFragment = (baseBoard) => {
7079
7224
  if (targetDrawElements.length) {
7080
7225
  if (operationType === WritableClipboardOperationType.cut) {
7081
7226
  const geometryElements = targetDrawElements.filter(value => PlaitDrawElement.isGeometry(value));
7082
- const lineElements = targetDrawElements.filter(value => PlaitDrawElement.isLine(value));
7083
- boundLineElements = getBoundedLineElements(board, geometryElements).filter(line => !lineElements.includes(line));
7227
+ const lineElements = targetDrawElements.filter(value => PlaitDrawElement.isArrowLine(value));
7228
+ boundLineElements = getBoundedArrowLineElements(board, geometryElements).filter(line => !lineElements.includes(line));
7084
7229
  }
7085
7230
  const selectedElements = [...targetDrawElements, ...boundLineElements];
7086
7231
  const elements = buildClipboardData(board, selectedElements, rectangle ? [rectangle.x, rectangle.y] : [0, 0]);
@@ -7132,19 +7277,19 @@ const withDrawFragment = (baseBoard) => {
7132
7277
  };
7133
7278
  return board;
7134
7279
  };
7135
- const getBoundedLineElements = (board, plaitShapes) => {
7136
- const lines = getLines(board);
7137
- return lines.filter(line => plaitShapes.find(shape => PlaitLine.isBoundElementOfSource(line, shape) || PlaitLine.isBoundElementOfTarget(line, shape)));
7280
+ const getBoundedArrowLineElements = (board, plaitShapes) => {
7281
+ const lines = getArrowLines(board);
7282
+ return lines.filter(line => plaitShapes.find(shape => PlaitArrowLine.isBoundElementOfSource(line, shape) || PlaitArrowLine.isBoundElementOfTarget(line, shape)));
7138
7283
  };
7139
7284
 
7140
- const withLineCreateByDraw = (board) => {
7285
+ const withArrowLineCreateByDraw = (board) => {
7141
7286
  const { pointerDown, pointerMove, globalPointerUp } = board;
7142
7287
  let start = null;
7143
7288
  let sourceElement;
7144
7289
  let lineShapeG = null;
7145
7290
  let temporaryElement = null;
7146
7291
  board.pointerDown = (event) => {
7147
- const linePointers = getLinePointers();
7292
+ const linePointers = getArrowLinePointers();
7148
7293
  const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
7149
7294
  if (!PlaitBoard.isReadonly(board) && isLinePointer && isDrawingMode(board)) {
7150
7295
  const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
@@ -7163,7 +7308,7 @@ const withLineCreateByDraw = (board) => {
7163
7308
  let movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
7164
7309
  if (start) {
7165
7310
  const lineShape = PlaitBoard.getPointer(board);
7166
- temporaryElement = handleLineCreating(board, lineShape, start, movingPoint, sourceElement, lineShapeG);
7311
+ temporaryElement = handleArrowLineCreating(board, lineShape, start, movingPoint, sourceElement, lineShapeG);
7167
7312
  }
7168
7313
  pointerMove(event);
7169
7314
  };
@@ -7246,7 +7391,7 @@ const withGeometryResize = (board) => {
7246
7391
  return board;
7247
7392
  };
7248
7393
 
7249
- const withLineResize = (board) => {
7394
+ const withArrowLineResize = (board) => {
7250
7395
  let elbowLineIndex;
7251
7396
  let elbowLineDeleteCount;
7252
7397
  let elbowSourcePoint;
@@ -7258,11 +7403,11 @@ const withLineResize = (board) => {
7258
7403
  return true;
7259
7404
  },
7260
7405
  hitTest: (point) => {
7261
- const selectedLineElements = getSelectedLineElements(board);
7406
+ const selectedLineElements = getSelectedArrowLineElements(board);
7262
7407
  if (selectedLineElements.length > 0) {
7263
7408
  let result = null;
7264
7409
  selectedLineElements.forEach(value => {
7265
- const handleRef = getHitLineResizeHandleRef(board, value, point);
7410
+ const handleRef = getHitArrowLineResizeHandleRef(board, value, point);
7266
7411
  if (handleRef) {
7267
7412
  result = {
7268
7413
  element: value,
@@ -7276,9 +7421,9 @@ const withLineResize = (board) => {
7276
7421
  return null;
7277
7422
  },
7278
7423
  beforeResize: (resizeRef) => {
7279
- if (resizeRef.element.shape === LineShape.elbow &&
7280
- resizeRef.handle !== LineResizeHandle.source &&
7281
- resizeRef.handle !== LineResizeHandle.target) {
7424
+ if (resizeRef.element.shape === ArrowLineShape.elbow &&
7425
+ resizeRef.handle !== ArrowLineResizeHandle.source &&
7426
+ resizeRef.handle !== ArrowLineResizeHandle.target) {
7282
7427
  const params = getElbowLineRouteOptions(board, resizeRef.element);
7283
7428
  if (isUseDefaultOrthogonalRoute(resizeRef.element, params)) {
7284
7429
  return;
@@ -7300,8 +7445,8 @@ const withLineResize = (board) => {
7300
7445
  let target = { ...resizeRef.element.target };
7301
7446
  let handleIndex = resizeRef.handleIndex;
7302
7447
  const hitElement = getSnappingShape(board, resizeState.endPoint);
7303
- if (resizeRef.handle === LineResizeHandle.source || resizeRef.handle === LineResizeHandle.target) {
7304
- const object = resizeRef.handle === LineResizeHandle.source ? source : target;
7448
+ if (resizeRef.handle === ArrowLineResizeHandle.source || resizeRef.handle === ArrowLineResizeHandle.target) {
7449
+ const object = resizeRef.handle === ArrowLineResizeHandle.source ? source : target;
7305
7450
  points[handleIndex] = resizeState.endPoint;
7306
7451
  if (hitElement) {
7307
7452
  object.connection = getHitConnection(board, resizeState.endPoint, hitElement);
@@ -7313,7 +7458,7 @@ const withLineResize = (board) => {
7313
7458
  }
7314
7459
  }
7315
7460
  else {
7316
- if (resizeRef.element.shape === LineShape.elbow) {
7461
+ if (resizeRef.element.shape === ArrowLineShape.elbow) {
7317
7462
  if (elbowNextRenderPoints && elbowSourcePoint && elbowTargetPoint) {
7318
7463
  const resizedPreviousAndNextPoint = getResizedPreviousAndNextPoint(elbowNextRenderPoints, elbowSourcePoint, elbowTargetPoint, handleIndex);
7319
7464
  const startKeyPoint = elbowNextRenderPoints[handleIndex];
@@ -7332,7 +7477,7 @@ const withLineResize = (board) => {
7332
7477
  }
7333
7478
  }
7334
7479
  else {
7335
- if (resizeRef.handle === LineResizeHandle.addHandle) {
7480
+ if (resizeRef.handle === ArrowLineResizeHandle.addHandle) {
7336
7481
  points.splice(handleIndex + 1, 0, resizeState.endPoint);
7337
7482
  }
7338
7483
  else {
@@ -7341,13 +7486,13 @@ const withLineResize = (board) => {
7341
7486
  }
7342
7487
  }
7343
7488
  if (!hitElement) {
7344
- handleIndex = resizeRef.handle === LineResizeHandle.addHandle ? handleIndex + 1 : handleIndex;
7345
- const drawPoints = getLinePoints(board, resizeRef.element);
7489
+ handleIndex = resizeRef.handle === ArrowLineResizeHandle.addHandle ? handleIndex + 1 : handleIndex;
7490
+ const drawPoints = getArrowLinePoints(board, resizeRef.element);
7346
7491
  const newPoints = [...points];
7347
7492
  newPoints[0] = drawPoints[0];
7348
7493
  newPoints[newPoints.length - 1] = drawPoints[drawPoints.length - 1];
7349
- if (resizeRef.element.shape !== LineShape.elbow ||
7350
- (resizeRef.element.shape === LineShape.elbow && newPoints.length === 2)) {
7494
+ if (resizeRef.element.shape !== ArrowLineShape.elbow ||
7495
+ (resizeRef.element.shape === ArrowLineShape.elbow && newPoints.length === 2)) {
7351
7496
  newPoints.forEach((point, index) => {
7352
7497
  if (index === handleIndex)
7353
7498
  return;
@@ -7357,10 +7502,10 @@ const withLineResize = (board) => {
7357
7502
  });
7358
7503
  }
7359
7504
  }
7360
- DrawTransforms.resizeLine(board, { points, source, target }, resizeRef.path);
7505
+ DrawTransforms.resizeArrowLine(board, { points, source, target }, resizeRef.path);
7361
7506
  },
7362
7507
  afterResize: (resizeRef) => {
7363
- if (resizeRef.element.shape === LineShape.elbow) {
7508
+ if (resizeRef.element.shape === ArrowLineShape.elbow) {
7364
7509
  const element = PlaitNode.get(board, resizeRef.path);
7365
7510
  let points = element && [...element.points];
7366
7511
  if (points.length > 2 && elbowNextRenderPoints && elbowSourcePoint && elbowTargetPoint) {
@@ -7379,7 +7524,7 @@ const withLineResize = (board) => {
7379
7524
  points = [];
7380
7525
  }
7381
7526
  points = [elbowSourcePoint, ...points, elbowTargetPoint];
7382
- DrawTransforms.resizeLine(board, { points }, resizeRef.path);
7527
+ DrawTransforms.resizeArrowLine(board, { points }, resizeRef.path);
7383
7528
  }
7384
7529
  }
7385
7530
  elbowLineIndex = null;
@@ -7393,7 +7538,7 @@ const withLineResize = (board) => {
7393
7538
  return board;
7394
7539
  };
7395
7540
 
7396
- const withLineBoundReaction = (board) => {
7541
+ const withArrowLineBoundReaction = (board) => {
7397
7542
  const { pointerMove, pointerUp } = board;
7398
7543
  let boundShapeG = null;
7399
7544
  board.pointerMove = (event) => {
@@ -7402,13 +7547,13 @@ const withLineBoundReaction = (board) => {
7402
7547
  pointerMove(event);
7403
7548
  return;
7404
7549
  }
7405
- const linePointers = Object.keys(LineShape);
7550
+ const linePointers = Object.keys(ArrowLineShape);
7406
7551
  const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
7407
7552
  const movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
7408
7553
  const isLineResizing = isResizingByCondition(board, resizeRef => {
7409
7554
  const { element, handle } = resizeRef;
7410
- const isSourceOrTarget = handle === LineResizeHandle.target || handle === LineResizeHandle.source;
7411
- return PlaitDrawElement.isLine(element) && isSourceOrTarget;
7555
+ const isSourceOrTarget = handle === ArrowLineResizeHandle.target || handle === ArrowLineResizeHandle.source;
7556
+ return PlaitDrawElement.isArrowLine(element) && isSourceOrTarget;
7412
7557
  });
7413
7558
  if (isLinePointer || isLineResizing) {
7414
7559
  const hitElement = getHitShape(board, movingPoint);
@@ -7441,33 +7586,34 @@ const withLineBoundReaction = (board) => {
7441
7586
  return board;
7442
7587
  };
7443
7588
 
7444
- const withLineText = (board) => {
7589
+ const withArrowLineText = (board) => {
7445
7590
  const { dblClick } = board;
7446
7591
  board.dblClick = (event) => {
7447
7592
  if (!PlaitBoard.isReadonly(board)) {
7448
7593
  const clickPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
7449
7594
  const hitTarget = getHitElementByPoint(board, clickPoint, (element) => {
7450
- return PlaitDrawElement.isLine(element);
7595
+ return PlaitDrawElement.isArrowLine(element);
7451
7596
  });
7452
7597
  const hitTargetPath = hitTarget && PlaitBoard.findPath(board, hitTarget);
7453
7598
  if (hitTarget) {
7454
- const points = getLinePoints(board, hitTarget);
7599
+ const points = getArrowLinePoints(board, hitTarget);
7455
7600
  const point = getNearestPointBetweenPointAndSegments(clickPoint, points);
7456
7601
  const texts = hitTarget.texts?.length ? [...hitTarget.texts] : [];
7457
- const textIndex = getHitLineTextIndex(board, hitTarget, clickPoint);
7458
- const isHitText = isHitLineText(board, hitTarget, clickPoint);
7602
+ const textIndex = getHitArrowLineTextIndex(board, hitTarget, clickPoint);
7603
+ const isHitText = isHitArrowLineText(board, hitTarget, clickPoint);
7459
7604
  if (isHitText) {
7460
7605
  editHandle(board, hitTarget, textIndex);
7461
7606
  }
7462
7607
  else {
7463
7608
  const ratio = getRatioByPoint(points, point);
7609
+ const textMemory = getMemorizedLatest('line')?.text || {};
7464
7610
  texts.push({
7465
- text: buildText(LINE_TEXT),
7611
+ text: buildText(LINE_TEXT, undefined, textMemory),
7466
7612
  position: ratio,
7467
7613
  width: 28,
7468
7614
  height: 20
7469
7615
  });
7470
- DrawTransforms.setLineTexts(board, hitTarget, texts);
7616
+ DrawTransforms.setArrowLineTexts(board, hitTarget, texts);
7471
7617
  setTimeout(() => {
7472
7618
  if (hitTargetPath) {
7473
7619
  const newHitTarget = PlaitNode.get(board, hitTargetPath);
@@ -7489,7 +7635,7 @@ function editHandle(board, element, manageIndex, isFirstEdit = false) {
7489
7635
  const text = Node.string(textManage.getText());
7490
7636
  const shouldRemove = !text || (isFirstEdit && text === LINE_TEXT);
7491
7637
  if (shouldRemove) {
7492
- DrawTransforms.removeLineText(board, element, manageIndex);
7638
+ DrawTransforms.removeArrowLineText(board, element, manageIndex);
7493
7639
  }
7494
7640
  });
7495
7641
  }
@@ -7516,8 +7662,8 @@ class ImageComponent extends CommonElementFlavour {
7516
7662
  };
7517
7663
  }
7518
7664
  });
7519
- this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
7520
- this.getRef().addGenerator(LineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
7665
+ this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
7666
+ this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
7521
7667
  }
7522
7668
  initialize() {
7523
7669
  super.initialize();
@@ -7554,7 +7700,7 @@ class ImageComponent extends CommonElementFlavour {
7554
7700
  }
7555
7701
  }
7556
7702
 
7557
- const withLineAutoCompleteReaction = (board) => {
7703
+ const withArrowLineAutoCompleteReaction = (board) => {
7558
7704
  const { pointerMove } = board;
7559
7705
  let reactionG = null;
7560
7706
  board.pointerMove = (event) => {
@@ -7568,7 +7714,7 @@ const withLineAutoCompleteReaction = (board) => {
7568
7714
  const hitIndex = getHitIndexOfAutoCompletePoint(rotateAntiPointsByElement(movingPoint, targetElement) || movingPoint, points);
7569
7715
  const hitPoint = points[hitIndex];
7570
7716
  const ref = PlaitElement.getElementRef(targetElement);
7571
- const lineAutoCompleteGenerator = ref.getGenerator(LineAutoCompleteGenerator.key);
7717
+ const lineAutoCompleteGenerator = ref.getGenerator(ArrowLineAutoCompleteGenerator.key);
7572
7718
  lineAutoCompleteGenerator.recoverAutoCompleteG();
7573
7719
  if (hitPoint) {
7574
7720
  lineAutoCompleteGenerator?.removeAutoCompleteG(hitIndex);
@@ -7589,8 +7735,8 @@ const withLineAutoCompleteReaction = (board) => {
7589
7735
  return board;
7590
7736
  };
7591
7737
 
7592
- const WithLineAutoCompletePluginKey = 'plait-line-auto-complete-plugin-key';
7593
- const withLineAutoComplete = (board) => {
7738
+ const WithArrowLineAutoCompletePluginKey = 'plait-arrow-line-auto-complete-plugin-key';
7739
+ const withArrowLineAutoComplete = (board) => {
7594
7740
  const { pointerDown, pointerMove, globalPointerUp } = board;
7595
7741
  let autoCompletePoint = null;
7596
7742
  let lineShapeG = null;
@@ -7608,7 +7754,7 @@ const withLineAutoComplete = (board) => {
7608
7754
  temporaryDisableSelection(board);
7609
7755
  autoCompletePoint = hitPoint;
7610
7756
  sourceElement = targetElement;
7611
- BoardTransforms.updatePointerType(board, LineShape.elbow);
7757
+ BoardTransforms.updatePointerType(board, ArrowLineShape.elbow);
7612
7758
  }
7613
7759
  }
7614
7760
  pointerDown(event);
@@ -7630,7 +7776,7 @@ const withLineAutoComplete = (board) => {
7630
7776
  }
7631
7777
  // source point must be click point
7632
7778
  const rotatedSourcePoint = rotatePointsByElement(sourcePoint, sourceElement) || sourcePoint;
7633
- temporaryElement = handleLineCreating(board, LineShape.elbow, rotatedSourcePoint, movingPoint, sourceElement, lineShapeG);
7779
+ temporaryElement = handleArrowLineCreating(board, ArrowLineShape.elbow, rotatedSourcePoint, movingPoint, sourceElement, lineShapeG);
7634
7780
  }
7635
7781
  }
7636
7782
  pointerMove(event);
@@ -7640,8 +7786,7 @@ const withLineAutoComplete = (board) => {
7640
7786
  Transforms.insertNode(board, temporaryElement, [board.children.length]);
7641
7787
  clearSelectedElement(board);
7642
7788
  addSelectedElement(board, temporaryElement);
7643
- const afterComplete = board.getPluginOptions(WithLineAutoCompletePluginKey)
7644
- ?.afterComplete;
7789
+ const afterComplete = board.getPluginOptions(WithArrowLineAutoCompletePluginKey)?.afterComplete;
7645
7790
  afterComplete && afterComplete(temporaryElement);
7646
7791
  }
7647
7792
  if (autoCompletePoint) {
@@ -7657,7 +7802,7 @@ const withLineAutoComplete = (board) => {
7657
7802
  return board;
7658
7803
  };
7659
7804
 
7660
- const withLineTextMove = (board) => {
7805
+ const withArrowLineTextMove = (board) => {
7661
7806
  let textIndex = 0;
7662
7807
  const movableBuffer = 100;
7663
7808
  const options = {
@@ -7668,10 +7813,10 @@ const withLineTextMove = (board) => {
7668
7813
  hitTest: (point) => {
7669
7814
  let result = null;
7670
7815
  const line = getHitElementByPoint(board, point, (element) => {
7671
- return PlaitDrawElement.isLine(element);
7816
+ return PlaitDrawElement.isArrowLine(element);
7672
7817
  });
7673
7818
  if (line) {
7674
- const index = getHitLineTextIndex(board, line, point);
7819
+ const index = getHitArrowLineTextIndex(board, line, point);
7675
7820
  const textManages = getTextManages(line);
7676
7821
  const textManage = textManages[index];
7677
7822
  if (index !== -1 && !textManage.isEditing) {
@@ -7685,7 +7830,7 @@ const withLineTextMove = (board) => {
7685
7830
  const element = resizeRef.element;
7686
7831
  if (element) {
7687
7832
  const movingPoint = resizeState.endPoint;
7688
- const points = getLinePoints(board, element);
7833
+ const points = getArrowLinePoints(board, element);
7689
7834
  const distance = distanceBetweenPointAndSegments(points, movingPoint);
7690
7835
  if (distance <= movableBuffer) {
7691
7836
  const point = getNearestPointBetweenPointAndSegments(movingPoint, points, false);
@@ -7695,7 +7840,7 @@ const withLineTextMove = (board) => {
7695
7840
  ...texts[textIndex],
7696
7841
  position
7697
7842
  };
7698
- DrawTransforms.setLineTexts(board, element, texts);
7843
+ DrawTransforms.setArrowLineTexts(board, element, texts);
7699
7844
  }
7700
7845
  }
7701
7846
  }
@@ -7855,8 +8000,8 @@ class TableComponent extends CommonElementFlavour {
7855
8000
  });
7856
8001
  this.tableGenerator = new TableGenerator(this.board);
7857
8002
  this.initializeTextManage();
7858
- this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
7859
- this.getRef().addGenerator(LineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
8003
+ this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
8004
+ this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
7860
8005
  }
7861
8006
  initialize() {
7862
8007
  super.initialize();
@@ -7902,9 +8047,9 @@ class TableComponent extends CommonElementFlavour {
7902
8047
  this.textGenerator = new TextGenerator(this.board, this.element, texts, {
7903
8048
  onChange: (value, data, text) => {
7904
8049
  const height = data.height / this.board.viewport.zoom;
7905
- const width = data.width / this.board.viewport.zoom;
8050
+ const path = PlaitBoard.findPath(this.board, value);
7906
8051
  if (data.newText) {
7907
- DrawTransforms.setTableText(this.board, value, text.key, data.newText, width, height);
8052
+ DrawTransforms.setTableText(this.board, path, text.key, data.newText, height);
7908
8053
  }
7909
8054
  data.operations && memorizeLatestText(value, data.operations);
7910
8055
  },
@@ -8095,7 +8240,7 @@ function withTableResize(board) {
8095
8240
 
8096
8241
  const withTable = (board) => {
8097
8242
  const tableBoard = board;
8098
- const { drawElement, getRectangle, isRectangleHit, isHit, isMovable, dblClick, keyDown } = tableBoard;
8243
+ const { drawElement, getRectangle, isRectangleHit, isHit, isMovable, dblClick, keyDown, pointerUp } = tableBoard;
8099
8244
  tableBoard.drawElement = (context) => {
8100
8245
  if (PlaitDrawElement.isElementByTable(context.element)) {
8101
8246
  return TableComponent;
@@ -8132,12 +8277,21 @@ const withTable = (board) => {
8132
8277
  const selectedElements = getSelectedElements(board);
8133
8278
  const isSingleSelection = selectedElements.length === 1;
8134
8279
  const targetElement = selectedElements[0];
8135
- if (!PlaitBoard.isReadonly(board) && !isVirtualKey(event) && !isDelete(event) && !isSpaceHotkey(event) && isSingleSelection) {
8280
+ if (!PlaitBoard.isReadonly(board) &&
8281
+ !PlaitBoard.hasBeenTextEditing(tableBoard) &&
8282
+ !isVirtualKey(event) &&
8283
+ !isDelete(event) &&
8284
+ !isSpaceHotkey(event) &&
8285
+ isSingleSelection) {
8136
8286
  event.preventDefault();
8137
8287
  if (PlaitDrawElement.isElementByTable(targetElement)) {
8138
- const firstTextCell = targetElement.cells.find(item => item.text && item.textHeight);
8139
- if (firstTextCell) {
8140
- editCell(firstTextCell);
8288
+ const cells = getSelectedCells(targetElement);
8289
+ let cell = targetElement.cells.find(item => item.text && item.textHeight);
8290
+ if (cells?.length) {
8291
+ cell = cells.find(item => item.text && item.textHeight);
8292
+ }
8293
+ if (cell) {
8294
+ editCell(cell);
8141
8295
  return;
8142
8296
  }
8143
8297
  }
@@ -8159,6 +8313,23 @@ const withTable = (board) => {
8159
8313
  }
8160
8314
  dblClick(event);
8161
8315
  };
8316
+ tableBoard.pointerUp = (event) => {
8317
+ const isSetSelectionPointer = PlaitBoard.isPointer(tableBoard, PlaitPointerType.selection) || PlaitBoard.isPointer(tableBoard, PlaitPointerType.hand);
8318
+ const isSkip = !isMainPointer(event) || isDragging(tableBoard) || !isSetSelectionPointer;
8319
+ if (isSkip) {
8320
+ pointerUp(event);
8321
+ return;
8322
+ }
8323
+ if (isSingleSelectTable(tableBoard)) {
8324
+ const point = toViewBoxPoint(tableBoard, toHostPoint(tableBoard, event.x, event.y));
8325
+ const element = getSelectedTableElements(tableBoard)[0];
8326
+ const hitCell = getHitCell(tableBoard, element, point);
8327
+ if (hitCell && hitCell.text && hitCell.textHeight) {
8328
+ setSelectedCells(element, [hitCell]);
8329
+ }
8330
+ }
8331
+ pointerUp(event);
8332
+ };
8162
8333
  tableBoard.buildTable = (element) => {
8163
8334
  return element;
8164
8335
  };
@@ -8166,14 +8337,12 @@ const withTable = (board) => {
8166
8337
  };
8167
8338
 
8168
8339
  const isSwimlaneDndMode = (board) => {
8169
- const swimlanePointers = getSwimlanePointers();
8170
- const isSwimlanePointer = PlaitBoard.isInPointer(board, swimlanePointers);
8340
+ const isSwimlanePointer = isSwimlanePointers(board);
8171
8341
  const dndMode = isSwimlanePointer && isDndMode(board);
8172
8342
  return dndMode;
8173
8343
  };
8174
8344
  const isSwimlaneDrawingMode = (board) => {
8175
- const swimlanePointers = getSwimlanePointers();
8176
- const isSwimlanePointer = PlaitBoard.isInPointer(board, swimlanePointers);
8345
+ const isSwimlanePointer = isSwimlanePointers(board);
8177
8346
  const drawingMode = isSwimlanePointer && isDrawingMode(board);
8178
8347
  return drawingMode;
8179
8348
  };
@@ -8303,28 +8472,11 @@ const withSwimlane = (board) => {
8303
8472
  }
8304
8473
  return buildTable(element);
8305
8474
  };
8306
- board.pointerUp = (event) => {
8307
- const isSetSelectionPointer = PlaitBoard.isPointer(board, PlaitPointerType.selection) || PlaitBoard.isPointer(board, PlaitPointerType.hand);
8308
- const isSkip = !isMainPointer(event) || isDragging(board) || !isSetSelectionPointer;
8309
- if (isSkip) {
8310
- pointerUp(event);
8311
- return;
8312
- }
8313
- if (isSingleSelectSwimlane(board)) {
8314
- const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
8315
- const element = getSelectedSwimlane(board);
8316
- const hitCell = getHitCell(board, element, point);
8317
- if (hitCell && hitCell.text && hitCell.textHeight) {
8318
- setSelectedCells(element, [hitCell]);
8319
- }
8320
- }
8321
- pointerUp(event);
8322
- };
8323
8475
  return withSwimlaneCreateByDrawing(withSwimlaneCreateByDrag(board));
8324
8476
  };
8325
8477
 
8326
8478
  const withDraw = (board) => {
8327
- const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment } = board;
8479
+ const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment, getHitElement } = board;
8328
8480
  board.drawElement = (context) => {
8329
8481
  if (PlaitDrawElement.isGeometry(context.element)) {
8330
8482
  if (PlaitDrawElement.isUML(context.element)) {
@@ -8332,8 +8484,8 @@ const withDraw = (board) => {
8332
8484
  }
8333
8485
  return GeometryComponent;
8334
8486
  }
8335
- else if (PlaitDrawElement.isLine(context.element)) {
8336
- return LineComponent;
8487
+ else if (PlaitDrawElement.isArrowLine(context.element)) {
8488
+ return ArrowLineComponent;
8337
8489
  }
8338
8490
  else if (PlaitDrawElement.isImage(context.element)) {
8339
8491
  return ImageComponent;
@@ -8344,10 +8496,10 @@ const withDraw = (board) => {
8344
8496
  if (PlaitDrawElement.isGeometry(element)) {
8345
8497
  return RectangleClient.getRectangleByPoints(element.points);
8346
8498
  }
8347
- if (PlaitDrawElement.isLine(element)) {
8348
- const points = getLinePoints(board, element);
8499
+ if (PlaitDrawElement.isArrowLine(element)) {
8500
+ const points = getArrowLinePoints(board, element);
8349
8501
  const lineTextRectangles = element.texts.map((text, index) => {
8350
- const rectangle = getLineTextRectangle(board, element, index);
8502
+ const rectangle = getArrowLineTextRectangle(board, element, index);
8351
8503
  return rectangle;
8352
8504
  });
8353
8505
  const linePointsRectangle = RectangleClient.getRectangleByPoints(points);
@@ -8372,6 +8524,13 @@ const withDraw = (board) => {
8372
8524
  }
8373
8525
  return isHit(element, point);
8374
8526
  };
8527
+ board.getHitElement = elements => {
8528
+ const isDrawElements = elements.every(item => PlaitDrawElement.isDrawElement(item));
8529
+ if (isDrawElements) {
8530
+ return getDrawHitElement(board, elements);
8531
+ }
8532
+ return getHitElement(elements);
8533
+ };
8375
8534
  board.isInsidePoint = (element, point) => {
8376
8535
  const result = isHitElementInside(board, element, point);
8377
8536
  if (result !== null) {
@@ -8386,7 +8545,7 @@ const withDraw = (board) => {
8386
8545
  if (PlaitDrawElement.isImage(element)) {
8387
8546
  return true;
8388
8547
  }
8389
- if (PlaitDrawElement.isLine(element)) {
8548
+ if (PlaitDrawElement.isArrowLine(element)) {
8390
8549
  const selectedElements = getSelectedElements(board);
8391
8550
  const isSelected = (boundId) => {
8392
8551
  return !!selectedElements.find(value => value.id === boundId);
@@ -8412,7 +8571,7 @@ const withDraw = (board) => {
8412
8571
  };
8413
8572
  board.getRelatedFragment = (elements, originData) => {
8414
8573
  const selectedElements = originData?.length ? originData : getSelectedElements(board);
8415
- const lineElements = board.children.filter(element => PlaitDrawElement.isLine(element));
8574
+ const lineElements = board.children.filter(element => PlaitDrawElement.isArrowLine(element));
8416
8575
  const activeLines = lineElements.filter(line => {
8417
8576
  const source = selectedElements.find(element => element.id === line.source.boundId);
8418
8577
  const target = selectedElements.find(element => element.id === line.target.boundId);
@@ -8421,12 +8580,12 @@ const withDraw = (board) => {
8421
8580
  });
8422
8581
  return getRelatedFragment([...elements, ...activeLines], originData);
8423
8582
  };
8424
- return withSwimlane(withTable(withDrawResize(withLineAutoCompleteReaction(withLineBoundReaction(withLineResize(withLineTextMove(withLineText(withGeometryResize(withDrawRotate(withLineCreateByDraw(withLineAutoComplete(withGeometryCreateByDrag(withGeometryCreateByDrawing(withDrawFragment(withDrawHotkey(board))))))))))))))));
8583
+ return withSwimlane(withTable(withDrawResize(withArrowLineAutoCompleteReaction(withArrowLineBoundReaction(withArrowLineResize(withArrowLineTextMove(withArrowLineText(withGeometryResize(withDrawRotate(withArrowLineCreateByDraw(withArrowLineAutoComplete(withGeometryCreateByDrag(withGeometryCreateByDrawing(withDrawFragment(withDrawHotkey(board))))))))))))))));
8425
8584
  };
8426
8585
 
8427
8586
  /**
8428
8587
  * Generated bundle index. Do not edit.
8429
8588
  */
8430
8589
 
8431
- export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, LineAutoCompleteGenerator, LineComponent, LineHandleKey, LineMarkerType, LineShape, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryCommonTextKeys, MultipleTextGeometryTextKeys, PlaitDrawElement, PlaitGeometry, PlaitLine, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, StrokeStyle, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, WithLineAutoCompletePluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createLineElement, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawBoundReaction, drawGeometry, drawLine, drawLineArrow, drawShape, editCell, editText, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getLines, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedCells, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getSelectedSwimlane, getSelectedTableElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, handleLineCreating, hasIllegalElbowPoint, insertElement, isCellIncludeText, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryIncludeText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitLine, isHitLineText, isHitPolyLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isSelfLoop, isSingleSelectElementByTable, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, withDraw, withLineAutoComplete };
8590
+ export { ArrowLineActiveGenerator, ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryCommonTextKeys, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, StrokeStyle, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineShape, WithArrowLineAutoCompletePluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getDrawHitElement, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineDashByElement, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, handleArrowLineCreating, hasIllegalElbowPoint, insertElement, isCellIncludeText, isDrawElementClosed, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isSelfLoop, isSingleSelectElementByTable, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, withArrowLineAutoComplete, withDraw };
8432
8591
  //# sourceMappingURL=plait-draw.mjs.map