@nuxtjs/mdc 0.19.2 → 0.20.1
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.d.mts +6 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +10 -4
- package/dist/runtime/components/MDCRenderer.vue +14 -5
- package/dist/runtime/parser/handlers/paragraph.js +1 -1
- package/dist/runtime/parser/utils/html-tags-list.d.ts +1 -1
- package/dist/runtime/parser/utils/html-tags-list.js +2 -2
- package/dist/runtime/parser/utils/props.js +3 -0
- package/package.json +14 -14
package/dist/module.d.mts
CHANGED
|
@@ -193,6 +193,10 @@ interface ModuleOptions {
|
|
|
193
193
|
components?: {
|
|
194
194
|
prose?: boolean;
|
|
195
195
|
map?: Record<string, string>;
|
|
196
|
+
/**
|
|
197
|
+
* Custom element tags to ignore at MDC runtime (ex: ['mjx-container', 'my-element'])
|
|
198
|
+
*/
|
|
199
|
+
customElements?: string[];
|
|
196
200
|
};
|
|
197
201
|
}
|
|
198
202
|
|
|
@@ -572,6 +576,7 @@ declare module '@nuxt/schema' {
|
|
|
572
576
|
components: {
|
|
573
577
|
prose: boolean;
|
|
574
578
|
map: Record<string, string>;
|
|
579
|
+
customElements: string[];
|
|
575
580
|
};
|
|
576
581
|
headings: ModuleOptions['headings'];
|
|
577
582
|
highlight: ModuleOptions['highlight'];
|
|
@@ -584,6 +589,7 @@ declare module '@nuxt/schema' {
|
|
|
584
589
|
components: {
|
|
585
590
|
prose: boolean;
|
|
586
591
|
map: Record<string, string>;
|
|
592
|
+
customElements: string[];
|
|
587
593
|
};
|
|
588
594
|
};
|
|
589
595
|
headings: ModuleOptions['headings'];
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -252,20 +252,26 @@ const module$1 = defineNuxtModule({
|
|
|
252
252
|
keepComments: false,
|
|
253
253
|
components: {
|
|
254
254
|
prose: true,
|
|
255
|
-
map: {}
|
|
255
|
+
map: {},
|
|
256
|
+
customElements: []
|
|
256
257
|
}
|
|
257
258
|
},
|
|
258
259
|
async setup(options, nuxt) {
|
|
259
260
|
resolveOptions(options);
|
|
260
261
|
const resolver = createResolver(import.meta.url);
|
|
261
|
-
nuxt.options.runtimeConfig.public.mdc = defu(nuxt.options.runtimeConfig.public.mdc, {
|
|
262
|
+
const mdc = nuxt.options.runtimeConfig.public.mdc = defu(nuxt.options.runtimeConfig.public.mdc, {
|
|
262
263
|
components: {
|
|
263
264
|
prose: options.components.prose,
|
|
264
|
-
map: options.components.map
|
|
265
|
+
map: options.components.map,
|
|
266
|
+
customElements: options.components?.customElements || []
|
|
265
267
|
},
|
|
266
268
|
headings: options.headings,
|
|
267
269
|
highlight: options.highlight
|
|
268
270
|
});
|
|
271
|
+
if (mdc.components.customElements.length > 0 && !nuxt.options.vue.compilerOptions?.isCustomElement) {
|
|
272
|
+
nuxt.options.vue.compilerOptions ||= {};
|
|
273
|
+
nuxt.options.vue.compilerOptions.isCustomElement = (tag) => mdc.components.customElements.includes(tag);
|
|
274
|
+
}
|
|
269
275
|
nuxt.options.build.transpile ||= [];
|
|
270
276
|
nuxt.options.build.transpile.push("yaml");
|
|
271
277
|
if (options.highlight) {
|
|
@@ -310,7 +316,7 @@ const module$1 = defineNuxtModule({
|
|
|
310
316
|
}
|
|
311
317
|
}
|
|
312
318
|
}
|
|
313
|
-
|
|
319
|
+
nuxt.hook("modules:done", () => nuxt.callHook("mdc:configSources", mdcConfigs$1));
|
|
314
320
|
registerTemplate({
|
|
315
321
|
filename: "mdc-configs.mjs",
|
|
316
322
|
getContents: mdcConfigs,
|
|
@@ -11,7 +11,8 @@ const rxOn = /^@|^v-on:/;
|
|
|
11
11
|
const rxBind = /^:|^v-bind:/;
|
|
12
12
|
const rxModel = /^v-model/;
|
|
13
13
|
const nativeInputs = ["select", "textarea", "input"];
|
|
14
|
-
const specialParentTags = ["math", "svg"];
|
|
14
|
+
const specialParentTags = /* @__PURE__ */ new Set(["math", "svg"]);
|
|
15
|
+
const customElements = /* @__PURE__ */ new Set();
|
|
15
16
|
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
17
|
const dangerousTags = ["script", "base"];
|
|
17
18
|
export default defineComponent({
|
|
@@ -73,6 +74,10 @@ export default defineComponent({
|
|
|
73
74
|
const $nuxt = app?.$nuxt;
|
|
74
75
|
const route = $nuxt?.$route || $nuxt?._route;
|
|
75
76
|
const { mdc } = $nuxt?.$config?.public || {};
|
|
77
|
+
const customElementTags = mdc?.components?.customElements || mdc?.components?.custom;
|
|
78
|
+
if (customElementTags) {
|
|
79
|
+
customElementTags.forEach((tag) => customElements.add(tag));
|
|
80
|
+
}
|
|
76
81
|
const tags = computed(() => ({
|
|
77
82
|
...mdc?.components?.prose && props.prose !== false ? proseComponentMap : {},
|
|
78
83
|
...mdc?.components?.map || {},
|
|
@@ -80,7 +85,7 @@ export default defineComponent({
|
|
|
80
85
|
...props.components
|
|
81
86
|
}));
|
|
82
87
|
const contentKey = computed(() => {
|
|
83
|
-
const components = (props.body?.children || []).map((n) => n.tag || n.type).filter((t) => !
|
|
88
|
+
const components = (props.body?.children || []).map((n) => n.tag || n.type).filter((t) => !ignoreTag(t));
|
|
84
89
|
return Array.from(new Set(components)).sort().join(".");
|
|
85
90
|
});
|
|
86
91
|
const runtimeData = reactive({
|
|
@@ -291,7 +296,7 @@ function propsToDataRxBind(key, value, data, documentMeta) {
|
|
|
291
296
|
}
|
|
292
297
|
const resolveComponentInstance = (component) => {
|
|
293
298
|
if (typeof component === "string") {
|
|
294
|
-
if (
|
|
299
|
+
if (ignoreTag(component)) {
|
|
295
300
|
return component;
|
|
296
301
|
}
|
|
297
302
|
const _component = vueResolveComponent(pascalCase(component), false);
|
|
@@ -327,7 +332,7 @@ function isTemplate(node) {
|
|
|
327
332
|
return node.tag === "template";
|
|
328
333
|
}
|
|
329
334
|
function isUnresolvableTag(tag) {
|
|
330
|
-
return specialParentTags.
|
|
335
|
+
return specialParentTags.has(tag);
|
|
331
336
|
}
|
|
332
337
|
function mergeTextNodes(nodes) {
|
|
333
338
|
const mergedNodes = [];
|
|
@@ -365,7 +370,7 @@ async function resolveContentComponents(body, meta) {
|
|
|
365
370
|
return [];
|
|
366
371
|
}
|
|
367
372
|
const components2 = [];
|
|
368
|
-
if (node.type !== "root" && !
|
|
373
|
+
if (node.type !== "root" && !ignoreTag(renderTag)) {
|
|
369
374
|
components2.push(renderTag);
|
|
370
375
|
}
|
|
371
376
|
for (const child of node.children || []) {
|
|
@@ -381,4 +386,8 @@ function findMappedTag(node, tags) {
|
|
|
381
386
|
}
|
|
382
387
|
return tags[tag] || tags[pascalCase(tag)] || tags[kebabCase(node.tag)] || tag;
|
|
383
388
|
}
|
|
389
|
+
function ignoreTag(tag) {
|
|
390
|
+
const isCustomEl = typeof tag === "string" ? customElements.has(tag) : false;
|
|
391
|
+
return isCustomEl || htmlTags.has(tag);
|
|
392
|
+
}
|
|
384
393
|
</script>
|
|
@@ -4,7 +4,7 @@ import { getTagName } from "./utils.js";
|
|
|
4
4
|
export default function paragraph(state, node) {
|
|
5
5
|
if (node.children && node.children[0] && node.children[0].type === "html") {
|
|
6
6
|
const tagName = kebabCase(getTagName(node.children[0].value) || "div");
|
|
7
|
-
if (!htmlTags.
|
|
7
|
+
if (!htmlTags.has(tagName)) {
|
|
8
8
|
return state.all(node);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: string
|
|
1
|
+
declare const _default: Set<string>;
|
|
2
2
|
export default _default;
|
|
@@ -50,6 +50,9 @@ export const validateProps = (type, props) => {
|
|
|
50
50
|
}
|
|
51
51
|
props = Object.fromEntries(
|
|
52
52
|
Object.entries(props).filter(([name, value]) => {
|
|
53
|
+
if (props?.[`:${name}`]) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
53
56
|
const isValid = validateProp(name, value);
|
|
54
57
|
if (!isValid) {
|
|
55
58
|
console.warn(`[@nuxtjs/mdc] removing unsafe attribute: ${name}="${value}"`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mdc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Nuxt MDC module",
|
|
5
5
|
"repository": "nuxt-content/mdc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@nuxt/kit": "^4.2.2",
|
|
72
|
-
"@shikijs/core": "^3.
|
|
73
|
-
"@shikijs/langs": "^3.
|
|
74
|
-
"@shikijs/themes": "^3.
|
|
75
|
-
"@shikijs/transformers": "^3.
|
|
72
|
+
"@shikijs/core": "^3.21.0",
|
|
73
|
+
"@shikijs/langs": "^3.21.0",
|
|
74
|
+
"@shikijs/themes": "^3.21.0",
|
|
75
|
+
"@shikijs/transformers": "^3.21.0",
|
|
76
76
|
"@types/hast": "^3.0.4",
|
|
77
77
|
"@types/mdast": "^4.0.4",
|
|
78
78
|
"@vue/compiler-core": "^3.5.26",
|
|
@@ -104,12 +104,12 @@
|
|
|
104
104
|
"remark-rehype": "^11.1.2",
|
|
105
105
|
"remark-stringify": "^11.0.0",
|
|
106
106
|
"scule": "^1.3.0",
|
|
107
|
-
"shiki": "^3.
|
|
108
|
-
"ufo": "^1.6.
|
|
107
|
+
"shiki": "^3.21.0",
|
|
108
|
+
"ufo": "^1.6.3",
|
|
109
109
|
"unified": "^11.0.5",
|
|
110
110
|
"unist-builder": "^4.0.0",
|
|
111
111
|
"unist-util-visit": "^5.0.0",
|
|
112
|
-
"unwasm": "^0.5.
|
|
112
|
+
"unwasm": "^0.5.3",
|
|
113
113
|
"vfile": "^6.0.3"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
@@ -117,22 +117,22 @@
|
|
|
117
117
|
"@nuxt/eslint-config": "^1.12.1",
|
|
118
118
|
"@nuxt/module-builder": "^1.0.2",
|
|
119
119
|
"@nuxt/schema": "^4.2.2",
|
|
120
|
-
"@nuxt/test-utils": "^3.
|
|
120
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
121
121
|
"@nuxt/ui": "^4.3.0",
|
|
122
122
|
"@nuxtjs/mdc": "link:.",
|
|
123
|
-
"@types/node": "^25.0.
|
|
123
|
+
"@types/node": "^25.0.8",
|
|
124
124
|
"eslint": "^9.39.2",
|
|
125
125
|
"nuxt": "^4.2.2",
|
|
126
126
|
"rehype": "^13.0.2",
|
|
127
|
-
"release-it": "^19.2.
|
|
127
|
+
"release-it": "^19.2.3",
|
|
128
128
|
"typescript": "5.9.3",
|
|
129
|
-
"vitest": "^4.0.
|
|
130
|
-
"vue-tsc": "^3.2.
|
|
129
|
+
"vitest": "^4.0.17",
|
|
130
|
+
"vue-tsc": "^3.2.2"
|
|
131
131
|
},
|
|
132
132
|
"resolutions": {
|
|
133
133
|
"mkdist": "2.3.0"
|
|
134
134
|
},
|
|
135
|
-
"packageManager": "pnpm@10.
|
|
135
|
+
"packageManager": "pnpm@10.28.0",
|
|
136
136
|
"release-it": {
|
|
137
137
|
"git": {
|
|
138
138
|
"commitMessage": "chore(release): release v${version}"
|