@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.js 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.0-alpha.0
6
+ * Version: v2.8.0-alpha.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -360,7 +360,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
360
360
  var size = options.size, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? EFFECTS.spec.TextOverflow.clip : _options_textOverflow, _options_textVerticalAlign = options.textVerticalAlign, textVerticalAlign = _options_textVerticalAlign === void 0 ? EFFECTS.spec.TextVerticalAlign.middle : _options_textVerticalAlign, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? EFFECTS.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 ? EFFECTS.spec.TextSizeMode.autoWidth : _options_sizeMode, _options_useLegacyRichText = options.// @ts-expect-error 兼容旧版
361
361
  useLegacyRichText, useLegacyRichText = _options_useLegacyRichText === void 0 ? false : _options_useLegacyRichText;
362
362
  this.letterSpace = letterSpace;
363
- this.lineHeight = lineHeight * 300;
363
+ this.lineHeight = lineHeight;
364
364
  this.useLegacyRichText = useLegacyRichText;
365
365
  this.overflow = textOverflow;
366
366
  this.textVerticalAlign = textVerticalAlign;
@@ -379,6 +379,7 @@ var RichTextLayout = /*#__PURE__*/ function() {
379
379
  var offsetY = (lineHeight - fontSize) / 3;
380
380
  // 计算基础偏移量
381
381
  var baseOffset = fontSize + outlineWidth * fontScale;
382
+ // 除去首行之外的总高度,用于 bottom 对齐时将第一行向上偏移
382
383
  var commonCalculation = totalLineHeight !== undefined ? totalLineHeight : lineHeight * (lineCount - 1);
383
384
  var offsetResult = 0;
384
385
  switch(this.textVerticalAlign){
@@ -459,7 +460,10 @@ var RichTextLayout = /*#__PURE__*/ function() {
459
460
  return 0;
460
461
  }
461
462
  };
462
- _proto.setSize = function setSize(width, height) {
463
+ /**
464
+ * 设置文本框尺寸
465
+ * - 不包含 fontScale 缩放
466
+ */ _proto.setSize = function setSize(width, height) {
463
467
  this.width = width;
464
468
  this.height = height;
465
469
  };
@@ -1182,7 +1186,9 @@ exports.RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1182
1186
  });
1183
1187
  program(text);
1184
1188
  };
1185
- _proto.updateWithOptions = function updateWithOptions(options) {
1189
+ /**
1190
+ * 根据配置更新文本样式和布局
1191
+ */ _proto.updateWithOptions = function updateWithOptions(options) {
1186
1192
  this.textStyle = new EFFECTS.TextStyle(options);
1187
1193
  this.textLayout = new RichTextLayout(options);
1188
1194
  this.text = options.text ? options.text.toString() : " ";
@@ -1200,7 +1206,10 @@ exports.RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1200
1206
  }
1201
1207
  this.updateTexture();
1202
1208
  };
1203
- _proto.updateTexture = function updateTexture(flipY) {
1209
+ /**
1210
+ * 更新文本
1211
+ * @returns
1212
+ */ _proto.updateTexture = function updateTexture(flipY) {
1204
1213
  if (flipY === void 0) flipY = true;
1205
1214
  if (!this.isDirty || !this.context || !this.canvas || !this.textStyle || !this.textLayout) {
1206
1215
  return;
@@ -1601,6 +1610,12 @@ exports.RichTextComponent = /*#__PURE__*/ function(MaskableGraphic) {
1601
1610
  */ _proto.setFontSize = function setFontSize(value) {
1602
1611
  this.unsupported("setFontSize");
1603
1612
  };
1613
+ /**
1614
+ * @deprecated 2.8.0 本方法已废弃,请使用 setTextVerticalAlign 替代。
1615
+ */ _proto.setTextBaseline = function setTextBaseline(value) {
1616
+ console.warn("setTextBaseline 已废弃,请改用 setTextVerticalAlign。" + "本次调用将转调用 setTextVerticalAlign。");
1617
+ this.setTextVerticalAlign(value);
1618
+ };
1604
1619
  return RichTextComponent;
1605
1620
  }(EFFECTS.MaskableGraphic);
1606
1621
  exports.RichTextComponent = __decorate([
@@ -1612,8 +1627,8 @@ EFFECTS.applyMixins(exports.RichTextComponent, [
1612
1627
 
1613
1628
  /**
1614
1629
  * 插件版本号
1615
- */ var version = "2.8.0-alpha.0";
1616
- EFFECTS.registerPlugin("rich-text", RichTextLoader, EFFECTS.VFXItem);
1630
+ */ var version = "2.8.0-alpha.2";
1631
+ EFFECTS.registerPlugin("rich-text", RichTextLoader);
1617
1632
  EFFECTS.logger.info("Plugin rich text version: " + version + ".");
1618
1633
  if (version !== EFFECTS__namespace.version) {
1619
1634
  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!");