@visactor/vrender-core 0.22.0 → 0.22.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.
Files changed (114) hide show
  1. package/cjs/allocator/bounds-allocate.js +1 -1
  2. package/cjs/allocator/canvas-allocate.js +1 -1
  3. package/cjs/allocator/constants.js +1 -1
  4. package/cjs/allocator/graphic-allocate.js +1 -1
  5. package/cjs/allocator/matrix-allocate.js +1 -1
  6. package/cjs/animate/custom-animate.js +2 -1
  7. package/cjs/animate/index.js +1 -2
  8. package/cjs/color-string/store.js +2 -1
  9. package/cjs/common/custom-path2d.js +8 -6
  10. package/cjs/common/custom-path2d.js.map +1 -1
  11. package/cjs/common/enums.js +1 -2
  12. package/cjs/common/render-area.js +1 -0
  13. package/cjs/common/store.js +1 -1
  14. package/cjs/common/text.js +1 -2
  15. package/cjs/common/utils.js +1 -1
  16. package/cjs/core/application.js +1 -1
  17. package/cjs/core/camera.js +1 -1
  18. package/cjs/graphic/config.js +2 -1
  19. package/cjs/graphic/config.js.map +1 -1
  20. package/cjs/graphic/graphic.d.ts +1 -1
  21. package/cjs/graphic/graphic.js +7 -7
  22. package/cjs/graphic/graphic.js.map +1 -1
  23. package/cjs/graphic/group.d.ts +1 -0
  24. package/cjs/graphic/group.js +5 -0
  25. package/cjs/graphic/group.js.map +1 -1
  26. package/cjs/graphic/richtext/line.js +11 -1
  27. package/cjs/graphic/richtext/line.js.map +1 -1
  28. package/cjs/graphic/richtext/paragraph.d.ts +8 -1
  29. package/cjs/graphic/richtext/paragraph.js +5 -16
  30. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  31. package/cjs/graphic/richtext.js +11 -7
  32. package/cjs/graphic/richtext.js.map +1 -1
  33. package/cjs/graphic/symbol.d.ts +1 -0
  34. package/cjs/graphic/symbol.js +11 -0
  35. package/cjs/graphic/symbol.js.map +1 -1
  36. package/cjs/interface/graphic/arc.js.map +1 -1
  37. package/cjs/interface/graphic/area.js.map +1 -1
  38. package/cjs/interface/graphic/circle.js.map +1 -1
  39. package/cjs/interface/graphic/group.js.map +1 -1
  40. package/cjs/interface/graphic/image.js.map +1 -1
  41. package/cjs/interface/graphic/line.js.map +1 -1
  42. package/cjs/interface/graphic/polygon.js.map +1 -1
  43. package/cjs/interface/graphic/rect.js.map +1 -1
  44. package/cjs/interface/graphic/richText.d.ts +4 -0
  45. package/cjs/interface/graphic/richText.js.map +1 -1
  46. package/cjs/interface/graphic/symbol.d.ts +1 -0
  47. package/cjs/interface/graphic/symbol.js.map +1 -1
  48. package/cjs/interface/graphic/text.js.map +1 -1
  49. package/cjs/plugins/builtin-plugin/edit-module.js +3 -2
  50. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  51. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +6 -3
  52. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +49 -31
  53. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  54. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.d.ts +2 -1
  55. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +20 -3
  56. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  57. package/dist/index.es.js +208 -85
  58. package/es/allocator/bounds-allocate.js +1 -1
  59. package/es/allocator/canvas-allocate.js +1 -1
  60. package/es/allocator/constants.js +1 -1
  61. package/es/allocator/graphic-allocate.js +1 -1
  62. package/es/allocator/matrix-allocate.js +1 -1
  63. package/es/animate/custom-animate.js +2 -1
  64. package/es/animate/index.js +1 -2
  65. package/es/color-string/store.js +2 -1
  66. package/es/common/custom-path2d.js +8 -6
  67. package/es/common/custom-path2d.js.map +1 -1
  68. package/es/common/enums.js +1 -2
  69. package/es/common/render-area.js +2 -1
  70. package/es/common/store.js +1 -1
  71. package/es/common/text.js +1 -2
  72. package/es/common/utils.js +1 -1
  73. package/es/core/application.js +1 -1
  74. package/es/core/camera.js +1 -1
  75. package/es/graphic/config.js +2 -1
  76. package/es/graphic/config.js.map +1 -1
  77. package/es/graphic/graphic.d.ts +1 -1
  78. package/es/graphic/graphic.js +9 -9
  79. package/es/graphic/graphic.js.map +1 -1
  80. package/es/graphic/group.d.ts +1 -0
  81. package/es/graphic/group.js +5 -0
  82. package/es/graphic/group.js.map +1 -1
  83. package/es/graphic/richtext/line.js +11 -1
  84. package/es/graphic/richtext/line.js.map +1 -1
  85. package/es/graphic/richtext/paragraph.d.ts +8 -1
  86. package/es/graphic/richtext/paragraph.js +5 -16
  87. package/es/graphic/richtext/paragraph.js.map +1 -1
  88. package/es/graphic/richtext.js +11 -7
  89. package/es/graphic/richtext.js.map +1 -1
  90. package/es/graphic/symbol.d.ts +1 -0
  91. package/es/graphic/symbol.js +11 -0
  92. package/es/graphic/symbol.js.map +1 -1
  93. package/es/interface/graphic/arc.js.map +1 -1
  94. package/es/interface/graphic/area.js.map +1 -1
  95. package/es/interface/graphic/circle.js.map +1 -1
  96. package/es/interface/graphic/group.js.map +1 -1
  97. package/es/interface/graphic/image.js.map +1 -1
  98. package/es/interface/graphic/line.js.map +1 -1
  99. package/es/interface/graphic/polygon.js.map +1 -1
  100. package/es/interface/graphic/rect.js.map +1 -1
  101. package/es/interface/graphic/richText.d.ts +4 -0
  102. package/es/interface/graphic/richText.js.map +1 -1
  103. package/es/interface/graphic/symbol.d.ts +1 -0
  104. package/es/interface/graphic/symbol.js.map +1 -1
  105. package/es/interface/graphic/text.js.map +1 -1
  106. package/es/plugins/builtin-plugin/edit-module.js +3 -2
  107. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  108. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +6 -3
  109. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +49 -31
  110. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  111. package/es/render/contributions/render/contributions/base-texture-contribution-render.d.ts +2 -1
  112. package/es/render/contributions/render/contributions/base-texture-contribution-render.js +22 -2
  113. package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  114. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -2963,24 +2963,40 @@ class CustomPath2D extends CurvePath {
2963
2963
  case 's':
2964
2964
  tempX = x + current[3];
2965
2965
  tempY = y + current[4];
2966
- controlX = 2 * x - controlX;
2967
- controlY = 2 * y - controlY;
2968
- this.bezierCurveTo(controlX + l, controlY + t, x + current[1] + l, y + current[2] + t, tempX + l, tempY + t);
2969
- controlX = x + current[1];
2970
- controlY = y + current[2];
2966
+ if (previous[0].match(/[CcSs]/) === null) {
2967
+ controlX = x;
2968
+ controlY = y;
2969
+ }
2970
+ else {
2971
+ controlX = 2 * x - controlX;
2972
+ controlY = 2 * y - controlY;
2973
+ }
2974
+ tempControlX = x + current[1];
2975
+ tempControlY = y + current[2];
2976
+ this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t);
2977
+ controlX = tempControlX;
2978
+ controlY = tempControlY;
2971
2979
  x = tempX;
2972
2980
  y = tempY;
2973
2981
  break;
2974
2982
  case 'S':
2975
2983
  tempX = current[3];
2976
2984
  tempY = current[4];
2977
- controlX = 2 * x - controlX;
2978
- controlY = 2 * y - controlY;
2979
- this.bezierCurveTo(controlX + l, controlY + t, current[1] + l, current[2] + t, tempX + l, tempY + t);
2985
+ if (previous[0].match(/[CcSs]/) === null) {
2986
+ controlX = x;
2987
+ controlY = y;
2988
+ }
2989
+ else {
2990
+ controlX = 2 * x - controlX;
2991
+ controlY = 2 * y - controlY;
2992
+ }
2993
+ tempControlX = current[1];
2994
+ tempControlY = current[2];
2995
+ this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t);
2996
+ controlX = tempControlX;
2997
+ controlY = tempControlY;
2980
2998
  x = tempX;
2981
2999
  y = tempY;
2982
- controlX = current[1];
2983
- controlY = current[2];
2984
3000
  break;
2985
3001
  case 'q':
2986
3002
  tempX = x + current[3];
@@ -3288,7 +3304,7 @@ const DefaultTextStyle = {
3288
3304
  const DefaultPickStyle = {
3289
3305
  pickStrokeBuffer: 0
3290
3306
  };
3291
- const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({ forceBoundsWidth: undefined, forceBoundsHeight: undefined, opacity: 1, background: null, autoAnimateTexture: false, textureRatio: 0, textureOptions: null, backgroundOpacity: 1, backgroundCornerRadius: 0, texture: null, textureColor: 'black', textureSize: 10, texturePadding: 2, backgroundMode: 'no-repeat', backgroundFit: true, backgroundKeepAspectRatio: false, backgroundClip: true, backgroundScale: 1, backgroundOffsetX: 0, backgroundOffsetY: 0, blur: 0, filter: '', cursor: null, html: null, react: null }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
3307
+ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({ forceBoundsWidth: undefined, forceBoundsHeight: undefined, opacity: 1, background: null, autoAnimateTexture: false, textureRatio: 1, textureOptions: null, backgroundOpacity: 1, backgroundCornerRadius: 0, texture: null, textureColor: 'black', textureSize: 10, texturePadding: 2, backgroundMode: 'no-repeat', backgroundFit: true, backgroundKeepAspectRatio: false, backgroundClip: true, backgroundScale: 1, backgroundOffsetX: 0, backgroundOffsetY: 0, blur: 0, filter: '', cursor: null, html: null, react: null }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
3292
3308
  const DefaultConnectAttribute = {
3293
3309
  connectedType: 'none',
3294
3310
  connectedStyle: {},
@@ -3321,7 +3337,7 @@ const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute),
3321
3337
  const DefaultRect3dAttribute = Object.assign(Object.assign({}, DefaultAttribute), { width: 0, height: 0, x1: 0, y1: 0, cornerRadius: 0, length: 0, cornerType: 'round' });
3322
3338
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), { symbolType: 'circle', size: 10, keepDirIn3d: true, clipRange: 1 });
3323
3339
  const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { strokeBoundsBuffer: 0, keepDirIn3d: true });
3324
- 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 });
3340
+ const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), { upgradeAttrs: null, 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 });
3325
3341
  const DefaultImageAttribute = Object.assign(Object.assign({ repeatX: 'no-repeat', repeatY: 'no-repeat', image: '', width: 0, height: 0 }, DefaultAttribute), { fill: true, cornerRadius: 0, cornerType: 'round' });
3326
3342
  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 });
3327
3343
 
@@ -12412,6 +12428,7 @@ class Graphic extends Node {
12412
12428
  }
12413
12429
  this.animates.set(animate.id, animate);
12414
12430
  animate.onRemove(() => {
12431
+ animate.stop();
12415
12432
  this.animates.delete(animate.id);
12416
12433
  });
12417
12434
  return animate;
@@ -12533,10 +12550,12 @@ class Graphic extends Node {
12533
12550
  this.normalAttrs = null;
12534
12551
  }
12535
12552
  removeState(stateName, hasAnimation) {
12536
- const index = this.currentStates ? this.currentStates.indexOf(stateName) : -1;
12537
- if (index >= 0) {
12538
- const currentStates = this.currentStates.filter(state => state !== stateName);
12539
- this.useStates(currentStates, hasAnimation);
12553
+ if (this.currentStates) {
12554
+ const filter = isArray(stateName) ? (s) => !stateName.includes(s) : (s) => s !== stateName;
12555
+ const newStates = this.currentStates.filter(filter);
12556
+ if (newStates.length !== this.currentStates.length) {
12557
+ this.useStates(newStates, hasAnimation);
12558
+ }
12540
12559
  }
12541
12560
  }
12542
12561
  toggleState(stateName, hasAnimation) {
@@ -12712,7 +12731,9 @@ class Graphic extends Node {
12712
12731
  if (this.animates && this.animates.size) {
12713
12732
  const timeline = stage.getTimeline();
12714
12733
  this.animates.forEach(a => {
12715
- a.setTimeline(timeline);
12734
+ if (a.timeline === defaultTimeline) {
12735
+ a.setTimeline(timeline);
12736
+ }
12716
12737
  });
12717
12738
  }
12718
12739
  this._onSetStage && this._onSetStage(this, stage, layer);
@@ -12886,6 +12907,7 @@ class Graphic extends Node {
12886
12907
  detachShadow() {
12887
12908
  if (this.shadowRoot) {
12888
12909
  this.addUpdateBoundTag();
12910
+ this.shadowRoot.release(true);
12889
12911
  this.shadowRoot = null;
12890
12912
  }
12891
12913
  }
@@ -12993,6 +13015,7 @@ class Graphic extends Node {
12993
13015
  }
12994
13016
  release() {
12995
13017
  this.releaseStatus = 'released';
13018
+ this.stopAnimates();
12996
13019
  application.graphicService.onRelease(this);
12997
13020
  }
12998
13021
  _emitCustomEvent(type, context) {
@@ -13807,6 +13830,14 @@ class Group extends Graphic {
13807
13830
  getNoWorkAnimateAttr() {
13808
13831
  return Group.NOWORK_ANIMATE_ATTR;
13809
13832
  }
13833
+ release(all) {
13834
+ if (all) {
13835
+ this.forEachChildren((g) => {
13836
+ g.release(all);
13837
+ });
13838
+ }
13839
+ super.release();
13840
+ }
13810
13841
  }
13811
13842
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
13812
13843
  function createGroup(attributes) {
@@ -17045,6 +17076,20 @@ let Symbol$1 = class Symbol extends Graphic {
17045
17076
  }
17046
17077
  return this._parsedPath;
17047
17078
  }
17079
+ getParsedPath2D(x = 0, y = 0, size = 1) {
17080
+ let path = null;
17081
+ try {
17082
+ path = new Path2D();
17083
+ }
17084
+ catch (err) {
17085
+ return null;
17086
+ }
17087
+ const parsedPath = this.getParsedPath();
17088
+ if (!parsedPath) {
17089
+ return null;
17090
+ }
17091
+ parsedPath.draw(path, size, x, y);
17092
+ }
17048
17093
  isValid() {
17049
17094
  return super.isValid() && this._isValid();
17050
17095
  }
@@ -17950,7 +17995,10 @@ class Paragraph {
17950
17995
  }
17951
17996
  }
17952
17997
  drawBackground(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
17953
- if (!(this.character.background && (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0))) {
17998
+ if (!(this.text !== '' &&
17999
+ this.text !== '\n' &&
18000
+ this.character.background &&
18001
+ (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0))) {
17954
18002
  return;
17955
18003
  }
17956
18004
  let baseline = top + ascent;
@@ -17984,34 +18032,10 @@ class Paragraph {
17984
18032
  }
17985
18033
  }
17986
18034
  }
17987
- switch (this.character.script) {
17988
- case 'super':
17989
- baseline -= this.ascent * (1 / 3);
17990
- break;
17991
- case 'sub':
17992
- baseline += this.descent / 2;
17993
- break;
17994
- }
17995
- if (direction === 'vertical') {
17996
- ctx.save();
17997
- ctx.rotateAbout(Math.PI / 2, left, baseline);
17998
- ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2);
17999
- ctx.translate(left, baseline);
18000
- left = 0;
18001
- baseline = 0;
18002
- }
18003
- const fillStyle = ctx.fillStyle;
18004
- const globalAlpha = ctx.globalAlpha;
18005
- ctx.fillStyle = this.character.background;
18006
- if (this.character.backgroundOpacity !== void 0) {
18007
- ctx.globalAlpha = this.character.backgroundOpacity;
18008
- }
18009
18035
  const right = left + (this.widthOrigin || this.width);
18010
18036
  const bottom = top + lineHeight;
18011
18037
  const lrtb = getFixedLRTB(left, right, top, bottom);
18012
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);
18013
- ctx.fillStyle = fillStyle;
18014
- ctx.globalAlpha = globalAlpha;
18038
+ return Object.assign(Object.assign({}, lrtb), { fillStyle: this.character.background, globalAlpha: this.character.backgroundOpacity });
18015
18039
  }
18016
18040
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
18017
18041
  let baseline = top + ascent;
@@ -18436,11 +18460,35 @@ class Line {
18436
18460
  }
18437
18461
  }
18438
18462
  }
18463
+ let fillStyle = '';
18464
+ let globalAlpha = -1;
18465
+ let currBgList = [];
18466
+ const bgList = [currBgList];
18439
18467
  this.paragraphs.forEach((paragraph, index) => {
18440
18468
  if (paragraph instanceof RichTextIcon) {
18441
18469
  return;
18442
18470
  }
18443
- paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
18471
+ const data = paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
18472
+ if (!data) {
18473
+ return;
18474
+ }
18475
+ if (!(fillStyle === data.fillStyle && globalAlpha === data.globalAlpha)) {
18476
+ currBgList = [];
18477
+ bgList.push(currBgList);
18478
+ fillStyle = data.fillStyle;
18479
+ globalAlpha = data.globalAlpha;
18480
+ }
18481
+ currBgList.push(data);
18482
+ });
18483
+ bgList.forEach(bg => {
18484
+ if (bg.length === 0) {
18485
+ return;
18486
+ }
18487
+ const data = bg[0];
18488
+ const end = bg[bg.length - 1];
18489
+ ctx.fillStyle = data.fillStyle;
18490
+ ctx.globalAlpha = data.globalAlpha;
18491
+ ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
18444
18492
  });
18445
18493
  this.paragraphs.forEach((paragraph, index) => {
18446
18494
  if (paragraph instanceof RichTextIcon) {
@@ -18872,6 +18920,9 @@ class RichText extends Graphic {
18872
18920
  application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds);
18873
18921
  }
18874
18922
  application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, false, this);
18923
+ if (aabbBounds.width() === 0 && aabbBounds.height() === 0) {
18924
+ aabbBounds.clear();
18925
+ }
18875
18926
  return aabbBounds;
18876
18927
  }
18877
18928
  needUpdateTags(keys) {
@@ -18907,8 +18958,8 @@ class RichText extends Graphic {
18907
18958
  return false;
18908
18959
  }
18909
18960
  combinedStyleToCharacter(config) {
18910
- const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, strokeOpacity } = this.attribute;
18911
- return Object.assign({ fill,
18961
+ const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, lineHeight, strokeOpacity, upgradeAttrs } = this.attribute;
18962
+ const out = Object.assign({ fill,
18912
18963
  stroke,
18913
18964
  fontSize,
18914
18965
  fontFamily,
@@ -18918,10 +18969,15 @@ class RichText extends Graphic {
18918
18969
  opacity,
18919
18970
  fillOpacity,
18920
18971
  strokeOpacity }, config);
18972
+ if (upgradeAttrs === null || upgradeAttrs === void 0 ? void 0 : upgradeAttrs.lineHeight) {
18973
+ out.lineHeight = lineHeight;
18974
+ }
18975
+ return out;
18921
18976
  }
18922
18977
  doUpdateFrameCache(tc) {
18923
18978
  var _a;
18924
- const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode } = this.attribute;
18979
+ const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode, upgradeAttrs } = this.attribute;
18980
+ const enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;
18925
18981
  let { textConfig: _tc = [] } = this.attribute;
18926
18982
  if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {
18927
18983
  _tc = RichText.TransformTextConfig2SingleCharacter(_tc);
@@ -18956,7 +19012,16 @@ class RichText extends Graphic {
18956
19012
  if (richTextConfig.text && richTextConfig.text.includes('\n')) {
18957
19013
  const textParts = richTextConfig.text.split('\n');
18958
19014
  for (let j = 0; j < textParts.length; j++) {
18959
- paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
19015
+ if (j === 0) {
19016
+ paragraphs.push(new Paragraph(textParts[j], false, richTextConfig, ascentDescentMode));
19017
+ }
19018
+ else if (textParts[j] || i === textConfig.length - 1) {
19019
+ paragraphs.push(new Paragraph(textParts[j], true, richTextConfig, ascentDescentMode));
19020
+ }
19021
+ else {
19022
+ const nextRichTextConfig = this.combinedStyleToCharacter(textConfig[i + 1]);
19023
+ paragraphs.push(new Paragraph(textParts[j], true, nextRichTextConfig, ascentDescentMode));
19024
+ }
18960
19025
  }
18961
19026
  }
18962
19027
  else if (richTextConfig.text) {
@@ -18978,7 +19043,7 @@ class RichText extends Graphic {
18978
19043
  const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;
18979
19044
  const frame = new Frame(0, 0, frameWidth || 0, frameHeight || 0, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection || 'horizontal', !richTextWidthEnable && maxWidthFinite, !richTextHeightEnable && maxHeightFinite, singleLine || false, (_a = this._frameCache) === null || _a === void 0 ? void 0 : _a.icons);
18980
19045
  const wrapper = new Wrapper(frame);
18981
- wrapper.newLine = editable;
19046
+ wrapper.newLine = enableMultiBreakLine;
18982
19047
  if (disableAutoWrapLine) {
18983
19048
  let lineCount = 0;
18984
19049
  let skip = false;
@@ -19026,7 +19091,7 @@ class RichText extends Graphic {
19026
19091
  l.calcOffset(offsetSize, false);
19027
19092
  });
19028
19093
  }
19029
- if (editable) {
19094
+ if (enableMultiBreakLine) {
19030
19095
  frame.lines.forEach(item => {
19031
19096
  const lastParagraphs = item.paragraphs;
19032
19097
  item.paragraphs = item.paragraphs.filter(p => p.text !== '');
@@ -20292,6 +20357,7 @@ class DefaultBaseTextureRenderContribution {
20292
20357
  this.time = BaseRenderContributionTime.afterFillStroke;
20293
20358
  this.useStyle = true;
20294
20359
  this.order = 10;
20360
+ this._tempSymbolGraphic = null;
20295
20361
  }
20296
20362
  createCommonPattern(size, padding, color, targetContext, cb) {
20297
20363
  const r = (size - padding * 2) / 2;
@@ -20438,7 +20504,45 @@ class DefaultBaseTextureRenderContribution {
20438
20504
  break;
20439
20505
  }
20440
20506
  }
20441
- if (pattern) {
20507
+ if (textureOptions && textureOptions.dynamicTexture) {
20508
+ context.save();
20509
+ context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);
20510
+ context.clip();
20511
+ const { gridConfig = {} } = textureOptions;
20512
+ const b = graphic.AABBBounds;
20513
+ const width = b.width();
20514
+ const height = b.height();
20515
+ const padding = texturePadding;
20516
+ const cellSize = textureSize;
20517
+ const gridColumns = gridConfig.columns ? gridConfig.columns : Math.ceil(width / cellSize);
20518
+ const gridRows = gridConfig.rows ? gridConfig.rows : Math.ceil(height / cellSize);
20519
+ const gutterColumn = gridConfig.gutterColumn ? gridConfig.gutterColumn : padding * 2;
20520
+ const gutterRow = gridConfig.gutterRow ? gridConfig.gutterRow : padding * 2;
20521
+ if (!this._tempSymbolGraphic) {
20522
+ this._tempSymbolGraphic = createSymbol({});
20523
+ }
20524
+ const sizeW = gridConfig.columns ? width / gridConfig.columns : cellSize;
20525
+ const sizeH = gridConfig.rows ? height / gridConfig.rows : cellSize;
20526
+ this._tempSymbolGraphic.setAttributes({
20527
+ size: [sizeW - gutterColumn, sizeH - gutterRow],
20528
+ symbolType: texture
20529
+ });
20530
+ const parsedPath = this._tempSymbolGraphic.getParsedPath();
20531
+ for (let i = 0; i < gridRows; i++) {
20532
+ for (let j = 0; j < gridColumns; j++) {
20533
+ const _x = x + cellSize / 2 + j * cellSize;
20534
+ const _y = y + cellSize / 2 + i * cellSize;
20535
+ context.beginPath();
20536
+ if (parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) === false) {
20537
+ context.closePath();
20538
+ }
20539
+ context.fillStyle = textureColor;
20540
+ textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic);
20541
+ }
20542
+ }
20543
+ context.restore();
20544
+ }
20545
+ else if (pattern) {
20442
20546
  context.highPerformanceSave();
20443
20547
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);
20444
20548
  context.fillStyle = pattern;
@@ -26855,7 +26959,7 @@ function flatten_simplify(points, tolerance, highestQuality) {
26855
26959
  }
26856
26960
 
26857
26961
  function getDefaultCharacterConfig(attribute) {
26858
- const { fill = 'black', stroke = false, fontWeight = 'normal', fontFamily = 'Arial' } = attribute;
26962
+ const { fill = 'black', stroke = false, fontWeight = 'normal', lineHeight, fontFamily = 'Arial' } = attribute;
26859
26963
  let { fontSize = 12 } = attribute;
26860
26964
  if (!isFinite(fontSize)) {
26861
26965
  fontSize = 12;
@@ -26865,7 +26969,8 @@ function getDefaultCharacterConfig(attribute) {
26865
26969
  stroke,
26866
26970
  fontSize,
26867
26971
  fontWeight,
26868
- fontFamily
26972
+ fontFamily,
26973
+ lineHeight
26869
26974
  };
26870
26975
  }
26871
26976
  function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
@@ -27277,28 +27382,31 @@ class RichTextEditPlugin {
27277
27382
  throw new Error('不会走到这里 handleFocusOut');
27278
27383
  };
27279
27384
  this.handleMove = (e) => {
27280
- if (!this.isRichtext(e)) {
27385
+ if (this.currRt && !this.currRt.attribute.editable) {
27386
+ this.deFocus(true);
27387
+ }
27388
+ if (!this.isEditableRichtext(e)) {
27389
+ this.handleLeave();
27281
27390
  return;
27282
27391
  }
27283
- this.currRt = e.target;
27284
- this.handleEnter(e);
27392
+ this.handleEnter();
27285
27393
  e.target.once('pointerleave', this.handleLeave, { capture: true });
27286
27394
  this.tryShowSelection(e, false);
27287
27395
  };
27288
- this.handleEnter = (e) => {
27396
+ this.handleEnter = () => {
27289
27397
  this.editing = true;
27290
27398
  this.pluginService.stage.setCursor('text');
27291
27399
  };
27292
- this.handleLeave = (e) => {
27400
+ this.handleLeave = () => {
27293
27401
  this.editing = false;
27294
27402
  this.pluginService.stage.setCursor('default');
27295
27403
  };
27296
27404
  this.handlePointerDown = (e) => {
27297
- if (this.editing) {
27298
- this.onFocus(e);
27405
+ if (!this.editing || !this.isEditableRichtext(e)) {
27406
+ this.deFocus(true);
27299
27407
  }
27300
27408
  else {
27301
- this.deFocus(true);
27409
+ this.onFocus(e);
27302
27410
  }
27303
27411
  this.triggerRender();
27304
27412
  this.pointerDown = true;
@@ -27500,6 +27608,7 @@ class RichTextEditPlugin {
27500
27608
  else if (this.curCursorIdx > totalCursorCount + 0.1) {
27501
27609
  this.curCursorIdx = totalCursorCount + 0.1;
27502
27610
  }
27611
+ this.selectionStartCursorIdx = this.curCursorIdx;
27503
27612
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
27504
27613
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt);
27505
27614
  this.hideSelection();
@@ -27600,7 +27709,7 @@ class RichTextEditPlugin {
27600
27709
  zIndex: -1
27601
27710
  });
27602
27711
  const shadow = this.getShadow(this.currRt);
27603
- shadow.add(this.shadowBounds);
27712
+ this.addEditLineOrBgOrBounds(this.shadowBounds, shadow);
27604
27713
  this.offsetLineBgAndShadowBounds();
27605
27714
  this.offsetShadowRoot();
27606
27715
  }
@@ -27633,10 +27742,27 @@ class RichTextEditPlugin {
27633
27742
  stopPropagation(e) {
27634
27743
  e.stopPropagation();
27635
27744
  }
27745
+ addEditLineOrBgOrBounds(graphic, shadowRoot) {
27746
+ let group = shadowRoot.getElementById('emptyBoundsContainer');
27747
+ if (!group) {
27748
+ group = createGroup({ x: 0, y: 0, width: 0, height: 0, boundsMode: 'empty' });
27749
+ group.id = 'emptyBoundsContainer';
27750
+ shadowRoot.add(group);
27751
+ }
27752
+ group.add(graphic);
27753
+ }
27754
+ removeEditLineOrBgOrBounds(graphic, shadowRoot) {
27755
+ const group = shadowRoot.getElementById('emptyBoundsContainer');
27756
+ if (!group) {
27757
+ return;
27758
+ }
27759
+ group.removeChild(graphic);
27760
+ }
27636
27761
  onFocus(e, data) {
27637
27762
  this.updateCbs && this.updateCbs.forEach(cb => cb('beforeOnfocus', this));
27638
27763
  this.deFocus(false);
27639
27764
  this.focusing = true;
27765
+ this.editing = true;
27640
27766
  const target = e.target;
27641
27767
  if (!(target && target.type === 'richtext')) {
27642
27768
  return;
@@ -27660,8 +27786,8 @@ class RichTextEditPlugin {
27660
27786
  this.ticker.start(true);
27661
27787
  const g = createGroup({ x: 0, y: 0, width: 0, height: 0 });
27662
27788
  this.editBg = g;
27663
- shadowRoot.add(this.editLine);
27664
- shadowRoot.add(this.editBg);
27789
+ this.addEditLineOrBgOrBounds(this.editLine, shadowRoot);
27790
+ this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
27665
27791
  }
27666
27792
  data = data || this.computedCursorPosByEvent(e, cache);
27667
27793
  if (data) {
@@ -27726,32 +27852,33 @@ class RichTextEditPlugin {
27726
27852
  }
27727
27853
  }
27728
27854
  deFocus(trulyDeFocus = false) {
27855
+ this.editing = false;
27729
27856
  this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
27730
- const target = this.currRt;
27731
- if (!target) {
27857
+ const currRt = this.currRt;
27858
+ if (!currRt) {
27732
27859
  return;
27733
27860
  }
27734
- const { editOptions = {} } = target.attribute;
27861
+ const { editOptions = {} } = currRt.attribute;
27735
27862
  if (editOptions.stopPropagation) {
27736
- target.removeEventListener('*', this.stopPropagation);
27863
+ currRt.removeEventListener('*', this.stopPropagation);
27737
27864
  }
27738
27865
  if (trulyDeFocus) {
27739
27866
  this.trySyncPlaceholderToTextConfig();
27740
- target.detachShadow();
27867
+ currRt.detachShadow();
27741
27868
  }
27742
- const currRt = this.currRt;
27743
27869
  this.currRt = null;
27870
+ const shadowRoot = this.getShadow(currRt);
27744
27871
  if (this.editLine) {
27745
- this.editLine.parent && this.editLine.parent.removeChild(this.editLine);
27872
+ this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot);
27746
27873
  this.editLine.release();
27747
27874
  this.editLine = null;
27748
- this.editBg.parent && this.editBg.parent.removeChild(this.editBg);
27875
+ this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot);
27749
27876
  this.editBg.release();
27750
27877
  this.editBg = null;
27751
27878
  }
27752
27879
  if (trulyDeFocus) {
27753
27880
  if (this.shadowBounds) {
27754
- this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds);
27881
+ this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot);
27755
27882
  this.shadowBounds.release();
27756
27883
  this.shadowBounds = null;
27757
27884
  }
@@ -27762,17 +27889,10 @@ class RichTextEditPlugin {
27762
27889
  }
27763
27890
  }
27764
27891
  this.focusing = false;
27765
- const textConfig = currRt.attribute.textConfig;
27766
- let lastConfig = textConfig[textConfig.length - 1];
27767
- let cleared = false;
27768
- while (lastConfig && lastConfig.text === '\n') {
27769
- textConfig.pop();
27770
- lastConfig = textConfig[textConfig.length - 1];
27771
- cleared = true;
27772
- }
27773
- cleared && currRt.setAttributes({ textConfig });
27892
+ currRt.removeEventListener('pointerleave', this.handleLeave);
27774
27893
  }
27775
27894
  addAnimateToLine(line) {
27895
+ line.setAttributes({ opacity: 1 });
27776
27896
  line.animates &&
27777
27897
  line.animates.forEach(animate => {
27778
27898
  animate.stop();
@@ -27903,7 +28023,7 @@ class RichTextEditPlugin {
27903
28023
  }
27904
28024
  getShadow(rt) {
27905
28025
  const sr = rt.shadowRoot || rt.attachShadow();
27906
- sr.setAttributes({ boundsMode: 'empty' });
28026
+ sr.setAttributes({ width: 1, height: 1 });
27907
28027
  return sr;
27908
28028
  }
27909
28029
  getLineByPoint(cache, p1) {
@@ -27964,7 +28084,10 @@ class RichTextEditPlugin {
27964
28084
  return -1;
27965
28085
  }
27966
28086
  isRichtext(e) {
27967
- return !!(e.target && e.target.type === 'richtext' && e.target.attribute.editable);
28087
+ return !!(e.target && e.target.type === 'richtext');
28088
+ }
28089
+ isEditableRichtext(e) {
28090
+ return this.isRichtext(e) && !!e.target.attribute.editable;
27968
28091
  }
27969
28092
  triggerRender() {
27970
28093
  this.pluginService.stage.renderNextFrame();
@@ -28127,7 +28250,7 @@ class RichTextEditPlugin {
28127
28250
  }
28128
28251
  }
28129
28252
  _forceFocusByEvent(e) {
28130
- this.handleEnter(e);
28253
+ this.handleEnter();
28131
28254
  this.handlePointerDown(e);
28132
28255
  this.handlePointerUp(e);
28133
28256
  }
@@ -29,4 +29,4 @@ export class DefaultBoundsAllocate {
29
29
  }
30
30
 
31
31
  export const boundsAllocate = new DefaultBoundsAllocate;
32
- //# sourceMappingURL=bounds-allocate.js.map
32
+ //# sourceMappingURL=bounds-allocate.js.map
@@ -52,4 +52,4 @@ export class DefaultCanvasAllocate {
52
52
  }
53
53
 
54
54
  export const canvasAllocate = new DefaultCanvasAllocate;
55
- //# sourceMappingURL=canvas-allocate.js.map
55
+ //# sourceMappingURL=canvas-allocate.js.map
@@ -15,4 +15,4 @@ export const PathAllocate = Symbol.for("PathAllocate");
15
15
  export const SymbolAllocate = Symbol.for("SymbolAllocate");
16
16
 
17
17
  export const TextAllocate = Symbol.for("TextAllocate");
18
- //# sourceMappingURL=constants.js.map
18
+ //# sourceMappingURL=constants.js.map
@@ -152,4 +152,4 @@ export class DefaultGraphicMemoryManager {
152
152
  }
153
153
 
154
154
  export const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager;
155
- //# sourceMappingURL=graphic-allocate.js.map
155
+ //# sourceMappingURL=graphic-allocate.js.map
@@ -68,4 +68,4 @@ export class DefaultMat4Allocate {
68
68
  export const matrixAllocate = new DefaultMatrixAllocate;
69
69
 
70
70
  export const mat4Allocate = new DefaultMat4Allocate;
71
- //# sourceMappingURL=matrix-allocate.js.map
71
+ //# sourceMappingURL=matrix-allocate.js.map
@@ -696,4 +696,5 @@ export class AnimateGroup1 extends ACustomAnimate {
696
696
  ratio = easingFunc(ratio), a.onUpdate(end, ratio, out);
697
697
  })), this.updating = !1);
698
698
  }
699
- }
699
+ }
700
+ //# sourceMappingURL=custom-animate.js.map
@@ -12,5 +12,4 @@ export * from "./timeline";
12
12
 
13
13
  export * from "./group-fade";
14
14
 
15
- export * from "./easing";
16
- //# sourceMappingURL=index.js.map
15
+ export * from "./easing";
@@ -44,4 +44,5 @@ export class ColorStore {
44
44
  }
45
45
  }
46
46
 
47
- ColorStore.store255 = {}, ColorStore.store1 = {};
47
+ ColorStore.store255 = {}, ColorStore.store1 = {};
48
+ //# sourceMappingURL=store.js.map
@@ -204,15 +204,17 @@ export class CustomPath2D extends CurvePath {
204
204
  break;
205
205
 
206
206
  case "s":
207
- tempX = x + current[3], tempY = y + current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY,
208
- this.bezierCurveTo(controlX + l, controlY + t, x + current[1] + l, y + current[2] + t, tempX + l, tempY + t),
209
- controlX = x + current[1], controlY = y + current[2], x = tempX, y = tempY;
207
+ tempX = x + current[3], tempY = y + current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x,
208
+ controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = x + current[1],
209
+ tempControlY = y + current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t),
210
+ controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
210
211
  break;
211
212
 
212
213
  case "S":
213
- tempX = current[3], tempY = current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY,
214
- this.bezierCurveTo(controlX + l, controlY + t, current[1] + l, current[2] + t, tempX + l, tempY + t),
215
- x = tempX, y = tempY, controlX = current[1], controlY = current[2];
214
+ tempX = current[3], tempY = current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x,
215
+ controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = current[1],
216
+ tempControlY = current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t),
217
+ controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
216
218
  break;
217
219
 
218
220
  case "q":