@pixui-dev/pixui-richtext-helper 0.2.18 → 0.2.19

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.
@@ -92,6 +92,10 @@ export declare class RichTextCore {
92
92
  private static adjustLineHeightAndLetterSpacing;
93
93
  /** 把 div 的 text-align 转移到子 text 上 */
94
94
  private static transferTextAlign;
95
+ /**
96
+ * 对设置了 direction 的 text 下 key 追加 U+061C(仅处理 rtl)
97
+ */
98
+ private static ensureArabicOrUrduMarkForDirectedTextKeys;
95
99
  /** 删除空 text 节点;并在安全场景下清理空 key 节点(不影响占位/换行) */
96
100
  private static removeEmptyText;
97
101
  /** 补默认 heading 字体大小 */
@@ -439,6 +439,8 @@ var RichTextCore = /** @class */ (function () {
439
439
  this.adjustLineHeightAndLetterSpacing($, config);
440
440
  // 文本对齐与方向:从 div 下沉至子 <text>
441
441
  this.transferTextAlign($);
442
+ // 对设置了 direction: rtl 的 text 下的 key 检查是否有单独的不带阿语乌语字符的文字节点,没有的话附加一个阿语空格,绕过pixui排版问题
443
+ this.ensureArabicOrUrduMarkForDirectedTextKeys($);
442
444
  // 清理空 <text>
443
445
  this.removeEmptyText($);
444
446
  // this.fixHeadingFontSize($);
@@ -1165,6 +1167,32 @@ var RichTextCore = /** @class */ (function () {
1165
1167
  });
1166
1168
  });
1167
1169
  };
1170
+ /**
1171
+ * 对设置了 direction 的 text 下 key 追加 U+061C(仅处理 rtl)
1172
+ */
1173
+ RichTextCore.ensureArabicOrUrduMarkForDirectedTextKeys = function ($) {
1174
+ var ARABIC_URDU_REGEX = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
1175
+ $("text").each(function () {
1176
+ var styleObj = parseStyleString($(this).attr("style") || "");
1177
+ var dir = (styleObj["direction"] || "").trim().toLowerCase();
1178
+ if (dir !== "rtl")
1179
+ return;
1180
+ $(this)
1181
+ .find("key")
1182
+ .each(function () {
1183
+ var $key = $(this);
1184
+ var textContent = $key.text() || "";
1185
+ if (!textContent.trim())
1186
+ return;
1187
+ if (textContent.includes("\u061C"))
1188
+ return;
1189
+ if (ARABIC_URDU_REGEX.test(textContent))
1190
+ return;
1191
+ var html = $key.html() || "";
1192
+ $key.html(html + "\u061C");
1193
+ });
1194
+ });
1195
+ };
1168
1196
  /** 删除空 text 节点;并在安全场景下清理空 key 节点(不影响占位/换行) */
1169
1197
  RichTextCore.removeEmptyText = function ($) {
1170
1198
  $("text").each(function () {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.2.17";
1
+ export declare const LIB_VERSION = "0.2.19";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_VERSION = void 0;
4
4
  /* Auto-generated by scripts/generate-version.js */
5
- exports.LIB_VERSION = "0.2.17";
5
+ exports.LIB_VERSION = "0.2.19";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixui-dev/pixui-richtext-helper",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "pixui richtext helper",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",