@nuxtjs/mdc 0.19.1 → 0.20.0
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/README.md +2 -2
- package/dist/module.d.mts +7 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +14 -7
- package/dist/runtime/components/MDC.vue.d.ts +9 -9
- package/dist/runtime/components/MDCCached.vue.d.ts +9 -9
- package/dist/runtime/components/MDCRenderer.vue +14 -5
- package/dist/runtime/components/MDCRenderer.vue.d.ts +9 -9
- package/dist/runtime/components/MDCSlot.vue.d.ts +8 -8
- package/dist/runtime/components/prose/ProseImg.vue.d.ts +4 -4
- package/dist/runtime/highlighter/rehype-nuxt.js +27 -2
- package/dist/runtime/highlighter/shiki.js +1 -1
- 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/package.json +22 -22
package/README.md
CHANGED
|
@@ -128,14 +128,14 @@ export default defineNuxtConfig({
|
|
|
128
128
|
components: {
|
|
129
129
|
prose: false, // Disable predefined prose components
|
|
130
130
|
map: {
|
|
131
|
-
p: 'MyCustomPComponent'
|
|
131
|
+
p: 'MyCustomPComponent' // add global like MyCustomPComponent.global.vue
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
})
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
In order to customize these components yourself simply make a component with the same name of the prose component you are trying to take control over. Make sure to put these prose components in their own prose folder and tell nuxt to globally register them so that MDC can get proper access.
|
|
138
|
+
In order to customize these components yourself simply make a component with the same name of the prose component you are trying to take control over. Make sure to put these prose components in their own prose folder and tell nuxt to globally register or simple create in `prose` folder `P.global.vue` them so that MDC can get proper access.
|
|
139
139
|
|
|
140
140
|
```ts
|
|
141
141
|
export default defineNuxtConfig({
|
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,8 +576,10 @@ 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'];
|
|
582
|
+
highlight: ModuleOptions['highlight'];
|
|
577
583
|
};
|
|
578
584
|
}
|
|
579
585
|
interface ConfigSchema {
|
|
@@ -583,6 +589,7 @@ declare module '@nuxt/schema' {
|
|
|
583
589
|
components: {
|
|
584
590
|
prose: boolean;
|
|
585
591
|
map: Record<string, string>;
|
|
592
|
+
customElements: string[];
|
|
586
593
|
};
|
|
587
594
|
};
|
|
588
595
|
headings: ModuleOptions['headings'];
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -84,7 +84,7 @@ async function mdcHighlighter({
|
|
|
84
84
|
}
|
|
85
85
|
code = code.replace(
|
|
86
86
|
/from\s+(['"])shiki\1/,
|
|
87
|
-
'from "
|
|
87
|
+
'from "@shikijs/engine-javascript"'
|
|
88
88
|
);
|
|
89
89
|
const langsMap = /* @__PURE__ */ new Map();
|
|
90
90
|
options.langs?.forEach((lang) => {
|
|
@@ -110,7 +110,7 @@ async function mdcHighlighter({
|
|
|
110
110
|
} = options;
|
|
111
111
|
return [
|
|
112
112
|
"import { getMdcConfigs } from '#mdc-configs'",
|
|
113
|
-
shikiEngine === "javascript" ? "" : "import { createOnigurumaEngine } from '
|
|
113
|
+
shikiEngine === "javascript" ? "" : "import { createOnigurumaEngine } from '@shikijs/engine-oniguruma'",
|
|
114
114
|
code,
|
|
115
115
|
"const bundledLangs = {",
|
|
116
116
|
...Array.from(langsMap.entries()).map(([name, lang]) => typeof lang === "string" ? JSON.stringify(name) + `: () => import('@shikijs/langs/${lang}').then(r => r.default || r),` : JSON.stringify(name) + ": " + JSON.stringify(lang) + ","),
|
|
@@ -252,19 +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
|
-
headings: options.headings
|
|
268
|
+
headings: options.headings,
|
|
269
|
+
highlight: options.highlight
|
|
267
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
|
+
}
|
|
268
275
|
nuxt.options.build.transpile ||= [];
|
|
269
276
|
nuxt.options.build.transpile.push("yaml");
|
|
270
277
|
if (options.highlight) {
|
|
@@ -309,7 +316,7 @@ const module$1 = defineNuxtModule({
|
|
|
309
316
|
}
|
|
310
317
|
}
|
|
311
318
|
}
|
|
312
|
-
|
|
319
|
+
nuxt.hook("modules:done", () => nuxt.callHook("mdc:configSources", mdcConfigs$1));
|
|
313
320
|
registerTemplate({
|
|
314
321
|
filename: "mdc-configs.mjs",
|
|
315
322
|
getContents: mdcConfigs,
|
|
@@ -12,14 +12,14 @@ type __VLS_Slots = {} & {
|
|
|
12
12
|
};
|
|
13
13
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
14
14
|
tag: {
|
|
15
|
-
type: (
|
|
15
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
16
16
|
default: string;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Raw markdown string or parsed markdown object from `parseMarkdown`
|
|
20
20
|
*/
|
|
21
21
|
value: {
|
|
22
|
-
type: (
|
|
22
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
23
23
|
required: true;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
@@ -40,7 +40,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
40
40
|
* Class to be applied to the root element
|
|
41
41
|
*/
|
|
42
42
|
class: {
|
|
43
|
-
type: (
|
|
43
|
+
type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
|
|
44
44
|
default: string;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
@@ -48,7 +48,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
48
48
|
* Example: 'ul li'
|
|
49
49
|
*/
|
|
50
50
|
unwrap: {
|
|
51
|
-
type: (
|
|
51
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
52
52
|
default: boolean;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
@@ -68,14 +68,14 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
68
68
|
};
|
|
69
69
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
70
70
|
tag: {
|
|
71
|
-
type: (
|
|
71
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
72
72
|
default: string;
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* Raw markdown string or parsed markdown object from `parseMarkdown`
|
|
76
76
|
*/
|
|
77
77
|
value: {
|
|
78
|
-
type: (
|
|
78
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
79
79
|
required: true;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
@@ -96,7 +96,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
96
96
|
* Class to be applied to the root element
|
|
97
97
|
*/
|
|
98
98
|
class: {
|
|
99
|
-
type: (
|
|
99
|
+
type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
|
|
100
100
|
default: string;
|
|
101
101
|
};
|
|
102
102
|
/**
|
|
@@ -104,7 +104,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
104
104
|
* Example: 'ul li'
|
|
105
105
|
*/
|
|
106
106
|
unwrap: {
|
|
107
|
-
type: (
|
|
107
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
108
108
|
default: boolean;
|
|
109
109
|
};
|
|
110
110
|
/**
|
|
@@ -126,7 +126,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
126
126
|
tag: string | boolean;
|
|
127
127
|
excerpt: boolean;
|
|
128
128
|
parserOptions: MDCParseOptions;
|
|
129
|
-
class: string | Record<string, any
|
|
129
|
+
class: string | unknown[] | Record<string, any>;
|
|
130
130
|
unwrap: string | boolean;
|
|
131
131
|
cacheKey: string;
|
|
132
132
|
partial: boolean;
|
|
@@ -12,14 +12,14 @@ type __VLS_Slots = {} & {
|
|
|
12
12
|
};
|
|
13
13
|
declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
14
14
|
tag: {
|
|
15
|
-
type: (
|
|
15
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
16
16
|
default: string;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Raw markdown string or parsed markdown object from `parseMarkdown`
|
|
20
20
|
*/
|
|
21
21
|
value: {
|
|
22
|
-
type: (
|
|
22
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
23
23
|
required: true;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
@@ -40,7 +40,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
40
40
|
* Class to be applied to the root element
|
|
41
41
|
*/
|
|
42
42
|
class: {
|
|
43
|
-
type: (
|
|
43
|
+
type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
|
|
44
44
|
default: string;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
@@ -48,7 +48,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
48
48
|
* Example: 'ul li'
|
|
49
49
|
*/
|
|
50
50
|
unwrap: {
|
|
51
|
-
type: (
|
|
51
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
52
52
|
default: boolean;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
@@ -75,14 +75,14 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
75
75
|
};
|
|
76
76
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
77
77
|
tag: {
|
|
78
|
-
type: (
|
|
78
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
79
79
|
default: string;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
82
|
* Raw markdown string or parsed markdown object from `parseMarkdown`
|
|
83
83
|
*/
|
|
84
84
|
value: {
|
|
85
|
-
type: (
|
|
85
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
86
86
|
required: true;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
@@ -103,7 +103,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
103
103
|
* Class to be applied to the root element
|
|
104
104
|
*/
|
|
105
105
|
class: {
|
|
106
|
-
type: (
|
|
106
|
+
type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
|
|
107
107
|
default: string;
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
@@ -111,7 +111,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
111
111
|
* Example: 'ul li'
|
|
112
112
|
*/
|
|
113
113
|
unwrap: {
|
|
114
|
-
type: (
|
|
114
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
115
115
|
default: boolean;
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
@@ -140,7 +140,7 @@ declare const __VLS_base: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
140
140
|
tag: string | boolean;
|
|
141
141
|
excerpt: boolean;
|
|
142
142
|
parserOptions: MDCParseOptions;
|
|
143
|
-
class: string | Record<string, any
|
|
143
|
+
class: string | unknown[] | Record<string, any>;
|
|
144
144
|
unwrap: string | boolean;
|
|
145
145
|
cacheKey: string;
|
|
146
146
|
partial: boolean;
|
|
@@ -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>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PropType, DefineComponent } from 'vue';
|
|
2
2
|
import type { MDCRoot } from '@nuxtjs/mdc';
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
3
5
|
declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
6
|
/**
|
|
5
7
|
* Content to render
|
|
@@ -19,14 +21,14 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
19
21
|
* Class(es) to bind to the component
|
|
20
22
|
*/
|
|
21
23
|
class: {
|
|
22
|
-
type: (
|
|
24
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
23
25
|
default: undefined;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* Root tag to use for rendering
|
|
27
29
|
*/
|
|
28
30
|
tag: {
|
|
29
|
-
type: (
|
|
31
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
30
32
|
default: undefined;
|
|
31
33
|
};
|
|
32
34
|
/**
|
|
@@ -48,7 +50,7 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
48
50
|
* Example: 'ul li'
|
|
49
51
|
*/
|
|
50
52
|
unwrap: {
|
|
51
|
-
type: (
|
|
53
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
52
54
|
default: boolean;
|
|
53
55
|
};
|
|
54
56
|
}>, {
|
|
@@ -80,14 +82,14 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
80
82
|
* Class(es) to bind to the component
|
|
81
83
|
*/
|
|
82
84
|
class: {
|
|
83
|
-
type: (
|
|
85
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
84
86
|
default: undefined;
|
|
85
87
|
};
|
|
86
88
|
/**
|
|
87
89
|
* Root tag to use for rendering
|
|
88
90
|
*/
|
|
89
91
|
tag: {
|
|
90
|
-
type: (
|
|
92
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
91
93
|
default: undefined;
|
|
92
94
|
};
|
|
93
95
|
/**
|
|
@@ -109,16 +111,14 @@ declare const __VLS_export: DefineComponent<import("vue").ExtractPropTypes<{
|
|
|
109
111
|
* Example: 'ul li'
|
|
110
112
|
*/
|
|
111
113
|
unwrap: {
|
|
112
|
-
type: (
|
|
114
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
113
115
|
default: boolean;
|
|
114
116
|
};
|
|
115
117
|
}>> & Readonly<{}>, {
|
|
116
|
-
data: Record<string, any>;
|
|
117
118
|
tag: string | boolean;
|
|
118
119
|
class: string | Record<string, any>;
|
|
119
120
|
unwrap: string | boolean;
|
|
121
|
+
data: Record<string, any>;
|
|
120
122
|
components: Record<string, string | DefineComponent<any, any, any>>;
|
|
121
123
|
prose: boolean;
|
|
122
124
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
123
|
-
declare const _default: typeof __VLS_export;
|
|
124
|
-
export default _default;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Slot } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* MDCSlot component
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
2
7
|
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
8
|
name: {
|
|
4
9
|
type: StringConstructor;
|
|
@@ -9,7 +14,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
9
14
|
* Example: 'ul li'
|
|
10
15
|
*/
|
|
11
16
|
unwrap: {
|
|
12
|
-
type: (
|
|
17
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
13
18
|
default: boolean;
|
|
14
19
|
};
|
|
15
20
|
/**
|
|
@@ -34,7 +39,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
34
39
|
* Example: 'ul li'
|
|
35
40
|
*/
|
|
36
41
|
unwrap: {
|
|
37
|
-
type: (
|
|
42
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
38
43
|
default: boolean;
|
|
39
44
|
};
|
|
40
45
|
/**
|
|
@@ -46,12 +51,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
46
51
|
default: undefined;
|
|
47
52
|
};
|
|
48
53
|
}>> & Readonly<{}>, {
|
|
49
|
-
name: string;
|
|
50
54
|
unwrap: string | boolean;
|
|
55
|
+
name: string;
|
|
51
56
|
use: Function;
|
|
52
57
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
53
|
-
/**
|
|
54
|
-
* MDCSlot component
|
|
55
|
-
*/
|
|
56
|
-
declare const _default: typeof __VLS_export;
|
|
57
|
-
export default _default;
|
|
@@ -8,11 +8,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
8
8
|
default: string;
|
|
9
9
|
};
|
|
10
10
|
width: {
|
|
11
|
-
type: (
|
|
11
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
12
12
|
default: undefined;
|
|
13
13
|
};
|
|
14
14
|
height: {
|
|
15
|
-
type: (
|
|
15
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
16
16
|
default: undefined;
|
|
17
17
|
};
|
|
18
18
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -25,11 +25,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
25
25
|
default: string;
|
|
26
26
|
};
|
|
27
27
|
width: {
|
|
28
|
-
type: (
|
|
28
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
29
29
|
default: undefined;
|
|
30
30
|
};
|
|
31
31
|
height: {
|
|
32
|
-
type: (
|
|
32
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
33
33
|
default: undefined;
|
|
34
34
|
};
|
|
35
35
|
}>> & Readonly<{}>, {
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { rehypeHighlight as rehypeHighlightUniversal } from "./rehype.js";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
class HighlighterError extends Error {
|
|
4
|
+
constructor(message, httpStatus) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.httpStatus = httpStatus;
|
|
7
|
+
this.name = "HighlighterError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function isHighlightResult(res) {
|
|
11
|
+
if (!res) return false;
|
|
12
|
+
return "tree" in res;
|
|
13
|
+
}
|
|
2
14
|
const defaults = {
|
|
3
15
|
theme: {},
|
|
4
16
|
async highlighter(code, lang, theme, options) {
|
|
@@ -6,7 +18,16 @@ const defaults = {
|
|
|
6
18
|
if (import.meta.client && window.sessionStorage.getItem("mdc-shiki-highlighter") === "browser") {
|
|
7
19
|
return import("#mdc-highlighter").then((h) => h.default(code, lang, theme, options)).catch(() => ({}));
|
|
8
20
|
}
|
|
9
|
-
|
|
21
|
+
if (import.meta.client) {
|
|
22
|
+
const highlight = useRuntimeConfig().public.mdc.highlight;
|
|
23
|
+
if (highlight === false) {
|
|
24
|
+
return Promise.resolve({ tree: [{ type: "text", value: code }], className: "", style: "" });
|
|
25
|
+
}
|
|
26
|
+
if (highlight?.noApiRoute === true) {
|
|
27
|
+
return import("#mdc-highlighter").then((h) => h.default(code, lang, theme, options)).catch(() => ({}));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const result = await $fetch("/api/_mdc/highlight", {
|
|
10
31
|
params: {
|
|
11
32
|
code,
|
|
12
33
|
lang,
|
|
@@ -14,8 +35,12 @@ const defaults = {
|
|
|
14
35
|
options: JSON.stringify(options)
|
|
15
36
|
}
|
|
16
37
|
});
|
|
38
|
+
if (!isHighlightResult(result)) {
|
|
39
|
+
throw new HighlighterError(`result:${result}`);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
17
42
|
} catch (e) {
|
|
18
|
-
if (import.meta.client && e?.response?.status
|
|
43
|
+
if (import.meta.client && (e?.response?.status > 399 || e?.name == "HighlighterError")) {
|
|
19
44
|
window.sessionStorage.setItem("mdc-shiki-highlighter", "browser");
|
|
20
45
|
return this.highlighter?.(code, lang, theme, options);
|
|
21
46
|
}
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mdc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Nuxt MDC module",
|
|
5
5
|
"repository": "nuxt-content/mdc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
"verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@nuxt/kit": "^4.2.
|
|
72
|
-
"@shikijs/core": "^3.
|
|
73
|
-
"@shikijs/langs": "^3.
|
|
74
|
-
"@shikijs/themes": "^3.
|
|
75
|
-
"@shikijs/transformers": "^3.
|
|
71
|
+
"@nuxt/kit": "^4.2.2",
|
|
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
|
-
"@vue/compiler-core": "^3.5.
|
|
78
|
+
"@vue/compiler-core": "^3.5.26",
|
|
79
79
|
"consola": "^3.4.2",
|
|
80
80
|
"debug": "^4.4.3",
|
|
81
81
|
"defu": "^6.1.4",
|
|
@@ -99,40 +99,40 @@
|
|
|
99
99
|
"rehype-sort-attributes": "^5.0.1",
|
|
100
100
|
"remark-emoji": "^5.0.2",
|
|
101
101
|
"remark-gfm": "^4.0.1",
|
|
102
|
-
"remark-mdc": "^3.
|
|
102
|
+
"remark-mdc": "^3.10.0",
|
|
103
103
|
"remark-parse": "^11.0.0",
|
|
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": {
|
|
116
116
|
"@nuxt/devtools": "^3.1.1",
|
|
117
|
-
"@nuxt/eslint-config": "^1.
|
|
117
|
+
"@nuxt/eslint-config": "^1.12.1",
|
|
118
118
|
"@nuxt/module-builder": "^1.0.2",
|
|
119
|
-
"@nuxt/schema": "^4.2.
|
|
120
|
-
"@nuxt/test-utils": "^3.
|
|
121
|
-
"@nuxt/ui": "^4.
|
|
119
|
+
"@nuxt/schema": "^4.2.2",
|
|
120
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
121
|
+
"@nuxt/ui": "^4.3.0",
|
|
122
122
|
"@nuxtjs/mdc": "link:.",
|
|
123
|
-
"@types/node": "^
|
|
124
|
-
"eslint": "^9.39.
|
|
125
|
-
"nuxt": "^4.2.
|
|
123
|
+
"@types/node": "^25.0.8",
|
|
124
|
+
"eslint": "^9.39.2",
|
|
125
|
+
"nuxt": "^4.2.2",
|
|
126
126
|
"rehype": "^13.0.2",
|
|
127
|
-
"release-it": "^19.
|
|
127
|
+
"release-it": "^19.2.3",
|
|
128
128
|
"typescript": "5.9.3",
|
|
129
|
-
"vitest": "^4.0.
|
|
130
|
-
"vue-tsc": "^3.
|
|
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}"
|