@plait/draw 0.70.0 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/arrow-line.component.d.ts +1 -1
  2. package/constants/default.d.ts +1 -0
  3. package/constants/geometry.d.ts +5 -5
  4. package/constants/index.d.ts +1 -0
  5. package/constants/pointer.d.ts +3 -3
  6. package/engines/table/table.d.ts +2 -2
  7. package/engines/uml/combined-fragment.d.ts +2 -2
  8. package/engines/uml/package.d.ts +2 -2
  9. package/esm2022/arrow-line.component.mjs +13 -13
  10. package/esm2022/constants/default.mjs +2 -0
  11. package/esm2022/constants/geometry.mjs +8 -8
  12. package/esm2022/constants/index.mjs +2 -1
  13. package/esm2022/constants/pointer.mjs +4 -4
  14. package/esm2022/engines/table/table.mjs +3 -3
  15. package/esm2022/engines/uml/combined-fragment.mjs +5 -5
  16. package/esm2022/engines/uml/package.mjs +5 -5
  17. package/esm2022/generators/geometry-shape.generator.mjs +6 -5
  18. package/esm2022/generators/single-text.generator.mjs +3 -3
  19. package/esm2022/generators/table.generator.mjs +6 -5
  20. package/esm2022/generators/text.generator.mjs +25 -21
  21. package/esm2022/geometry.component.mjs +4 -5
  22. package/esm2022/interfaces/arrow-line.mjs +1 -1
  23. package/esm2022/interfaces/element.mjs +1 -7
  24. package/esm2022/interfaces/geometry.mjs +6 -6
  25. package/esm2022/interfaces/index.mjs +13 -1
  26. package/esm2022/interfaces/options.mjs +2 -0
  27. package/esm2022/interfaces/vector-line.mjs +5 -5
  28. package/esm2022/plugins/with-arrow-line-text.mjs +2 -2
  29. package/esm2022/plugins/with-draw-fragment.mjs +8 -12
  30. package/esm2022/plugins/with-draw-hotkey.mjs +3 -3
  31. package/esm2022/plugins/with-draw-resize.mjs +11 -6
  32. package/esm2022/plugins/with-draw-rotate.mjs +3 -2
  33. package/esm2022/plugins/with-draw.mjs +10 -11
  34. package/esm2022/plugins/with-vector-line-create.mjs +123 -0
  35. package/esm2022/plugins/with-vector-line-resize.mjs +3 -3
  36. package/esm2022/table.component.mjs +8 -9
  37. package/esm2022/transforms/index.mjs +3 -3
  38. package/esm2022/transforms/multi-text-geometry-text.mjs +3 -3
  39. package/esm2022/utils/arrow-line/arrow-line-basic.mjs +6 -5
  40. package/esm2022/utils/clipboard.mjs +6 -17
  41. package/esm2022/utils/common.mjs +15 -8
  42. package/esm2022/utils/geometry.mjs +3 -3
  43. package/esm2022/utils/hit.mjs +21 -19
  44. package/esm2022/utils/index.mjs +2 -1
  45. package/esm2022/utils/multi-text-geometry.mjs +3 -3
  46. package/esm2022/utils/selected.mjs +9 -1
  47. package/esm2022/utils/snap-resizing.mjs +1 -1
  48. package/esm2022/utils/style/stroke.mjs +7 -17
  49. package/esm2022/utils/table.mjs +2 -2
  50. package/esm2022/utils/vector-line.mjs +6 -10
  51. package/esm2022/vector-line.component.mjs +2 -4
  52. package/fesm2022/plait-draw.mjs +259 -318
  53. package/fesm2022/plait-draw.mjs.map +1 -1
  54. package/generators/single-text.generator.d.ts +2 -2
  55. package/generators/text.generator.d.ts +11 -11
  56. package/interfaces/arrow-line.d.ts +1 -1
  57. package/interfaces/element.d.ts +0 -5
  58. package/interfaces/geometry.d.ts +11 -10
  59. package/interfaces/index.d.ts +4 -1
  60. package/interfaces/options.d.ts +4 -0
  61. package/interfaces/vector-line.d.ts +4 -4
  62. package/package.json +1 -1
  63. package/plugins/with-vector-line-create.d.ts +2 -0
  64. package/styles/styles.scss +1 -1
  65. package/table.component.d.ts +2 -2
  66. package/transforms/common.d.ts +1 -1
  67. package/transforms/geometry.d.ts +1 -1
  68. package/transforms/index.d.ts +3 -3
  69. package/transforms/multi-text-geometry-text.d.ts +2 -2
  70. package/utils/clipboard.d.ts +10 -3
  71. package/utils/common.d.ts +5 -3
  72. package/utils/geometry.d.ts +6 -6
  73. package/utils/hit.d.ts +8 -4
  74. package/utils/index.d.ts +1 -0
  75. package/utils/multi-text-geometry.d.ts +6 -10
  76. package/utils/selected.d.ts +3 -1
  77. package/utils/snap-resizing.d.ts +2 -2
  78. package/utils/style/stroke.d.ts +1 -2
  79. package/utils/vector-line.d.ts +0 -1
  80. package/esm2022/plugins/with-geometry-resize.mjs +0 -70
  81. package/esm2022/plugins/with-vector-pen-create.mjs +0 -123
  82. package/plugins/with-geometry-resize.d.ts +0 -2
  83. package/plugins/with-vector-pen-create.d.ts +0 -2
@@ -1,5 +1,5 @@
1
- import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, RectangleClient, getSelectedElements, idCreator, catmullRomFitting, PlaitBoard, createG, drawLinearPath, setStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, rotatePointsByElement, isPolylineHitRectangle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, rotate, 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, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, setPathStrokeLinecap, getCrossingPointsBetweenEllipseAndSegment, drawLine, Path, RgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, getHitElementByPoint, WritableClipboardOperationType, createClipboardContext, WritableClipboardType, addClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
- import { DEFAULT_FILL, Alignment, WithTextPluginKey, ELEMENT_TO_TEXT_MANAGES, TextManage, getMemorizedLatest, memorizeLatest, getPointOnPolyline, buildText, Generator, sortElementsByArea, isFilled, getTextEditorsByElement, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, RESIZE_HANDLE_DIAMETER, 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';
1
+ import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, catmullRomFitting, PlaitBoard, createG, drawLinearPath, setStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isPolylineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, rotate, findElements, createMask, createRect, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, setPathStrokeLinecap, getCrossingPointsBetweenEllipseAndSegment, drawLine, Path, RgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
+ import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, getPointOnPolyline, buildText, Generator, getStrokeLineDash, StrokeStyle, sortElementsByArea, isFilled, getTextEditorsByElement, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, RESIZE_HANDLE_DIAMETER, 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, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, 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';
@@ -80,11 +80,11 @@ var UMLSymbols;
80
80
  UMLSymbols["providedInterface"] = "providedInterface";
81
81
  UMLSymbols["requiredInterface"] = "requiredInterface";
82
82
  })(UMLSymbols || (UMLSymbols = {}));
83
- var MultipleTextGeometryCommonTextKeys;
84
- (function (MultipleTextGeometryCommonTextKeys) {
85
- MultipleTextGeometryCommonTextKeys["name"] = "name";
86
- MultipleTextGeometryCommonTextKeys["content"] = "content";
87
- })(MultipleTextGeometryCommonTextKeys || (MultipleTextGeometryCommonTextKeys = {}));
83
+ var GeometryCommonTextKeys;
84
+ (function (GeometryCommonTextKeys) {
85
+ GeometryCommonTextKeys["name"] = "name";
86
+ GeometryCommonTextKeys["content"] = "content";
87
+ })(GeometryCommonTextKeys || (GeometryCommonTextKeys = {}));
88
88
  const PlaitGeometry = {};
89
89
 
90
90
  var SwimlaneSymbols;
@@ -113,6 +113,8 @@ const PlaitTableElement = {
113
113
  }
114
114
  };
115
115
 
116
+ const WithDrawPluginKey = 'plait-draw-plugin-key';
117
+
116
118
  const ShapeDefaultSpace = {
117
119
  rectangleAndText: 4
118
120
  };
@@ -213,12 +215,12 @@ const DefaultPackageProperty = {
213
215
  height: 150,
214
216
  texts: [
215
217
  {
216
- key: MultipleTextGeometryCommonTextKeys.name,
218
+ id: GeometryCommonTextKeys.name,
217
219
  text: '包名',
218
220
  align: Alignment.left
219
221
  },
220
222
  {
221
- key: MultipleTextGeometryCommonTextKeys.content,
223
+ id: GeometryCommonTextKeys.content,
222
224
  text: '',
223
225
  align: Alignment.left
224
226
  }
@@ -261,12 +263,12 @@ const DefaultCombinedFragmentProperty = {
261
263
  height: 280,
262
264
  texts: [
263
265
  {
264
- key: MultipleTextGeometryCommonTextKeys.name,
266
+ id: GeometryCommonTextKeys.name,
265
267
  text: 'Opt | Alt | Loop',
266
268
  align: Alignment.left
267
269
  },
268
270
  {
269
- key: MultipleTextGeometryCommonTextKeys.content,
271
+ id: GeometryCommonTextKeys.content,
270
272
  text: '[Condition]',
271
273
  align: Alignment.left
272
274
  }
@@ -356,8 +358,8 @@ const DefaultUMLPropertyMap = {
356
358
  [UMLSymbols.requiredInterface]: DefaultRequiredInterfaceProperty
357
359
  };
358
360
  const MultipleTextGeometryTextKeys = {
359
- [UMLSymbols.package]: Object.keys(MultipleTextGeometryCommonTextKeys),
360
- [UMLSymbols.combinedFragment]: Object.keys(MultipleTextGeometryCommonTextKeys)
361
+ [UMLSymbols.package]: Object.keys(GeometryCommonTextKeys),
362
+ [UMLSymbols.combinedFragment]: Object.keys(GeometryCommonTextKeys)
361
363
  };
362
364
  const LINE_HIT_GEOMETRY_BUFFER = 10;
363
365
  const LINE_SNAPPING_BUFFER = 6;
@@ -400,8 +402,8 @@ const getUMLPointers = () => {
400
402
  const getArrowLinePointers = () => {
401
403
  return Object.keys(ArrowLineShape);
402
404
  };
403
- const getVectorPenPointers = () => {
404
- return Object.keys(VectorPenPointerType);
405
+ const getVectorLinePointers = () => {
406
+ return Object.keys(VectorLinePointerType);
405
407
  };
406
408
 
407
409
  const DEFAULT_IMAGE_WIDTH = 1000;
@@ -469,14 +471,20 @@ const getElementShape = (value) => {
469
471
  return value.shape;
470
472
  };
471
473
 
474
+ // TODO: 是否可以完全基于位置定位 TextManager,实现 line 和 多文本 geometry 统一
475
+ // 一个元素有多个文本时,单纯通过位置无法获取 TextManage,因此这里单独通过 Map 保存关键字 key 和 TextManage 的对应关系
476
+ // 1. 单文本元素 key 就是元素的 id
477
+ // 2. 表格元素 key 是单元格的 id
478
+ // 3. 符合 isMultipleTextGeometry 的元素,key 是元素 id + text.id (通常不是 id 而是文本位置的常量)
479
+ // 4. arrow-line 和 vector-line 文本不依赖于 text.generator,基于 text 可以直接找到 TextManage
472
480
  const KEY_TO_TEXT_MANAGE = new WeakMap();
473
- const setTextManage = (board, key, textManage) => {
481
+ const setTextManage = (board, element, text, textManage) => {
474
482
  const textManages = KEY_TO_TEXT_MANAGE.get(board);
475
- return KEY_TO_TEXT_MANAGE.set(board, { ...textManages, [key]: textManage });
483
+ return KEY_TO_TEXT_MANAGE.set(board, { ...textManages, [getTextKey(element, text)]: textManage });
476
484
  };
477
- const getTextManage = (board, key) => {
485
+ const getTextManage = (board, element, text) => {
478
486
  const textManages = KEY_TO_TEXT_MANAGE.get(board);
479
- return textManages[key];
487
+ return textManages[getTextKey(element, text)];
480
488
  };
481
489
  const deleteTextManage = (board, key) => {
482
490
  const textManages = KEY_TO_TEXT_MANAGE.get(board);
@@ -498,15 +506,16 @@ class TextGenerator {
498
506
  .textPlugins;
499
507
  this.textManages = this.texts.map(text => {
500
508
  const textManage = this.createTextManage(text, textPlugins);
501
- setTextManage(this.board, getTextKey(this.element, text), textManage);
509
+ setTextManage(this.board, this.element, text, textManage);
502
510
  return textManage;
503
511
  });
504
- ELEMENT_TO_TEXT_MANAGES.set(this.element, this.textManages);
512
+ const ref = PlaitElement.getElementRef(this.element);
513
+ ref.initializeTextManage(this.textManages);
505
514
  }
506
515
  draw(elementG) {
507
516
  const centerPoint = RectangleClient.getCenterPoint(this.board.getRectangle(this.element));
508
517
  this.texts.forEach(drawShapeText => {
509
- const textManage = getTextManage(this.board, getTextKey(this.element, drawShapeText));
518
+ const textManage = getTextManage(this.board, this.element, drawShapeText);
510
519
  if (drawShapeText.text && textManage) {
511
520
  textManage.draw(drawShapeText.text);
512
521
  elementG.append(textManage.g);
@@ -516,30 +525,29 @@ class TextGenerator {
516
525
  }
517
526
  update(element, previousDrawShapeTexts, currentDrawShapeTexts, elementG) {
518
527
  this.element = element;
519
- ELEMENT_TO_TEXT_MANAGES.set(this.element, this.textManages);
520
528
  const centerPoint = RectangleClient.getCenterPoint(this.board.getRectangle(this.element));
521
529
  const textPlugins = (this.board.getPluginOptions(WithTextPluginKey) || {})
522
530
  .textPlugins;
523
531
  const removedTexts = previousDrawShapeTexts.filter(value => {
524
- return !currentDrawShapeTexts.find(item => item.key === value.key);
532
+ return !currentDrawShapeTexts.find(item => item.id === value.id);
525
533
  });
526
534
  if (removedTexts.length) {
527
535
  removedTexts.forEach(item => {
528
- const textManage = getTextManage(this.board, item.key);
536
+ const textManage = getTextManage(this.board, element, item);
529
537
  const index = this.textManages.findIndex(value => value === textManage);
530
538
  if (index > -1 && item.text && item.textHeight) {
531
539
  this.textManages.splice(index, 1);
532
540
  }
533
541
  textManage?.destroy();
534
- deleteTextManage(this.board, item.key);
542
+ deleteTextManage(this.board, item.id);
535
543
  });
536
544
  }
537
545
  currentDrawShapeTexts.forEach(drawShapeText => {
538
546
  if (drawShapeText.text) {
539
- let textManage = getTextManage(this.board, getTextKey(this.element, drawShapeText));
547
+ let textManage = getTextManage(this.board, this.element, drawShapeText);
540
548
  if (!textManage) {
541
549
  textManage = this.createTextManage(drawShapeText, textPlugins);
542
- setTextManage(this.board, drawShapeText.key, textManage);
550
+ setTextManage(this.board, element, drawShapeText, textManage);
543
551
  textManage.draw(drawShapeText.text);
544
552
  elementG.append(textManage.g);
545
553
  this.textManages.push(textManage);
@@ -581,13 +589,11 @@ class TextGenerator {
581
589
  return this.options.getMaxWidth ? this.options.getMaxWidth() : this.getRectangle(text).width;
582
590
  }
583
591
  destroy() {
584
- this.textManages.forEach(manage => {
585
- manage.destroy();
586
- });
592
+ const ref = PlaitElement.getElementRef(this.element);
593
+ ref.destroyTextManage();
587
594
  this.textManages = [];
588
- ELEMENT_TO_TEXT_MANAGES.delete(this.element);
589
595
  this.texts.forEach(item => {
590
- deleteTextManage(this.board, item.key);
596
+ deleteTextManage(this.board, item.id);
591
597
  });
592
598
  }
593
599
  }
@@ -708,7 +714,7 @@ function editCell(board, cell) {
708
714
  textManage && textManage.edit();
709
715
  }
710
716
  function getTextManageByCell(board, cell) {
711
- return getTextManage(board, cell.id);
717
+ return getTextManage(board, undefined, cell);
712
718
  }
713
719
  const updateColumns = (table, columnId, width, offset) => {
714
720
  const columns = table.columns.map(item => (item.id === columnId ? { ...item, width } : item));
@@ -925,7 +931,7 @@ const buildDefaultTextsByShape = (shape) => {
925
931
  return (textKeys || []).map((textKey) => {
926
932
  const text = defaultTexts?.find((item) => item?.key === textKey);
927
933
  return {
928
- key: textKey,
934
+ id: textKey,
929
935
  text: buildText(text?.text || '', alignment || text?.align || Alignment.center, textProperties),
930
936
  textHeight: textHeight
931
937
  };
@@ -937,7 +943,7 @@ const getHitMultipleGeometryText = (element, point) => {
937
943
  let hitText;
938
944
  if (engine.getTextRectangle) {
939
945
  hitText = element.texts.find(text => {
940
- const textRectangle = engine.getTextRectangle(element, { key: text.key });
946
+ const textRectangle = engine.getTextRectangle(element, { id: text.id });
941
947
  return RectangleClient.isHit(rectangle, textRectangle);
942
948
  });
943
949
  }
@@ -967,12 +973,6 @@ class VectorLineShapeGenerator extends Generator {
967
973
  }
968
974
  }
969
975
 
970
- const isClosedVectorLine = (vectorLine) => {
971
- const points = vectorLine.points;
972
- const startPoint = points[0];
973
- const endPoint = points[points.length - 1];
974
- return startPoint[0] === endPoint[0] && startPoint[1] === endPoint[1];
975
- };
976
976
  const getVectorLinePoints = (board, element) => {
977
977
  switch (element.shape) {
978
978
  case VectorLineShape.straight: {
@@ -1018,7 +1018,8 @@ const vectorLineCreating = (board, lineShape, points, movingPoint, lineShapeG) =
1018
1018
  const drawVectorLine = (board, element) => {
1019
1019
  const strokeWidth = getStrokeWidthByElement(element);
1020
1020
  const strokeColor = getStrokeColorByElement(board, element);
1021
- const strokeLineDash = getLineDashByElement(element);
1021
+ const strokeStyle = getStrokeStyleByElement(board, element);
1022
+ const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
1022
1023
  const fill = getFillByElement(board, element);
1023
1024
  const options = { stroke: strokeColor, strokeWidth, strokeLineDash, fill };
1024
1025
  const lineG = createG();
@@ -1054,7 +1055,7 @@ const isHitArrowLine = (board, element, point) => {
1054
1055
  };
1055
1056
  const isHitVectorLine = (board, element, point) => {
1056
1057
  const points = getVectorLinePoints(board, element);
1057
- if (isClosedVectorLine(element)) {
1058
+ if (isClosedPoints(element.points)) {
1058
1059
  return isPointInPolygon(point, points) || isHitPolyLine(points, point);
1059
1060
  }
1060
1061
  else {
@@ -1066,15 +1067,13 @@ const isRectangleHitElementText = (element, rectangle) => {
1066
1067
  if (isMultipleTextGeometry(element)) {
1067
1068
  const texts = element.texts;
1068
1069
  return texts.some(item => {
1069
- const textClient = engine.getTextRectangle(element, { key: item.key });
1070
- const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
1071
- return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
1070
+ const textClient = engine.getTextRectangle(element, { id: item.id });
1071
+ return isRectangleHitRotatedPoints(rectangle, RectangleClient.getCornerPoints(textClient), element.angle);
1072
1072
  });
1073
1073
  }
1074
1074
  else {
1075
1075
  const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
1076
- const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
1077
- return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
1076
+ return isRectangleHitRotatedPoints(rectangle, RectangleClient.getCornerPoints(textClient), element.angle);
1078
1077
  }
1079
1078
  };
1080
1079
  const isHitElementText = (element, point) => {
@@ -1082,7 +1081,7 @@ const isHitElementText = (element, point) => {
1082
1081
  if (isMultipleTextGeometry(element)) {
1083
1082
  const texts = element.texts;
1084
1083
  return texts.some(item => {
1085
- const textClient = engine.getTextRectangle(element, { key: item.key });
1084
+ const textClient = engine.getTextRectangle(element, { id: item.id });
1086
1085
  return RectangleClient.isPointInRectangle(textClient, point);
1087
1086
  });
1088
1087
  }
@@ -1094,18 +1093,14 @@ const isHitElementText = (element, point) => {
1094
1093
  const isRectangleHitDrawElement = (board, element, selection) => {
1095
1094
  const rangeRectangle = RectangleClient.getRectangleByPoints([selection.anchor, selection.focus]);
1096
1095
  if (PlaitDrawElement.isGeometry(element)) {
1097
- const client = RectangleClient.getRectangleByPoints(element.points);
1098
- let rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(client), element) || RectangleClient.getCornerPoints(client);
1099
- const isHitElement = isPolylineHitRectangle(rotatedCornerPoints, rangeRectangle);
1096
+ const isHitElement = isRectangleHitRotatedElement(board, rangeRectangle, element);
1100
1097
  if (isHitElement) {
1101
1098
  return isHitElement;
1102
1099
  }
1103
1100
  return isRectangleHitElementText(element, rangeRectangle);
1104
1101
  }
1105
1102
  if (PlaitDrawElement.isImage(element)) {
1106
- const client = RectangleClient.getRectangleByPoints(element.points);
1107
- const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(client), element) || RectangleClient.getCornerPoints(client);
1108
- return isPolylineHitRectangle(rotatedCornerPoints, rangeRectangle);
1103
+ return isRectangleHitRotatedElement(board, rangeRectangle, element);
1109
1104
  }
1110
1105
  if (PlaitDrawElement.isArrowLine(element)) {
1111
1106
  const points = getArrowLinePoints(board, element);
@@ -1117,7 +1112,15 @@ const isRectangleHitDrawElement = (board, element, selection) => {
1117
1112
  }
1118
1113
  return null;
1119
1114
  };
1120
- const getDrawHitElement = (board, elements) => {
1115
+ const isRectangleHitRotatedElement = (board, rectangle, element) => {
1116
+ const client = RectangleClient.getRectangleByPoints(element.points);
1117
+ return isRectangleHitRotatedPoints(rectangle, RectangleClient.getCornerPoints(client), element.angle);
1118
+ };
1119
+ const isRectangleHitRotatedPoints = (rectangle, points, angle) => {
1120
+ let rotatedPoints = rotatePointsByAngle(points, angle) || points;
1121
+ return isPolylineHitRectangle(rotatedPoints, rectangle);
1122
+ };
1123
+ const getHitDrawElement = (board, elements) => {
1121
1124
  let firstFilledElement = getFirstFilledDrawElement(board, elements);
1122
1125
  let endIndex = elements.length;
1123
1126
  if (firstFilledElement) {
@@ -1135,7 +1138,7 @@ const getFirstFilledDrawElement = (board, elements) => {
1135
1138
  let filledElement = null;
1136
1139
  for (let i = 0; i < elements.length; i++) {
1137
1140
  const element = elements[i];
1138
- if (isDrawElementClosed(element)) {
1141
+ if (isCustomGeometryClosed(board, element) || isDrawElementClosed(element)) {
1139
1142
  const fill = getFillByElement(board, element);
1140
1143
  if (isFilled(fill)) {
1141
1144
  filledElement = element;
@@ -1276,13 +1279,16 @@ const isDrawElementClosed = (element) => {
1276
1279
  return false;
1277
1280
  }
1278
1281
  if (PlaitDrawElement.isVectorLine(element)) {
1279
- return isClosedVectorLine(element);
1282
+ return isClosedPoints(element.points);
1280
1283
  }
1281
1284
  if (PlaitDrawElement.isGeometry(element)) {
1282
1285
  return isGeometryClosed(element);
1283
1286
  }
1284
1287
  return true;
1285
1288
  };
1289
+ const isCustomGeometryClosed = (board, value) => {
1290
+ return PlaitDrawElement.isCustomGeometryElement(board, value) && isClosedPoints(value.points);
1291
+ };
1286
1292
  const getSnappingShape = (board, point) => {
1287
1293
  let hitElement = getHitShape(board, point);
1288
1294
  if (hitElement) {
@@ -1357,16 +1363,16 @@ const drawBoundReaction = (board, element, roughOptions = { hasMask: true, hasCo
1357
1363
  return g;
1358
1364
  };
1359
1365
  const getTextKey = (element, text) => {
1360
- if (isMultipleTextGeometry(element)) {
1361
- return `${element.id}-${text.key}`;
1366
+ if (element && isMultipleTextGeometry(element)) {
1367
+ return `${element.id}-${text.id}`;
1362
1368
  }
1363
1369
  else {
1364
- return text.key;
1370
+ return text.id;
1365
1371
  }
1366
1372
  };
1367
1373
  const getGeometryAlign = (board, element) => {
1368
1374
  if (isMultipleTextGeometry(element)) {
1369
- const drawShapeText = element.texts.find(item => item.key.includes(MultipleTextGeometryCommonTextKeys.content));
1375
+ const drawShapeText = element.texts.find(item => item.id.includes(GeometryCommonTextKeys.content));
1370
1376
  return drawShapeText?.text.align || Alignment.center;
1371
1377
  }
1372
1378
  if (isSingleTextGeometry(element)) {
@@ -1378,6 +1384,11 @@ const getGeometryAlign = (board, element) => {
1378
1384
  }
1379
1385
  return Alignment.center;
1380
1386
  };
1387
+ const isClosedPoints = (points) => {
1388
+ const startPoint = points[0];
1389
+ const endPoint = points[points.length - 1];
1390
+ return startPoint[0] === endPoint[0] && startPoint[1] === endPoint[1];
1391
+ };
1381
1392
 
1382
1393
  const getStrokeColorByElement = (board, element) => {
1383
1394
  const defaultColor = getDrawDefaultStrokeColor(board.theme.themeColorMode);
@@ -1385,23 +1396,13 @@ const getStrokeColorByElement = (board, element) => {
1385
1396
  return strokeColor;
1386
1397
  };
1387
1398
  const getFillByElement = (board, element) => {
1388
- const defaultFill = PlaitDrawElement.isFlowchart(element) && isDrawElementClosed(element)
1389
- ? getFlowchartDefaultFill(board.theme.themeColorMode)
1399
+ const defaultFill = isDrawElementClosed(element) || isCustomGeometryClosed(board, element)
1400
+ ? getDefaultFill(board.theme.themeColorMode)
1390
1401
  : DefaultDrawStyle.fill;
1391
1402
  const fill = element.fill || defaultFill;
1392
1403
  return fill;
1393
1404
  };
1394
- const getLineDashByElement = (element) => {
1395
- switch (element.strokeStyle) {
1396
- case StrokeStyle.dashed:
1397
- return [8, 8 + getStrokeWidthByElement(element)];
1398
- case StrokeStyle.dotted:
1399
- return [2, 4 + getStrokeWidthByElement(element)];
1400
- default:
1401
- return undefined;
1402
- }
1403
- };
1404
- const getStrokeStyleByElement = (element) => {
1405
+ const getStrokeStyleByElement = (board, element) => {
1405
1406
  return element.strokeStyle || StrokeStyle.solid;
1406
1407
  };
1407
1408
 
@@ -1908,7 +1909,8 @@ const getCurvePoints = (board, element) => {
1908
1909
  const drawArrowLine = (board, element) => {
1909
1910
  const strokeWidth = getStrokeWidthByElement(element);
1910
1911
  const strokeColor = getStrokeColorByElement(board, element);
1911
- const strokeLineDash = getLineDashByElement(element);
1912
+ const strokeStyle = getStrokeStyleByElement(board, element);
1913
+ const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
1912
1914
  const options = { stroke: strokeColor, strokeWidth, strokeLineDash };
1913
1915
  const lineG = createG();
1914
1916
  let points = getArrowLinePoints(board, element);
@@ -2253,7 +2255,7 @@ const getHitIndexOfAutoCompletePoint = (movingPoint, points) => {
2253
2255
  const getDrawDefaultStrokeColor = (theme) => {
2254
2256
  return DrawThemeColors[theme].strokeColor;
2255
2257
  };
2256
- const getFlowchartDefaultFill = (theme) => {
2258
+ const getDefaultFill = (theme) => {
2257
2259
  return DrawThemeColors[theme].fill;
2258
2260
  };
2259
2261
  const getTextShapeProperty = (board, text = DefaultTextProperty.text, fontSize) => {
@@ -2313,7 +2315,7 @@ const createDefaultGeometry = (board, points, shape) => {
2313
2315
  }
2314
2316
  };
2315
2317
  const editText = (board, element, text) => {
2316
- const textManage = text ? getTextManage(board, `${element.id}-${text.key}`) : getFirstTextManage(element);
2318
+ const textManage = text ? getTextManage(board, element, text) : getFirstTextManage(element);
2317
2319
  if (textManage) {
2318
2320
  textManage.edit(() => {
2319
2321
  // delay to avoid blinking
@@ -2458,6 +2460,10 @@ const getSelectedGeometryElements = (board) => {
2458
2460
  const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isGeometry(value));
2459
2461
  return selectedElements;
2460
2462
  };
2463
+ const getSelectedCustomGeometryElements = (board) => {
2464
+ const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isCustomGeometryElement(board, value));
2465
+ return selectedElements;
2466
+ };
2461
2467
  const getSelectedArrowLineElements = (board) => {
2462
2468
  const selectedElements = getSelectedElements(board).filter(value => PlaitDrawElement.isArrowLine(value));
2463
2469
  return selectedElements;
@@ -2474,6 +2480,10 @@ const isSingleSelectSwimlane = (board) => {
2474
2480
  const selectedElements = getSelectedElements(board);
2475
2481
  return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isSwimlane(selectedElements[0]);
2476
2482
  };
2483
+ const isSingleSelectArrowLine = (board) => {
2484
+ const selectedElements = getSelectedElements(board);
2485
+ return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isArrowLine(selectedElements[0]);
2486
+ };
2477
2487
  const getSelectedSwimlane = (board) => {
2478
2488
  const selectedElements = getSelectedElements(board);
2479
2489
  return selectedElements.find(item => PlaitDrawElement.isSwimlane(item));
@@ -2932,9 +2942,9 @@ const updateSwimlane = (board, swimlane, newColumns, newRows, newCells, newPoint
2932
2942
  }, path);
2933
2943
  };
2934
2944
 
2935
- const setDrawShapeText = (board, element, text) => {
2945
+ const setDrawTexts = (board, element, text) => {
2936
2946
  const newTexts = element.texts?.map(item => {
2937
- if (item.key === text.key) {
2947
+ if (item.id === text.id) {
2938
2948
  return { ...item, ...text };
2939
2949
  }
2940
2950
  return item;
@@ -3064,7 +3074,7 @@ const insertDrawByVector = (board, point, shape, vector) => {
3064
3074
 
3065
3075
  const DrawTransforms = {
3066
3076
  setText,
3067
- setDrawShapeText,
3077
+ setDrawTexts,
3068
3078
  insertGeometry,
3069
3079
  resizeGeometry,
3070
3080
  insertText,
@@ -3126,7 +3136,10 @@ function withDrawResize(board) {
3126
3136
  let resizeActivePoints = null;
3127
3137
  const canResize = () => {
3128
3138
  const elements = getSelectedElements(board);
3129
- return elements.length > 1 && elements.every(el => PlaitDrawElement.isDrawElement(el));
3139
+ return (elements.length >= 1 &&
3140
+ elements.every(el => (PlaitDrawElement.isDrawElement(el) || PlaitDrawElement.isCustomGeometryElement(board, el)) &&
3141
+ !isSingleSelectArrowLine(board) &&
3142
+ !isSingleSelectSwimlane(board)));
3130
3143
  };
3131
3144
  const options = {
3132
3145
  key: 'draw-elements',
@@ -3150,7 +3163,7 @@ function withDrawResize(board) {
3150
3163
  snapG?.remove();
3151
3164
  debugGenerator$2.isDebug() && debugGenerator$2.clear();
3152
3165
  const isFromCorner = isCornerHandle(board, resizeRef.handle);
3153
- const isAspectRatio = resizeState.isShift || isFromCorner;
3166
+ const isAspectRatio = resizeState.isShift;
3154
3167
  const centerPoint = RectangleClient.getCenterPoint(resizeRef.rectangle);
3155
3168
  const handleIndex = getIndexByResizeHandle(resizeRef.handle);
3156
3169
  const { originPoint, handlePoint } = getResizeOriginPointAndHandlePoint(board, handleIndex, resizeRef.rectangle);
@@ -3220,7 +3233,7 @@ function withDrawResize(board) {
3220
3233
  }
3221
3234
  }
3222
3235
  if (PlaitDrawElement.isGeometry(target)) {
3223
- if (isGeometryIncludeText(target)) {
3236
+ if (PlaitDrawElement.isGeometry(target) && isGeometryIncludeText(target)) {
3224
3237
  const { height: textHeight } = getFirstTextManage(target).getSize();
3225
3238
  DrawTransforms.resizeGeometry(board, points, textHeight, path);
3226
3239
  }
@@ -3229,7 +3242,9 @@ function withDrawResize(board) {
3229
3242
  Transforms.setNode(board, { points }, path);
3230
3243
  }
3231
3244
  }
3232
- else if (PlaitDrawElement.isArrowLine(target)) {
3245
+ else if (PlaitDrawElement.isLine(target) ||
3246
+ PlaitDrawElement.isCustomGeometryElement(board, target) ||
3247
+ PlaitDrawElement.isVectorLine(target)) {
3233
3248
  Transforms.setNode(board, { points }, path);
3234
3249
  }
3235
3250
  else if (PlaitDrawElement.isImage(target)) {
@@ -3608,6 +3623,56 @@ function getMiddlePoints(board, element) {
3608
3623
  return result;
3609
3624
  }
3610
3625
 
3626
+ const buildClipboardData = (board, elements, startPoint) => {
3627
+ return buildClipboardData$1(board, elements, startPoint, (element) => {
3628
+ if (PlaitDrawElement.isArrowLine(element)) {
3629
+ let source = { ...element.source };
3630
+ let target = { ...element.target };
3631
+ let points = [...element.points];
3632
+ if (element.source.boundId) {
3633
+ points[0] = getConnectionPoint(getElementById(board, element.source.boundId), element.source.connection);
3634
+ if (!getElementById(board, element.source.boundId, elements)) {
3635
+ delete source.boundId;
3636
+ delete source.connection;
3637
+ }
3638
+ }
3639
+ if (element.target.boundId) {
3640
+ points[points.length - 1] = getConnectionPoint(getElementById(board, element.target.boundId), element.target.connection);
3641
+ if (!getElementById(board, element.target.boundId, elements)) {
3642
+ delete target.boundId;
3643
+ delete target.connection;
3644
+ }
3645
+ }
3646
+ points = points.map(point => [point[0] - startPoint[0], point[1] - startPoint[1]]);
3647
+ return { ...element, points, source, target };
3648
+ }
3649
+ return undefined;
3650
+ });
3651
+ };
3652
+ const insertClipboardData = (board, elements, startPoint) => {
3653
+ insertClipboardData$1(board, elements, startPoint, (element, idsMap) => {
3654
+ if (PlaitDrawElement.isArrowLine(element)) {
3655
+ if (element.source.boundId) {
3656
+ const boundElement = elements.find(item => [element.source.boundId, idsMap[element.source.boundId]].includes(item.id));
3657
+ if (boundElement) {
3658
+ element.source.boundId = idsMap[element.source.boundId];
3659
+ }
3660
+ }
3661
+ if (element.target.boundId) {
3662
+ const boundElement = elements.find(item => [element.target.boundId, idsMap[element.target.boundId]].includes(item.id));
3663
+ if (boundElement) {
3664
+ element.target.boundId = idsMap[element.target.boundId];
3665
+ }
3666
+ }
3667
+ }
3668
+ if (PlaitDrawElement.isElementByTable(element)) {
3669
+ updateRowOrColumnIds(element, 'row');
3670
+ updateRowOrColumnIds(element, 'column');
3671
+ updateCellIds(element.cells);
3672
+ }
3673
+ });
3674
+ };
3675
+
3611
3676
  const getCenterPointsOnPolygon = (points) => {
3612
3677
  const centerPoints = [];
3613
3678
  for (let i = 0; i < points.length; i++) {
@@ -5419,8 +5484,8 @@ const TableEngine = {
5419
5484
  },
5420
5485
  getTextRectangle(element, options) {
5421
5486
  try {
5422
- if (options && options.key) {
5423
- const cell = getCellWithPoints(options?.board, element, options.key);
5487
+ if (options && options.id) {
5488
+ const cell = getCellWithPoints(options?.board, element, options.id);
5424
5489
  if (cell) {
5425
5490
  if (PlaitTableElement.isVerticalText(cell)) {
5426
5491
  return getVerticalTextRectangle(cell);
@@ -5651,8 +5716,8 @@ const PackageEngine = {
5651
5716
  getTextRectangle(element, options) {
5652
5717
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5653
5718
  const strokeWidth = getStrokeWidthByElement(element);
5654
- const textHeight = element.texts?.find(item => item.key === options?.key)?.textHeight;
5655
- if (options?.key === MultipleTextGeometryCommonTextKeys.name) {
5719
+ const textHeight = element.texts?.find(item => item.id === options?.id)?.textHeight;
5720
+ if (options?.id === GeometryCommonTextKeys.name) {
5656
5721
  const width = elementRectangle.width * 0.7 - ShapeDefaultSpace.rectangleAndText - strokeWidth;
5657
5722
  return {
5658
5723
  height: textHeight,
@@ -5661,7 +5726,7 @@ const PackageEngine = {
5661
5726
  y: elementRectangle.y + (25 - textHeight) / 2
5662
5727
  };
5663
5728
  }
5664
- if (options?.key === MultipleTextGeometryCommonTextKeys.content) {
5729
+ if (options?.id === GeometryCommonTextKeys.content) {
5665
5730
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5666
5731
  return {
5667
5732
  height: textHeight,
@@ -5711,8 +5776,8 @@ const CombinedFragmentEngine = {
5711
5776
  getTextRectangle(element, options) {
5712
5777
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5713
5778
  const strokeWidth = getStrokeWidthByElement(element);
5714
- const textHeight = element.texts?.find(item => item.key === options?.key)?.textHeight;
5715
- if (options?.key === MultipleTextGeometryCommonTextKeys.name) {
5779
+ const textHeight = element.texts?.find(item => item.id === options?.id)?.textHeight;
5780
+ if (options?.id === GeometryCommonTextKeys.name) {
5716
5781
  const width = elementRectangle.width / 3 - 8 - ShapeDefaultSpace.rectangleAndText - strokeWidth;
5717
5782
  return {
5718
5783
  height: textHeight,
@@ -5721,7 +5786,7 @@ const CombinedFragmentEngine = {
5721
5786
  y: elementRectangle.y + (25 - textHeight) / 2
5722
5787
  };
5723
5788
  }
5724
- if (options?.key === MultipleTextGeometryCommonTextKeys.content) {
5789
+ if (options?.id === GeometryCommonTextKeys.content) {
5725
5790
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5726
5791
  return {
5727
5792
  height: textHeight,
@@ -6451,12 +6516,6 @@ const PlaitArrowLine = {
6451
6516
  }
6452
6517
  };
6453
6518
 
6454
- var StrokeStyle;
6455
- (function (StrokeStyle) {
6456
- StrokeStyle["solid"] = "solid";
6457
- StrokeStyle["dashed"] = "dashed";
6458
- StrokeStyle["dotted"] = "dotted";
6459
- })(StrokeStyle || (StrokeStyle = {}));
6460
6519
  var MemorizeKey;
6461
6520
  (function (MemorizeKey) {
6462
6521
  MemorizeKey["basicShape"] = "basicShape";
@@ -6466,10 +6525,10 @@ var MemorizeKey;
6466
6525
  MemorizeKey["UML"] = "UML";
6467
6526
  })(MemorizeKey || (MemorizeKey = {}));
6468
6527
 
6469
- var VectorPenPointerType;
6470
- (function (VectorPenPointerType) {
6471
- VectorPenPointerType["vectorPen"] = "vectorPen";
6472
- })(VectorPenPointerType || (VectorPenPointerType = {}));
6528
+ var VectorLinePointerType;
6529
+ (function (VectorLinePointerType) {
6530
+ VectorLinePointerType["vectorLine"] = "vectorLine";
6531
+ })(VectorLinePointerType || (VectorLinePointerType = {}));
6473
6532
  var VectorLineShape;
6474
6533
  (function (VectorLineShape) {
6475
6534
  VectorLineShape["straight"] = "straight";
@@ -6510,6 +6569,16 @@ const PlaitDrawElement = {
6510
6569
  return false;
6511
6570
  }
6512
6571
  },
6572
+ isCustomGeometryElement: (board, value) => {
6573
+ const options = board.getPluginOptions(WithDrawPluginKey);
6574
+ const customGeometryTypes = options?.customGeometryTypes || [];
6575
+ if (customGeometryTypes.includes(value.type)) {
6576
+ return true;
6577
+ }
6578
+ else {
6579
+ return false;
6580
+ }
6581
+ },
6513
6582
  isShapeElement: (value) => {
6514
6583
  return (PlaitDrawElement.isImage(value) ||
6515
6584
  PlaitDrawElement.isGeometry(value) ||
@@ -6555,10 +6624,11 @@ class GeometryShapeGenerator extends Generator {
6555
6624
  if (shape === BasicShapes.text) {
6556
6625
  return;
6557
6626
  }
6627
+ const fill = getFillByElement(this.board, element);
6558
6628
  const strokeWidth = getStrokeWidthByElement(element);
6559
6629
  const strokeColor = getStrokeColorByElement(this.board, element);
6560
- const fill = getFillByElement(this.board, element);
6561
- const strokeLineDash = getLineDashByElement(element);
6630
+ const strokeStyle = getStrokeStyleByElement(this.board, element);
6631
+ const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
6562
6632
  return drawGeometry(this.board, RectangleClient.inflate(rectangle, -strokeWidth), shape, {
6563
6633
  stroke: strokeColor,
6564
6634
  strokeWidth,
@@ -6615,11 +6685,11 @@ class SingleTextGenerator extends TextGenerator {
6615
6685
  return this.textManages[0];
6616
6686
  }
6617
6687
  constructor(board, element, text, options) {
6618
- super(board, element, [{ key: element.id, text: text, textHeight: element.textHeight }], options);
6688
+ super(board, element, [{ id: element.id, text: text, textHeight: element.textHeight }], options);
6619
6689
  }
6620
6690
  update(element, previousText, currentText, elementG) {
6621
6691
  if (!isMultipleTextGeometry(element)) {
6622
- super.update(element, [{ text: previousText, key: element.id, textHeight: element.textHeight }], [{ text: currentText, key: element.id, textHeight: element.textHeight }], elementG);
6692
+ super.update(element, [{ text: previousText, id: element.id, textHeight: element.textHeight }], [{ text: currentText, id: element.id, textHeight: element.textHeight }], elementG);
6623
6693
  }
6624
6694
  }
6625
6695
  }
@@ -6676,8 +6746,7 @@ class GeometryComponent extends CommonElementFlavour {
6676
6746
  this.textGenerator && this.textGenerator.draw(this.getElementG());
6677
6747
  }
6678
6748
  onContextChanged(value, previous) {
6679
- const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
6680
- if (value.element !== previous.element || isChangeTheme) {
6749
+ if (value.element !== previous.element || value.hasThemeChanged) {
6681
6750
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
6682
6751
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), { selected: this.selected });
6683
6752
  this.lineAutoCompleteGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
@@ -6708,8 +6777,8 @@ class GeometryComponent extends CommonElementFlavour {
6708
6777
  const onTextChange = (element, textManageChangeData, text) => {
6709
6778
  if (textManageChangeData.newText) {
6710
6779
  if (isMultipleTextGeometry(element)) {
6711
- DrawTransforms.setDrawShapeText(this.board, element, {
6712
- key: text.key,
6780
+ DrawTransforms.setDrawTexts(this.board, element, {
6781
+ id: text.id,
6713
6782
  text: textManageChangeData.newText,
6714
6783
  textHeight: textManageChangeData.height
6715
6784
  });
@@ -6880,7 +6949,7 @@ class ArrowLineComponent extends CommonElementFlavour {
6880
6949
  initializeGenerator() {
6881
6950
  this.shapeGenerator = new ArrowLineShapeGenerator(this.board);
6882
6951
  this.activeGenerator = new LineActiveGenerator(this.board);
6883
- this.initializeTextManagesByElement();
6952
+ this.initializeTextManages();
6884
6953
  }
6885
6954
  initialize() {
6886
6955
  this.initializeGenerator();
@@ -6912,13 +6981,11 @@ class ArrowLineComponent extends CommonElementFlavour {
6912
6981
  return boundedElements;
6913
6982
  }
6914
6983
  onContextChanged(value, previous) {
6915
- this.initializeWeakMap();
6916
6984
  const boundedElements = this.getBoundedElements();
6917
6985
  const isBoundedElementsChanged = boundedElements.source !== this.boundedElements.source || boundedElements.target !== this.boundedElements.target;
6918
6986
  this.boundedElements = boundedElements;
6919
- const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
6920
6987
  const linePoints = getArrowLinePoints(this.board, this.element);
6921
- if (value.element !== previous.element || isChangeTheme) {
6988
+ if (value.element !== previous.element || value.hasThemeChanged) {
6922
6989
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
6923
6990
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
6924
6991
  selected: this.selected,
@@ -6946,19 +7013,21 @@ class ArrowLineComponent extends CommonElementFlavour {
6946
7013
  return;
6947
7014
  }
6948
7015
  }
6949
- initializeTextManagesByElement() {
7016
+ initializeTextManages() {
6950
7017
  if (this.element.texts?.length) {
6951
7018
  const textManages = [];
6952
7019
  this.element.texts.forEach((text, index) => {
6953
7020
  const manage = this.createTextManage(text, index);
6954
7021
  textManages.push(manage);
6955
7022
  });
6956
- this.initializeTextManages(textManages);
7023
+ this.getRef().initializeTextManage(textManages);
6957
7024
  }
6958
7025
  }
6959
7026
  drawText() {
6960
7027
  if (this.element.texts?.length) {
6961
- this.getTextManages().forEach((manage, index) => {
7028
+ this.getRef()
7029
+ .getTextManages()
7030
+ .forEach((manage, index) => {
6962
7031
  manage.draw(this.element.texts[index].text);
6963
7032
  this.getElementG().append(manage.g);
6964
7033
  });
@@ -6992,7 +7061,7 @@ class ArrowLineComponent extends CommonElementFlavour {
6992
7061
  return;
6993
7062
  const previousTextsLength = previousTexts.length;
6994
7063
  const currentTextsLength = currentTexts.length;
6995
- const textManages = this.getTextManages();
7064
+ const textManages = this.getRef().getTextManages();
6996
7065
  if (currentTextsLength === previousTextsLength) {
6997
7066
  for (let i = 0; i < previousTextsLength; i++) {
6998
7067
  if (previousTexts[i].text !== currentTexts[i].text) {
@@ -7001,13 +7070,13 @@ class ArrowLineComponent extends CommonElementFlavour {
7001
7070
  }
7002
7071
  }
7003
7072
  else {
7004
- this.destroyTextManages();
7005
- this.initializeTextManagesByElement();
7073
+ this.getRef().destroyTextManage();
7074
+ this.initializeTextManages();
7006
7075
  this.drawText();
7007
7076
  }
7008
7077
  }
7009
7078
  updateTextRectangle() {
7010
- const textManages = this.getTextManages();
7079
+ const textManages = this.getRef().getTextManages();
7011
7080
  textManages.forEach(manage => {
7012
7081
  manage.updateRectangle();
7013
7082
  });
@@ -7015,7 +7084,7 @@ class ArrowLineComponent extends CommonElementFlavour {
7015
7084
  destroy() {
7016
7085
  super.destroy();
7017
7086
  this.activeGenerator.destroy();
7018
- this.destroyTextManages();
7087
+ this.getRef().destroyTextManage();
7019
7088
  }
7020
7089
  }
7021
7090
 
@@ -7038,10 +7107,8 @@ class VectorLineComponent extends CommonElementFlavour {
7038
7107
  super.initialize();
7039
7108
  }
7040
7109
  onContextChanged(value, previous) {
7041
- this.initializeWeakMap();
7042
- const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
7043
7110
  const linePoints = getVectorLinePoints(this.board, this.element);
7044
- if (value.element !== previous.element || isChangeTheme) {
7111
+ if (value.element !== previous.element || value.hasThemeChanged) {
7045
7112
  this.shapeGenerator.processDrawing(this.element, this.getElementG());
7046
7113
  this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
7047
7114
  selected: this.selected,
@@ -7090,7 +7157,7 @@ const withDrawHotkey = (board) => {
7090
7157
  if (hitElement && PlaitDrawElement.isGeometry(hitElement)) {
7091
7158
  if (isMultipleTextGeometry(hitElement)) {
7092
7159
  const hitText = getHitMultipleGeometryText(hitElement, point) ||
7093
- hitElement.texts.find(item => item.key.includes(MultipleTextGeometryCommonTextKeys.content)) ||
7160
+ hitElement.texts.find(item => item.id.includes(GeometryCommonTextKeys.content)) ||
7094
7161
  hitElement.texts[0];
7095
7162
  editText(board, hitElement, hitText);
7096
7163
  }
@@ -7110,13 +7177,14 @@ class TableGenerator extends Generator {
7110
7177
  }
7111
7178
  draw(element, data) {
7112
7179
  const rectangle = RectangleClient.getRectangleByPoints(element.points);
7113
- const strokeLineDash = getLineDashByElement(element);
7114
7180
  const strokeWidth = getStrokeWidthByElement(element);
7115
7181
  const strokeColor = getStrokeColorByElement(this.board, element);
7182
+ const strokeStyle = getStrokeStyleByElement(this.board, element);
7183
+ const strokeLineDash = getStrokeLineDash(strokeStyle, strokeWidth);
7116
7184
  return getEngine(TableSymbols.table).draw(this.board, rectangle, {
7117
7185
  strokeWidth,
7118
7186
  stroke: strokeColor,
7119
- strokeLineDash,
7187
+ strokeLineDash
7120
7188
  }, {
7121
7189
  element: element
7122
7190
  });
@@ -7296,68 +7364,6 @@ const withGeometryCreateByDrawing = (board) => {
7296
7364
  return board;
7297
7365
  };
7298
7366
 
7299
- const buildClipboardData = (board, elements, startPoint) => {
7300
- return elements.map(element => {
7301
- if (PlaitDrawElement.isShapeElement(element)) {
7302
- const points = element.points.map(point => [point[0] - startPoint[0], point[1] - startPoint[1]]);
7303
- return { ...element, points };
7304
- }
7305
- if (PlaitDrawElement.isArrowLine(element)) {
7306
- let source = { ...element.source };
7307
- let target = { ...element.target };
7308
- let points = [...element.points];
7309
- if (element.source.boundId) {
7310
- points[0] = getConnectionPoint(getElementById(board, element.source.boundId), element.source.connection);
7311
- if (!getElementById(board, element.source.boundId, elements)) {
7312
- delete source.boundId;
7313
- delete source.connection;
7314
- }
7315
- }
7316
- if (element.target.boundId) {
7317
- points[points.length - 1] = getConnectionPoint(getElementById(board, element.target.boundId), element.target.connection);
7318
- if (!getElementById(board, element.target.boundId, elements)) {
7319
- delete target.boundId;
7320
- delete target.connection;
7321
- }
7322
- }
7323
- points = points.map(point => [point[0] - startPoint[0], point[1] - startPoint[1]]);
7324
- return { ...element, points, source, target };
7325
- }
7326
- return element;
7327
- });
7328
- };
7329
- const insertClipboardData = (board, elements, startPoint) => {
7330
- const idsMap = {};
7331
- elements.forEach(element => {
7332
- idsMap[element.id] = idCreator();
7333
- });
7334
- elements.forEach(element => {
7335
- element.id = idsMap[element.id];
7336
- if (PlaitDrawElement.isArrowLine(element)) {
7337
- if (element.source.boundId) {
7338
- const boundElement = elements.find(item => [element.source.boundId, idsMap[element.source.boundId]].includes(item.id));
7339
- if (boundElement) {
7340
- element.source.boundId = idsMap[element.source.boundId];
7341
- }
7342
- }
7343
- if (element.target.boundId) {
7344
- const boundElement = elements.find(item => [element.target.boundId, idsMap[element.target.boundId]].includes(item.id));
7345
- if (boundElement) {
7346
- element.target.boundId = idsMap[element.target.boundId];
7347
- }
7348
- }
7349
- }
7350
- if (PlaitDrawElement.isElementByTable(element)) {
7351
- updateRowOrColumnIds(element, 'row');
7352
- updateRowOrColumnIds(element, 'column');
7353
- updateCellIds(element.cells);
7354
- }
7355
- element.points = element.points.map(point => [startPoint[0] + point[0], startPoint[1] + point[1]]);
7356
- Transforms.insertNode(board, element, [board.children.length]);
7357
- });
7358
- Transforms.addSelectionWithTemporaryElements(board, elements);
7359
- };
7360
-
7361
7367
  const withDrawFragment = (baseBoard) => {
7362
7368
  const board = baseBoard;
7363
7369
  const { getDeletedFragment, buildFragment, insertFragment } = board;
@@ -7400,16 +7406,12 @@ const withDrawFragment = (baseBoard) => {
7400
7406
  const selectedElements = [...targetDrawElements, ...boundLineElements];
7401
7407
  const elements = buildClipboardData(board, selectedElements, rectangle ? [rectangle.x, rectangle.y] : [0, 0]);
7402
7408
  const text = getElementsText(selectedElements);
7403
- if (!clipboardContext) {
7404
- clipboardContext = createClipboardContext(WritableClipboardType.elements, elements, text);
7405
- }
7406
- else {
7407
- clipboardContext = addClipboardContext(clipboardContext, {
7408
- text,
7409
- type: WritableClipboardType.elements,
7410
- elements
7411
- });
7412
- }
7409
+ const addition = {
7410
+ text,
7411
+ type: WritableClipboardType.elements,
7412
+ elements: elements
7413
+ };
7414
+ clipboardContext = addOrCreateClipboardContext(clipboardContext, addition);
7413
7415
  }
7414
7416
  return buildFragment(clipboardContext, rectangle, operationType, originData);
7415
7417
  };
@@ -7498,67 +7500,6 @@ const withArrowLineCreateByDraw = (board) => {
7498
7500
  return board;
7499
7501
  };
7500
7502
 
7501
- const withGeometryResize = (board) => {
7502
- let snapG;
7503
- const options = {
7504
- key: 'draw-geometry',
7505
- canResize: () => {
7506
- return true;
7507
- },
7508
- hitTest: (point) => {
7509
- const selectedElements = [...getSelectedGeometryElements(board), ...getSelectedImageElements(board)];
7510
- if (selectedElements.length !== 1 || getSelectedElements(board).length !== 1) {
7511
- return null;
7512
- }
7513
- const target = selectedElements[0];
7514
- if (canResize(board, target)) {
7515
- const rectangle = board.getRectangle(target);
7516
- const handleRef = getHitRectangleResizeHandleRef(board, rectangle, point, target.angle);
7517
- if (handleRef) {
7518
- return {
7519
- element: target,
7520
- handle: handleRef.handle,
7521
- cursorClass: handleRef.cursorClass,
7522
- rectangle
7523
- };
7524
- }
7525
- }
7526
- return null;
7527
- },
7528
- onResize: (resizeRef, resizeState) => {
7529
- resizeState.startPoint = rotateAntiPointsByElement(resizeState.startPoint, resizeRef.element) || resizeState.startPoint;
7530
- resizeState.endPoint = rotateAntiPointsByElement(resizeState.endPoint, resizeRef.element) || resizeState.endPoint;
7531
- snapG?.remove();
7532
- const isFromCorner = isCornerHandle(board, resizeRef.handle);
7533
- const isAspectRatio = resizeState.isShift || PlaitDrawElement.isImage(resizeRef.element);
7534
- const handleIndex = getIndexByResizeHandle(resizeRef.handle);
7535
- const { originPoint, handlePoint } = getResizeOriginPointAndHandlePoint(board, handleIndex, resizeRef.rectangle);
7536
- const resizeSnapRefOptions = getSnapResizingRefOptions(board, resizeRef, resizeState, {
7537
- originPoint,
7538
- handlePoint
7539
- }, isAspectRatio, isFromCorner);
7540
- const resizeSnapRef = getSnapResizingRef(board, [resizeRef.element], resizeSnapRefOptions);
7541
- snapG = resizeSnapRef.snapG;
7542
- PlaitBoard.getElementActiveHost(board).append(snapG);
7543
- let points = resizeSnapRef.activePoints;
7544
- if (PlaitDrawElement.isGeometry(resizeRef.element) && isGeometryIncludeText(resizeRef.element)) {
7545
- const { height: textHeight } = getFirstTextManage(resizeRef.element).getSize();
7546
- DrawTransforms.resizeGeometry(board, points, textHeight, resizeRef.path);
7547
- }
7548
- else {
7549
- points = normalizeShapePoints(points);
7550
- Transforms.setNode(board, { points }, resizeRef.path);
7551
- }
7552
- },
7553
- afterResize: (resizeRef) => {
7554
- snapG?.remove();
7555
- snapG = null;
7556
- }
7557
- };
7558
- withResize(board, options);
7559
- return board;
7560
- };
7561
-
7562
7503
  const withArrowLineResize = (board) => {
7563
7504
  let elbowLineIndex;
7564
7505
  let elbowLineDeleteCount;
@@ -7772,7 +7713,7 @@ const withArrowLineText = (board) => {
7772
7713
  }
7773
7714
  else {
7774
7715
  const ratio = getRatioByPoint(points, point);
7775
- const textMemory = getMemorizedLatest('line')?.text || {};
7716
+ const textMemory = getMemorizedLatest('arrow-line')?.text || {};
7776
7717
  texts.push({
7777
7718
  text: buildText(LINE_TEXT, undefined, textMemory),
7778
7719
  position: ratio,
@@ -8022,7 +7963,8 @@ const withDrawRotate = (board) => {
8022
7963
  let needCustomActiveRectangle = false;
8023
7964
  const canRotate = () => {
8024
7965
  const elements = getSelectedElements(board);
8025
- return elements.length > 0 && elements.every(el => PlaitDrawElement.isGeometry(el) || PlaitDrawElement.isImage(el));
7966
+ return (elements.length > 0 &&
7967
+ elements.every(el => PlaitDrawElement.isDrawElement(el) || PlaitDrawElement.isCustomGeometryElement(board, el)));
8026
7968
  };
8027
7969
  board.pointerDown = (event) => {
8028
7970
  if (!canRotate() || PlaitBoard.isReadonly(board) || PlaitBoard.hasBeenTextEditing(board) || !isMainPointer(event)) {
@@ -8185,7 +8127,7 @@ class TableComponent extends CommonElementFlavour {
8185
8127
  const table = this.board.buildTable(this.element);
8186
8128
  table.cells.forEach(item => {
8187
8129
  if (PlaitTableElement.isVerticalText(item)) {
8188
- const textManage = getTextManage(this.board, item.id);
8130
+ const textManage = getTextManageByCell(this.board, item);
8189
8131
  if (textManage) {
8190
8132
  const engine = getEngine(TableSymbols.table);
8191
8133
  const rectangle = engine.getTextRectangle(this.element, { key: item.id, board: this.board });
@@ -8200,7 +8142,7 @@ class TableComponent extends CommonElementFlavour {
8200
8142
  .filter(item => isCellIncludeText(item))
8201
8143
  .map(item => {
8202
8144
  return {
8203
- key: item.id,
8145
+ id: item.id,
8204
8146
  text: item.text,
8205
8147
  textHeight: item.textHeight,
8206
8148
  board: this.board
@@ -8213,12 +8155,12 @@ class TableComponent extends CommonElementFlavour {
8213
8155
  onChange: (value, data, text) => {
8214
8156
  const path = PlaitBoard.findPath(this.board, value);
8215
8157
  if (data.newText) {
8216
- DrawTransforms.setTableText(this.board, path, text.key, data.newText, data.height);
8158
+ DrawTransforms.setTableText(this.board, path, text.id, data.newText, data.height);
8217
8159
  }
8218
8160
  data.operations && memorizeLatestText(value, data.operations);
8219
8161
  },
8220
8162
  getRenderRectangle: (value, text) => {
8221
- const cell = getCellWithPoints(this.board, value, text.key);
8163
+ const cell = getCellWithPoints(this.board, value, text.id);
8222
8164
  if (PlaitTableElement.isVerticalText(cell)) {
8223
8165
  const cellRectangle = RectangleClient.getRectangleByPoints(cell.points);
8224
8166
  const strokeWidth = getStrokeWidthByElement(cell);
@@ -8239,8 +8181,7 @@ class TableComponent extends CommonElementFlavour {
8239
8181
  this.textGenerator.initialize();
8240
8182
  }
8241
8183
  onContextChanged(value, previous) {
8242
- const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
8243
- if (value.element !== previous.element || isChangeTheme) {
8184
+ if (value.element !== previous.element || value.hasThemeChanged) {
8244
8185
  const previousSelectedCells = getSelectedCells(previous.element);
8245
8186
  if (previousSelectedCells?.length) {
8246
8187
  clearSelectedCells(previous.element);
@@ -8637,57 +8578,57 @@ const withSwimlane = (board) => {
8637
8578
  return withSwimlaneCreateByDrawing(withSwimlaneCreateByDrag(board));
8638
8579
  };
8639
8580
 
8640
- const withVectorPenCreateByDraw = (board) => {
8581
+ const withVectorLineCreateByDraw = (board) => {
8641
8582
  const { pointerDown, pointerMove, dblClick, globalKeyDown } = board;
8642
8583
  let lineShapeG = null;
8643
8584
  let temporaryElement = null;
8644
- let vectorPenRef;
8585
+ let vectorLineRef;
8645
8586
  const vectorLineComplete = () => {
8646
- if (vectorPenRef) {
8587
+ if (vectorLineRef) {
8647
8588
  clearSelectedElement(board);
8648
- if (vectorPenRef?.element) {
8649
- addSelectedElement(board, vectorPenRef?.element);
8589
+ if (vectorLineRef?.element) {
8590
+ addSelectedElement(board, vectorLineRef?.element);
8650
8591
  }
8651
8592
  }
8652
8593
  PlaitBoard.getBoardContainer(board).classList.remove(`vector-line-closed`);
8653
8594
  lineShapeG?.remove();
8654
8595
  lineShapeG = null;
8655
- vectorPenRef = null;
8596
+ vectorLineRef = null;
8656
8597
  temporaryElement = null;
8657
8598
  };
8658
8599
  board.pointerDown = (event) => {
8659
- const penPointers = getVectorPenPointers();
8660
- const isVectorPenPointer = PlaitBoard.isInPointer(board, penPointers);
8661
- if (isVectorPenPointer && !vectorPenRef) {
8662
- vectorPenRef = { shape: VectorLineShape.straight };
8600
+ const penPointers = getVectorLinePointers();
8601
+ const isVectorLinePointer = PlaitBoard.isInPointer(board, penPointers);
8602
+ if (isVectorLinePointer && !vectorLineRef) {
8603
+ vectorLineRef = { shape: VectorLineShape.straight };
8663
8604
  }
8664
- if (!PlaitBoard.isReadonly(board) && vectorPenRef && isDrawingMode(board)) {
8605
+ if (!PlaitBoard.isReadonly(board) && vectorLineRef && isDrawingMode(board)) {
8665
8606
  let point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
8666
8607
  if (!temporaryElement) {
8667
- vectorPenRef = {
8668
- ...vectorPenRef,
8608
+ vectorLineRef = {
8609
+ ...vectorLineRef,
8669
8610
  start: point
8670
8611
  };
8671
8612
  }
8672
8613
  else {
8673
- if (!vectorPenRef.element) {
8674
- vectorPenRef.element = temporaryElement;
8675
- Transforms.insertNode(board, vectorPenRef.element, [board.children.length]);
8614
+ if (!vectorLineRef.element) {
8615
+ vectorLineRef.element = temporaryElement;
8616
+ Transforms.insertNode(board, vectorLineRef.element, [board.children.length]);
8676
8617
  }
8677
8618
  else {
8678
- let points = vectorPenRef.element.points;
8679
- const isClosed = distanceBetweenPointAndPoint(...point, ...vectorPenRef.start) <= LINE_HIT_GEOMETRY_BUFFER;
8619
+ let points = vectorLineRef.element.points;
8620
+ const isClosed = distanceBetweenPointAndPoint(...point, ...vectorLineRef.start) <= LINE_HIT_GEOMETRY_BUFFER;
8680
8621
  if (isClosed) {
8681
- point = vectorPenRef.start;
8622
+ point = vectorLineRef.start;
8682
8623
  }
8683
- if (vectorPenRef.path) {
8624
+ if (vectorLineRef.path) {
8684
8625
  const lastPoint = points[points.length - 1];
8685
8626
  const distance = distanceBetweenPointAndPoint(...point, ...lastPoint);
8686
8627
  if (distance > 2) {
8687
- Transforms.setNode(board, { points: [...points, point] }, vectorPenRef.path);
8628
+ Transforms.setNode(board, { points: [...points, point] }, vectorLineRef.path);
8688
8629
  }
8689
8630
  }
8690
- vectorPenRef.element = getElementById(board, vectorPenRef.element.id);
8631
+ vectorLineRef.element = getElementById(board, vectorLineRef.element.id);
8691
8632
  if (isClosed) {
8692
8633
  vectorLineComplete();
8693
8634
  }
@@ -8701,33 +8642,33 @@ const withVectorPenCreateByDraw = (board) => {
8701
8642
  lineShapeG = createG();
8702
8643
  let movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
8703
8644
  const pointer = PlaitBoard.getPointer(board);
8704
- if (pointer !== VectorPenPointerType.vectorPen) {
8645
+ if (pointer !== VectorLinePointerType.vectorLine) {
8705
8646
  vectorLineComplete();
8706
8647
  }
8707
- if (vectorPenRef && vectorPenRef.start) {
8708
- let drawPoints = [vectorPenRef.start];
8709
- if (vectorPenRef.element) {
8710
- drawPoints = [vectorPenRef.start, ...vectorPenRef.element.points];
8711
- const path = PlaitBoard.findPath(board, vectorPenRef.element);
8712
- vectorPenRef.path = path;
8648
+ if (vectorLineRef && vectorLineRef.start) {
8649
+ let drawPoints = [vectorLineRef.start];
8650
+ if (vectorLineRef.element) {
8651
+ drawPoints = [vectorLineRef.start, ...vectorLineRef.element.points];
8652
+ const path = PlaitBoard.findPath(board, vectorLineRef.element);
8653
+ vectorLineRef.path = path;
8713
8654
  }
8714
- const distance = distanceBetweenPointAndPoint(...movingPoint, ...vectorPenRef.start);
8655
+ const distance = distanceBetweenPointAndPoint(...movingPoint, ...vectorLineRef.start);
8715
8656
  if (distance <= LINE_HIT_GEOMETRY_BUFFER) {
8716
- movingPoint = vectorPenRef.start;
8657
+ movingPoint = vectorLineRef.start;
8717
8658
  PlaitBoard.getBoardContainer(board).classList.add(`vector-line-closed`);
8718
8659
  }
8719
8660
  else {
8720
8661
  PlaitBoard.getBoardContainer(board).classList.remove(`vector-line-closed`);
8721
8662
  }
8722
- temporaryElement = vectorLineCreating(board, vectorPenRef.shape, drawPoints, movingPoint, lineShapeG);
8663
+ temporaryElement = vectorLineCreating(board, vectorLineRef.shape, drawPoints, movingPoint, lineShapeG);
8723
8664
  }
8724
8665
  pointerMove(event);
8725
8666
  };
8726
8667
  board.dblClick = (event) => {
8727
8668
  if (!PlaitBoard.isReadonly(board)) {
8728
- if (vectorPenRef) {
8729
- if (vectorPenRef.path) {
8730
- Transforms.setNode(board, { points: vectorPenRef?.element?.points }, vectorPenRef.path);
8669
+ if (vectorLineRef) {
8670
+ if (vectorLineRef.path) {
8671
+ Transforms.setNode(board, { points: vectorLineRef?.element?.points }, vectorLineRef.path);
8731
8672
  }
8732
8673
  vectorLineComplete();
8733
8674
  BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
@@ -8739,9 +8680,9 @@ const withVectorPenCreateByDraw = (board) => {
8739
8680
  if (!PlaitBoard.isReadonly(board)) {
8740
8681
  const isEsc = isKeyHotkey('esc', event);
8741
8682
  const isV = isKeyHotkey('v', event);
8742
- if ((isEsc || isV) && vectorPenRef) {
8743
- if (vectorPenRef.path) {
8744
- Transforms.setNode(board, { points: vectorPenRef.element?.points }, vectorPenRef.path);
8683
+ if ((isEsc || isV) && vectorLineRef) {
8684
+ if (vectorLineRef.path) {
8685
+ Transforms.setNode(board, { points: vectorLineRef.element?.points }, vectorLineRef.path);
8745
8686
  }
8746
8687
  vectorLineComplete();
8747
8688
  if (isV) {
@@ -8783,7 +8724,7 @@ const withVectorLineResize = (board) => {
8783
8724
  let handleIndex = resizeRef.handleIndex;
8784
8725
  if (resizeRef.handle === LineResizeHandle.source || resizeRef.handle === LineResizeHandle.target) {
8785
8726
  points[handleIndex] = resizeState.endPoint;
8786
- if (isClosedVectorLine(resizeRef.element)) {
8727
+ if (isClosedPoints(resizeRef.element.points)) {
8787
8728
  points[points.length - 1] = resizeState.endPoint;
8788
8729
  }
8789
8730
  else {
@@ -8810,7 +8751,7 @@ const withVectorLineResize = (board) => {
8810
8751
  };
8811
8752
 
8812
8753
  const withDraw = (board) => {
8813
- const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment, getHitElement } = board;
8754
+ const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment, getOneHitElement } = board;
8814
8755
  board.drawElement = (context) => {
8815
8756
  if (PlaitDrawElement.isGeometry(context.element)) {
8816
8757
  if (PlaitDrawElement.isUML(context.element)) {
@@ -8866,12 +8807,12 @@ const withDraw = (board) => {
8866
8807
  }
8867
8808
  return isHit(element, point);
8868
8809
  };
8869
- board.getHitElement = elements => {
8870
- const isDrawElements = elements.every(item => PlaitDrawElement.isDrawElement(item));
8871
- if (isDrawElements) {
8872
- return getDrawHitElement(board, elements);
8810
+ board.getOneHitElement = elements => {
8811
+ const isAllDrawElements = elements.every(item => PlaitDrawElement.isDrawElement(item));
8812
+ if (isAllDrawElements) {
8813
+ return getHitDrawElement(board, elements);
8873
8814
  }
8874
- return getHitElement(elements);
8815
+ return getOneHitElement(elements);
8875
8816
  };
8876
8817
  board.isInsidePoint = (element, point) => {
8877
8818
  const result = isHitElementInside(board, element, point);
@@ -8925,12 +8866,12 @@ const withDraw = (board) => {
8925
8866
  });
8926
8867
  return getRelatedFragment([...elements, ...activeLines], originData);
8927
8868
  };
8928
- return withSwimlane(withTable(withDrawResize(withVectorPenCreateByDraw(withArrowLineAutoCompleteReaction(withArrowLineBoundReaction(withVectorLineResize(withArrowLineResize(withArrowLineTextMove(withArrowLineText(withGeometryResize(withDrawRotate(withArrowLineCreateByDraw(withArrowLineAutoComplete(withGeometryCreateByDrag(withGeometryCreateByDrawing(withDrawFragment(withDrawHotkey(board))))))))))))))))));
8869
+ return withSwimlane(withTable(withDrawResize(withVectorLineCreateByDraw(withArrowLineAutoCompleteReaction(withArrowLineBoundReaction(withVectorLineResize(withArrowLineResize(withArrowLineTextMove(withArrowLineText(withDrawRotate(withArrowLineCreateByDraw(withArrowLineAutoComplete(withGeometryCreateByDrag(withGeometryCreateByDrawing(withDrawFragment(withDrawHotkey(board)))))))))))))))));
8929
8870
  };
8930
8871
 
8931
8872
  /**
8932
8873
  * Generated bundle index. Do not edit.
8933
8874
  */
8934
8875
 
8935
- export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, 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, VectorLineComponent, VectorLineShape, VectorPenPointerType, WithArrowLineAutoCompletePluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$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, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePoints, getVectorPenPointers, handleArrowLineCreating, hasIllegalElbowPoint, insertElement, isCellIncludeText, isClosedVectorLine, isDrawElementClosed, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, 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, vectorLineCreating, withArrowLineAutoComplete, withDraw };
8876
+ export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFill, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedPoints, isCustomGeometryClosed, isDrawElementClosed, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectArrowLine, isSingleSelectElementByTable, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
8936
8877
  //# sourceMappingURL=plait-draw.mjs.map