@nuxtjs/mdc 0.17.1 → 0.17.3
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/module.json +3 -3
- package/dist/module.mjs +5 -3
- package/dist/runtime/components/MDC.vue.d.ts +1 -1
- package/dist/runtime/components/MDCCached.vue.d.ts +1 -1
- package/dist/runtime/components/MDCRenderer.vue +4 -3
- package/dist/runtime/parser/compiler.js +1 -1
- package/dist/runtime/parser/handlers/list.js +1 -1
- package/dist/runtime/parser/handlers/utils.d.ts +1 -1
- package/dist/runtime/parser/handlers/utils.js +1 -1
- package/dist/runtime/parser/utils/props.d.ts +2 -0
- package/dist/runtime/parser/utils/props.js +12 -1
- package/dist/runtime/stringify/mdc-remark.js +2 -2
- package/package.json +23 -23
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -32,10 +32,12 @@ const registerMDCSlotTransformer = (resolver) => {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
if (context.nodeTransforms[0]
|
|
35
|
+
if (context.nodeTransforms[0]?.name !== "viteMDCSlot") {
|
|
36
36
|
const index = context.nodeTransforms.findIndex((f) => f.name === "viteMDCSlot");
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (index !== -1) {
|
|
38
|
+
const nt = context.nodeTransforms.splice(index, 1);
|
|
39
|
+
context.nodeTransforms.unshift(nt[0]);
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
];
|
|
@@ -13,6 +13,7 @@ const rxModel = /^v-model/;
|
|
|
13
13
|
const nativeInputs = ["select", "textarea", "input"];
|
|
14
14
|
const specialParentTags = ["math", "svg"];
|
|
15
15
|
const proseComponentMap = Object.fromEntries(["p", "a", "blockquote", "code", "pre", "code", "em", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "img", "ul", "ol", "li", "strong", "table", "thead", "tbody", "td", "th", "tr", "script"].map((t) => [t, `prose-${t}`]));
|
|
16
|
+
const dangerousTags = ["script", "base"];
|
|
16
17
|
export default defineComponent({
|
|
17
18
|
name: "MDCRenderer",
|
|
18
19
|
props: {
|
|
@@ -138,11 +139,11 @@ function _renderNode(node, h2, options, keyInParent) {
|
|
|
138
139
|
return renderBinding(node, h2, documentMeta, parentScope);
|
|
139
140
|
}
|
|
140
141
|
const _resolveComponent = isUnresolvableTag(renderTag) ? (component2) => component2 : resolveComponent;
|
|
141
|
-
if (renderTag
|
|
142
|
+
if (dangerousTags.includes(renderTag)) {
|
|
142
143
|
return h2(
|
|
143
144
|
"pre",
|
|
144
|
-
{ class: "
|
|
145
|
-
"<
|
|
145
|
+
{ class: "mdc-renderer-dangerous-tag" },
|
|
146
|
+
"<" + renderTag + ">" + nodeTextContent(node) + "</" + renderTag + ">"
|
|
146
147
|
);
|
|
147
148
|
}
|
|
148
149
|
const component = _resolveComponent(renderTag);
|
|
@@ -76,7 +76,7 @@ export function compileHast(options = {}) {
|
|
|
76
76
|
});
|
|
77
77
|
if (excerpt.children.find((node) => node.type === "element" && node.tag === "pre")) {
|
|
78
78
|
const lastChild = body.children[body.children.length - 1];
|
|
79
|
-
if (lastChild.type === "element" && lastChild.tag === "style") {
|
|
79
|
+
if (lastChild && lastChild.type === "element" && lastChild.tag === "style") {
|
|
80
80
|
excerpt.children.push(lastChild);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -7,7 +7,7 @@ export default function list(state, node) {
|
|
|
7
7
|
}
|
|
8
8
|
while (++index < results.length) {
|
|
9
9
|
const child = results[index];
|
|
10
|
-
if (child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) {
|
|
10
|
+
if (child && child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) {
|
|
11
11
|
properties.className = ["contains-task-list"];
|
|
12
12
|
break;
|
|
13
13
|
}
|
|
@@ -26,7 +26,7 @@ export function parseThematicBlock(lang) {
|
|
|
26
26
|
function parseHighlightedLines(lines) {
|
|
27
27
|
const lineArray = String(lines || "").split(",").filter(Boolean).flatMap((line) => {
|
|
28
28
|
const [start, end] = line.trim().split("-").map((a) => Number(a.trim()));
|
|
29
|
-
return Array.from({ length: (end || start) - start + 1 }).map((_, i) => start + i);
|
|
29
|
+
return Array.from({ length: (end || start || 0) - (start || 0) + 1 }).map((_, i) => (start || 0) + i);
|
|
30
30
|
});
|
|
31
31
|
return lineArray.length ? lineArray : void 0;
|
|
32
32
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const unsafeTags: string[];
|
|
2
|
+
export declare const unsafeAttributes: string[];
|
|
1
3
|
export declare const unsafeLinkPrefix: string[];
|
|
2
4
|
export declare const validateProp: (attribute: string, value: string) => boolean;
|
|
3
5
|
export declare const validateProps: (type: string, props?: Record<string, any>) => Record<string, any>;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export const unsafeTags = [
|
|
2
|
+
"object"
|
|
3
|
+
];
|
|
4
|
+
export const unsafeAttributes = [
|
|
5
|
+
"srcdoc",
|
|
6
|
+
"formaction"
|
|
7
|
+
];
|
|
1
8
|
export const unsafeLinkPrefix = [
|
|
2
9
|
"javascript:",
|
|
3
10
|
"data:text/html",
|
|
@@ -25,7 +32,8 @@ function isAnchorLinkAllowed(value) {
|
|
|
25
32
|
return true;
|
|
26
33
|
}
|
|
27
34
|
export const validateProp = (attribute, value) => {
|
|
28
|
-
|
|
35
|
+
attribute = attribute.toLowerCase();
|
|
36
|
+
if (attribute.startsWith("on") || unsafeAttributes.includes(attribute)) {
|
|
29
37
|
return false;
|
|
30
38
|
}
|
|
31
39
|
if (attribute === "href" || attribute === "src") {
|
|
@@ -34,6 +42,9 @@ export const validateProp = (attribute, value) => {
|
|
|
34
42
|
return true;
|
|
35
43
|
};
|
|
36
44
|
export const validateProps = (type, props) => {
|
|
45
|
+
if (unsafeTags.includes(type)) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
37
48
|
if (!props) {
|
|
38
49
|
return {};
|
|
39
50
|
}
|
|
@@ -35,13 +35,13 @@ export function mdcRemark(options) {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
if (index && parent && parent.children) {
|
|
38
|
-
if (index > 0 && parent.children[index - 1]
|
|
38
|
+
if (index > 0 && parent.children[index - 1]?.type === "text") {
|
|
39
39
|
const text = parent.children[index - 1];
|
|
40
40
|
if (!["\n", " ", " "].includes(text.value.slice(-1))) {
|
|
41
41
|
text.value += " ";
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
if (index && index < parent.children.length - 1 && parent.children[index + 1]
|
|
44
|
+
if (index && index < parent.children.length - 1 && parent.children[index + 1]?.type === "text") {
|
|
45
45
|
const text = parent.children[index + 1];
|
|
46
46
|
if (!["\n", " ", " ", ",", "."].includes(text.value.slice(0, 1))) {
|
|
47
47
|
text.value = " " + text.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mdc",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"description": "Nuxt MDC module",
|
|
5
5
|
"repository": "nuxt-modules/mdc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,15 +68,15 @@
|
|
|
68
68
|
"verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@nuxt/kit": "^
|
|
72
|
-
"@shikijs/langs": "^3.
|
|
73
|
-
"@shikijs/themes": "^3.
|
|
74
|
-
"@shikijs/transformers": "^3.
|
|
71
|
+
"@nuxt/kit": "^4.0.3",
|
|
72
|
+
"@shikijs/langs": "^3.12.1",
|
|
73
|
+
"@shikijs/themes": "^3.12.1",
|
|
74
|
+
"@shikijs/transformers": "^3.12.1",
|
|
75
75
|
"@types/hast": "^3.0.4",
|
|
76
76
|
"@types/mdast": "^4.0.4",
|
|
77
|
-
"@vue/compiler-core": "^3.5.
|
|
77
|
+
"@vue/compiler-core": "^3.5.20",
|
|
78
78
|
"consola": "^3.4.2",
|
|
79
|
-
"debug": "4.4.1",
|
|
79
|
+
"debug": "^4.4.1",
|
|
80
80
|
"defu": "^6.1.4",
|
|
81
81
|
"destr": "^2.0.5",
|
|
82
82
|
"detab": "^3.0.2",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"hast-util-to-string": "^3.0.1",
|
|
87
87
|
"mdast-util-to-hast": "^13.2.0",
|
|
88
88
|
"micromark-util-sanitize-uri": "^2.0.1",
|
|
89
|
-
"parse5": "^
|
|
89
|
+
"parse5": "^8.0.0",
|
|
90
90
|
"pathe": "^2.0.3",
|
|
91
91
|
"property-information": "^7.1.0",
|
|
92
92
|
"rehype-external-links": "^3.0.0",
|
|
@@ -96,42 +96,42 @@
|
|
|
96
96
|
"rehype-slug": "^6.0.0",
|
|
97
97
|
"rehype-sort-attribute-values": "^5.0.1",
|
|
98
98
|
"rehype-sort-attributes": "^5.0.1",
|
|
99
|
-
"remark-emoji": "^5.0.
|
|
99
|
+
"remark-emoji": "^5.0.2",
|
|
100
100
|
"remark-gfm": "^4.0.1",
|
|
101
101
|
"remark-mdc": "v3.6.0",
|
|
102
102
|
"remark-parse": "^11.0.0",
|
|
103
103
|
"remark-rehype": "^11.1.2",
|
|
104
104
|
"remark-stringify": "^11.0.0",
|
|
105
105
|
"scule": "^1.3.0",
|
|
106
|
-
"shiki": "^3.
|
|
106
|
+
"shiki": "^3.12.1",
|
|
107
107
|
"ufo": "^1.6.1",
|
|
108
108
|
"unified": "^11.0.5",
|
|
109
109
|
"unist-builder": "^4.0.0",
|
|
110
110
|
"unist-util-visit": "^5.0.0",
|
|
111
|
-
"unwasm": "^0.3.
|
|
111
|
+
"unwasm": "^0.3.11",
|
|
112
112
|
"vfile": "^6.0.3"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@nuxt/devtools": "^2.6.
|
|
116
|
-
"@nuxt/eslint-config": "^1.
|
|
117
|
-
"@nuxt/module-builder": "^1.0.
|
|
118
|
-
"@nuxt/schema": "^
|
|
115
|
+
"@nuxt/devtools": "^2.6.3",
|
|
116
|
+
"@nuxt/eslint-config": "^1.9.0",
|
|
117
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
118
|
+
"@nuxt/schema": "^4.0.3",
|
|
119
119
|
"@nuxt/test-utils": "^3.19.2",
|
|
120
|
-
"@nuxt/ui": "^3.
|
|
120
|
+
"@nuxt/ui": "^3.3.3",
|
|
121
121
|
"@nuxtjs/mdc": "link:.",
|
|
122
|
-
"@types/node": "^24.0
|
|
123
|
-
"eslint": "^9.
|
|
124
|
-
"nuxt": "^
|
|
122
|
+
"@types/node": "^24.3.0",
|
|
123
|
+
"eslint": "^9.34.0",
|
|
124
|
+
"nuxt": "^4.0.3",
|
|
125
125
|
"rehype": "^13.0.2",
|
|
126
|
-
"release-it": "^19.0.
|
|
127
|
-
"typescript": "5.
|
|
126
|
+
"release-it": "^19.0.4",
|
|
127
|
+
"typescript": "5.9.2",
|
|
128
128
|
"vitest": "^3.2.4",
|
|
129
|
-
"vue-tsc": "^3.0.
|
|
129
|
+
"vue-tsc": "^3.0.6"
|
|
130
130
|
},
|
|
131
131
|
"resolutions": {
|
|
132
132
|
"@nuxtjs/mdc": "workspace:*"
|
|
133
133
|
},
|
|
134
|
-
"packageManager": "pnpm@10.
|
|
134
|
+
"packageManager": "pnpm@10.15.1",
|
|
135
135
|
"release-it": {
|
|
136
136
|
"git": {
|
|
137
137
|
"commitMessage": "chore(release): release v${version}"
|