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