@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/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
  }
@@ -4152,6 +4155,7 @@
4152
4155
  texturePadding: 2,
4153
4156
  backgroundMode: "no-repeat",
4154
4157
  backgroundFit: !0,
4158
+ backgroundKeepAspectRatio: !1,
4155
4159
  backgroundClip: !0,
4156
4160
  backgroundScale: 1,
4157
4161
  backgroundOffsetX: 0,
@@ -4790,6 +4794,9 @@
4790
4794
  }
4791
4795
  compatibleMetrics(metrics, options) {
4792
4796
  if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4797
+ metrics = {
4798
+ width: metrics.width
4799
+ };
4793
4800
  const {
4794
4801
  ascent: ascent,
4795
4802
  descent: descent
@@ -4797,6 +4804,13 @@
4797
4804
  metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4798
4805
  }
4799
4806
  if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4807
+ metrics = {
4808
+ width: metrics.width,
4809
+ actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
4810
+ actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
4811
+ fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
4812
+ fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
4813
+ };
4800
4814
  const {
4801
4815
  left: left,
4802
4816
  right: right
@@ -14313,6 +14327,12 @@
14313
14327
  }
14314
14328
  }
14315
14329
 
14330
+ let supportIntl = !1;
14331
+ try {
14332
+ supportIntl = Intl && "function" == typeof Intl.Segmenter;
14333
+ } catch (e) {
14334
+ supportIntl = !1;
14335
+ }
14316
14336
  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
14337
  class RichText extends Graphic {
14318
14338
  constructor(params) {
@@ -14402,6 +14422,16 @@
14402
14422
  return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
14403
14423
  }
14404
14424
  static splitText(text) {
14425
+ if (supportIntl) {
14426
+ const segmenter = new Intl.Segmenter(void 0, {
14427
+ granularity: "grapheme"
14428
+ }),
14429
+ segments = [];
14430
+ for (const {
14431
+ segment: segment
14432
+ } of segmenter.segment(text)) segments.push(segment);
14433
+ return segments;
14434
+ }
14405
14435
  return Array.from(text);
14406
14436
  }
14407
14437
  static TransformTextConfig2SingleCharacter(textConfig) {
@@ -14417,14 +14447,14 @@
14417
14447
  }), tc;
14418
14448
  }
14419
14449
  updateAABBBounds(attribute, richtextTheme, aabbBounds) {
14420
- var _a, _b;
14450
+ var _a, _b, _c, _d;
14421
14451
  const {
14422
14452
  width = richtextTheme.width,
14423
14453
  height = richtextTheme.height,
14424
14454
  maxWidth = richtextTheme.maxWidth,
14425
14455
  maxHeight = richtextTheme.maxHeight,
14426
14456
  textAlign = richtextTheme.textAlign,
14427
- textBaseline = richtextTheme.textBaseline,
14457
+ verticalDirection = null !== (_b = null !== (_a = attribute.textBaseline) && void 0 !== _a ? _a : richtextTheme.textBaseline) && void 0 !== _b ? _b : richtextTheme.verticalDirection,
14428
14458
  editOptions: editOptions
14429
14459
  } = attribute;
14430
14460
  if (width > 0 && height > 0) aabbBounds.set(0, 0, width, height);else {
@@ -14437,9 +14467,9 @@
14437
14467
  contentHeight = height || actualHeight || 0;
14438
14468
  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
14469
  }
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);
14470
+ 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
14471
  let deltaY = 0;
14442
- switch (textBaseline) {
14472
+ switch (verticalDirection) {
14443
14473
  case "top":
14444
14474
  deltaY = 0;
14445
14475
  break;
@@ -15443,6 +15473,7 @@
15443
15473
  opacity = graphicAttribute.opacity,
15444
15474
  backgroundMode = graphicAttribute.backgroundMode,
15445
15475
  backgroundFit = graphicAttribute.backgroundFit,
15476
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15446
15477
  backgroundScale = graphicAttribute.backgroundScale,
15447
15478
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15448
15479
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
@@ -15464,6 +15495,7 @@
15464
15495
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, this.doDrawImage(context, res.data, b, {
15465
15496
  backgroundMode: backgroundMode,
15466
15497
  backgroundFit: backgroundFit,
15498
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15467
15499
  backgroundScale: backgroundScale,
15468
15500
  backgroundOffsetX: backgroundOffsetX,
15469
15501
  backgroundOffsetY: backgroundOffsetY
@@ -15474,6 +15506,7 @@
15474
15506
  const {
15475
15507
  backgroundMode: backgroundMode,
15476
15508
  backgroundFit: backgroundFit,
15509
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15477
15510
  backgroundScale = 1,
15478
15511
  backgroundOffsetX = 0,
15479
15512
  backgroundOffsetY = 0
@@ -15483,7 +15516,12 @@
15483
15516
  let w = targetW,
15484
15517
  h = targetH;
15485
15518
  if ("no-repeat" === backgroundMode) {
15486
- if (backgroundFit) context.drawImage(data, b.x1, b.y1, b.width(), b.height());else {
15519
+ if (backgroundFit) {
15520
+ if (backgroundKeepAspectRatio) {
15521
+ const maxScale = Math.max(targetW / data.width, targetH / data.height);
15522
+ context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
15523
+ } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
15524
+ } else {
15487
15525
  const resW = data.width * backgroundScale,
15488
15526
  resH = data.height * backgroundScale;
15489
15527
  context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
@@ -15789,6 +15827,7 @@
15789
15827
  background: background,
15790
15828
  backgroundMode = graphicAttribute.backgroundMode,
15791
15829
  backgroundFit = graphicAttribute.backgroundFit,
15830
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15792
15831
  backgroundScale = graphicAttribute.backgroundScale,
15793
15832
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15794
15833
  backgroundOffsetY = graphicAttribute.backgroundOffsetY
@@ -15801,6 +15840,7 @@
15801
15840
  this.doDrawImage(context, res.data, b, {
15802
15841
  backgroundMode: backgroundMode,
15803
15842
  backgroundFit: backgroundFit,
15843
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15804
15844
  backgroundScale: backgroundScale,
15805
15845
  backgroundOffsetX: backgroundOffsetX,
15806
15846
  backgroundOffsetY: backgroundOffsetY
@@ -17131,7 +17171,8 @@
17131
17171
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17132
17172
  const {
17133
17173
  backgroundMode = graphicAttribute.backgroundMode,
17134
- backgroundFit = graphicAttribute.backgroundFit
17174
+ backgroundFit = graphicAttribute.backgroundFit,
17175
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
17135
17176
  } = graphic.attribute;
17136
17177
  let matrix,
17137
17178
  {
@@ -17170,7 +17211,8 @@
17170
17211
  if ("success" !== res.state || !res.data) return void restore();
17171
17212
  context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
17172
17213
  backgroundMode: backgroundMode,
17173
- backgroundFit: backgroundFit
17214
+ backgroundFit: backgroundFit,
17215
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
17174
17216
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
17175
17217
  } else {
17176
17218
  const {
@@ -18305,7 +18347,7 @@
18305
18347
  };
18306
18348
  let DefaultDrawContribution = class {
18307
18349
  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();
18350
+ 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
18351
  }
18310
18352
  init() {
18311
18353
  this.contributions.forEach(item => {
@@ -20348,10 +20390,11 @@
20348
20390
  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
20391
  }
20350
20392
  parseCompositionStr(configIdx) {
20393
+ var _a;
20351
20394
  const {
20352
20395
  textConfig = []
20353
20396
  } = this.currRt.attribute,
20354
- lastConfig = textConfig[configIdx];
20397
+ lastConfig = null !== (_a = textConfig[configIdx]) && void 0 !== _a ? _a : {};
20355
20398
  textConfig.splice(configIdx, 1);
20356
20399
  const text = lastConfig.text,
20357
20400
  textList = text ? Array.from(text.toString()) : [];
@@ -20408,15 +20451,18 @@
20408
20451
  return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
20409
20452
  }
20410
20453
  getFormat(key) {
20411
- return this.getAllFormat(key)[0];
20454
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20455
+ return this.getAllFormat(key, supportOutAttr)[0];
20412
20456
  }
20413
20457
  getAllFormat(key) {
20458
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20459
+ var _a, _b, _c, _d;
20414
20460
  const valSet = new Set(),
20415
20461
  minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx),
20416
20462
  maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
20417
- if (minCursorIdx === maxCursorIdx) return [this._getFormat(key, minCursorIdx)];
20463
+ 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
20464
  for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
20419
- const val = this._getFormat(key, i);
20465
+ 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
20466
  val && valSet.add(val);
20421
20467
  }
20422
20468
  return Array.from(valSet.values());
@@ -20464,7 +20510,7 @@
20464
20510
  const config = rt.attribute.textConfig;
20465
20511
  this._formatTextCommand(payload, config, rt);
20466
20512
  }, this.handleKeyDown = e => {
20467
- this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelection(e) || this.directKey(e));
20513
+ this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelectionKeyHandler(e) || this.directKeyHandler(e));
20468
20514
  }, this.handleInput = (text, isComposing, cursorIdx, rt) => {
20469
20515
  this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(), this.updateCbs.forEach(cb => cb("input", this)));
20470
20516
  }, this.handleChange = (text, isComposing, cursorIdx, rt) => {
@@ -20477,7 +20523,9 @@
20477
20523
  }, this.handleFocusOut = () => {
20478
20524
  throw new Error("不会走到这里 handleFocusOut");
20479
20525
  }, this.handleMove = e => {
20480
- this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave), this.tryShowSelection(e, !1));
20526
+ this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
20527
+ capture: !0
20528
+ }), this.tryShowSelection(e, !1));
20481
20529
  }, this.handleEnter = e => {
20482
20530
  this.editing = !0, this.pluginService.stage.setCursor("text");
20483
20531
  }, this.handleLeave = e => {
@@ -20516,7 +20564,17 @@
20516
20564
  idx > -1 && cbs.splice(idx, 1);
20517
20565
  }
20518
20566
  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);
20567
+ this.pluginService = context, this.editModule = new EditModule(), context.stage.on("pointermove", this.handleMove, {
20568
+ capture: !0
20569
+ }), context.stage.on("pointerdown", this.handlePointerDown, {
20570
+ capture: !0
20571
+ }), context.stage.on("pointerup", this.handlePointerUp, {
20572
+ capture: !0
20573
+ }), context.stage.on("pointerleave", this.handlePointerUp, {
20574
+ capture: !0
20575
+ }), context.stage.on("dblclick", this.handleDBLClick, {
20576
+ capture: !0
20577
+ }), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
20520
20578
  }
20521
20579
  copyToClipboard(e) {
20522
20580
  if (application.global.isMacOS() && e.metaKey && "c" === e.key || !application.global.isMacOS() && e.ctrlKey && "c" === e.key) {
@@ -20550,21 +20608,22 @@
20550
20608
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
20551
20609
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
20552
20610
  }
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;
20611
+ fullSelection() {
20612
+ const currRt = this.currRt;
20613
+ if (!currRt) return;
20614
+ const cache = currRt.getFrameCache();
20615
+ if (!cache) return;
20616
+ const {
20617
+ lines: lines
20618
+ } = cache;
20619
+ if (!lines.length || !lines[0].paragraphs.length) return;
20620
+ const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20621
+ this.selectionRange(-.1, totalCursorCount + .1);
20566
20622
  }
20567
- directKey(e) {
20623
+ fullSelectionKeyHandler(e) {
20624
+ return !!(application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) && (this.fullSelection(), e.preventDefault(), !0);
20625
+ }
20626
+ directKeyHandler(e) {
20568
20627
  if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
20569
20628
  const cache = this.currRt.getFrameCache();
20570
20629
  if (!cache) return !1;
@@ -20617,7 +20676,7 @@
20617
20676
  }
20618
20677
  const {
20619
20678
  textConfig: textConfig,
20620
- editOptions: editOptions
20679
+ editOptions = {}
20621
20680
  } = this.currRt.attribute;
20622
20681
  if (textConfig && textConfig.length) return;
20623
20682
  if (!editOptions || !editOptions.placeholder) return;
@@ -20634,11 +20693,23 @@
20634
20693
  placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
20635
20694
  x: 0,
20636
20695
  y: 0,
20696
+ dx: -this.deltaX,
20697
+ dy: -this.deltaY,
20637
20698
  angle: 0,
20638
- _debug_bounds: !1,
20639
20699
  textConfig: [textConfigItem]
20640
20700
  })), shadow.add(this.shadowPlaceHolder);
20641
20701
  }
20702
+ getRichTextAABBBounds(rt) {
20703
+ const {
20704
+ attribute: attribute
20705
+ } = rt;
20706
+ return attribute.textConfig.length ? rt.AABBBounds : getRichTextBounds(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), {
20707
+ x: attribute.x,
20708
+ y: attribute.y,
20709
+ textAlign: attribute.textAlign,
20710
+ boundsMode: "accurate"
20711
+ }));
20712
+ }
20642
20713
  tryShowInputBounds() {
20643
20714
  if (!this.currRt || !this.focusing) return;
20644
20715
  const {
@@ -20648,28 +20719,20 @@
20648
20719
  boundsStrokeWhenInput: boundsStrokeWhenInput
20649
20720
  } = editOptions;
20650
20721
  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
- }
20722
+ const b = this.getRichTextAABBBounds(this.currRt),
20723
+ height = b.height(),
20724
+ width = b.width();
20662
20725
  this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
20663
20726
  x: 0,
20664
20727
  y: 0,
20665
- width: b.width(),
20666
- height: h,
20728
+ width: width,
20729
+ height: height,
20667
20730
  fill: !1,
20668
20731
  stroke: boundsStrokeWhenInput,
20669
20732
  lineWidth: 1,
20670
20733
  zIndex: -1
20671
20734
  });
20672
- this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
20735
+ this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20673
20736
  }
20674
20737
  trySyncPlaceholderToTextConfig() {
20675
20738
  if (!this.currRt) return;
@@ -20678,7 +20741,7 @@
20678
20741
  editOptions: editOptions
20679
20742
  } = this.currRt.attribute;
20680
20743
  if (textConfig && textConfig.length) return;
20681
- if (!editOptions || !editOptions.placeholder) return;
20744
+ if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) return;
20682
20745
  const {
20683
20746
  placeholder: placeholder
20684
20747
  } = editOptions;
@@ -20689,7 +20752,20 @@
20689
20752
  });
20690
20753
  }
20691
20754
  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);
20755
+ context.stage.off("pointermove", this.handleMove, {
20756
+ capture: !0
20757
+ }), context.stage.off("pointerdown", this.handlePointerDown, {
20758
+ capture: !0
20759
+ }), context.stage.off("pointerup", this.handlePointerUp, {
20760
+ capture: !0
20761
+ }), context.stage.off("pointerleave", this.handlePointerUp, {
20762
+ capture: !0
20763
+ }), context.stage.off("dblclick", this.handleDBLClick, {
20764
+ capture: !0
20765
+ }), application.global.addEventListener("keydown", this.handleKeyDown);
20766
+ }
20767
+ stopPropagation(e) {
20768
+ e.stopPropagation();
20693
20769
  }
20694
20770
  onFocus(e, data) {
20695
20771
  this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
@@ -20698,54 +20774,66 @@
20698
20774
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
20699
20775
  const shadowRoot = this.getShadow(target),
20700
20776
  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();
20777
+ if (!cache) return;
20778
+ const {
20779
+ editOptions = {}
20780
+ } = this.currRt.attribute;
20781
+ if (editOptions.stopPropagation && target.addEventListener("*", this.stopPropagation), this.offsetShadowRoot(target), !this.editLine) {
20782
+ const line = createLine({
20783
+ x: 0,
20784
+ y: 0,
20785
+ lineWidth: 1,
20786
+ stroke: "black"
20787
+ });
20788
+ this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20789
+ const g = createGroup({
20790
+ x: 0,
20791
+ y: 0,
20792
+ width: 0,
20793
+ height: 0
20794
+ });
20795
+ this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20748
20796
  }
20797
+ if (data = data || this.computedCursorPosByEvent(e, cache)) {
20798
+ const {
20799
+ x: x,
20800
+ y1: y1,
20801
+ y2: y2,
20802
+ cursorIndex: cursorIndex
20803
+ } = data;
20804
+ this.startCursorPos = {
20805
+ x: x,
20806
+ y: (y1 + y2) / 2
20807
+ }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20808
+ } else {
20809
+ const x = 0,
20810
+ y1 = 0,
20811
+ y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20812
+ textConfig: [{
20813
+ text: "a"
20814
+ }]
20815
+ })).height();
20816
+ this.startCursorPos = {
20817
+ x: x,
20818
+ y: (y1 + y2) / 2
20819
+ }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20820
+ }
20821
+ this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20822
+ }
20823
+ offsetShadowRoot(rt) {
20824
+ if (!(rt = rt || this.currRt)) return;
20825
+ const shadowRoot = this.getShadow(rt);
20826
+ if (!shadowRoot) return;
20827
+ const cache = rt.getFrameCache();
20828
+ cache && (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20829
+ shadowRootIdx: 1,
20830
+ pickable: !1,
20831
+ x: this.deltaX,
20832
+ y: this.deltaY
20833
+ }), this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({
20834
+ dx: -this.deltaX,
20835
+ dy: -this.deltaY
20836
+ }));
20749
20837
  }
20750
20838
  offsetLineBgAndShadowBounds() {
20751
20839
  const rt = this.currRt,
@@ -20774,7 +20862,10 @@
20774
20862
  }));
20775
20863
  const target = this.currRt;
20776
20864
  if (!target) return;
20777
- trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20865
+ const {
20866
+ editOptions = {}
20867
+ } = target.attribute;
20868
+ editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20778
20869
  const currRt = this.currRt;
20779
20870
  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
20871
  const textConfig = currRt.attribute.textConfig;
@@ -20935,7 +21026,7 @@
20935
21026
  this.pluginService.stage.renderNextFrame();
20936
21027
  }
20937
21028
  computeGlobalDelta(cache) {
20938
- this.deltaX = 0, this.deltaY = 0;
21029
+ this.deltaX = 0, this.deltaY = 0, 0 === cache.lines.length && this.shadowPlaceHolder && (cache = this.shadowPlaceHolder.getFrameCache());
20939
21030
  const height = cache.height,
20940
21031
  actualHeight = cache.actualHeight,
20941
21032
  width = cache.lines.reduce((w, item) => Math.max(w, item.actualWidth), 0);
@@ -20982,7 +21073,7 @@
20982
21073
  left: left,
20983
21074
  top: top
20984
21075
  } = 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);
21076
+ out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
20986
21077
  }
20987
21078
  computedCursorPosByEvent(e, cache) {
20988
21079
  const p1 = this.getEventPosition(e),
@@ -26339,6 +26430,7 @@
26339
26430
  contains(graphic, point, params) {
26340
26431
  if (!graphic.AABBBounds.containsPoint(point)) return !1;
26341
26432
  if ("imprecise" === graphic.attribute.pickMode) return !0;
26433
+ if (!this.canvasRenderer) return !0;
26342
26434
  const {
26343
26435
  pickContext: pickContext
26344
26436
  } = null != params ? params : {};
@@ -31141,7 +31233,7 @@
31141
31233
 
31142
31234
  const roughModule = _roughModule;
31143
31235
 
31144
- const version = "0.22.0-vstory.12";
31236
+ const version = "0.22.0-vstory.14";
31145
31237
  preLoadAllModule();
31146
31238
  if (isBrowserEnv()) {
31147
31239
  loadBrowserEnv(container);