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

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/dist/index.js CHANGED
@@ -437,12 +437,15 @@
437
437
  serviceIdentifier: injectIdentifier,
438
438
  constructorArgsMetadata: constructorArgsMetadata
439
439
  },
440
- request = {
440
+ bindings = (this._bindingDictionary.get(injectIdentifier) || []).filter(b => b.constraint(target));
441
+ if (bindings.length) {
442
+ const request = {
441
443
  injectIdentifier: injectIdentifier,
442
444
  metadata: constructorArgsMetadata,
443
- bindings: this._bindingDictionary.get(injectIdentifier).filter(b => b.constraint(target))
445
+ bindings: bindings
444
446
  };
445
- arr.push(request);
447
+ arr.push(request);
448
+ }
446
449
  }
447
450
  return arr;
448
451
  }
@@ -2497,6 +2500,8 @@
2497
2500
  return color.getLuminance2();
2498
2501
  case "lum3":
2499
2502
  return color.getLuminance3();
2503
+ case "wcag":
2504
+ return color.getLuminanceWCAG();
2500
2505
  }
2501
2506
  }
2502
2507
  static parseColorString(value) {
@@ -2598,6 +2603,14 @@
2598
2603
  getLuminance3() {
2599
2604
  return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
2600
2605
  }
2606
+ getLuminanceWCAG() {
2607
+ const RsRGB = this.color.r / 255,
2608
+ GsRGB = this.color.g / 255,
2609
+ BsRGB = this.color.b / 255;
2610
+ let R, G, B;
2611
+ 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);
2612
+ return .2126 * R + .7152 * G + .0722 * B;
2613
+ }
2601
2614
  clone() {
2602
2615
  return new Color(this.color.toString());
2603
2616
  }
@@ -4152,6 +4165,7 @@
4152
4165
  texturePadding: 2,
4153
4166
  backgroundMode: "no-repeat",
4154
4167
  backgroundFit: !0,
4168
+ backgroundKeepAspectRatio: !1,
4155
4169
  backgroundClip: !0,
4156
4170
  backgroundScale: 1,
4157
4171
  backgroundOffsetX: 0,
@@ -4790,6 +4804,9 @@
4790
4804
  }
4791
4805
  compatibleMetrics(metrics, options) {
4792
4806
  if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4807
+ metrics = {
4808
+ width: metrics.width
4809
+ };
4793
4810
  const {
4794
4811
  ascent: ascent,
4795
4812
  descent: descent
@@ -4797,6 +4814,13 @@
4797
4814
  metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4798
4815
  }
4799
4816
  if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4817
+ metrics = {
4818
+ width: metrics.width,
4819
+ actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
4820
+ actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
4821
+ fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
4822
+ fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
4823
+ };
4800
4824
  const {
4801
4825
  left: left,
4802
4826
  right: right
@@ -14313,6 +14337,12 @@
14313
14337
  }
14314
14338
  }
14315
14339
 
14340
+ let supportIntl = !1;
14341
+ try {
14342
+ supportIntl = Intl && "function" == typeof Intl.Segmenter;
14343
+ } catch (e) {
14344
+ supportIntl = !1;
14345
+ }
14316
14346
  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];
14317
14347
  class RichText extends Graphic {
14318
14348
  constructor(params) {
@@ -14402,6 +14432,16 @@
14402
14432
  return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
14403
14433
  }
14404
14434
  static splitText(text) {
14435
+ if (supportIntl) {
14436
+ const segmenter = new Intl.Segmenter(void 0, {
14437
+ granularity: "grapheme"
14438
+ }),
14439
+ segments = [];
14440
+ for (const {
14441
+ segment: segment
14442
+ } of segmenter.segment(text)) segments.push(segment);
14443
+ return segments;
14444
+ }
14405
14445
  return Array.from(text);
14406
14446
  }
14407
14447
  static TransformTextConfig2SingleCharacter(textConfig) {
@@ -14417,14 +14457,14 @@
14417
14457
  }), tc;
14418
14458
  }
14419
14459
  updateAABBBounds(attribute, richtextTheme, aabbBounds) {
14420
- var _a, _b;
14460
+ var _a, _b, _c, _d;
14421
14461
  const {
14422
14462
  width = richtextTheme.width,
14423
14463
  height = richtextTheme.height,
14424
14464
  maxWidth = richtextTheme.maxWidth,
14425
14465
  maxHeight = richtextTheme.maxHeight,
14426
14466
  textAlign = richtextTheme.textAlign,
14427
- textBaseline = richtextTheme.textBaseline,
14467
+ verticalDirection = null !== (_b = null !== (_a = attribute.textBaseline) && void 0 !== _a ? _a : richtextTheme.textBaseline) && void 0 !== _b ? _b : richtextTheme.verticalDirection,
14428
14468
  editOptions: editOptions
14429
14469
  } = attribute;
14430
14470
  if (width > 0 && height > 0) aabbBounds.set(0, 0, width, height);else {
@@ -14437,9 +14477,9 @@
14437
14477
  contentHeight = height || actualHeight || 0;
14438
14478
  contentHeight = "number" == typeof maxHeight && contentHeight > maxHeight ? maxHeight : contentHeight || 0, contentWidth = "number" == typeof maxWidth && contentWidth > maxWidth ? maxWidth : contentWidth || 0, aabbBounds.set(0, 0, contentWidth, contentHeight);
14439
14479
  }
14440
- 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);
14480
+ 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);
14441
14481
  let deltaY = 0;
14442
- switch (textBaseline) {
14482
+ switch (verticalDirection) {
14443
14483
  case "top":
14444
14484
  deltaY = 0;
14445
14485
  break;
@@ -14460,7 +14500,7 @@
14460
14500
  case "right":
14461
14501
  deltaX = -aabbBounds.width();
14462
14502
  }
14463
- 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;
14503
+ 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;
14464
14504
  }
14465
14505
  needUpdateTags(keys) {
14466
14506
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -15443,6 +15483,7 @@
15443
15483
  opacity = graphicAttribute.opacity,
15444
15484
  backgroundMode = graphicAttribute.backgroundMode,
15445
15485
  backgroundFit = graphicAttribute.backgroundFit,
15486
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15446
15487
  backgroundScale = graphicAttribute.backgroundScale,
15447
15488
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15448
15489
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
@@ -15464,6 +15505,7 @@
15464
15505
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, this.doDrawImage(context, res.data, b, {
15465
15506
  backgroundMode: backgroundMode,
15466
15507
  backgroundFit: backgroundFit,
15508
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15467
15509
  backgroundScale: backgroundScale,
15468
15510
  backgroundOffsetX: backgroundOffsetX,
15469
15511
  backgroundOffsetY: backgroundOffsetY
@@ -15474,6 +15516,7 @@
15474
15516
  const {
15475
15517
  backgroundMode: backgroundMode,
15476
15518
  backgroundFit: backgroundFit,
15519
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15477
15520
  backgroundScale = 1,
15478
15521
  backgroundOffsetX = 0,
15479
15522
  backgroundOffsetY = 0
@@ -15483,7 +15526,12 @@
15483
15526
  let w = targetW,
15484
15527
  h = targetH;
15485
15528
  if ("no-repeat" === backgroundMode) {
15486
- if (backgroundFit) context.drawImage(data, b.x1, b.y1, b.width(), b.height());else {
15529
+ if (backgroundFit) {
15530
+ if (backgroundKeepAspectRatio) {
15531
+ const maxScale = Math.max(targetW / data.width, targetH / data.height);
15532
+ context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
15533
+ } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
15534
+ } else {
15487
15535
  const resW = data.width * backgroundScale,
15488
15536
  resH = data.height * backgroundScale;
15489
15537
  context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
@@ -15789,6 +15837,7 @@
15789
15837
  background: background,
15790
15838
  backgroundMode = graphicAttribute.backgroundMode,
15791
15839
  backgroundFit = graphicAttribute.backgroundFit,
15840
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15792
15841
  backgroundScale = graphicAttribute.backgroundScale,
15793
15842
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15794
15843
  backgroundOffsetY = graphicAttribute.backgroundOffsetY
@@ -15801,6 +15850,7 @@
15801
15850
  this.doDrawImage(context, res.data, b, {
15802
15851
  backgroundMode: backgroundMode,
15803
15852
  backgroundFit: backgroundFit,
15853
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15804
15854
  backgroundScale: backgroundScale,
15805
15855
  backgroundOffsetX: backgroundOffsetX,
15806
15856
  backgroundOffsetY: backgroundOffsetY
@@ -17131,7 +17181,8 @@
17131
17181
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17132
17182
  const {
17133
17183
  backgroundMode = graphicAttribute.backgroundMode,
17134
- backgroundFit = graphicAttribute.backgroundFit
17184
+ backgroundFit = graphicAttribute.backgroundFit,
17185
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
17135
17186
  } = graphic.attribute;
17136
17187
  let matrix,
17137
17188
  {
@@ -17170,7 +17221,8 @@
17170
17221
  if ("success" !== res.state || !res.data) return void restore();
17171
17222
  context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
17172
17223
  backgroundMode: backgroundMode,
17173
- backgroundFit: backgroundFit
17224
+ backgroundFit: backgroundFit,
17225
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
17174
17226
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
17175
17227
  } else {
17176
17228
  const {
@@ -18305,7 +18357,7 @@
18305
18357
  };
18306
18358
  let DefaultDrawContribution = class {
18307
18359
  constructor(contributions, drawItemInterceptorContributions) {
18308
- 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();
18360
+ 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();
18309
18361
  }
18310
18362
  init() {
18311
18363
  this.contributions.forEach(item => {
@@ -20348,10 +20400,11 @@
20348
20400
  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);
20349
20401
  }
20350
20402
  parseCompositionStr(configIdx) {
20403
+ var _a;
20351
20404
  const {
20352
20405
  textConfig = []
20353
20406
  } = this.currRt.attribute,
20354
- lastConfig = textConfig[configIdx];
20407
+ lastConfig = null !== (_a = textConfig[configIdx]) && void 0 !== _a ? _a : {};
20355
20408
  textConfig.splice(configIdx, 1);
20356
20409
  const text = lastConfig.text,
20357
20410
  textList = text ? Array.from(text.toString()) : [];
@@ -20408,15 +20461,18 @@
20408
20461
  return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
20409
20462
  }
20410
20463
  getFormat(key) {
20411
- return this.getAllFormat(key)[0];
20464
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20465
+ return this.getAllFormat(key, supportOutAttr)[0];
20412
20466
  }
20413
20467
  getAllFormat(key) {
20468
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20469
+ var _a, _b, _c, _d;
20414
20470
  const valSet = new Set(),
20415
20471
  minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx),
20416
20472
  maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
20417
- if (minCursorIdx === maxCursorIdx) return [this._getFormat(key, minCursorIdx)];
20473
+ 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)];
20418
20474
  for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
20419
- const val = this._getFormat(key, i);
20475
+ 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);
20420
20476
  val && valSet.add(val);
20421
20477
  }
20422
20478
  return Array.from(valSet.values());
@@ -20464,7 +20520,7 @@
20464
20520
  const config = rt.attribute.textConfig;
20465
20521
  this._formatTextCommand(payload, config, rt);
20466
20522
  }, this.handleKeyDown = e => {
20467
- this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelection(e) || this.directKey(e));
20523
+ this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelectionKeyHandler(e) || this.directKeyHandler(e));
20468
20524
  }, this.handleInput = (text, isComposing, cursorIdx, rt) => {
20469
20525
  this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(), this.updateCbs.forEach(cb => cb("input", this)));
20470
20526
  }, this.handleChange = (text, isComposing, cursorIdx, rt) => {
@@ -20477,7 +20533,9 @@
20477
20533
  }, this.handleFocusOut = () => {
20478
20534
  throw new Error("不会走到这里 handleFocusOut");
20479
20535
  }, this.handleMove = e => {
20480
- this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave), this.tryShowSelection(e, !1));
20536
+ this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
20537
+ capture: !0
20538
+ }), this.tryShowSelection(e, !1));
20481
20539
  }, this.handleEnter = e => {
20482
20540
  this.editing = !0, this.pluginService.stage.setCursor("text");
20483
20541
  }, this.handleLeave = e => {
@@ -20516,7 +20574,17 @@
20516
20574
  idx > -1 && cbs.splice(idx, 1);
20517
20575
  }
20518
20576
  activate(context) {
20519
- 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);
20577
+ this.pluginService = context, this.editModule = new EditModule(), context.stage.on("pointermove", this.handleMove, {
20578
+ capture: !0
20579
+ }), context.stage.on("pointerdown", this.handlePointerDown, {
20580
+ capture: !0
20581
+ }), context.stage.on("pointerup", this.handlePointerUp, {
20582
+ capture: !0
20583
+ }), context.stage.on("pointerleave", this.handlePointerUp, {
20584
+ capture: !0
20585
+ }), context.stage.on("dblclick", this.handleDBLClick, {
20586
+ capture: !0
20587
+ }), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
20520
20588
  }
20521
20589
  copyToClipboard(e) {
20522
20590
  if (application.global.isMacOS() && e.metaKey && "c" === e.key || !application.global.isMacOS() && e.ctrlKey && "c" === e.key) {
@@ -20550,21 +20618,22 @@
20550
20618
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
20551
20619
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
20552
20620
  }
20553
- fullSelection(e) {
20554
- if (application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) {
20555
- const currRt = this.currRt;
20556
- if (!currRt) return;
20557
- const cache = currRt.getFrameCache();
20558
- if (!cache) return;
20559
- const {
20560
- lines: lines
20561
- } = cache,
20562
- totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20563
- return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
20564
- }
20565
- return !1;
20621
+ fullSelection() {
20622
+ const currRt = this.currRt;
20623
+ if (!currRt) return;
20624
+ const cache = currRt.getFrameCache();
20625
+ if (!cache) return;
20626
+ const {
20627
+ lines: lines
20628
+ } = cache;
20629
+ if (!lines.length || !lines[0].paragraphs.length) return;
20630
+ const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20631
+ this.selectionRange(-.1, totalCursorCount + .1);
20632
+ }
20633
+ fullSelectionKeyHandler(e) {
20634
+ return !!(application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) && (this.fullSelection(), e.preventDefault(), !0);
20566
20635
  }
20567
- directKey(e) {
20636
+ directKeyHandler(e) {
20568
20637
  if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
20569
20638
  const cache = this.currRt.getFrameCache();
20570
20639
  if (!cache) return !1;
@@ -20617,7 +20686,7 @@
20617
20686
  }
20618
20687
  const {
20619
20688
  textConfig: textConfig,
20620
- editOptions: editOptions
20689
+ editOptions = {}
20621
20690
  } = this.currRt.attribute;
20622
20691
  if (textConfig && textConfig.length) return;
20623
20692
  if (!editOptions || !editOptions.placeholder) return;
@@ -20634,11 +20703,23 @@
20634
20703
  placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
20635
20704
  x: 0,
20636
20705
  y: 0,
20706
+ dx: -this.deltaX,
20707
+ dy: -this.deltaY,
20637
20708
  angle: 0,
20638
- _debug_bounds: !1,
20639
20709
  textConfig: [textConfigItem]
20640
20710
  })), shadow.add(this.shadowPlaceHolder);
20641
20711
  }
20712
+ getRichTextAABBBounds(rt) {
20713
+ const {
20714
+ attribute: attribute
20715
+ } = rt;
20716
+ return attribute.textConfig.length ? rt.AABBBounds : getRichTextBounds(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), {
20717
+ x: attribute.x,
20718
+ y: attribute.y,
20719
+ textAlign: attribute.textAlign,
20720
+ boundsMode: "accurate"
20721
+ }));
20722
+ }
20642
20723
  tryShowInputBounds() {
20643
20724
  if (!this.currRt || !this.focusing) return;
20644
20725
  const {
@@ -20648,28 +20729,20 @@
20648
20729
  boundsStrokeWhenInput: boundsStrokeWhenInput
20649
20730
  } = editOptions;
20650
20731
  if (!editOptions || !boundsStrokeWhenInput) return;
20651
- const {
20652
- attribute: attribute
20653
- } = this.currRt,
20654
- b = this.currRt.AABBBounds;
20655
- let h = b.height();
20656
- if (!attribute.textConfig.length && this.editLine) {
20657
- const {
20658
- points: points
20659
- } = this.editLine.attribute;
20660
- h = points[1].y - points[0].y;
20661
- }
20732
+ const b = this.getRichTextAABBBounds(this.currRt),
20733
+ height = b.height(),
20734
+ width = b.width();
20662
20735
  this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
20663
20736
  x: 0,
20664
20737
  y: 0,
20665
- width: b.width(),
20666
- height: h,
20738
+ width: width,
20739
+ height: height,
20667
20740
  fill: !1,
20668
20741
  stroke: boundsStrokeWhenInput,
20669
20742
  lineWidth: 1,
20670
20743
  zIndex: -1
20671
20744
  });
20672
- this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
20745
+ this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20673
20746
  }
20674
20747
  trySyncPlaceholderToTextConfig() {
20675
20748
  if (!this.currRt) return;
@@ -20678,7 +20751,7 @@
20678
20751
  editOptions: editOptions
20679
20752
  } = this.currRt.attribute;
20680
20753
  if (textConfig && textConfig.length) return;
20681
- if (!editOptions || !editOptions.placeholder) return;
20754
+ if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) return;
20682
20755
  const {
20683
20756
  placeholder: placeholder
20684
20757
  } = editOptions;
@@ -20689,7 +20762,20 @@
20689
20762
  });
20690
20763
  }
20691
20764
  deactivate(context) {
20692
- 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);
20765
+ context.stage.off("pointermove", this.handleMove, {
20766
+ capture: !0
20767
+ }), context.stage.off("pointerdown", this.handlePointerDown, {
20768
+ capture: !0
20769
+ }), context.stage.off("pointerup", this.handlePointerUp, {
20770
+ capture: !0
20771
+ }), context.stage.off("pointerleave", this.handlePointerUp, {
20772
+ capture: !0
20773
+ }), context.stage.off("dblclick", this.handleDBLClick, {
20774
+ capture: !0
20775
+ }), application.global.addEventListener("keydown", this.handleKeyDown);
20776
+ }
20777
+ stopPropagation(e) {
20778
+ e.stopPropagation();
20693
20779
  }
20694
20780
  onFocus(e, data) {
20695
20781
  this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
@@ -20698,54 +20784,66 @@
20698
20784
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
20699
20785
  const shadowRoot = this.getShadow(target),
20700
20786
  cache = target.getFrameCache();
20701
- if (cache) {
20702
- if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20703
- shadowRootIdx: 1,
20704
- pickable: !1,
20705
- x: this.deltaX,
20706
- y: this.deltaY
20707
- }), !this.editLine) {
20708
- const line = createLine({
20709
- x: 0,
20710
- y: 0,
20711
- lineWidth: 1,
20712
- stroke: "black"
20713
- });
20714
- this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20715
- const g = createGroup({
20716
- x: 0,
20717
- y: 0,
20718
- width: 0,
20719
- height: 0
20720
- });
20721
- this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20722
- }
20723
- if (data = data || this.computedCursorPosByEvent(e, cache)) {
20724
- const {
20725
- x: x,
20726
- y1: y1,
20727
- y2: y2,
20728
- cursorIndex: cursorIndex
20729
- } = data;
20730
- this.startCursorPos = {
20731
- x: x,
20732
- y: (y1 + y2) / 2
20733
- }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20734
- } else {
20735
- const x = 0,
20736
- y1 = 0,
20737
- y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20738
- textConfig: [{
20739
- text: "a"
20740
- }]
20741
- })).height();
20742
- this.startCursorPos = {
20743
- x: x,
20744
- y: (y1 + y2) / 2
20745
- }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20746
- }
20747
- this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20787
+ if (!cache) return;
20788
+ const {
20789
+ editOptions = {}
20790
+ } = this.currRt.attribute;
20791
+ if (editOptions.stopPropagation && target.addEventListener("*", this.stopPropagation), this.offsetShadowRoot(target), !this.editLine) {
20792
+ const line = createLine({
20793
+ x: 0,
20794
+ y: 0,
20795
+ lineWidth: 1,
20796
+ stroke: "black"
20797
+ });
20798
+ this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20799
+ const g = createGroup({
20800
+ x: 0,
20801
+ y: 0,
20802
+ width: 0,
20803
+ height: 0
20804
+ });
20805
+ this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20806
+ }
20807
+ if (data = data || this.computedCursorPosByEvent(e, cache)) {
20808
+ const {
20809
+ x: x,
20810
+ y1: y1,
20811
+ y2: y2,
20812
+ cursorIndex: cursorIndex
20813
+ } = data;
20814
+ this.startCursorPos = {
20815
+ x: x,
20816
+ y: (y1 + y2) / 2
20817
+ }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20818
+ } else {
20819
+ const x = 0,
20820
+ y1 = 0,
20821
+ y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20822
+ textConfig: [{
20823
+ text: "a"
20824
+ }]
20825
+ })).height();
20826
+ this.startCursorPos = {
20827
+ x: x,
20828
+ y: (y1 + y2) / 2
20829
+ }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20748
20830
  }
20831
+ this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20832
+ }
20833
+ offsetShadowRoot(rt) {
20834
+ if (!(rt = rt || this.currRt)) return;
20835
+ const shadowRoot = this.getShadow(rt);
20836
+ if (!shadowRoot) return;
20837
+ const cache = rt.getFrameCache();
20838
+ cache && (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20839
+ shadowRootIdx: 1,
20840
+ pickable: !1,
20841
+ x: this.deltaX,
20842
+ y: this.deltaY
20843
+ }), this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({
20844
+ dx: -this.deltaX,
20845
+ dy: -this.deltaY
20846
+ }));
20749
20847
  }
20750
20848
  offsetLineBgAndShadowBounds() {
20751
20849
  const rt = this.currRt,
@@ -20774,7 +20872,10 @@
20774
20872
  }));
20775
20873
  const target = this.currRt;
20776
20874
  if (!target) return;
20777
- trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20875
+ const {
20876
+ editOptions = {}
20877
+ } = target.attribute;
20878
+ editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20778
20879
  const currRt = this.currRt;
20779
20880
  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;
20780
20881
  const textConfig = currRt.attribute.textConfig;
@@ -20935,7 +21036,7 @@
20935
21036
  this.pluginService.stage.renderNextFrame();
20936
21037
  }
20937
21038
  computeGlobalDelta(cache) {
20938
- this.deltaX = 0, this.deltaY = 0;
21039
+ this.deltaX = 0, this.deltaY = 0, 0 === cache.lines.length && this.shadowPlaceHolder && (cache = this.shadowPlaceHolder.getFrameCache());
20939
21040
  const height = cache.height,
20940
21041
  actualHeight = cache.actualHeight,
20941
21042
  width = cache.lines.reduce((w, item) => Math.max(w, item.actualWidth), 0);
@@ -20982,7 +21083,7 @@
20982
21083
  left: left,
20983
21084
  top: top
20984
21085
  } = this.pluginService.stage.window.getBoundingClientRect();
20985
- out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
21086
+ out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
20986
21087
  }
20987
21088
  computedCursorPosByEvent(e, cache) {
20988
21089
  const p1 = this.getEventPosition(e),
@@ -26339,6 +26440,7 @@
26339
26440
  contains(graphic, point, params) {
26340
26441
  if (!graphic.AABBBounds.containsPoint(point)) return !1;
26341
26442
  if ("imprecise" === graphic.attribute.pickMode) return !0;
26443
+ if (!this.canvasRenderer) return !0;
26342
26444
  const {
26343
26445
  pickContext: pickContext
26344
26446
  } = null != params ? params : {};
@@ -31141,7 +31243,7 @@
31141
31243
 
31142
31244
  const roughModule = _roughModule;
31143
31245
 
31144
- const version = "0.22.0-vstory.12";
31246
+ const version = "0.22.0-vstory.15";
31145
31247
  preLoadAllModule();
31146
31248
  if (isBrowserEnv()) {
31147
31249
  loadBrowserEnv(container);