@visactor/vrender 0.22.0-vstory.6 → 0.22.0-vstory.8

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.
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import '@visactor/vrender-core';
2
- export declare const version = "0.22.0-vstory.6";
2
+ export declare const version = "0.22.0-vstory.8";
3
3
  export * from '@visactor/vrender-core';
4
4
  export * from '@visactor/vrender-kits';
package/cjs/index.js CHANGED
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", {
21
21
 
22
22
  const vrender_core_1 = require("@visactor/vrender-core"), vrender_kits_1 = require("@visactor/vrender-kits"), vrender_kits_2 = require("@visactor/vrender-kits");
23
23
 
24
- exports.version = "0.22.0-vstory.6", (0, vrender_core_1.preLoadAllModule)(), (0,
24
+ exports.version = "0.22.0-vstory.8", (0, vrender_core_1.preLoadAllModule)(), (0,
25
25
  vrender_core_1.isBrowserEnv)() ? (0, vrender_kits_1.loadBrowserEnv)(vrender_core_1.container) : (0,
26
26
  vrender_core_1.isNodeEnv)() && (0, vrender_kits_1.loadNodeEnv)(vrender_core_1.container),
27
27
  (0, vrender_kits_2.registerArc)(), (0, vrender_kits_2.registerArc3d)(), (0, vrender_kits_2.registerArea)(),
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAWgC;AAChC,yDAAqE;AACrE,yDAmBgC;AAEnB,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAI,IAAA,2BAAY,GAAE,EAAE;IAClB,IAAA,6BAAc,EAAC,wBAAS,CAAC,CAAC;CAC3B;KAAM,IAAI,IAAA,wBAAS,GAAE,EAAE;IACtB,IAAA,0BAAW,EAAC,wBAAS,CAAC,CAAC;CACxB;AACD,IAAA,0BAAW,GAAE,CAAC;AACd,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,8BAAe,GAAE,CAAC;AAClB,IAAA,gCAAiB,GAAE,CAAC;AACpB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,iCAAkB,GAAE,CAAC;AACrB,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,4CAA6B,GAAE,CAAC;AAChC,IAAA,0CAA2B,GAAE,CAAC;AAC9B,IAAA,2CAA4B,GAAE,CAAC;AAC/B,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,kCAAmB,GAAE,CAAC;AACtB,yDAAuC;AACvC,yDAAuC","file":"index.js","sourcesContent":["import '@visactor/vrender-core';\nimport {\n container,\n isBrowserEnv,\n isNodeEnv,\n preLoadAllModule,\n registerFlexLayoutPlugin,\n registerViewTransform3dPlugin,\n registerHtmlAttributePlugin,\n registerReactAttributePlugin,\n registerDirectionalLight,\n registerOrthoCamera\n} from '@visactor/vrender-core';\nimport { loadBrowserEnv, loadNodeEnv } from '@visactor/vrender-kits';\nimport {\n registerArc,\n registerArc3d,\n registerArea,\n registerCircle,\n registerGlyph,\n registerGroup,\n registerImage,\n registerLine,\n registerPath,\n registerPolygon,\n registerPyramid3d,\n registerRect,\n registerRect3d,\n registerRichtext,\n registerShadowRoot,\n registerSymbol,\n registerText,\n registerWrapText\n} from '@visactor/vrender-kits';\n// 导出版本号\nexport const version = \"0.22.0-vstory.6\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAWgC;AAChC,yDAAqE;AACrE,yDAmBgC;AAEnB,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAI,IAAA,2BAAY,GAAE,EAAE;IAClB,IAAA,6BAAc,EAAC,wBAAS,CAAC,CAAC;CAC3B;KAAM,IAAI,IAAA,wBAAS,GAAE,EAAE;IACtB,IAAA,0BAAW,EAAC,wBAAS,CAAC,CAAC;CACxB;AACD,IAAA,0BAAW,GAAE,CAAC;AACd,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,8BAAe,GAAE,CAAC;AAClB,IAAA,gCAAiB,GAAE,CAAC;AACpB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,iCAAkB,GAAE,CAAC;AACrB,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,4CAA6B,GAAE,CAAC;AAChC,IAAA,0CAA2B,GAAE,CAAC;AAC9B,IAAA,2CAA4B,GAAE,CAAC;AAC/B,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,kCAAmB,GAAE,CAAC;AACtB,yDAAuC;AACvC,yDAAuC","file":"index.js","sourcesContent":["import '@visactor/vrender-core';\nimport {\n container,\n isBrowserEnv,\n isNodeEnv,\n preLoadAllModule,\n registerFlexLayoutPlugin,\n registerViewTransform3dPlugin,\n registerHtmlAttributePlugin,\n registerReactAttributePlugin,\n registerDirectionalLight,\n registerOrthoCamera\n} from '@visactor/vrender-core';\nimport { loadBrowserEnv, loadNodeEnv } from '@visactor/vrender-kits';\nimport {\n registerArc,\n registerArc3d,\n registerArea,\n registerCircle,\n registerGlyph,\n registerGroup,\n registerImage,\n registerLine,\n registerPath,\n registerPolygon,\n registerPyramid3d,\n registerRect,\n registerRect3d,\n registerRichtext,\n registerShadowRoot,\n registerSymbol,\n registerText,\n registerWrapText\n} from '@visactor/vrender-kits';\n// 导出版本号\nexport const version = \"0.22.0-vstory.8\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
package/dist/index.es.js CHANGED
@@ -10912,7 +10912,7 @@ class Group extends Graphic {
10912
10912
  application.graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
10913
10913
  const selfChange = this.shouldSelfChangeUpdateAABBBounds(),
10914
10914
  bounds = this.doUpdateAABBBounds();
10915
- return this.addUpdateLayoutTag(), application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange), bounds;
10915
+ return this.addUpdateLayoutTag(), application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange), "empty" === this.attribute.boundsMode && bounds.clear(), bounds;
10916
10916
  }
10917
10917
  doUpdateLocalMatrix() {
10918
10918
  const {
@@ -13882,15 +13882,11 @@ class Frame {
13882
13882
  }
13883
13883
 
13884
13884
  function getFixedLRTB(left, right, top, bottom) {
13885
- const leftInt = Math.round(left),
13886
- topInt = Math.round(top),
13887
- rightInt = Math.round(right),
13888
- bottomInt = Math.round(bottom);
13889
13885
  return {
13890
- left: left > leftInt ? leftInt : leftInt - .5,
13891
- top: top > topInt ? topInt : topInt - .5,
13892
- right: rightInt > right ? rightInt : rightInt + .5,
13893
- bottom: bottomInt > bottom ? bottomInt : bottomInt + .5
13886
+ left: Math.round(left),
13887
+ top: Math.round(top),
13888
+ right: Math.round(right),
13889
+ bottom: Math.round(bottom)
13894
13890
  };
13895
13891
  }
13896
13892
  class Paragraph {
@@ -13934,19 +13930,11 @@ class Paragraph {
13934
13930
  }
13935
13931
  }
13936
13932
  }
13937
- switch (this.character.script) {
13938
- case "super":
13939
- baseline -= this.ascent * (1 / 3);
13940
- break;
13941
- case "sub":
13942
- baseline += this.descent / 2;
13943
- }
13944
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
13945
- const fillStyle = ctx.fillStyle,
13946
- globalAlpha = ctx.globalAlpha;
13947
- ctx.fillStyle = this.character.background, void 0 !== this.character.backgroundOpacity && (ctx.globalAlpha = this.character.backgroundOpacity);
13948
13933
  const lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + lineHeight);
13949
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top), ctx.fillStyle = fillStyle, ctx.globalAlpha = globalAlpha;
13934
+ return Object.assign(Object.assign({}, lrtb), {
13935
+ fillStyle: this.character.background,
13936
+ globalAlpha: this.character.backgroundOpacity
13937
+ });
13950
13938
  }
13951
13939
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
13952
13940
  let baseline = top + ascent,
@@ -14220,8 +14208,19 @@ class Line {
14220
14208
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
14221
14209
  }
14222
14210
  }
14211
+ let fillStyle = "",
14212
+ globalAlpha = -1,
14213
+ currBgList = [];
14214
+ const bgList = [currBgList];
14223
14215
  this.paragraphs.forEach((paragraph, index) => {
14224
- paragraph instanceof RichTextIcon || paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
14216
+ if (paragraph instanceof RichTextIcon) return;
14217
+ const data = paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
14218
+ data && (fillStyle === data.fillStyle && globalAlpha === data.globalAlpha || (currBgList = [], bgList.push(currBgList), fillStyle = data.fillStyle, globalAlpha = data.globalAlpha), currBgList.push(data));
14219
+ }), bgList.forEach(bg => {
14220
+ if (0 === bg.length) return;
14221
+ const data = bg[0],
14222
+ end = bg[bg.length - 1];
14223
+ ctx.fillStyle = data.fillStyle, ctx.globalAlpha = data.globalAlpha, ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
14225
14224
  }), this.paragraphs.forEach((paragraph, index) => {
14226
14225
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
14227
14226
  x: x + paragraph._x,
@@ -14384,7 +14383,13 @@ class RichText extends Graphic {
14384
14383
  }
14385
14384
  return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
14386
14385
  }
14386
+ static splitEmoji(text) {
14387
+ return [...new Intl.Segmenter().segment(text)].map(x => x.segment);
14388
+ }
14387
14389
  static splitText(text) {
14390
+ try {
14391
+ return this.splitEmoji(text);
14392
+ } catch (e) {}
14388
14393
  return Array.from(text);
14389
14394
  }
14390
14395
  static TransformTextConfig2SingleCharacter(textConfig) {
@@ -18430,7 +18435,7 @@ let DefaultDrawContribution = class {
18430
18435
  renderGroup(group, drawContext, parentMatrix, skipSort) {
18431
18436
  if (drawContext.break || !1 === group.attribute.visibleAll) return;
18432
18437
  if (group.incremental && (null == drawContext.startAtId || drawContext.startAtId === group._uid)) return drawContext.break = !0, void this._increaseRender(group, drawContext);
18433
- if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, !1)) return;
18438
+ if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, !1) && "empty" !== group.attribute.boundsMode) return;
18434
18439
  let tempBounds,
18435
18440
  nextM = parentMatrix;
18436
18441
  if (this.useDirtyBounds) {
@@ -20425,9 +20430,9 @@ class EditModule {
20425
20430
  textConfig.splice(configIdx, 1);
20426
20431
  const text = lastConfig.text,
20427
20432
  textList = text ? Array.from(text.toString()) : [];
20428
- for (let i = 0; i < textList.length; i++) textConfig.splice(i + configIdx, 0, Object.assign(Object.assign({
20433
+ for (let i = 0; i < textList.length; i++) textConfig.splice(i + configIdx, 0, Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
20429
20434
  fill: "black"
20430
- }, lastConfig), {
20435
+ }), lastConfig), {
20431
20436
  isComposing: !1,
20432
20437
  text: textList[i]
20433
20438
  }));
@@ -20627,9 +20632,11 @@ class RichTextEditPlugin {
20627
20632
  const cache = currRt.getFrameCache();
20628
20633
  if (!cache) return;
20629
20634
  const {
20630
- lines: lines
20631
- } = cache,
20632
- totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20635
+ lines: lines
20636
+ } = cache;
20637
+ if (0 === lines.length) return;
20638
+ if (!lines[0].paragraphs || 0 === lines[0].paragraphs.length) return;
20639
+ const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20633
20640
  return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
20634
20641
  }
20635
20642
  return !1;
@@ -20697,18 +20704,19 @@ class RichTextEditPlugin {
20697
20704
  placeholderFontFamily: placeholderFontFamily,
20698
20705
  placeholderFontSize: placeholderFontSize
20699
20706
  } = editOptions,
20700
- shadow = this.currRt.shadowRoot || this.currRt.attachShadow();
20701
- this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
20707
+ shadow = this.getShadow(this.currRt),
20708
+ textConfigItem = Object.assign(Object.assign({}, getDefaultCharacterConfig(this.currRt.attribute)), {
20709
+ text: placeholder
20710
+ });
20711
+ placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
20702
20712
  x: 0,
20703
20713
  y: 0,
20714
+ pickable: !1,
20715
+ editable: !1,
20716
+ editOptions: null,
20704
20717
  angle: 0,
20705
20718
  _debug_bounds: !1,
20706
- textConfig: [{
20707
- text: placeholder,
20708
- fill: placeholderColor,
20709
- fontFamily: placeholderFontFamily,
20710
- fontSize: placeholderFontSize
20711
- }]
20719
+ textConfig: [textConfigItem]
20712
20720
  })), shadow.add(this.shadowPlaceHolder);
20713
20721
  }
20714
20722
  tryShowInputBounds() {
@@ -20721,15 +20729,15 @@ class RichTextEditPlugin {
20721
20729
  } = editOptions;
20722
20730
  if (!editOptions || !boundsStrokeWhenInput) return;
20723
20731
  const {
20724
- attribute: attribute
20725
- } = this.currRt,
20726
- b = this.currRt.AABBBounds;
20727
- let h = b.height();
20732
+ attribute: attribute
20733
+ } = this.currRt;
20734
+ let b = this.currRt.AABBBounds,
20735
+ h = b.height();
20728
20736
  if (!attribute.textConfig.length && this.editLine) {
20729
20737
  const {
20730
20738
  points: points
20731
20739
  } = this.editLine.attribute;
20732
- h = points[1].y - points[0].y;
20740
+ h = points[1].y - points[0].y, b = getRichTextBounds(Object.assign({}, this.shadowPlaceHolder.attribute));
20733
20741
  }
20734
20742
  this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
20735
20743
  x: 0,
@@ -20739,10 +20747,9 @@ class RichTextEditPlugin {
20739
20747
  fill: !1,
20740
20748
  stroke: boundsStrokeWhenInput,
20741
20749
  lineWidth: 1,
20742
- boundsMode: "empty",
20743
20750
  zIndex: -1
20744
20751
  });
20745
- (this.currRt.shadowRoot || this.currRt.attachShadow()).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
20752
+ this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
20746
20753
  }
20747
20754
  trySyncPlaceholderToTextConfig() {
20748
20755
  if (!this.currRt) return;
@@ -20751,7 +20758,7 @@ class RichTextEditPlugin {
20751
20758
  editOptions: editOptions
20752
20759
  } = this.currRt.attribute;
20753
20760
  if (textConfig && textConfig.length) return;
20754
- if (!editOptions || !editOptions.placeholder) return;
20761
+ if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceHolderToTextConfig)) return;
20755
20762
  const {
20756
20763
  placeholder: placeholder
20757
20764
  } = editOptions;
@@ -20765,11 +20772,11 @@ class RichTextEditPlugin {
20765
20772
  context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown), context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp), context.stage.off("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown);
20766
20773
  }
20767
20774
  onFocus(e, data) {
20768
- this.deFocus(!1), this.focusing = !0;
20775
+ this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
20769
20776
  const target = e.target;
20770
20777
  if (!target || "richtext" !== target.type) return;
20771
20778
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
20772
- const shadowRoot = target.shadowRoot || target.attachShadow(),
20779
+ const shadowRoot = this.getShadow(target),
20773
20780
  cache = target.getFrameCache();
20774
20781
  if (cache) {
20775
20782
  if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
@@ -20782,16 +20789,14 @@ class RichTextEditPlugin {
20782
20789
  x: 0,
20783
20790
  y: 0,
20784
20791
  lineWidth: 1,
20785
- stroke: "black",
20786
- boundsMode: "empty"
20792
+ stroke: "black"
20787
20793
  });
20788
20794
  this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20789
20795
  const g = createGroup({
20790
20796
  x: 0,
20791
20797
  y: 0,
20792
20798
  width: 0,
20793
- height: 0,
20794
- boundsMode: "empty"
20799
+ height: 0
20795
20800
  });
20796
20801
  this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20797
20802
  }
@@ -20846,7 +20851,9 @@ class RichTextEditPlugin {
20846
20851
  let trulyDeFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
20847
20852
  const target = this.currRt;
20848
20853
  if (!target) return;
20849
- trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20854
+ this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
20855
+ trulyDeFocus: trulyDeFocus
20856
+ })), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20850
20857
  const currRt = this.currRt;
20851
20858
  this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine), this.editLine.release(), this.editLine = null, this.editBg.parent && this.editBg.parent.removeChild(this.editBg), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
20852
20859
  const textConfig = currRt.attribute.textConfig;
@@ -20903,67 +20910,75 @@ class RichTextEditPlugin {
20903
20910
  },
20904
20911
  line0Info = this.getLineByPoint(cache, startCursorPos),
20905
20912
  line1Info = this.getLineByPoint(cache, endCursorPos);
20906
- if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [endCursorPos, startCursorPos], [line1Info, line0Info] = [line0Info, line1Info]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
20907
- x: startCursorPos.x,
20908
- y: line0Info.top,
20909
- width: endCursorPos.x - startCursorPos.x,
20910
- height: line0Info.height,
20911
- fill: "#336df4",
20912
- fillOpacity: .2
20913
- });else {
20914
- this.editBg.setAttributes({
20915
- x: 0,
20913
+ if (line0Info && line1Info) {
20914
+ if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [endCursorPos, startCursorPos], [line1Info, line0Info] = [line0Info, line1Info]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
20915
+ x: startCursorPos.x,
20916
20916
  y: line0Info.top,
20917
- width: 0,
20918
- height: 0
20919
- });
20920
- const startIdx = cache.lines.findIndex(item => item === line0Info),
20921
- endIdx = cache.lines.findIndex(item => item === line1Info);
20922
- let y = 0;
20923
- for (let i = startIdx; i <= endIdx; i++) {
20924
- const line = cache.lines[i];
20925
- if (i === startIdx) {
20926
- const p = line.paragraphs[line.paragraphs.length - 1];
20927
- this.editBg.add(createRect({
20928
- x: startCursorPos.x,
20929
- y: y,
20930
- width: p.left + p.width - startCursorPos.x,
20931
- height: line.height,
20932
- fill: "#336df4",
20933
- fillOpacity: .2
20934
- }));
20935
- } else if (i === endIdx) {
20936
- const p = line.paragraphs[0];
20937
- this.editBg.add(createRect({
20938
- x: p.left,
20939
- y: y,
20940
- width: endCursorPos.x - p.left,
20941
- height: line.height,
20942
- fill: "#336df4",
20943
- fillOpacity: .2
20944
- }));
20945
- } else {
20946
- const p0 = line.paragraphs[0],
20947
- p1 = line.paragraphs[line.paragraphs.length - 1];
20948
- this.editBg.add(createRect({
20949
- x: p0.left,
20950
- y: y,
20951
- width: p1.left + p1.width - p0.left,
20952
- height: line.height,
20953
- fill: "#336df4",
20954
- fillOpacity: .2
20955
- }));
20917
+ width: endCursorPos.x - startCursorPos.x,
20918
+ height: line0Info.height,
20919
+ fill: "#336df4",
20920
+ fillOpacity: .2
20921
+ });else {
20922
+ this.editBg.setAttributes({
20923
+ x: 0,
20924
+ y: line0Info.top,
20925
+ width: 0,
20926
+ height: 0
20927
+ });
20928
+ const startIdx = cache.lines.findIndex(item => item === line0Info),
20929
+ endIdx = cache.lines.findIndex(item => item === line1Info);
20930
+ let y = 0;
20931
+ for (let i = startIdx; i <= endIdx; i++) {
20932
+ const line = cache.lines[i];
20933
+ if (i === startIdx) {
20934
+ const p = line.paragraphs[line.paragraphs.length - 1];
20935
+ this.editBg.add(createRect({
20936
+ x: startCursorPos.x,
20937
+ y: y,
20938
+ width: p.left + p.width - startCursorPos.x,
20939
+ height: line.height,
20940
+ fill: "#336df4",
20941
+ fillOpacity: .2
20942
+ }));
20943
+ } else if (i === endIdx) {
20944
+ const p = line.paragraphs[0];
20945
+ this.editBg.add(createRect({
20946
+ x: p.left,
20947
+ y: y,
20948
+ width: endCursorPos.x - p.left,
20949
+ height: line.height,
20950
+ fill: "#336df4",
20951
+ fillOpacity: .2
20952
+ }));
20953
+ } else {
20954
+ const p0 = line.paragraphs[0],
20955
+ p1 = line.paragraphs[line.paragraphs.length - 1];
20956
+ this.editBg.add(createRect({
20957
+ x: p0.left,
20958
+ y: y,
20959
+ width: p1.left + p1.width - p0.left,
20960
+ height: line.height,
20961
+ fill: "#336df4",
20962
+ fillOpacity: .2
20963
+ }));
20964
+ }
20965
+ y += line.height;
20956
20966
  }
20957
- y += line.height;
20958
20967
  }
20968
+ this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt), this.triggerRender(), this.updateCbs.forEach(cb => cb("selection", this));
20959
20969
  }
20960
- this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt), this.triggerRender(), this.updateCbs.forEach(cb => cb("selection", this));
20961
20970
  }
20962
20971
  hideSelection() {
20963
20972
  this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
20964
20973
  fill: "transparent"
20965
20974
  }));
20966
20975
  }
20976
+ getShadow(rt) {
20977
+ const sr = rt.shadowRoot || rt.attachShadow();
20978
+ return sr.setAttributes({
20979
+ boundsMode: "empty"
20980
+ }), sr;
20981
+ }
20967
20982
  getLineByPoint(cache, p1) {
20968
20983
  let lineInfo = cache.lines[0];
20969
20984
  for (let i = 0; i < cache.lines.length && !(lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y); i++) lineInfo = cache.lines[i + 1];
@@ -30459,7 +30474,7 @@ const registerWrapText = _registerWrapText;
30459
30474
 
30460
30475
  const roughModule = _roughModule;
30461
30476
 
30462
- const version = "0.22.0-vstory.6";
30477
+ const version = "0.22.0-vstory.8";
30463
30478
  preLoadAllModule();
30464
30479
  if (isBrowserEnv()) {
30465
30480
  loadBrowserEnv(container);