@plait/draw 0.87.0 → 0.88.1

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.
@@ -1819,18 +1819,10 @@ const CloudEngine = {
1819
1819
  return RectangleClient.getEdgeCenterPoints(rectangle);
1820
1820
  },
1821
1821
  getTextRectangle: (board, element) => {
1822
- const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
1823
- const strokeWidth = getStrokeWidthByElement(element);
1824
- const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
1825
- const width = originWidth / 1.5;
1826
- const text = element.text;
1827
- const textSize = getTextSize(board, text, width);
1828
- return {
1829
- height: textSize.height,
1830
- width: width > 0 ? width : 0,
1831
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
1832
- y: elementRectangle.y + elementRectangle.height / 6 + ((elementRectangle.height * 4) / 6 - textSize.height) / 2
1833
- };
1822
+ const widthRatio = 1 / 1.5;
1823
+ const rectangle = RectangleClient.getRectangleByPoints(element.points);
1824
+ const textRectangle = getCustomTextRectangle(board, element, widthRatio);
1825
+ return textRectangle;
1834
1826
  }
1835
1827
  };
1836
1828
 
@@ -2072,6 +2064,17 @@ const getTextRectangle$1 = (board, element) => {
2072
2064
  y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
2073
2065
  };
2074
2066
  };
2067
+ const getCustomTextRectangle = (board, element, widthRatio) => {
2068
+ const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
2069
+ const width = widthRatio * elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - getStrokeWidthByElement(element) * 2;
2070
+ const textSize = getTextSize(board, element.text, width);
2071
+ return {
2072
+ height: textSize.height,
2073
+ width: width,
2074
+ x: elementRectangle.x + (elementRectangle.width - width) / 2,
2075
+ y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
2076
+ };
2077
+ };
2075
2078
  const getStrokeWidthByElement = (element) => {
2076
2079
  if (PlaitDrawElement.isText(element)) {
2077
2080
  return 0;
@@ -4090,16 +4093,9 @@ const CommentEngine = {
4090
4093
  },
4091
4094
  getTextRectangle: (board, element) => {
4092
4095
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4093
- const strokeWidth = getStrokeWidthByElement(element);
4094
- const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4095
- const text = element.text;
4096
- const textSize = getTextSize(board, text, width);
4097
- return {
4098
- height: textSize.height,
4099
- width: width > 0 ? width : 0,
4100
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
4101
- y: elementRectangle.y + (elementRectangle.height * heightRatio$1 - textSize.height) / 2
4102
- };
4096
+ const textRectangle = getTextRectangle$1(board, element);
4097
+ textRectangle.y = elementRectangle.y + (elementRectangle.height * heightRatio$1 - textRectangle.height) / 2;
4098
+ return textRectangle;
4103
4099
  }
4104
4100
  };
4105
4101
  const getCommentPoints = (rectangle) => {
@@ -4190,11 +4186,8 @@ const CrossEngine = createPolygonEngine({
4190
4186
  return RectangleClient.getEdgeCenterPoints(rectangle);
4191
4187
  },
4192
4188
  getTextRectangle: (board, element) => {
4193
- const rectangle = getTextRectangle$1(board, element);
4194
- const width = rectangle.width;
4195
- rectangle.width = rectangle.width / 2;
4196
- rectangle.x += width / 4;
4197
- return rectangle;
4189
+ const widthRatio = 1 / 2;
4190
+ return getCustomTextRectangle(board, element, widthRatio);
4198
4191
  }
4199
4192
  });
4200
4193
 
@@ -4204,10 +4197,7 @@ const DiamondEngine = createPolygonEngine({
4204
4197
  return RectangleClient.getEdgeCenterPoints(rectangle);
4205
4198
  },
4206
4199
  getTextRectangle: (board, element) => {
4207
- const rectangle = getTextRectangle$1(board, element);
4208
- rectangle.width = rectangle.width / 2;
4209
- rectangle.x += rectangle.width / 2;
4210
- return rectangle;
4200
+ return getCustomTextRectangle(board, element, 1 / 2);
4211
4201
  }
4212
4202
  });
4213
4203
 
@@ -4245,11 +4235,7 @@ function createEllipseEngine(createOptions) {
4245
4235
  return RectangleClient.getEdgeCenterPoints(rectangle);
4246
4236
  },
4247
4237
  getTextRectangle: (board, element) => {
4248
- const rectangle = getTextRectangle$1(board, element);
4249
- const width = rectangle.width;
4250
- rectangle.width = (rectangle.width * 3) / 4;
4251
- rectangle.x += width / 8;
4252
- return rectangle;
4238
+ return getCustomTextRectangle(board, element, 3 / 4);
4253
4239
  }
4254
4240
  };
4255
4241
  if (createOptions?.draw) {
@@ -4278,11 +4264,7 @@ const HexagonEngine = createPolygonEngine({
4278
4264
  return RectangleClient.getEdgeCenterPoints(rectangle);
4279
4265
  },
4280
4266
  getTextRectangle: (board, element) => {
4281
- const rectangle = getTextRectangle$1(board, element);
4282
- const width = rectangle.width;
4283
- rectangle.width = (rectangle.width * 3) / 4;
4284
- rectangle.x += width / 8;
4285
- return rectangle;
4267
+ return getCustomTextRectangle(board, element, 3 / 4);
4286
4268
  }
4287
4269
  });
4288
4270
 
@@ -4306,11 +4288,10 @@ const LeftArrowEngine = createPolygonEngine({
4306
4288
  ];
4307
4289
  },
4308
4290
  getTextRectangle: (board, element) => {
4309
- const rectangle = getTextRectangle$1(board, element);
4310
- const width = rectangle.width;
4311
- rectangle.width = rectangle.width * (1 - 0.32);
4312
- rectangle.x += width * 0.32;
4313
- return rectangle;
4291
+ const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4292
+ const customTextRectangle = getCustomTextRectangle(board, element, 1 - 0.32);
4293
+ customTextRectangle.x = elementRectangle.x + elementRectangle.width * 0.32 + ShapeDefaultSpace.rectangleAndText;
4294
+ return customTextRectangle;
4314
4295
  }
4315
4296
  });
4316
4297
 
@@ -4332,11 +4313,7 @@ const OctagonEngine = createPolygonEngine({
4332
4313
  return RectangleClient.getEdgeCenterPoints(rectangle);
4333
4314
  },
4334
4315
  getTextRectangle: (board, element) => {
4335
- const rectangle = getTextRectangle$1(board, element);
4336
- const width = rectangle.width;
4337
- rectangle.width = (rectangle.width * 3) / 4;
4338
- rectangle.x += width / 8;
4339
- return rectangle;
4316
+ return getCustomTextRectangle(board, element, 3 / 4);
4340
4317
  }
4341
4318
  });
4342
4319
 
@@ -4355,11 +4332,7 @@ const ParallelogramEngine = createPolygonEngine({
4355
4332
  return getCenterPointsOnPolygon$1(cornerPoints);
4356
4333
  },
4357
4334
  getTextRectangle: (board, element) => {
4358
- const rectangle = getTextRectangle$1(board, element);
4359
- const width = rectangle.width;
4360
- rectangle.width = rectangle.width / 2;
4361
- rectangle.x += width / 4;
4362
- return rectangle;
4335
+ return getCustomTextRectangle(board, element, 1 / 2);
4363
4336
  }
4364
4337
  });
4365
4338
 
@@ -4376,17 +4349,11 @@ const PentagonEngine = createPolygonEngine({
4376
4349
  getPolygonPoints: getPentagonPoints,
4377
4350
  getTextRectangle: (board, element) => {
4378
4351
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4379
- const strokeWidth = getStrokeWidthByElement(element);
4380
- const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4381
- const width = (originWidth * 3) / 5;
4382
- const text = element.text;
4383
- const textSize = getTextSize(board, text, width);
4384
- return {
4385
- height: textSize.height,
4386
- width: width > 0 ? width : 0,
4387
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 5,
4388
- y: elementRectangle.y + elementRectangle.height / 5 + ((elementRectangle.height * 4) / 5 - textSize.height) / 2
4389
- };
4352
+ const customTextRectangle = getCustomTextRectangle(board, element, 3 / 5);
4353
+ const startY = elementRectangle.y + elementRectangle.height / 5;
4354
+ const endY = elementRectangle.y + elementRectangle.height;
4355
+ customTextRectangle.y = startY + (endY - startY - customTextRectangle.height) / 2;
4356
+ return customTextRectangle;
4390
4357
  }
4391
4358
  });
4392
4359
 
@@ -4407,10 +4374,9 @@ const PentagonArrowEngine = createPolygonEngine({
4407
4374
  },
4408
4375
  getTextRectangle: (board, element) => {
4409
4376
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4410
- const rectangle = getTextRectangle$1(board, element);
4411
- const wider = elementRectangle.width > elementRectangle.height / 2 + 20;
4412
- rectangle.width = wider ? elementRectangle.width - elementRectangle.height / 2 : rectangle.width;
4413
- return rectangle;
4377
+ const customTextRectangle = getCustomTextRectangle(board, element, 3 / 4);
4378
+ customTextRectangle.x = elementRectangle.x + ShapeDefaultSpace.rectangleAndText;
4379
+ return customTextRectangle;
4414
4380
  }
4415
4381
  });
4416
4382
 
@@ -4429,11 +4395,10 @@ const ProcessArrowEngine = createPolygonEngine({
4429
4395
  getPolygonPoints: getProcessArrowPoints,
4430
4396
  getTextRectangle: (board, element) => {
4431
4397
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4432
- const rectangle = getTextRectangle$1(board, element);
4433
4398
  const wider = elementRectangle.width > elementRectangle.height + 20;
4434
- rectangle.width = wider ? elementRectangle.width - elementRectangle.height : rectangle.width;
4435
- rectangle.x = wider ? elementRectangle.x + elementRectangle.height / 2 : rectangle.x;
4436
- return rectangle;
4399
+ const widthRatio = wider ? (elementRectangle.width - elementRectangle.height) / elementRectangle.width : 3 / 4;
4400
+ const customTextRectangle = getCustomTextRectangle(board, element, widthRatio);
4401
+ return customTextRectangle;
4437
4402
  }
4438
4403
  });
4439
4404
 
@@ -4457,9 +4422,10 @@ const RightArrowEngine = createPolygonEngine({
4457
4422
  ];
4458
4423
  },
4459
4424
  getTextRectangle: (board, element) => {
4460
- const rectangle = getTextRectangle$1(board, element);
4461
- rectangle.width = rectangle.width * 0.68;
4462
- return rectangle;
4425
+ const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4426
+ const customTextRectangle = getCustomTextRectangle(board, element, 1 - 0.32);
4427
+ customTextRectangle.x = elementRectangle.x + ShapeDefaultSpace.rectangleAndText;
4428
+ return customTextRectangle;
4463
4429
  }
4464
4430
  });
4465
4431
 
@@ -4596,16 +4562,9 @@ const RoundCommentEngine = {
4596
4562
  },
4597
4563
  getTextRectangle: (board, element) => {
4598
4564
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4599
- const strokeWidth = getStrokeWidthByElement(element);
4600
- const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4601
- const text = element.text;
4602
- const textSize = getTextSize(board, text, width);
4603
- return {
4604
- height: textSize.height,
4605
- width: width > 0 ? width : 0,
4606
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
4607
- y: elementRectangle.y + (elementRectangle.height * heightRatio - textSize.height) / 2
4608
- };
4565
+ const textRectangle = getTextRectangle$1(board, element);
4566
+ textRectangle.y = elementRectangle.y + (elementRectangle.height * heightRatio - textRectangle.height) / 2;
4567
+ return textRectangle;
4609
4568
  }
4610
4569
  };
4611
4570
  const getRoundCommentPoints = (rectangle) => {
@@ -4635,11 +4594,7 @@ const TrapezoidEngine = createPolygonEngine({
4635
4594
  return getCenterPointsOnPolygon$1(points);
4636
4595
  },
4637
4596
  getTextRectangle(board, element) {
4638
- const rectangle = getTextRectangle$1(board, element);
4639
- const width = rectangle.width;
4640
- rectangle.width = (rectangle.width * 3) / 4;
4641
- rectangle.x += width / 8;
4642
- return rectangle;
4597
+ return getCustomTextRectangle(board, element, 3 / 4);
4643
4598
  }
4644
4599
  });
4645
4600
 
@@ -4658,18 +4613,13 @@ const TriangleEngine = createPolygonEngine({
4658
4613
  return [...lineCenterPoints, ...cornerPoints];
4659
4614
  },
4660
4615
  getTextRectangle: (board, element) => {
4616
+ const customTextRectangle = getCustomTextRectangle(board, element, 1 / 2);
4661
4617
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4662
- const strokeWidth = getStrokeWidthByElement(element);
4663
- const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4664
- const width = (originWidth * 2) / 3;
4665
- const text = element.text;
4666
- const textSize = getTextSize(board, text, width);
4667
- return {
4668
- height: textSize.height,
4669
- width: width > 0 ? width : 0,
4670
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
4671
- y: elementRectangle.y + (elementRectangle.height * 3) / 5 + ((elementRectangle.height * 2) / 5 - textSize.height) / 2
4672
- };
4618
+ customTextRectangle.y =
4619
+ elementRectangle.y +
4620
+ (elementRectangle.height * 2.5) / 5 +
4621
+ (elementRectangle.height - (elementRectangle.height * 2.5) / 5 - customTextRectangle.height) / 2;
4622
+ return customTextRectangle;
4673
4623
  }
4674
4624
  });
4675
4625
 
@@ -4719,17 +4669,12 @@ const StarEngine = createPolygonEngine({
4719
4669
  },
4720
4670
  getTextRectangle: (board, element) => {
4721
4671
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4722
- const strokeWidth = getStrokeWidthByElement(element);
4723
- const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4724
- const width = originWidth / 2;
4725
- const text = element.text;
4726
- const textSize = getTextSize(board, text, width);
4727
- return {
4728
- height: textSize.height,
4729
- width: width > 0 ? width : 0,
4730
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 4,
4731
- y: elementRectangle.y + (elementRectangle.height * 1) / 6 + ((elementRectangle.height * 4) / 5 - textSize.height) / 2
4732
- };
4672
+ const customTextRectangle = getCustomTextRectangle(board, element, 1 / 2);
4673
+ customTextRectangle.y =
4674
+ elementRectangle.y +
4675
+ elementRectangle.height / 5 +
4676
+ (elementRectangle.height - elementRectangle.height / 5 - customTextRectangle.height) / 2;
4677
+ return customTextRectangle;
4733
4678
  }
4734
4679
  });
4735
4680
 
@@ -4845,10 +4790,7 @@ const PreparationEngine = createPolygonEngine({
4845
4790
  return RectangleClient.getEdgeCenterPoints(rectangle);
4846
4791
  },
4847
4792
  getTextRectangle(board, element) {
4848
- const rectangle = getTextRectangle$1(board, element);
4849
- const width = rectangle.width;
4850
- rectangle.width = (rectangle.width * 2) / 3;
4851
- rectangle.x += width / 6;
4793
+ const rectangle = getCustomTextRectangle(board, element, 2 / 3);
4852
4794
  return rectangle;
4853
4795
  }
4854
4796
  });
@@ -4868,10 +4810,7 @@ const ManualLoopEngine = createPolygonEngine({
4868
4810
  return getCenterPointsOnPolygon$1(cornerPoints);
4869
4811
  },
4870
4812
  getTextRectangle: (board, element) => {
4871
- const rectangle = getTextRectangle$1(board, element);
4872
- const width = rectangle.width;
4873
- rectangle.width = (rectangle.width * 3) / 4;
4874
- rectangle.x += width / 8;
4813
+ const rectangle = getCustomTextRectangle(board, element, 3 / 4);
4875
4814
  return rectangle;
4876
4815
  }
4877
4816
  });
@@ -4951,10 +4890,7 @@ const DelayEngine = {
4951
4890
  const StoredDataEngine = {
4952
4891
  draw(board, rectangle, options) {
4953
4892
  const rs = PlaitBoard.getRoughSVG(board);
4954
- const shape = rs.path(`M${rectangle.x + rectangle.width / 10} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y} A ${rectangle.width /
4955
- 10} ${rectangle.height / 2}, 0, 0, 0,${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height} L${rectangle.x +
4956
- rectangle.width / 10} ${rectangle.y + rectangle.height}A ${rectangle.width / 10} ${rectangle.height /
4957
- 2}, 0, 0, 1,${rectangle.x + rectangle.width / 10} ${rectangle.y}`, { ...options, fillStyle: 'solid' });
4893
+ const shape = rs.path(`M${rectangle.x + rectangle.width / 10} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y} A ${rectangle.width / 10} ${rectangle.height / 2}, 0, 0, 0,${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height} L${rectangle.x + rectangle.width / 10} ${rectangle.y + rectangle.height}A ${rectangle.width / 10} ${rectangle.height / 2}, 0, 0, 1,${rectangle.x + rectangle.width / 10} ${rectangle.y}`, { ...options, fillStyle: 'solid' });
4958
4894
  setStrokeLinecap(shape, 'round');
4959
4895
  return shape;
4960
4896
  },
@@ -5005,7 +4941,7 @@ const StoredDataEngine = {
5005
4941
  const point = [connectionPoint[0] - centerPoint[0], -(connectionPoint[1] - centerPoint[1])];
5006
4942
  const slope = getEllipseTangentSlope(point[0], point[1], a, b);
5007
4943
  const vector = getVectorFromPointAndSlope(point[0], point[1], slope);
5008
- return isBackEllipse ? vector.map(num => -num) : vector;
4944
+ return isBackEllipse ? vector.map((num) => -num) : vector;
5009
4945
  },
5010
4946
  getConnectorPoints(rectangle) {
5011
4947
  return [
@@ -5016,11 +4952,8 @@ const StoredDataEngine = {
5016
4952
  ];
5017
4953
  },
5018
4954
  getTextRectangle(board, element) {
5019
- const rectangle = getTextRectangle$1(board, element);
5020
- const width = rectangle.width;
5021
- rectangle.width = (rectangle.width * 3) / 4;
5022
- rectangle.x += width / 8;
5023
- return rectangle;
4955
+ const widthRatio = 3 / 4;
4956
+ return getCustomTextRectangle(board, element, widthRatio);
5024
4957
  }
5025
4958
  };
5026
4959
 
@@ -5197,17 +5130,7 @@ const DocumentEngine = {
5197
5130
  return getUnitVectorByPointAndPoint(connectionPoint, [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height]);
5198
5131
  },
5199
5132
  getTextRectangle: (board, element) => {
5200
- const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5201
- const strokeWidth = getStrokeWidthByElement(element);
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);
5205
- return {
5206
- height: textSize.height,
5207
- width: width > 0 ? width : 0,
5208
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.06,
5209
- y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5210
- };
5133
+ return getCustomTextRectangle(board, element, 0.88);
5211
5134
  }
5212
5135
  };
5213
5136
 
@@ -5310,17 +5233,7 @@ const MultiDocumentEngine = {
5310
5233
  return [factor.x, factor.y];
5311
5234
  },
5312
5235
  getTextRectangle: (board, element) => {
5313
- const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5314
- const strokeWidth = getStrokeWidthByElement(element);
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);
5318
- return {
5319
- height: textSize.height,
5320
- width: width > 0 ? width - 10 : 0,
5321
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.06,
5322
- y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5323
- };
5236
+ return getCustomTextRectangle(board, element, 0.88);
5324
5237
  }
5325
5238
  };
5326
5239
 
@@ -5328,13 +5241,10 @@ const DatabaseEngine = {
5328
5241
  draw(board, rectangle, options) {
5329
5242
  const rs = PlaitBoard.getRoughSVG(board);
5330
5243
  const shape = rs.path(`M${rectangle.x} ${rectangle.y + rectangle.height * 0.15}
5331
- A${rectangle.width / 2} ${rectangle.height * 0.15}, 0, 0, 0,${rectangle.x + rectangle.width} ${rectangle.y +
5332
- rectangle.height * 0.15}
5244
+ A${rectangle.width / 2} ${rectangle.height * 0.15}, 0, 0, 0,${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height * 0.15}
5333
5245
  A${rectangle.width / 2} ${rectangle.height * 0.15}, 0, 0, 0,${rectangle.x} ${rectangle.y + rectangle.height * 0.15}
5334
5246
  V${rectangle.y + rectangle.height - rectangle.height * 0.15}
5335
- A${rectangle.width / 2} ${rectangle.height * 0.15}, 0, 0, 0, ${rectangle.x + rectangle.width} ${rectangle.y +
5336
- rectangle.height -
5337
- rectangle.height * 0.15}
5247
+ A${rectangle.width / 2} ${rectangle.height * 0.15}, 0, 0, 0, ${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height - rectangle.height * 0.15}
5338
5248
  V${rectangle.y + rectangle.height * 0.15}`, { ...options, fillStyle: 'solid' });
5339
5249
  setStrokeLinecap(shape, 'round');
5340
5250
  return shape;
@@ -5392,16 +5302,12 @@ const DatabaseEngine = {
5392
5302
  },
5393
5303
  getTextRectangle: (board, element) => {
5394
5304
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5395
- const strokeWidth = getStrokeWidthByElement(element);
5396
- const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5397
- const text = element.text;
5398
- const textSize = getTextSize(board, text, width);
5399
- return {
5400
- height: textSize.height,
5401
- width: width > 0 ? width : 0,
5402
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5403
- y: elementRectangle.y + elementRectangle.height * 0.3 + (elementRectangle.height - elementRectangle.height * 0.45 - textSize.height) / 2
5404
- };
5305
+ const textRectangle = getCustomTextRectangle(board, element, 1);
5306
+ textRectangle.y += getStrokeWidthByElement(element);
5307
+ const startY = elementRectangle.y + elementRectangle.height * 0.45;
5308
+ const endY = elementRectangle.y + elementRectangle.height - elementRectangle.height * 0.3;
5309
+ textRectangle.y = startY + (endY - startY - textRectangle.height) / 2;
5310
+ return textRectangle;
5405
5311
  }
5406
5312
  };
5407
5313
 
@@ -5597,16 +5503,9 @@ const NoteCurlyLeftEngine = {
5597
5503
  },
5598
5504
  getTextRectangle: (board, element) => {
5599
5505
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5600
- const strokeWidth = getStrokeWidthByElement(element);
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);
5604
- return {
5605
- height: textSize.height,
5606
- width: width > 0 ? width : 0,
5607
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5608
- y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5609
- };
5506
+ const textRectangle = getCustomTextRectangle(board, element, 0.9);
5507
+ textRectangle.x = elementRectangle.x + getStrokeWidthByElement(element) + ShapeDefaultSpace.rectangleAndText;
5508
+ return textRectangle;
5610
5509
  }
5611
5510
  };
5612
5511
 
@@ -5681,16 +5580,10 @@ const NoteCurlyRightEngine = {
5681
5580
  },
5682
5581
  getTextRectangle: (board, element) => {
5683
5582
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5684
- const strokeWidth = getStrokeWidthByElement(element);
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);
5688
- return {
5689
- height: textSize.height,
5690
- width: width > 0 ? width : 0,
5691
- x: elementRectangle.x + elementRectangle.width * 0.09 + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5692
- y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5693
- };
5583
+ const textRectangle = getCustomTextRectangle(board, element, 0.9);
5584
+ textRectangle.x =
5585
+ elementRectangle.x + getStrokeWidthByElement(element) + ShapeDefaultSpace.rectangleAndText + elementRectangle.width * 0.1;
5586
+ return textRectangle;
5694
5587
  }
5695
5588
  };
5696
5589
 
@@ -5722,17 +5615,7 @@ const NoteSquareEngine = {
5722
5615
  return RectangleClient.getEdgeCenterPoints(rectangle);
5723
5616
  },
5724
5617
  getTextRectangle: (board, element) => {
5725
- const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5726
- const strokeWidth = getStrokeWidthByElement(element);
5727
- const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
5728
- const text = element.text;
5729
- const textSize = getTextSize(board, text, width);
5730
- return {
5731
- height: textSize.height,
5732
- width: width > 0 ? width : 0,
5733
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5734
- y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5735
- };
5618
+ return getCustomTextRectangle(board, element, 0.88);
5736
5619
  }
5737
5620
  };
5738
5621
 
@@ -5795,17 +5678,7 @@ const DisplayEngine = {
5795
5678
  return RectangleClient.getEdgeCenterPoints(rectangle);
5796
5679
  },
5797
5680
  getTextRectangle: (board, element) => {
5798
- const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5799
- const strokeWidth = getStrokeWidthByElement(element);
5800
- const width = elementRectangle.width - strokeWidth * 2 - elementRectangle.width * 0.25;
5801
- const text = element.text;
5802
- const textSize = getTextSize(board, text, width);
5803
- return {
5804
- width: width > 0 ? width : 0,
5805
- height: textSize.height,
5806
- x: elementRectangle.x + strokeWidth + elementRectangle.width * 0.15,
5807
- y: elementRectangle.y + (elementRectangle.height - textSize.height) / 2
5808
- };
5681
+ return getCustomTextRectangle(board, element, 0.75);
5809
5682
  }
5810
5683
  };
5811
5684
 
@@ -9387,5 +9260,5 @@ const withDraw = (board) => {
9387
9260
  * Generated bundle index. Do not edit.
9388
9261
  */
9389
9262
 
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 };
9263
+ 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, getCustomTextRectangle, 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 };
9391
9264
  //# sourceMappingURL=plait-draw.mjs.map