@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.
- package/dist/RichTextCore.js +31 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +26 -26
- package/readme.md +5 -1
package/dist/RichTextCore.js
CHANGED
|
@@ -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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
1
|
+
export declare const LIB_VERSION = "0.2.21";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pixui-dev/pixui-richtext-helper",
|
|
3
|
-
"version": "0.2.
|
|
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
|
}
|