@plait/draw 0.62.0-next.6 → 0.62.0-next.8

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 (150) 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/geometry.component.mjs +4 -4
  22. package/esm2022/image.component.mjs +4 -4
  23. package/esm2022/interfaces/arrow-line.mjs +70 -0
  24. package/esm2022/interfaces/element.mjs +2 -2
  25. package/esm2022/interfaces/index.mjs +14 -7
  26. package/esm2022/interfaces/vector-line.mjs +6 -0
  27. package/esm2022/plugins/with-arrow-line-auto-complete-reaction.mjs +41 -0
  28. package/esm2022/plugins/with-arrow-line-auto-complete.mjs +74 -0
  29. package/esm2022/plugins/with-arrow-line-bound-reaction.mjs +53 -0
  30. package/esm2022/plugins/with-arrow-line-create.mjs +53 -0
  31. package/esm2022/plugins/with-arrow-line-resize.mjs +158 -0
  32. package/esm2022/plugins/with-arrow-line-text-move.mjs +53 -0
  33. package/esm2022/plugins/with-arrow-line-text.mjs +63 -0
  34. package/esm2022/plugins/with-draw-fragment.mjs +13 -13
  35. package/esm2022/plugins/with-draw-resize.mjs +12 -5
  36. package/esm2022/plugins/with-draw.mjs +27 -20
  37. package/esm2022/plugins/with-geometry-resize.mjs +1 -1
  38. package/esm2022/plugins/with-swimlane-create.mjs +4 -7
  39. package/esm2022/plugins/with-swimlane.mjs +1 -20
  40. package/esm2022/plugins/with-table.mjs +34 -7
  41. package/esm2022/public-api.mjs +3 -3
  42. package/esm2022/table.component.mjs +6 -6
  43. package/esm2022/transforms/arrow-line.mjs +66 -0
  44. package/esm2022/transforms/common.mjs +36 -0
  45. package/esm2022/transforms/geometry.mjs +6 -28
  46. package/esm2022/transforms/index.mjs +15 -13
  47. package/esm2022/transforms/swimlane.mjs +1 -29
  48. package/esm2022/transforms/table-text.mjs +5 -5
  49. package/esm2022/transforms/table.mjs +30 -0
  50. package/esm2022/utils/arrow-line/arrow-line-arrow.mjs +123 -0
  51. package/esm2022/utils/arrow-line/arrow-line-basic.mjs +257 -0
  52. package/esm2022/utils/arrow-line/arrow-line-common.mjs +162 -0
  53. package/esm2022/utils/arrow-line/arrow-line-resize.mjs +309 -0
  54. package/esm2022/utils/arrow-line/elbow.mjs +114 -0
  55. package/esm2022/utils/arrow-line/index.mjs +6 -0
  56. package/esm2022/utils/clipboard.mjs +10 -10
  57. package/esm2022/utils/common.mjs +14 -5
  58. package/esm2022/utils/geometry.mjs +17 -14
  59. package/esm2022/utils/hit.mjs +67 -44
  60. package/esm2022/utils/index.mjs +2 -2
  61. package/esm2022/utils/memorize.mjs +4 -5
  62. package/esm2022/utils/position/arrow-line.mjs +67 -0
  63. package/esm2022/utils/position/geometry.mjs +1 -1
  64. package/esm2022/utils/selected.mjs +3 -3
  65. package/esm2022/utils/style/stroke.mjs +6 -4
  66. package/esm2022/utils/swimlane.mjs +16 -7
  67. package/esm2022/utils/table-selected.mjs +3 -4
  68. package/esm2022/utils/table.mjs +28 -5
  69. package/fesm2022/plait-draw.mjs +668 -511
  70. package/fesm2022/plait-draw.mjs.map +1 -1
  71. package/generators/arrow-line-active.generator.d.ts +13 -0
  72. package/generators/{line-auto-complete.generator.d.ts → arrow-line-auto-complete.generator.d.ts} +1 -1
  73. package/generators/arrow-line.generator.d.ts +8 -0
  74. package/generators/index.d.ts +2 -2
  75. package/geometry.component.d.ts +2 -2
  76. package/image.component.d.ts +2 -2
  77. package/interfaces/arrow-line.d.ts +75 -0
  78. package/interfaces/element.d.ts +1 -1
  79. package/interfaces/index.d.ts +6 -4
  80. package/interfaces/vector-line.d.ts +16 -0
  81. package/package.json +11 -1
  82. package/plugins/with-arrow-line-auto-complete-reaction.d.ts +2 -0
  83. package/plugins/with-arrow-line-auto-complete.d.ts +7 -0
  84. package/plugins/with-arrow-line-bound-reaction.d.ts +2 -0
  85. package/plugins/with-arrow-line-create.d.ts +2 -0
  86. package/plugins/with-arrow-line-resize.d.ts +2 -0
  87. package/plugins/with-arrow-line-text-move.d.ts +2 -0
  88. package/plugins/with-arrow-line-text.d.ts +2 -0
  89. package/plugins/with-draw-fragment.d.ts +2 -2
  90. package/plugins/with-swimlane.d.ts +1 -2
  91. package/public-api.d.ts +2 -2
  92. package/table.component.d.ts +2 -2
  93. package/transforms/arrow-line.d.ts +8 -0
  94. package/transforms/common.d.ts +3 -0
  95. package/transforms/geometry.d.ts +1 -2
  96. package/transforms/index.d.ts +9 -9
  97. package/transforms/swimlane.d.ts +1 -3
  98. package/transforms/table-text.d.ts +2 -3
  99. package/transforms/table.d.ts +3 -0
  100. package/utils/arrow-line/arrow-line-arrow.d.ts +4 -0
  101. package/utils/arrow-line/arrow-line-basic.d.ts +13 -0
  102. package/utils/{line/line-common.d.ts → arrow-line/arrow-line-common.d.ts} +8 -4
  103. package/utils/{line/line-resize.d.ts → arrow-line/arrow-line-resize.d.ts} +3 -3
  104. package/utils/{line → arrow-line}/elbow.d.ts +7 -7
  105. package/utils/arrow-line/index.d.ts +5 -0
  106. package/utils/clipboard.d.ts +4 -4
  107. package/utils/common.d.ts +1 -0
  108. package/utils/geometry.d.ts +2 -1
  109. package/utils/hit.d.ts +7 -4
  110. package/utils/index.d.ts +1 -1
  111. package/utils/position/arrow-line.d.ts +16 -0
  112. package/utils/selected.d.ts +2 -2
  113. package/utils/swimlane.d.ts +3 -2
  114. package/utils/table.d.ts +2 -0
  115. package/esm2022/generators/line-active.generator.mjs +0 -81
  116. package/esm2022/generators/line-auto-complete.generator.mjs +0 -46
  117. package/esm2022/generators/line.generator.mjs +0 -13
  118. package/esm2022/interfaces/line.mjs +0 -70
  119. package/esm2022/line.component.mjs +0 -155
  120. package/esm2022/plugins/with-line-auto-complete-reaction.mjs +0 -41
  121. package/esm2022/plugins/with-line-auto-complete.mjs +0 -75
  122. package/esm2022/plugins/with-line-bound-reaction.mjs +0 -53
  123. package/esm2022/plugins/with-line-create.mjs +0 -53
  124. package/esm2022/plugins/with-line-resize.mjs +0 -158
  125. package/esm2022/plugins/with-line-text-move.mjs +0 -53
  126. package/esm2022/plugins/with-line-text.mjs +0 -62
  127. package/esm2022/transforms/line.mjs +0 -100
  128. package/esm2022/utils/line/elbow.mjs +0 -114
  129. package/esm2022/utils/line/index.mjs +0 -6
  130. package/esm2022/utils/line/line-arrow.mjs +0 -123
  131. package/esm2022/utils/line/line-basic.mjs +0 -257
  132. package/esm2022/utils/line/line-common.mjs +0 -123
  133. package/esm2022/utils/line/line-resize.mjs +0 -309
  134. package/esm2022/utils/position/line.mjs +0 -67
  135. package/generators/line-active.generator.d.ts +0 -13
  136. package/generators/line.generator.d.ts +0 -8
  137. package/interfaces/line.d.ts +0 -75
  138. package/line.component.d.ts +0 -26
  139. package/plugins/with-line-auto-complete-reaction.d.ts +0 -2
  140. package/plugins/with-line-auto-complete.d.ts +0 -7
  141. package/plugins/with-line-bound-reaction.d.ts +0 -2
  142. package/plugins/with-line-create.d.ts +0 -2
  143. package/plugins/with-line-resize.d.ts +0 -2
  144. package/plugins/with-line-text-move.d.ts +0 -2
  145. package/plugins/with-line-text.d.ts +0 -2
  146. package/transforms/line.d.ts +0 -12
  147. package/utils/line/index.d.ts +0 -5
  148. package/utils/line/line-arrow.d.ts +0 -4
  149. package/utils/line/line-basic.d.ts +0 -13
  150. 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,9 @@ const getStrokeColorByElement = (board, element) => {
1229
1313
  return strokeColor;
1230
1314
  };
1231
1315
  const getFillByElement = (board, element) => {
1232
- const defaultFill = PlaitDrawElement.isFlowchart(element) ? getFlowchartDefaultFill(board.theme.themeColorMode) : DefaultDrawStyle.fill;
1316
+ const defaultFill = PlaitDrawElement.isFlowchart(element) && isDrawElementClosed(element)
1317
+ ? getFlowchartDefaultFill(board.theme.themeColorMode)
1318
+ : DefaultDrawStyle.fill;
1233
1319
  const fill = element.fill || defaultFill;
1234
1320
  return fill;
1235
1321
  };
@@ -1238,7 +1324,7 @@ const getLineDashByElement = (element) => {
1238
1324
  case StrokeStyle.dashed:
1239
1325
  return [8, 8 + getStrokeWidthByElement(element)];
1240
1326
  case StrokeStyle.dotted:
1241
- return [0, 4 + getStrokeWidthByElement(element)];
1327
+ return [2, 4 + getStrokeWidthByElement(element)];
1242
1328
  default:
1243
1329
  return undefined;
1244
1330
  }
@@ -1259,13 +1345,13 @@ const LINE_AUTO_COMPLETE_HOVERED_DIAMETER = 10;
1259
1345
  const LINE_ALIGN_TOLERANCE = 3;
1260
1346
  const LINE_TEXT = '文本';
1261
1347
 
1262
- class LineShapeGenerator extends Generator {
1348
+ class ArrowLineShapeGenerator extends Generator {
1263
1349
  canDraw(element, data) {
1264
1350
  return true;
1265
1351
  }
1266
1352
  draw(element, data) {
1267
1353
  let lineG;
1268
- lineG = drawLine(this.board, element);
1354
+ lineG = drawArrowLine(this.board, element);
1269
1355
  return lineG;
1270
1356
  }
1271
1357
  }
@@ -1406,7 +1492,7 @@ function getIndexAndDeleteCountByKeyPoint(board, element, dataPoints, nextRender
1406
1492
  if (index === null) {
1407
1493
  deleteCount = 0;
1408
1494
  if (midDataPoints.length > 0) {
1409
- const handleRefPair = getLineHandleRefPair(board, element);
1495
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
1410
1496
  const params = getElbowLineRouteOptions(board, element, handleRefPair);
1411
1497
  const keyPoints = removeDuplicatePoints(generateElbowLineRoute(params, board));
1412
1498
  const nextKeyPoints = simplifyOrthogonalPoints(keyPoints.slice(1, keyPoints.length - 1));
@@ -1576,9 +1662,9 @@ const hasIllegalElbowPoint = (midDataPoints) => {
1576
1662
  };
1577
1663
 
1578
1664
  const ARROW_LENGTH = 20;
1579
- const drawLineArrow = (element, points, options) => {
1665
+ const drawArrowLineArrow = (element, points, options) => {
1580
1666
  const arrowG = createG();
1581
- if (PlaitLine.isSourceMark(element, LineMarkerType.none) && PlaitLine.isTargetMark(element, LineMarkerType.none)) {
1667
+ if (PlaitArrowLine.isSourceMark(element, ArrowLineMarkerType.none) && PlaitArrowLine.isTargetMark(element, ArrowLineMarkerType.none)) {
1582
1668
  return null;
1583
1669
  }
1584
1670
  const strokeWidth = getStrokeWidthByElement(element);
@@ -1586,12 +1672,12 @@ const drawLineArrow = (element, points, options) => {
1586
1672
  if (points.length === 1) {
1587
1673
  points = [points[0], [points[0][0] + 0.1, points[0][1]]];
1588
1674
  }
1589
- if (!PlaitLine.isSourceMark(element, LineMarkerType.none)) {
1675
+ if (!PlaitArrowLine.isSourceMark(element, ArrowLineMarkerType.none)) {
1590
1676
  const source = getExtendPoint(points[0], points[1], ARROW_LENGTH + offset);
1591
1677
  const sourceArrow = getArrow(element, { marker: element.source.marker, source, target: points[0], isSource: true }, options);
1592
1678
  sourceArrow && arrowG.appendChild(sourceArrow);
1593
1679
  }
1594
- if (!PlaitLine.isTargetMark(element, LineMarkerType.none)) {
1680
+ if (!PlaitArrowLine.isTargetMark(element, ArrowLineMarkerType.none)) {
1595
1681
  const source = getExtendPoint(points[points.length - 1], points[points.length - 2], ARROW_LENGTH + offset);
1596
1682
  const arrow = getArrow(element, { marker: element.target.marker, source, target: points[points.length - 1], isSource: false }, options);
1597
1683
  arrow && arrowG.appendChild(arrow);
@@ -1602,35 +1688,35 @@ const getArrow = (element, arrowOptions, options) => {
1602
1688
  const { marker, target, source, isSource } = arrowOptions;
1603
1689
  let targetArrow;
1604
1690
  switch (marker) {
1605
- case LineMarkerType.openTriangle: {
1691
+ case ArrowLineMarkerType.openTriangle: {
1606
1692
  targetArrow = drawOpenTriangle(element, source, target, options);
1607
1693
  break;
1608
1694
  }
1609
- case LineMarkerType.solidTriangle: {
1695
+ case ArrowLineMarkerType.solidTriangle: {
1610
1696
  targetArrow = drawSolidTriangle(source, target, options);
1611
1697
  break;
1612
1698
  }
1613
- case LineMarkerType.arrow: {
1699
+ case ArrowLineMarkerType.arrow: {
1614
1700
  targetArrow = drawArrow(element, source, target, options);
1615
1701
  break;
1616
1702
  }
1617
- case LineMarkerType.sharpArrow: {
1703
+ case ArrowLineMarkerType.sharpArrow: {
1618
1704
  targetArrow = drawSharpArrow(source, target, options);
1619
1705
  break;
1620
1706
  }
1621
- case LineMarkerType.oneSideUp: {
1707
+ case ArrowLineMarkerType.oneSideUp: {
1622
1708
  targetArrow = drawOneSideArrow(source, target, isSource ? 'down' : 'up', options);
1623
1709
  break;
1624
1710
  }
1625
- case LineMarkerType.oneSideDown: {
1711
+ case ArrowLineMarkerType.oneSideDown: {
1626
1712
  targetArrow = drawOneSideArrow(source, target, isSource ? 'up' : 'down', options);
1627
1713
  break;
1628
1714
  }
1629
- case LineMarkerType.hollowTriangle: {
1715
+ case ArrowLineMarkerType.hollowTriangle: {
1630
1716
  targetArrow = drawHollowTriangleArrow(source, target, options);
1631
1717
  break;
1632
1718
  }
1633
- case LineMarkerType.singleSlash: {
1719
+ case ArrowLineMarkerType.singleSlash: {
1634
1720
  targetArrow = drawSingleSlash(source, target, isSource, options);
1635
1721
  break;
1636
1722
  }
@@ -1694,10 +1780,10 @@ const drawHollowTriangleArrow = (source, target, options) => {
1694
1780
  return drawLinearPath([pointLeft, pointRight, target], { ...options, fill: 'white' }, true);
1695
1781
  };
1696
1782
 
1697
- const createLineElement = (shape, points, source, target, texts, options) => {
1783
+ const createArrowLineElement = (shape, points, source, target, texts, options) => {
1698
1784
  return {
1699
1785
  id: idCreator(),
1700
- type: 'line',
1786
+ type: 'arrow-line',
1701
1787
  shape,
1702
1788
  source,
1703
1789
  texts: texts ? texts : [],
@@ -1707,17 +1793,17 @@ const createLineElement = (shape, points, source, target, texts, options) => {
1707
1793
  ...options
1708
1794
  };
1709
1795
  };
1710
- const getLinePoints = (board, element) => {
1796
+ const getArrowLinePoints = (board, element) => {
1711
1797
  switch (element.shape) {
1712
- case LineShape.elbow: {
1798
+ case ArrowLineShape.elbow: {
1713
1799
  return getElbowPoints(board, element);
1714
1800
  }
1715
- case LineShape.curve: {
1801
+ case ArrowLineShape.curve: {
1716
1802
  return getCurvePoints(board, element);
1717
1803
  }
1718
1804
  default: {
1719
- const points = PlaitLine.getPoints(board, element);
1720
- const handleRefPair = getLineHandleRefPair(board, element);
1805
+ const points = PlaitArrowLine.getPoints(board, element);
1806
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
1721
1807
  points[0] = handleRefPair.source.point;
1722
1808
  points[points.length - 1] = handleRefPair.target.point;
1723
1809
  return points;
@@ -1726,7 +1812,7 @@ const getLinePoints = (board, element) => {
1726
1812
  };
1727
1813
  const getCurvePoints = (board, element) => {
1728
1814
  if (element.points.length === 2) {
1729
- const handleRefPair = getLineHandleRefPair(board, element);
1815
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
1730
1816
  const { source, target } = handleRefPair;
1731
1817
  const sourceBoundElement = handleRefPair.source.boundElement;
1732
1818
  const targetBoundElement = handleRefPair.target.boundElement;
@@ -1753,7 +1839,7 @@ const getCurvePoints = (board, element) => {
1753
1839
  return pointsOnBezierCurves(curvePoints);
1754
1840
  }
1755
1841
  else {
1756
- let dataPoints = PlaitLine.getPoints(board, element);
1842
+ let dataPoints = PlaitArrowLine.getPoints(board, element);
1757
1843
  dataPoints = removeDuplicatePoints(dataPoints);
1758
1844
  const points = catmullRomFitting(dataPoints);
1759
1845
  return pointsOnBezierCurves(points);
@@ -1763,8 +1849,8 @@ function getMiddlePoints(board, element) {
1763
1849
  const result = [];
1764
1850
  const shape = element.shape;
1765
1851
  const hideBuffer = 10;
1766
- if (shape === LineShape.straight) {
1767
- const points = PlaitLine.getPoints(board, element);
1852
+ if (shape === ArrowLineShape.straight) {
1853
+ const points = PlaitArrowLine.getPoints(board, element);
1768
1854
  for (let i = 0; i < points.length - 1; i++) {
1769
1855
  const distance = distanceBetweenPointAndPoint(...points[i], ...points[i + 1]);
1770
1856
  if (distance < hideBuffer)
@@ -1772,8 +1858,8 @@ function getMiddlePoints(board, element) {
1772
1858
  result.push([(points[i][0] + points[i + 1][0]) / 2, (points[i][1] + points[i + 1][1]) / 2]);
1773
1859
  }
1774
1860
  }
1775
- if (shape === LineShape.curve) {
1776
- const points = PlaitLine.getPoints(board, element);
1861
+ if (shape === ArrowLineShape.curve) {
1862
+ const points = PlaitArrowLine.getPoints(board, element);
1777
1863
  const pointsOnBezier = getCurvePoints(board, element);
1778
1864
  if (points.length === 2) {
1779
1865
  const start = 0;
@@ -1793,7 +1879,7 @@ function getMiddlePoints(board, element) {
1793
1879
  }
1794
1880
  }
1795
1881
  }
1796
- if (shape === LineShape.elbow) {
1882
+ if (shape === ArrowLineShape.elbow) {
1797
1883
  const renderPoints = getElbowPoints(board, element);
1798
1884
  const options = getElbowLineRouteOptions(board, element);
1799
1885
  if (!isUseDefaultOrthogonalRoute(element, options)) {
@@ -1812,15 +1898,15 @@ function getMiddlePoints(board, element) {
1812
1898
  }
1813
1899
  return result;
1814
1900
  }
1815
- const drawLine = (board, element) => {
1901
+ const drawArrowLine = (board, element) => {
1816
1902
  const strokeWidth = getStrokeWidthByElement(element);
1817
1903
  const strokeColor = getStrokeColorByElement(board, element);
1818
1904
  const strokeLineDash = getLineDashByElement(element);
1819
1905
  const options = { stroke: strokeColor, strokeWidth, strokeLineDash };
1820
1906
  const lineG = createG();
1821
- let points = getLinePoints(board, element);
1907
+ let points = getArrowLinePoints(board, element);
1822
1908
  let line;
1823
- if (element.shape === LineShape.curve) {
1909
+ if (element.shape === ArrowLineShape.curve) {
1824
1910
  line = PlaitBoard.getRoughSVG(board).curve(points, options);
1825
1911
  }
1826
1912
  else {
@@ -1832,10 +1918,10 @@ const drawLine = (board, element) => {
1832
1918
  setStrokeLinecap(line, 'round');
1833
1919
  }
1834
1920
  lineG.appendChild(line);
1835
- const { mask, maskTargetFillRect } = drawMask(board, element, id);
1921
+ const { mask, maskTargetFillRect } = drawArrowLineMask(board, element, id);
1836
1922
  lineG.appendChild(mask);
1837
1923
  line.appendChild(maskTargetFillRect);
1838
- const arrow = drawLineArrow(element, points, { stroke: strokeColor, strokeWidth });
1924
+ const arrow = drawArrowLineArrow(element, points, { stroke: strokeColor, strokeWidth });
1839
1925
  arrow && lineG.appendChild(arrow);
1840
1926
  return lineG;
1841
1927
  };
@@ -1853,9 +1939,9 @@ const getHitConnectorPoint = (point, hitElement) => {
1853
1939
  return distanceBetweenPointAndPoint(...connectorPoint, ...point) <= LINE_SNAPPING_CONNECTOR_BUFFER;
1854
1940
  });
1855
1941
  };
1856
- const getLineTextRectangle = (board, element, index) => {
1942
+ const getArrowLineTextRectangle = (board, element, index) => {
1857
1943
  const text = element.texts[index];
1858
- const elbowPoints = getLinePoints(board, element);
1944
+ const elbowPoints = getArrowLinePoints(board, element);
1859
1945
  const point = getPointOnPolyline(elbowPoints, text.position);
1860
1946
  return {
1861
1947
  x: point[0] - text.width / 2,
@@ -1864,9 +1950,9 @@ const getLineTextRectangle = (board, element, index) => {
1864
1950
  height: text.height
1865
1951
  };
1866
1952
  };
1867
- const getLines = (board) => {
1953
+ const getArrowLines = (board) => {
1868
1954
  return findElements(board, {
1869
- match: (element) => PlaitDrawElement.isLine(element),
1955
+ match: (element) => PlaitDrawElement.isArrowLine(element),
1870
1956
  recursion: (element) => PlaitDrawElement.isDrawElement(element)
1871
1957
  });
1872
1958
  };
@@ -1886,33 +1972,33 @@ const Q2C = (points) => {
1886
1972
  }
1887
1973
  return result;
1888
1974
  };
1889
- const handleLineCreating = (board, lineShape, sourcePoint, movingPoint, sourceElement, lineShapeG) => {
1975
+ const handleArrowLineCreating = (board, lineShape, sourcePoint, movingPoint, sourceElement, lineShapeG) => {
1890
1976
  const hitElement = getSnappingShape(board, movingPoint);
1891
1977
  const targetConnection = hitElement ? getHitConnection(board, movingPoint, hitElement) : undefined;
1892
1978
  const sourceConnection = sourceElement ? getHitConnection(board, sourcePoint, sourceElement) : undefined;
1893
1979
  const targetBoundId = hitElement ? hitElement.id : undefined;
1894
- const lineGenerator = new LineShapeGenerator(board);
1980
+ const lineGenerator = new ArrowLineShapeGenerator(board);
1895
1981
  const memorizedLatest = getLineMemorizedLatest();
1896
1982
  let sourceMarker, targetMarker;
1897
1983
  sourceMarker = memorizedLatest.source;
1898
1984
  targetMarker = memorizedLatest.target;
1899
1985
  sourceMarker && delete memorizedLatest.source;
1900
1986
  targetMarker && delete memorizedLatest.target;
1901
- 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 }, [], {
1902
1988
  strokeWidth: DefaultLineStyle.strokeWidth,
1903
1989
  ...memorizedLatest
1904
1990
  });
1905
- const linePoints = getLinePoints(board, temporaryLineElement);
1991
+ const linePoints = getArrowLinePoints(board, temporaryLineElement);
1906
1992
  const otherPoint = linePoints[0];
1907
1993
  temporaryLineElement.points[1] = alignPoints(otherPoint, movingPoint);
1908
1994
  lineGenerator.processDrawing(temporaryLineElement, lineShapeG);
1909
1995
  PlaitBoard.getElementActiveHost(board).append(lineShapeG);
1910
1996
  return temporaryLineElement;
1911
1997
  };
1912
- function drawMask(board, element, id) {
1998
+ function drawArrowLineMask(board, element, id) {
1913
1999
  const mask = createMask();
1914
2000
  mask.setAttribute('id', id);
1915
- const points = getLinePoints(board, element);
2001
+ const points = getArrowLinePoints(board, element);
1916
2002
  let rectangle = RectangleClient.getRectangleByPoints(points);
1917
2003
  rectangle = RectangleClient.getOutlineRectangle(rectangle, -30);
1918
2004
  const maskFillRect = createRect(rectangle, {
@@ -1921,7 +2007,7 @@ function drawMask(board, element, id) {
1921
2007
  mask.appendChild(maskFillRect);
1922
2008
  const texts = element.texts;
1923
2009
  texts.forEach((text, index) => {
1924
- let textRectangle = getLineTextRectangle(board, element, index);
2010
+ let textRectangle = getArrowLineTextRectangle(board, element, index);
1925
2011
  textRectangle = RectangleClient.inflate(textRectangle, LINE_TEXT_SPACE * 2);
1926
2012
  const rect = createRect(textRectangle, {
1927
2013
  fill: 'black'
@@ -2107,18 +2193,18 @@ const createDefaultFlowchart = (point) => {
2107
2193
  const processElement2 = createGeometryElement(FlowchartSymbols.process, getDefaultGeometryPoints(FlowchartSymbols.process, processPoint2), '过程', options);
2108
2194
  const endPoint = [decisionPoint[0], decisionPoint[1] + decisionProperty.height / 2 + 95 + terminalProperty.height / 2];
2109
2195
  const endElement = createGeometryElement(FlowchartSymbols.terminal, getDefaultGeometryPoints(FlowchartSymbols.terminal, endPoint), '结束', options);
2110
- const line1 = createLineElement(LineShape.elbow, [
2196
+ const line1 = createArrowLineElement(ArrowLineShape.elbow, [
2111
2197
  [0, 0],
2112
2198
  [0, 0]
2113
- ], { marker: LineMarkerType.none, connection: [0.5, 1], boundId: startElement.id }, { marker: LineMarkerType.arrow, connection: [0.5, 0], boundId: processElement1.id }, [], lineOptions);
2114
- 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, [
2115
2201
  [0, 0],
2116
2202
  [0, 0]
2117
- ], { marker: LineMarkerType.none, connection: [0.5, 1], boundId: processElement1.id }, { marker: LineMarkerType.arrow, connection: [0.5, 0], boundId: decisionElement.id }, [], lineOptions);
2118
- 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, [
2119
2205
  [0, 0],
2120
2206
  [0, 0]
2121
- ], { 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 }, [
2122
2208
  {
2123
2209
  text: buildText('是'),
2124
2210
  position: 0.5,
@@ -2126,10 +2212,10 @@ const createDefaultFlowchart = (point) => {
2126
2212
  height: 20
2127
2213
  }
2128
2214
  ], lineOptions);
2129
- const line4 = createLineElement(LineShape.elbow, [
2215
+ const line4 = createArrowLineElement(ArrowLineShape.elbow, [
2130
2216
  [0, 0],
2131
2217
  [0, 0]
2132
- ], { 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 }, [
2133
2219
  {
2134
2220
  text: buildText('否'),
2135
2221
  position: 0.5,
@@ -2137,10 +2223,10 @@ const createDefaultFlowchart = (point) => {
2137
2223
  height: 20
2138
2224
  }
2139
2225
  ], lineOptions);
2140
- const line5 = createLineElement(LineShape.elbow, [
2226
+ const line5 = createArrowLineElement(ArrowLineShape.elbow, [
2141
2227
  [0, 0],
2142
2228
  [0, 0]
2143
- ], { 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);
2144
2230
  return [startElement, processElement1, decisionElement, processElement2, endElement, line1, line2, line3, line4, line5];
2145
2231
  };
2146
2232
  const getAutoCompletePoints = (element) => {
@@ -2246,6 +2332,9 @@ const isSingleTextShape = (shape) => {
2246
2332
  const isSingleTextGeometry = (element) => {
2247
2333
  return PlaitDrawElement.isGeometry(element) && isSingleTextShape(element.shape);
2248
2334
  };
2335
+ const isGeometryClosed = (element) => {
2336
+ return !GEOMETRY_NOT_CLOSED.includes(element.shape);
2337
+ };
2249
2338
 
2250
2339
  const isSelfLoop = (element) => {
2251
2340
  return element.source.boundId && element.source.boundId === element.target.boundId;
@@ -2254,7 +2343,7 @@ const isUseDefaultOrthogonalRoute = (element, options) => {
2254
2343
  return isSourceAndTargetIntersect(options) && !isSelfLoop(element);
2255
2344
  };
2256
2345
  const getElbowPoints = (board, element) => {
2257
- const handleRefPair = getLineHandleRefPair(board, element);
2346
+ const handleRefPair = getArrowLineHandleRefPair(board, element);
2258
2347
  const params = getElbowLineRouteOptions(board, element, handleRefPair);
2259
2348
  // console.log(params, 'params');
2260
2349
  if (isUseDefaultOrthogonalRoute(element, params)) {
@@ -2267,7 +2356,7 @@ const getElbowPoints = (board, element) => {
2267
2356
  }
2268
2357
  else {
2269
2358
  const simplifiedNextKeyPoints = simplifyOrthogonalPoints(nextKeyPoints);
2270
- const dataPoints = removeDuplicatePoints(PlaitLine.getPoints(board, element));
2359
+ const dataPoints = removeDuplicatePoints(PlaitArrowLine.getPoints(board, element));
2271
2360
  const midDataPoints = dataPoints.slice(1, -1);
2272
2361
  if (hasIllegalElbowPoint(midDataPoints)) {
2273
2362
  return simplifyOrthogonalPoints(keyPoints);
@@ -2362,8 +2451,8 @@ const getSelectedGeometryElements = (board) => {
2362
2451
  const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isGeometry(value));
2363
2452
  return selectedElements;
2364
2453
  };
2365
- const getSelectedLineElements = (board) => {
2366
- const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isLine(value));
2454
+ const getSelectedArrowLineElements = (board) => {
2455
+ const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isArrowLine(value));
2367
2456
  return selectedElements;
2368
2457
  };
2369
2458
  const getSelectedImageElements = (board) => {
@@ -2379,126 +2468,11 @@ const getSelectedSwimlane = (board) => {
2379
2468
  return selectedElements.find(item => PlaitDrawElement.isSwimlane(item));
2380
2469
  };
2381
2470
 
2382
- const resizeLine = (board, options, path) => {
2383
- Transforms.setNode(board, options, path);
2384
- };
2385
- const setLineTexts = (board, element, texts) => {
2386
- const path = PlaitBoard.findPath(board, element);
2387
- Transforms.setNode(board, { texts }, path);
2388
- };
2389
- const removeLineText = (board, element, index) => {
2390
- const path = PlaitBoard.findPath(board, element);
2391
- const texts = element.texts?.length ? [...element.texts] : [];
2392
- const newTexts = [...texts];
2393
- newTexts.splice(index, 1);
2394
- Transforms.setNode(board, { texts: newTexts }, path);
2395
- };
2396
- const setLineMark = (board, handleKey, marker) => {
2397
- memorizeLatest(MemorizeKey.line, handleKey, marker);
2398
- const selectedElements = getSelectedLineElements(board);
2399
- selectedElements.forEach((element) => {
2400
- const path = PlaitBoard.findPath(board, element);
2401
- let handle = handleKey === LineHandleKey.source ? element.source : element.target;
2402
- handle = { ...handle, marker };
2403
- Transforms.setNode(board, { [handleKey]: handle }, path);
2404
- });
2405
- };
2406
- const setLineShape = (board, newProperties) => {
2407
- const elements = getSelectedLineElements(board);
2408
- elements.map(element => {
2409
- const _properties = { ...newProperties };
2410
- if (element.shape === newProperties.shape) {
2411
- return;
2412
- }
2413
- const path = PlaitBoard.findPath(board, element);
2414
- Transforms.setNode(board, _properties, path);
2415
- });
2416
- };
2417
- const collectLineUpdatedRefsByGeometry = (board, geometry, refs) => {
2418
- const lines = findElements(board, {
2419
- match: (element) => {
2420
- if (PlaitDrawElement.isLine(element)) {
2421
- return element.source.boundId === geometry.id || element.target.boundId === geometry.id;
2422
- }
2423
- return false;
2424
- },
2425
- recursion: element => true
2426
- });
2427
- if (lines.length) {
2428
- lines.forEach(line => {
2429
- const isSourceBound = line.source.boundId === geometry.id;
2430
- const handle = isSourceBound ? 'source' : 'target';
2431
- const object = { ...line[handle] };
2432
- const linePoints = getLinePoints(board, line);
2433
- const point = isSourceBound ? linePoints[0] : linePoints[linePoints.length - 1];
2434
- object.connection = getHitConnection(board, point, geometry);
2435
- const path = PlaitBoard.findPath(board, line);
2436
- const index = refs.findIndex(obj => Path.equals(obj.path, path));
2437
- if (index === -1) {
2438
- refs.push({
2439
- property: {
2440
- [handle]: object
2441
- },
2442
- path
2443
- });
2444
- }
2445
- else {
2446
- refs[index].property = { ...refs[index].property, [handle]: object };
2447
- }
2448
- });
2449
- }
2450
- };
2451
- const connectLineToGeometry = (board, lineElement, handle, geometryElement) => {
2452
- const linePoints = PlaitLine.getPoints(board, lineElement);
2453
- const point = handle === LineHandleKey.source ? linePoints[0] : linePoints[linePoints.length - 1];
2454
- const connection = getHitConnection(board, point, geometryElement);
2455
- if (connection) {
2456
- let source = lineElement.source;
2457
- let target = lineElement.target;
2458
- if (handle === LineHandleKey.source) {
2459
- source = {
2460
- ...source,
2461
- boundId: geometryElement.id,
2462
- connection
2463
- };
2464
- }
2465
- else {
2466
- target = {
2467
- ...target,
2468
- boundId: geometryElement.id,
2469
- connection
2470
- };
2471
- }
2472
- const path = PlaitBoard.findPath(board, lineElement);
2473
- resizeLine(board, { source, target }, path);
2474
- }
2475
- };
2476
-
2477
2471
  const insertGeometry = (board, points, shape) => {
2478
2472
  const newElement = createDefaultGeometry(board, points, shape);
2479
2473
  insertElement(board, newElement);
2480
2474
  return newElement;
2481
2475
  };
2482
- const insertGeometryByVector = (board, point, shape, vector) => {
2483
- const shapeProperty = DefaultFlowchartPropertyMap[shape] ||
2484
- DefaultBasicShapePropertyMap[shape] ||
2485
- DefaultUMLPropertyMap[shape] ||
2486
- DefaultBasicShapeProperty;
2487
- const direction = getDirectionByVector(vector);
2488
- if (direction) {
2489
- let offset = 0;
2490
- if ([Direction.left, Direction.right].includes(direction)) {
2491
- offset = -shapeProperty.width / 2;
2492
- }
2493
- else {
2494
- offset = -shapeProperty.height / 2;
2495
- }
2496
- const vectorPoint = getPointByVectorComponent(point, vector, offset);
2497
- const points = RectangleClient.getPoints(RectangleClient.getRectangleByCenterPoint(vectorPoint, shapeProperty.width, shapeProperty.height));
2498
- return insertGeometry(board, points, shape);
2499
- }
2500
- return null;
2501
- };
2502
2476
  const insertText = (board, point, text) => {
2503
2477
  const memorizedLatest = getMemorizedLatestByPointer(BasicShapes.text);
2504
2478
  const property = getTextShapeProperty(board, text, memorizedLatest.textProperties['font-size']);
@@ -2523,12 +2497,12 @@ const switchGeometryShape = (board, shape) => {
2523
2497
  if (PlaitDrawElement.isGeometry(item) && !PlaitDrawElement.isText(item)) {
2524
2498
  const path = PlaitBoard.findPath(board, item);
2525
2499
  Transforms.setNode(board, { shape }, path);
2526
- collectLineUpdatedRefsByGeometry(board, { ...item, shape }, refs);
2500
+ collectArrowLineUpdatedRefsByGeometry(board, { ...item, shape }, refs);
2527
2501
  }
2528
2502
  });
2529
2503
  if (refs.length) {
2530
2504
  refs.forEach(ref => {
2531
- DrawTransforms.resizeLine(board, ref.property, ref.path);
2505
+ DrawTransforms.resizeArrowLine(board, ref.property, ref.path);
2532
2506
  });
2533
2507
  }
2534
2508
  };
@@ -2608,6 +2582,67 @@ const insertImage = (board, imageItem, startPoint) => {
2608
2582
  Transforms.addSelectionWithTemporaryElements(board, [imageElement]);
2609
2583
  };
2610
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
+
2611
2646
  function buildSwimlaneTable(element) {
2612
2647
  const swimlaneElement = { ...element };
2613
2648
  if (PlaitDrawElement.isHorizontalSwimlane(element)) {
@@ -2649,8 +2684,10 @@ const getDefaultSwimlanePoints = (pointer, centerPoint) => {
2649
2684
  const createDefaultSwimlane = (shape, points) => {
2650
2685
  const header = isSwimlaneWithHeader(shape);
2651
2686
  const dataShape = adjustSwimlaneShape(shape);
2652
- const rows = createDefaultRowsOrColumns(dataShape, 'row', header);
2653
- 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);
2654
2691
  const swimlane = {
2655
2692
  id: idCreator(),
2656
2693
  type: 'swimlane',
@@ -2663,18 +2700,22 @@ const createDefaultSwimlane = (shape, points) => {
2663
2700
  };
2664
2701
  return swimlane;
2665
2702
  };
2666
- const createDefaultRowsOrColumns = (shape, type, header) => {
2703
+ const createDefaultRowsOrColumns = (shape, type, header, size) => {
2667
2704
  const createItems = (count) => new Array(count).fill('').map(() => ({ id: idCreator() }));
2668
2705
  let data = createItems(3);
2669
2706
  if ((type === 'row' && shape === SwimlaneSymbols.swimlaneVertical) ||
2670
2707
  (type === 'column' && shape === SwimlaneSymbols.swimlaneHorizontal)) {
2671
2708
  data = header ? data : createItems(2);
2672
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
+ }
2673
2714
  data = data.map((item, index) => {
2674
2715
  if (index === 0 || (index === 1 && header)) {
2675
2716
  return {
2676
2717
  ...item,
2677
- [dimension]: SWIMLANE_HEADER_SIZE
2718
+ [dimension]: defaultSize
2678
2719
  };
2679
2720
  }
2680
2721
  return item;
@@ -2718,6 +2759,9 @@ const adjustSwimlaneShape = (shape) => {
2718
2759
  ? SwimlaneSymbols.swimlaneHorizontal
2719
2760
  : SwimlaneSymbols.swimlaneVertical;
2720
2761
  };
2762
+ const isSwimlanePointers = (board) => {
2763
+ return PlaitBoard.isInPointer(board, getSwimlanePointers());
2764
+ };
2721
2765
 
2722
2766
  const updateSwimlaneCount = (board, swimlane, count) => {
2723
2767
  if (count > 0 && PlaitDrawElement.isSwimlane(swimlane)) {
@@ -2877,33 +2921,6 @@ const updateSwimlane = (board, swimlane, newColumns, newRows, newCells, newPoint
2877
2921
  points: newPoints
2878
2922
  }, path);
2879
2923
  };
2880
- const setSwimlaneFill = (board, element, fill, path) => {
2881
- const selectedCells = getSelectedCells(element);
2882
- let newCells = element.cells;
2883
- if (selectedCells?.length) {
2884
- newCells = element.cells.map(cell => {
2885
- if (selectedCells.map(item => item.id).includes(cell.id)) {
2886
- return {
2887
- ...cell,
2888
- fill
2889
- };
2890
- }
2891
- return cell;
2892
- });
2893
- }
2894
- else {
2895
- newCells = element.cells.map(cell => {
2896
- if (cell.text && cell.textHeight) {
2897
- return {
2898
- ...cell,
2899
- fill
2900
- };
2901
- }
2902
- return cell;
2903
- });
2904
- }
2905
- Transforms.setNode(board, { cells: newCells }, path);
2906
- };
2907
2924
 
2908
2925
  const setDrawShapeText = (board, element, text) => {
2909
2926
  const newTexts = element.texts?.map(item => {
@@ -2919,7 +2936,8 @@ const setDrawShapeText = (board, element, text) => {
2919
2936
  Transforms.setNode(board, newElement, [path]);
2920
2937
  };
2921
2938
 
2922
- const setTableText = (board, table, cellId, text, textWidth, textHeight) => {
2939
+ const setTableText = (board, path, cellId, text, textHeight) => {
2940
+ const table = PlaitNode.get(board, path);
2923
2941
  const cell = getCellWithPoints(board, table, cellId);
2924
2942
  const cellIndex = table.cells.findIndex(item => item.id === cell.id);
2925
2943
  let rows = [...table.rows];
@@ -2955,8 +2973,66 @@ const setTableText = (board, table, cellId, text, textWidth, textHeight) => {
2955
2973
  textHeight: textHeight,
2956
2974
  text
2957
2975
  };
2958
- const path = board.children.findIndex(child => child.id === table.id);
2959
- 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;
2960
3036
  };
2961
3037
 
2962
3038
  const DrawTransforms = {
@@ -2966,22 +3042,22 @@ const DrawTransforms = {
2966
3042
  resizeGeometry,
2967
3043
  insertText,
2968
3044
  setTextSize,
2969
- resizeLine,
2970
- setLineTexts,
2971
- removeLineText,
2972
- setLineMark,
2973
- setLineShape,
3045
+ resizeArrowLine,
3046
+ setArrowLineTexts,
3047
+ removeArrowLineText,
3048
+ setArrowLineMark,
3049
+ setArrowLineShape,
2974
3050
  insertImage,
3051
+ connectArrowLineToDraw,
2975
3052
  switchGeometryShape,
2976
- connectLineToGeometry,
2977
- insertGeometryByVector,
2978
3053
  setTableText,
2979
3054
  addSwimlaneRow,
2980
3055
  addSwimlaneColumn,
2981
3056
  removeSwimlaneRow,
2982
3057
  removeSwimlaneColumn,
2983
- setSwimlaneFill,
2984
- updateSwimlaneCount
3058
+ updateSwimlaneCount,
3059
+ setTableFill,
3060
+ insertDrawByVector
2985
3061
  };
2986
3062
 
2987
3063
  const getHitRectangleResizeHandleRef = (board, rectangle, point, angle = 0) => {
@@ -3116,10 +3192,16 @@ function withDrawResize(board) {
3116
3192
  }
3117
3193
  }
3118
3194
  if (PlaitDrawElement.isGeometry(target)) {
3119
- const { height: textHeight } = getFirstTextManage(target).getSize();
3120
- 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
+ }
3121
3203
  }
3122
- else if (PlaitDrawElement.isLine(target)) {
3204
+ else if (PlaitDrawElement.isArrowLine(target)) {
3123
3205
  Transforms.setNode(board, { points }, path);
3124
3206
  }
3125
3207
  else if (PlaitDrawElement.isImage(target)) {
@@ -3438,29 +3520,6 @@ function drawIsometricSnapLines(board, activePoints, snapRectangles, resizeSnapO
3438
3520
  return drawSolidLines(board, isometricLines);
3439
3521
  }
3440
3522
 
3441
- const isSingleSelectTable = (board) => {
3442
- const selectedElements = getSelectedElements(board);
3443
- return selectedElements && selectedElements.length === 1 && PlaitTableElement.isTable(selectedElements[0]);
3444
- };
3445
- const isSingleSelectElementByTable = (board) => {
3446
- const selectedElements = getSelectedElements(board);
3447
- return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
3448
- };
3449
- const getSelectedTableElements = (board, elements) => {
3450
- const selectedElements = elements?.length ? elements : getSelectedElements(board);
3451
- return selectedElements.filter(value => PlaitTableElement.isTable(value));
3452
- };
3453
- const SELECTED_CELLS = new WeakMap();
3454
- function getSelectedCells(element) {
3455
- return SELECTED_CELLS.get(element);
3456
- }
3457
- function setSelectedCells(element, cells) {
3458
- return SELECTED_CELLS.set(element, cells);
3459
- }
3460
- function clearSelectedCells(element) {
3461
- return SELECTED_CELLS.delete(element);
3462
- }
3463
-
3464
3523
  const getCenterPointsOnPolygon = (points) => {
3465
3524
  const centerPoints = [];
3466
3525
  for (let i = 0; i < points.length; i++) {
@@ -3644,7 +3703,9 @@ function createEllipseEngine(createOptions) {
3644
3703
  draw(board, rectangle, options) {
3645
3704
  const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
3646
3705
  const rs = PlaitBoard.getRoughSVG(board);
3647
- 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;
3648
3709
  },
3649
3710
  isInsidePoint(rectangle, point) {
3650
3711
  const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
@@ -3987,7 +4048,9 @@ const RoundCommentEngine = {
3987
4048
  const point9 = [x1 + rectangle.width / 4, y2];
3988
4049
  const point10 = [x1 + rectangle.width / 4, rectangle.y + rectangle.height];
3989
4050
  const point11 = [x1 + rectangle.width / 2, y2];
3990
- 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;
3991
4054
  },
3992
4055
  isInsidePoint(rectangle, point) {
3993
4056
  const points = [
@@ -4571,13 +4634,15 @@ const OrEngine = createEllipseEngine({
4571
4634
  const rx = rectangle.width / 2;
4572
4635
  const ry = rectangle.height / 2;
4573
4636
  const startPoint = [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2];
4574
- return rs.path(`M${startPoint[0]} ${startPoint[1]}
4637
+ const shape = rs.path(`M${startPoint[0]} ${startPoint[1]}
4575
4638
  A${rx},${ry} 0 1,1 ${startPoint[0]} ${startPoint[1] - 0.01}
4576
4639
  M${rectangle.x} ${rectangle.y + rectangle.height / 2}
4577
4640
  L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height / 2}
4578
4641
  M${rectangle.x + rectangle.width / 2} ${rectangle.y}
4579
4642
  L${rectangle.x + rectangle.width / 2} ${rectangle.y + rectangle.height}
4580
4643
  `, { ...options, fillStyle: 'solid' });
4644
+ setStrokeLinecap(shape, 'round');
4645
+ return shape;
4581
4646
  }
4582
4647
  });
4583
4648
 
@@ -4590,13 +4655,15 @@ const SummingJunctionEngine = createEllipseEngine({
4590
4655
  const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
4591
4656
  const line1Points = getCrossingPointsBetweenEllipseAndSegment([rectangle.x, rectangle.y], [rectangle.x + rectangle.width, rectangle.y + rectangle.height], centerPoint[0], centerPoint[1], rx, ry);
4592
4657
  const line2Points = getCrossingPointsBetweenEllipseAndSegment([rectangle.x + rectangle.width, rectangle.y], [rectangle.x, rectangle.y + rectangle.height], centerPoint[0], centerPoint[1], rx, ry);
4593
- return rs.path(`M${startPoint[0]} ${startPoint[1]}
4658
+ const shape = rs.path(`M${startPoint[0]} ${startPoint[1]}
4594
4659
  A${rx},${ry} 0 1,1 ${startPoint[0]} ${startPoint[1] - 0.01}
4595
4660
  M${line1Points[0][0]} ${line1Points[0][1]}
4596
4661
  L${line1Points[1][0]} ${line1Points[1][1]}
4597
4662
  M${line2Points[0][0]} ${line2Points[0][1]}
4598
4663
  L${line2Points[1][0]} ${line2Points[1][1]}
4599
4664
  `, { ...options, fillStyle: 'solid' });
4665
+ setStrokeLinecap(shape, 'round');
4666
+ return shape;
4600
4667
  }
4601
4668
  });
4602
4669
 
@@ -5023,7 +5090,7 @@ const NoteCurlyLeftEngine = {
5023
5090
  ${rectangle.x + rectangle.width - rectangle.width * 0.09} ${rectangle.y + rectangle.height / 2}
5024
5091
  C${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height / 2},
5025
5092
  ${rectangle.x + rectangle.width - rectangle.width * 0.09} ${rectangle.y + rectangle.height},
5026
- ${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' });
5027
5094
  setStrokeLinecap(shape, 'round');
5028
5095
  return shape;
5029
5096
  },
@@ -5062,13 +5129,13 @@ const NoteCurlyLeftEngine = {
5062
5129
  const NoteCurlyRightEngine = {
5063
5130
  draw(board, rectangle, options) {
5064
5131
  const rs = PlaitBoard.getRoughSVG(board);
5065
- const shape = rs.path(`M${rectangle.x} ${rectangle.y}
5066
- C${rectangle.x + rectangle.width * 0.09} ${rectangle.y},
5067
- ${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},
5068
5135
  ${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height / 2}
5069
- C${rectangle.x} ${rectangle.y + rectangle.height / 2},
5070
- ${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height},
5071
- ${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' });
5072
5139
  setStrokeLinecap(shape, 'round');
5073
5140
  return shape;
5074
5141
  },
@@ -5109,7 +5176,7 @@ const NoteSquareEngine = {
5109
5176
  const rs = PlaitBoard.getRoughSVG(board);
5110
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 +
5111
5178
  rectangle.width * 0.075}
5112
- `, { ...options, fillStyle: 'solid' });
5179
+ `, { ...options, fillStyle: 'solid', fill: 'transparent' });
5113
5180
  setStrokeLinecap(shape, 'round');
5114
5181
  return shape;
5115
5182
  },
@@ -5219,27 +5286,34 @@ const DisplayEngine = {
5219
5286
 
5220
5287
  const TableEngine = {
5221
5288
  draw(board, rectangle, roughOptions, options) {
5222
- const rs = PlaitBoard.getRoughSVG(board);
5223
5289
  const g = createG();
5224
- const { x, y, width, height } = rectangle;
5225
- const tableTopBorder = drawLine$1(rs, [x, y], [x + width, y], roughOptions);
5226
- const tableLeftBorder = drawLine$1(rs, [x, y], [x, y + height], roughOptions);
5227
- g.append(tableTopBorder, tableLeftBorder);
5228
- const pointCells = getCellsWithPoints(board, { ...options?.element });
5229
- pointCells.forEach(cell => {
5230
- const rectangle = RectangleClient.getRectangleByPoints(cell.points);
5231
- const { x, y, width, height } = rectangle;
5232
- const cellRectangle = drawRectangle(board, {
5233
- x: x + ACTIVE_STROKE_WIDTH,
5234
- y: y + ACTIVE_STROKE_WIDTH,
5235
- width: width - ACTIVE_STROKE_WIDTH * 2,
5236
- height: height - ACTIVE_STROKE_WIDTH * 2
5237
- }, { fill: cell.fill, fillStyle: 'solid', strokeWidth: 0 });
5238
- const cellRightBorder = drawLine$1(rs, [x + width, y], [x + width, y + height], roughOptions);
5239
- const cellBottomBorder = drawLine$1(rs, [x, y + height], [x + width, y + height], roughOptions);
5240
- g.append(cellRectangle, cellRightBorder, cellBottomBorder);
5241
- });
5242
- 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
+ }
5243
5317
  return g;
5244
5318
  },
5245
5319
  isInsidePoint(rectangle, point) {
@@ -5256,13 +5330,28 @@ const TableEngine = {
5256
5330
  return RectangleClient.getEdgeCenterPoints(rectangle);
5257
5331
  },
5258
5332
  getTextRectangle(element, options) {
5259
- const cell = getCellWithPoints(options?.board, element, options.key);
5260
- if (PlaitTableElement.isVerticalText(cell)) {
5261
- 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
+ }
5262
5345
  }
5263
- else {
5264
- return getHorizontalTextRectangle(cell);
5346
+ catch (error) {
5347
+ console.error(error);
5265
5348
  }
5349
+ return {
5350
+ x: 0,
5351
+ y: 0,
5352
+ width: 0,
5353
+ height: 0
5354
+ };
5266
5355
  }
5267
5356
  };
5268
5357
  function getVerticalTextRectangle(cell) {
@@ -5563,6 +5652,7 @@ const DeletionEngine = {
5563
5652
  const shape = rs.path(`M${rectangle.x} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}
5564
5653
  M${rectangle.x + rectangle.width} ${rectangle.y} L${rectangle.x} ${rectangle.y + rectangle.height}
5565
5654
  `, { ...options, fillStyle: 'solid', strokeWidth: 4 });
5655
+ setStrokeLinecap(shape, 'round');
5566
5656
  return shape;
5567
5657
  },
5568
5658
  isInsidePoint(rectangle, point) {
@@ -5742,7 +5832,8 @@ const RequiredInterfaceEngine = {
5742
5832
  M${rectangle.x + rectangle.width * 0.41} ${rectangle.y + rectangle.height / 2} H${rectangle.x + rectangle.width}
5743
5833
  `, {
5744
5834
  ...options,
5745
- fillStyle: 'solid'
5835
+ fillStyle: 'solid',
5836
+ fill: 'transparent'
5746
5837
  });
5747
5838
  setStrokeLinecap(shape, 'round');
5748
5839
  return shape;
@@ -6050,7 +6141,7 @@ const getEngine = (shape) => {
6050
6141
  return ShapeEngineMap[shape];
6051
6142
  };
6052
6143
 
6053
- const getLineHandleRefPair = (board, element) => {
6144
+ const getArrowLineHandleRefPair = (board, element) => {
6054
6145
  const strokeWidth = getStrokeWidthByElement(element);
6055
6146
  const sourceBoundElement = element.source.boundId ? getElementById(board, element.source.boundId) : undefined;
6056
6147
  const targetBoundElement = element.target.boundId ? getElementById(board, element.target.boundId) : undefined;
@@ -6063,19 +6154,21 @@ const getLineHandleRefPair = (board, element) => {
6063
6154
  const sourceFactor = getDirectionFactor(sourceDirection);
6064
6155
  const targetFactor = getDirectionFactor(targetDirection);
6065
6156
  const sourceHandleRef = {
6066
- key: LineHandleKey.source,
6157
+ key: ArrowLineHandleKey.source,
6067
6158
  point: sourcePoint,
6068
6159
  direction: sourceDirection,
6069
6160
  vector: [sourceFactor.x, sourceFactor.y]
6070
6161
  };
6071
6162
  const targetHandleRef = {
6072
- key: LineHandleKey.target,
6163
+ key: ArrowLineHandleKey.target,
6073
6164
  point: targetPoint,
6074
6165
  direction: targetDirection,
6075
6166
  vector: [targetFactor.x, targetFactor.y]
6076
6167
  };
6077
6168
  if (sourceBoundElement) {
6078
- 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;
6079
6172
  const sourceVector = getVectorByConnection(sourceBoundElement, element.source.connection);
6080
6173
  sourceHandleRef.vector = sourceVector;
6081
6174
  sourceHandleRef.boundElement = sourceBoundElement;
@@ -6092,7 +6185,9 @@ const getLineHandleRefPair = (board, element) => {
6092
6185
  sourceHandleRef.point = rotatePointsByElement(sourcePoint, sourceBoundElement) || sourcePoint;
6093
6186
  }
6094
6187
  if (targetBoundElement) {
6095
- 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;
6096
6191
  const targetVector = getVectorByConnection(targetBoundElement, element.target.connection);
6097
6192
  targetHandleRef.vector = targetVector;
6098
6193
  targetHandleRef.boundElement = targetBoundElement;
@@ -6147,7 +6242,7 @@ const getVectorByConnection = (boundElement, connection) => {
6147
6242
  return vector;
6148
6243
  };
6149
6244
  const getElbowLineRouteOptions = (board, element, handleRefPair) => {
6150
- handleRefPair = handleRefPair ?? getLineHandleRefPair(board, element);
6245
+ handleRefPair = handleRefPair ?? getArrowLineHandleRefPair(board, element);
6151
6246
  const { sourceRectangle, targetRectangle } = getSourceAndTargetRectangle(board, element, handleRefPair);
6152
6247
  const { sourceOuterRectangle, targetOuterRectangle } = getSourceAndTargetOuterRectangle(sourceRectangle, targetRectangle);
6153
6248
  const sourcePoint = handleRefPair.source.point;
@@ -6165,33 +6260,67 @@ const getElbowLineRouteOptions = (board, element, handleRefPair) => {
6165
6260
  targetOuterRectangle
6166
6261
  };
6167
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
+ };
6168
6297
 
6169
- var LineMarkerType;
6170
- (function (LineMarkerType) {
6171
- LineMarkerType["arrow"] = "arrow";
6172
- LineMarkerType["none"] = "none";
6173
- LineMarkerType["openTriangle"] = "open-triangle";
6174
- LineMarkerType["solidTriangle"] = "solid-triangle";
6175
- LineMarkerType["sharpArrow"] = "sharp-arrow";
6176
- LineMarkerType["oneSideUp"] = "one-side-up";
6177
- LineMarkerType["oneSideDown"] = "one-side-down";
6178
- LineMarkerType["hollowTriangle"] = "hollow-triangle";
6179
- LineMarkerType["singleSlash"] = "single-slash";
6180
- })(LineMarkerType || (LineMarkerType = {}));
6181
- var LineShape;
6182
- (function (LineShape) {
6183
- LineShape["straight"] = "straight";
6184
- LineShape["curve"] = "curve";
6185
- LineShape["elbow"] = "elbow";
6186
- })(LineShape || (LineShape = {}));
6187
- var LineHandleKey;
6188
- (function (LineHandleKey) {
6189
- LineHandleKey["source"] = "source";
6190
- LineHandleKey["target"] = "target";
6191
- })(LineHandleKey || (LineHandleKey = {}));
6192
- 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 = {
6193
6322
  isSourceMarkOrTargetMark(line, markType, handleKey) {
6194
- if (handleKey === LineHandleKey.source) {
6323
+ if (handleKey === ArrowLineHandleKey.source) {
6195
6324
  return line.source.marker === markType;
6196
6325
  }
6197
6326
  else {
@@ -6199,10 +6328,10 @@ const PlaitLine = {
6199
6328
  }
6200
6329
  },
6201
6330
  isSourceMark(line, markType) {
6202
- return PlaitLine.isSourceMarkOrTargetMark(line, markType, LineHandleKey.source);
6331
+ return PlaitArrowLine.isSourceMarkOrTargetMark(line, markType, ArrowLineHandleKey.source);
6203
6332
  },
6204
6333
  isTargetMark(line, markType) {
6205
- return PlaitLine.isSourceMarkOrTargetMark(line, markType, LineHandleKey.target);
6334
+ return PlaitArrowLine.isSourceMarkOrTargetMark(line, markType, ArrowLineHandleKey.target);
6206
6335
  },
6207
6336
  isBoundElementOfSource(line, element) {
6208
6337
  return line.source.boundId === element.id;
@@ -6245,16 +6374,25 @@ var MemorizeKey;
6245
6374
  MemorizeKey["basicShape"] = "basicShape";
6246
6375
  MemorizeKey["flowchart"] = "flowchart";
6247
6376
  MemorizeKey["text"] = "text";
6248
- MemorizeKey["line"] = "line";
6377
+ MemorizeKey["arrowLine"] = "arrow-line";
6249
6378
  MemorizeKey["UML"] = "UML";
6250
6379
  })(MemorizeKey || (MemorizeKey = {}));
6251
6380
 
6381
+ var VectorLineShape;
6382
+ (function (VectorLineShape) {
6383
+ VectorLineShape["straight"] = "straight";
6384
+ VectorLineShape["curve"] = "curve";
6385
+ })(VectorLineShape || (VectorLineShape = {}));
6386
+
6252
6387
  const PlaitDrawElement = {
6253
6388
  isGeometry: (value) => {
6254
6389
  return value.type === 'geometry';
6255
6390
  },
6256
- isLine: (value) => {
6257
- 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';
6258
6396
  },
6259
6397
  isText: (value) => {
6260
6398
  return value.type === 'geometry' && value.shape === BasicShapes.text;
@@ -6267,7 +6405,7 @@ const PlaitDrawElement = {
6267
6405
  },
6268
6406
  isDrawElement: (value) => {
6269
6407
  if (PlaitDrawElement.isGeometry(value) ||
6270
- PlaitDrawElement.isLine(value) ||
6408
+ PlaitDrawElement.isArrowLine(value) ||
6271
6409
  PlaitDrawElement.isImage(value) ||
6272
6410
  PlaitDrawElement.isTable(value) ||
6273
6411
  PlaitDrawElement.isSwimlane(value)) {
@@ -6278,7 +6416,10 @@ const PlaitDrawElement = {
6278
6416
  }
6279
6417
  },
6280
6418
  isShapeElement: (value) => {
6281
- 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));
6282
6423
  },
6283
6424
  isBasicShape: (value) => {
6284
6425
  return Object.keys(BasicShapes).includes(value.shape);
@@ -6306,7 +6447,7 @@ const PlaitDrawElement = {
6306
6447
  },
6307
6448
  isElementByTable: (value) => {
6308
6449
  return PlaitDrawElement.isTable(value) || PlaitDrawElement.isSwimlane(value) || PlaitDrawElement.isGeometryByTable(value);
6309
- },
6450
+ }
6310
6451
  };
6311
6452
 
6312
6453
  class GeometryShapeGenerator extends Generator {
@@ -6332,7 +6473,7 @@ class GeometryShapeGenerator extends Generator {
6332
6473
  }
6333
6474
  }
6334
6475
 
6335
- class LineAutoCompleteGenerator extends Generator {
6476
+ class ArrowLineAutoCompleteGenerator extends Generator {
6336
6477
  static { this.key = 'line-auto-complete-generator'; }
6337
6478
  constructor(board) {
6338
6479
  super(board);
@@ -6419,12 +6560,12 @@ class GeometryComponent extends CommonElementFlavour {
6419
6560
  return canResize(this.board, this.element);
6420
6561
  }
6421
6562
  });
6422
- this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
6563
+ this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
6423
6564
  this.shapeGenerator = new GeometryShapeGenerator(this.board);
6424
6565
  if (isGeometryIncludeText(this.element)) {
6425
6566
  this.initializeTextManage();
6426
6567
  }
6427
- this.getRef().addGenerator(LineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
6568
+ this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
6428
6569
  this.getRef().addGenerator(ActiveGenerator.key, this.activeGenerator);
6429
6570
  }
6430
6571
  initialize() {
@@ -6515,7 +6656,7 @@ class GeometryComponent extends CommonElementFlavour {
6515
6656
  }
6516
6657
  }
6517
6658
 
6518
- class LineActiveGenerator extends Generator {
6659
+ class ArrowLineActiveGenerator extends Generator {
6519
6660
  constructor() {
6520
6661
  super(...arguments);
6521
6662
  this.onlySelectedCurrentLine = false;
@@ -6535,10 +6676,10 @@ class LineActiveGenerator extends Generator {
6535
6676
  if (this.onlySelectedCurrentLine) {
6536
6677
  activeG.classList.add('active');
6537
6678
  activeG.classList.add('line-handle');
6538
- const points = PlaitLine.getPoints(this.board, element);
6679
+ const points = PlaitArrowLine.getPoints(this.board, element);
6539
6680
  let updatePoints = [...points];
6540
6681
  let elbowNextRenderPoints = [];
6541
- if (element.shape === LineShape.elbow) {
6682
+ if (element.shape === ArrowLineShape.elbow) {
6542
6683
  updatePoints = points.slice(0, 1).concat(points.slice(-1));
6543
6684
  elbowNextRenderPoints = getNextRenderPoints(this.board, element, data.linePoints);
6544
6685
  }
@@ -6550,7 +6691,7 @@ class LineActiveGenerator extends Generator {
6550
6691
  if (!PlaitBoard.hasBeenTextEditing(this.board)) {
6551
6692
  for (let i = 0; i < middlePoints.length; i++) {
6552
6693
  const point = middlePoints[i];
6553
- if (element.shape === LineShape.elbow && elbowNextRenderPoints.length) {
6694
+ if (element.shape === ArrowLineShape.elbow && elbowNextRenderPoints.length) {
6554
6695
  const handleIndex = getHitPointIndex(middlePoints, point);
6555
6696
  const isUpdateHandleIndex = isUpdatedHandleIndex(this.board, element, [...points], elbowNextRenderPoints, handleIndex);
6556
6697
  if (isUpdateHandleIndex) {
@@ -6590,20 +6731,20 @@ class LineActiveGenerator extends Generator {
6590
6731
 
6591
6732
  const debugKey = 'debug:plait:line-turning';
6592
6733
  const debugGenerator = createDebugGenerator(debugKey);
6593
- class LineComponent extends CommonElementFlavour {
6734
+ class ArrowLineComponent extends CommonElementFlavour {
6594
6735
  constructor() {
6595
6736
  super();
6596
6737
  this.boundedElements = {};
6597
6738
  }
6598
6739
  initializeGenerator() {
6599
- this.shapeGenerator = new LineShapeGenerator(this.board);
6600
- this.activeGenerator = new LineActiveGenerator(this.board);
6740
+ this.shapeGenerator = new ArrowLineShapeGenerator(this.board);
6741
+ this.activeGenerator = new ArrowLineActiveGenerator(this.board);
6601
6742
  this.initializeTextManagesByElement();
6602
6743
  }
6603
6744
  initialize() {
6604
6745
  this.initializeGenerator();
6605
6746
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
6606
- const linePoints = getLinePoints(this.board, this.element);
6747
+ const linePoints = getArrowLinePoints(this.board, this.element);
6607
6748
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
6608
6749
  selected: this.selected,
6609
6750
  linePoints
@@ -6635,7 +6776,7 @@ class LineComponent extends CommonElementFlavour {
6635
6776
  const isBoundedElementsChanged = boundedElements.source !== this.boundedElements.source || boundedElements.target !== this.boundedElements.target;
6636
6777
  this.boundedElements = boundedElements;
6637
6778
  const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
6638
- const linePoints = getLinePoints(this.board, this.element);
6779
+ const linePoints = getArrowLinePoints(this.board, this.element);
6639
6780
  if (value.element !== previous.element || isChangeTheme) {
6640
6781
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
6641
6782
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
@@ -6685,10 +6826,12 @@ class LineComponent extends CommonElementFlavour {
6685
6826
  createTextManage(text, index) {
6686
6827
  return new TextManage(this.board, {
6687
6828
  getRectangle: () => {
6688
- return getLineTextRectangle(this.board, this.element, index);
6829
+ return getArrowLineTextRectangle(this.board, this.element, index);
6689
6830
  },
6690
6831
  onChange: (textManageChangeData) => {
6691
- 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];
6692
6835
  const newWidth = textManageChangeData.width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : textManageChangeData.width;
6693
6836
  texts.splice(index, 1, {
6694
6837
  text: textManageChangeData.newText ? textManageChangeData.newText : this.element.texts[index].text,
@@ -6696,7 +6839,7 @@ class LineComponent extends CommonElementFlavour {
6696
6839
  width: newWidth,
6697
6840
  height: textManageChangeData.height
6698
6841
  });
6699
- DrawTransforms.setLineTexts(this.board, this.element, texts);
6842
+ DrawTransforms.setArrowLineTexts(this.board, this.element, texts);
6700
6843
  textManageChangeData.operations && memorizeLatestText(this.element, textManageChangeData.operations);
6701
6844
  },
6702
6845
  getMaxWidth: () => GeometryThreshold.defaultTextMaxWidth,
@@ -6976,7 +7119,7 @@ const buildClipboardData = (board, elements, startPoint) => {
6976
7119
  const points = element.points.map(point => [point[0] - startPoint[0], point[1] - startPoint[1]]);
6977
7120
  return { ...element, points };
6978
7121
  }
6979
- if (PlaitDrawElement.isLine(element)) {
7122
+ if (PlaitDrawElement.isArrowLine(element)) {
6980
7123
  let source = { ...element.source };
6981
7124
  let target = { ...element.target };
6982
7125
  let points = [...element.points];
@@ -7001,12 +7144,12 @@ const buildClipboardData = (board, elements, startPoint) => {
7001
7144
  });
7002
7145
  };
7003
7146
  const insertClipboardData = (board, elements, startPoint) => {
7004
- const lines = elements.filter(value => PlaitDrawElement.isLine(value));
7147
+ const lines = elements.filter(value => PlaitDrawElement.isArrowLine(value));
7005
7148
  const geometries = elements.filter(value => (PlaitDrawElement.isGeometry(value) && !PlaitDrawElement.isGeometryByTable(value)) || PlaitDrawElement.isImage(value));
7006
7149
  const tables = elements.filter(value => PlaitDrawElement.isElementByTable(value));
7007
7150
  geometries.forEach(element => {
7008
7151
  const newId = idCreator();
7009
- updateBoundLinesId(element, lines, newId);
7152
+ updateBoundArrowLinesId(element, lines, newId);
7010
7153
  element.id = newId;
7011
7154
  element.points = element.points.map(point => [startPoint[0] + point[0], startPoint[1] + point[1]]);
7012
7155
  Transforms.insertNode(board, element, [board.children.length]);
@@ -7022,7 +7165,7 @@ const insertClipboardData = (board, elements, startPoint) => {
7022
7165
  const insertClipboardTableData = (board, elements, startPoint, lines) => {
7023
7166
  elements.forEach(element => {
7024
7167
  const newId = idCreator();
7025
- updateBoundLinesId(element, lines, newId);
7168
+ updateBoundArrowLinesId(element, lines, newId);
7026
7169
  element.id = newId;
7027
7170
  updateRowOrColumnIds(element, 'row');
7028
7171
  updateRowOrColumnIds(element, 'column');
@@ -7031,14 +7174,14 @@ const insertClipboardTableData = (board, elements, startPoint, lines) => {
7031
7174
  Transforms.insertNode(board, element, [board.children.length]);
7032
7175
  });
7033
7176
  };
7034
- const updateBoundLinesId = (element, lines, newId) => {
7177
+ const updateBoundArrowLinesId = (element, lines, newId) => {
7035
7178
  const sourceLines = [];
7036
7179
  const targetLines = [];
7037
7180
  lines.forEach(line => {
7038
- if (PlaitLine.isBoundElementOfSource(line, element)) {
7181
+ if (PlaitArrowLine.isBoundElementOfSource(line, element)) {
7039
7182
  sourceLines.push(line);
7040
7183
  }
7041
- if (PlaitLine.isBoundElementOfTarget(line, element)) {
7184
+ if (PlaitArrowLine.isBoundElementOfTarget(line, element)) {
7042
7185
  targetLines.push(line);
7043
7186
  }
7044
7187
  });
@@ -7054,15 +7197,15 @@ const withDrawFragment = (baseBoard) => {
7054
7197
  const drawElements = getSelectedDrawElements(board);
7055
7198
  if (drawElements.length) {
7056
7199
  const geometryElements = drawElements.filter(value => PlaitDrawElement.isGeometry(value));
7057
- const lineElements = drawElements.filter(value => PlaitDrawElement.isLine(value));
7200
+ const lineElements = drawElements.filter(value => PlaitDrawElement.isArrowLine(value));
7058
7201
  const imageElements = drawElements.filter(value => PlaitDrawElement.isImage(value));
7059
7202
  const tableElements = drawElements.filter(value => PlaitDrawElement.isTable(value));
7060
7203
  const swimlaneElements = drawElements.filter(value => PlaitDrawElement.isSwimlane(value));
7061
7204
  const boundLineElements = [
7062
- ...getBoundedLineElements(board, geometryElements),
7063
- ...getBoundedLineElements(board, imageElements),
7064
- ...getBoundedLineElements(board, tableElements),
7065
- ...getBoundedLineElements(board, swimlaneElements)
7205
+ ...getBoundedArrowLineElements(board, geometryElements),
7206
+ ...getBoundedArrowLineElements(board, imageElements),
7207
+ ...getBoundedArrowLineElements(board, tableElements),
7208
+ ...getBoundedArrowLineElements(board, swimlaneElements)
7066
7209
  ].filter(line => !lineElements.includes(line));
7067
7210
  data.push(...[
7068
7211
  ...geometryElements,
@@ -7081,8 +7224,8 @@ const withDrawFragment = (baseBoard) => {
7081
7224
  if (targetDrawElements.length) {
7082
7225
  if (operationType === WritableClipboardOperationType.cut) {
7083
7226
  const geometryElements = targetDrawElements.filter(value => PlaitDrawElement.isGeometry(value));
7084
- const lineElements = targetDrawElements.filter(value => PlaitDrawElement.isLine(value));
7085
- 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));
7086
7229
  }
7087
7230
  const selectedElements = [...targetDrawElements, ...boundLineElements];
7088
7231
  const elements = buildClipboardData(board, selectedElements, rectangle ? [rectangle.x, rectangle.y] : [0, 0]);
@@ -7134,19 +7277,19 @@ const withDrawFragment = (baseBoard) => {
7134
7277
  };
7135
7278
  return board;
7136
7279
  };
7137
- const getBoundedLineElements = (board, plaitShapes) => {
7138
- const lines = getLines(board);
7139
- 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)));
7140
7283
  };
7141
7284
 
7142
- const withLineCreateByDraw = (board) => {
7285
+ const withArrowLineCreateByDraw = (board) => {
7143
7286
  const { pointerDown, pointerMove, globalPointerUp } = board;
7144
7287
  let start = null;
7145
7288
  let sourceElement;
7146
7289
  let lineShapeG = null;
7147
7290
  let temporaryElement = null;
7148
7291
  board.pointerDown = (event) => {
7149
- const linePointers = getLinePointers();
7292
+ const linePointers = getArrowLinePointers();
7150
7293
  const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
7151
7294
  if (!PlaitBoard.isReadonly(board) && isLinePointer && isDrawingMode(board)) {
7152
7295
  const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
@@ -7165,7 +7308,7 @@ const withLineCreateByDraw = (board) => {
7165
7308
  let movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
7166
7309
  if (start) {
7167
7310
  const lineShape = PlaitBoard.getPointer(board);
7168
- temporaryElement = handleLineCreating(board, lineShape, start, movingPoint, sourceElement, lineShapeG);
7311
+ temporaryElement = handleArrowLineCreating(board, lineShape, start, movingPoint, sourceElement, lineShapeG);
7169
7312
  }
7170
7313
  pointerMove(event);
7171
7314
  };
@@ -7248,7 +7391,7 @@ const withGeometryResize = (board) => {
7248
7391
  return board;
7249
7392
  };
7250
7393
 
7251
- const withLineResize = (board) => {
7394
+ const withArrowLineResize = (board) => {
7252
7395
  let elbowLineIndex;
7253
7396
  let elbowLineDeleteCount;
7254
7397
  let elbowSourcePoint;
@@ -7260,11 +7403,11 @@ const withLineResize = (board) => {
7260
7403
  return true;
7261
7404
  },
7262
7405
  hitTest: (point) => {
7263
- const selectedLineElements = getSelectedLineElements(board);
7406
+ const selectedLineElements = getSelectedArrowLineElements(board);
7264
7407
  if (selectedLineElements.length > 0) {
7265
7408
  let result = null;
7266
7409
  selectedLineElements.forEach(value => {
7267
- const handleRef = getHitLineResizeHandleRef(board, value, point);
7410
+ const handleRef = getHitArrowLineResizeHandleRef(board, value, point);
7268
7411
  if (handleRef) {
7269
7412
  result = {
7270
7413
  element: value,
@@ -7278,9 +7421,9 @@ const withLineResize = (board) => {
7278
7421
  return null;
7279
7422
  },
7280
7423
  beforeResize: (resizeRef) => {
7281
- if (resizeRef.element.shape === LineShape.elbow &&
7282
- resizeRef.handle !== LineResizeHandle.source &&
7283
- resizeRef.handle !== LineResizeHandle.target) {
7424
+ if (resizeRef.element.shape === ArrowLineShape.elbow &&
7425
+ resizeRef.handle !== ArrowLineResizeHandle.source &&
7426
+ resizeRef.handle !== ArrowLineResizeHandle.target) {
7284
7427
  const params = getElbowLineRouteOptions(board, resizeRef.element);
7285
7428
  if (isUseDefaultOrthogonalRoute(resizeRef.element, params)) {
7286
7429
  return;
@@ -7302,8 +7445,8 @@ const withLineResize = (board) => {
7302
7445
  let target = { ...resizeRef.element.target };
7303
7446
  let handleIndex = resizeRef.handleIndex;
7304
7447
  const hitElement = getSnappingShape(board, resizeState.endPoint);
7305
- if (resizeRef.handle === LineResizeHandle.source || resizeRef.handle === LineResizeHandle.target) {
7306
- 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;
7307
7450
  points[handleIndex] = resizeState.endPoint;
7308
7451
  if (hitElement) {
7309
7452
  object.connection = getHitConnection(board, resizeState.endPoint, hitElement);
@@ -7315,7 +7458,7 @@ const withLineResize = (board) => {
7315
7458
  }
7316
7459
  }
7317
7460
  else {
7318
- if (resizeRef.element.shape === LineShape.elbow) {
7461
+ if (resizeRef.element.shape === ArrowLineShape.elbow) {
7319
7462
  if (elbowNextRenderPoints && elbowSourcePoint && elbowTargetPoint) {
7320
7463
  const resizedPreviousAndNextPoint = getResizedPreviousAndNextPoint(elbowNextRenderPoints, elbowSourcePoint, elbowTargetPoint, handleIndex);
7321
7464
  const startKeyPoint = elbowNextRenderPoints[handleIndex];
@@ -7334,7 +7477,7 @@ const withLineResize = (board) => {
7334
7477
  }
7335
7478
  }
7336
7479
  else {
7337
- if (resizeRef.handle === LineResizeHandle.addHandle) {
7480
+ if (resizeRef.handle === ArrowLineResizeHandle.addHandle) {
7338
7481
  points.splice(handleIndex + 1, 0, resizeState.endPoint);
7339
7482
  }
7340
7483
  else {
@@ -7343,13 +7486,13 @@ const withLineResize = (board) => {
7343
7486
  }
7344
7487
  }
7345
7488
  if (!hitElement) {
7346
- handleIndex = resizeRef.handle === LineResizeHandle.addHandle ? handleIndex + 1 : handleIndex;
7347
- const drawPoints = getLinePoints(board, resizeRef.element);
7489
+ handleIndex = resizeRef.handle === ArrowLineResizeHandle.addHandle ? handleIndex + 1 : handleIndex;
7490
+ const drawPoints = getArrowLinePoints(board, resizeRef.element);
7348
7491
  const newPoints = [...points];
7349
7492
  newPoints[0] = drawPoints[0];
7350
7493
  newPoints[newPoints.length - 1] = drawPoints[drawPoints.length - 1];
7351
- if (resizeRef.element.shape !== LineShape.elbow ||
7352
- (resizeRef.element.shape === LineShape.elbow && newPoints.length === 2)) {
7494
+ if (resizeRef.element.shape !== ArrowLineShape.elbow ||
7495
+ (resizeRef.element.shape === ArrowLineShape.elbow && newPoints.length === 2)) {
7353
7496
  newPoints.forEach((point, index) => {
7354
7497
  if (index === handleIndex)
7355
7498
  return;
@@ -7359,10 +7502,10 @@ const withLineResize = (board) => {
7359
7502
  });
7360
7503
  }
7361
7504
  }
7362
- DrawTransforms.resizeLine(board, { points, source, target }, resizeRef.path);
7505
+ DrawTransforms.resizeArrowLine(board, { points, source, target }, resizeRef.path);
7363
7506
  },
7364
7507
  afterResize: (resizeRef) => {
7365
- if (resizeRef.element.shape === LineShape.elbow) {
7508
+ if (resizeRef.element.shape === ArrowLineShape.elbow) {
7366
7509
  const element = PlaitNode.get(board, resizeRef.path);
7367
7510
  let points = element && [...element.points];
7368
7511
  if (points.length > 2 && elbowNextRenderPoints && elbowSourcePoint && elbowTargetPoint) {
@@ -7381,7 +7524,7 @@ const withLineResize = (board) => {
7381
7524
  points = [];
7382
7525
  }
7383
7526
  points = [elbowSourcePoint, ...points, elbowTargetPoint];
7384
- DrawTransforms.resizeLine(board, { points }, resizeRef.path);
7527
+ DrawTransforms.resizeArrowLine(board, { points }, resizeRef.path);
7385
7528
  }
7386
7529
  }
7387
7530
  elbowLineIndex = null;
@@ -7395,7 +7538,7 @@ const withLineResize = (board) => {
7395
7538
  return board;
7396
7539
  };
7397
7540
 
7398
- const withLineBoundReaction = (board) => {
7541
+ const withArrowLineBoundReaction = (board) => {
7399
7542
  const { pointerMove, pointerUp } = board;
7400
7543
  let boundShapeG = null;
7401
7544
  board.pointerMove = (event) => {
@@ -7404,13 +7547,13 @@ const withLineBoundReaction = (board) => {
7404
7547
  pointerMove(event);
7405
7548
  return;
7406
7549
  }
7407
- const linePointers = Object.keys(LineShape);
7550
+ const linePointers = Object.keys(ArrowLineShape);
7408
7551
  const isLinePointer = PlaitBoard.isInPointer(board, linePointers);
7409
7552
  const movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
7410
7553
  const isLineResizing = isResizingByCondition(board, resizeRef => {
7411
7554
  const { element, handle } = resizeRef;
7412
- const isSourceOrTarget = handle === LineResizeHandle.target || handle === LineResizeHandle.source;
7413
- return PlaitDrawElement.isLine(element) && isSourceOrTarget;
7555
+ const isSourceOrTarget = handle === ArrowLineResizeHandle.target || handle === ArrowLineResizeHandle.source;
7556
+ return PlaitDrawElement.isArrowLine(element) && isSourceOrTarget;
7414
7557
  });
7415
7558
  if (isLinePointer || isLineResizing) {
7416
7559
  const hitElement = getHitShape(board, movingPoint);
@@ -7443,33 +7586,34 @@ const withLineBoundReaction = (board) => {
7443
7586
  return board;
7444
7587
  };
7445
7588
 
7446
- const withLineText = (board) => {
7589
+ const withArrowLineText = (board) => {
7447
7590
  const { dblClick } = board;
7448
7591
  board.dblClick = (event) => {
7449
7592
  if (!PlaitBoard.isReadonly(board)) {
7450
7593
  const clickPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
7451
7594
  const hitTarget = getHitElementByPoint(board, clickPoint, (element) => {
7452
- return PlaitDrawElement.isLine(element);
7595
+ return PlaitDrawElement.isArrowLine(element);
7453
7596
  });
7454
7597
  const hitTargetPath = hitTarget && PlaitBoard.findPath(board, hitTarget);
7455
7598
  if (hitTarget) {
7456
- const points = getLinePoints(board, hitTarget);
7599
+ const points = getArrowLinePoints(board, hitTarget);
7457
7600
  const point = getNearestPointBetweenPointAndSegments(clickPoint, points);
7458
7601
  const texts = hitTarget.texts?.length ? [...hitTarget.texts] : [];
7459
- const textIndex = getHitLineTextIndex(board, hitTarget, clickPoint);
7460
- const isHitText = isHitLineText(board, hitTarget, clickPoint);
7602
+ const textIndex = getHitArrowLineTextIndex(board, hitTarget, clickPoint);
7603
+ const isHitText = isHitArrowLineText(board, hitTarget, clickPoint);
7461
7604
  if (isHitText) {
7462
7605
  editHandle(board, hitTarget, textIndex);
7463
7606
  }
7464
7607
  else {
7465
7608
  const ratio = getRatioByPoint(points, point);
7609
+ const textMemory = getMemorizedLatest('line')?.text || {};
7466
7610
  texts.push({
7467
- text: buildText(LINE_TEXT),
7611
+ text: buildText(LINE_TEXT, undefined, textMemory),
7468
7612
  position: ratio,
7469
7613
  width: 28,
7470
7614
  height: 20
7471
7615
  });
7472
- DrawTransforms.setLineTexts(board, hitTarget, texts);
7616
+ DrawTransforms.setArrowLineTexts(board, hitTarget, texts);
7473
7617
  setTimeout(() => {
7474
7618
  if (hitTargetPath) {
7475
7619
  const newHitTarget = PlaitNode.get(board, hitTargetPath);
@@ -7491,7 +7635,7 @@ function editHandle(board, element, manageIndex, isFirstEdit = false) {
7491
7635
  const text = Node.string(textManage.getText());
7492
7636
  const shouldRemove = !text || (isFirstEdit && text === LINE_TEXT);
7493
7637
  if (shouldRemove) {
7494
- DrawTransforms.removeLineText(board, element, manageIndex);
7638
+ DrawTransforms.removeArrowLineText(board, element, manageIndex);
7495
7639
  }
7496
7640
  });
7497
7641
  }
@@ -7518,8 +7662,8 @@ class ImageComponent extends CommonElementFlavour {
7518
7662
  };
7519
7663
  }
7520
7664
  });
7521
- this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
7522
- this.getRef().addGenerator(LineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
7665
+ this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
7666
+ this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
7523
7667
  }
7524
7668
  initialize() {
7525
7669
  super.initialize();
@@ -7556,7 +7700,7 @@ class ImageComponent extends CommonElementFlavour {
7556
7700
  }
7557
7701
  }
7558
7702
 
7559
- const withLineAutoCompleteReaction = (board) => {
7703
+ const withArrowLineAutoCompleteReaction = (board) => {
7560
7704
  const { pointerMove } = board;
7561
7705
  let reactionG = null;
7562
7706
  board.pointerMove = (event) => {
@@ -7570,7 +7714,7 @@ const withLineAutoCompleteReaction = (board) => {
7570
7714
  const hitIndex = getHitIndexOfAutoCompletePoint(rotateAntiPointsByElement(movingPoint, targetElement) || movingPoint, points);
7571
7715
  const hitPoint = points[hitIndex];
7572
7716
  const ref = PlaitElement.getElementRef(targetElement);
7573
- const lineAutoCompleteGenerator = ref.getGenerator(LineAutoCompleteGenerator.key);
7717
+ const lineAutoCompleteGenerator = ref.getGenerator(ArrowLineAutoCompleteGenerator.key);
7574
7718
  lineAutoCompleteGenerator.recoverAutoCompleteG();
7575
7719
  if (hitPoint) {
7576
7720
  lineAutoCompleteGenerator?.removeAutoCompleteG(hitIndex);
@@ -7591,8 +7735,8 @@ const withLineAutoCompleteReaction = (board) => {
7591
7735
  return board;
7592
7736
  };
7593
7737
 
7594
- const WithLineAutoCompletePluginKey = 'plait-line-auto-complete-plugin-key';
7595
- const withLineAutoComplete = (board) => {
7738
+ const WithArrowLineAutoCompletePluginKey = 'plait-arrow-line-auto-complete-plugin-key';
7739
+ const withArrowLineAutoComplete = (board) => {
7596
7740
  const { pointerDown, pointerMove, globalPointerUp } = board;
7597
7741
  let autoCompletePoint = null;
7598
7742
  let lineShapeG = null;
@@ -7610,7 +7754,7 @@ const withLineAutoComplete = (board) => {
7610
7754
  temporaryDisableSelection(board);
7611
7755
  autoCompletePoint = hitPoint;
7612
7756
  sourceElement = targetElement;
7613
- BoardTransforms.updatePointerType(board, LineShape.elbow);
7757
+ BoardTransforms.updatePointerType(board, ArrowLineShape.elbow);
7614
7758
  }
7615
7759
  }
7616
7760
  pointerDown(event);
@@ -7632,7 +7776,7 @@ const withLineAutoComplete = (board) => {
7632
7776
  }
7633
7777
  // source point must be click point
7634
7778
  const rotatedSourcePoint = rotatePointsByElement(sourcePoint, sourceElement) || sourcePoint;
7635
- temporaryElement = handleLineCreating(board, LineShape.elbow, rotatedSourcePoint, movingPoint, sourceElement, lineShapeG);
7779
+ temporaryElement = handleArrowLineCreating(board, ArrowLineShape.elbow, rotatedSourcePoint, movingPoint, sourceElement, lineShapeG);
7636
7780
  }
7637
7781
  }
7638
7782
  pointerMove(event);
@@ -7642,8 +7786,7 @@ const withLineAutoComplete = (board) => {
7642
7786
  Transforms.insertNode(board, temporaryElement, [board.children.length]);
7643
7787
  clearSelectedElement(board);
7644
7788
  addSelectedElement(board, temporaryElement);
7645
- const afterComplete = board.getPluginOptions(WithLineAutoCompletePluginKey)
7646
- ?.afterComplete;
7789
+ const afterComplete = board.getPluginOptions(WithArrowLineAutoCompletePluginKey)?.afterComplete;
7647
7790
  afterComplete && afterComplete(temporaryElement);
7648
7791
  }
7649
7792
  if (autoCompletePoint) {
@@ -7659,7 +7802,7 @@ const withLineAutoComplete = (board) => {
7659
7802
  return board;
7660
7803
  };
7661
7804
 
7662
- const withLineTextMove = (board) => {
7805
+ const withArrowLineTextMove = (board) => {
7663
7806
  let textIndex = 0;
7664
7807
  const movableBuffer = 100;
7665
7808
  const options = {
@@ -7670,10 +7813,10 @@ const withLineTextMove = (board) => {
7670
7813
  hitTest: (point) => {
7671
7814
  let result = null;
7672
7815
  const line = getHitElementByPoint(board, point, (element) => {
7673
- return PlaitDrawElement.isLine(element);
7816
+ return PlaitDrawElement.isArrowLine(element);
7674
7817
  });
7675
7818
  if (line) {
7676
- const index = getHitLineTextIndex(board, line, point);
7819
+ const index = getHitArrowLineTextIndex(board, line, point);
7677
7820
  const textManages = getTextManages(line);
7678
7821
  const textManage = textManages[index];
7679
7822
  if (index !== -1 && !textManage.isEditing) {
@@ -7687,7 +7830,7 @@ const withLineTextMove = (board) => {
7687
7830
  const element = resizeRef.element;
7688
7831
  if (element) {
7689
7832
  const movingPoint = resizeState.endPoint;
7690
- const points = getLinePoints(board, element);
7833
+ const points = getArrowLinePoints(board, element);
7691
7834
  const distance = distanceBetweenPointAndSegments(points, movingPoint);
7692
7835
  if (distance <= movableBuffer) {
7693
7836
  const point = getNearestPointBetweenPointAndSegments(movingPoint, points, false);
@@ -7697,7 +7840,7 @@ const withLineTextMove = (board) => {
7697
7840
  ...texts[textIndex],
7698
7841
  position
7699
7842
  };
7700
- DrawTransforms.setLineTexts(board, element, texts);
7843
+ DrawTransforms.setArrowLineTexts(board, element, texts);
7701
7844
  }
7702
7845
  }
7703
7846
  }
@@ -7857,8 +8000,8 @@ class TableComponent extends CommonElementFlavour {
7857
8000
  });
7858
8001
  this.tableGenerator = new TableGenerator(this.board);
7859
8002
  this.initializeTextManage();
7860
- this.lineAutoCompleteGenerator = new LineAutoCompleteGenerator(this.board);
7861
- this.getRef().addGenerator(LineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
8003
+ this.lineAutoCompleteGenerator = new ArrowLineAutoCompleteGenerator(this.board);
8004
+ this.getRef().addGenerator(ArrowLineAutoCompleteGenerator.key, this.lineAutoCompleteGenerator);
7862
8005
  }
7863
8006
  initialize() {
7864
8007
  super.initialize();
@@ -7904,9 +8047,9 @@ class TableComponent extends CommonElementFlavour {
7904
8047
  this.textGenerator = new TextGenerator(this.board, this.element, texts, {
7905
8048
  onChange: (value, data, text) => {
7906
8049
  const height = data.height / this.board.viewport.zoom;
7907
- const width = data.width / this.board.viewport.zoom;
8050
+ const path = PlaitBoard.findPath(this.board, value);
7908
8051
  if (data.newText) {
7909
- DrawTransforms.setTableText(this.board, value, text.key, data.newText, width, height);
8052
+ DrawTransforms.setTableText(this.board, path, text.key, data.newText, height);
7910
8053
  }
7911
8054
  data.operations && memorizeLatestText(value, data.operations);
7912
8055
  },
@@ -8097,7 +8240,7 @@ function withTableResize(board) {
8097
8240
 
8098
8241
  const withTable = (board) => {
8099
8242
  const tableBoard = board;
8100
- const { drawElement, getRectangle, isRectangleHit, isHit, isMovable, dblClick, keyDown } = tableBoard;
8243
+ const { drawElement, getRectangle, isRectangleHit, isHit, isMovable, dblClick, keyDown, pointerUp } = tableBoard;
8101
8244
  tableBoard.drawElement = (context) => {
8102
8245
  if (PlaitDrawElement.isElementByTable(context.element)) {
8103
8246
  return TableComponent;
@@ -8134,12 +8277,21 @@ const withTable = (board) => {
8134
8277
  const selectedElements = getSelectedElements(board);
8135
8278
  const isSingleSelection = selectedElements.length === 1;
8136
8279
  const targetElement = selectedElements[0];
8137
- 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) {
8138
8286
  event.preventDefault();
8139
8287
  if (PlaitDrawElement.isElementByTable(targetElement)) {
8140
- const firstTextCell = targetElement.cells.find(item => item.text && item.textHeight);
8141
- if (firstTextCell) {
8142
- 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);
8143
8295
  return;
8144
8296
  }
8145
8297
  }
@@ -8161,6 +8313,23 @@ const withTable = (board) => {
8161
8313
  }
8162
8314
  dblClick(event);
8163
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
+ };
8164
8333
  tableBoard.buildTable = (element) => {
8165
8334
  return element;
8166
8335
  };
@@ -8168,14 +8337,12 @@ const withTable = (board) => {
8168
8337
  };
8169
8338
 
8170
8339
  const isSwimlaneDndMode = (board) => {
8171
- const swimlanePointers = getSwimlanePointers();
8172
- const isSwimlanePointer = PlaitBoard.isInPointer(board, swimlanePointers);
8340
+ const isSwimlanePointer = isSwimlanePointers(board);
8173
8341
  const dndMode = isSwimlanePointer && isDndMode(board);
8174
8342
  return dndMode;
8175
8343
  };
8176
8344
  const isSwimlaneDrawingMode = (board) => {
8177
- const swimlanePointers = getSwimlanePointers();
8178
- const isSwimlanePointer = PlaitBoard.isInPointer(board, swimlanePointers);
8345
+ const isSwimlanePointer = isSwimlanePointers(board);
8179
8346
  const drawingMode = isSwimlanePointer && isDrawingMode(board);
8180
8347
  return drawingMode;
8181
8348
  };
@@ -8305,28 +8472,11 @@ const withSwimlane = (board) => {
8305
8472
  }
8306
8473
  return buildTable(element);
8307
8474
  };
8308
- board.pointerUp = (event) => {
8309
- const isSetSelectionPointer = PlaitBoard.isPointer(board, PlaitPointerType.selection) || PlaitBoard.isPointer(board, PlaitPointerType.hand);
8310
- const isSkip = !isMainPointer(event) || isDragging(board) || !isSetSelectionPointer;
8311
- if (isSkip) {
8312
- pointerUp(event);
8313
- return;
8314
- }
8315
- if (isSingleSelectSwimlane(board)) {
8316
- const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
8317
- const element = getSelectedSwimlane(board);
8318
- const hitCell = getHitCell(board, element, point);
8319
- if (hitCell && hitCell.text && hitCell.textHeight) {
8320
- setSelectedCells(element, [hitCell]);
8321
- }
8322
- }
8323
- pointerUp(event);
8324
- };
8325
8475
  return withSwimlaneCreateByDrawing(withSwimlaneCreateByDrag(board));
8326
8476
  };
8327
8477
 
8328
8478
  const withDraw = (board) => {
8329
- const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment } = board;
8479
+ const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment, getHitElement } = board;
8330
8480
  board.drawElement = (context) => {
8331
8481
  if (PlaitDrawElement.isGeometry(context.element)) {
8332
8482
  if (PlaitDrawElement.isUML(context.element)) {
@@ -8334,8 +8484,8 @@ const withDraw = (board) => {
8334
8484
  }
8335
8485
  return GeometryComponent;
8336
8486
  }
8337
- else if (PlaitDrawElement.isLine(context.element)) {
8338
- return LineComponent;
8487
+ else if (PlaitDrawElement.isArrowLine(context.element)) {
8488
+ return ArrowLineComponent;
8339
8489
  }
8340
8490
  else if (PlaitDrawElement.isImage(context.element)) {
8341
8491
  return ImageComponent;
@@ -8346,10 +8496,10 @@ const withDraw = (board) => {
8346
8496
  if (PlaitDrawElement.isGeometry(element)) {
8347
8497
  return RectangleClient.getRectangleByPoints(element.points);
8348
8498
  }
8349
- if (PlaitDrawElement.isLine(element)) {
8350
- const points = getLinePoints(board, element);
8499
+ if (PlaitDrawElement.isArrowLine(element)) {
8500
+ const points = getArrowLinePoints(board, element);
8351
8501
  const lineTextRectangles = element.texts.map((text, index) => {
8352
- const rectangle = getLineTextRectangle(board, element, index);
8502
+ const rectangle = getArrowLineTextRectangle(board, element, index);
8353
8503
  return rectangle;
8354
8504
  });
8355
8505
  const linePointsRectangle = RectangleClient.getRectangleByPoints(points);
@@ -8374,6 +8524,13 @@ const withDraw = (board) => {
8374
8524
  }
8375
8525
  return isHit(element, point);
8376
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
+ };
8377
8534
  board.isInsidePoint = (element, point) => {
8378
8535
  const result = isHitElementInside(board, element, point);
8379
8536
  if (result !== null) {
@@ -8388,7 +8545,7 @@ const withDraw = (board) => {
8388
8545
  if (PlaitDrawElement.isImage(element)) {
8389
8546
  return true;
8390
8547
  }
8391
- if (PlaitDrawElement.isLine(element)) {
8548
+ if (PlaitDrawElement.isArrowLine(element)) {
8392
8549
  const selectedElements = getSelectedElements(board);
8393
8550
  const isSelected = (boundId) => {
8394
8551
  return !!selectedElements.find(value => value.id === boundId);
@@ -8414,7 +8571,7 @@ const withDraw = (board) => {
8414
8571
  };
8415
8572
  board.getRelatedFragment = (elements, originData) => {
8416
8573
  const selectedElements = originData?.length ? originData : getSelectedElements(board);
8417
- const lineElements = board.children.filter(element => PlaitDrawElement.isLine(element));
8574
+ const lineElements = board.children.filter(element => PlaitDrawElement.isArrowLine(element));
8418
8575
  const activeLines = lineElements.filter(line => {
8419
8576
  const source = selectedElements.find(element => element.id === line.source.boundId);
8420
8577
  const target = selectedElements.find(element => element.id === line.target.boundId);
@@ -8423,12 +8580,12 @@ const withDraw = (board) => {
8423
8580
  });
8424
8581
  return getRelatedFragment([...elements, ...activeLines], originData);
8425
8582
  };
8426
- 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))))))))))))))));
8427
8584
  };
8428
8585
 
8429
8586
  /**
8430
8587
  * Generated bundle index. Do not edit.
8431
8588
  */
8432
8589
 
8433
- 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 };
8434
8591
  //# sourceMappingURL=plait-draw.mjs.map