@visactor/vrender 0.14.0-alpha.2 → 0.14.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/cjs/canvas/contributions/browser/context.d.ts +1 -0
  2. package/cjs/common/render-curve.js +3 -3
  3. package/cjs/common/render-curve.js.map +1 -1
  4. package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +4 -4
  5. package/cjs/core/contributions/textMeasure/AtextMeasure.js +37 -13
  6. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  7. package/cjs/core/contributions/textMeasure/layout.d.ts +2 -2
  8. package/cjs/core/contributions/textMeasure/layout.js +4 -4
  9. package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
  10. package/cjs/graphic/config.js +2 -1
  11. package/cjs/graphic/config.js.map +1 -1
  12. package/cjs/graphic/graphic.d.ts +1 -0
  13. package/cjs/graphic/graphic.js +3 -0
  14. package/cjs/graphic/graphic.js.map +1 -1
  15. package/cjs/graphic/text.js +11 -11
  16. package/cjs/graphic/text.js.map +1 -1
  17. package/cjs/index.d.ts +1 -1
  18. package/cjs/index.js +1 -1
  19. package/cjs/index.js.map +1 -1
  20. package/cjs/interface/graphic/text.d.ts +1 -0
  21. package/cjs/interface/graphic/text.js.map +1 -1
  22. package/cjs/interface/text.d.ts +4 -4
  23. package/cjs/interface/text.js.map +1 -1
  24. package/dist/index.js +230 -194
  25. package/dist/index.min.js +1 -1
  26. package/es/canvas/contributions/browser/context.d.ts +1 -0
  27. package/es/common/render-curve.js +3 -3
  28. package/es/common/render-curve.js.map +1 -1
  29. package/es/core/contributions/textMeasure/AtextMeasure.d.ts +4 -4
  30. package/es/core/contributions/textMeasure/AtextMeasure.js +38 -12
  31. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  32. package/es/core/contributions/textMeasure/layout.d.ts +2 -2
  33. package/es/core/contributions/textMeasure/layout.js +4 -4
  34. package/es/core/contributions/textMeasure/layout.js.map +1 -1
  35. package/es/graphic/config.js +2 -1
  36. package/es/graphic/config.js.map +1 -1
  37. package/es/graphic/graphic.d.ts +1 -0
  38. package/es/graphic/graphic.js +3 -0
  39. package/es/graphic/graphic.js.map +1 -1
  40. package/es/graphic/text.js +11 -11
  41. package/es/graphic/text.js.map +1 -1
  42. package/es/index.d.ts +1 -1
  43. package/es/index.js +1 -1
  44. package/es/index.js.map +1 -1
  45. package/es/interface/graphic/text.d.ts +1 -0
  46. package/es/interface/graphic/text.js.map +1 -1
  47. package/es/interface/text.d.ts +4 -4
  48. package/es/interface/text.js.map +1 -1
  49. package/es/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -9291,7 +9291,8 @@
9291
9291
  underline: 0,
9292
9292
  lineThrough: 0,
9293
9293
  scaleIn3d: false,
9294
- direction: 'horizontal'
9294
+ direction: 'horizontal',
9295
+ wordBreak: 'break-all'
9295
9296
  };
9296
9297
  const DefaultStyle = {
9297
9298
  opacity: 1,
@@ -9476,6 +9477,170 @@
9476
9477
  opacity: 1
9477
9478
  };
9478
9479
 
9480
+ class Application {
9481
+ global;
9482
+ graphicUtil;
9483
+ graphicService;
9484
+ transformUtil;
9485
+ layerService;
9486
+ }
9487
+ const application = new Application();
9488
+
9489
+ const DIRECTION_KEY = {
9490
+ horizontal: {
9491
+ width: 'width',
9492
+ height: 'height',
9493
+ left: 'left',
9494
+ top: 'top',
9495
+ x: 'x',
9496
+ y: 'y',
9497
+ bottom: 'bottom'
9498
+ },
9499
+ vertical: {
9500
+ width: 'height',
9501
+ height: 'width',
9502
+ left: 'top',
9503
+ top: 'left',
9504
+ x: 'y',
9505
+ y: 'x',
9506
+ bottom: 'right'
9507
+ }
9508
+ };
9509
+ const defaultFormatting = {
9510
+ fontSize: 16,
9511
+ fontFamily: 'sans-serif',
9512
+ fill: true,
9513
+ stroke: false,
9514
+ fontWeight: 'normal',
9515
+ lineHeight: 'normal',
9516
+ fontStyle: 'normal',
9517
+ textDecoration: 'none',
9518
+ textAlign: 'left',
9519
+ script: 'normal'
9520
+ };
9521
+ const regLetter = /\w|\(|\)/;
9522
+ const regPunctuation = /[.?!,;:/,。?!、;:]/;
9523
+ const regFirstSpace = /\S/;
9524
+ function applyFillStyle(ctx, character) {
9525
+ const fillStyle = (character && character.fill) || defaultFormatting.fill;
9526
+ if (!fillStyle) {
9527
+ ctx.globalAlpha = 0;
9528
+ return;
9529
+ }
9530
+ ctx.globalAlpha = 1;
9531
+ ctx.fillStyle = fillStyle;
9532
+ let fontSize = character.fontSize || 16;
9533
+ switch (character.script) {
9534
+ case 'super':
9535
+ case 'sub':
9536
+ fontSize *= 0.8;
9537
+ break;
9538
+ }
9539
+ ctx.setTextStyle({
9540
+ textAlign: 'left',
9541
+ textBaseline: character.textBaseline || 'alphabetic',
9542
+ fontStyle: character.fontStyle || '',
9543
+ fontWeight: character.fontWeight || '',
9544
+ fontSize,
9545
+ fontFamily: character.fontFamily || 'sans-serif'
9546
+ });
9547
+ }
9548
+ function applyStrokeStyle(ctx, character) {
9549
+ const strokeStyle = (character && character.stroke) || defaultFormatting.stroke;
9550
+ if (!strokeStyle) {
9551
+ ctx.globalAlpha = 0;
9552
+ return;
9553
+ }
9554
+ ctx.globalAlpha = 1;
9555
+ ctx.lineWidth = 1;
9556
+ ctx.strokeStyle = strokeStyle;
9557
+ let fontSize = character.fontSize || 16;
9558
+ switch (character.script) {
9559
+ case 'super':
9560
+ case 'sub':
9561
+ fontSize *= 0.8;
9562
+ break;
9563
+ }
9564
+ ctx.setTextStyle({
9565
+ textAlign: 'left',
9566
+ textBaseline: character.textBaseline || 'alphabetic',
9567
+ fontStyle: character.fontStyle || '',
9568
+ fontWeight: character.fontWeight || '',
9569
+ fontSize,
9570
+ fontFamily: character.fontFamily || 'sans-serif'
9571
+ });
9572
+ }
9573
+ function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
9574
+ if (!width || width <= 0) {
9575
+ return 0;
9576
+ }
9577
+ const textMeasure = application.graphicUtil.textMeasure;
9578
+ let index = guessIndex;
9579
+ let temp = desc.slice(0, index);
9580
+ let tempWidth = Math.floor(textMeasure.measureText(temp, character).width);
9581
+ let tempNext = desc.slice(0, index + 1);
9582
+ let tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
9583
+ while (tempWidth > width || tempWidthNext <= width) {
9584
+ if (tempWidth > width) {
9585
+ index--;
9586
+ }
9587
+ else {
9588
+ index++;
9589
+ }
9590
+ if (index > desc.length) {
9591
+ index = desc.length;
9592
+ break;
9593
+ }
9594
+ else if (index < 0) {
9595
+ index = 0;
9596
+ break;
9597
+ }
9598
+ temp = desc.slice(0, index);
9599
+ tempWidth = Math.floor(textMeasure.measureText(temp, character).width);
9600
+ tempNext = desc.slice(0, index + 1);
9601
+ tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
9602
+ }
9603
+ if (needTestLetter) {
9604
+ index = testLetter(desc, index);
9605
+ }
9606
+ return index;
9607
+ }
9608
+ function testLetter(string, index) {
9609
+ let i = index;
9610
+ while ((regLetter.test(string[i - 1]) && regLetter.test(string[i])) ||
9611
+ regPunctuation.test(string[i])) {
9612
+ i--;
9613
+ if (i <= 0) {
9614
+ return index;
9615
+ }
9616
+ }
9617
+ return i;
9618
+ }
9619
+ function measureTextCanvas(text, character) {
9620
+ const textMeasure = application.graphicUtil.textMeasure;
9621
+ const measurement = textMeasure.measureText(text, character);
9622
+ const result = {
9623
+ ascent: 0,
9624
+ height: 0,
9625
+ descent: 0,
9626
+ width: 0
9627
+ };
9628
+ if (typeof measurement.actualBoundingBoxAscent !== 'number' ||
9629
+ typeof measurement.actualBoundingBoxDescent !== 'number') {
9630
+ result.width = Math.floor(measurement.width);
9631
+ result.height = character.fontSize || 0;
9632
+ result.ascent = result.height;
9633
+ result.descent = 0;
9634
+ }
9635
+ else {
9636
+ result.width = Math.floor(measurement.width);
9637
+ result.height = Math.floor(measurement.actualBoundingBoxAscent + measurement.actualBoundingBoxDescent);
9638
+ result.ascent = Math.floor(measurement.actualBoundingBoxAscent);
9639
+ result.descent = result.height - result.ascent;
9640
+ }
9641
+ return result;
9642
+ }
9643
+
9479
9644
  let ATextMeasure = class ATextMeasure {
9480
9645
  release;
9481
9646
  canvas;
@@ -9527,7 +9692,7 @@
9527
9692
  this.context.setTextStyleWithoutAlignBaseline(options);
9528
9693
  return this.context.measureText(text);
9529
9694
  }
9530
- clipTextVertical(verticalList, options, width) {
9695
+ clipTextVertical(verticalList, options, width, wordBreak) {
9531
9696
  if (verticalList.length === 0) {
9532
9697
  return { verticalList, width: 0 };
9533
9698
  }
@@ -9549,7 +9714,24 @@
9549
9714
  }
9550
9715
  if (verticalList[i] && verticalList[i].text.length > 1) {
9551
9716
  const clipedData = this._clipText(verticalList[i].text, options, width - length, 0, verticalList[i].text.length - 1);
9552
- out.push({ ...verticalList[i], text: clipedData.str });
9717
+ if (wordBreak && clipedData.str !== verticalList[i].text) {
9718
+ let text = '';
9719
+ let length = 0;
9720
+ for (let j = 0; j < i; j++) {
9721
+ const item = verticalList[j];
9722
+ text += item.text;
9723
+ length += item.text.length;
9724
+ }
9725
+ text += verticalList[i].text;
9726
+ const totalLength = length + clipedData.str.length;
9727
+ let index = testLetter(text, totalLength);
9728
+ index = index - length;
9729
+ if (index !== clipedData.str.length - 1) {
9730
+ clipedData.str = clipedData.str.substring(0, index);
9731
+ clipedData.width = this.measureTextWidth(clipedData.str, options);
9732
+ }
9733
+ }
9734
+ out.push({ ...verticalList[i], text: clipedData.str, width: clipedData.width });
9553
9735
  length += clipedData.width;
9554
9736
  }
9555
9737
  return {
@@ -9557,7 +9739,7 @@
9557
9739
  width: length
9558
9740
  };
9559
9741
  }
9560
- clipText(text, options, width) {
9742
+ clipText(text, options, width, wordBreak) {
9561
9743
  if (text.length === 0) {
9562
9744
  return { str: '', width: 0 };
9563
9745
  }
@@ -9569,7 +9751,15 @@
9569
9751
  if (length > width) {
9570
9752
  return { str: '', width: 0 };
9571
9753
  }
9572
- return this._clipText(text, options, width, 0, text.length - 1);
9754
+ const data = this._clipText(text, options, width, 0, text.length - 1);
9755
+ if (wordBreak && data.str !== text) {
9756
+ const index = testLetter(text, data.str.length);
9757
+ if (index !== data.str.length) {
9758
+ data.str = text.substring(0, index);
9759
+ data.width = this.measureTextWidth(data.str, options);
9760
+ }
9761
+ }
9762
+ return data;
9573
9763
  }
9574
9764
  _clipText(text, options, width, leftIdx, rightIdx) {
9575
9765
  const middleIdx = Math.floor((leftIdx + rightIdx) / 2);
@@ -9600,14 +9790,14 @@
9600
9790
  }
9601
9791
  return { str: subText, width: strWidth };
9602
9792
  }
9603
- clipTextWithSuffixVertical(verticalList, options, width, suffix) {
9793
+ clipTextWithSuffixVertical(verticalList, options, width, suffix, wordBreak) {
9604
9794
  if (suffix === '') {
9605
- return this.clipTextVertical(verticalList, options, width);
9795
+ return this.clipTextVertical(verticalList, options, width, wordBreak);
9606
9796
  }
9607
9797
  if (verticalList.length === 0) {
9608
9798
  return { verticalList, width: 0 };
9609
9799
  }
9610
- const output = this.clipTextVertical(verticalList, options, width);
9800
+ const output = this.clipTextVertical(verticalList, options, width, wordBreak);
9611
9801
  if (output.verticalList.length === verticalList.length &&
9612
9802
  output.verticalList[output.verticalList.length - 1].width === verticalList[verticalList.length - 1].width) {
9613
9803
  return output;
@@ -9617,7 +9807,7 @@
9617
9807
  return output;
9618
9808
  }
9619
9809
  width -= suffixWidth;
9620
- const out = this.clipTextVertical(verticalList, options, width);
9810
+ const out = this.clipTextVertical(verticalList, options, width, wordBreak);
9621
9811
  out.width += suffixWidth;
9622
9812
  out.verticalList.push({
9623
9813
  text: suffix,
@@ -9626,9 +9816,9 @@
9626
9816
  });
9627
9817
  return out;
9628
9818
  }
9629
- clipTextWithSuffix(text, options, width, suffix) {
9819
+ clipTextWithSuffix(text, options, width, suffix, wordBreak) {
9630
9820
  if (suffix === '') {
9631
- return this.clipText(text, options, width);
9821
+ return this.clipText(text, options, width, wordBreak);
9632
9822
  }
9633
9823
  if (text.length === 0) {
9634
9824
  return { str: '', width: 0 };
@@ -9643,6 +9833,13 @@
9643
9833
  }
9644
9834
  width -= suffixWidth;
9645
9835
  const data = this._clipText(text, options, width, 0, text.length - 1);
9836
+ if (wordBreak && data.str !== text) {
9837
+ const index = testLetter(text, data.str.length);
9838
+ if (index !== data.str.length) {
9839
+ data.str = text.substring(0, index);
9840
+ data.width = this.measureTextWidth(data.str, options);
9841
+ }
9842
+ }
9646
9843
  data.str += suffix;
9647
9844
  data.width += suffixWidth;
9648
9845
  return data;
@@ -9661,15 +9858,6 @@
9661
9858
 
9662
9859
  const container = new Container();
9663
9860
 
9664
- class Application {
9665
- global;
9666
- graphicUtil;
9667
- graphicService;
9668
- transformUtil;
9669
- layerService;
9670
- }
9671
- const application = new Application();
9672
-
9673
9861
  const CanvasFactory = Symbol.for('CanvasFactory');
9674
9862
  const Context2dFactory = Symbol.for('Context2dFactory');
9675
9863
 
@@ -17088,6 +17276,9 @@
17088
17276
  }
17089
17277
  return point;
17090
17278
  }
17279
+ onAnimateBind(animate) {
17280
+ this._emitCustomEvent('animate-bind', animate);
17281
+ }
17091
17282
  tryUpdateAABBBounds(full) {
17092
17283
  if (!this.shouldUpdateAABBBounds()) {
17093
17284
  return this._AABBBounds;
@@ -19663,12 +19854,12 @@
19663
19854
  }
19664
19855
  return bbox;
19665
19856
  }
19666
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, miniApp) {
19857
+ GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, miniApp) {
19667
19858
  const linesLayout = [];
19668
19859
  const bboxWH = [width, height];
19669
19860
  const bboxOffset = [0, 0];
19670
19861
  while (str.length > 0) {
19671
- const { str: clipText } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix);
19862
+ const { str: clipText } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak);
19672
19863
  linesLayout.push({
19673
19864
  str: clipText,
19674
19865
  width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
@@ -19697,7 +19888,7 @@
19697
19888
  };
19698
19889
  return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
19699
19890
  }
19700
- GetLayoutByLines(lines, textAlign, textBaseline, lineHeight, suffix = '', lineWidth) {
19891
+ GetLayoutByLines(lines, textAlign, textBaseline, lineHeight, suffix = '', wordBreak, lineWidth) {
19701
19892
  lines = lines.map(l => l.toString());
19702
19893
  const linesLayout = [];
19703
19894
  const bboxWH = [0, 0];
@@ -19706,7 +19897,7 @@
19706
19897
  for (let i = 0, len = lines.length; i < len; i++) {
19707
19898
  width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth);
19708
19899
  linesLayout.push({
19709
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix).str,
19900
+ str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak).str,
19710
19901
  width
19711
19902
  });
19712
19903
  }
@@ -19881,7 +20072,7 @@
19881
20072
  let str;
19882
20073
  const buf = 2;
19883
20074
  const attribute = this.attribute;
19884
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth } = attribute;
20075
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak } = attribute;
19885
20076
  if (!this.shouldUpdateShape() && this.cache) {
19886
20077
  width = this.cache.clipedWidth;
19887
20078
  const dx = textDrawOffsetX(textAlign, width);
@@ -19895,12 +20086,12 @@
19895
20086
  if (Number.isFinite(maxLineWidth)) {
19896
20087
  if (ellipsis) {
19897
20088
  const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
19898
- const data = textMeasure.clipTextWithSuffix(text.toString(), { fontSize, fontWeight }, maxLineWidth, strEllipsis);
20089
+ const data = textMeasure.clipTextWithSuffix(text.toString(), { fontSize, fontWeight }, maxLineWidth, strEllipsis, wordBreak === 'break-word');
19899
20090
  str = data.str;
19900
20091
  width = data.width;
19901
20092
  }
19902
20093
  else {
19903
- const data = textMeasure.clipText(text.toString(), { fontSize, fontWeight }, maxLineWidth);
20094
+ const data = textMeasure.clipText(text.toString(), { fontSize, fontWeight }, maxLineWidth, wordBreak === 'break-word');
19904
20095
  str = data.str;
19905
20096
  width = data.width;
19906
20097
  }
@@ -19927,7 +20118,7 @@
19927
20118
  let width;
19928
20119
  const buf = 2;
19929
20120
  const attribute = this.attribute;
19930
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth } = attribute;
20121
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak } = attribute;
19931
20122
  if (!this.shouldUpdateShape() && this.cache) {
19932
20123
  width = this.cache.clipedWidth;
19933
20124
  const dx = textDrawOffsetX(textAlign, width);
@@ -19944,12 +20135,12 @@
19944
20135
  if (Number.isFinite(maxLineWidth)) {
19945
20136
  if (ellipsis) {
19946
20137
  const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
19947
- const data = textMeasure.clipTextWithSuffixVertical(verticalList[0], { fontSize, fontWeight }, maxLineWidth, strEllipsis);
20138
+ const data = textMeasure.clipTextWithSuffixVertical(verticalList[0], { fontSize, fontWeight }, maxLineWidth, strEllipsis, wordBreak === 'break-word');
19948
20139
  verticalList = [data.verticalList];
19949
20140
  width = data.width;
19950
20141
  }
19951
20142
  else {
19952
- const data = textMeasure.clipTextVertical(verticalList[0], { fontSize, fontWeight }, maxLineWidth);
20143
+ const data = textMeasure.clipTextVertical(verticalList[0], { fontSize, fontWeight }, maxLineWidth, wordBreak === 'break-word');
19953
20144
  verticalList = [data.verticalList];
19954
20145
  width = data.width;
19955
20146
  }
@@ -19980,7 +20171,7 @@
19980
20171
  updateHorizontalMultilineAABBBounds(text) {
19981
20172
  const textTheme = getTheme(this).text;
19982
20173
  const attribute = this.attribute;
19983
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, lineHeight = attribute.lineHeight || attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth } = attribute;
20174
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, lineHeight = attribute.lineHeight || attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak } = attribute;
19984
20175
  if (!this.shouldUpdateShape() && this.cache?.layoutData) {
19985
20176
  const bbox = this.cache.layoutData.bbox;
19986
20177
  this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
@@ -19991,7 +20182,7 @@
19991
20182
  }
19992
20183
  const textMeasure = application.graphicUtil.textMeasure;
19993
20184
  const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight }, textMeasure);
19994
- const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, maxLineWidth);
20185
+ const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, wordBreak === 'break-word', maxLineWidth);
19995
20186
  const { bbox } = layoutData;
19996
20187
  this.cache.layoutData = layoutData;
19997
20188
  this.clearUpdateShapeTag();
@@ -20007,7 +20198,7 @@
20007
20198
  let width;
20008
20199
  const buf = 2;
20009
20200
  const attribute = this.attribute;
20010
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth } = attribute;
20201
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak } = attribute;
20011
20202
  width = 0;
20012
20203
  if (!this.shouldUpdateShape() && this.cache) {
20013
20204
  this.cache.verticalList.forEach(item => {
@@ -20030,12 +20221,12 @@
20030
20221
  if (Number.isFinite(maxLineWidth)) {
20031
20222
  if (ellipsis) {
20032
20223
  const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
20033
- const data = textMeasure.clipTextWithSuffixVertical(verticalData, { fontSize, fontWeight }, maxLineWidth, strEllipsis);
20224
+ const data = textMeasure.clipTextWithSuffixVertical(verticalData, { fontSize, fontWeight }, maxLineWidth, strEllipsis, wordBreak === 'break-word');
20034
20225
  verticalLists[i] = data.verticalList;
20035
20226
  width = data.width;
20036
20227
  }
20037
20228
  else {
20038
- const data = textMeasure.clipTextVertical(verticalData, { fontSize, fontWeight }, maxLineWidth);
20229
+ const data = textMeasure.clipTextVertical(verticalData, { fontSize, fontWeight }, maxLineWidth, wordBreak === 'break-word');
20039
20230
  verticalLists[i] = data.verticalList;
20040
20231
  width = data.width;
20041
20232
  }
@@ -21210,161 +21401,6 @@
21210
21401
  }
21211
21402
  }
21212
21403
 
21213
- const DIRECTION_KEY = {
21214
- horizontal: {
21215
- width: 'width',
21216
- height: 'height',
21217
- left: 'left',
21218
- top: 'top',
21219
- x: 'x',
21220
- y: 'y',
21221
- bottom: 'bottom'
21222
- },
21223
- vertical: {
21224
- width: 'height',
21225
- height: 'width',
21226
- left: 'top',
21227
- top: 'left',
21228
- x: 'y',
21229
- y: 'x',
21230
- bottom: 'right'
21231
- }
21232
- };
21233
- const defaultFormatting = {
21234
- fontSize: 16,
21235
- fontFamily: 'sans-serif',
21236
- fill: true,
21237
- stroke: false,
21238
- fontWeight: 'normal',
21239
- lineHeight: 'normal',
21240
- fontStyle: 'normal',
21241
- textDecoration: 'none',
21242
- textAlign: 'left',
21243
- script: 'normal'
21244
- };
21245
- const regLetter = /\w|\(|\)/;
21246
- const regPunctuation = /[.?!,;:/,。?!、;:]/;
21247
- const regFirstSpace = /\S/;
21248
- function applyFillStyle(ctx, character) {
21249
- const fillStyle = (character && character.fill) || defaultFormatting.fill;
21250
- if (!fillStyle) {
21251
- ctx.globalAlpha = 0;
21252
- return;
21253
- }
21254
- ctx.globalAlpha = 1;
21255
- ctx.fillStyle = fillStyle;
21256
- let fontSize = character.fontSize || 16;
21257
- switch (character.script) {
21258
- case 'super':
21259
- case 'sub':
21260
- fontSize *= 0.8;
21261
- break;
21262
- }
21263
- ctx.setTextStyle({
21264
- textAlign: 'left',
21265
- textBaseline: character.textBaseline || 'alphabetic',
21266
- fontStyle: character.fontStyle || '',
21267
- fontWeight: character.fontWeight || '',
21268
- fontSize,
21269
- fontFamily: character.fontFamily || 'sans-serif'
21270
- });
21271
- }
21272
- function applyStrokeStyle(ctx, character) {
21273
- const strokeStyle = (character && character.stroke) || defaultFormatting.stroke;
21274
- if (!strokeStyle) {
21275
- ctx.globalAlpha = 0;
21276
- return;
21277
- }
21278
- ctx.globalAlpha = 1;
21279
- ctx.lineWidth = 1;
21280
- ctx.strokeStyle = strokeStyle;
21281
- let fontSize = character.fontSize || 16;
21282
- switch (character.script) {
21283
- case 'super':
21284
- case 'sub':
21285
- fontSize *= 0.8;
21286
- break;
21287
- }
21288
- ctx.setTextStyle({
21289
- textAlign: 'left',
21290
- textBaseline: character.textBaseline || 'alphabetic',
21291
- fontStyle: character.fontStyle || '',
21292
- fontWeight: character.fontWeight || '',
21293
- fontSize,
21294
- fontFamily: character.fontFamily || 'sans-serif'
21295
- });
21296
- }
21297
- function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
21298
- if (!width || width <= 0) {
21299
- return 0;
21300
- }
21301
- const textMeasure = application.graphicUtil.textMeasure;
21302
- let index = guessIndex;
21303
- let temp = desc.slice(0, index);
21304
- let tempWidth = Math.floor(textMeasure.measureText(temp, character).width);
21305
- let tempNext = desc.slice(0, index + 1);
21306
- let tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
21307
- while (tempWidth > width || tempWidthNext <= width) {
21308
- if (tempWidth > width) {
21309
- index--;
21310
- }
21311
- else {
21312
- index++;
21313
- }
21314
- if (index > desc.length) {
21315
- index = desc.length;
21316
- break;
21317
- }
21318
- else if (index < 0) {
21319
- index = 0;
21320
- break;
21321
- }
21322
- temp = desc.slice(0, index);
21323
- tempWidth = Math.floor(textMeasure.measureText(temp, character).width);
21324
- tempNext = desc.slice(0, index + 1);
21325
- tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
21326
- }
21327
- if (needTestLetter) {
21328
- index = testLetter(desc, index);
21329
- }
21330
- return index;
21331
- }
21332
- function testLetter(string, index) {
21333
- let i = index;
21334
- while ((regLetter.test(string[i - 1]) && regLetter.test(string[i])) ||
21335
- regPunctuation.test(string[i])) {
21336
- i--;
21337
- if (i <= 0) {
21338
- return index;
21339
- }
21340
- }
21341
- return i;
21342
- }
21343
- function measureTextCanvas(text, character) {
21344
- const textMeasure = application.graphicUtil.textMeasure;
21345
- const measurement = textMeasure.measureText(text, character);
21346
- const result = {
21347
- ascent: 0,
21348
- height: 0,
21349
- descent: 0,
21350
- width: 0
21351
- };
21352
- if (typeof measurement.actualBoundingBoxAscent !== 'number' ||
21353
- typeof measurement.actualBoundingBoxDescent !== 'number') {
21354
- result.width = Math.floor(measurement.width);
21355
- result.height = character.fontSize || 0;
21356
- result.ascent = result.height;
21357
- result.descent = 0;
21358
- }
21359
- else {
21360
- result.width = Math.floor(measurement.width);
21361
- result.height = Math.floor(measurement.actualBoundingBoxAscent + measurement.actualBoundingBoxDescent);
21362
- result.ascent = Math.floor(measurement.actualBoundingBoxAscent);
21363
- result.descent = result.height - result.ascent;
21364
- }
21365
- return result;
21366
- }
21367
-
21368
21404
  class Frame {
21369
21405
  left;
21370
21406
  top;
@@ -24679,13 +24715,13 @@
24679
24715
  if (!segPath) {
24680
24716
  return;
24681
24717
  }
24682
- let needMoveTo = true;
24718
+ let needMoveTo = !drawConnect;
24683
24719
  const { curves } = segPath;
24684
24720
  if (percent >= 1) {
24685
24721
  if (drawConnect) {
24686
24722
  curves.forEach((curve, i) => {
24687
24723
  if (curve.defined) {
24688
- if (needMoveTo && i !== 0) {
24724
+ if (needMoveTo) {
24689
24725
  path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
24690
24726
  }
24691
24727
  needMoveTo = false;
@@ -24744,7 +24780,7 @@
24744
24780
  }
24745
24781
  if (drawConnect) {
24746
24782
  if (curve.defined) {
24747
- if (needMoveTo && i !== 0) {
24783
+ if (needMoveTo) {
24748
24784
  path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
24749
24785
  }
24750
24786
  needMoveTo = false;
@@ -37152,7 +37188,7 @@
37152
37188
  'rect'
37153
37189
  ];
37154
37190
 
37155
- const version = "0.14.0-alpha.2";
37191
+ const version = "0.14.0-alpha.4";
37156
37192
 
37157
37193
  exports.ACustomAnimate = ACustomAnimate;
37158
37194
  exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;