@galacean/effects-plugin-rich-text 2.8.6 → 2.8.7
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/alipay.js +1 -1
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -1
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +14 -13
- package/dist/index.mjs.map +1 -1
- package/dist/rich-text-component.d.ts +1 -1
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -1
- package/dist/weapp.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player rich text plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.8.
|
|
6
|
+
* Version: v2.8.7
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -400,6 +400,7 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
|
|
|
400
400
|
|
|
401
401
|
var RichTextLayout = /*#__PURE__*/ function() {
|
|
402
402
|
function RichTextLayout(options) {
|
|
403
|
+
// TODO: width 和 height 新版富文本计算没有地方用到
|
|
403
404
|
this.width = 0;
|
|
404
405
|
this.height = 0;
|
|
405
406
|
var size = options.size, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? spec.TextOverflow.clip : _options_textOverflow, _options_textVerticalAlign = options.textVerticalAlign, textVerticalAlign = _options_textVerticalAlign === void 0 ? spec.TextVerticalAlign.middle : _options_textVerticalAlign, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? spec.TextAlignment.left : _options_textAlign, _options_letterSpace = options.letterSpace, letterSpace = _options_letterSpace === void 0 ? 0 : _options_letterSpace, _options_lineHeight = options.lineHeight, lineHeight = _options_lineHeight === void 0 ? 0.571 : _options_lineHeight, _options_wrapEnabled = options.wrapEnabled, wrapEnabled = _options_wrapEnabled === void 0 ? false : _options_wrapEnabled, _options_maxTextWidth = options.maxTextWidth, maxTextWidth = _options_maxTextWidth === void 0 ? 350 : _options_maxTextWidth, _options_maxTextHeight = options.maxTextHeight, maxTextHeight = _options_maxTextHeight === void 0 ? 1000 : _options_maxTextHeight, _options_sizeMode = options.sizeMode, sizeMode = _options_sizeMode === void 0 ? spec.TextSizeMode.autoWidth : _options_sizeMode, _options_useLegacyRichText = options.// @ts-expect-error 兼容旧版
|
|
@@ -413,10 +414,8 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
413
414
|
this.width = size ? size[0] : 100;
|
|
414
415
|
this.height = size ? size[1] : 100;
|
|
415
416
|
this.wrapEnabled = wrapEnabled;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
this.maxTextWidth = maxTextWidth * scaleFactor;
|
|
419
|
-
this.maxTextHeight = maxTextHeight * scaleFactor;
|
|
417
|
+
this.maxTextWidth = maxTextWidth;
|
|
418
|
+
this.maxTextHeight = maxTextHeight;
|
|
420
419
|
this.sizeMode = sizeMode;
|
|
421
420
|
}
|
|
422
421
|
var _proto = RichTextLayout.prototype;
|
|
@@ -790,7 +789,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
|
|
|
790
789
|
var spacing = chunkChars.length > 0 ? letterSpace : 0;
|
|
791
790
|
var willWidth = currentLine.width + spacing + charWidth;
|
|
792
791
|
// 自动换行判断
|
|
793
|
-
if (willWidth > (layout.maxTextWidth || Infinity)) {
|
|
792
|
+
if (willWidth > (layout.maxTextWidth * fontScale || Infinity)) {
|
|
794
793
|
flushChunk();
|
|
795
794
|
finishCurrentLine();
|
|
796
795
|
}
|
|
@@ -1176,7 +1175,7 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1176
1175
|
_this.size = null;
|
|
1177
1176
|
_this.initialized = false;
|
|
1178
1177
|
_this.canvasSize = null;
|
|
1179
|
-
_this.SCALE_FACTOR = 0.
|
|
1178
|
+
_this.SCALE_FACTOR = 0.11092565;
|
|
1180
1179
|
_this.ALPHA_FIX_VALUE = 1 / 255;
|
|
1181
1180
|
_this.name = "MRichText" + seed++;
|
|
1182
1181
|
_this.initTextBase(engine);
|
|
@@ -1299,6 +1298,7 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1299
1298
|
if (!this.isDirty || !this.context || !this.canvas || !this.textStyle) {
|
|
1300
1299
|
return;
|
|
1301
1300
|
}
|
|
1301
|
+
var legacyScaleFactor = 0.1;
|
|
1302
1302
|
this.generateTextProgram(this.text);
|
|
1303
1303
|
var width = 0, height = 0;
|
|
1304
1304
|
var layout = this.textLayout;
|
|
@@ -1345,7 +1345,7 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1345
1345
|
charInfo.offsetY = fontSize * textStyle.fontScale * (_this.singleLineHeight - 1) / 2;
|
|
1346
1346
|
}
|
|
1347
1347
|
charInfo.offsetX.push(charInfo.width);
|
|
1348
|
-
charInfo.width += (textWidth <= 0 ? 0 : textWidth) * fontSize *
|
|
1348
|
+
charInfo.width += (textWidth <= 0 ? 0 : textWidth) * fontSize * legacyScaleFactor * textStyle.fontScale + text.length * letterSpace;
|
|
1349
1349
|
charInfo.richOptions.push(options);
|
|
1350
1350
|
});
|
|
1351
1351
|
charsInfo.push(charInfo);
|
|
@@ -1363,7 +1363,7 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1363
1363
|
if (!this.initialized) {
|
|
1364
1364
|
this.canvasSize = !this.canvasSize ? new math.Vector2(width, height) : this.canvasSize;
|
|
1365
1365
|
var _this_canvasSize = this.canvasSize, canvasWidth = _this_canvasSize.x, canvasHeight = _this_canvasSize.y;
|
|
1366
|
-
this.item.transform.size.set(x * canvasWidth *
|
|
1366
|
+
this.item.transform.size.set(x * canvasWidth * legacyScaleFactor * legacyScaleFactor, y * canvasHeight * legacyScaleFactor * legacyScaleFactor);
|
|
1367
1367
|
this.size = this.item.transform.size.clone();
|
|
1368
1368
|
this.initialized = true;
|
|
1369
1369
|
}
|
|
@@ -1573,7 +1573,8 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1573
1573
|
this.canvasSize = new math.Vector2(finalWpx, finalHpx);
|
|
1574
1574
|
var _this_size1;
|
|
1575
1575
|
var _ref = (_this_size1 = this.size) != null ? _this_size1 : this.item.transform.size, _ref_x = _ref.x, x1 = _ref_x === void 0 ? 1 : _ref_x, _ref_y = _ref.y, y1 = _ref_y === void 0 ? 1 : _ref_y;
|
|
1576
|
-
|
|
1576
|
+
// 实际元素渲染尺寸不随着 fontScale 改变
|
|
1577
|
+
this.item.transform.size.set(x1 * finalWpx / fontScale * this.SCALE_FACTOR * this.SCALE_FACTOR, y1 * finalHpx / fontScale * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1577
1578
|
this.initialized = true;
|
|
1578
1579
|
break;
|
|
1579
1580
|
}
|
|
@@ -1594,7 +1595,7 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1594
1595
|
layout.height = frameH;
|
|
1595
1596
|
var _this_size2;
|
|
1596
1597
|
var _ref1 = (_this_size2 = this.size) != null ? _this_size2 : this.item.transform.size, _ref_x1 = _ref1.x, x2 = _ref_x1 === void 0 ? 1 : _ref_x1, _ref_y1 = _ref1.y, y2 = _ref_y1 === void 0 ? 1 : _ref_y1;
|
|
1597
|
-
this.item.transform.size.set(x2 * frameWpx1 * this.SCALE_FACTOR * this.SCALE_FACTOR, y2 * frameHpx1 * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1598
|
+
this.item.transform.size.set(x2 * frameWpx1 / fontScale * this.SCALE_FACTOR * this.SCALE_FACTOR, y2 * frameHpx1 / fontScale * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1598
1599
|
this.initialized = true;
|
|
1599
1600
|
break;
|
|
1600
1601
|
}
|
|
@@ -1604,7 +1605,7 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
1604
1605
|
var frameWpx2 = frameW * fontScale;
|
|
1605
1606
|
var frameHpx2 = frameH * fontScale;
|
|
1606
1607
|
this.canvasSize = new math.Vector2(frameWpx2, frameHpx2);
|
|
1607
|
-
this.item.transform.size.set(x * frameWpx2 * this.SCALE_FACTOR * this.SCALE_FACTOR, y * frameHpx2 * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1608
|
+
this.item.transform.size.set(x * frameWpx2 / fontScale * this.SCALE_FACTOR * this.SCALE_FACTOR, y * frameHpx2 / fontScale * this.SCALE_FACTOR * this.SCALE_FACTOR);
|
|
1608
1609
|
this.initialized = true;
|
|
1609
1610
|
}
|
|
1610
1611
|
break;
|
|
@@ -1723,7 +1724,7 @@ applyMixins(RichTextComponent, [
|
|
|
1723
1724
|
|
|
1724
1725
|
/**
|
|
1725
1726
|
* 插件版本号
|
|
1726
|
-
*/ var version = "2.8.
|
|
1727
|
+
*/ var version = "2.8.7";
|
|
1727
1728
|
registerPlugin("rich-text", RichTextLoader);
|
|
1728
1729
|
logger.info("Plugin rich text version: " + version + ".");
|
|
1729
1730
|
if (version !== EFFECTS.version) {
|