@visactor/vrender 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.
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.14";
2
+ export declare const version = "0.22.0-vstory.16";
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.14", (0, vrender_core_1.preLoadAllModule)(), (0,
24
+ exports.version = "0.22.0-vstory.16", (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,kBAAkB,CAAC;AAE1C,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.14\";\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,kBAAkB,CAAC;AAE1C,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.16\";\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
@@ -2494,6 +2494,8 @@ class Color {
2494
2494
  return color.getLuminance2();
2495
2495
  case "lum3":
2496
2496
  return color.getLuminance3();
2497
+ case "wcag":
2498
+ return color.getLuminanceWCAG();
2497
2499
  }
2498
2500
  }
2499
2501
  static parseColorString(value) {
@@ -2595,6 +2597,14 @@ class Color {
2595
2597
  getLuminance3() {
2596
2598
  return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
2597
2599
  }
2600
+ getLuminanceWCAG() {
2601
+ const RsRGB = this.color.r / 255,
2602
+ GsRGB = this.color.g / 255,
2603
+ BsRGB = this.color.b / 255;
2604
+ let R, G, B;
2605
+ R = RsRGB <= .03928 ? RsRGB / 12.92 : Math.pow((RsRGB + .055) / 1.055, 2.4), G = GsRGB <= .03928 ? GsRGB / 12.92 : Math.pow((GsRGB + .055) / 1.055, 2.4), B = BsRGB <= .03928 ? BsRGB / 12.92 : Math.pow((BsRGB + .055) / 1.055, 2.4);
2606
+ return .2126 * R + .7152 * G + .0722 * B;
2607
+ }
2598
2608
  clone() {
2599
2609
  return new Color(this.color.toString());
2600
2610
  }
@@ -3908,10 +3918,10 @@ class CustomPath2D extends CurvePath {
3908
3918
  x = current[5], y = current[6], controlX = current[3], controlY = current[4], this.bezierCurveTo(current[1] + l, current[2] + t, controlX + l, controlY + t, x + l, y + t);
3909
3919
  break;
3910
3920
  case "s":
3911
- tempX = x + current[3], tempY = y + current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t, x + current[1] + l, y + current[2] + t, tempX + l, tempY + t), controlX = x + current[1], controlY = y + current[2], x = tempX, y = tempY;
3921
+ tempX = x + current[3], tempY = y + current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = x + current[1], tempControlY = y + current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
3912
3922
  break;
3913
3923
  case "S":
3914
- tempX = current[3], tempY = current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t, current[1] + l, current[2] + t, tempX + l, tempY + t), x = tempX, y = tempY, controlX = current[1], controlY = current[2];
3924
+ tempX = current[3], tempY = current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = current[1], tempControlY = current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
3915
3925
  break;
3916
3926
  case "q":
3917
3927
  tempX = x + current[3], tempY = y + current[4], controlX = x + current[1], controlY = y + current[2], this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
@@ -4302,6 +4312,7 @@ const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, Defau
4302
4312
  keepDirIn3d: !0
4303
4313
  });
4304
4314
  const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
4315
+ upgradeAttrs: null,
4305
4316
  editable: !1,
4306
4317
  editOptions: null,
4307
4318
  ascentDescentMode: "actual",
@@ -10138,7 +10149,7 @@ class Graphic extends Node {
10138
10149
  null != onStart && animate.onStart(onStart), null != onFrame && animate.onFrame(onFrame), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove), animate.interpolateFunc = params.interpolate;
10139
10150
  }
10140
10151
  return this.animates.set(animate.id, animate), animate.onRemove(() => {
10141
- this.animates.delete(animate.id);
10152
+ animate.stop(), this.animates.delete(animate.id);
10142
10153
  }), animate;
10143
10154
  }
10144
10155
  onAttributeUpdate(context) {
@@ -10342,7 +10353,7 @@ class Graphic extends Node {
10342
10353
  if (this.stage = stage, this.layer = layer, this.setStageToShadowRoot(stage, layer), this.animates && this.animates.size) {
10343
10354
  const timeline = stage.getTimeline();
10344
10355
  this.animates.forEach(a => {
10345
- a.setTimeline(timeline);
10356
+ a.timeline === defaultTimeline && a.setTimeline(timeline);
10346
10357
  });
10347
10358
  }
10348
10359
  this._onSetStage && this._onSetStage(this, stage, layer), application.graphicService.onSetStage(this, stage);
@@ -10446,7 +10457,7 @@ class Graphic extends Node {
10446
10457
  return shadowRoot && (shadowRoot.shadowHost = this), this.shadowRoot = null != shadowRoot ? shadowRoot : application.graphicService.creator.shadowRoot(this), this.addUpdateBoundTag(), this.shadowRoot.setStage(this.stage, this.layer), this.shadowRoot;
10447
10458
  }
10448
10459
  detachShadow() {
10449
- this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot = null);
10460
+ this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot.release(!0), this.shadowRoot = null);
10450
10461
  }
10451
10462
  toJson() {
10452
10463
  return {
@@ -10498,7 +10509,7 @@ class Graphic extends Node {
10498
10509
  });
10499
10510
  }
10500
10511
  release() {
10501
- this.releaseStatus = "released", application.graphicService.onRelease(this);
10512
+ this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
10502
10513
  }
10503
10514
  _emitCustomEvent(type, context) {
10504
10515
  var _a, _b;
@@ -11074,6 +11085,11 @@ class Group extends Graphic {
11074
11085
  getNoWorkAnimateAttr() {
11075
11086
  return Group.NOWORK_ANIMATE_ATTR;
11076
11087
  }
11088
+ release(all) {
11089
+ all && this.forEachChildren(g => {
11090
+ g.release(all);
11091
+ }), super.release();
11092
+ }
11077
11093
  }
11078
11094
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
11079
11095
  function createGroup(attributes) {
@@ -13941,7 +13957,7 @@ class Paragraph {
13941
13957
  this.width = width, "vertical" === this.direction && (this.widthOrigin = this.width, this.width = this.heightOrigin, this.height = this.widthOrigin);
13942
13958
  }
13943
13959
  drawBackground(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
13944
- if (!this.character.background || this.character.backgroundOpacity && !(this.character.backgroundOpacity > 0)) return;
13960
+ if ("" === this.text || "\n" === this.text || !this.character.background || this.character.backgroundOpacity && !(this.character.backgroundOpacity > 0)) return;
13945
13961
  let baseline = top + ascent,
13946
13962
  text = this.text,
13947
13963
  left = this.left + deltaLeft;
@@ -13959,19 +13975,11 @@ class Paragraph {
13959
13975
  }
13960
13976
  }
13961
13977
  }
13962
- switch (this.character.script) {
13963
- case "super":
13964
- baseline -= this.ascent * (1 / 3);
13965
- break;
13966
- case "sub":
13967
- baseline += this.descent / 2;
13968
- }
13969
- "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);
13970
- const fillStyle = ctx.fillStyle,
13971
- globalAlpha = ctx.globalAlpha;
13972
- ctx.fillStyle = this.character.background, void 0 !== this.character.backgroundOpacity && (ctx.globalAlpha = this.character.backgroundOpacity);
13973
13978
  const lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + lineHeight);
13974
- ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top), ctx.fillStyle = fillStyle, ctx.globalAlpha = globalAlpha;
13979
+ return Object.assign(Object.assign({}, lrtb), {
13980
+ fillStyle: this.character.background,
13981
+ globalAlpha: this.character.backgroundOpacity
13982
+ });
13975
13983
  }
13976
13984
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
13977
13985
  let baseline = top + ascent,
@@ -14245,8 +14253,19 @@ class Line {
14245
14253
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
14246
14254
  }
14247
14255
  }
14256
+ let fillStyle = "",
14257
+ globalAlpha = -1,
14258
+ currBgList = [];
14259
+ const bgList = [currBgList];
14248
14260
  this.paragraphs.forEach((paragraph, index) => {
14249
- paragraph instanceof RichTextIcon || paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
14261
+ if (paragraph instanceof RichTextIcon) return;
14262
+ const data = paragraph.drawBackground(ctx, y, this.ascent, x, 0 === index, this.textAlign, this.height);
14263
+ data && (fillStyle === data.fillStyle && globalAlpha === data.globalAlpha || (currBgList = [], bgList.push(currBgList), fillStyle = data.fillStyle, globalAlpha = data.globalAlpha), currBgList.push(data));
14264
+ }), bgList.forEach(bg => {
14265
+ if (0 === bg.length) return;
14266
+ const data = bg[0],
14267
+ end = bg[bg.length - 1];
14268
+ ctx.fillStyle = data.fillStyle, ctx.globalAlpha = data.globalAlpha, ctx.fillRect(data.left, data.top, end.right - data.left, end.bottom - data.top);
14250
14269
  }), this.paragraphs.forEach((paragraph, index) => {
14251
14270
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
14252
14271
  x: x + paragraph._x,
@@ -14484,7 +14503,7 @@ class RichText extends Graphic {
14484
14503
  case "right":
14485
14504
  deltaX = -aabbBounds.width();
14486
14505
  }
14487
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), aabbBounds;
14506
+ return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
14488
14507
  }
14489
14508
  needUpdateTags(keys) {
14490
14509
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -14512,48 +14531,53 @@ class RichText extends Graphic {
14512
14531
  }
14513
14532
  combinedStyleToCharacter(config) {
14514
14533
  const {
14515
- fill: fill,
14516
- stroke: stroke,
14517
- fontSize: fontSize,
14518
- fontFamily: fontFamily,
14519
- fontStyle: fontStyle,
14520
- fontWeight: fontWeight,
14521
- lineWidth: lineWidth,
14522
- opacity: opacity,
14523
- fillOpacity: fillOpacity,
14524
- strokeOpacity: strokeOpacity
14525
- } = this.attribute;
14526
- return Object.assign({
14527
- fill: fill,
14528
- stroke: stroke,
14529
- fontSize: fontSize,
14530
- fontFamily: fontFamily,
14531
- fontStyle: fontStyle,
14532
- fontWeight: fontWeight,
14533
- lineWidth: lineWidth,
14534
- opacity: opacity,
14535
- fillOpacity: fillOpacity,
14536
- strokeOpacity: strokeOpacity
14537
- }, config);
14534
+ fill: fill,
14535
+ stroke: stroke,
14536
+ fontSize: fontSize,
14537
+ fontFamily: fontFamily,
14538
+ fontStyle: fontStyle,
14539
+ fontWeight: fontWeight,
14540
+ lineWidth: lineWidth,
14541
+ opacity: opacity,
14542
+ fillOpacity: fillOpacity,
14543
+ lineHeight: lineHeight,
14544
+ strokeOpacity: strokeOpacity,
14545
+ upgradeAttrs: upgradeAttrs
14546
+ } = this.attribute,
14547
+ out = Object.assign({
14548
+ fill: fill,
14549
+ stroke: stroke,
14550
+ fontSize: fontSize,
14551
+ fontFamily: fontFamily,
14552
+ fontStyle: fontStyle,
14553
+ fontWeight: fontWeight,
14554
+ lineWidth: lineWidth,
14555
+ opacity: opacity,
14556
+ fillOpacity: fillOpacity,
14557
+ strokeOpacity: strokeOpacity
14558
+ }, config);
14559
+ return (null == upgradeAttrs ? void 0 : upgradeAttrs.lineHeight) && (out.lineHeight = lineHeight), out;
14538
14560
  }
14539
14561
  doUpdateFrameCache(tc) {
14540
14562
  var _a;
14541
14563
  const {
14542
- maxWidth: maxWidth,
14543
- maxHeight: maxHeight,
14544
- width: width,
14545
- height: height,
14546
- ellipsis: ellipsis,
14547
- wordBreak: wordBreak,
14548
- verticalDirection: verticalDirection,
14549
- textAlign: textAlign,
14550
- textBaseline: textBaseline,
14551
- layoutDirection: layoutDirection,
14552
- singleLine: singleLine,
14553
- disableAutoWrapLine: disableAutoWrapLine,
14554
- editable: editable,
14555
- ascentDescentMode: ascentDescentMode
14556
- } = this.attribute;
14564
+ maxWidth: maxWidth,
14565
+ maxHeight: maxHeight,
14566
+ width: width,
14567
+ height: height,
14568
+ ellipsis: ellipsis,
14569
+ wordBreak: wordBreak,
14570
+ verticalDirection: verticalDirection,
14571
+ textAlign: textAlign,
14572
+ textBaseline: textBaseline,
14573
+ layoutDirection: layoutDirection,
14574
+ singleLine: singleLine,
14575
+ disableAutoWrapLine: disableAutoWrapLine,
14576
+ editable: editable,
14577
+ ascentDescentMode: ascentDescentMode,
14578
+ upgradeAttrs: upgradeAttrs
14579
+ } = this.attribute,
14580
+ enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;
14557
14581
  let {
14558
14582
  textConfig: _tc = []
14559
14583
  } = this.attribute;
@@ -14575,7 +14599,10 @@ class RichText extends Graphic {
14575
14599
  const richTextConfig = this.combinedStyleToCharacter(textConfig[i]);
14576
14600
  if (isNumber$1(richTextConfig.text) && (richTextConfig.text = `${richTextConfig.text}`), richTextConfig.text && richTextConfig.text.includes("\n")) {
14577
14601
  const textParts = richTextConfig.text.split("\n");
14578
- for (let j = 0; j < textParts.length; j++) paragraphs.push(new Paragraph(textParts[j], 0 !== j, richTextConfig, ascentDescentMode));
14602
+ for (let j = 0; j < textParts.length; j++) if (0 === j) paragraphs.push(new Paragraph(textParts[j], !1, richTextConfig, ascentDescentMode));else if (textParts[j] || i === textConfig.length - 1) paragraphs.push(new Paragraph(textParts[j], !0, richTextConfig, ascentDescentMode));else {
14603
+ const nextRichTextConfig = this.combinedStyleToCharacter(textConfig[i + 1]);
14604
+ paragraphs.push(new Paragraph(textParts[j], !0, nextRichTextConfig, ascentDescentMode));
14605
+ }
14579
14606
  } else richTextConfig.text && paragraphs.push(new Paragraph(richTextConfig.text, !1, richTextConfig, ascentDescentMode));
14580
14607
  }
14581
14608
  const maxWidthFinite = "number" == typeof maxWidth && Number.isFinite(maxWidth) && maxWidth > 0,
@@ -14584,7 +14611,7 @@ class RichText extends Graphic {
14584
14611
  richTextHeightEnable = "number" == typeof height && Number.isFinite(height) && height > 0 && (!maxHeightFinite || height <= maxHeight),
14585
14612
  frame = new Frame(0, 0, (richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0) || 0, (richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0) || 0, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection || "horizontal", !richTextWidthEnable && maxWidthFinite, !richTextHeightEnable && maxHeightFinite, singleLine || !1, null === (_a = this._frameCache) || void 0 === _a ? void 0 : _a.icons),
14586
14613
  wrapper = new Wrapper(frame);
14587
- if (wrapper.newLine = editable, disableAutoWrapLine) {
14614
+ if (wrapper.newLine = enableMultiBreakLine, disableAutoWrapLine) {
14588
14615
  let lineCount = 0,
14589
14616
  skip = !1;
14590
14617
  for (let i = 0; i < paragraphs.length; i++) {
@@ -14600,7 +14627,7 @@ class RichText extends Graphic {
14600
14627
  l.calcOffset(offsetSize, !1);
14601
14628
  });
14602
14629
  }
14603
- editable && frame.lines.forEach(item => {
14630
+ enableMultiBreakLine && frame.lines.forEach(item => {
14604
14631
  const lastParagraphs = item.paragraphs;
14605
14632
  item.paragraphs = item.paragraphs.filter(p => "" !== p.text), 0 === item.paragraphs.length && lastParagraphs.length && (lastParagraphs[0].text = "\n", item.paragraphs.push(lastParagraphs[0]));
14606
14633
  }), this._frameCache = frame;
@@ -20258,6 +20285,7 @@ function getDefaultCharacterConfig(attribute) {
20258
20285
  fill = "black",
20259
20286
  stroke = !1,
20260
20287
  fontWeight = "normal",
20288
+ lineHeight: lineHeight,
20261
20289
  fontFamily = "Arial"
20262
20290
  } = attribute;
20263
20291
  let {
@@ -20268,7 +20296,8 @@ function getDefaultCharacterConfig(attribute) {
20268
20296
  stroke: stroke,
20269
20297
  fontSize: fontSize,
20270
20298
  fontWeight: fontWeight,
20271
- fontFamily: fontFamily
20299
+ fontFamily: fontFamily,
20300
+ lineHeight: lineHeight
20272
20301
  };
20273
20302
  }
20274
20303
  function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
@@ -20517,15 +20546,15 @@ class RichTextEditPlugin {
20517
20546
  }, this.handleFocusOut = () => {
20518
20547
  throw new Error("不会走到这里 handleFocusOut");
20519
20548
  }, this.handleMove = e => {
20520
- this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
20549
+ this.currRt && !this.currRt.attribute.editable && this.deFocus(!0), this.isEditableRichtext(e) ? (this.handleEnter(), e.target.once("pointerleave", this.handleLeave, {
20521
20550
  capture: !0
20522
- }), this.tryShowSelection(e, !1));
20523
- }, this.handleEnter = e => {
20551
+ }), this.tryShowSelection(e, !1)) : this.handleLeave();
20552
+ }, this.handleEnter = () => {
20524
20553
  this.editing = !0, this.pluginService.stage.setCursor("text");
20525
- }, this.handleLeave = e => {
20554
+ }, this.handleLeave = () => {
20526
20555
  this.editing = !1, this.pluginService.stage.setCursor("default");
20527
20556
  }, this.handlePointerDown = e => {
20528
- this.editing ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach(cb => cb(this.editing ? "onfocus" : "defocus", this));
20557
+ this.editing && this.isEditableRichtext(e) ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0, this.updateCbs.forEach(cb => cb(this.editing ? "onfocus" : "defocus", this));
20529
20558
  }, this.handlePointerUp = e => {
20530
20559
  this.pointerDown = !1;
20531
20560
  }, this.handleDBLClick = e => {
@@ -20633,7 +20662,7 @@ class RichTextEditPlugin {
20633
20662
  } = cache,
20634
20663
  totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20635
20664
  if (x) {
20636
- x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x, this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1);
20665
+ x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x, this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1), this.selectionStartCursorIdx = this.curCursorIdx;
20637
20666
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
20638
20667
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
20639
20668
  }
@@ -20726,7 +20755,8 @@ class RichTextEditPlugin {
20726
20755
  lineWidth: 1,
20727
20756
  zIndex: -1
20728
20757
  });
20729
- this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20758
+ const shadow = this.getShadow(this.currRt);
20759
+ this.addEditLineOrBgOrBounds(this.shadowBounds, shadow), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20730
20760
  }
20731
20761
  trySyncPlaceholderToTextConfig() {
20732
20762
  if (!this.currRt) return;
@@ -20761,8 +20791,22 @@ class RichTextEditPlugin {
20761
20791
  stopPropagation(e) {
20762
20792
  e.stopPropagation();
20763
20793
  }
20794
+ addEditLineOrBgOrBounds(graphic, shadowRoot) {
20795
+ let group = shadowRoot.getElementById("emptyBoundsContainer");
20796
+ group || (group = createGroup({
20797
+ x: 0,
20798
+ y: 0,
20799
+ width: 0,
20800
+ height: 0,
20801
+ boundsMode: "empty"
20802
+ }), group.id = "emptyBoundsContainer", shadowRoot.add(group)), group.add(graphic);
20803
+ }
20804
+ removeEditLineOrBgOrBounds(graphic, shadowRoot) {
20805
+ const group = shadowRoot.getElementById("emptyBoundsContainer");
20806
+ group && group.removeChild(graphic);
20807
+ }
20764
20808
  onFocus(e, data) {
20765
- this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
20809
+ this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0, this.editing = !0;
20766
20810
  const target = e.target;
20767
20811
  if (!target || "richtext" !== target.type) return;
20768
20812
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
@@ -20786,7 +20830,7 @@ class RichTextEditPlugin {
20786
20830
  width: 0,
20787
20831
  height: 0
20788
20832
  });
20789
- this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20833
+ this.editBg = g, this.addEditLineOrBgOrBounds(this.editLine, shadowRoot), this.addEditLineOrBgOrBounds(this.editBg, shadowRoot);
20790
20834
  }
20791
20835
  if (data = data || this.computedCursorPosByEvent(e, cache)) {
20792
20836
  const {
@@ -20851,27 +20895,29 @@ class RichTextEditPlugin {
20851
20895
  }
20852
20896
  deFocus() {
20853
20897
  let trulyDeFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
20854
- this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
20898
+ this.editing = !1, this.updateCbs && this.updateCbs.forEach(cb => cb("beforeDefocus", this, {
20855
20899
  trulyDeFocus: trulyDeFocus
20856
20900
  }));
20857
- const target = this.currRt;
20858
- if (!target) return;
20901
+ const currRt = this.currRt;
20902
+ if (!currRt) return;
20859
20903
  const {
20860
20904
  editOptions = {}
20861
- } = target.attribute;
20862
- editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20863
- const currRt = this.currRt;
20864
- 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;
20905
+ } = currRt.attribute;
20906
+ editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null;
20907
+ const shadowRoot = this.getShadow(currRt);
20908
+ this.editLine && (this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot), this.editLine.release(), this.editLine = null, this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot), 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;
20865
20909
  const textConfig = currRt.attribute.textConfig;
20866
20910
  let lastConfig = textConfig[textConfig.length - 1],
20867
20911
  cleared = !1;
20868
20912
  for (; lastConfig && "\n" === lastConfig.text;) textConfig.pop(), lastConfig = textConfig[textConfig.length - 1], cleared = !0;
20869
20913
  cleared && currRt.setAttributes({
20870
20914
  textConfig: textConfig
20871
- });
20915
+ }), currRt.removeEventListener("pointerleave", this.handleLeave);
20872
20916
  }
20873
20917
  addAnimateToLine(line) {
20874
- line.animates && line.animates.forEach(animate => {
20918
+ line.setAttributes({
20919
+ opacity: 1
20920
+ }), line.animates && line.animates.forEach(animate => {
20875
20921
  animate.stop(), animate.release();
20876
20922
  });
20877
20923
  line.animate({
@@ -20980,7 +21026,8 @@ class RichTextEditPlugin {
20980
21026
  getShadow(rt) {
20981
21027
  const sr = rt.shadowRoot || rt.attachShadow();
20982
21028
  return sr.setAttributes({
20983
- boundsMode: "empty"
21029
+ width: 1,
21030
+ height: 1
20984
21031
  }), sr;
20985
21032
  }
20986
21033
  getLineByPoint(cache, p1) {
@@ -21014,7 +21061,10 @@ class RichTextEditPlugin {
21014
21061
  return -1;
21015
21062
  }
21016
21063
  isRichtext(e) {
21017
- return !(!e.target || "richtext" !== e.target.type || !e.target.attribute.editable);
21064
+ return !(!e.target || "richtext" !== e.target.type);
21065
+ }
21066
+ isEditableRichtext(e) {
21067
+ return this.isRichtext(e) && !!e.target.attribute.editable;
21018
21068
  }
21019
21069
  triggerRender() {
21020
21070
  this.pluginService.stage.renderNextFrame();
@@ -21160,7 +21210,7 @@ class RichTextEditPlugin {
21160
21210
  target && (this.currRt = target, e ? this._forceFocusByEvent(e) : this._forceFocusByCursorIndex(null != cursorIndex ? cursorIndex : -.1));
21161
21211
  }
21162
21212
  _forceFocusByEvent(e) {
21163
- this.handleEnter(e), this.handlePointerDown(e), this.handlePointerUp(e);
21213
+ this.handleEnter(), this.handlePointerDown(e), this.handlePointerUp(e);
21164
21214
  }
21165
21215
  _forceFocusByCursorIndex(cursorIndex) {
21166
21216
  const richtext = this.currRt;
@@ -27481,13 +27531,15 @@ let NodeWindowHandlerContribution = class extends BaseWindowHandlerContribution
27481
27531
  this.canvas = new NodeCanvas(options);
27482
27532
  }
27483
27533
  createWindowByCanvas(params) {
27484
- const canvas = params.canvas;
27534
+ var _a;
27535
+ const canvas = params.canvas,
27536
+ dpr = null !== (_a = params.dpr) && void 0 !== _a ? _a : 1;
27485
27537
  let width = params.width,
27486
27538
  height = params.height;
27487
- null != width && null != height && params.canvasControled || (width = canvas.width, height = canvas.height), this.canvas = new NodeCanvas({
27539
+ null != width && null != height && params.canvasControled || (width = canvas.width / dpr, height = canvas.height / dpr), this.canvas = new NodeCanvas({
27488
27540
  width: width,
27489
27541
  height: height,
27490
- dpr: 1,
27542
+ dpr: dpr,
27491
27543
  nativeCanvas: canvas,
27492
27544
  canvasControled: params.canvasControled
27493
27545
  });
@@ -31227,7 +31279,7 @@ const registerWrapText = _registerWrapText;
31227
31279
 
31228
31280
  const roughModule = _roughModule;
31229
31281
 
31230
- const version = "0.22.0-vstory.14";
31282
+ const version = "0.22.0-vstory.16";
31231
31283
  preLoadAllModule();
31232
31284
  if (isBrowserEnv()) {
31233
31285
  loadBrowserEnv(container);