@pixui-dev/pixui-richtext-helper 0.2.2 → 0.2.3

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.
@@ -442,6 +442,9 @@ var RichTextCore = /** @class */ (function () {
442
442
  var listParent = $(this).closest("[data-list-item='true']");
443
443
  if (listParent.length > 0)
444
444
  return;
445
+ var brParent = $(this).closest(".pixui-richtext-br-placeholder");
446
+ if (brParent.length > 0)
447
+ return;
445
448
  if (this.type === "text") {
446
449
  var text = this.data.trim();
447
450
  if (text.length > 0) {
@@ -621,15 +624,29 @@ var RichTextCore = /** @class */ (function () {
621
624
  RichTextCore.adjustLineHeightAndLetterSpacing = function ($, config) {
622
625
  $("text").each(function () {
623
626
  var $text = $(this);
624
- var maxLineHeight = 0;
627
+ var maxLineHeightVal = 0;
628
+ var lineHeightUnit = "";
625
629
  $text.children("div").each(function () {
626
- var lh = parseInt($(this).css("line-height") || "1");
627
- maxLineHeight = Math.max(maxLineHeight, lh);
630
+ var lhRaw = ($(this).css("line-height") || "").trim();
631
+ var match = lhRaw.match(/^([0-9.]+)([a-z%]*)$/i);
632
+ if (match) {
633
+ var val = parseFloat(match[1]);
634
+ if (!isNaN(val)) {
635
+ maxLineHeightVal = Math.max(maxLineHeightVal, val);
636
+ }
637
+ if (!lineHeightUnit && match[2])
638
+ lineHeightUnit = match[2];
639
+ }
640
+ if (lhRaw) {
641
+ var styleObj = parseStyleString($(this).attr("style") || "");
642
+ delete styleObj["line-height"];
643
+ $(this).attr("style", serializeStyleObject(styleObj));
644
+ }
628
645
  });
629
646
  var scale = (config === null || config === void 0 ? void 0 : config.lineHeightScale) || 1;
630
- if (maxLineHeight > 0) {
647
+ if (maxLineHeightVal > 0) {
631
648
  var currentStyle = $text.attr("style") || "";
632
- $text.attr("style", mergeStyles(currentStyle, "line-height: ".concat(maxLineHeight * scale)));
649
+ $text.attr("style", mergeStyles(currentStyle, "line-height: ".concat(maxLineHeightVal * scale).concat(lineHeightUnit)));
633
650
  }
634
651
  });
635
652
  $("text").each(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixui-dev/pixui-richtext-helper",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "pixui richtext helper",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -27,6 +27,9 @@ componentDidMount() { // 在节点渲染后绑定点击事件
27
27
  }
28
28
  ```
29
29
 
30
+ ## 注意
31
+ 组件在转换长富文本(节点数量较多,参考节点数量大于100)的时候可能会比较慢阻塞活动显示,如果需要转换很长的富文本,建议询问管理端是否可以提供预转换服务,或者活动在前置虚拟机中预先转换以后保存到本地,活动中直接使用转换以后的结果。
32
+
30
33
  ### 自定义节点样式
31
34
 
32
35
  `convertRichTextToPixuiStyle` 在转换过程中会为特定节点增加 class 或 data-attribute,方便业务侧按需覆盖样式:
@@ -83,3 +86,6 @@ componentDidMount() { // 在节点渲染后绑定点击事件
83
86
  0.2.2
84
87
  1. 去掉某些节点默认的lineheight:1
85
88
  2. 超链接改为直接在节点中记录数据,方便预加载流程在不同的环境调用convert和bind
89
+
90
+ 0.2.3
91
+ 1. line-height 的单位支持浮点数