@inzombieland/core 1.18.49 → 1.18.51

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.
@@ -1,6 +1,7 @@
1
- import { defineOtpInputPlugin, defineSanitizeUrlPlugin, defineVarletPlugin } from "./plugins/index.mjs";
1
+ import { defineOtpInputPlugin, defineSanitizeHtmlPlugin, defineSanitizeUrlPlugin, defineVarletPlugin } from "./plugins/index.mjs";
2
2
  export function defineVuePlugins(app) {
3
3
  defineOtpInputPlugin(app);
4
+ defineSanitizeHtmlPlugin(app);
4
5
  defineSanitizeUrlPlugin(app);
5
6
  defineVarletPlugin(app);
6
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.18.49",
3
+ "version": "1.18.51",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -19,6 +19,7 @@
19
19
  "ofetch": "^1.4.1",
20
20
  "ohash": "^2.0.11",
21
21
  "rxjs": "^7.8.2",
22
+ "ultrahtml": "^1.6.0",
22
23
  "vant": "^4.9.19",
23
24
  "vue3-otp-input": "^0.5.21",
24
25
  "zod": "^3.24.2"
@@ -1,3 +1,4 @@
1
1
  export * from "./otp-input";
2
+ export * from "./sanitize-html";
2
3
  export * from "./sanitize-url";
3
4
  export * from "./varlet-ui";
package/plugins/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./otp-input.mjs";
2
+ export * from "./sanitize-html.mjs";
2
3
  export * from "./sanitize-url.mjs";
3
4
  export * from "./varlet-ui.mjs";
@@ -0,0 +1,2 @@
1
+ import type { App } from "vue";
2
+ export declare function defineSanitizeHtmlPlugin(app: App): void;
@@ -0,0 +1,88 @@
1
+ import { transform } from "ultrahtml";
2
+ import sanitize from "ultrahtml/transformers/sanitize";
3
+ export function defineSanitizeHtmlPlugin(app) {
4
+ app.directive("sanitize-html", async (el, binding) => {
5
+ if (binding.value !== binding.oldValue) {
6
+ const allowElements = [
7
+ "address",
8
+ "article",
9
+ "aside",
10
+ "footer",
11
+ "header",
12
+ "h1",
13
+ "h2",
14
+ "h3",
15
+ "h4",
16
+ "h5",
17
+ "h6",
18
+ "hgroup",
19
+ "main",
20
+ "nav",
21
+ "section",
22
+ "blockquote",
23
+ "dd",
24
+ "div",
25
+ "dl",
26
+ "dt",
27
+ "figcaption",
28
+ "figure",
29
+ "hr",
30
+ "li",
31
+ "main",
32
+ "ol",
33
+ "p",
34
+ "pre",
35
+ "ul",
36
+ "a",
37
+ "abbr",
38
+ "b",
39
+ "bdi",
40
+ "bdo",
41
+ "br",
42
+ "cite",
43
+ "code",
44
+ "data",
45
+ "dfn",
46
+ "em",
47
+ "i",
48
+ "kbd",
49
+ "mark",
50
+ "q",
51
+ "rb",
52
+ "rp",
53
+ "rt",
54
+ "rtc",
55
+ "ruby",
56
+ "s",
57
+ "samp",
58
+ "small",
59
+ "span",
60
+ "strong",
61
+ "sub",
62
+ "sup",
63
+ "time",
64
+ "u",
65
+ "var",
66
+ "wbr",
67
+ "caption",
68
+ "col",
69
+ "colgroup",
70
+ "table",
71
+ "tbody",
72
+ "td",
73
+ "tfoot",
74
+ "th",
75
+ "thead",
76
+ "tr"
77
+ ];
78
+ const allowAttributes = {
79
+ a: ["href", "name", "target"],
80
+ img: ["src", "srcset", "alt", "title", "width", "height", "loading"]
81
+ };
82
+ if (!binding.modifiers.disallowimg) {
83
+ allowElements.push("img");
84
+ }
85
+ el.innerHTML = await transform(binding.value, [sanitize({ allowElements, allowAttributes })]);
86
+ }
87
+ });
88
+ }