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

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.
@@ -16,6 +16,11 @@ export declare const RichText: {
16
16
  * @see RichTextCore.bindLinkClickEvents
17
17
  */
18
18
  bindLinkClickEvents: typeof RichTextCore.bindLinkClickEvents;
19
+ /**
20
+ * 统一转换已解析的 html 中的所有 px 单位为 em 单位
21
+ * @see RichTextCore.convertAllPxToEm
22
+ */
23
+ convertAllPxToEm: typeof RichTextCore.convertAllPxToEm;
19
24
  };
20
25
  export type { LinkClickParams };
21
26
  export { LinkNodeType };
package/dist/RichText.js CHANGED
@@ -20,5 +20,10 @@ exports.RichText = {
20
20
  * @see RichTextCore.bindLinkClickEvents
21
21
  */
22
22
  bindLinkClickEvents: RichTextCore_1.RichTextCore.bindLinkClickEvents,
23
+ /**
24
+ * 统一转换已解析的 html 中的所有 px 单位为 em 单位
25
+ * @see RichTextCore.convertAllPxToEm
26
+ */
27
+ convertAllPxToEm: RichTextCore_1.RichTextCore.convertAllPxToEm,
23
28
  };
24
29
  exports.default = exports.RichText;
@@ -37,6 +37,12 @@ export declare class RichTextCore {
37
37
  * 绑定链接点击事件
38
38
  */
39
39
  static bindLinkClickEvents(linkClickHandler: (params: LinkClickParams) => void): void;
40
+ /**
41
+ * 统一转换HTML中的所有px单位为em单位
42
+ * @param html 原始HTML字符串
43
+ * @returns 转换后的HTML字符串
44
+ */
45
+ static convertAllPxToEm(html: string): string;
40
46
  /*****************************************************
41
47
  * 内部流程函数
42
48
  *****************************************************/
@@ -49,12 +55,6 @@ export declare class RichTextCore {
49
55
  * 处理单个段落片段,返回转换后的片段 HTML
50
56
  */
51
57
  private static processSegment;
52
- /**
53
- * 统一转换HTML中的所有px单位为em单位
54
- * @param html 原始HTML字符串
55
- * @returns 转换后的HTML字符串
56
- */
57
- private static convertAllPxToEm;
58
58
  private static preprocess;
59
59
  private static fixImgSizeUnit;
60
60
  /** 合并 img 标签的 width 和 height 属性 */
@@ -297,6 +297,19 @@ var RichTextCore = /** @class */ (function () {
297
297
  });
298
298
  }, 100);
299
299
  };
300
+ /**
301
+ * 统一转换HTML中的所有px单位为em单位
302
+ * @param html 原始HTML字符串
303
+ * @returns 转换后的HTML字符串
304
+ */
305
+ RichTextCore.convertAllPxToEm = function (html) {
306
+ // 转换style属性中的px
307
+ html = html.replace(/style="([^"]*?)"/g, function (match, styleContent) {
308
+ var convertedStyle = convertStylePxToEm(styleContent);
309
+ return "style=\"".concat(convertedStyle, "\"");
310
+ });
311
+ return html;
312
+ };
300
313
  /*****************************************************
301
314
  * 内部流程函数
302
315
  *****************************************************/
@@ -443,19 +456,6 @@ var RichTextCore = /** @class */ (function () {
443
456
  }
444
457
  return res;
445
458
  };
446
- /**
447
- * 统一转换HTML中的所有px单位为em单位
448
- * @param html 原始HTML字符串
449
- * @returns 转换后的HTML字符串
450
- */
451
- RichTextCore.convertAllPxToEm = function (html) {
452
- // 转换style属性中的px
453
- html = html.replace(/style="([^"]*?)"/g, function (match, styleContent) {
454
- var convertedStyle = convertStylePxToEm(styleContent);
455
- return "style=\"".concat(convertedStyle, "\"");
456
- });
457
- return html;
458
- };
459
459
  // ------------------------------
460
460
  // 各独立处理步骤实现
461
461
  // ------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixui-dev/pixui-richtext-helper",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "pixui richtext helper",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",