@galacean/effects-plugin-rich-text 2.8.0-alpha.0 → 2.8.0-alpha.2

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.mjs CHANGED
@@ -3,11 +3,11 @@
3
3
  * Description: Galacean Effects player rich text plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 云垣
6
- * Version: v2.8.0-alpha.0
6
+ * Version: v2.8.0-alpha.2
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
10
- import { AbstractPlugin, spec, effectsClass, applyMixins, TextComponentBase, TextStyle, math, assertExist, MaskableGraphic, registerPlugin, VFXItem, logger } from '@galacean/effects';
10
+ import { AbstractPlugin, spec, effectsClass, applyMixins, TextComponentBase, TextStyle, math, assertExist, MaskableGraphic, registerPlugin, logger } from '@galacean/effects';
11
11
 
12
12
  function _set_prototype_of(o, p) {
13
13
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -337,7 +337,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
337
337
  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 兼容旧版
338
338
  useLegacyRichText, useLegacyRichText = _options_useLegacyRichText === void 0 ? false : _options_useLegacyRichText;
339
339
  this.letterSpace = letterSpace;
340
- this.lineHeight = lineHeight * 300;
340
+ this.lineHeight = lineHeight;
341
341
  this.useLegacyRichText = useLegacyRichText;
342
342
  this.overflow = textOverflow;
343
343
  this.textVerticalAlign = textVerticalAlign;
@@ -356,6 +356,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
356
356
  var offsetY = (lineHeight - fontSize) / 3;
357
357
  // 计算基础偏移量
358
358
  var baseOffset = fontSize + outlineWidth * fontScale;
359
+ // 除去首行之外的总高度,用于 bottom 对齐时将第一行向上偏移
359
360
  var commonCalculation = totalLineHeight !== undefined ? totalLineHeight : lineHeight * (lineCount - 1);
360
361
  var offsetResult = 0;
361
362
  switch(this.textVerticalAlign){
@@ -436,7 +437,10 @@ var RichTextLayout = /*#__PURE__*/ function() {
436
437
  return 0;
437
438
  }
438
439
  };
439
- _proto.setSize = function setSize(width, height) {
440
+ /**
441
+ * 设置文本框尺寸
442
+ * - 不包含 fontScale 缩放
443
+ */ _proto.setSize = function setSize(width, height) {
440
444
  this.width = width;
441
445
  this.height = height;
442
446
  };
@@ -1159,7 +1163,9 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1159
1163
  });
1160
1164
  program(text);
1161
1165
  };
1162
- _proto.updateWithOptions = function updateWithOptions(options) {
1166
+ /**
1167
+ * 根据配置更新文本样式和布局
1168
+ */ _proto.updateWithOptions = function updateWithOptions(options) {
1163
1169
  this.textStyle = new TextStyle(options);
1164
1170
  this.textLayout = new RichTextLayout(options);
1165
1171
  this.text = options.text ? options.text.toString() : " ";
@@ -1177,7 +1183,10 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1177
1183
  }
1178
1184
  this.updateTexture();
1179
1185
  };
1180
- _proto.updateTexture = function updateTexture(flipY) {
1186
+ /**
1187
+ * 更新文本
1188
+ * @returns
1189
+ */ _proto.updateTexture = function updateTexture(flipY) {
1181
1190
  if (flipY === void 0) flipY = true;
1182
1191
  if (!this.isDirty || !this.context || !this.canvas || !this.textStyle || !this.textLayout) {
1183
1192
  return;
@@ -1578,6 +1587,12 @@ var RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1578
1587
  */ _proto.setFontSize = function setFontSize(value) {
1579
1588
  this.unsupported("setFontSize");
1580
1589
  };
1590
+ /**
1591
+ * @deprecated 2.8.0 本方法已废弃,请使用 setTextVerticalAlign 替代。
1592
+ */ _proto.setTextBaseline = function setTextBaseline(value) {
1593
+ console.warn("setTextBaseline 已废弃,请改用 setTextVerticalAlign。" + "本次调用将转调用 setTextVerticalAlign。");
1594
+ this.setTextVerticalAlign(value);
1595
+ };
1581
1596
  return RichTextComponent;
1582
1597
  }(MaskableGraphic);
1583
1598
  RichTextComponent = __decorate([
@@ -1589,8 +1604,8 @@ applyMixins(RichTextComponent, [
1589
1604
 
1590
1605
  /**
1591
1606
  * 插件版本号
1592
- */ var version = "2.8.0-alpha.0";
1593
- registerPlugin("rich-text", RichTextLoader, VFXItem);
1607
+ */ var version = "2.8.0-alpha.2";
1608
+ registerPlugin("rich-text", RichTextLoader);
1594
1609
  logger.info("Plugin rich text version: " + version + ".");
1595
1610
  if (version !== EFFECTS.version) {
1596
1611
  console.error("注意:请统一 RichText 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the RichText plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");