@plait/draw 0.86.0 → 0.87.0-next.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.
@@ -1,7 +1,7 @@
1
1
  import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, createDebugGenerator, Point, createG, arrowPoints, createPath, distanceBetweenPointAndPoint, drawLinearPath, rotate, catmullRomFitting, PlaitBoard, setStrokeLinecap, findElements, createMask, createRect, getNearestPointBetweenPointAndArc, setPathStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, getI18nValue, SELECTION_RECTANGLE_CLASS_NAME, toActivePointFromViewBoxPoint, toActiveRectangleFromViewBoxRectangle, drawRectangle, isSelectionMoving, rgbaToHEX, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, getRectangleByElements, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, getEllipseTangentSlope, getVectorFromPointAndSlope, getNearestPointBetweenPointAndEllipse, isPointInEllipse, isPointInRoundRectangle, drawRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, getNearestPointBetweenPointAndDiscreteSegments, getNearestPointBetweenPointAndSegment, Path, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, toActivePoint, temporaryDisableSelection, toScreenPointFromActivePoint, PRESS_AND_MOVE_BUFFER, CursorClass, isHorizontalDirection, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
- import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, Generator, getPointByVectorComponent, getStrokeLineDash, StrokeStyle, getPointOnPolyline, buildText, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, RESIZE_HANDLE_DIAMETER, drawPrimaryHandle, drawFillPrimaryHandle, PRIMARY_COLOR, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_SIZE, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, isCornerHandle, getIndexByResizeHandle, withResize, getSymmetricHandleIndex, getResizeHandlePointByIndex, drawHandle, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, CommonElementFlavour, createActiveGenerator, hasResizeHandle, ActiveGenerator, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, getDirectionByIndex, moveXOfPoint, getXDistanceBetweenPoint, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
3
- import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
2
+ import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, Generator, getElementSize, DEFAULT_FONT_FAMILY, getPointByVectorComponent, getStrokeLineDash, StrokeStyle, getPointOnPolyline, buildText, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, RESIZE_HANDLE_DIAMETER, drawPrimaryHandle, drawFillPrimaryHandle, PRIMARY_COLOR, measureElement, getFirstTextManage, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_SIZE, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, isCornerHandle, getIndexByResizeHandle, withResize, getSymmetricHandleIndex, getResizeHandlePointByIndex, drawHandle, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, CommonElementFlavour, createActiveGenerator, hasResizeHandle, ActiveGenerator, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, getDirectionByIndex, moveXOfPoint, getXDistanceBetweenPoint, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
4
3
  import { pointsOnBezierCurves } from 'points-on-curve';
4
+ import { DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
5
5
  import { Editor, Node } from 'slate';
6
6
  import { isKeyHotkey } from 'is-hotkey';
7
7
 
@@ -545,7 +545,7 @@ class TextGenerator {
545
545
  removedTexts.forEach(item => {
546
546
  const textManage = getTextManage(this.board, element, item);
547
547
  const index = this.textManages.findIndex(value => value === textManage);
548
- if (index > -1 && item.text && item.textHeight) {
548
+ if (index > -1 && item.text) {
549
549
  this.textManages.splice(index, 1);
550
550
  }
551
551
  textManage?.destroy();
@@ -591,9 +591,9 @@ class TextGenerator {
591
591
  getRectangle(text) {
592
592
  const getRectangle = getEngine(this.shape).getTextRectangle;
593
593
  if (getRectangle) {
594
- return getRectangle(this.element, text);
594
+ return getRectangle(this.board, this.element, text);
595
595
  }
596
- return getTextRectangle(this.element);
596
+ return getTextRectangle$1(this.board, this.element);
597
597
  }
598
598
  getMaxWidth(text) {
599
599
  return this.options.getMaxWidth ? this.options.getMaxWidth() : this.getRectangle(text).width;
@@ -754,7 +754,7 @@ function updateCellIds(cells) {
754
754
  });
755
755
  }
756
756
  function isCellIncludeText(cell) {
757
- return cell.text && cell.textHeight;
757
+ return cell.text;
758
758
  }
759
759
  function getCellsRectangle(board, element, cells) {
760
760
  const cellsWithPoints = getCellsWithPoints(board, element);
@@ -771,7 +771,6 @@ const createCell = (rowId, columnId, text = null) => {
771
771
  columnId
772
772
  };
773
773
  if (text !== null) {
774
- cell['textHeight'] = TEXT_DEFAULT_HEIGHT;
775
774
  cell['text'] = {
776
775
  children: [{ text }],
777
776
  align: Alignment.center
@@ -823,7 +822,7 @@ const getMemorizeKey = (element) => {
823
822
  };
824
823
  const getLineMemorizedLatest = () => {
825
824
  const properties = getMemorizedLatest(MemorizeKey.arrowLine);
826
- return { ...properties } || {};
825
+ return { ...properties };
827
826
  };
828
827
  const getMemorizedLatestByPointer = (pointer) => {
829
828
  let memorizeKey = '';
@@ -836,15 +835,15 @@ const getMemorizedLatestByPointer = (pointer) => {
836
835
  else {
837
836
  memorizeKey = MemorizeKey.flowchart;
838
837
  }
839
- const properties = { ...getMemorizedLatest(memorizeKey) } || {};
840
- const textProperties = { ...properties.text } || {};
838
+ const properties = { ...getMemorizedLatest(memorizeKey) };
839
+ const textProperties = { ...properties.text };
841
840
  delete properties.text;
842
841
  return { textProperties, geometryProperties: properties };
843
842
  };
844
843
  const memorizeLatestText = (element, operations) => {
845
844
  const memorizeKey = getMemorizeKey(element);
846
845
  let textMemory = getMemorizedLatest(memorizeKey)?.text || {};
847
- const setNodeOperation = operations.find(operation => operation.type === 'set_node');
846
+ const setNodeOperation = operations.find((operation) => operation.type === 'set_node');
848
847
  if (setNodeOperation) {
849
848
  const { properties, newProperties } = setNodeOperation;
850
849
  for (const key in newProperties) {
@@ -1320,6 +1319,15 @@ class ArrowLineShapeGenerator extends Generator {
1320
1319
  }
1321
1320
  }
1322
1321
 
1322
+ const getTextSize = (board, text, maxWidth) => {
1323
+ const textSize = getElementSize(board, text, { fontSize: DEFAULT_FONT_SIZE, fontFamily: DEFAULT_FONT_FAMILY }, maxWidth);
1324
+ const normalizedTextSize = normalizeWidthAndHeight(textSize);
1325
+ return normalizedTextSize;
1326
+ };
1327
+ const normalizeWidthAndHeight = (textSize) => {
1328
+ return { ...textSize, width: textSize.width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : textSize.width };
1329
+ };
1330
+
1323
1331
  const createArrowLineElement = (shape, points, source, target, texts, options) => {
1324
1332
  return {
1325
1333
  id: idCreator(),
@@ -1434,11 +1442,12 @@ const getArrowLineTextRectangle = (board, element, index) => {
1434
1442
  const text = element.texts[index];
1435
1443
  const elbowPoints = getArrowLinePoints(board, element);
1436
1444
  const point = getPointOnPolyline(elbowPoints, text.position);
1445
+ const textSize = getTextSize(board, text.text);
1437
1446
  return {
1438
- x: point[0] - text.width / 2,
1439
- y: point[1] - text.height / 2,
1440
- width: text.width,
1441
- height: text.height
1447
+ x: point[0] - textSize.width / 2,
1448
+ y: point[1] - textSize.height / 2,
1449
+ width: textSize.width,
1450
+ height: textSize.height
1442
1451
  };
1443
1452
  };
1444
1453
  const getArrowLines = (board) => {
@@ -1518,13 +1527,14 @@ const getHitArrowLineTextIndex = (board, element, point) => {
1518
1527
  if (!texts.length)
1519
1528
  return -1;
1520
1529
  const points = getArrowLinePoints(board, element);
1521
- return texts.findIndex(text => {
1530
+ return texts.findIndex((text) => {
1522
1531
  const center = getPointOnPolyline(points, text.position);
1532
+ const textSize = getTextSize(board, text.text);
1523
1533
  const rectangle = {
1524
- x: center[0] - text.width / 2,
1525
- y: center[1] - text.height / 2,
1526
- width: text.width,
1527
- height: text.height
1534
+ x: center[0] - textSize.width / 2,
1535
+ y: center[1] - textSize.height / 2,
1536
+ width: textSize.width,
1537
+ height: textSize.height
1528
1538
  };
1529
1539
  return RectangleClient.isHit(rectangle, RectangleClient.getRectangleByPoints([point, point]));
1530
1540
  });
@@ -1557,27 +1567,24 @@ const buildDefaultTextsByShape = (shape) => {
1557
1567
  const memorizedLatest = getMemorizedLatestByPointer(shape);
1558
1568
  const textProperties = { ...memorizedLatest.textProperties };
1559
1569
  const alignment = textProperties?.align;
1560
- const textHeight = textProperties?.textHeight || DefaultTextProperty.height;
1561
1570
  delete textProperties?.align;
1562
- delete textProperties?.textHeight;
1563
1571
  const defaultTexts = getDefaultGeometryProperty(shape)?.texts || [];
1564
1572
  const textKeys = getMultipleTextGeometryTextKeys(shape);
1565
1573
  return (textKeys || []).map((textKey) => {
1566
1574
  const text = defaultTexts?.find((item) => item?.key === textKey);
1567
1575
  return {
1568
1576
  id: textKey,
1569
- text: buildText(text?.text || '', alignment || text?.align || Alignment.center, textProperties),
1570
- textHeight: textHeight
1577
+ text: buildText(text?.text || '', alignment || text?.align || Alignment.center, textProperties)
1571
1578
  };
1572
1579
  });
1573
1580
  };
1574
- const getHitMultipleGeometryText = (element, point) => {
1581
+ const getHitMultipleGeometryText = (board, element, point) => {
1575
1582
  const engine = getEngine(element.shape);
1576
1583
  const rectangle = RectangleClient.getRectangleByPoints([point, point]);
1577
1584
  let hitText;
1578
1585
  if (engine.getTextRectangle) {
1579
- hitText = element.texts.find(text => {
1580
- const textRectangle = engine.getTextRectangle(element, { id: text.id });
1586
+ hitText = element.texts.find((text) => {
1587
+ const textRectangle = engine.getTextRectangle(board, element, { id: text.id });
1581
1588
  return RectangleClient.isHit(rectangle, textRectangle);
1582
1589
  });
1583
1590
  }
@@ -1811,28 +1818,22 @@ const CloudEngine = {
1811
1818
  getConnectorPoints(rectangle) {
1812
1819
  return RectangleClient.getEdgeCenterPoints(rectangle);
1813
1820
  },
1814
- getTextRectangle(element) {
1821
+ getTextRectangle: (board, element) => {
1815
1822
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
1816
1823
  const strokeWidth = getStrokeWidthByElement(element);
1817
- const height = element.textHeight;
1818
1824
  const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
1819
1825
  const width = originWidth / 1.5;
1826
+ const text = element.text;
1827
+ const textSize = getTextSize(board, text, width);
1820
1828
  return {
1821
- height,
1829
+ height: textSize.height,
1822
1830
  width: width > 0 ? width : 0,
1823
1831
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
1824
- y: elementRectangle.y + elementRectangle.height / 6 + ((elementRectangle.height * 4) / 6 - height) / 2
1832
+ y: elementRectangle.y + elementRectangle.height / 6 + ((elementRectangle.height * 4) / 6 - textSize.height) / 2
1825
1833
  };
1826
1834
  }
1827
1835
  };
1828
1836
 
1829
- const isTextExceedingBounds = (geometry) => {
1830
- const client = RectangleClient.getRectangleByPoints(geometry.points);
1831
- if (geometry.textHeight && geometry.textHeight > client.height) {
1832
- return true;
1833
- }
1834
- return false;
1835
- };
1836
1837
  const isHitArrowLineText = (board, element, point) => {
1837
1838
  return getHitArrowLineTextIndex(board, element, point) !== -1;
1838
1839
  };
@@ -1854,31 +1855,31 @@ const isHitVectorLine = (board, element, point) => {
1854
1855
  return isHitPolyLine(points, point);
1855
1856
  }
1856
1857
  };
1857
- const isRectangleHitElementText = (element, rectangle) => {
1858
+ const isRectangleHitElementText = (board, element, rectangle) => {
1858
1859
  const engine = getEngine(element.shape);
1859
1860
  if (isMultipleTextGeometry(element)) {
1860
1861
  const texts = element.texts;
1861
1862
  return texts.some((item) => {
1862
- const textClient = engine.getTextRectangle(element, { id: item.id });
1863
+ const textClient = engine.getTextRectangle(board, element, { id: item.id });
1863
1864
  return isRectangleHitRotatedPoints(rectangle, RectangleClient.getCornerPoints(textClient), element.angle);
1864
1865
  });
1865
1866
  }
1866
1867
  else {
1867
- const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
1868
+ const textClient = engine.getTextRectangle ? engine.getTextRectangle(board, element) : getTextRectangle$1(board, element);
1868
1869
  return isRectangleHitRotatedPoints(rectangle, RectangleClient.getCornerPoints(textClient), element.angle);
1869
1870
  }
1870
1871
  };
1871
- const isHitElementText = (element, point) => {
1872
+ const isHitElementText = (board, element, point) => {
1872
1873
  const engine = getEngine(element.shape);
1873
1874
  if (isMultipleTextGeometry(element)) {
1874
1875
  const texts = element.texts;
1875
1876
  return texts.some((item) => {
1876
- const textClient = engine.getTextRectangle(element, { id: item.id });
1877
+ const textClient = engine.getTextRectangle(board, element, { id: item.id });
1877
1878
  return RectangleClient.isPointInRectangle(textClient, point);
1878
1879
  });
1879
1880
  }
1880
1881
  else {
1881
- const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
1882
+ const textClient = engine.getTextRectangle ? engine.getTextRectangle(board, element) : getTextRectangle$1(board, element);
1882
1883
  return RectangleClient.isPointInRectangle(textClient, point);
1883
1884
  }
1884
1885
  };
@@ -1896,7 +1897,7 @@ const isRectangleHitDrawElement = (board, element, selection) => {
1896
1897
  if (isHitElement) {
1897
1898
  return isHitElement;
1898
1899
  }
1899
- return !isEmptyTextElement(element) && isRectangleHitElementText(element, rangeRectangle);
1900
+ return !isEmptyTextElement(element) && isRectangleHitElementText(board, element, rangeRectangle);
1900
1901
  }
1901
1902
  if (PlaitDrawElement.isImage(element)) {
1902
1903
  return isRectangleHitRotatedElement(board, rangeRectangle, element);
@@ -1991,13 +1992,13 @@ const isHitDrawElement = (board, element, point, isStrict = true) => {
1991
1992
  }
1992
1993
  const engine = getEngine(getElementShape(element));
1993
1994
  if (PlaitDrawElement.isText(element)) {
1994
- const textClient = getTextRectangle(element);
1995
+ const textClient = getTextRectangle$1(board, element);
1995
1996
  return RectangleClient.isPointInRectangle(textClient, point);
1996
1997
  }
1997
1998
  if (!!isStrict && isEmptyTextElement(element) && !isFilledDrawElement(board, element)) {
1998
1999
  return false;
1999
2000
  }
2000
- const isHitText = isHitElementText(element, point);
2001
+ const isHitText = isHitElementText(board, element, point);
2001
2002
  return isHitText || engine.isInsidePoint(rectangle, point);
2002
2003
  }
2003
2004
  if (PlaitDrawElement.isImage(element)) {
@@ -2031,7 +2032,7 @@ const isHitElementInside = (board, element, point) => {
2031
2032
  return isHitInside;
2032
2033
  }
2033
2034
  if (engine.getTextRectangle) {
2034
- const isHitText = isHitElementText(element, point);
2035
+ const isHitText = isHitElementText(board, element, point);
2035
2036
  if (isHitText) {
2036
2037
  return isHitText;
2037
2038
  }
@@ -2050,16 +2051,25 @@ const isHitElementInside = (board, element, point) => {
2050
2051
  return null;
2051
2052
  };
2052
2053
 
2053
- const getTextRectangle = (element) => {
2054
+ const getTextRectangle$1 = (board, element) => {
2055
+ const isAutoSize = PlaitDrawElement.isText(element) ? element.autoSize : false;
2054
2056
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
2055
2057
  const strokeWidth = getStrokeWidthByElement(element);
2056
- const height = element.textHeight;
2057
2058
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
2059
+ const textSize = getTextSize(board, element.text, isAutoSize ? GeometryThreshold.defaultTextMaxWidth : width);
2060
+ if (isAutoSize) {
2061
+ return {
2062
+ height: textSize.height,
2063
+ width: textSize.width,
2064
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
2065
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
2066
+ };
2067
+ }
2058
2068
  return {
2059
- height,
2069
+ height: textSize.height,
2060
2070
  width: width > 0 ? width : 0,
2061
2071
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
2062
- y: elementRectangle.y + (elementRectangle.height - height) / 2
2072
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
2063
2073
  };
2064
2074
  };
2065
2075
  const getStrokeWidthByElement = (element) => {
@@ -2492,11 +2502,11 @@ class SingleTextGenerator extends TextGenerator {
2492
2502
  return this.textManages[0];
2493
2503
  }
2494
2504
  constructor(board, element, text, options) {
2495
- super(board, element, [{ id: element.id, text: text, textHeight: element.textHeight }], options);
2505
+ super(board, element, [{ id: element.id, text: text }], options);
2496
2506
  }
2497
2507
  update(element, previousText, currentText, elementG) {
2498
2508
  if (!isMultipleTextGeometry(element)) {
2499
- super.update(element, [{ text: previousText, id: element.id, textHeight: element.textHeight }], [{ text: currentText, id: element.id, textHeight: element.textHeight }], elementG);
2509
+ super.update(element, [{ text: previousText, id: element.id }], [{ text: currentText, id: element.id }], elementG);
2500
2510
  }
2501
2511
  }
2502
2512
  }
@@ -2596,13 +2606,8 @@ const createUMLClassOrInterfaceGeometryElement = (board, shape, points) => {
2596
2606
  };
2597
2607
  };
2598
2608
  const buildTableCellsForGeometry = (board, rows, columns, shape) => {
2599
- const memorizedLatest = getMemorizedLatestByPointer(shape);
2600
2609
  const cellCount = rows.length * columns.length;
2601
2610
  const defaultTexts = getDefaultGeometryProperty(shape)?.texts || [];
2602
- const textHeights = defaultTexts.map((textItem) => {
2603
- return getTextShapeProperty(board, textItem.text || getDefaultGeometryText(board), memorizedLatest.textProperties['font-size'])
2604
- .height;
2605
- });
2606
2611
  return new Array(cellCount).fill('').map((item, index) => {
2607
2612
  const rowIndex = Math.floor(index / columns.length);
2608
2613
  const columnIndex = index % columns.length;
@@ -2610,7 +2615,6 @@ const buildTableCellsForGeometry = (board, rows, columns, shape) => {
2610
2615
  id: idCreator(),
2611
2616
  rowId: rows[rowIndex].id,
2612
2617
  columnId: columns[columnIndex].id,
2613
- textHeight: textHeights[index],
2614
2618
  text: {
2615
2619
  children: [
2616
2620
  {
@@ -2634,23 +2638,19 @@ const createGeometryElement = (shape, points, text, options = {}, textProperties
2634
2638
  const createGeometryElementWithText = (shape, points, text, options = {}, textProperties = {}) => {
2635
2639
  let textOptions = {};
2636
2640
  let alignment = Alignment.center;
2637
- let textHeight = DefaultTextProperty.height;
2638
2641
  if (shape === BasicShapes.text) {
2639
2642
  textOptions = { autoSize: true };
2640
2643
  alignment = undefined;
2641
2644
  }
2642
2645
  textProperties = { ...textProperties };
2643
2646
  textProperties?.align && (alignment = textProperties?.align);
2644
- textProperties?.textHeight && (textHeight = textProperties?.textHeight);
2645
2647
  delete textProperties?.align;
2646
- delete textProperties?.textHeight;
2647
2648
  return {
2648
2649
  id: idCreator(),
2649
2650
  type: 'geometry',
2650
2651
  shape,
2651
2652
  angle: 0,
2652
2653
  opacity: 1,
2653
- textHeight,
2654
2654
  text: buildText(text, alignment, textProperties),
2655
2655
  points,
2656
2656
  ...textOptions,
@@ -2743,17 +2743,14 @@ const getDefaultTextPoints = (board, centerPoint, fontSize) => {
2743
2743
  const property = getTextShapeProperty(board, DefaultTextProperty.text, fontSize);
2744
2744
  return RectangleClient.getPoints(RectangleClient.getRectangleByCenterPoint(centerPoint, property.width, property.height));
2745
2745
  };
2746
- const createTextElement = (board, points, text, textHeight) => {
2746
+ const createTextElement = (board, points, text) => {
2747
2747
  const memorizedLatest = getMemorizedLatestByPointer(BasicShapes.text);
2748
- textHeight = textHeight ? textHeight : RectangleClient.getRectangleByPoints(points).height;
2749
2748
  return createGeometryElement(BasicShapes.text, points, text, memorizedLatest.geometryProperties, {
2750
- ...memorizedLatest.textProperties,
2751
- textHeight
2749
+ ...memorizedLatest.textProperties
2752
2750
  });
2753
2751
  };
2754
2752
  const createDefaultGeometry = (board, points, shape) => {
2755
2753
  const memorizedLatest = getMemorizedLatestByPointer(shape);
2756
- const textHeight = getTextShapeProperty(board, DefaultTextProperty.text, memorizedLatest.textProperties['font-size']).height;
2757
2754
  if (PlaitDrawElement.isUMLClassOrInterface({ shape })) {
2758
2755
  return createUMLClassOrInterfaceGeometryElement(board, shape, points);
2759
2756
  }
@@ -2767,7 +2764,7 @@ const createDefaultGeometry = (board, points, shape) => {
2767
2764
  return createGeometryElement(shape, points, '', {
2768
2765
  strokeWidth: DefaultBasicShapeProperty.strokeWidth,
2769
2766
  ...memorizedLatest.geometryProperties
2770
- }, { ...memorizedLatest.textProperties, textHeight });
2767
+ }, { ...memorizedLatest.textProperties });
2771
2768
  }
2772
2769
  };
2773
2770
  const editText = (board, element, text) => {
@@ -2945,10 +2942,10 @@ const insertText = (board, point, text) => {
2945
2942
  const newElement = createTextElement(board, points, text);
2946
2943
  insertElement(board, newElement);
2947
2944
  };
2948
- const resizeGeometry = (board, points, textHeight, path) => {
2945
+ const resizeGeometry = (board, points, path) => {
2949
2946
  const normalizePoints = normalizeShapePoints(points);
2950
2947
  const element = PlaitNode.get(board, path);
2951
- const newProperties = { points: normalizePoints, textHeight };
2948
+ const newProperties = { points: normalizePoints, text: { ...element.text } };
2952
2949
  if (PlaitDrawElement.isText(element) && element.autoSize) {
2953
2950
  newProperties.autoSize = false;
2954
2951
  }
@@ -2957,7 +2954,7 @@ const resizeGeometry = (board, points, textHeight, path) => {
2957
2954
  const switchGeometryShape = (board, shape) => {
2958
2955
  const selectedElements = getSelectedElements(board);
2959
2956
  const refs = [];
2960
- selectedElements.forEach(item => {
2957
+ selectedElements.forEach((item) => {
2961
2958
  if (PlaitDrawElement.isGeometry(item) && !PlaitDrawElement.isText(item)) {
2962
2959
  const path = PlaitBoard.findPath(board, item);
2963
2960
  Transforms.setNode(board, { shape }, path);
@@ -2965,15 +2962,15 @@ const switchGeometryShape = (board, shape) => {
2965
2962
  }
2966
2963
  });
2967
2964
  if (refs.length) {
2968
- refs.forEach(ref => {
2965
+ refs.forEach((ref) => {
2969
2966
  DrawTransforms.resizeArrowLine(board, ref.property, ref.path);
2970
2967
  });
2971
2968
  }
2972
2969
  };
2973
2970
 
2974
- const normalizePoints = (board, element, width, textHeight) => {
2971
+ const normalizePoints = (board, element, width, height) => {
2975
2972
  let points = element.points;
2976
- let autoSize = element.autoSize;
2973
+ let autoSize = PlaitDrawElement.isText(element) ? element.autoSize : false;
2977
2974
  const defaultSpace = ShapeDefaultSpace.rectangleAndText;
2978
2975
  if (autoSize) {
2979
2976
  const newWidth = width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : width;
@@ -2981,7 +2978,7 @@ const normalizePoints = (board, element, width, textHeight) => {
2981
2978
  if (AlignEditor.isActive(editor, Alignment.right)) {
2982
2979
  points = [
2983
2980
  [points[1][0] - (newWidth + defaultSpace * 2), points[0][1]],
2984
- [points[1][0], points[0][1] + textHeight]
2981
+ [points[1][0], points[0][1] + height]
2985
2982
  ];
2986
2983
  }
2987
2984
  else if (AlignEditor.isActive(editor, Alignment.center)) {
@@ -2989,11 +2986,11 @@ const normalizePoints = (board, element, width, textHeight) => {
2989
2986
  const offset = (newWidth - oldWidth) / 2;
2990
2987
  points = [
2991
2988
  [points[0][0] - offset - defaultSpace, points[0][1]],
2992
- [points[1][0] + offset + defaultSpace, points[0][1] + textHeight]
2989
+ [points[1][0] + offset + defaultSpace, points[0][1] + height]
2993
2990
  ];
2994
2991
  }
2995
2992
  else {
2996
- points = [points[0], [points[0][0] + newWidth + defaultSpace * 2, points[0][1] + textHeight]];
2993
+ points = [points[0], [points[0][0] + newWidth + defaultSpace * 2, points[0][1] + height]];
2997
2994
  }
2998
2995
  if (hasValidAngle(element)) {
2999
2996
  points = resetPointsAfterResize(RectangleClient.getRectangleByPoints(element.points), RectangleClient.getRectangleByPoints(points), RectangleClient.getCenterPoint(RectangleClient.getRectangleByPoints(element.points)), RectangleClient.getCenterPoint(RectangleClient.getRectangleByPoints(points)), element.angle);
@@ -3001,27 +2998,22 @@ const normalizePoints = (board, element, width, textHeight) => {
3001
2998
  }
3002
2999
  return { points };
3003
3000
  };
3004
- const setText = (board, element, text, width, textHeight) => {
3001
+ const setText = (board, element, text, width, height) => {
3005
3002
  const newElement = {
3006
3003
  text,
3007
- textHeight,
3008
- ...normalizePoints(board, element, width, textHeight)
3004
+ ...normalizePoints(board, element, width, height)
3009
3005
  };
3010
- const path = board.children.findIndex(child => child === element);
3006
+ const path = board.children.findIndex((child) => child === element);
3011
3007
  Transforms.setNode(board, newElement, [path]);
3012
3008
  };
3013
- const setTextSize = (board, element, textWidth, textHeight) => {
3014
- if (element.autoSize) {
3009
+ const setTextSize = (board, element, width, height) => {
3010
+ const isAutoSize = PlaitDrawElement.isText(element) ? element.autoSize : false;
3011
+ if (isAutoSize) {
3015
3012
  const newElement = {
3016
- textHeight,
3017
- ...normalizePoints(board, element, textWidth, textHeight)
3013
+ ...normalizePoints(board, element, width, height)
3018
3014
  };
3019
- const isPointsEqual = Point.isEquals(element.points[0], newElement.points[0]) && Point.isEquals(element.points[1], newElement.points[1]);
3020
- const isTextHeightEqual = Math.round(textHeight) === Math.round(element.textHeight);
3021
- if (!isPointsEqual || !isTextHeightEqual) {
3022
- const path = board.children.findIndex(child => child === element);
3023
- Transforms.setNode(board, newElement, [path]);
3024
- }
3015
+ const path = board.children.findIndex((child) => child === element);
3016
+ Transforms.setNode(board, newElement, [path]);
3025
3017
  }
3026
3018
  };
3027
3019
 
@@ -3128,7 +3120,7 @@ function buildSwimlaneTable(element) {
3128
3120
  rowspan: element.rows.length
3129
3121
  };
3130
3122
  }
3131
- if (item.text && item.textHeight && !item.text.direction) {
3123
+ if (item.text && !item.text.direction) {
3132
3124
  item = {
3133
3125
  ...item,
3134
3126
  text: {
@@ -3385,8 +3377,7 @@ const createNewSwimlaneCells = (swimlane, newId, type) => {
3385
3377
  children: [{ text: swimlane.header ? 'Lane' : 'New Swimlane' }],
3386
3378
  align: Alignment.center,
3387
3379
  direction: type === 'row' ? undefined : 'vertical'
3388
- },
3389
- textHeight: 20
3380
+ }
3390
3381
  };
3391
3382
  return cells;
3392
3383
  };
@@ -3417,7 +3408,7 @@ const setDrawTexts = (board, element, text) => {
3417
3408
  const setTableText = (board, path, cellId, text, textHeight) => {
3418
3409
  const table = PlaitNode.get(board, path);
3419
3410
  const cell = getCellWithPoints(board, table, cellId);
3420
- const cellIndex = table.cells.findIndex(item => item.id === cell.id);
3411
+ const cellIndex = table.cells.findIndex((item) => item.id === cell.id);
3421
3412
  let rows = [...table.rows];
3422
3413
  let columns = [...table.columns];
3423
3414
  let cells = [...table.cells];
@@ -3425,7 +3416,7 @@ const setTableText = (board, path, cellId, text, textHeight) => {
3425
3416
  const { width: cellWidth, height: cellHeight } = RectangleClient.getRectangleByPoints(cell.points);
3426
3417
  const defaultSpace = ShapeDefaultSpace.rectangleAndText;
3427
3418
  if (PlaitTableElement.isVerticalText(cell)) {
3428
- const columnIdx = table.columns.findIndex(column => column.id === cell.columnId);
3419
+ const columnIdx = table.columns.findIndex((column) => column.id === cell.columnId);
3429
3420
  if (textHeight > cellWidth) {
3430
3421
  const newColumnWidth = textHeight + defaultSpace * 2;
3431
3422
  const offset = newColumnWidth - cellWidth;
@@ -3435,9 +3426,9 @@ const setTableText = (board, path, cellId, text, textHeight) => {
3435
3426
  }
3436
3427
  }
3437
3428
  else {
3438
- const rowIdx = table.rows.findIndex(row => row.id === cell.rowId);
3429
+ const rowIdx = table.rows.findIndex((row) => row.id === cell.rowId);
3439
3430
  const tableRow = table.rows[rowIdx];
3440
- const compareHeight = tableRow.height ?? Math.max(cellHeight, cell.textHeight || 0);
3431
+ const compareHeight = tableRow.height ?? Math.max(cellHeight, textHeight || 0);
3441
3432
  if (textHeight > compareHeight) {
3442
3433
  const newRowHeight = textHeight + defaultSpace * 2;
3443
3434
  const offset = newRowHeight - compareHeight;
@@ -3448,7 +3439,6 @@ const setTableText = (board, path, cellId, text, textHeight) => {
3448
3439
  }
3449
3440
  cells[cellIndex] = {
3450
3441
  ...cells[cellIndex],
3451
- textHeight: textHeight,
3452
3442
  text
3453
3443
  };
3454
3444
  Transforms.setNode(board, { rows, columns, cells, points }, path);
@@ -3467,7 +3457,7 @@ const setTableFill = (board, element, fill, path) => {
3467
3457
  }
3468
3458
  else {
3469
3459
  newCells = element.cells.map(cell => {
3470
- if (cell.text && cell.textHeight) {
3460
+ if (cell.text) {
3471
3461
  return getNewCell(cell, fill);
3472
3462
  }
3473
3463
  return cell;
@@ -3691,14 +3681,7 @@ function withDrawResize(board) {
3691
3681
  }
3692
3682
  }
3693
3683
  if (PlaitDrawElement.isGeometry(target)) {
3694
- if (PlaitDrawElement.isGeometry(target) && isGeometryIncludeText(target)) {
3695
- const { height: textHeight } = getFirstTextManage(target).getSize();
3696
- DrawTransforms.resizeGeometry(board, points, textHeight, path);
3697
- }
3698
- else {
3699
- points = normalizeShapePoints(points);
3700
- Transforms.setNode(board, { points }, path);
3701
- }
3684
+ DrawTransforms.resizeGeometry(board, points, path);
3702
3685
  }
3703
3686
  else if (PlaitDrawElement.isLine(target) ||
3704
3687
  PlaitDrawElement.isCustomGeometryElement(board, target) ||
@@ -4105,16 +4088,17 @@ const CommentEngine = {
4105
4088
  getConnectorPoints(rectangle) {
4106
4089
  return RectangleClient.getEdgeCenterPoints(rectangle);
4107
4090
  },
4108
- getTextRectangle(element) {
4091
+ getTextRectangle: (board, element) => {
4109
4092
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4110
4093
  const strokeWidth = getStrokeWidthByElement(element);
4111
- const height = element.textHeight;
4112
4094
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4095
+ const text = element.text;
4096
+ const textSize = getTextSize(board, text, width);
4113
4097
  return {
4114
- height,
4098
+ height: textSize.height,
4115
4099
  width: width > 0 ? width : 0,
4116
4100
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
4117
- y: elementRectangle.y + (elementRectangle.height * heightRatio$1 - height) / 2
4101
+ y: elementRectangle.y + (elementRectangle.height * heightRatio$1 - textSize.height) / 2
4118
4102
  };
4119
4103
  }
4120
4104
  };
@@ -4205,8 +4189,8 @@ const CrossEngine = createPolygonEngine({
4205
4189
  getConnectorPoints(rectangle) {
4206
4190
  return RectangleClient.getEdgeCenterPoints(rectangle);
4207
4191
  },
4208
- getTextRectangle(element) {
4209
- const rectangle = getTextRectangle(element);
4192
+ getTextRectangle: (board, element) => {
4193
+ const rectangle = getTextRectangle$1(board, element);
4210
4194
  const width = rectangle.width;
4211
4195
  rectangle.width = rectangle.width / 2;
4212
4196
  rectangle.x += width / 4;
@@ -4219,8 +4203,8 @@ const DiamondEngine = createPolygonEngine({
4219
4203
  getConnectorPoints(rectangle) {
4220
4204
  return RectangleClient.getEdgeCenterPoints(rectangle);
4221
4205
  },
4222
- getTextRectangle(element) {
4223
- const rectangle = getTextRectangle(element);
4206
+ getTextRectangle: (board, element) => {
4207
+ const rectangle = getTextRectangle$1(board, element);
4224
4208
  rectangle.width = rectangle.width / 2;
4225
4209
  rectangle.x += rectangle.width / 2;
4226
4210
  return rectangle;
@@ -4260,8 +4244,8 @@ function createEllipseEngine(createOptions) {
4260
4244
  getConnectorPoints(rectangle) {
4261
4245
  return RectangleClient.getEdgeCenterPoints(rectangle);
4262
4246
  },
4263
- getTextRectangle(element) {
4264
- const rectangle = getTextRectangle(element);
4247
+ getTextRectangle: (board, element) => {
4248
+ const rectangle = getTextRectangle$1(board, element);
4265
4249
  const width = rectangle.width;
4266
4250
  rectangle.width = (rectangle.width * 3) / 4;
4267
4251
  rectangle.x += width / 8;
@@ -4293,8 +4277,8 @@ const HexagonEngine = createPolygonEngine({
4293
4277
  getConnectorPoints(rectangle) {
4294
4278
  return RectangleClient.getEdgeCenterPoints(rectangle);
4295
4279
  },
4296
- getTextRectangle(element) {
4297
- const rectangle = getTextRectangle(element);
4280
+ getTextRectangle: (board, element) => {
4281
+ const rectangle = getTextRectangle$1(board, element);
4298
4282
  const width = rectangle.width;
4299
4283
  rectangle.width = (rectangle.width * 3) / 4;
4300
4284
  rectangle.x += width / 8;
@@ -4321,8 +4305,8 @@ const LeftArrowEngine = createPolygonEngine({
4321
4305
  [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
4322
4306
  ];
4323
4307
  },
4324
- getTextRectangle(element) {
4325
- const rectangle = getTextRectangle(element);
4308
+ getTextRectangle: (board, element) => {
4309
+ const rectangle = getTextRectangle$1(board, element);
4326
4310
  const width = rectangle.width;
4327
4311
  rectangle.width = rectangle.width * (1 - 0.32);
4328
4312
  rectangle.x += width * 0.32;
@@ -4347,8 +4331,8 @@ const OctagonEngine = createPolygonEngine({
4347
4331
  getConnectorPoints(rectangle) {
4348
4332
  return RectangleClient.getEdgeCenterPoints(rectangle);
4349
4333
  },
4350
- getTextRectangle(element) {
4351
- const rectangle = getTextRectangle(element);
4334
+ getTextRectangle: (board, element) => {
4335
+ const rectangle = getTextRectangle$1(board, element);
4352
4336
  const width = rectangle.width;
4353
4337
  rectangle.width = (rectangle.width * 3) / 4;
4354
4338
  rectangle.x += width / 8;
@@ -4370,8 +4354,8 @@ const ParallelogramEngine = createPolygonEngine({
4370
4354
  const cornerPoints = getParallelogramPoints(rectangle);
4371
4355
  return getCenterPointsOnPolygon$1(cornerPoints);
4372
4356
  },
4373
- getTextRectangle(element) {
4374
- const rectangle = getTextRectangle(element);
4357
+ getTextRectangle: (board, element) => {
4358
+ const rectangle = getTextRectangle$1(board, element);
4375
4359
  const width = rectangle.width;
4376
4360
  rectangle.width = rectangle.width / 2;
4377
4361
  rectangle.x += width / 4;
@@ -4390,17 +4374,18 @@ const getPentagonPoints = (rectangle) => {
4390
4374
  };
4391
4375
  const PentagonEngine = createPolygonEngine({
4392
4376
  getPolygonPoints: getPentagonPoints,
4393
- getTextRectangle(element) {
4377
+ getTextRectangle: (board, element) => {
4394
4378
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4395
4379
  const strokeWidth = getStrokeWidthByElement(element);
4396
- const height = element.textHeight;
4397
4380
  const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4398
4381
  const width = (originWidth * 3) / 5;
4382
+ const text = element.text;
4383
+ const textSize = getTextSize(board, text, width);
4399
4384
  return {
4400
- height,
4385
+ height: textSize.height,
4401
4386
  width: width > 0 ? width : 0,
4402
4387
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 5,
4403
- y: elementRectangle.y + elementRectangle.height / 5 + ((elementRectangle.height * 4) / 5 - height) / 2
4388
+ y: elementRectangle.y + elementRectangle.height / 5 + ((elementRectangle.height * 4) / 5 - textSize.height) / 2
4404
4389
  };
4405
4390
  }
4406
4391
  });
@@ -4420,9 +4405,9 @@ const PentagonArrowEngine = createPolygonEngine({
4420
4405
  getConnectorPoints(rectangle) {
4421
4406
  return RectangleClient.getEdgeCenterPoints(rectangle);
4422
4407
  },
4423
- getTextRectangle(element) {
4408
+ getTextRectangle: (board, element) => {
4424
4409
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4425
- const rectangle = getTextRectangle(element);
4410
+ const rectangle = getTextRectangle$1(board, element);
4426
4411
  const wider = elementRectangle.width > elementRectangle.height / 2 + 20;
4427
4412
  rectangle.width = wider ? elementRectangle.width - elementRectangle.height / 2 : rectangle.width;
4428
4413
  return rectangle;
@@ -4442,9 +4427,9 @@ const getProcessArrowPoints = (rectangle) => {
4442
4427
  };
4443
4428
  const ProcessArrowEngine = createPolygonEngine({
4444
4429
  getPolygonPoints: getProcessArrowPoints,
4445
- getTextRectangle(element) {
4430
+ getTextRectangle: (board, element) => {
4446
4431
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4447
- const rectangle = getTextRectangle(element);
4432
+ const rectangle = getTextRectangle$1(board, element);
4448
4433
  const wider = elementRectangle.width > elementRectangle.height + 20;
4449
4434
  rectangle.width = wider ? elementRectangle.width - elementRectangle.height : rectangle.width;
4450
4435
  rectangle.x = wider ? elementRectangle.x + elementRectangle.height / 2 : rectangle.x;
@@ -4471,8 +4456,8 @@ const RightArrowEngine = createPolygonEngine({
4471
4456
  [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
4472
4457
  ];
4473
4458
  },
4474
- getTextRectangle(element) {
4475
- const rectangle = getTextRectangle(element);
4459
+ getTextRectangle: (board, element) => {
4460
+ const rectangle = getTextRectangle$1(board, element);
4476
4461
  rectangle.width = rectangle.width * 0.68;
4477
4462
  return rectangle;
4478
4463
  }
@@ -4609,16 +4594,17 @@ const RoundCommentEngine = {
4609
4594
  [rectangle.x, rectangle.y + rectangle.height / 2]
4610
4595
  ];
4611
4596
  },
4612
- getTextRectangle(element) {
4597
+ getTextRectangle: (board, element) => {
4613
4598
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4614
4599
  const strokeWidth = getStrokeWidthByElement(element);
4615
- const height = element.textHeight;
4616
4600
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4601
+ const text = element.text;
4602
+ const textSize = getTextSize(board, text, width);
4617
4603
  return {
4618
- height,
4604
+ height: textSize.height,
4619
4605
  width: width > 0 ? width : 0,
4620
4606
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
4621
- y: elementRectangle.y + (elementRectangle.height * heightRatio - height) / 2
4607
+ y: elementRectangle.y + (elementRectangle.height * heightRatio - textSize.height) / 2
4622
4608
  };
4623
4609
  }
4624
4610
  };
@@ -4648,8 +4634,8 @@ const TrapezoidEngine = createPolygonEngine({
4648
4634
  const points = getTrapezoidPoints(rectangle);
4649
4635
  return getCenterPointsOnPolygon$1(points);
4650
4636
  },
4651
- getTextRectangle(element) {
4652
- const rectangle = getTextRectangle(element);
4637
+ getTextRectangle(board, element) {
4638
+ const rectangle = getTextRectangle$1(board, element);
4653
4639
  const width = rectangle.width;
4654
4640
  rectangle.width = (rectangle.width * 3) / 4;
4655
4641
  rectangle.x += width / 8;
@@ -4671,17 +4657,18 @@ const TriangleEngine = createPolygonEngine({
4671
4657
  const lineCenterPoints = getCenterPointsOnPolygon$1(cornerPoints);
4672
4658
  return [...lineCenterPoints, ...cornerPoints];
4673
4659
  },
4674
- getTextRectangle(element) {
4660
+ getTextRectangle: (board, element) => {
4675
4661
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4676
4662
  const strokeWidth = getStrokeWidthByElement(element);
4677
- const height = element.textHeight;
4678
4663
  const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4679
4664
  const width = (originWidth * 2) / 3;
4665
+ const text = element.text;
4666
+ const textSize = getTextSize(board, text, width);
4680
4667
  return {
4681
- height,
4668
+ height: textSize.height,
4682
4669
  width: width > 0 ? width : 0,
4683
4670
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
4684
- y: elementRectangle.y + (elementRectangle.height * 3) / 5 + ((elementRectangle.height * 2) / 5 - height) / 2
4671
+ y: elementRectangle.y + (elementRectangle.height * 3) / 5 + ((elementRectangle.height * 2) / 5 - textSize.height) / 2
4685
4672
  };
4686
4673
  }
4687
4674
  });
@@ -4730,17 +4717,18 @@ const StarEngine = createPolygonEngine({
4730
4717
  const points = getStarPoints(rectangle);
4731
4718
  return [points[1], points[3], points[5], points[7], points[9]];
4732
4719
  },
4733
- getTextRectangle(element) {
4720
+ getTextRectangle: (board, element) => {
4734
4721
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4735
4722
  const strokeWidth = getStrokeWidthByElement(element);
4736
- const height = element.textHeight;
4737
4723
  const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4738
4724
  const width = originWidth / 2;
4725
+ const text = element.text;
4726
+ const textSize = getTextSize(board, text, width);
4739
4727
  return {
4740
- height,
4728
+ height: textSize.height,
4741
4729
  width: width > 0 ? width : 0,
4742
4730
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 4,
4743
- y: elementRectangle.y + (elementRectangle.height * 1) / 6 + ((elementRectangle.height * 4) / 5 - height) / 2
4731
+ y: elementRectangle.y + (elementRectangle.height * 1) / 6 + ((elementRectangle.height * 4) / 5 - textSize.height) / 2
4744
4732
  };
4745
4733
  }
4746
4734
  });
@@ -4826,16 +4814,17 @@ const ManualInputEngine = createPolygonEngine({
4826
4814
  const cornerPoints = getManualInputPoints(rectangle);
4827
4815
  return getCenterPointsOnPolygon$1(cornerPoints);
4828
4816
  },
4829
- getTextRectangle: (element) => {
4817
+ getTextRectangle: (board, element) => {
4830
4818
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4831
4819
  const strokeWidth = getStrokeWidthByElement(element);
4832
- const height = element.textHeight;
4833
4820
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4821
+ const text = element.text;
4822
+ const textSize = getTextSize(board, text, width);
4834
4823
  return {
4835
- height,
4824
+ height: textSize.height,
4836
4825
  width: width > 0 ? width : 0,
4837
4826
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
4838
- y: elementRectangle.y + elementRectangle.height / 4 + ((elementRectangle.height * 3) / 4 - height) / 2
4827
+ y: elementRectangle.y + elementRectangle.height / 4 + ((elementRectangle.height * 3) / 4 - textSize.height) / 2
4839
4828
  };
4840
4829
  }
4841
4830
  });
@@ -4855,8 +4844,8 @@ const PreparationEngine = createPolygonEngine({
4855
4844
  getConnectorPoints: (rectangle) => {
4856
4845
  return RectangleClient.getEdgeCenterPoints(rectangle);
4857
4846
  },
4858
- getTextRectangle(element) {
4859
- const rectangle = getTextRectangle(element);
4847
+ getTextRectangle(board, element) {
4848
+ const rectangle = getTextRectangle$1(board, element);
4860
4849
  const width = rectangle.width;
4861
4850
  rectangle.width = (rectangle.width * 2) / 3;
4862
4851
  rectangle.x += width / 6;
@@ -4878,8 +4867,8 @@ const ManualLoopEngine = createPolygonEngine({
4878
4867
  const cornerPoints = getManualLoopPoints(rectangle);
4879
4868
  return getCenterPointsOnPolygon$1(cornerPoints);
4880
4869
  },
4881
- getTextRectangle(element) {
4882
- const rectangle = getTextRectangle(element);
4870
+ getTextRectangle: (board, element) => {
4871
+ const rectangle = getTextRectangle$1(board, element);
4883
4872
  const width = rectangle.width;
4884
4873
  rectangle.width = (rectangle.width * 3) / 4;
4885
4874
  rectangle.x += width / 8;
@@ -4901,17 +4890,18 @@ const MergeEngine = createPolygonEngine({
4901
4890
  const lineCenterPoints = getCenterPointsOnPolygon$1(cornerPoints);
4902
4891
  return [...lineCenterPoints, ...cornerPoints];
4903
4892
  },
4904
- getTextRectangle(element) {
4893
+ getTextRectangle: (board, element) => {
4905
4894
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4906
4895
  const strokeWidth = getStrokeWidthByElement(element);
4907
- const height = element.textHeight;
4908
4896
  const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4909
4897
  const width = (originWidth * 2) / 3;
4898
+ const text = element.text;
4899
+ const textSize = getTextSize(board, text, width);
4910
4900
  return {
4911
- height,
4901
+ height: textSize.height,
4912
4902
  width: width > 0 ? width : 0,
4913
4903
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
4914
- y: elementRectangle.y + ((elementRectangle.height * 2) / 3 - height) / 2
4904
+ y: elementRectangle.y + ((elementRectangle.height * 2) / 3 - textSize.height) / 2
4915
4905
  };
4916
4906
  }
4917
4907
  });
@@ -5025,8 +5015,8 @@ const StoredDataEngine = {
5025
5015
  [rectangle.x, rectangle.y + rectangle.height / 2]
5026
5016
  ];
5027
5017
  },
5028
- getTextRectangle(element) {
5029
- const rectangle = getTextRectangle(element);
5018
+ getTextRectangle(board, element) {
5019
+ const rectangle = getTextRectangle$1(board, element);
5030
5020
  const width = rectangle.width;
5031
5021
  rectangle.width = (rectangle.width * 3) / 4;
5032
5022
  rectangle.x += width / 8;
@@ -5062,16 +5052,17 @@ const PredefinedProcessEngine = {
5062
5052
  getConnectorPoints(rectangle) {
5063
5053
  return RectangleClient.getEdgeCenterPoints(rectangle);
5064
5054
  },
5065
- getTextRectangle: (element) => {
5055
+ getTextRectangle: (board, element) => {
5066
5056
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5067
5057
  const strokeWidth = getStrokeWidthByElement(element);
5068
- const height = element.textHeight;
5069
5058
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2 - elementRectangle.width * 0.06 * 2;
5059
+ const text = element.text;
5060
+ const textSize = getTextSize(board, text, width);
5070
5061
  return {
5071
- height,
5062
+ height: textSize.height,
5072
5063
  width: width > 0 ? width : 0,
5073
5064
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.06,
5074
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5065
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5075
5066
  };
5076
5067
  }
5077
5068
  };
@@ -5090,16 +5081,17 @@ const OffPageEngine = createPolygonEngine({
5090
5081
  getConnectorPoints: (rectangle) => {
5091
5082
  return RectangleClient.getEdgeCenterPoints(rectangle);
5092
5083
  },
5093
- getTextRectangle: (element) => {
5084
+ getTextRectangle: (board, element) => {
5094
5085
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5095
5086
  const strokeWidth = getStrokeWidthByElement(element);
5096
- const height = element.textHeight;
5097
5087
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5088
+ const text = element.text;
5089
+ const textSize = getTextSize(board, text, width);
5098
5090
  return {
5099
5091
  width: width > 0 ? width : 0,
5100
- height: height,
5092
+ height: textSize.height,
5101
5093
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5102
- y: elementRectangle.y + (elementRectangle.height - elementRectangle.height / 2 - height) / 2
5094
+ y: elementRectangle.y + (elementRectangle.height - elementRectangle.height / 2 - textSize.height) / 2
5103
5095
  };
5104
5096
  }
5105
5097
  });
@@ -5204,16 +5196,17 @@ const DocumentEngine = {
5204
5196
  }
5205
5197
  return getUnitVectorByPointAndPoint(connectionPoint, [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height]);
5206
5198
  },
5207
- getTextRectangle: (element) => {
5199
+ getTextRectangle: (board, element) => {
5208
5200
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5209
5201
  const strokeWidth = getStrokeWidthByElement(element);
5210
- const height = element.textHeight;
5211
5202
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2 - elementRectangle.width * 0.06 * 2;
5203
+ const text = element.text;
5204
+ const textSize = getTextSize(board, text, width);
5212
5205
  return {
5213
- height,
5206
+ height: textSize.height,
5214
5207
  width: width > 0 ? width : 0,
5215
5208
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.06,
5216
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5209
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5217
5210
  };
5218
5211
  }
5219
5212
  };
@@ -5245,39 +5238,14 @@ const getMultiDocumentPoints = (rectangle) => {
5245
5238
  const MultiDocumentEngine = {
5246
5239
  draw(board, rectangle, options) {
5247
5240
  const rs = PlaitBoard.getRoughSVG(board);
5248
- const shape = rs.path(`M${rectangle.x} ${rectangle.y + rectangle.height - rectangle.height / 9} V${rectangle.y + 10} H${rectangle.x +
5249
- 5} V${rectangle.y + 5} H${rectangle.x + 10} V${rectangle.y} H${rectangle.x + rectangle.width} V${rectangle.y +
5250
- rectangle.height -
5251
- rectangle.height / 9 -
5252
- 10 -
5253
- 3} L${rectangle.x + rectangle.width - 5} ${rectangle.y +
5254
- rectangle.height -
5255
- rectangle.height / 9 -
5256
- 10 -
5257
- 3 -
5258
- 4} V${rectangle.y + rectangle.height - rectangle.height / 9 - 5 - 3}
5259
- L${rectangle.x + rectangle.width - 10} ${rectangle.y +
5260
- rectangle.height -
5261
- rectangle.height / 9 -
5262
- 5 -
5263
- 3 -
5264
- 4} V${rectangle.y + rectangle.height - rectangle.height / 9}
5241
+ const shape = rs.path(`M${rectangle.x} ${rectangle.y + rectangle.height - rectangle.height / 9} V${rectangle.y + 10} H${rectangle.x + 5} V${rectangle.y + 5} H${rectangle.x + 10} V${rectangle.y} H${rectangle.x + rectangle.width} V${rectangle.y + rectangle.height - rectangle.height / 9 - 10 - 3} L${rectangle.x + rectangle.width - 5} ${rectangle.y + rectangle.height - rectangle.height / 9 - 10 - 3 - 4} V${rectangle.y + rectangle.height - rectangle.height / 9 - 5 - 3}
5242
+ L${rectangle.x + rectangle.width - 10} ${rectangle.y + rectangle.height - rectangle.height / 9 - 5 - 3 - 4} V${rectangle.y + rectangle.height - rectangle.height / 9}
5265
5243
 
5266
- Q${rectangle.x + rectangle.width - 10 - (rectangle.width - 10) / 4} ${rectangle.y +
5267
- rectangle.height -
5268
- (rectangle.height / 9) * 3}, ${rectangle.x + (rectangle.width - 10) / 2} ${rectangle.y +
5269
- rectangle.height -
5270
- rectangle.height / 9} T${rectangle.x} ${rectangle.y + rectangle.height - rectangle.height / 9}
5244
+ Q${rectangle.x + rectangle.width - 10 - (rectangle.width - 10) / 4} ${rectangle.y + rectangle.height - (rectangle.height / 9) * 3}, ${rectangle.x + (rectangle.width - 10) / 2} ${rectangle.y + rectangle.height - rectangle.height / 9} T${rectangle.x} ${rectangle.y + rectangle.height - rectangle.height / 9}
5271
5245
 
5272
- M${rectangle.x + 5} ${rectangle.y + 10} H${rectangle.x + rectangle.width - 10} V${rectangle.y +
5273
- rectangle.height -
5274
- rectangle.height / 9}
5246
+ M${rectangle.x + 5} ${rectangle.y + 10} H${rectangle.x + rectangle.width - 10} V${rectangle.y + rectangle.height - rectangle.height / 9}
5275
5247
 
5276
- M${rectangle.x + 10} ${rectangle.y + 5} H${rectangle.x + rectangle.width - 5} V${rectangle.y +
5277
- rectangle.height -
5278
- rectangle.height / 9 -
5279
- 10 -
5280
- 3}
5248
+ M${rectangle.x + 10} ${rectangle.y + 5} H${rectangle.x + rectangle.width - 5} V${rectangle.y + rectangle.height - rectangle.height / 9 - 10 - 3}
5281
5249
  `, { ...options, fillStyle: 'solid' });
5282
5250
  setStrokeLinecap(shape, 'round');
5283
5251
  return shape;
@@ -5315,7 +5283,7 @@ const MultiDocumentEngine = {
5315
5283
  let nearestDistance = distanceBetweenPointAndPoint(point[0], point[1], nearestPoint[0], nearestPoint[1]);
5316
5284
  crossingPoints
5317
5285
  .filter((v, index) => index > 0)
5318
- .forEach(crossingPoint => {
5286
+ .forEach((crossingPoint) => {
5319
5287
  let distance = distanceBetweenPointAndPoint(point[0], point[1], crossingPoint[0], crossingPoint[1]);
5320
5288
  if (distance < nearestDistance) {
5321
5289
  nearestDistance = distance;
@@ -5341,16 +5309,17 @@ const MultiDocumentEngine = {
5341
5309
  const factor = getDirectionFactor(direction);
5342
5310
  return [factor.x, factor.y];
5343
5311
  },
5344
- getTextRectangle: (element) => {
5312
+ getTextRectangle: (board, element) => {
5345
5313
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5346
5314
  const strokeWidth = getStrokeWidthByElement(element);
5347
- const height = element.textHeight;
5348
5315
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2 - elementRectangle.width * 0.06 * 2;
5316
+ const text = element.text;
5317
+ const textSize = getTextSize(board, text, width);
5349
5318
  return {
5350
- height,
5319
+ height: textSize.height,
5351
5320
  width: width > 0 ? width - 10 : 0,
5352
5321
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.06,
5353
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5322
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5354
5323
  };
5355
5324
  }
5356
5325
  };
@@ -5421,16 +5390,17 @@ const DatabaseEngine = {
5421
5390
  const vector = getVectorFromPointAndSlope(point[0], point[1], slope);
5422
5391
  return vector;
5423
5392
  },
5424
- getTextRectangle: (element) => {
5393
+ getTextRectangle: (board, element) => {
5425
5394
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5426
5395
  const strokeWidth = getStrokeWidthByElement(element);
5427
- const height = element.textHeight;
5428
5396
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5397
+ const text = element.text;
5398
+ const textSize = getTextSize(board, text, width);
5429
5399
  return {
5430
- height,
5400
+ height: textSize.height,
5431
5401
  width: width > 0 ? width : 0,
5432
5402
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5433
- y: elementRectangle.y + elementRectangle.height * 0.3 + (elementRectangle.height - elementRectangle.height * 0.45 - height) / 2
5403
+ y: elementRectangle.y + elementRectangle.height * 0.3 + (elementRectangle.height - elementRectangle.height * 0.45 - textSize.height) / 2
5434
5404
  };
5435
5405
  }
5436
5406
  };
@@ -5501,16 +5471,17 @@ const HardDiskEngine = {
5501
5471
  const vector = getVectorFromPointAndSlope(point[0], point[1], slope);
5502
5472
  return vector;
5503
5473
  },
5504
- getTextRectangle: (element) => {
5474
+ getTextRectangle: (board, element) => {
5505
5475
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5506
5476
  const strokeWidth = getStrokeWidthByElement(element);
5507
- const height = element.textHeight;
5508
5477
  const width = elementRectangle.width - elementRectangle.width * 0.45 - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5478
+ const text = element.text;
5479
+ const textSize = getTextSize(board, text, width);
5509
5480
  return {
5510
- height,
5481
+ height: textSize.height,
5511
5482
  width: width > 0 ? width : 0,
5512
5483
  x: elementRectangle.x + elementRectangle.width * 0.15 + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5513
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5484
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5514
5485
  };
5515
5486
  }
5516
5487
  };
@@ -5543,16 +5514,17 @@ const InternalStorageEngine = {
5543
5514
  getConnectorPoints(rectangle) {
5544
5515
  return RectangleClient.getEdgeCenterPoints(rectangle);
5545
5516
  },
5546
- getTextRectangle: (element) => {
5517
+ getTextRectangle: (board, element) => {
5547
5518
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5548
5519
  const strokeWidth = getStrokeWidthByElement(element);
5549
- const height = element.textHeight;
5550
5520
  const width = elementRectangle.width - elementRectangle.width * 0.1 - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5521
+ const text = element.text;
5522
+ const textSize = getTextSize(board, text, width);
5551
5523
  return {
5552
- height,
5524
+ height: textSize.height,
5553
5525
  width: width > 0 ? width : 0,
5554
5526
  x: elementRectangle.x + elementRectangle.width * 0.1 + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5555
- y: elementRectangle.y + elementRectangle.height * 0.1 + (elementRectangle.height - elementRectangle.height * 0.1 - height) / 2
5527
+ y: elementRectangle.y + elementRectangle.height * 0.1 + (elementRectangle.height - elementRectangle.height * 0.1 - textSize.height) / 2
5556
5528
  };
5557
5529
  }
5558
5530
  };
@@ -5623,16 +5595,17 @@ const NoteCurlyLeftEngine = {
5623
5595
  getConnectorPoints(rectangle) {
5624
5596
  return RectangleClient.getEdgeCenterPoints(rectangle);
5625
5597
  },
5626
- getTextRectangle: (element) => {
5598
+ getTextRectangle: (board, element) => {
5627
5599
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5628
5600
  const strokeWidth = getStrokeWidthByElement(element);
5629
- const height = element.textHeight;
5630
5601
  const width = elementRectangle.width - elementRectangle.width * 0.09 - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5602
+ const text = element.text;
5603
+ const textSize = getTextSize(board, text, width);
5631
5604
  return {
5632
- height,
5605
+ height: textSize.height,
5633
5606
  width: width > 0 ? width : 0,
5634
5607
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5635
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5608
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5636
5609
  };
5637
5610
  }
5638
5611
  };
@@ -5706,16 +5679,17 @@ const NoteCurlyRightEngine = {
5706
5679
  getConnectorPoints(rectangle) {
5707
5680
  return RectangleClient.getEdgeCenterPoints(rectangle);
5708
5681
  },
5709
- getTextRectangle: (element) => {
5682
+ getTextRectangle: (board, element) => {
5710
5683
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5711
5684
  const strokeWidth = getStrokeWidthByElement(element);
5712
- const height = element.textHeight;
5713
5685
  const width = elementRectangle.width - elementRectangle.width * 0.09 - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5686
+ const text = element.text;
5687
+ const textSize = getTextSize(board, text, width);
5714
5688
  return {
5715
- height,
5689
+ height: textSize.height,
5716
5690
  width: width > 0 ? width : 0,
5717
5691
  x: elementRectangle.x + elementRectangle.width * 0.09 + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5718
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5692
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5719
5693
  };
5720
5694
  }
5721
5695
  };
@@ -5747,16 +5721,17 @@ const NoteSquareEngine = {
5747
5721
  getConnectorPoints(rectangle) {
5748
5722
  return RectangleClient.getEdgeCenterPoints(rectangle);
5749
5723
  },
5750
- getTextRectangle: (element) => {
5724
+ getTextRectangle: (board, element) => {
5751
5725
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5752
5726
  const strokeWidth = getStrokeWidthByElement(element);
5753
- const height = element.textHeight;
5754
5727
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5728
+ const text = element.text;
5729
+ const textSize = getTextSize(board, text, width);
5755
5730
  return {
5756
- height,
5731
+ height: textSize.height,
5757
5732
  width: width > 0 ? width : 0,
5758
5733
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5759
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5734
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5760
5735
  };
5761
5736
  }
5762
5737
  };
@@ -5819,16 +5794,17 @@ const DisplayEngine = {
5819
5794
  getConnectorPoints(rectangle) {
5820
5795
  return RectangleClient.getEdgeCenterPoints(rectangle);
5821
5796
  },
5822
- getTextRectangle: (element) => {
5797
+ getTextRectangle: (board, element) => {
5823
5798
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5824
5799
  const strokeWidth = getStrokeWidthByElement(element);
5825
- const height = element.textHeight;
5826
5800
  const width = elementRectangle.width - strokeWidth * 2 - elementRectangle.width * 0.25;
5801
+ const text = element.text;
5802
+ const textSize = getTextSize(board, text, width);
5827
5803
  return {
5828
5804
  width: width > 0 ? width : 0,
5829
- height: height,
5805
+ height: textSize.height,
5830
5806
  x: elementRectangle.x + strokeWidth + elementRectangle.width * 0.15,
5831
- y: elementRectangle.y + (elementRectangle.height - height) / 2
5807
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5832
5808
  };
5833
5809
  }
5834
5810
  };
@@ -5844,7 +5820,7 @@ const TableEngine = {
5844
5820
  const tableTopBorder = drawLine(rs, [x, y], [x + width, y], roughOptions);
5845
5821
  const tableLeftBorder = drawLine(rs, [x, y], [x, y + height], roughOptions);
5846
5822
  g.append(tableTopBorder, tableLeftBorder);
5847
- pointCells.forEach(cell => {
5823
+ pointCells.forEach((cell) => {
5848
5824
  const rectangle = RectangleClient.getRectangleByPoints(cell.points);
5849
5825
  const { x, y, width, height } = rectangle;
5850
5826
  const cellRectangle = drawRectangle(board, {
@@ -5878,16 +5854,16 @@ const TableEngine = {
5878
5854
  getConnectorPoints(rectangle) {
5879
5855
  return RectangleClient.getEdgeCenterPoints(rectangle);
5880
5856
  },
5881
- getTextRectangle(element, options) {
5857
+ getTextRectangle(board, element, options) {
5882
5858
  try {
5883
5859
  if (options && options.id) {
5884
- const cell = getCellWithPoints(options?.board, element, options.id);
5860
+ const cell = getCellWithPoints(board, element, options.id);
5885
5861
  if (cell) {
5886
5862
  if (PlaitTableElement.isVerticalText(cell)) {
5887
- return getVerticalTextRectangle(cell);
5863
+ return getVerticalTextRectangle(board, cell);
5888
5864
  }
5889
5865
  else {
5890
- return getHorizontalTextRectangle(cell);
5866
+ return getHorizontalTextRectangle(board, cell);
5891
5867
  }
5892
5868
  }
5893
5869
  }
@@ -5903,30 +5879,50 @@ const TableEngine = {
5903
5879
  };
5904
5880
  }
5905
5881
  };
5906
- function getVerticalTextRectangle(cell) {
5882
+ function getVerticalTextRectangle(board, cell) {
5907
5883
  const cellRectangle = RectangleClient.getRectangleByPoints(cell.points);
5908
5884
  const strokeWidth = getStrokeWidthByElement(cell);
5909
- const height = cell.textHeight || 0;
5910
5885
  const width = cellRectangle.height - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5911
- return {
5912
- width: width > 0 ? width : 0,
5913
- height,
5914
- x: cellRectangle.x - width / 2 + cellRectangle.width / 2,
5915
- y: cellRectangle.y + (cellRectangle.height - height) / 2
5916
- };
5886
+ return getTextRectangle(board, cell, width, cellRectangle);
5917
5887
  }
5918
- function getHorizontalTextRectangle(cell) {
5888
+ function getHorizontalTextRectangle(board, cell) {
5919
5889
  const cellRectangle = RectangleClient.getRectangleByPoints(cell.points);
5920
5890
  const strokeWidth = getStrokeWidthByElement(cell);
5921
- const height = cell.textHeight || 0;
5922
5891
  const width = cellRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5923
- return {
5924
- height,
5925
- width: width > 0 ? width : 0,
5926
- x: cellRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5927
- y: cellRectangle.y + (cellRectangle.height - height) / 2
5928
- };
5892
+ return getTextRectangle(board, cell, width, cellRectangle);
5893
+ }
5894
+ function getTextRectangle(board, cell, width, cellRectangle) {
5895
+ const text = cell.text;
5896
+ if (text) {
5897
+ const textSize = getTextSize(board, text, width);
5898
+ return {
5899
+ width: width > 0 ? width : 0,
5900
+ height: textSize.height,
5901
+ x: cellRectangle.x - width / 2 + cellRectangle.width / 2,
5902
+ y: cellRectangle.y + (cellRectangle.height - textSize.height) / 2
5903
+ };
5904
+ }
5905
+ else {
5906
+ return {
5907
+ width: 0,
5908
+ height: 0,
5909
+ x: cellRectangle.x,
5910
+ y: cellRectangle.y
5911
+ };
5912
+ }
5929
5913
  }
5914
+ const getCellTextHeight = (board, cell, isVertical = false) => {
5915
+ if (cell.text) {
5916
+ const cellRectangle = RectangleClient.getRectangleByPoints(cell.points);
5917
+ const strokeWidth = getStrokeWidthByElement(cell);
5918
+ let width = cellRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5919
+ if (isVertical) {
5920
+ width = cellRectangle.height - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5921
+ }
5922
+ return getTextSize(board, cell.text, width).height;
5923
+ }
5924
+ return 0;
5925
+ };
5930
5926
 
5931
5927
  function generateActorPath(rectangle) {
5932
5928
  const centerX = rectangle.x + rectangle.width / 2;
@@ -6032,12 +6028,13 @@ const ActorEngine = {
6032
6028
  }
6033
6029
  return getUnitVectorByPointAndPoint(connectionPoint, [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height]);
6034
6030
  },
6035
- getTextRectangle: (element) => {
6031
+ getTextRectangle: (board, element) => {
6036
6032
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6037
- const height = element.textHeight;
6038
6033
  const width = elementRectangle.width + 40;
6034
+ const text = element.text;
6035
+ const textSize = getTextSize(board, text, width);
6039
6036
  return {
6040
- height,
6037
+ height: textSize.height,
6041
6038
  width: width > 0 ? width : 0,
6042
6039
  x: elementRectangle.x - 20,
6043
6040
  y: elementRectangle.y + elementRectangle.height + 4
@@ -6070,16 +6067,17 @@ const ContainerEngine = {
6070
6067
  getConnectorPoints(rectangle) {
6071
6068
  return RectangleClient.getEdgeCenterPoints(rectangle);
6072
6069
  },
6073
- getTextRectangle(element) {
6070
+ getTextRectangle(board, element) {
6074
6071
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6075
6072
  const strokeWidth = getStrokeWidthByElement(element);
6076
- const height = element.textHeight;
6077
6073
  const width = 40 - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
6074
+ const text = element.text;
6075
+ const textSize = getTextSize(board, text, width);
6078
6076
  return {
6079
- height,
6077
+ height: textSize.height,
6080
6078
  width: width > 0 ? width : 0,
6081
6079
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6082
- y: elementRectangle.y + (elementRectangle.height - height) / 2
6080
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
6083
6081
  };
6084
6082
  }
6085
6083
  };
@@ -6158,26 +6156,28 @@ const PackageEngine = {
6158
6156
  }
6159
6157
  return getUnitVectorByPointAndPoint([rectangle.x + rectangle.width * 0.8, rectangle.y + 25], connectionPoint);
6160
6158
  },
6161
- getTextRectangle(element, options) {
6159
+ getTextRectangle(board, element, options) {
6162
6160
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6163
6161
  const strokeWidth = getStrokeWidthByElement(element);
6164
- const textHeight = element.texts?.find(item => item.id === options?.id)?.textHeight;
6165
- if (options?.id === GeometryCommonTextKeys.name) {
6162
+ const textInfo = element.texts?.find((item) => item.id === options?.id);
6163
+ if (options?.id === GeometryCommonTextKeys.name && textInfo) {
6166
6164
  const width = elementRectangle.width * 0.7 - ShapeDefaultSpace.rectangleAndText - strokeWidth;
6165
+ const textSize = getTextSize(board, textInfo.text, width);
6167
6166
  return {
6168
- height: textHeight,
6167
+ height: textSize.height,
6169
6168
  width: width > 0 ? width : 0,
6170
6169
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6171
- y: elementRectangle.y + (25 - textHeight) / 2
6170
+ y: elementRectangle.y + (25 - textSize.height) / 2
6172
6171
  };
6173
6172
  }
6174
- if (options?.id === GeometryCommonTextKeys.content) {
6173
+ if (options?.id === GeometryCommonTextKeys.content && textInfo) {
6175
6174
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
6175
+ const textSize = getTextSize(board, textInfo.text, width);
6176
6176
  return {
6177
- height: textHeight,
6177
+ height: textSize.height,
6178
6178
  width: width > 0 ? width : 0,
6179
6179
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6180
- y: elementRectangle.y + 25 + (elementRectangle.height - 25 - textHeight) / 2
6180
+ y: elementRectangle.y + 25 + (elementRectangle.height - 25 - textSize.height) / 2
6181
6181
  };
6182
6182
  }
6183
6183
  return elementRectangle;
@@ -6218,23 +6218,25 @@ const CombinedFragmentEngine = {
6218
6218
  getConnectorPoints(rectangle) {
6219
6219
  return RectangleClient.getEdgeCenterPoints(rectangle);
6220
6220
  },
6221
- getTextRectangle(element, options) {
6221
+ getTextRectangle(board, element, options) {
6222
6222
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6223
6223
  const strokeWidth = getStrokeWidthByElement(element);
6224
- const textHeight = element.texts?.find(item => item.id === options?.id)?.textHeight;
6225
- if (options?.id === GeometryCommonTextKeys.name) {
6224
+ const textInfo = element.texts?.find((item) => item.id === options?.id);
6225
+ if (options?.id === GeometryCommonTextKeys.name && textInfo) {
6226
6226
  const width = elementRectangle.width / 3 - 8 - ShapeDefaultSpace.rectangleAndText - strokeWidth;
6227
+ const textSize = getTextSize(board, textInfo.text, width);
6227
6228
  return {
6228
- height: textHeight,
6229
+ height: textSize.height,
6229
6230
  width: width > 0 ? width : 0,
6230
6231
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6231
- y: elementRectangle.y + (25 - textHeight) / 2
6232
+ y: elementRectangle.y + (25 - textSize.height) / 2
6232
6233
  };
6233
6234
  }
6234
- if (options?.id === GeometryCommonTextKeys.content) {
6235
+ if (options?.id === GeometryCommonTextKeys.content && textInfo) {
6235
6236
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
6237
+ const textSize = getTextSize(board, textInfo.text, width);
6236
6238
  return {
6237
- height: textHeight,
6239
+ height: textSize.height,
6238
6240
  width: width > 0 ? width : 0,
6239
6241
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6240
6242
  y: elementRectangle.y + 25 + ShapeDefaultSpace.rectangleAndText + strokeWidth
@@ -6323,16 +6325,17 @@ const ActiveClassEngine = {
6323
6325
  getConnectorPoints(rectangle) {
6324
6326
  return RectangleClient.getEdgeCenterPoints(rectangle);
6325
6327
  },
6326
- getTextRectangle: (element) => {
6328
+ getTextRectangle: (board, element) => {
6327
6329
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6328
6330
  const strokeWidth = getStrokeWidthByElement(element);
6329
- const height = element.textHeight;
6330
6331
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2 - elementRectangle.width * 0.125 * 2;
6332
+ const text = element.text;
6333
+ const textSize = getTextSize(board, text, width);
6331
6334
  return {
6332
- height,
6335
+ height: textSize.height,
6333
6336
  width: width > 0 ? width : 0,
6334
6337
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.125,
6335
- y: elementRectangle.y + (elementRectangle.height - height) / 2
6338
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
6336
6339
  };
6337
6340
  }
6338
6341
  };
@@ -6377,16 +6380,17 @@ const NoteEngine = {
6377
6380
  getConnectorPoints(rectangle) {
6378
6381
  return RectangleClient.getEdgeCenterPoints(rectangle);
6379
6382
  },
6380
- getTextRectangle: (element) => {
6383
+ getTextRectangle: (board, element) => {
6381
6384
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6382
6385
  const strokeWidth = getStrokeWidthByElement(element);
6383
- const height = element.textHeight;
6384
6386
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth - 15;
6387
+ const text = element.text;
6388
+ const textSize = getTextSize(board, text, width);
6385
6389
  return {
6386
- height,
6390
+ height: textSize.height,
6387
6391
  width: width > 0 ? width : 0,
6388
6392
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6389
- y: elementRectangle.y + (elementRectangle.height - height) / 2
6393
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
6390
6394
  };
6391
6395
  }
6392
6396
  };
@@ -6761,16 +6765,17 @@ const ComponentEngine = {
6761
6765
  [points.mainStart[0], rectangle.y + rectangle.height / 2]
6762
6766
  ];
6763
6767
  },
6764
- getTextRectangle(element) {
6768
+ getTextRectangle(board, element) {
6765
6769
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6766
6770
  const strokeWidth = getStrokeWidthByElement(element);
6767
- const height = element.textHeight;
6768
6771
  const width = elementRectangle.width - 24 - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
6772
+ const text = element.text;
6773
+ const textSize = getTextSize(board, text, width);
6769
6774
  return {
6770
- height,
6775
+ height: textSize.height,
6771
6776
  width: width > 0 ? width : 0,
6772
6777
  x: elementRectangle.x + 24 + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6773
- y: elementRectangle.y + (elementRectangle.height - height) / 2
6778
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
6774
6779
  };
6775
6780
  }
6776
6781
  };
@@ -6815,17 +6820,18 @@ const ComponentBoxEngine = {
6815
6820
  getConnectorPoints(rectangle) {
6816
6821
  return RectangleClient.getEdgeCenterPoints(rectangle);
6817
6822
  },
6818
- getTextRectangle(element) {
6823
+ getTextRectangle(board, element) {
6819
6824
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6820
6825
  const strokeWidth = getStrokeWidthByElement(element);
6821
- const height = element.textHeight;
6822
6826
  const componentWidth = elementRectangle.width - 45 * 2 - 18 > 1 ? 45 : elementRectangle.width * 0.25;
6823
6827
  const width = elementRectangle.width - 18 - componentWidth - ShapeDefaultSpace.rectangleAndText - strokeWidth * 2;
6828
+ const text = element.text;
6829
+ const textSize = getTextSize(board, text, width);
6824
6830
  return {
6825
- height,
6831
+ height: textSize.height,
6826
6832
  width: width > 0 ? width : 0,
6827
6833
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6828
- y: elementRectangle.y + (elementRectangle.height - height) / 2
6834
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
6829
6835
  };
6830
6836
  }
6831
6837
  };
@@ -6858,16 +6864,17 @@ const TemplateEngine = {
6858
6864
  getConnectorPoints(rectangle) {
6859
6865
  return RectangleClient.getEdgeCenterPoints(rectangle);
6860
6866
  },
6861
- getTextRectangle(element) {
6867
+ getTextRectangle(board, element) {
6862
6868
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
6863
6869
  const strokeWidth = getStrokeWidthByElement(element);
6864
- const height = element.textHeight;
6865
6870
  const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
6871
+ const text = element.text;
6872
+ const textSize = getTextSize(board, text, width);
6866
6873
  return {
6867
- height,
6874
+ height: textSize.height,
6868
6875
  width: width > 0 ? width : 0,
6869
6876
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
6870
- y: elementRectangle.y + (elementRectangle.height - height) / 2
6877
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
6871
6878
  };
6872
6879
  }
6873
6880
  };
@@ -7361,8 +7368,7 @@ class GeometryComponent extends CommonElementFlavour {
7361
7368
  if (isMultipleTextGeometry(element)) {
7362
7369
  DrawTransforms.setDrawTexts(this.board, element, {
7363
7370
  id: text.id,
7364
- text: textManageChangeData.newText,
7365
- textHeight: textManageChangeData.height
7371
+ text: textManageChangeData.newText
7366
7372
  });
7367
7373
  }
7368
7374
  else {
@@ -7383,12 +7389,12 @@ class GeometryComponent extends CommonElementFlavour {
7383
7389
  this.textGenerator = new SingleTextGenerator(this.board, this.element, this.element.text, {
7384
7390
  onChange: onTextChange,
7385
7391
  getMaxWidth: () => {
7386
- let width = getTextRectangle(this.element).width;
7392
+ let width = getTextRectangle$1(this.board, this.element).width;
7387
7393
  const getRectangle = getEngine(this.element.shape).getTextRectangle;
7388
7394
  if (getRectangle) {
7389
- width = getRectangle(this.element).width;
7395
+ width = getRectangle(this.board, this.element).width;
7390
7396
  }
7391
- return this.element?.autoSize ? GeometryThreshold.defaultTextMaxWidth : width;
7397
+ return PlaitDrawElement.isText(this.element) && this.element.autoSize ? GeometryThreshold.defaultTextMaxWidth : width;
7392
7398
  }
7393
7399
  });
7394
7400
  }
@@ -7512,12 +7518,10 @@ class ArrowLineComponent extends CommonElementFlavour {
7512
7518
  const path = PlaitBoard.findPath(this.board, this.element);
7513
7519
  const node = PlaitNode.get(this.board, path);
7514
7520
  const texts = [...node.texts];
7515
- const newWidth = textManageChangeData.width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : textManageChangeData.width;
7521
+ // const newWidth = textManageChangeData.width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : textManageChangeData.width;
7516
7522
  texts.splice(index, 1, {
7517
7523
  text: textManageChangeData.newText ? textManageChangeData.newText : this.element.texts[index].text,
7518
- position: this.element.texts[index].position,
7519
- width: newWidth,
7520
- height: textManageChangeData.height
7524
+ position: this.element.texts[index].position
7521
7525
  });
7522
7526
  DrawTransforms.setArrowLineTexts(this.board, this.element, texts);
7523
7527
  textManageChangeData.operations && memorizeLatestText(this.element, textManageChangeData.operations);
@@ -7633,7 +7637,7 @@ const withDrawHotkey = (board) => {
7633
7637
  const hitElement = getHitElementByPoint(board, point, undefined, false);
7634
7638
  if (hitElement && PlaitDrawElement.isGeometry(hitElement) && isDrawElementIncludeText(hitElement)) {
7635
7639
  if (isMultipleTextGeometry(hitElement)) {
7636
- const hitText = getHitMultipleGeometryText(hitElement, point) ||
7640
+ const hitText = getHitMultipleGeometryText(board, hitElement, point) ||
7637
7641
  hitElement.texts.find((item) => item.id.includes(GeometryCommonTextKeys.content)) ||
7638
7642
  hitElement.texts[0];
7639
7643
  editText(board, hitElement, hitText);
@@ -7683,7 +7687,7 @@ const withGeometryCreateByDrag = (board) => {
7683
7687
  if (!fakeCreateTextRef) {
7684
7688
  const textManage = new TextManage(board, {
7685
7689
  getRectangle: () => {
7686
- return getTextRectangle(temporaryElement);
7690
+ return getTextRectangle$1(board, temporaryElement);
7687
7691
  }
7688
7692
  });
7689
7693
  textManage.draw(temporaryElement.text);
@@ -8167,16 +8171,10 @@ const withArrowLineText = (board) => {
8167
8171
  const defaultLineText = getDefaultLineText(board);
8168
8172
  const textMemory = getMemorizedLatest('arrow-line')?.text || {};
8169
8173
  const textElement = buildText(defaultLineText, undefined, textMemory);
8170
- const { width, height } = measureElement(board, textElement, {
8171
- fontSize: DEFAULT_FONT_SIZE,
8172
- fontFamily: DEFAULT_FONT_FAMILY
8173
- });
8174
8174
  const ratio = getRatioByPoint(points, point);
8175
8175
  texts.push({
8176
8176
  text: textElement,
8177
- position: ratio,
8178
- width,
8179
- height
8177
+ position: ratio
8180
8178
  });
8181
8179
  DrawTransforms.setArrowLineTexts(board, hitTarget, texts);
8182
8180
  setTimeout(() => {
@@ -8679,7 +8677,7 @@ class TableComponent extends CommonElementFlavour {
8679
8677
  const textManage = getTextManageByCell(this.board, item);
8680
8678
  if (textManage) {
8681
8679
  const engine = getEngine(TableSymbols.table);
8682
- const rectangle = engine.getTextRectangle(this.element, { id: item.id, board: this.board });
8680
+ const rectangle = engine.getTextRectangle(this.board, this.element, { id: item.id, board: this.board });
8683
8681
  textManage.g.classList.add('vertical-cell-text');
8684
8682
  setAngleForG(textManage.g, RectangleClient.getCenterPoint(rectangle), degreesToRadians(-90));
8685
8683
  }
@@ -8693,7 +8691,6 @@ class TableComponent extends CommonElementFlavour {
8693
8691
  return {
8694
8692
  id: item.id,
8695
8693
  text: item.text,
8696
- textHeight: item.textHeight,
8697
8694
  board: this.board
8698
8695
  };
8699
8696
  });
@@ -8713,17 +8710,17 @@ class TableComponent extends CommonElementFlavour {
8713
8710
  if (PlaitTableElement.isVerticalText(cell)) {
8714
8711
  const cellRectangle = RectangleClient.getRectangleByPoints(cell.points);
8715
8712
  const strokeWidth = getStrokeWidthByElement(cell);
8716
- const width = cell.textHeight || 0;
8717
- const height = cellRectangle.height - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
8713
+ const width = cellRectangle.height - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
8714
+ const height = getCellTextHeight(this.board, cell, true);
8718
8715
  return {
8719
- width,
8720
- height: height > 0 ? height : 0,
8716
+ width: height,
8717
+ height: width > 0 ? width : 0,
8721
8718
  x: cellRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
8722
- y: cellRectangle.y + (cellRectangle.height - height) / 2
8719
+ y: cellRectangle.y + (cellRectangle.height - width) / 2
8723
8720
  };
8724
8721
  }
8725
8722
  else {
8726
- return getHorizontalTextRectangle(cell);
8723
+ return getHorizontalTextRectangle(this.board, cell);
8727
8724
  }
8728
8725
  }
8729
8726
  });
@@ -8946,9 +8943,9 @@ const withTable = (board) => {
8946
8943
  event.preventDefault();
8947
8944
  if (PlaitDrawElement.isElementByTable(targetElement)) {
8948
8945
  const cells = getSelectedCells(targetElement);
8949
- let cell = targetElement.cells.find((item) => item.text && item.textHeight);
8946
+ let cell = targetElement.cells.find((item) => item.text);
8950
8947
  if (cells?.length) {
8951
- cell = cells.find((item) => item.text && item.textHeight);
8948
+ cell = cells.find((item) => item.text);
8952
8949
  }
8953
8950
  if (cell) {
8954
8951
  editCell(board, cell);
@@ -8965,7 +8962,7 @@ const withTable = (board) => {
8965
8962
  const hitElement = getHitElementByPoint(board, point);
8966
8963
  if (hitElement && PlaitDrawElement.isElementByTable(hitElement)) {
8967
8964
  const hitCell = getHitCell(tableBoard, hitElement, point);
8968
- if (hitCell && hitCell.text && hitCell.textHeight) {
8965
+ if (hitCell && hitCell.text) {
8969
8966
  editCell(board, hitCell);
8970
8967
  return;
8971
8968
  }
@@ -8984,7 +8981,7 @@ const withTable = (board) => {
8984
8981
  const point = toViewBoxPoint(tableBoard, toHostPoint(tableBoard, event.x, event.y));
8985
8982
  const element = getSelectedTableElements(tableBoard)[0];
8986
8983
  const hitCell = getHitCell(tableBoard, element, point);
8987
- if (hitCell && hitCell.text && hitCell.textHeight) {
8984
+ if (hitCell && hitCell.text) {
8988
8985
  setSelectedCells(element, [hitCell]);
8989
8986
  }
8990
8987
  }
@@ -9390,5 +9387,5 @@ const withDraw = (board) => {
9390
9387
  * Generated bundle index. Do not edit.
9391
9388
  */
9392
9389
 
9393
- export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BOARD_TO_PRE_COMMIT, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultLineStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawI18nKey, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_ALIGN_TOLERANCE, LINE_AUTO_COMPLETE_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_OPACITY, LINE_AUTO_COMPLETE_OPACITY, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LINE_TEXT, LINE_TEXT_SPACE, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultGeometryText, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectionFromConnectionPoint, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSolidElements, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getSwimlaneShapes, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedCustomGeometry, isClosedDrawElement, isClosedPoints, isDrawElementIncludeText, isDrawElementsIncludeText, isEmptyTextElement, isFilledDrawElement, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneShape, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
9390
+ export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BOARD_TO_PRE_COMMIT, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultLineStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawI18nKey, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_ALIGN_TOLERANCE, LINE_AUTO_COMPLETE_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, LINE_AUTO_COMPLETE_HOVERED_OPACITY, LINE_AUTO_COMPLETE_OPACITY, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LINE_TEXT, LINE_TEXT_SPACE, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultGeometryText, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectionFromConnectionPoint, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSolidElements, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getSwimlaneShapes, getTextKey, getTextManage, getTextManageByCell, getTextRectangle$1 as getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedCustomGeometry, isClosedDrawElement, isClosedPoints, isDrawElementIncludeText, isDrawElementsIncludeText, isEmptyTextElement, isFilledDrawElement, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneShape, isSwimlaneWithHeader, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
9394
9391
  //# sourceMappingURL=plait-draw.mjs.map