@visactor/vrender-core 0.22.0-vstory.14 → 0.22.0-vstory.16

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 (48) hide show
  1. package/cjs/common/custom-path2d.js +8 -6
  2. package/cjs/common/custom-path2d.js.map +1 -1
  3. package/cjs/graphic/config.js +1 -0
  4. package/cjs/graphic/config.js.map +1 -1
  5. package/cjs/graphic/graphic.js +4 -4
  6. package/cjs/graphic/graphic.js.map +1 -1
  7. package/cjs/graphic/group.d.ts +1 -0
  8. package/cjs/graphic/group.js +5 -0
  9. package/cjs/graphic/group.js.map +1 -1
  10. package/cjs/graphic/richtext/line.js +11 -1
  11. package/cjs/graphic/richtext/line.js.map +1 -1
  12. package/cjs/graphic/richtext/paragraph.d.ts +8 -1
  13. package/cjs/graphic/richtext/paragraph.js +5 -16
  14. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  15. package/cjs/graphic/richtext.js +11 -7
  16. package/cjs/graphic/richtext.js.map +1 -1
  17. package/cjs/interface/graphic/richText.d.ts +4 -0
  18. package/cjs/interface/graphic/richText.js.map +1 -1
  19. package/cjs/plugins/builtin-plugin/edit-module.js +3 -2
  20. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  21. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +6 -3
  22. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +48 -24
  23. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  24. package/dist/index.es.js +147 -70
  25. package/es/common/custom-path2d.js +8 -6
  26. package/es/common/custom-path2d.js.map +1 -1
  27. package/es/graphic/config.js +1 -0
  28. package/es/graphic/config.js.map +1 -1
  29. package/es/graphic/graphic.js +5 -5
  30. package/es/graphic/graphic.js.map +1 -1
  31. package/es/graphic/group.d.ts +1 -0
  32. package/es/graphic/group.js +5 -0
  33. package/es/graphic/group.js.map +1 -1
  34. package/es/graphic/richtext/line.js +11 -1
  35. package/es/graphic/richtext/line.js.map +1 -1
  36. package/es/graphic/richtext/paragraph.d.ts +8 -1
  37. package/es/graphic/richtext/paragraph.js +5 -16
  38. package/es/graphic/richtext/paragraph.js.map +1 -1
  39. package/es/graphic/richtext.js +11 -7
  40. package/es/graphic/richtext.js.map +1 -1
  41. package/es/interface/graphic/richText.d.ts +4 -0
  42. package/es/interface/graphic/richText.js.map +1 -1
  43. package/es/plugins/builtin-plugin/edit-module.js +3 -2
  44. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  45. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +6 -3
  46. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +48 -24
  47. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  48. package/package.json +2 -2
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];
@@ -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;
@@ -12712,7 +12729,9 @@ class Graphic extends Node {
12712
12729
  if (this.animates && this.animates.size) {
12713
12730
  const timeline = stage.getTimeline();
12714
12731
  this.animates.forEach(a => {
12715
- a.setTimeline(timeline);
12732
+ if (a.timeline === defaultTimeline) {
12733
+ a.setTimeline(timeline);
12734
+ }
12716
12735
  });
12717
12736
  }
12718
12737
  this._onSetStage && this._onSetStage(this, stage, layer);
@@ -12886,6 +12905,7 @@ class Graphic extends Node {
12886
12905
  detachShadow() {
12887
12906
  if (this.shadowRoot) {
12888
12907
  this.addUpdateBoundTag();
12908
+ this.shadowRoot.release(true);
12889
12909
  this.shadowRoot = null;
12890
12910
  }
12891
12911
  }
@@ -12993,6 +13013,7 @@ class Graphic extends Node {
12993
13013
  }
12994
13014
  release() {
12995
13015
  this.releaseStatus = 'released';
13016
+ this.stopAnimates();
12996
13017
  application.graphicService.onRelease(this);
12997
13018
  }
12998
13019
  _emitCustomEvent(type, context) {
@@ -13807,6 +13828,14 @@ class Group extends Graphic {
13807
13828
  getNoWorkAnimateAttr() {
13808
13829
  return Group.NOWORK_ANIMATE_ATTR;
13809
13830
  }
13831
+ release(all) {
13832
+ if (all) {
13833
+ this.forEachChildren((g) => {
13834
+ g.release(all);
13835
+ });
13836
+ }
13837
+ super.release();
13838
+ }
13810
13839
  }
13811
13840
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
13812
13841
  function createGroup(attributes) {
@@ -17950,7 +17979,10 @@ class Paragraph {
17950
17979
  }
17951
17980
  }
17952
17981
  drawBackground(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
17953
- if (!(this.character.background && (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0))) {
17982
+ if (!(this.text !== '' &&
17983
+ this.text !== '\n' &&
17984
+ this.character.background &&
17985
+ (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0))) {
17954
17986
  return;
17955
17987
  }
17956
17988
  let baseline = top + ascent;
@@ -17984,34 +18016,10 @@ class Paragraph {
17984
18016
  }
17985
18017
  }
17986
18018
  }
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
18019
  const right = left + (this.widthOrigin || this.width);
18010
18020
  const bottom = top + lineHeight;
18011
18021
  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;
18022
+ return Object.assign(Object.assign({}, lrtb), { fillStyle: this.character.background, globalAlpha: this.character.backgroundOpacity });
18015
18023
  }
18016
18024
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
18017
18025
  let baseline = top + ascent;
@@ -18436,11 +18444,35 @@ class Line {
18436
18444
  }
18437
18445
  }
18438
18446
  }
18447
+ let fillStyle = '';
18448
+ let globalAlpha = -1;
18449
+ let currBgList = [];
18450
+ const bgList = [currBgList];
18439
18451
  this.paragraphs.forEach((paragraph, index) => {
18440
18452
  if (paragraph instanceof RichTextIcon) {
18441
18453
  return;
18442
18454
  }
18443
- paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
18455
+ const data = paragraph.drawBackground(ctx, y, this.ascent, x, index === 0, this.textAlign, this.height);
18456
+ if (!data) {
18457
+ return;
18458
+ }
18459
+ if (!(fillStyle === data.fillStyle && globalAlpha === data.globalAlpha)) {
18460
+ currBgList = [];
18461
+ bgList.push(currBgList);
18462
+ fillStyle = data.fillStyle;
18463
+ globalAlpha = data.globalAlpha;
18464
+ }
18465
+ currBgList.push(data);
18466
+ });
18467
+ bgList.forEach(bg => {
18468
+ if (bg.length === 0) {
18469
+ return;
18470
+ }
18471
+ const data = bg[0];
18472
+ const end = bg[bg.length - 1];
18473
+ ctx.fillStyle = data.fillStyle;
18474
+ ctx.globalAlpha = data.globalAlpha;
18475
+ ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
18444
18476
  });
18445
18477
  this.paragraphs.forEach((paragraph, index) => {
18446
18478
  if (paragraph instanceof RichTextIcon) {
@@ -18872,6 +18904,9 @@ class RichText extends Graphic {
18872
18904
  application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds);
18873
18905
  }
18874
18906
  application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, false, this);
18907
+ if (aabbBounds.width() === 0 && aabbBounds.height() === 0) {
18908
+ aabbBounds.clear();
18909
+ }
18875
18910
  return aabbBounds;
18876
18911
  }
18877
18912
  needUpdateTags(keys) {
@@ -18907,8 +18942,8 @@ class RichText extends Graphic {
18907
18942
  return false;
18908
18943
  }
18909
18944
  combinedStyleToCharacter(config) {
18910
- const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, strokeOpacity } = this.attribute;
18911
- return Object.assign({ fill,
18945
+ const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, lineHeight, strokeOpacity, upgradeAttrs } = this.attribute;
18946
+ const out = Object.assign({ fill,
18912
18947
  stroke,
18913
18948
  fontSize,
18914
18949
  fontFamily,
@@ -18918,10 +18953,15 @@ class RichText extends Graphic {
18918
18953
  opacity,
18919
18954
  fillOpacity,
18920
18955
  strokeOpacity }, config);
18956
+ if (upgradeAttrs === null || upgradeAttrs === void 0 ? void 0 : upgradeAttrs.lineHeight) {
18957
+ out.lineHeight = lineHeight;
18958
+ }
18959
+ return out;
18921
18960
  }
18922
18961
  doUpdateFrameCache(tc) {
18923
18962
  var _a;
18924
- const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode } = this.attribute;
18963
+ const { maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine, disableAutoWrapLine, editable, ascentDescentMode, upgradeAttrs } = this.attribute;
18964
+ const enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;
18925
18965
  let { textConfig: _tc = [] } = this.attribute;
18926
18966
  if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {
18927
18967
  _tc = RichText.TransformTextConfig2SingleCharacter(_tc);
@@ -18956,7 +18996,16 @@ class RichText extends Graphic {
18956
18996
  if (richTextConfig.text && richTextConfig.text.includes('\n')) {
18957
18997
  const textParts = richTextConfig.text.split('\n');
18958
18998
  for (let j = 0; j < textParts.length; j++) {
18959
- paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
18999
+ if (j === 0) {
19000
+ paragraphs.push(new Paragraph(textParts[j], false, richTextConfig, ascentDescentMode));
19001
+ }
19002
+ else if (textParts[j] || i === textConfig.length - 1) {
19003
+ paragraphs.push(new Paragraph(textParts[j], true, richTextConfig, ascentDescentMode));
19004
+ }
19005
+ else {
19006
+ const nextRichTextConfig = this.combinedStyleToCharacter(textConfig[i + 1]);
19007
+ paragraphs.push(new Paragraph(textParts[j], true, nextRichTextConfig, ascentDescentMode));
19008
+ }
18960
19009
  }
18961
19010
  }
18962
19011
  else if (richTextConfig.text) {
@@ -18978,7 +19027,7 @@ class RichText extends Graphic {
18978
19027
  const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;
18979
19028
  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
19029
  const wrapper = new Wrapper(frame);
18981
- wrapper.newLine = editable;
19030
+ wrapper.newLine = enableMultiBreakLine;
18982
19031
  if (disableAutoWrapLine) {
18983
19032
  let lineCount = 0;
18984
19033
  let skip = false;
@@ -19026,7 +19075,7 @@ class RichText extends Graphic {
19026
19075
  l.calcOffset(offsetSize, false);
19027
19076
  });
19028
19077
  }
19029
- if (editable) {
19078
+ if (enableMultiBreakLine) {
19030
19079
  frame.lines.forEach(item => {
19031
19080
  const lastParagraphs = item.paragraphs;
19032
19081
  item.paragraphs = item.paragraphs.filter(p => p.text !== '');
@@ -26855,7 +26904,7 @@ function flatten_simplify(points, tolerance, highestQuality) {
26855
26904
  }
26856
26905
 
26857
26906
  function getDefaultCharacterConfig(attribute) {
26858
- const { fill = 'black', stroke = false, fontWeight = 'normal', fontFamily = 'Arial' } = attribute;
26907
+ const { fill = 'black', stroke = false, fontWeight = 'normal', lineHeight, fontFamily = 'Arial' } = attribute;
26859
26908
  let { fontSize = 12 } = attribute;
26860
26909
  if (!isFinite(fontSize)) {
26861
26910
  fontSize = 12;
@@ -26865,7 +26914,8 @@ function getDefaultCharacterConfig(attribute) {
26865
26914
  stroke,
26866
26915
  fontSize,
26867
26916
  fontWeight,
26868
- fontFamily
26917
+ fontFamily,
26918
+ lineHeight
26869
26919
  };
26870
26920
  }
26871
26921
  function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
@@ -27277,28 +27327,31 @@ class RichTextEditPlugin {
27277
27327
  throw new Error('不会走到这里 handleFocusOut');
27278
27328
  };
27279
27329
  this.handleMove = (e) => {
27280
- if (!this.isRichtext(e)) {
27330
+ if (this.currRt && !this.currRt.attribute.editable) {
27331
+ this.deFocus(true);
27332
+ }
27333
+ if (!this.isEditableRichtext(e)) {
27334
+ this.handleLeave();
27281
27335
  return;
27282
27336
  }
27283
- this.currRt = e.target;
27284
- this.handleEnter(e);
27337
+ this.handleEnter();
27285
27338
  e.target.once('pointerleave', this.handleLeave, { capture: true });
27286
27339
  this.tryShowSelection(e, false);
27287
27340
  };
27288
- this.handleEnter = (e) => {
27341
+ this.handleEnter = () => {
27289
27342
  this.editing = true;
27290
27343
  this.pluginService.stage.setCursor('text');
27291
27344
  };
27292
- this.handleLeave = (e) => {
27345
+ this.handleLeave = () => {
27293
27346
  this.editing = false;
27294
27347
  this.pluginService.stage.setCursor('default');
27295
27348
  };
27296
27349
  this.handlePointerDown = (e) => {
27297
- if (this.editing) {
27298
- this.onFocus(e);
27350
+ if (!this.editing || !this.isEditableRichtext(e)) {
27351
+ this.deFocus(true);
27299
27352
  }
27300
27353
  else {
27301
- this.deFocus(true);
27354
+ this.onFocus(e);
27302
27355
  }
27303
27356
  this.triggerRender();
27304
27357
  this.pointerDown = true;
@@ -27500,6 +27553,7 @@ class RichTextEditPlugin {
27500
27553
  else if (this.curCursorIdx > totalCursorCount + 0.1) {
27501
27554
  this.curCursorIdx = totalCursorCount + 0.1;
27502
27555
  }
27556
+ this.selectionStartCursorIdx = this.curCursorIdx;
27503
27557
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
27504
27558
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt);
27505
27559
  this.hideSelection();
@@ -27600,7 +27654,7 @@ class RichTextEditPlugin {
27600
27654
  zIndex: -1
27601
27655
  });
27602
27656
  const shadow = this.getShadow(this.currRt);
27603
- shadow.add(this.shadowBounds);
27657
+ this.addEditLineOrBgOrBounds(this.shadowBounds, shadow);
27604
27658
  this.offsetLineBgAndShadowBounds();
27605
27659
  this.offsetShadowRoot();
27606
27660
  }
@@ -27633,10 +27687,27 @@ class RichTextEditPlugin {
27633
27687
  stopPropagation(e) {
27634
27688
  e.stopPropagation();
27635
27689
  }
27690
+ addEditLineOrBgOrBounds(graphic, shadowRoot) {
27691
+ let group = shadowRoot.getElementById('emptyBoundsContainer');
27692
+ if (!group) {
27693
+ group = createGroup({ x: 0, y: 0, width: 0, height: 0, boundsMode: 'empty' });
27694
+ group.id = 'emptyBoundsContainer';
27695
+ shadowRoot.add(group);
27696
+ }
27697
+ group.add(graphic);
27698
+ }
27699
+ removeEditLineOrBgOrBounds(graphic, shadowRoot) {
27700
+ const group = shadowRoot.getElementById('emptyBoundsContainer');
27701
+ if (!group) {
27702
+ return;
27703
+ }
27704
+ group.removeChild(graphic);
27705
+ }
27636
27706
  onFocus(e, data) {
27637
27707
  this.updateCbs && this.updateCbs.forEach(cb => cb('beforeOnfocus', this));
27638
27708
  this.deFocus(false);
27639
27709
  this.focusing = true;
27710
+ this.editing = true;
27640
27711
  const target = e.target;
27641
27712
  if (!(target && target.type === 'richtext')) {
27642
27713
  return;
@@ -27660,8 +27731,8 @@ class RichTextEditPlugin {
27660
27731
  this.ticker.start(true);
27661
27732
  const g = createGroup({ x: 0, y: 0, width: 0, height: 0 });
27662
27733
  this.editBg = g;
27663
- shadowRoot.add(this.editLine);
27664
- shadowRoot.add(this.editBg);
27734
+ this.addEditLineOrBgOrBounds(this.editLine, shadowRoot);
27735
+ this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
27665
27736
  }
27666
27737
  data = data || this.computedCursorPosByEvent(e, cache);
27667
27738
  if (data) {
@@ -27726,32 +27797,33 @@ class RichTextEditPlugin {
27726
27797
  }
27727
27798
  }
27728
27799
  deFocus(trulyDeFocus = false) {
27800
+ this.editing = false;
27729
27801
  this.updateCbs && this.updateCbs.forEach(cb => cb('beforeDefocus', this, { trulyDeFocus }));
27730
- const target = this.currRt;
27731
- if (!target) {
27802
+ const currRt = this.currRt;
27803
+ if (!currRt) {
27732
27804
  return;
27733
27805
  }
27734
- const { editOptions = {} } = target.attribute;
27806
+ const { editOptions = {} } = currRt.attribute;
27735
27807
  if (editOptions.stopPropagation) {
27736
- target.removeEventListener('*', this.stopPropagation);
27808
+ currRt.removeEventListener('*', this.stopPropagation);
27737
27809
  }
27738
27810
  if (trulyDeFocus) {
27739
27811
  this.trySyncPlaceholderToTextConfig();
27740
- target.detachShadow();
27812
+ currRt.detachShadow();
27741
27813
  }
27742
- const currRt = this.currRt;
27743
27814
  this.currRt = null;
27815
+ const shadowRoot = this.getShadow(currRt);
27744
27816
  if (this.editLine) {
27745
- this.editLine.parent && this.editLine.parent.removeChild(this.editLine);
27817
+ this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot);
27746
27818
  this.editLine.release();
27747
27819
  this.editLine = null;
27748
- this.editBg.parent && this.editBg.parent.removeChild(this.editBg);
27820
+ this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot);
27749
27821
  this.editBg.release();
27750
27822
  this.editBg = null;
27751
27823
  }
27752
27824
  if (trulyDeFocus) {
27753
27825
  if (this.shadowBounds) {
27754
- this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds);
27826
+ this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot);
27755
27827
  this.shadowBounds.release();
27756
27828
  this.shadowBounds = null;
27757
27829
  }
@@ -27771,8 +27843,10 @@ class RichTextEditPlugin {
27771
27843
  cleared = true;
27772
27844
  }
27773
27845
  cleared && currRt.setAttributes({ textConfig });
27846
+ currRt.removeEventListener('pointerleave', this.handleLeave);
27774
27847
  }
27775
27848
  addAnimateToLine(line) {
27849
+ line.setAttributes({ opacity: 1 });
27776
27850
  line.animates &&
27777
27851
  line.animates.forEach(animate => {
27778
27852
  animate.stop();
@@ -27903,7 +27977,7 @@ class RichTextEditPlugin {
27903
27977
  }
27904
27978
  getShadow(rt) {
27905
27979
  const sr = rt.shadowRoot || rt.attachShadow();
27906
- sr.setAttributes({ boundsMode: 'empty' });
27980
+ sr.setAttributes({ width: 1, height: 1 });
27907
27981
  return sr;
27908
27982
  }
27909
27983
  getLineByPoint(cache, p1) {
@@ -27964,7 +28038,10 @@ class RichTextEditPlugin {
27964
28038
  return -1;
27965
28039
  }
27966
28040
  isRichtext(e) {
27967
- return !!(e.target && e.target.type === 'richtext' && e.target.attribute.editable);
28041
+ return !!(e.target && e.target.type === 'richtext');
28042
+ }
28043
+ isEditableRichtext(e) {
28044
+ return this.isRichtext(e) && !!e.target.attribute.editable;
27968
28045
  }
27969
28046
  triggerRender() {
27970
28047
  this.pluginService.stage.renderNextFrame();
@@ -28127,7 +28204,7 @@ class RichTextEditPlugin {
28127
28204
  }
28128
28205
  }
28129
28206
  _forceFocusByEvent(e) {
28130
- this.handleEnter(e);
28207
+ this.handleEnter();
28131
28208
  this.handlePointerDown(e);
28132
28209
  this.handlePointerUp(e);
28133
28210
  }
@@ -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":