@pixui-dev/pixui-richtext-helper 0.2.16 → 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 属性 */
@@ -132,6 +132,7 @@ var mergeStyles = function () {
132
132
  var CLASS_STYLE_MAP = {
133
133
  "ql-direction-rtl": function (old) { return mergeStyles(old, "direction: rtl;"); },
134
134
  "ql-align-right": function (old) { return mergeStyles(old, "text-align: right;"); },
135
+ "ql-align-center": function (old) { return mergeStyles(old, "text-align: center;"); },
135
136
  };
136
137
  // data-list value → 需追加的 class 名
137
138
  var DATA_LIST_CLASS_MAP = {
@@ -296,6 +297,19 @@ var RichTextCore = /** @class */ (function () {
296
297
  });
297
298
  }, 100);
298
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
+ };
299
313
  /*****************************************************
300
314
  * 内部流程函数
301
315
  *****************************************************/
@@ -442,19 +456,6 @@ var RichTextCore = /** @class */ (function () {
442
456
  }
443
457
  return res;
444
458
  };
445
- /**
446
- * 统一转换HTML中的所有px单位为em单位
447
- * @param html 原始HTML字符串
448
- * @returns 转换后的HTML字符串
449
- */
450
- RichTextCore.convertAllPxToEm = function (html) {
451
- // 转换style属性中的px
452
- html = html.replace(/style="([^"]*?)"/g, function (match, styleContent) {
453
- var convertedStyle = convertStylePxToEm(styleContent);
454
- return "style=\"".concat(convertedStyle, "\"");
455
- });
456
- return html;
457
- };
458
459
  // ------------------------------
459
460
  // 各独立处理步骤实现
460
461
  // ------------------------------
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.2.15";
1
+ export declare const LIB_VERSION = "0.2.17";
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.15";
5
+ exports.LIB_VERSION = "0.2.17";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixui-dev/pixui-richtext-helper",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "pixui richtext helper",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,4 +24,4 @@
24
24
  "dependencies": {
25
25
  "cheerio": "1.0.0-rc.10"
26
26
  }
27
- }
27
+ }