@visactor/vrender 0.22.0-vstory.12 → 0.22.0-vstory.14

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.12";
2
+ export declare const version = "0.22.0-vstory.14";
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.12", (0, vrender_core_1.preLoadAllModule)(), (0,
24
+ exports.version = "0.22.0-vstory.14", (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.12\";\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.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"]}
package/dist/index.es.js CHANGED
@@ -431,12 +431,15 @@ class Container {
431
431
  serviceIdentifier: injectIdentifier,
432
432
  constructorArgsMetadata: constructorArgsMetadata
433
433
  },
434
- request = {
434
+ bindings = (this._bindingDictionary.get(injectIdentifier) || []).filter(b => b.constraint(target));
435
+ if (bindings.length) {
436
+ const request = {
435
437
  injectIdentifier: injectIdentifier,
436
438
  metadata: constructorArgsMetadata,
437
- bindings: this._bindingDictionary.get(injectIdentifier).filter(b => b.constraint(target))
439
+ bindings: bindings
438
440
  };
439
- arr.push(request);
441
+ arr.push(request);
442
+ }
440
443
  }
441
444
  return arr;
442
445
  }
@@ -4146,6 +4149,7 @@ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
4146
4149
  texturePadding: 2,
4147
4150
  backgroundMode: "no-repeat",
4148
4151
  backgroundFit: !0,
4152
+ backgroundKeepAspectRatio: !1,
4149
4153
  backgroundClip: !0,
4150
4154
  backgroundScale: 1,
4151
4155
  backgroundOffsetX: 0,
@@ -4784,6 +4788,9 @@ let ATextMeasure = class {
4784
4788
  }
4785
4789
  compatibleMetrics(metrics, options) {
4786
4790
  if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4791
+ metrics = {
4792
+ width: metrics.width
4793
+ };
4787
4794
  const {
4788
4795
  ascent: ascent,
4789
4796
  descent: descent
@@ -4791,6 +4798,13 @@ let ATextMeasure = class {
4791
4798
  metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4792
4799
  }
4793
4800
  if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4801
+ metrics = {
4802
+ width: metrics.width,
4803
+ actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
4804
+ actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
4805
+ fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
4806
+ fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
4807
+ };
4794
4808
  const {
4795
4809
  left: left,
4796
4810
  right: right
@@ -14307,6 +14321,12 @@ class Wrapper {
14307
14321
  }
14308
14322
  }
14309
14323
 
14324
+ let supportIntl = !1;
14325
+ try {
14326
+ supportIntl = Intl && "function" == typeof Intl.Segmenter;
14327
+ } catch (e) {
14328
+ supportIntl = !1;
14329
+ }
14310
14330
  const RICHTEXT_UPDATE_TAG_KEY = ["width", "height", "ellipsis", "wordBreak", "verticalDirection", "maxHeight", "maxWidth", "textAlign", "textBaseline", "textConfig", "layoutDirection", "fill", "stroke", "fontSize", "fontFamily", "fontStyle", "fontWeight", "lineWidth", "opacity", "fillOpacity", "strokeOpacity", ...GRAPHIC_UPDATE_TAG_KEY];
14311
14331
  class RichText extends Graphic {
14312
14332
  constructor(params) {
@@ -14396,6 +14416,16 @@ class RichText extends Graphic {
14396
14416
  return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
14397
14417
  }
14398
14418
  static splitText(text) {
14419
+ if (supportIntl) {
14420
+ const segmenter = new Intl.Segmenter(void 0, {
14421
+ granularity: "grapheme"
14422
+ }),
14423
+ segments = [];
14424
+ for (const {
14425
+ segment: segment
14426
+ } of segmenter.segment(text)) segments.push(segment);
14427
+ return segments;
14428
+ }
14399
14429
  return Array.from(text);
14400
14430
  }
14401
14431
  static TransformTextConfig2SingleCharacter(textConfig) {
@@ -14411,14 +14441,14 @@ class RichText extends Graphic {
14411
14441
  }), tc;
14412
14442
  }
14413
14443
  updateAABBBounds(attribute, richtextTheme, aabbBounds) {
14414
- var _a, _b;
14444
+ var _a, _b, _c, _d;
14415
14445
  const {
14416
14446
  width = richtextTheme.width,
14417
14447
  height = richtextTheme.height,
14418
14448
  maxWidth = richtextTheme.maxWidth,
14419
14449
  maxHeight = richtextTheme.maxHeight,
14420
14450
  textAlign = richtextTheme.textAlign,
14421
- textBaseline = richtextTheme.textBaseline,
14451
+ verticalDirection = null !== (_b = null !== (_a = attribute.textBaseline) && void 0 !== _a ? _a : richtextTheme.textBaseline) && void 0 !== _b ? _b : richtextTheme.verticalDirection,
14422
14452
  editOptions: editOptions
14423
14453
  } = attribute;
14424
14454
  if (width > 0 && height > 0) aabbBounds.set(0, 0, width, height);else {
@@ -14431,9 +14461,9 @@ class RichText extends Graphic {
14431
14461
  contentHeight = height || actualHeight || 0;
14432
14462
  contentHeight = "number" == typeof maxHeight && contentHeight > maxHeight ? maxHeight : contentHeight || 0, contentWidth = "number" == typeof maxWidth && contentWidth > maxWidth ? maxWidth : contentWidth || 0, aabbBounds.set(0, 0, contentWidth, contentHeight);
14433
14463
  }
14434
- editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !(null === (_a = attribute.textConfig) || void 0 === _a ? void 0 : _a.length) && (aabbBounds.y2 = aabbBounds.y1 + (null !== (_b = attribute.fontSize) && void 0 !== _b ? _b : 12), aabbBounds.x2 = aabbBounds.x1 + 2);
14464
+ editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !(null === (_c = attribute.textConfig) || void 0 === _c ? void 0 : _c.length) && (aabbBounds.y2 = aabbBounds.y1 + (null !== (_d = attribute.fontSize) && void 0 !== _d ? _d : 12), aabbBounds.x2 = aabbBounds.x1 + 2);
14435
14465
  let deltaY = 0;
14436
- switch (textBaseline) {
14466
+ switch (verticalDirection) {
14437
14467
  case "top":
14438
14468
  deltaY = 0;
14439
14469
  break;
@@ -15437,6 +15467,7 @@ class DefaultBaseBackgroundRenderContribution {
15437
15467
  opacity = graphicAttribute.opacity,
15438
15468
  backgroundMode = graphicAttribute.backgroundMode,
15439
15469
  backgroundFit = graphicAttribute.backgroundFit,
15470
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15440
15471
  backgroundScale = graphicAttribute.backgroundScale,
15441
15472
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15442
15473
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
@@ -15458,6 +15489,7 @@ class DefaultBaseBackgroundRenderContribution {
15458
15489
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, this.doDrawImage(context, res.data, b, {
15459
15490
  backgroundMode: backgroundMode,
15460
15491
  backgroundFit: backgroundFit,
15492
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15461
15493
  backgroundScale: backgroundScale,
15462
15494
  backgroundOffsetX: backgroundOffsetX,
15463
15495
  backgroundOffsetY: backgroundOffsetY
@@ -15468,6 +15500,7 @@ class DefaultBaseBackgroundRenderContribution {
15468
15500
  const {
15469
15501
  backgroundMode: backgroundMode,
15470
15502
  backgroundFit: backgroundFit,
15503
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15471
15504
  backgroundScale = 1,
15472
15505
  backgroundOffsetX = 0,
15473
15506
  backgroundOffsetY = 0
@@ -15477,7 +15510,12 @@ class DefaultBaseBackgroundRenderContribution {
15477
15510
  let w = targetW,
15478
15511
  h = targetH;
15479
15512
  if ("no-repeat" === backgroundMode) {
15480
- if (backgroundFit) context.drawImage(data, b.x1, b.y1, b.width(), b.height());else {
15513
+ if (backgroundFit) {
15514
+ if (backgroundKeepAspectRatio) {
15515
+ const maxScale = Math.max(targetW / data.width, targetH / data.height);
15516
+ context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
15517
+ } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
15518
+ } else {
15481
15519
  const resW = data.width * backgroundScale,
15482
15520
  resH = data.height * backgroundScale;
15483
15521
  context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
@@ -15783,6 +15821,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
15783
15821
  background: background,
15784
15822
  backgroundMode = graphicAttribute.backgroundMode,
15785
15823
  backgroundFit = graphicAttribute.backgroundFit,
15824
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15786
15825
  backgroundScale = graphicAttribute.backgroundScale,
15787
15826
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15788
15827
  backgroundOffsetY = graphicAttribute.backgroundOffsetY
@@ -15795,6 +15834,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
15795
15834
  this.doDrawImage(context, res.data, b, {
15796
15835
  backgroundMode: backgroundMode,
15797
15836
  backgroundFit: backgroundFit,
15837
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15798
15838
  backgroundScale: backgroundScale,
15799
15839
  backgroundOffsetX: backgroundOffsetX,
15800
15840
  backgroundOffsetY: backgroundOffsetY
@@ -17125,7 +17165,8 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
17125
17165
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17126
17166
  const {
17127
17167
  backgroundMode = graphicAttribute.backgroundMode,
17128
- backgroundFit = graphicAttribute.backgroundFit
17168
+ backgroundFit = graphicAttribute.backgroundFit,
17169
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
17129
17170
  } = graphic.attribute;
17130
17171
  let matrix,
17131
17172
  {
@@ -17164,7 +17205,8 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
17164
17205
  if ("success" !== res.state || !res.data) return void restore();
17165
17206
  context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
17166
17207
  backgroundMode: backgroundMode,
17167
- backgroundFit: backgroundFit
17208
+ backgroundFit: backgroundFit,
17209
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
17168
17210
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
17169
17211
  } else {
17170
17212
  const {
@@ -18299,7 +18341,7 @@ var __decorate$1l = undefined && undefined.__decorate || function (decorators, t
18299
18341
  };
18300
18342
  let DefaultDrawContribution = class {
18301
18343
  constructor(contributions, drawItemInterceptorContributions) {
18302
- this.contributions = contributions, this.drawItemInterceptorContributions = drawItemInterceptorContributions, this.currentRenderMap = new Map(), this.defaultRenderMap = new Map(), this.styleRenderMap = new Map(), this.dirtyBounds = new Bounds(), this.backupDirtyBounds = new Bounds(), this.global = application.global, this.layerService = application.layerService, this.init();
18344
+ this.contributions = contributions, this.drawItemInterceptorContributions = drawItemInterceptorContributions, this.currentRenderMap = new Map(), this.defaultRenderMap = new Map(), this.styleRenderMap = new Map(), this.dirtyBounds = new Bounds(), this.backupDirtyBounds = new Bounds(), this.global = application.global, this.layerService = application.layerService, isArray$1(this.contributions) || (this.contributions = [this.contributions]), this.init();
18303
18345
  }
18304
18346
  init() {
18305
18347
  this.contributions.forEach(item => {
@@ -20342,10 +20384,11 @@ class EditModule {
20342
20384
  textAreaDom.setAttribute("style", "width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;"), textAreaDom.addEventListener("input", this.handleInput), textAreaDom.addEventListener("compositionstart", this.handleCompositionStart), textAreaDom.addEventListener("compositionend", this.handleCompositionEnd), textAreaDom.addEventListener("focusin", this.handleFocusIn), textAreaDom.addEventListener("focusout", this.handleFocusOut), application.global.addEventListener("keydown", this.handleKeyDown);
20343
20385
  }
20344
20386
  parseCompositionStr(configIdx) {
20387
+ var _a;
20345
20388
  const {
20346
20389
  textConfig = []
20347
20390
  } = this.currRt.attribute,
20348
- lastConfig = textConfig[configIdx];
20391
+ lastConfig = null !== (_a = textConfig[configIdx]) && void 0 !== _a ? _a : {};
20349
20392
  textConfig.splice(configIdx, 1);
20350
20393
  const text = lastConfig.text,
20351
20394
  textList = text ? Array.from(text.toString()) : [];
@@ -20402,15 +20445,18 @@ class Selection {
20402
20445
  return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
20403
20446
  }
20404
20447
  getFormat(key) {
20405
- return this.getAllFormat(key)[0];
20448
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20449
+ return this.getAllFormat(key, supportOutAttr)[0];
20406
20450
  }
20407
20451
  getAllFormat(key) {
20452
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20453
+ var _a, _b, _c, _d;
20408
20454
  const valSet = new Set(),
20409
20455
  minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx),
20410
20456
  maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
20411
- if (minCursorIdx === maxCursorIdx) return [this._getFormat(key, minCursorIdx)];
20457
+ if (minCursorIdx === maxCursorIdx) return supportOutAttr ? [null !== (_a = this._getFormat(key, minCursorIdx)) && void 0 !== _a ? _a : (null === (_b = this.rt) || void 0 === _b ? void 0 : _b.attribute)[key]] : [this._getFormat(key, minCursorIdx)];
20412
20458
  for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
20413
- const val = this._getFormat(key, i);
20459
+ const val = supportOutAttr ? null !== (_c = this._getFormat(key, i)) && void 0 !== _c ? _c : (null === (_d = this.rt) || void 0 === _d ? void 0 : _d.attribute)[key] : this._getFormat(key, i);
20414
20460
  val && valSet.add(val);
20415
20461
  }
20416
20462
  return Array.from(valSet.values());
@@ -20458,7 +20504,7 @@ class RichTextEditPlugin {
20458
20504
  const config = rt.attribute.textConfig;
20459
20505
  this._formatTextCommand(payload, config, rt);
20460
20506
  }, this.handleKeyDown = e => {
20461
- this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelection(e) || this.directKey(e));
20507
+ this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelectionKeyHandler(e) || this.directKeyHandler(e));
20462
20508
  }, this.handleInput = (text, isComposing, cursorIdx, rt) => {
20463
20509
  this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(), this.updateCbs.forEach(cb => cb("input", this)));
20464
20510
  }, this.handleChange = (text, isComposing, cursorIdx, rt) => {
@@ -20471,7 +20517,9 @@ class RichTextEditPlugin {
20471
20517
  }, this.handleFocusOut = () => {
20472
20518
  throw new Error("不会走到这里 handleFocusOut");
20473
20519
  }, this.handleMove = e => {
20474
- this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave), this.tryShowSelection(e, !1));
20520
+ this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
20521
+ capture: !0
20522
+ }), this.tryShowSelection(e, !1));
20475
20523
  }, this.handleEnter = e => {
20476
20524
  this.editing = !0, this.pluginService.stage.setCursor("text");
20477
20525
  }, this.handleLeave = e => {
@@ -20510,7 +20558,17 @@ class RichTextEditPlugin {
20510
20558
  idx > -1 && cbs.splice(idx, 1);
20511
20559
  }
20512
20560
  activate(context) {
20513
- this.pluginService = context, this.editModule = new EditModule(), context.stage.on("pointermove", this.handleMove), context.stage.on("pointerdown", this.handlePointerDown), context.stage.on("pointerup", this.handlePointerUp), context.stage.on("pointerleave", this.handlePointerUp), context.stage.on("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
20561
+ this.pluginService = context, this.editModule = new EditModule(), context.stage.on("pointermove", this.handleMove, {
20562
+ capture: !0
20563
+ }), context.stage.on("pointerdown", this.handlePointerDown, {
20564
+ capture: !0
20565
+ }), context.stage.on("pointerup", this.handlePointerUp, {
20566
+ capture: !0
20567
+ }), context.stage.on("pointerleave", this.handlePointerUp, {
20568
+ capture: !0
20569
+ }), context.stage.on("dblclick", this.handleDBLClick, {
20570
+ capture: !0
20571
+ }), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
20514
20572
  }
20515
20573
  copyToClipboard(e) {
20516
20574
  if (application.global.isMacOS() && e.metaKey && "c" === e.key || !application.global.isMacOS() && e.ctrlKey && "c" === e.key) {
@@ -20544,21 +20602,22 @@ class RichTextEditPlugin {
20544
20602
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
20545
20603
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
20546
20604
  }
20547
- fullSelection(e) {
20548
- if (application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) {
20549
- const currRt = this.currRt;
20550
- if (!currRt) return;
20551
- const cache = currRt.getFrameCache();
20552
- if (!cache) return;
20553
- const {
20554
- lines: lines
20555
- } = cache,
20556
- totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20557
- return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
20558
- }
20559
- return !1;
20605
+ fullSelection() {
20606
+ const currRt = this.currRt;
20607
+ if (!currRt) return;
20608
+ const cache = currRt.getFrameCache();
20609
+ if (!cache) return;
20610
+ const {
20611
+ lines: lines
20612
+ } = cache;
20613
+ if (!lines.length || !lines[0].paragraphs.length) return;
20614
+ const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20615
+ this.selectionRange(-.1, totalCursorCount + .1);
20560
20616
  }
20561
- directKey(e) {
20617
+ fullSelectionKeyHandler(e) {
20618
+ return !!(application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) && (this.fullSelection(), e.preventDefault(), !0);
20619
+ }
20620
+ directKeyHandler(e) {
20562
20621
  if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
20563
20622
  const cache = this.currRt.getFrameCache();
20564
20623
  if (!cache) return !1;
@@ -20611,7 +20670,7 @@ class RichTextEditPlugin {
20611
20670
  }
20612
20671
  const {
20613
20672
  textConfig: textConfig,
20614
- editOptions: editOptions
20673
+ editOptions = {}
20615
20674
  } = this.currRt.attribute;
20616
20675
  if (textConfig && textConfig.length) return;
20617
20676
  if (!editOptions || !editOptions.placeholder) return;
@@ -20628,11 +20687,23 @@ class RichTextEditPlugin {
20628
20687
  placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
20629
20688
  x: 0,
20630
20689
  y: 0,
20690
+ dx: -this.deltaX,
20691
+ dy: -this.deltaY,
20631
20692
  angle: 0,
20632
- _debug_bounds: !1,
20633
20693
  textConfig: [textConfigItem]
20634
20694
  })), shadow.add(this.shadowPlaceHolder);
20635
20695
  }
20696
+ getRichTextAABBBounds(rt) {
20697
+ const {
20698
+ attribute: attribute
20699
+ } = rt;
20700
+ return attribute.textConfig.length ? rt.AABBBounds : getRichTextBounds(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), {
20701
+ x: attribute.x,
20702
+ y: attribute.y,
20703
+ textAlign: attribute.textAlign,
20704
+ boundsMode: "accurate"
20705
+ }));
20706
+ }
20636
20707
  tryShowInputBounds() {
20637
20708
  if (!this.currRt || !this.focusing) return;
20638
20709
  const {
@@ -20642,28 +20713,20 @@ class RichTextEditPlugin {
20642
20713
  boundsStrokeWhenInput: boundsStrokeWhenInput
20643
20714
  } = editOptions;
20644
20715
  if (!editOptions || !boundsStrokeWhenInput) return;
20645
- const {
20646
- attribute: attribute
20647
- } = this.currRt,
20648
- b = this.currRt.AABBBounds;
20649
- let h = b.height();
20650
- if (!attribute.textConfig.length && this.editLine) {
20651
- const {
20652
- points: points
20653
- } = this.editLine.attribute;
20654
- h = points[1].y - points[0].y;
20655
- }
20716
+ const b = this.getRichTextAABBBounds(this.currRt),
20717
+ height = b.height(),
20718
+ width = b.width();
20656
20719
  this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
20657
20720
  x: 0,
20658
20721
  y: 0,
20659
- width: b.width(),
20660
- height: h,
20722
+ width: width,
20723
+ height: height,
20661
20724
  fill: !1,
20662
20725
  stroke: boundsStrokeWhenInput,
20663
20726
  lineWidth: 1,
20664
20727
  zIndex: -1
20665
20728
  });
20666
- this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
20729
+ this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20667
20730
  }
20668
20731
  trySyncPlaceholderToTextConfig() {
20669
20732
  if (!this.currRt) return;
@@ -20672,7 +20735,7 @@ class RichTextEditPlugin {
20672
20735
  editOptions: editOptions
20673
20736
  } = this.currRt.attribute;
20674
20737
  if (textConfig && textConfig.length) return;
20675
- if (!editOptions || !editOptions.placeholder) return;
20738
+ if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) return;
20676
20739
  const {
20677
20740
  placeholder: placeholder
20678
20741
  } = editOptions;
@@ -20683,7 +20746,20 @@ class RichTextEditPlugin {
20683
20746
  });
20684
20747
  }
20685
20748
  deactivate(context) {
20686
- 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);
20749
+ context.stage.off("pointermove", this.handleMove, {
20750
+ capture: !0
20751
+ }), context.stage.off("pointerdown", this.handlePointerDown, {
20752
+ capture: !0
20753
+ }), context.stage.off("pointerup", this.handlePointerUp, {
20754
+ capture: !0
20755
+ }), context.stage.off("pointerleave", this.handlePointerUp, {
20756
+ capture: !0
20757
+ }), context.stage.off("dblclick", this.handleDBLClick, {
20758
+ capture: !0
20759
+ }), application.global.addEventListener("keydown", this.handleKeyDown);
20760
+ }
20761
+ stopPropagation(e) {
20762
+ e.stopPropagation();
20687
20763
  }
20688
20764
  onFocus(e, data) {
20689
20765
  this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
@@ -20692,54 +20768,66 @@ class RichTextEditPlugin {
20692
20768
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
20693
20769
  const shadowRoot = this.getShadow(target),
20694
20770
  cache = target.getFrameCache();
20695
- if (cache) {
20696
- if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20697
- shadowRootIdx: 1,
20698
- pickable: !1,
20699
- x: this.deltaX,
20700
- y: this.deltaY
20701
- }), !this.editLine) {
20702
- const line = createLine({
20703
- x: 0,
20704
- y: 0,
20705
- lineWidth: 1,
20706
- stroke: "black"
20707
- });
20708
- this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20709
- const g = createGroup({
20710
- x: 0,
20711
- y: 0,
20712
- width: 0,
20713
- height: 0
20714
- });
20715
- this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20716
- }
20717
- if (data = data || this.computedCursorPosByEvent(e, cache)) {
20718
- const {
20719
- x: x,
20720
- y1: y1,
20721
- y2: y2,
20722
- cursorIndex: cursorIndex
20723
- } = data;
20724
- this.startCursorPos = {
20725
- x: x,
20726
- y: (y1 + y2) / 2
20727
- }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20728
- } else {
20729
- const x = 0,
20730
- y1 = 0,
20731
- y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20732
- textConfig: [{
20733
- text: "a"
20734
- }]
20735
- })).height();
20736
- this.startCursorPos = {
20737
- x: x,
20738
- y: (y1 + y2) / 2
20739
- }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20740
- }
20741
- this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20771
+ if (!cache) return;
20772
+ const {
20773
+ editOptions = {}
20774
+ } = this.currRt.attribute;
20775
+ if (editOptions.stopPropagation && target.addEventListener("*", this.stopPropagation), this.offsetShadowRoot(target), !this.editLine) {
20776
+ const line = createLine({
20777
+ x: 0,
20778
+ y: 0,
20779
+ lineWidth: 1,
20780
+ stroke: "black"
20781
+ });
20782
+ this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20783
+ const g = createGroup({
20784
+ x: 0,
20785
+ y: 0,
20786
+ width: 0,
20787
+ height: 0
20788
+ });
20789
+ this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20742
20790
  }
20791
+ if (data = data || this.computedCursorPosByEvent(e, cache)) {
20792
+ const {
20793
+ x: x,
20794
+ y1: y1,
20795
+ y2: y2,
20796
+ cursorIndex: cursorIndex
20797
+ } = data;
20798
+ this.startCursorPos = {
20799
+ x: x,
20800
+ y: (y1 + y2) / 2
20801
+ }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20802
+ } else {
20803
+ const x = 0,
20804
+ y1 = 0,
20805
+ y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20806
+ textConfig: [{
20807
+ text: "a"
20808
+ }]
20809
+ })).height();
20810
+ this.startCursorPos = {
20811
+ x: x,
20812
+ y: (y1 + y2) / 2
20813
+ }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20814
+ }
20815
+ this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20816
+ }
20817
+ offsetShadowRoot(rt) {
20818
+ if (!(rt = rt || this.currRt)) return;
20819
+ const shadowRoot = this.getShadow(rt);
20820
+ if (!shadowRoot) return;
20821
+ const cache = rt.getFrameCache();
20822
+ cache && (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20823
+ shadowRootIdx: 1,
20824
+ pickable: !1,
20825
+ x: this.deltaX,
20826
+ y: this.deltaY
20827
+ }), this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({
20828
+ dx: -this.deltaX,
20829
+ dy: -this.deltaY
20830
+ }));
20743
20831
  }
20744
20832
  offsetLineBgAndShadowBounds() {
20745
20833
  const rt = this.currRt,
@@ -20768,7 +20856,10 @@ class RichTextEditPlugin {
20768
20856
  }));
20769
20857
  const target = this.currRt;
20770
20858
  if (!target) return;
20771
- trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20859
+ const {
20860
+ editOptions = {}
20861
+ } = target.attribute;
20862
+ editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20772
20863
  const currRt = this.currRt;
20773
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;
20774
20865
  const textConfig = currRt.attribute.textConfig;
@@ -20929,7 +21020,7 @@ class RichTextEditPlugin {
20929
21020
  this.pluginService.stage.renderNextFrame();
20930
21021
  }
20931
21022
  computeGlobalDelta(cache) {
20932
- this.deltaX = 0, this.deltaY = 0;
21023
+ this.deltaX = 0, this.deltaY = 0, 0 === cache.lines.length && this.shadowPlaceHolder && (cache = this.shadowPlaceHolder.getFrameCache());
20933
21024
  const height = cache.height,
20934
21025
  actualHeight = cache.actualHeight,
20935
21026
  width = cache.lines.reduce((w, item) => Math.max(w, item.actualWidth), 0);
@@ -20976,7 +21067,7 @@ class RichTextEditPlugin {
20976
21067
  left: left,
20977
21068
  top: top
20978
21069
  } = this.pluginService.stage.window.getBoundingClientRect();
20979
- out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
21070
+ out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
20980
21071
  }
20981
21072
  computedCursorPosByEvent(e, cache) {
20982
21073
  const p1 = this.getEventPosition(e),
@@ -26333,6 +26424,7 @@ class PickerBase {
26333
26424
  contains(graphic, point, params) {
26334
26425
  if (!graphic.AABBBounds.containsPoint(point)) return !1;
26335
26426
  if ("imprecise" === graphic.attribute.pickMode) return !0;
26427
+ if (!this.canvasRenderer) return !0;
26336
26428
  const {
26337
26429
  pickContext: pickContext
26338
26430
  } = null != params ? params : {};
@@ -31135,7 +31227,7 @@ const registerWrapText = _registerWrapText;
31135
31227
 
31136
31228
  const roughModule = _roughModule;
31137
31229
 
31138
- const version = "0.22.0-vstory.12";
31230
+ const version = "0.22.0-vstory.14";
31139
31231
  preLoadAllModule();
31140
31232
  if (isBrowserEnv()) {
31141
31233
  loadBrowserEnv(container);