@visactor/vrender 0.22.7-alpha.5 → 0.22.7-alpha.6

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.7-alpha.5";
2
+ export declare const version = "0.22.7-alpha.6";
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.7-alpha.5", (0, vrender_core_1.preLoadAllModule)(), (0,
24
+ exports.version = "0.22.7-alpha.6", (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,gBAAgB,CAAC;AAExC,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.7-alpha.5\";\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,gBAAgB,CAAC;AAExC,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.7-alpha.6\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
package/dist/index.es.js CHANGED
@@ -4724,7 +4724,6 @@ function applyStrokeStyle(ctx, character) {
4724
4724
  ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
4725
4725
  }
4726
4726
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
4727
- if (desc.length <= 1) return 0;
4728
4727
  if (!width || width <= 0) return 0;
4729
4728
  const textMeasure = application.graphicUtil.textMeasure;
4730
4729
  let index = guessIndex,
@@ -4768,13 +4767,6 @@ function testLetter2(string, index) {
4768
4767
  }
4769
4768
  function measureTextCanvas(text, character) {
4770
4769
  let mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "actual";
4771
- var _a;
4772
- if ("" === text) return {
4773
- ascent: 0,
4774
- height: 0,
4775
- descent: 0,
4776
- width: 0
4777
- };
4778
4770
  const measurement = application.graphicUtil.textMeasure.measureText(text, character),
4779
4771
  result = {
4780
4772
  ascent: 0,
@@ -4784,9 +4776,7 @@ function measureTextCanvas(text, character) {
4784
4776
  },
4785
4777
  ascent = "actual" === mode ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent,
4786
4778
  descent = "actual" === mode ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;
4787
- "number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent), result.descent = result.height - result.ascent);
4788
- const space = null !== (_a = character.space) && void 0 !== _a ? _a : 0;
4789
- return result.width += space, result;
4779
+ return "number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent), result.descent = result.height - result.ascent), result;
4790
4780
  }
4791
4781
 
4792
4782
  var __decorate$1K = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -6424,7 +6414,7 @@ class FederatedEvent {
6424
6414
  }
6425
6415
  _composedDetailPath(params) {
6426
6416
  if (params && params.graphic) {
6427
- const g = params.graphic;
6417
+ const g = this.pickParams.graphic;
6428
6418
  if (g.stage) {
6429
6419
  const path = g.stage.eventSystem.manager.propagationPath(g);
6430
6420
  this.detailPath.push(path), this._composedDetailPath(params.params);
@@ -13988,7 +13978,6 @@ function getFixedLRTB(left, right, top, bottom) {
13988
13978
  }
13989
13979
  class Paragraph {
13990
13980
  constructor(text, newLine, character, ascentDescentMode) {
13991
- var _a, _b;
13992
13981
  this.fontSize = character.fontSize || 16, this.textBaseline = character.textBaseline || "alphabetic", this.ascentDescentMode = ascentDescentMode;
13993
13982
  const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
13994
13983
  this.lineHeight = "number" == typeof lineHeight ? lineHeight > this.fontSize ? lineHeight : this.fontSize : Math.floor(1.2 * this.fontSize), this.height = this.lineHeight;
@@ -14001,7 +13990,7 @@ class Paragraph {
14001
13990
  let halfDetaHeight = 0,
14002
13991
  deltaAscent = 0,
14003
13992
  deltaDescent = 0;
14004
- this.height > height && (halfDetaHeight = (this.height - height) / 2, deltaAscent = Math.ceil(halfDetaHeight), deltaDescent = Math.floor(halfDetaHeight)), "top" === this.textBaseline ? (this.ascent = halfDetaHeight, this.descent = height - halfDetaHeight) : "bottom" === this.textBaseline ? (this.ascent = height - halfDetaHeight, this.descent = halfDetaHeight) : "middle" === this.textBaseline ? (this.ascent = this.height / 2, this.descent = this.height / 2) : (this.ascent = ascent + deltaAscent, this.descent = descent + deltaDescent), this.length = text.length, this.width = width || 0, this.text = text || "", this.newLine = newLine || !1, this.character = character, this.left = 0, this.top = 0, this.ellipsis = "normal", this.ellipsisWidth = 0, this.ellipsisOtherParagraphWidth = 0, this.space = character.space, this.dx = null !== (_a = character.dx) && void 0 !== _a ? _a : 0, this.dy = null !== (_b = character.dy) && void 0 !== _b ? _b : 0, "vertical" === character.direction && (this.direction = character.direction, this.widthOrigin = this.width, this.heightOrigin = this.height, this.width = this.heightOrigin, this.height = this.widthOrigin, this.lineHeight = this.height), this.ellipsisStr = "...";
13993
+ this.height > height && (halfDetaHeight = (this.height - height) / 2, deltaAscent = Math.ceil(halfDetaHeight), deltaDescent = Math.floor(halfDetaHeight)), "top" === this.textBaseline ? (this.ascent = halfDetaHeight, this.descent = height - halfDetaHeight) : "bottom" === this.textBaseline ? (this.ascent = height - halfDetaHeight, this.descent = halfDetaHeight) : "middle" === this.textBaseline ? (this.ascent = this.height / 2, this.descent = this.height / 2) : (this.ascent = ascent + deltaAscent, this.descent = descent + deltaDescent), this.length = text.length, this.width = width || 0, this.text = text || "", this.newLine = newLine || !1, this.character = character, this.left = 0, this.top = 0, this.ellipsis = "normal", this.ellipsisWidth = 0, this.ellipsisOtherParagraphWidth = 0, "vertical" === character.direction && (this.direction = character.direction, this.widthOrigin = this.width, this.heightOrigin = this.height, this.width = this.heightOrigin, this.height = this.widthOrigin, this.lineHeight = this.height), this.ellipsisStr = "...";
14005
13994
  }
14006
13995
  updateWidth() {
14007
13996
  const {
@@ -14020,11 +14009,11 @@ class Paragraph {
14020
14009
  if ("hide" === this.ellipsis) return;
14021
14010
  if ("add" === this.ellipsis) text += this.ellipsisStr, "right" !== textAlign && "end" !== textAlign || (left -= this.ellipsisWidth);else if ("replace" === this.ellipsis) {
14022
14011
  const index = getStrByWithCanvas(text, ("vertical" === direction ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
14023
- if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) if ("vertical" === direction) ;else {
14012
+ if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) {
14024
14013
  const {
14025
14014
  width: width
14026
14015
  } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
14027
- left -= this.ellipsisWidth - width;
14016
+ "vertical" === direction || (left -= this.ellipsisWidth - width);
14028
14017
  }
14029
14018
  }
14030
14019
  }
@@ -14035,21 +14024,20 @@ class Paragraph {
14035
14024
  });
14036
14025
  }
14037
14026
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
14038
- var _a;
14039
14027
  let baseline = top + ascent,
14040
14028
  text = this.text,
14041
- left = this.left + deltaLeft + (null !== (_a = this.space) && void 0 !== _a ? _a : 0) / 2;
14029
+ left = this.left + deltaLeft;
14042
14030
  baseline += this.top;
14043
14031
  let direction = this.direction;
14044
14032
  if (this.verticalEllipsis) text = this.ellipsisStr, direction = "vertical", baseline -= this.ellipsisWidth / 2;else {
14045
14033
  if ("hide" === this.ellipsis) return;
14046
14034
  if ("add" === this.ellipsis) text += this.ellipsisStr, "right" !== textAlign && "end" !== textAlign || (left -= this.ellipsisWidth);else if ("replace" === this.ellipsis) {
14047
14035
  const index = getStrByWithCanvas(text, ("vertical" === direction ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
14048
- if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) if ("vertical" === direction) ;else {
14036
+ if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) {
14049
14037
  const {
14050
14038
  width: width
14051
14039
  } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
14052
- left -= this.ellipsisWidth - width;
14040
+ "vertical" === direction || (left -= this.ellipsisWidth - width);
14053
14041
  }
14054
14042
  }
14055
14043
  }
@@ -14064,7 +14052,7 @@ class Paragraph {
14064
14052
  const {
14065
14053
  lineWidth = 1
14066
14054
  } = this.character;
14067
- if (this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline + this.dy), this.character.fill && ctx.fillText(text, left, baseline + this.dy), this.character.fill) if (this.character.lineThrough || this.character.underline) {
14055
+ if (this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill) if (this.character.lineThrough || this.character.underline) {
14068
14056
  if (this.character.underline) {
14069
14057
  const top = 1 + baseline,
14070
14058
  lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1));
@@ -20489,11 +20477,10 @@ function getDefaultCharacterConfig(attribute) {
20489
20477
  };
20490
20478
  }
20491
20479
  function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
20492
- var _a;
20493
20480
  if (cursorIndex < 0) return 0;
20494
20481
  const intCursorIndex = Math.round(cursorIndex);
20495
20482
  let tempCursorIndex = intCursorIndex,
20496
- lineBreak = "\n" === (null === (_a = null == textConfig ? void 0 : textConfig[0]) || void 0 === _a ? void 0 : _a.text),
20483
+ lineBreak = !1,
20497
20484
  configIdx = 0;
20498
20485
  for (configIdx = 0; configIdx < textConfig.length && tempCursorIndex >= 0; configIdx++) {
20499
20486
  "\n" === textConfig[configIdx].text ? (tempCursorIndex -= Number(lineBreak), lineBreak = !0) : (tempCursorIndex--, lineBreak = !1);
@@ -20501,27 +20488,26 @@ function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
20501
20488
  return tempCursorIndex >= 0 ? textConfig.length : (configIdx -= 1, cursorIndex > intCursorIndex && !lineBreak && (configIdx += 1), configIdx);
20502
20489
  }
20503
20490
  function findCursorIdxByConfigIndex(textConfig, configIndex) {
20504
- var _a, _b, _c, _d;
20491
+ var _a, _b, _c;
20505
20492
  let cursorIndex = 0;
20506
20493
  if (configIndex < 0) return -.1;
20507
- let lastLineBreak = "\n" === (null === (_a = null == textConfig ? void 0 : textConfig[0]) || void 0 === _a ? void 0 : _a.text);
20494
+ let lastLineBreak = !1;
20508
20495
  for (let i = 0; i <= configIndex && i < textConfig.length; i++) {
20509
20496
  "\n" === textConfig[i].text ? (cursorIndex += Number(lastLineBreak), lastLineBreak = !0) : (cursorIndex++, lastLineBreak = !1);
20510
20497
  }
20511
- if (cursorIndex = Math.max(cursorIndex - 1, 0), configIndex > textConfig.length - 1) return "\n" === (null === (_b = textConfig[textConfig.length - 1]) || void 0 === _b ? void 0 : _b.text) ? cursorIndex + .9 : cursorIndex + .1;
20512
- const lineBreak = "\n" === (null === (_c = textConfig[configIndex]) || void 0 === _c ? void 0 : _c.text);
20498
+ if (cursorIndex = Math.max(cursorIndex - 1, 0), configIndex > textConfig.length - 1) return "\n" === (null === (_a = textConfig[textConfig.length - 1]) || void 0 === _a ? void 0 : _a.text) ? cursorIndex + .9 : cursorIndex + .1;
20499
+ const lineBreak = "\n" === (null === (_b = textConfig[configIndex]) || void 0 === _b ? void 0 : _b.text);
20513
20500
  if (configIndex >= textConfig.length - 1 && lineBreak) return cursorIndex + 1 - .1;
20514
- return cursorIndex -= .1, lineBreak && "\n" !== (null === (_d = textConfig[configIndex - 1]) || void 0 === _d ? void 0 : _d.text) && (cursorIndex += .2), cursorIndex;
20501
+ return cursorIndex -= .1, lineBreak && "\n" !== (null === (_c = textConfig[configIndex - 1]) || void 0 === _c ? void 0 : _c.text) && (cursorIndex += .2), cursorIndex;
20515
20502
  }
20516
20503
  class EditModule {
20517
20504
  constructor(container) {
20518
20505
  this.handleFocusIn = () => {}, this.handleFocusOut = () => {}, this.handleKeyDown = e => {
20519
- this.currRt && ("Delete" !== e.key && "Backspace" !== e.key || this.handleInput({
20506
+ "Delete" !== e.key && "Backspace" !== e.key || this.handleInput({
20520
20507
  data: null,
20521
20508
  type: "Backspace"
20522
- }));
20509
+ });
20523
20510
  }, this.handleCompositionStart = () => {
20524
- if (!this.currRt) return;
20525
20511
  this.isComposing = !0;
20526
20512
  const {
20527
20513
  textConfig = []
@@ -20604,7 +20590,6 @@ class EditModule {
20604
20590
  }
20605
20591
  parseCompositionStr(configIdx) {
20606
20592
  var _a;
20607
- if (!this.currRt) return "";
20608
20593
  const {
20609
20594
  textConfig = []
20610
20595
  } = this.currRt.attribute,
@@ -21095,7 +21080,7 @@ class RichTextEditPlugin {
21095
21080
  const {
21096
21081
  editOptions = {}
21097
21082
  } = currRt.attribute;
21098
- editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null, this.editModule.currRt = null;
21083
+ editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null;
21099
21084
  const shadowRoot = this.getShadow(currRt);
21100
21085
  this.editLine && (this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot), this.editLine.release(), this.editLine = null, this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1, currRt.removeEventListener("pointerleave", this.handleLeave);
21101
21086
  }
@@ -31649,7 +31634,7 @@ function particleEffect(ctx, row, column, rowCount, columnCount, ratio, graphic)
31649
31634
 
31650
31635
  const roughModule = _roughModule;
31651
31636
 
31652
- const version = "0.22.7-alpha.5";
31637
+ const version = "0.22.7-alpha.6";
31653
31638
  preLoadAllModule();
31654
31639
  if (isBrowserEnv()) {
31655
31640
  loadBrowserEnv(container);
package/dist/index.js CHANGED
@@ -4730,7 +4730,6 @@
4730
4730
  ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
4731
4731
  }
4732
4732
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
4733
- if (desc.length <= 1) return 0;
4734
4733
  if (!width || width <= 0) return 0;
4735
4734
  const textMeasure = application.graphicUtil.textMeasure;
4736
4735
  let index = guessIndex,
@@ -4774,13 +4773,6 @@
4774
4773
  }
4775
4774
  function measureTextCanvas(text, character) {
4776
4775
  let mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "actual";
4777
- var _a;
4778
- if ("" === text) return {
4779
- ascent: 0,
4780
- height: 0,
4781
- descent: 0,
4782
- width: 0
4783
- };
4784
4776
  const measurement = application.graphicUtil.textMeasure.measureText(text, character),
4785
4777
  result = {
4786
4778
  ascent: 0,
@@ -4790,9 +4782,7 @@
4790
4782
  },
4791
4783
  ascent = "actual" === mode ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent,
4792
4784
  descent = "actual" === mode ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;
4793
- "number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent), result.descent = result.height - result.ascent);
4794
- const space = null !== (_a = character.space) && void 0 !== _a ? _a : 0;
4795
- return result.width += space, result;
4785
+ return "number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent), result.descent = result.height - result.ascent), result;
4796
4786
  }
4797
4787
 
4798
4788
  var __decorate$1K = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -6430,7 +6420,7 @@
6430
6420
  }
6431
6421
  _composedDetailPath(params) {
6432
6422
  if (params && params.graphic) {
6433
- const g = params.graphic;
6423
+ const g = this.pickParams.graphic;
6434
6424
  if (g.stage) {
6435
6425
  const path = g.stage.eventSystem.manager.propagationPath(g);
6436
6426
  this.detailPath.push(path), this._composedDetailPath(params.params);
@@ -13994,7 +13984,6 @@
13994
13984
  }
13995
13985
  class Paragraph {
13996
13986
  constructor(text, newLine, character, ascentDescentMode) {
13997
- var _a, _b;
13998
13987
  this.fontSize = character.fontSize || 16, this.textBaseline = character.textBaseline || "alphabetic", this.ascentDescentMode = ascentDescentMode;
13999
13988
  const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
14000
13989
  this.lineHeight = "number" == typeof lineHeight ? lineHeight > this.fontSize ? lineHeight : this.fontSize : Math.floor(1.2 * this.fontSize), this.height = this.lineHeight;
@@ -14007,7 +13996,7 @@
14007
13996
  let halfDetaHeight = 0,
14008
13997
  deltaAscent = 0,
14009
13998
  deltaDescent = 0;
14010
- this.height > height && (halfDetaHeight = (this.height - height) / 2, deltaAscent = Math.ceil(halfDetaHeight), deltaDescent = Math.floor(halfDetaHeight)), "top" === this.textBaseline ? (this.ascent = halfDetaHeight, this.descent = height - halfDetaHeight) : "bottom" === this.textBaseline ? (this.ascent = height - halfDetaHeight, this.descent = halfDetaHeight) : "middle" === this.textBaseline ? (this.ascent = this.height / 2, this.descent = this.height / 2) : (this.ascent = ascent + deltaAscent, this.descent = descent + deltaDescent), this.length = text.length, this.width = width || 0, this.text = text || "", this.newLine = newLine || !1, this.character = character, this.left = 0, this.top = 0, this.ellipsis = "normal", this.ellipsisWidth = 0, this.ellipsisOtherParagraphWidth = 0, this.space = character.space, this.dx = null !== (_a = character.dx) && void 0 !== _a ? _a : 0, this.dy = null !== (_b = character.dy) && void 0 !== _b ? _b : 0, "vertical" === character.direction && (this.direction = character.direction, this.widthOrigin = this.width, this.heightOrigin = this.height, this.width = this.heightOrigin, this.height = this.widthOrigin, this.lineHeight = this.height), this.ellipsisStr = "...";
13999
+ this.height > height && (halfDetaHeight = (this.height - height) / 2, deltaAscent = Math.ceil(halfDetaHeight), deltaDescent = Math.floor(halfDetaHeight)), "top" === this.textBaseline ? (this.ascent = halfDetaHeight, this.descent = height - halfDetaHeight) : "bottom" === this.textBaseline ? (this.ascent = height - halfDetaHeight, this.descent = halfDetaHeight) : "middle" === this.textBaseline ? (this.ascent = this.height / 2, this.descent = this.height / 2) : (this.ascent = ascent + deltaAscent, this.descent = descent + deltaDescent), this.length = text.length, this.width = width || 0, this.text = text || "", this.newLine = newLine || !1, this.character = character, this.left = 0, this.top = 0, this.ellipsis = "normal", this.ellipsisWidth = 0, this.ellipsisOtherParagraphWidth = 0, "vertical" === character.direction && (this.direction = character.direction, this.widthOrigin = this.width, this.heightOrigin = this.height, this.width = this.heightOrigin, this.height = this.widthOrigin, this.lineHeight = this.height), this.ellipsisStr = "...";
14011
14000
  }
14012
14001
  updateWidth() {
14013
14002
  const {
@@ -14026,11 +14015,11 @@
14026
14015
  if ("hide" === this.ellipsis) return;
14027
14016
  if ("add" === this.ellipsis) text += this.ellipsisStr, "right" !== textAlign && "end" !== textAlign || (left -= this.ellipsisWidth);else if ("replace" === this.ellipsis) {
14028
14017
  const index = getStrByWithCanvas(text, ("vertical" === direction ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
14029
- if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) if ("vertical" === direction) ;else {
14018
+ if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) {
14030
14019
  const {
14031
14020
  width: width
14032
14021
  } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
14033
- left -= this.ellipsisWidth - width;
14022
+ "vertical" === direction || (left -= this.ellipsisWidth - width);
14034
14023
  }
14035
14024
  }
14036
14025
  }
@@ -14041,21 +14030,20 @@
14041
14030
  });
14042
14031
  }
14043
14032
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
14044
- var _a;
14045
14033
  let baseline = top + ascent,
14046
14034
  text = this.text,
14047
- left = this.left + deltaLeft + (null !== (_a = this.space) && void 0 !== _a ? _a : 0) / 2;
14035
+ left = this.left + deltaLeft;
14048
14036
  baseline += this.top;
14049
14037
  let direction = this.direction;
14050
14038
  if (this.verticalEllipsis) text = this.ellipsisStr, direction = "vertical", baseline -= this.ellipsisWidth / 2;else {
14051
14039
  if ("hide" === this.ellipsis) return;
14052
14040
  if ("add" === this.ellipsis) text += this.ellipsisStr, "right" !== textAlign && "end" !== textAlign || (left -= this.ellipsisWidth);else if ("replace" === this.ellipsis) {
14053
14041
  const index = getStrByWithCanvas(text, ("vertical" === direction ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
14054
- if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) if ("vertical" === direction) ;else {
14042
+ if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) {
14055
14043
  const {
14056
14044
  width: width
14057
14045
  } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
14058
- left -= this.ellipsisWidth - width;
14046
+ "vertical" === direction || (left -= this.ellipsisWidth - width);
14059
14047
  }
14060
14048
  }
14061
14049
  }
@@ -14070,7 +14058,7 @@
14070
14058
  const {
14071
14059
  lineWidth = 1
14072
14060
  } = this.character;
14073
- if (this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline + this.dy), this.character.fill && ctx.fillText(text, left, baseline + this.dy), this.character.fill) if (this.character.lineThrough || this.character.underline) {
14061
+ if (this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill) if (this.character.lineThrough || this.character.underline) {
14074
14062
  if (this.character.underline) {
14075
14063
  const top = 1 + baseline,
14076
14064
  lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1));
@@ -20495,11 +20483,10 @@
20495
20483
  };
20496
20484
  }
20497
20485
  function findConfigIndexByCursorIdx(textConfig, cursorIndex) {
20498
- var _a;
20499
20486
  if (cursorIndex < 0) return 0;
20500
20487
  const intCursorIndex = Math.round(cursorIndex);
20501
20488
  let tempCursorIndex = intCursorIndex,
20502
- lineBreak = "\n" === (null === (_a = null == textConfig ? void 0 : textConfig[0]) || void 0 === _a ? void 0 : _a.text),
20489
+ lineBreak = !1,
20503
20490
  configIdx = 0;
20504
20491
  for (configIdx = 0; configIdx < textConfig.length && tempCursorIndex >= 0; configIdx++) {
20505
20492
  "\n" === textConfig[configIdx].text ? (tempCursorIndex -= Number(lineBreak), lineBreak = !0) : (tempCursorIndex--, lineBreak = !1);
@@ -20507,27 +20494,26 @@
20507
20494
  return tempCursorIndex >= 0 ? textConfig.length : (configIdx -= 1, cursorIndex > intCursorIndex && !lineBreak && (configIdx += 1), configIdx);
20508
20495
  }
20509
20496
  function findCursorIdxByConfigIndex(textConfig, configIndex) {
20510
- var _a, _b, _c, _d;
20497
+ var _a, _b, _c;
20511
20498
  let cursorIndex = 0;
20512
20499
  if (configIndex < 0) return -.1;
20513
- let lastLineBreak = "\n" === (null === (_a = null == textConfig ? void 0 : textConfig[0]) || void 0 === _a ? void 0 : _a.text);
20500
+ let lastLineBreak = !1;
20514
20501
  for (let i = 0; i <= configIndex && i < textConfig.length; i++) {
20515
20502
  "\n" === textConfig[i].text ? (cursorIndex += Number(lastLineBreak), lastLineBreak = !0) : (cursorIndex++, lastLineBreak = !1);
20516
20503
  }
20517
- if (cursorIndex = Math.max(cursorIndex - 1, 0), configIndex > textConfig.length - 1) return "\n" === (null === (_b = textConfig[textConfig.length - 1]) || void 0 === _b ? void 0 : _b.text) ? cursorIndex + .9 : cursorIndex + .1;
20518
- const lineBreak = "\n" === (null === (_c = textConfig[configIndex]) || void 0 === _c ? void 0 : _c.text);
20504
+ if (cursorIndex = Math.max(cursorIndex - 1, 0), configIndex > textConfig.length - 1) return "\n" === (null === (_a = textConfig[textConfig.length - 1]) || void 0 === _a ? void 0 : _a.text) ? cursorIndex + .9 : cursorIndex + .1;
20505
+ const lineBreak = "\n" === (null === (_b = textConfig[configIndex]) || void 0 === _b ? void 0 : _b.text);
20519
20506
  if (configIndex >= textConfig.length - 1 && lineBreak) return cursorIndex + 1 - .1;
20520
- return cursorIndex -= .1, lineBreak && "\n" !== (null === (_d = textConfig[configIndex - 1]) || void 0 === _d ? void 0 : _d.text) && (cursorIndex += .2), cursorIndex;
20507
+ return cursorIndex -= .1, lineBreak && "\n" !== (null === (_c = textConfig[configIndex - 1]) || void 0 === _c ? void 0 : _c.text) && (cursorIndex += .2), cursorIndex;
20521
20508
  }
20522
20509
  class EditModule {
20523
20510
  constructor(container) {
20524
20511
  this.handleFocusIn = () => {}, this.handleFocusOut = () => {}, this.handleKeyDown = e => {
20525
- this.currRt && ("Delete" !== e.key && "Backspace" !== e.key || this.handleInput({
20512
+ "Delete" !== e.key && "Backspace" !== e.key || this.handleInput({
20526
20513
  data: null,
20527
20514
  type: "Backspace"
20528
- }));
20515
+ });
20529
20516
  }, this.handleCompositionStart = () => {
20530
- if (!this.currRt) return;
20531
20517
  this.isComposing = !0;
20532
20518
  const {
20533
20519
  textConfig = []
@@ -20610,7 +20596,6 @@
20610
20596
  }
20611
20597
  parseCompositionStr(configIdx) {
20612
20598
  var _a;
20613
- if (!this.currRt) return "";
20614
20599
  const {
20615
20600
  textConfig = []
20616
20601
  } = this.currRt.attribute,
@@ -21101,7 +21086,7 @@
21101
21086
  const {
21102
21087
  editOptions = {}
21103
21088
  } = currRt.attribute;
21104
- editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null, this.editModule.currRt = null;
21089
+ editOptions.stopPropagation && currRt.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), currRt.detachShadow()), this.currRt = null;
21105
21090
  const shadowRoot = this.getShadow(currRt);
21106
21091
  this.editLine && (this.removeEditLineOrBgOrBounds(this.editLine, shadowRoot), this.editLine.release(), this.editLine = null, this.removeEditLineOrBgOrBounds(this.editBg, shadowRoot), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.removeEditLineOrBgOrBounds(this.shadowBounds, shadowRoot), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1, currRt.removeEventListener("pointerleave", this.handleLeave);
21107
21092
  }
@@ -31655,7 +31640,7 @@
31655
31640
 
31656
31641
  const roughModule = _roughModule;
31657
31642
 
31658
- const version = "0.22.7-alpha.5";
31643
+ const version = "0.22.7-alpha.6";
31659
31644
  preLoadAllModule();
31660
31645
  if (isBrowserEnv()) {
31661
31646
  loadBrowserEnv(container);