@visactor/vrender-core 0.22.0-vstory.10 → 0.22.0-vstory.12

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 (110) hide show
  1. package/cjs/animate/animate.js +1 -1
  2. package/cjs/animate/animate.js.map +1 -1
  3. package/cjs/animate/custom-animate.js +2 -1
  4. package/cjs/animate/custom-animate.js.map +1 -1
  5. package/cjs/canvas/util.js +2 -1
  6. package/cjs/color-string/store.js +1 -2
  7. package/cjs/common/render-area.d.ts +0 -4
  8. package/cjs/common/render-area.js +16 -76
  9. package/cjs/common/render-area.js.map +1 -1
  10. package/cjs/common/render-curve.d.ts +1 -1
  11. package/cjs/common/render-curve.js.map +1 -1
  12. package/cjs/common/segment/step.js +1 -1
  13. package/cjs/common/segment/step.js.map +1 -1
  14. package/cjs/core/global.d.ts +3 -0
  15. package/cjs/core/global.js +7 -1
  16. package/cjs/core/global.js.map +1 -1
  17. package/cjs/graphic/config.js +1 -0
  18. package/cjs/graphic/config.js.map +1 -1
  19. package/cjs/graphic/line.js +2 -2
  20. package/cjs/graphic/line.js.map +1 -1
  21. package/cjs/graphic/richtext/line.js +3 -13
  22. package/cjs/graphic/richtext/line.js.map +1 -1
  23. package/cjs/graphic/richtext/paragraph.d.ts +3 -9
  24. package/cjs/graphic/richtext/paragraph.js +33 -20
  25. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  26. package/cjs/graphic/richtext/utils.d.ts +1 -1
  27. package/cjs/graphic/richtext/utils.js +6 -7
  28. package/cjs/graphic/richtext/utils.js.map +1 -1
  29. package/cjs/graphic/richtext.d.ts +1 -2
  30. package/cjs/graphic/richtext.js +3 -9
  31. package/cjs/graphic/richtext.js.map +1 -1
  32. package/cjs/interface/color.js.map +1 -1
  33. package/cjs/interface/global.d.ts +1 -0
  34. package/cjs/interface/global.js.map +1 -1
  35. package/cjs/interface/graphic/richText.d.ts +1 -1
  36. package/cjs/interface/graphic/richText.js.map +1 -1
  37. package/cjs/interface/graphic.d.ts +2 -2
  38. package/cjs/interface/graphic.js.map +1 -1
  39. package/cjs/plugins/builtin-plugin/edit-module.js +8 -4
  40. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  41. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -3
  42. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +70 -79
  43. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  44. package/cjs/render/contributions/render/area-render.d.ts +1 -1
  45. package/cjs/render/contributions/render/area-render.js +16 -36
  46. package/cjs/render/contributions/render/area-render.js.map +1 -1
  47. package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
  48. package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -2
  49. package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  50. package/cjs/render/contributions/render/image-render.js.map +1 -1
  51. package/cjs/render/contributions/render/line-render.js +9 -31
  52. package/cjs/render/contributions/render/line-render.js.map +1 -1
  53. package/cjs/resource-loader/loader.js +1 -1
  54. package/cjs/resource-loader/loader.js.map +1 -1
  55. package/dist/index.es.js +180 -418
  56. package/es/animate/animate.js +4 -3
  57. package/es/animate/animate.js.map +1 -1
  58. package/es/animate/custom-animate.js +2 -1
  59. package/es/animate/custom-animate.js.map +1 -1
  60. package/es/canvas/util.js +2 -1
  61. package/es/color-string/store.js +1 -2
  62. package/es/common/render-area.d.ts +0 -4
  63. package/es/common/render-area.js +16 -76
  64. package/es/common/render-area.js.map +1 -1
  65. package/es/common/render-curve.d.ts +1 -1
  66. package/es/common/render-curve.js.map +1 -1
  67. package/es/common/segment/step.js +1 -1
  68. package/es/common/segment/step.js.map +1 -1
  69. package/es/core/global.d.ts +3 -0
  70. package/es/core/global.js +8 -1
  71. package/es/core/global.js.map +1 -1
  72. package/es/graphic/config.js +1 -0
  73. package/es/graphic/config.js.map +1 -1
  74. package/es/graphic/line.js +2 -2
  75. package/es/graphic/line.js.map +1 -1
  76. package/es/graphic/richtext/line.js +3 -13
  77. package/es/graphic/richtext/line.js.map +1 -1
  78. package/es/graphic/richtext/paragraph.d.ts +3 -9
  79. package/es/graphic/richtext/paragraph.js +33 -20
  80. package/es/graphic/richtext/paragraph.js.map +1 -1
  81. package/es/graphic/richtext/utils.d.ts +1 -1
  82. package/es/graphic/richtext/utils.js +6 -7
  83. package/es/graphic/richtext/utils.js.map +1 -1
  84. package/es/graphic/richtext.d.ts +1 -2
  85. package/es/graphic/richtext.js +3 -9
  86. package/es/graphic/richtext.js.map +1 -1
  87. package/es/interface/color.js.map +1 -1
  88. package/es/interface/global.d.ts +1 -0
  89. package/es/interface/global.js.map +1 -1
  90. package/es/interface/graphic/richText.d.ts +1 -1
  91. package/es/interface/graphic/richText.js.map +1 -1
  92. package/es/interface/graphic.d.ts +2 -2
  93. package/es/interface/graphic.js.map +1 -1
  94. package/es/plugins/builtin-plugin/edit-module.js +8 -4
  95. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  96. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -3
  97. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +70 -79
  98. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  99. package/es/render/contributions/render/area-render.d.ts +1 -1
  100. package/es/render/contributions/render/area-render.js +16 -36
  101. package/es/render/contributions/render/area-render.js.map +1 -1
  102. package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
  103. package/es/render/contributions/render/contributions/image-contribution-render.js +2 -2
  104. package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  105. package/es/render/contributions/render/image-render.js.map +1 -1
  106. package/es/render/contributions/render/line-render.js +9 -31
  107. package/es/render/contributions/render/line-render.js.map +1 -1
  108. package/es/resource-loader/loader.js +1 -1
  109. package/es/resource-loader/loader.js.map +1 -1
  110. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -855,6 +855,12 @@ let DefaultGlobal = class DefaultGlobal {
855
855
  get env() {
856
856
  return this._env;
857
857
  }
858
+ get isImageAnonymous() {
859
+ return this._isImageAnonymous;
860
+ }
861
+ set isImageAnonymous(isImageAnonymous) {
862
+ this._isImageAnonymous = isImageAnonymous;
863
+ }
858
864
  get devicePixelRatio() {
859
865
  if (!this._env) {
860
866
  this.setEnv(defaultEnv);
@@ -923,6 +929,7 @@ let DefaultGlobal = class DefaultGlobal {
923
929
  }
924
930
  constructor(contributions) {
925
931
  this.contributions = contributions;
932
+ this._isImageAnonymous = true;
926
933
  this.id = Generator.GenAutoIncrementId();
927
934
  this.hooks = {
928
935
  onSetEnv: new SyncHook(['lastEnv', 'env', 'global'])
@@ -2355,7 +2362,12 @@ let Step$1 = class Step {
2355
2362
  }
2356
2363
  else {
2357
2364
  const x1 = this._x * (1 - this._t) + x * this._t;
2358
- this.context.lineTo(x1, this._y, this._lastDefined !== false && p.defined !== false, this.lastPoint);
2365
+ if (this._t === 0.5) {
2366
+ this.context.lineTo(x1, this._y, this._lastDefined !== false, this.lastPoint);
2367
+ }
2368
+ else {
2369
+ this.context.lineTo(x1, this._y, this._lastDefined !== false && p.defined !== false, this.lastPoint);
2370
+ }
2359
2371
  this.context.lineTo(x1, y, this._lastDefined !== false && p.defined !== false, p);
2360
2372
  }
2361
2373
  break;
@@ -3307,7 +3319,7 @@ const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute),
3307
3319
  const DefaultRect3dAttribute = Object.assign(Object.assign({}, DefaultAttribute), { width: 0, height: 0, x1: 0, y1: 0, cornerRadius: 0, length: 0, cornerType: 'round' });
3308
3320
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), { symbolType: 'circle', size: 10, keepDirIn3d: true, clipRange: 1 });
3309
3321
  const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { strokeBoundsBuffer: 0, keepDirIn3d: true });
3310
- const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { editable: false, editOptions: null, width: 300, height: 300, ellipsis: true, wordBreak: 'break-word', verticalDirection: 'top', textAlign: 'left', textBaseline: 'top', layoutDirection: 'horizontal', textConfig: [], disableAutoWrapLine: false, maxHeight: undefined, maxWidth: undefined, singleLine: false });
3322
+ const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { editable: false, editOptions: null, ascentDescentMode: 'actual', width: 300, height: 300, ellipsis: true, wordBreak: 'break-word', verticalDirection: 'top', textAlign: 'left', textBaseline: 'top', layoutDirection: 'horizontal', textConfig: [], disableAutoWrapLine: false, maxHeight: undefined, maxWidth: undefined, singleLine: false });
3311
3323
  const DefaultImageAttribute = Object.assign(Object.assign({ repeatX: 'no-repeat', repeatY: 'no-repeat', image: '', width: 0, height: 0 }, DefaultAttribute), { fill: true, cornerRadius: 0, cornerType: 'round' });
3312
3324
  const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImageAttribute), { backgroundShowMode: 'never', backgroundWidth: 0, backgroundHeight: 0, textAlign: 'left', textBaseline: 'middle', direction: 'horizontal', margin: 0, id: '', width: 20, height: 20, backgroundFill: 'rgba(101, 117, 168, 0.1)', backgroundFillOpacity: 1, backgroundStroke: false, backgroundStrokeOpacity: 1, backgroundRadius: 4, opacity: 1 });
3313
3325
 
@@ -3922,7 +3934,7 @@ function testLetter2(string, index) {
3922
3934
  }
3923
3935
  return i + 1;
3924
3936
  }
3925
- function measureTextCanvas(text, character) {
3937
+ function measureTextCanvas(text, character, mode = 'actual') {
3926
3938
  const textMeasure = application.graphicUtil.textMeasure;
3927
3939
  const measurement = textMeasure.measureText(text, character);
3928
3940
  const result = {
@@ -3931,16 +3943,18 @@ function measureTextCanvas(text, character) {
3931
3943
  descent: 0,
3932
3944
  width: 0
3933
3945
  };
3934
- if (typeof measurement.fontBoundingBoxAscent !== 'number' || typeof measurement.fontBoundingBoxDescent !== 'number') {
3935
- result.width = measurement.width;
3946
+ const ascent = mode === 'actual' ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent;
3947
+ const descent = mode === 'actual' ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;
3948
+ if (typeof ascent !== 'number' || typeof descent !== 'number') {
3949
+ result.width = Math.floor(measurement.width);
3936
3950
  result.height = character.fontSize || 0;
3937
3951
  result.ascent = result.height;
3938
3952
  result.descent = 0;
3939
3953
  }
3940
3954
  else {
3941
- result.width = measurement.width;
3942
- result.height = Math.floor(measurement.fontBoundingBoxAscent + measurement.fontBoundingBoxDescent);
3943
- result.ascent = Math.floor(measurement.fontBoundingBoxAscent);
3955
+ result.width = Math.floor(measurement.width);
3956
+ result.height = Math.floor(ascent + descent);
3957
+ result.ascent = Math.floor(ascent);
3944
3958
  result.descent = result.height - result.ascent;
3945
3959
  }
3946
3960
  return result;
@@ -8287,7 +8301,7 @@ class CbAnimate extends ACustomAnimate {
8287
8301
  class Animate {
8288
8302
  constructor(id = Generator.GenAutoIncrementId(), timeline = defaultTimeline, slience) {
8289
8303
  this.id = id;
8290
- this.timeline = timeline;
8304
+ this.timeline = timeline || defaultTimeline;
8291
8305
  this.status = AnimateStatus.INITIAL;
8292
8306
  this.tailAnimate = new SubAnimate(this);
8293
8307
  this.subAnimates = [this.tailAnimate];
@@ -9173,11 +9187,12 @@ class IncreaseCount extends ACustomAnimate {
9173
9187
  return;
9174
9188
  }
9175
9189
  onUpdate(end, ratio, out) {
9190
+ var _a;
9176
9191
  if (this.valid === false) {
9177
9192
  return;
9178
9193
  }
9179
9194
  if (end) {
9180
- out.text = this.toNumber;
9195
+ out.text = (_a = this.to) === null || _a === void 0 ? void 0 : _a.text;
9181
9196
  }
9182
9197
  else {
9183
9198
  out.text = (this.fromNumber + (this.toNumber - this.fromNumber) * ratio).toFixed(this.decimalLength);
@@ -11729,10 +11744,10 @@ class ResourceLoader {
11729
11744
  static GetFile(url, type) {
11730
11745
  let data = ResourceLoader.cache.get(url);
11731
11746
  if (data) {
11732
- if (data.loadState === 'init' || data.loadState === 'fail') {
11747
+ if (data.loadState === 'fail') {
11733
11748
  return Promise.reject();
11734
11749
  }
11735
- else if (data.loadState === 'loading') {
11750
+ else if (data.loadState === 'init' || data.loadState === 'loading') {
11736
11751
  return data.dataPromise.then(data => data.data);
11737
11752
  }
11738
11753
  return Promise.resolve(data.data);
@@ -17198,7 +17213,7 @@ let Line$1 = class Line extends Graphic {
17198
17213
  const { points = lineTheme.points, connectedType } = attribute;
17199
17214
  const b = aabbBounds;
17200
17215
  points.forEach(p => {
17201
- if (p.defined !== false || connectedType === 'zero' || connectedType === 'connect') {
17216
+ if (p.defined !== false || connectedType === 'connect') {
17202
17217
  b.add(p.x, p.y);
17203
17218
  }
17204
17219
  });
@@ -17209,7 +17224,7 @@ let Line$1 = class Line extends Graphic {
17209
17224
  const b = aabbBounds;
17210
17225
  segments.forEach(s => {
17211
17226
  s.points.forEach(p => {
17212
- if (p.defined !== false || connectedType === 'zero' || connectedType === 'connect') {
17227
+ if (p.defined !== false || connectedType === 'connect') {
17213
17228
  b.add(p.x, p.y);
17214
17229
  }
17215
17230
  });
@@ -17844,17 +17859,22 @@ function getFixedLRTB(left, right, top, bottom) {
17844
17859
  const topInt = Math.round(top);
17845
17860
  const rightInt = Math.round(right);
17846
17861
  const bottomInt = Math.round(bottom);
17862
+ const _left = left > leftInt ? leftInt : leftInt - 0.5;
17863
+ const _top = top > topInt ? topInt : topInt - 0.5;
17864
+ const _right = rightInt > right ? rightInt : rightInt + 0.5;
17865
+ const _bottom = bottomInt > bottom ? bottomInt : bottomInt + 0.5;
17847
17866
  return {
17848
- left: leftInt,
17849
- top: topInt,
17850
- right: rightInt,
17851
- bottom: bottomInt
17867
+ left: _left,
17868
+ top: _top,
17869
+ right: _right,
17870
+ bottom: _bottom
17852
17871
  };
17853
17872
  }
17854
17873
  class Paragraph {
17855
- constructor(text, newLine, character) {
17874
+ constructor(text, newLine, character, ascentDescentMode) {
17856
17875
  this.fontSize = character.fontSize || 16;
17857
17876
  this.textBaseline = character.textBaseline || 'alphabetic';
17877
+ this.ascentDescentMode = ascentDescentMode;
17858
17878
  const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
17859
17879
  if (typeof lineHeight === 'number') {
17860
17880
  this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;
@@ -17863,7 +17883,7 @@ class Paragraph {
17863
17883
  this.lineHeight = Math.floor(1.2 * this.fontSize);
17864
17884
  }
17865
17885
  this.height = this.lineHeight;
17866
- const { ascent, height, descent, width } = measureTextCanvas(text, character);
17886
+ const { ascent, height, descent, width } = measureTextCanvas(text, character, this.ascentDescentMode);
17867
17887
  let halfDetaHeight = 0;
17868
17888
  let deltaAscent = 0;
17869
17889
  let deltaDescent = 0;
@@ -17909,7 +17929,7 @@ class Paragraph {
17909
17929
  this.ellipsisStr = '...';
17910
17930
  }
17911
17931
  updateWidth() {
17912
- const { width } = measureTextCanvas(this.text, this.character);
17932
+ const { width } = measureTextCanvas(this.text, this.character, this.ascentDescentMode);
17913
17933
  this.width = width;
17914
17934
  if (this.direction === 'vertical') {
17915
17935
  this.widthOrigin = this.width;
@@ -17945,17 +17965,41 @@ class Paragraph {
17945
17965
  text = text.slice(0, index);
17946
17966
  text += this.ellipsisStr;
17947
17967
  if (textAlign === 'right' || textAlign === 'end') {
17948
- const { width } = measureTextCanvas(this.text.slice(index), this.character);
17968
+ const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
17949
17969
  if (direction === 'vertical') ;
17950
17970
  else {
17951
17971
  left -= this.ellipsisWidth - width;
17952
17972
  }
17953
17973
  }
17954
17974
  }
17975
+ switch (this.character.script) {
17976
+ case 'super':
17977
+ baseline -= this.ascent * (1 / 3);
17978
+ break;
17979
+ case 'sub':
17980
+ baseline += this.descent / 2;
17981
+ break;
17982
+ }
17983
+ if (direction === 'vertical') {
17984
+ ctx.save();
17985
+ ctx.rotateAbout(Math.PI / 2, left, baseline);
17986
+ ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2);
17987
+ ctx.translate(left, baseline);
17988
+ left = 0;
17989
+ baseline = 0;
17990
+ }
17991
+ const fillStyle = ctx.fillStyle;
17992
+ const globalAlpha = ctx.globalAlpha;
17993
+ ctx.fillStyle = this.character.background;
17994
+ if (this.character.backgroundOpacity !== void 0) {
17995
+ ctx.globalAlpha = this.character.backgroundOpacity;
17996
+ }
17955
17997
  const right = left + (this.widthOrigin || this.width);
17956
17998
  const bottom = top + lineHeight;
17957
17999
  const lrtb = getFixedLRTB(left, right, top, bottom);
17958
- return Object.assign(Object.assign({}, lrtb), { fillStyle: this.character.background, globalAlpha: this.character.backgroundOpacity });
18000
+ ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
18001
+ ctx.fillStyle = fillStyle;
18002
+ ctx.globalAlpha = globalAlpha;
17959
18003
  }
17960
18004
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
17961
18005
  let baseline = top + ascent;
@@ -17982,7 +18026,7 @@ class Paragraph {
17982
18026
  text = text.slice(0, index);
17983
18027
  text += this.ellipsisStr;
17984
18028
  if (textAlign === 'right' || textAlign === 'end') {
17985
- const { width } = measureTextCanvas(this.text.slice(index), this.character);
18029
+ const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
17986
18030
  if (direction === 'vertical') ;
17987
18031
  else {
17988
18032
  left -= this.ellipsisWidth - width;
@@ -18019,14 +18063,14 @@ class Paragraph {
18019
18063
  const right = left + (this.widthOrigin || this.width);
18020
18064
  const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18021
18065
  const lrtb = getFixedLRTB(left, right, top, bottom);
18022
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
18066
+ ctx.fillRect(lrtb.left, 1 + baseline, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18023
18067
  }
18024
18068
  if (this.character.lineThrough) {
18025
18069
  const top = 1 + baseline - this.ascent / 2;
18026
18070
  const right = left + (this.widthOrigin || this.width);
18027
18071
  const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18028
18072
  const lrtb = getFixedLRTB(left, right, top, bottom);
18029
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
18073
+ ctx.fillRect(lrtb.left, 1 + baseline - this.ascent / 2, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18030
18074
  }
18031
18075
  }
18032
18076
  else if (this.character.textDecoration === 'underline') {
@@ -18034,14 +18078,14 @@ class Paragraph {
18034
18078
  const right = left + (this.widthOrigin || this.width);
18035
18079
  const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18036
18080
  const lrtb = getFixedLRTB(left, right, top, bottom);
18037
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
18081
+ ctx.fillRect(lrtb.left, 1 + baseline, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18038
18082
  }
18039
18083
  else if (this.character.textDecoration === 'line-through') {
18040
18084
  const top = 1 + baseline - this.ascent / 2;
18041
18085
  const right = left + (this.widthOrigin || this.width);
18042
18086
  const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18043
18087
  const lrtb = getFixedLRTB(left, right, top, bottom);
18044
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
18088
+ ctx.fillRect(lrtb.left, 1 + baseline - this.ascent / 2, lrtb.right - lrtb.left, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);
18045
18089
  }
18046
18090
  }
18047
18091
  if (direction === 'vertical') {
@@ -18061,7 +18105,7 @@ class Paragraph {
18061
18105
  const index = getStrByWithCanvas(text, width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
18062
18106
  text = text.slice(0, index);
18063
18107
  text += this.ellipsisStr;
18064
- const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character);
18108
+ const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
18065
18109
  return width + this.ellipsisWidth - measureWidth;
18066
18110
  }
18067
18111
  return width;
@@ -18070,8 +18114,8 @@ class Paragraph {
18070
18114
  function seperateParagraph(paragraph, index) {
18071
18115
  const text1 = paragraph.text.slice(0, index);
18072
18116
  const text2 = paragraph.text.slice(index);
18073
- const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character);
18074
- const p2 = new Paragraph(text2, true, paragraph.character);
18117
+ const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode);
18118
+ const p2 = new Paragraph(text2, true, paragraph.character, paragraph.ascentDescentMode);
18075
18119
  return [p1, p2];
18076
18120
  }
18077
18121
 
@@ -18361,7 +18405,7 @@ class Line {
18361
18405
  }
18362
18406
  const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || '';
18363
18407
  paragraph.ellipsisStr = ellipsis;
18364
- const { width } = measureTextCanvas(ellipsis, paragraph.character);
18408
+ const { width } = measureTextCanvas(ellipsis, paragraph.character, paragraph.ascentDescentMode);
18365
18409
  const ellipsisWidth = width || 0;
18366
18410
  if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
18367
18411
  lastLine && (paragraph.ellipsis = 'add');
@@ -18380,35 +18424,11 @@ class Line {
18380
18424
  }
18381
18425
  }
18382
18426
  }
18383
- let fillStyle = '';
18384
- let globalAlpha = -1;
18385
- let currBgList = [];
18386
- const bgList = [currBgList];
18387
18427
  this.paragraphs.forEach((paragraph, index) => {
18388
18428
  if (paragraph instanceof RichTextIcon) {
18389
18429
  return;
18390
18430
  }
18391
- const data = paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
18392
- if (!data) {
18393
- return;
18394
- }
18395
- if (!(fillStyle === data.fillStyle && globalAlpha === data.globalAlpha)) {
18396
- currBgList = [];
18397
- bgList.push(currBgList);
18398
- fillStyle = data.fillStyle;
18399
- globalAlpha = data.globalAlpha;
18400
- }
18401
- currBgList.push(data);
18402
- });
18403
- bgList.forEach(bg => {
18404
- if (bg.length === 0) {
18405
- return;
18406
- }
18407
- const data = bg[0];
18408
- const end = bg[bg.length - 1];
18409
- ctx.fillStyle = data.fillStyle;
18410
- ctx.globalAlpha = data.globalAlpha;
18411
- ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
18431
+ paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
18412
18432
  });
18413
18433
  this.paragraphs.forEach((paragraph, index) => {
18414
18434
  if (paragraph instanceof RichTextIcon) {
@@ -18437,7 +18457,7 @@ class Line {
18437
18457
  if (paragraph instanceof RichTextIcon) {
18438
18458
  break;
18439
18459
  }
18440
- const { width } = measureTextCanvas(ellipsis, paragraph.character);
18460
+ const { width } = measureTextCanvas(ellipsis, paragraph.character, paragraph.ascentDescentMode);
18441
18461
  const ellipsisWidth = width || 0;
18442
18462
  if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
18443
18463
  paragraph.ellipsis = 'add';
@@ -18757,16 +18777,7 @@ class RichText extends Graphic {
18757
18777
  return tc.every(item => item.isComposing ||
18758
18778
  !(item.text && isString(item.text) && RichText.splitText(item.text).length > 1));
18759
18779
  }
18760
- static splitEmoji(text) {
18761
- return [...new Intl.Segmenter().segment(text)].map(x => x.segment);
18762
- }
18763
18780
  static splitText(text) {
18764
- try {
18765
- const arr = this.splitEmoji(text);
18766
- return arr;
18767
- }
18768
- catch (e) {
18769
- }
18770
18781
  return Array.from(text);
18771
18782
  }
18772
18783
  static TransformTextConfig2SingleCharacter(textConfig) {
@@ -18883,7 +18894,7 @@ class RichText extends Graphic {
18883
18894
  }
18884
18895
  doUpdateFrameCache(tc) {
18885
18896
  var _a;
18886
- const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable } = this.attribute;
18897
+ const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode } = this.attribute;
18887
18898
  let { textConfig: _tc = [] } = this.attribute;
18888
18899
  if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {
18889
18900
  _tc = RichText.TransformTextConfig2SingleCharacter(_tc);
@@ -18918,11 +18929,11 @@ class RichText extends Graphic {
18918
18929
  if (richTextConfig.text && richTextConfig.text.includes('\n')) {
18919
18930
  const textParts = richTextConfig.text.split('\n');
18920
18931
  for (let j = 0; j < textParts.length; j++) {
18921
- paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig));
18932
+ paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
18922
18933
  }
18923
18934
  }
18924
18935
  else if (richTextConfig.text) {
18925
- paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig));
18936
+ paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig, ascentDescentMode));
18926
18937
  }
18927
18938
  }
18928
18939
  }
@@ -20825,8 +20836,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
20825
20836
  this.useStyle = true;
20826
20837
  this.order = 0;
20827
20838
  }
20828
- drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
20829
- return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
20839
+ drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
20840
+ return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
20830
20841
  }
20831
20842
  }
20832
20843
  const defaultImageRenderContribution = new DefaultImageRenderContribution();
@@ -21424,7 +21435,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
21424
21435
  this._draw(line, lineAttribute, false, drawContext, params);
21425
21436
  }
21426
21437
  drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb) {
21427
- var _a, _b, _c, _d, _e;
21438
+ var _a;
21428
21439
  if (!cache) {
21429
21440
  return;
21430
21441
  }
@@ -21463,60 +21474,6 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
21463
21474
  context.stroke();
21464
21475
  }
21465
21476
  }
21466
- let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
21467
- if (isArray(defaultAttribute)) {
21468
- connectedType = (_b = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute[0].connectedType) !== null && _b !== void 0 ? _b : defaultAttribute[1].connectedType;
21469
- connectedX = (_c = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute[0].connectedX) !== null && _c !== void 0 ? _c : defaultAttribute[1].connectedX;
21470
- connectedY = (_d = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute[0].connectedY) !== null && _d !== void 0 ? _d : defaultAttribute[1].connectedY;
21471
- connectedStyle = (_e = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute[0].connectedStyle) !== null && _e !== void 0 ? _e : defaultAttribute[1].connectedStyle;
21472
- }
21473
- else {
21474
- connectedType = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute.connectedType;
21475
- connectedX = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute.connectedX;
21476
- connectedY = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute.connectedY;
21477
- connectedStyle = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute.connectedStyle;
21478
- }
21479
- if (connectedType !== 'connect' && connectedType !== 'zero') {
21480
- connectedType = 'none';
21481
- }
21482
- if (connectedType !== 'none') {
21483
- context.beginPath();
21484
- drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {
21485
- offsetX,
21486
- offsetY,
21487
- offsetZ: z,
21488
- drawConnect: true,
21489
- mode: connectedType,
21490
- zeroX: connectedX,
21491
- zeroY: connectedY
21492
- });
21493
- const da = [];
21494
- if (isArray(defaultAttribute)) {
21495
- defaultAttribute.forEach(i => da.push(i));
21496
- }
21497
- else {
21498
- da.push(defaultAttribute);
21499
- }
21500
- da.push(attribute);
21501
- if (fill !== false) {
21502
- if (fillCb) {
21503
- fillCb(context, attribute, defaultAttribute);
21504
- }
21505
- else if (fillOpacity) {
21506
- context.setCommonStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
21507
- context.fill();
21508
- }
21509
- }
21510
- if (stroke !== false) {
21511
- if (strokeCb) {
21512
- strokeCb(context, attribute, defaultAttribute);
21513
- }
21514
- else if (strokeOpacity) {
21515
- context.setStrokeStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
21516
- context.stroke();
21517
- }
21518
- }
21519
- }
21520
21477
  return !!ret;
21521
21478
  }
21522
21479
  drawLinearLineHighPerformance(line, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, lineAttribute, drawContext, params, fillCb, strokeCb) {
@@ -21553,7 +21510,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
21553
21510
  }
21554
21511
  drawShape(line, context, x, y, drawContext, params, fillCb, strokeCb) {
21555
21512
  const lineAttribute = getTheme(line, params === null || params === void 0 ? void 0 : params.theme).line;
21556
- const { fill = lineAttribute.fill, stroke = lineAttribute.stroke, fillOpacity = lineAttribute.fillOpacity, strokeOpacity = lineAttribute.strokeOpacity, segments, points, closePath, curveTension = lineAttribute.curveTension } = line.attribute;
21513
+ const { fill = lineAttribute.fill, stroke = lineAttribute.stroke, fillOpacity = lineAttribute.fillOpacity, strokeOpacity = lineAttribute.strokeOpacity, segments, points, closePath, curveTension = lineAttribute.curveTension, connectedType = lineAttribute.connectedType } = line.attribute;
21557
21514
  const data = this.valid(line, lineAttribute, fillCb, strokeCb);
21558
21515
  if (!data) {
21559
21516
  return;
@@ -21566,6 +21523,12 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
21566
21523
  if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
21567
21524
  return this.drawLinearLineHighPerformance(line, context, !!fill, !!stroke, fillOpacity, strokeOpacity, x, y, lineAttribute, drawContext, params, fillCb, strokeCb);
21568
21525
  }
21526
+ function parsePoint(points, connectedType) {
21527
+ if (connectedType === 'none') {
21528
+ return points;
21529
+ }
21530
+ return points.filter(p => p.defined !== false);
21531
+ }
21569
21532
  if (line.shouldUpdateShape()) {
21570
21533
  const { points, segments } = line.attribute;
21571
21534
  const _points = points;
@@ -21597,7 +21560,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
21597
21560
  startPoint.y = lastSeg.endY;
21598
21561
  startPoint.defined = lastSeg.curves[lastSeg.curves.length - 1].defined;
21599
21562
  }
21600
- const data = calcLineCache(seg.points, curveType, {
21563
+ const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
21601
21564
  startPoint,
21602
21565
  curveTension
21603
21566
  });
@@ -21623,7 +21586,7 @@ let DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
21623
21586
  }
21624
21587
  }
21625
21588
  else if (points && points.length) {
21626
- line.cache = calcLineCache(_points, curveType, { curveTension });
21589
+ line.cache = calcLineCache(parsePoint(_points, connectedType), curveType, { curveTension });
21627
21590
  }
21628
21591
  else {
21629
21592
  line.cache = null;
@@ -21675,10 +21638,6 @@ DefaultCanvasLineRender = __decorate([
21675
21638
 
21676
21639
  function drawAreaSegments(path, segPath, percent, params) {
21677
21640
  var _a;
21678
- const { drawConnect = false, mode = 'none' } = params || {};
21679
- if (drawConnect && mode === 'none') {
21680
- return;
21681
- }
21682
21641
  const { top, bottom } = segPath;
21683
21642
  if (top.curves.length !== bottom.curves.length) {
21684
21643
  return;
@@ -21687,90 +21646,28 @@ function drawAreaSegments(path, segPath, percent, params) {
21687
21646
  const topList = [];
21688
21647
  const bottomList = [];
21689
21648
  let lastDefined = true;
21690
- if (drawConnect) {
21691
- let defined0 = true;
21692
- let lastCurve;
21693
- let lastBottomCurve;
21694
- const n = top.curves.length;
21695
- top.curves.forEach((curve, i) => {
21696
- const bototmCurve = bottom.curves[n - i - 1];
21697
- let currentTopCurve = curve;
21698
- let currentBottomCurve = bototmCurve;
21699
- if (curve.originP1 === curve.originP2) {
21700
- lastCurve = curve;
21701
- lastBottomCurve = bototmCurve;
21702
- return;
21703
- }
21704
- if (lastCurve && lastCurve.originP1 === lastCurve.originP2) {
21705
- currentTopCurve = lastCurve;
21706
- currentBottomCurve = lastBottomCurve;
21707
- }
21708
- if (curve.defined) {
21709
- if (!defined0) {
21710
- topList.push(currentTopCurve);
21711
- bottomList.push(currentBottomCurve);
21712
- drawAreaConnectBlock(path, topList, bottomList, params);
21713
- topList.length = 0;
21714
- bottomList.length = 0;
21715
- defined0 = !defined0;
21716
- }
21649
+ for (let i = 0, n = top.curves.length; i < n; i++) {
21650
+ const topCurve = top.curves[i];
21651
+ if (lastDefined !== topCurve.defined) {
21652
+ if (lastDefined) {
21653
+ drawAreaBlock(path, topList, bottomList, params);
21654
+ topList.length = 0;
21655
+ bottomList.length = 0;
21717
21656
  }
21718
21657
  else {
21719
- const { originP1, originP2 } = curve;
21720
- let validTopCurve;
21721
- let validBottomCurve;
21722
- if (originP1 && originP1.defined !== false) {
21723
- validTopCurve = currentTopCurve;
21724
- validBottomCurve = currentBottomCurve;
21725
- }
21726
- else if (originP1 && originP2.defined !== false) {
21727
- validTopCurve = curve;
21728
- validBottomCurve = bototmCurve;
21729
- }
21730
- if (defined0) {
21731
- defined0 = !defined0;
21732
- topList.push(validTopCurve || curve);
21733
- bottomList.push(validBottomCurve || bototmCurve);
21734
- }
21735
- else {
21736
- if (validTopCurve) {
21737
- defined0 = !defined0;
21738
- topList.push(validTopCurve || curve);
21739
- bottomList.push(validBottomCurve || bototmCurve);
21740
- drawAreaConnectBlock(path, topList, bottomList, params);
21741
- topList.length = 0;
21742
- bottomList.length = 0;
21743
- }
21744
- }
21658
+ topList.push(topCurve);
21659
+ bottomList.push(bottom.curves[n - i - 1]);
21745
21660
  }
21746
- lastCurve = curve;
21747
- });
21748
- drawAreaConnectBlock(path, topList, bottomList, params);
21749
- }
21750
- else {
21751
- for (let i = 0, n = top.curves.length; i < n; i++) {
21752
- const topCurve = top.curves[i];
21753
- if (lastDefined !== topCurve.defined) {
21754
- if (lastDefined) {
21755
- drawAreaBlock(path, topList, bottomList, params);
21756
- topList.length = 0;
21757
- bottomList.length = 0;
21758
- }
21759
- else {
21760
- topList.push(topCurve);
21761
- bottomList.push(bottom.curves[n - i - 1]);
21762
- }
21763
- lastDefined = !lastDefined;
21764
- }
21765
- else {
21766
- if (lastDefined) {
21767
- topList.push(topCurve);
21768
- bottomList.push(bottom.curves[n - i - 1]);
21769
- }
21661
+ lastDefined = !lastDefined;
21662
+ }
21663
+ else {
21664
+ if (lastDefined) {
21665
+ topList.push(topCurve);
21666
+ bottomList.push(bottom.curves[n - i - 1]);
21770
21667
  }
21771
21668
  }
21772
- drawAreaBlock(path, topList, bottomList, params);
21773
21669
  }
21670
+ drawAreaBlock(path, topList, bottomList, params);
21774
21671
  return;
21775
21672
  }
21776
21673
  if (percent <= 0) {
@@ -21794,9 +21691,6 @@ function drawAreaSegments(path, segPath, percent, params) {
21794
21691
  let lastDefined = true;
21795
21692
  const topList = [];
21796
21693
  const bottomList = [];
21797
- let defined0 = true;
21798
- let lastTopCurve;
21799
- let lastBottomCurve;
21800
21694
  for (let i = 0, n = top.curves.length; i < n; i++) {
21801
21695
  const topCurve = top.curves[i];
21802
21696
  const curCurveLength = topCurve.getLength(direction);
@@ -21805,127 +21699,50 @@ function drawAreaSegments(path, segPath, percent, params) {
21805
21699
  break;
21806
21700
  }
21807
21701
  drawedLengthUntilLast += curCurveLength;
21808
- if (drawConnect) {
21809
- const bototmCurve = bottom.curves[n - i - 1];
21810
- let currentTopCurve = topCurve;
21811
- let currentBottomCurve = bototmCurve;
21812
- if (topCurve.originP1 === topCurve.originP2) {
21813
- lastTopCurve = topCurve;
21814
- lastBottomCurve = bototmCurve;
21815
- continue;
21816
- }
21817
- if (lastTopCurve && lastTopCurve.originP1 === lastTopCurve.originP2) {
21818
- currentTopCurve = lastTopCurve;
21819
- currentBottomCurve = lastBottomCurve;
21820
- }
21821
- if (topCurve.defined) {
21822
- if (!defined0) {
21823
- topList.push(currentTopCurve);
21824
- bottomList.push(currentBottomCurve);
21825
- drawAreaConnectBlock(path, topList, bottomList, params);
21826
- topList.length = 0;
21827
- bottomList.length = 0;
21828
- defined0 = !defined0;
21829
- }
21702
+ let tc = null;
21703
+ let bc = null;
21704
+ if (lastDefined !== topCurve.defined) {
21705
+ if (lastDefined) {
21706
+ drawAreaBlock(path, topList, bottomList, params);
21707
+ topList.length = 0;
21708
+ bottomList.length = 0;
21830
21709
  }
21831
21710
  else {
21832
- const { originP1, originP2 } = topCurve;
21833
- let validTopCurve;
21834
- let validBottomCurve;
21835
- if (originP1 && originP1.defined !== false) {
21836
- validTopCurve = currentTopCurve;
21837
- validBottomCurve = currentBottomCurve;
21838
- }
21839
- else if (originP1 && originP2.defined !== false) {
21840
- validTopCurve = topCurve;
21841
- validBottomCurve = bototmCurve;
21842
- }
21843
- if (defined0) {
21844
- defined0 = !defined0;
21845
- topList.push(validTopCurve || topCurve);
21846
- bottomList.push(validBottomCurve || bototmCurve);
21847
- }
21848
- else {
21849
- if (validTopCurve) {
21850
- defined0 = !defined0;
21851
- topList.push(validTopCurve || topCurve);
21852
- bottomList.push(validBottomCurve || bototmCurve);
21853
- drawAreaConnectBlock(path, topList, bottomList, params);
21854
- topList.length = 0;
21855
- bottomList.length = 0;
21856
- }
21857
- }
21711
+ tc = topCurve;
21712
+ bc = bottom.curves[n - i - 1];
21858
21713
  }
21859
- lastTopCurve = topCurve;
21714
+ lastDefined = !lastDefined;
21860
21715
  }
21861
21716
  else {
21862
- let tc = null;
21863
- let bc = null;
21864
- if (lastDefined !== topCurve.defined) {
21865
- if (lastDefined) {
21866
- drawAreaBlock(path, topList, bottomList, params);
21867
- topList.length = 0;
21868
- bottomList.length = 0;
21717
+ if (lastDefined) {
21718
+ tc = topCurve;
21719
+ bc = bottom.curves[n - i - 1];
21720
+ }
21721
+ }
21722
+ if (tc && bc) {
21723
+ if (percent < 1) {
21724
+ if (tc.p2 && tc.p3) {
21725
+ tc = divideCubic(tc, percent)[0];
21869
21726
  }
21870
21727
  else {
21871
- tc = topCurve;
21872
- bc = bottom.curves[n - i - 1];
21728
+ tc = divideLinear(tc, percent)[0];
21873
21729
  }
21874
- lastDefined = !lastDefined;
21875
- }
21876
- else {
21877
- if (lastDefined) {
21878
- tc = topCurve;
21879
- bc = bottom.curves[n - i - 1];
21730
+ if (bc.p2 && bc.p3) {
21731
+ bc = divideCubic(bc, 1 - percent)[1];
21880
21732
  }
21881
- }
21882
- if (tc && bc) {
21883
- if (percent < 1) {
21884
- if (tc.p2 && tc.p3) {
21885
- tc = divideCubic(tc, percent)[0];
21886
- }
21887
- else {
21888
- tc = divideLinear(tc, percent)[0];
21889
- }
21890
- if (bc.p2 && bc.p3) {
21891
- bc = divideCubic(bc, 1 - percent)[1];
21892
- }
21893
- else {
21894
- bc = divideLinear(bc, 1 - percent)[1];
21895
- }
21733
+ else {
21734
+ bc = divideLinear(bc, 1 - percent)[1];
21896
21735
  }
21897
- tc.defined = lastDefined;
21898
- bc.defined = lastDefined;
21899
- topList.push(tc);
21900
- bottomList.push(bc);
21901
21736
  }
21902
- tc = null;
21903
- bc = null;
21737
+ tc.defined = lastDefined;
21738
+ bc.defined = lastDefined;
21739
+ topList.push(tc);
21740
+ bottomList.push(bc);
21904
21741
  }
21742
+ tc = null;
21743
+ bc = null;
21905
21744
  }
21906
- if (drawConnect) {
21907
- drawAreaConnectBlock(path, topList, bottomList, params);
21908
- }
21909
- else {
21910
- drawAreaBlock(path, topList, bottomList, params);
21911
- }
21912
- }
21913
- function drawAreaConnectBlock(path, topList, bottomList, params) {
21914
- if (topList.length < 2) {
21915
- return;
21916
- }
21917
- const { offsetX = 0, offsetY = 0, offsetZ = 0, mode } = params || {};
21918
- let curve = topList[0];
21919
- path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
21920
- curve = topList[topList.length - 1];
21921
- let end = curve.p3 || curve.p1;
21922
- path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
21923
- curve = bottomList[bottomList.length - 1];
21924
- path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
21925
- curve = bottomList[0];
21926
- end = curve.p3 || curve.p1;
21927
- path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
21928
- path.closePath();
21745
+ drawAreaBlock(path, topList, bottomList, params);
21929
21746
  }
21930
21747
  function drawAreaBlock(path, topList, bottomList, params) {
21931
21748
  const { offsetX = 0, offsetY = 0, offsetZ = 0 } = params || {};
@@ -22039,7 +21856,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22039
21856
  drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
22040
21857
  var _a, _b, _c, _d, _e, _f;
22041
21858
  const areaAttribute = getTheme(area, params === null || params === void 0 ? void 0 : params.theme).area;
22042
- const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity, curveTension = areaAttribute.curveTension } = area.attribute;
21859
+ const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity, curveTension = areaAttribute.curveTension, connectedType = areaAttribute.connectedType } = area.attribute;
22043
21860
  const data = this.valid(area, areaAttribute, fillCb, strokeCb);
22044
21861
  if (!data) {
22045
21862
  return;
@@ -22051,6 +21868,12 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22051
21868
  if (closePath && curveType === 'linear') {
22052
21869
  curveType = 'linearClosed';
22053
21870
  }
21871
+ function parsePoint(points, connectedType) {
21872
+ if (connectedType !== 'connect') {
21873
+ return points;
21874
+ }
21875
+ return points.filter(p => p.defined !== false);
21876
+ }
22054
21877
  if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
22055
21878
  return this.drawLinearAreaHighPerformance(area, context, !!fill, doStroke, fillOpacity, strokeOpacity, x, y, areaAttribute, drawContext, params, fillCb, strokeCb);
22056
21879
  }
@@ -22073,7 +21896,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22073
21896
  startPoint.x = lastTopSeg.endX;
22074
21897
  startPoint.y = lastTopSeg.endY;
22075
21898
  }
22076
- const data = calcLineCache(seg.points, curveType, {
21899
+ const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
22077
21900
  startPoint,
22078
21901
  curveTension
22079
21902
  });
@@ -22102,7 +21925,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22102
21925
  });
22103
21926
  }
22104
21927
  if (bottomPoints.length > 1) {
22105
- lastBottomSeg = calcLineCache(bottomPoints, curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
21928
+ lastBottomSeg = calcLineCache(parsePoint(bottomPoints, connectedType), curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
22106
21929
  bottomCaches.unshift(lastBottomSeg);
22107
21930
  }
22108
21931
  }
@@ -22112,12 +21935,12 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22112
21935
  }));
22113
21936
  }
22114
21937
  else if (points && points.length) {
22115
- const topPoints = points;
21938
+ const topPoints = parsePoint(points, connectedType);
22116
21939
  const bottomPoints = [];
22117
- for (let i = points.length - 1; i >= 0; i--) {
21940
+ for (let i = topPoints.length - 1; i >= 0; i--) {
22118
21941
  bottomPoints.push({
22119
- x: (_e = points[i].x1) !== null && _e !== void 0 ? _e : points[i].x,
22120
- y: (_f = points[i].y1) !== null && _f !== void 0 ? _f : points[i].y
21942
+ x: (_e = topPoints[i].x1) !== null && _e !== void 0 ? _e : topPoints[i].x,
21943
+ y: (_f = topPoints[i].y1) !== null && _f !== void 0 ? _f : topPoints[i].y
22121
21944
  });
22122
21945
  }
22123
21946
  const topCache = calcLineCache(topPoints, curveType, { curveTension });
@@ -22172,17 +21995,9 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22172
21995
  this._draw(area, areaAttribute, false, drawContext, params);
22173
21996
  }
22174
21997
  drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
22175
- let ret = false;
22176
- ret =
22177
- ret ||
22178
- this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, false, fillCb, strokeCb);
22179
- ret =
22180
- ret ||
22181
- this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, true, fillCb, strokeCb);
22182
- return ret;
21998
+ return this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb);
22183
21999
  }
22184
- _drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, connect, fillCb, strokeCb) {
22185
- var _a, _b, _c, _d;
22000
+ _drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
22186
22001
  if (!(cache &&
22187
22002
  cache.top &&
22188
22003
  cache.bottom &&
@@ -22192,35 +22007,6 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22192
22007
  cache.bottom.curves.length)) {
22193
22008
  return;
22194
22009
  }
22195
- let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
22196
- const da = [];
22197
- if (connect) {
22198
- if (isArray(defaultAttribute)) {
22199
- connectedType = (_a = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute[0].connectedType) !== null && _a !== void 0 ? _a : defaultAttribute[1].connectedType;
22200
- connectedX = (_b = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute[0].connectedX) !== null && _b !== void 0 ? _b : defaultAttribute[1].connectedX;
22201
- connectedY = (_c = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute[0].connectedY) !== null && _c !== void 0 ? _c : defaultAttribute[1].connectedY;
22202
- connectedStyle = (_d = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute[0].connectedStyle) !== null && _d !== void 0 ? _d : defaultAttribute[1].connectedStyle;
22203
- }
22204
- else {
22205
- connectedType = connectedType !== null && connectedType !== void 0 ? connectedType : defaultAttribute.connectedType;
22206
- connectedX = connectedX !== null && connectedX !== void 0 ? connectedX : defaultAttribute.connectedX;
22207
- connectedY = connectedY !== null && connectedY !== void 0 ? connectedY : defaultAttribute.connectedY;
22208
- connectedStyle = connectedStyle !== null && connectedStyle !== void 0 ? connectedStyle : defaultAttribute.connectedStyle;
22209
- }
22210
- if (connectedType !== 'connect' && connectedType !== 'zero') {
22211
- connectedType = 'none';
22212
- }
22213
- if (isArray(defaultAttribute)) {
22214
- defaultAttribute.forEach(i => da.push(i));
22215
- }
22216
- else {
22217
- da.push(defaultAttribute);
22218
- }
22219
- da.push(attribute);
22220
- }
22221
- if (connect && connectedType === 'none') {
22222
- return false;
22223
- }
22224
22010
  context.beginPath();
22225
22011
  const ret = false;
22226
22012
  const { points, segments } = area.attribute;
@@ -22255,11 +22041,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22255
22041
  offsetX,
22256
22042
  offsetY,
22257
22043
  offsetZ,
22258
- direction,
22259
- drawConnect: connect,
22260
- mode: connectedType,
22261
- zeroX: connectedX,
22262
- zeroY: connectedY
22044
+ direction
22263
22045
  });
22264
22046
  this.beforeRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, defaultAttribute, drawContext, fillCb, null, { attribute });
22265
22047
  context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);
@@ -22270,7 +22052,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22270
22052
  fillCb(context, attribute, defaultAttribute);
22271
22053
  }
22272
22054
  else if (fillOpacity) {
22273
- context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
22055
+ context.setCommonStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
22274
22056
  context.fill();
22275
22057
  }
22276
22058
  }
@@ -22287,14 +22069,10 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
22287
22069
  drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? 'x' : 'y', {
22288
22070
  offsetX,
22289
22071
  offsetY,
22290
- offsetZ,
22291
- drawConnect: connect,
22292
- mode: connectedType,
22293
- zeroX: connectedX,
22294
- zeroY: connectedY
22072
+ offsetZ
22295
22073
  });
22296
22074
  }
22297
- context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
22075
+ context.setStrokeStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
22298
22076
  context.stroke();
22299
22077
  }
22300
22078
  }
@@ -27133,12 +26911,12 @@ class EditModule {
27133
26911
  this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);
27134
26912
  if (this.cursorIndex < 0) {
27135
26913
  const config = textConfig[0];
27136
- textConfig.unshift(Object.assign(Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), config), { text: '' }));
26914
+ textConfig.unshift(Object.assign(Object.assign(Object.assign({ fill: 'black' }, getDefaultCharacterConfig(this.currRt.attribute)), config), { text: '' }));
27137
26915
  }
27138
26916
  else {
27139
26917
  const configIdx = this.composingConfigIdx;
27140
26918
  const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];
27141
- textConfig.splice(configIdx, 0, Object.assign(Object.assign({}, lastConfig), { text: '' }));
26919
+ textConfig.splice(configIdx, 0, Object.assign(Object.assign({ fill: 'black' }, lastConfig), { text: '' }));
27142
26920
  }
27143
26921
  };
27144
26922
  this.handleCompositionEnd = () => {
@@ -27268,7 +27046,7 @@ class EditModule {
27268
27046
  const text = lastConfig.text;
27269
27047
  const textList = text ? Array.from(text.toString()) : [];
27270
27048
  for (let i = 0; i < textList.length; i++) {
27271
- textConfig.splice(i + configIdx, 0, Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), { fill: 'black' }), lastConfig), { isComposing: false, text: textList[i] }));
27049
+ textConfig.splice(i + configIdx, 0, Object.assign(Object.assign({ fill: 'black' }, lastConfig), { isComposing: false, text: textList[i] }));
27272
27050
  }
27273
27051
  this.currRt.setAttributes({ textConfig });
27274
27052
  const nextConfigIdx = configIdx + textList.length;
@@ -27455,31 +27233,28 @@ class RichTextEditPlugin {
27455
27233
  throw new Error('不会走到这里 handleFocusOut');
27456
27234
  };
27457
27235
  this.handleMove = (e) => {
27458
- if (this.currRt && !this.currRt.attribute.editable) {
27459
- this.deFocus(true);
27460
- }
27461
- if (!this.isEditableRichtext(e)) {
27462
- this.handleLeave();
27236
+ if (!this.isRichtext(e)) {
27463
27237
  return;
27464
27238
  }
27465
- this.handleEnter();
27239
+ this.currRt = e.target;
27240
+ this.handleEnter(e);
27466
27241
  e.target.once('pointerleave', this.handleLeave);
27467
27242
  this.tryShowSelection(e, false);
27468
27243
  };
27469
- this.handleEnter = () => {
27244
+ this.handleEnter = (e) => {
27470
27245
  this.editing = true;
27471
27246
  this.pluginService.stage.setCursor('text');
27472
27247
  };
27473
- this.handleLeave = () => {
27248
+ this.handleLeave = (e) => {
27474
27249
  this.editing = false;
27475
27250
  this.pluginService.stage.setCursor('default');
27476
27251
  };
27477
27252
  this.handlePointerDown = (e) => {
27478
- if (!this.editing || !this.isEditableRichtext(e)) {
27479
- this.deFocus(true);
27253
+ if (this.editing) {
27254
+ this.onFocus(e);
27480
27255
  }
27481
27256
  else {
27482
- this.onFocus(e);
27257
+ this.deFocus(true);
27483
27258
  }
27484
27259
  this.triggerRender();
27485
27260
  this.pointerDown = true;
@@ -27617,12 +27392,6 @@ class RichTextEditPlugin {
27617
27392
  return;
27618
27393
  }
27619
27394
  const { lines } = cache;
27620
- if (lines.length === 0) {
27621
- return;
27622
- }
27623
- if (!lines[0].paragraphs || lines[0].paragraphs.length === 0) {
27624
- return;
27625
- }
27626
27395
  const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
27627
27396
  this.selectionRange(-0.1, totalCursorCount + 0.1);
27628
27397
  e.preventDefault();
@@ -27747,7 +27516,7 @@ class RichTextEditPlugin {
27747
27516
  if (placeholderFontSize) {
27748
27517
  textConfigItem.fontSize = placeholderFontSize;
27749
27518
  }
27750
- this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), { x: 0, y: 0, pickable: false, editable: false, editOptions: null, angle: 0, _debug_bounds: false, textConfig: [textConfigItem] }));
27519
+ this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), { x: 0, y: 0, angle: 0, _debug_bounds: false, textConfig: [textConfigItem] }));
27751
27520
  shadow.add(this.shadowPlaceHolder);
27752
27521
  }
27753
27522
  tryShowInputBounds() {
@@ -27760,12 +27529,11 @@ class RichTextEditPlugin {
27760
27529
  return;
27761
27530
  }
27762
27531
  const { attribute } = this.currRt;
27763
- let b = this.currRt.AABBBounds;
27532
+ const b = this.currRt.AABBBounds;
27764
27533
  let h = b.height();
27765
27534
  if (!attribute.textConfig.length && this.editLine) {
27766
27535
  const { points } = this.editLine.attribute;
27767
27536
  h = points[1].y - points[0].y;
27768
- b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
27769
27537
  }
27770
27538
  this.shadowBounds = this.shadowBounds || createRect({});
27771
27539
  this.shadowBounds.setAttributes({
@@ -27790,7 +27558,7 @@ class RichTextEditPlugin {
27790
27558
  if (textConfig && textConfig.length) {
27791
27559
  return;
27792
27560
  }
27793
- if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceHolderToTextConfig)) {
27561
+ if (!(editOptions && editOptions.placeholder)) {
27794
27562
  return;
27795
27563
  }
27796
27564
  const { placeholder } = editOptions;
@@ -27881,15 +27649,16 @@ class RichTextEditPlugin {
27881
27649
  }
27882
27650
  }
27883
27651
  deFocus(trulyDeFocus = false) {
27884
- const currRt = this.currRt;
27885
- if (!currRt) {
27652
+ this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
27653
+ const target = this.currRt;
27654
+ if (!target) {
27886
27655
  return;
27887
27656
  }
27888
- this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
27889
27657
  if (trulyDeFocus) {
27890
27658
  this.trySyncPlaceholderToTextConfig();
27891
- currRt.detachShadow();
27659
+ target.detachShadow();
27892
27660
  }
27661
+ const currRt = this.currRt;
27893
27662
  this.currRt = null;
27894
27663
  if (this.editLine) {
27895
27664
  this.editLine.parent && this.editLine.parent.removeChild(this.editLine);
@@ -27921,7 +27690,6 @@ class RichTextEditPlugin {
27921
27690
  cleared = true;
27922
27691
  }
27923
27692
  cleared && currRt.setAttributes({ textConfig });
27924
- currRt.removeEventListener('pointerleave', this.handleLeave);
27925
27693
  }
27926
27694
  addAnimateToLine(line) {
27927
27695
  line.animates &&
@@ -27982,9 +27750,6 @@ class RichTextEditPlugin {
27982
27750
  };
27983
27751
  let line0Info = this.getLineByPoint(cache, startCursorPos);
27984
27752
  let line1Info = this.getLineByPoint(cache, endCursorPos);
27985
- if (!line0Info || !line1Info) {
27986
- return;
27987
- }
27988
27753
  if (startCursorPos.y > endCursorPos.y ||
27989
27754
  (startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x)) {
27990
27755
  [startCursorPos, endCursorPos] = [endCursorPos, startCursorPos];
@@ -28118,10 +27883,7 @@ class RichTextEditPlugin {
28118
27883
  return -1;
28119
27884
  }
28120
27885
  isRichtext(e) {
28121
- return !!(e.target && e.target.type === 'richtext');
28122
- }
28123
- isEditableRichtext(e) {
28124
- return this.isRichtext(e) && !!e.target.attribute.editable;
27886
+ return !!(e.target && e.target.type === 'richtext' && e.target.attribute.editable);
28125
27887
  }
28126
27888
  triggerRender() {
28127
27889
  this.pluginService.stage.renderNextFrame();
@@ -28280,7 +28042,7 @@ class RichTextEditPlugin {
28280
28042
  }
28281
28043
  }
28282
28044
  _forceFocusByEvent(e) {
28283
- this.handleEnter();
28045
+ this.handleEnter(e);
28284
28046
  this.handlePointerDown(e);
28285
28047
  this.handlePointerUp(e);
28286
28048
  }