@pixui-dev/pixui-richtext-helper 0.2.20 → 0.2.21

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.
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
26
36
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
37
  if (ar || !(i in from)) {
@@ -43,7 +53,7 @@ var LinkNodeType;
43
53
  (function (LinkNodeType) {
44
54
  LinkNodeType["IMG"] = "img";
45
55
  LinkNodeType["DIV"] = "div";
46
- })(LinkNodeType = exports.LinkNodeType || (exports.LinkNodeType = {}));
56
+ })(LinkNodeType || (exports.LinkNodeType = LinkNodeType = {}));
47
57
  var textNodeStyle = [
48
58
  { key: "direction", isNumber: false },
49
59
  { key: "line-height", isNumber: true },
@@ -303,9 +313,17 @@ var RichTextCore = /** @class */ (function () {
303
313
  * @returns 转换后的HTML字符串
304
314
  */
305
315
  RichTextCore.convertAllPxToEm = function (html) {
316
+ var styleCache = new Map(); // 避免重复转换相同style
306
317
  // 转换style属性中的px
307
318
  html = html.replace(/style="([^"]*?)"/g, function (match, styleContent) {
308
- var convertedStyle = convertStylePxToEm(styleContent);
319
+ if (!styleContent || styleContent.indexOf("px") === -1) {
320
+ return match;
321
+ }
322
+ var convertedStyle = styleCache.get(styleContent);
323
+ if (!convertedStyle) {
324
+ convertedStyle = convertStylePxToEm(styleContent);
325
+ styleCache.set(styleContent, convertedStyle);
326
+ }
309
327
  return "style=\"".concat(convertedStyle, "\"");
310
328
  });
311
329
  return html;
@@ -674,10 +692,10 @@ var RichTextCore = /** @class */ (function () {
674
692
  }
675
693
  // 根据 list-style-type 与列表类型决定 marker
676
694
  var BULLET_MARKER_MAP = {
677
- disc: "●",
678
- circle: "○",
679
- square: "■",
680
- "empty square": "□",
695
+ disc: "●", // 实心圆
696
+ circle: "○", // 空心圆
697
+ square: "■", // 实心方块
698
+ "empty square": "□", //空心方块
681
699
  none: "",
682
700
  };
683
701
  var finalMarker = "";
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.2.20";
1
+ export declare const LIB_VERSION = "0.2.21";
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.20";
5
+ exports.LIB_VERSION = "0.2.21";
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "@pixui-dev/pixui-richtext-helper",
3
- "version": "0.2.20",
4
- "description": "pixui richtext helper",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist/**/*",
9
- "index.js",
10
- "readme.md"
11
- ],
12
- "scripts": {
13
- "build": "node scripts/generate-version.js && rm -rf dist && tsc"
14
- },
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "author": "jnjnjnzhang",
19
- "license": "ISC",
20
- "devDependencies": {
21
- "@types/node": "^22.15.33",
22
- "typescript": "^5.8.3"
23
- },
24
- "dependencies": {
25
- "cheerio": "1.0.0-rc.10"
26
- }
1
+ {
2
+ "name": "@pixui-dev/pixui-richtext-helper",
3
+ "version": "0.2.21",
4
+ "description": "pixui richtext helper",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "index.js",
10
+ "readme.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "node scripts/generate-version.js && rm -rf dist && tsc"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "author": "jnjnjnzhang",
19
+ "license": "ISC",
20
+ "devDependencies": {
21
+ "@types/node": "^22.15.33",
22
+ "typescript": "^5.8.3"
23
+ },
24
+ "dependencies": {
25
+ "cheerio": "1.0.0-rc.10"
26
+ }
27
27
  }
package/readme.md CHANGED
@@ -156,4 +156,8 @@ componentDidMount() { // 在节点渲染后绑定点击事件
156
156
 
157
157
  0.2.20
158
158
 
159
- 1. 直接填充透明占位符规避行内多个节点的时候空格被pixui trim的问题
159
+ 1. 直接填充透明占位符规避行内多个节点的时候空格被pixui trim的问题
160
+
161
+ 0.2.21
162
+
163
+ 1. 优化px转换为em的工具函数的性能