@nuxtjs/mdc 0.16.0 → 0.17.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 +8 -8
- package/dist/config.d.mts +1 -1
- package/dist/module.d.mts +15 -3
- package/dist/module.json +3 -3
- package/dist/module.mjs +9 -4
- package/dist/runtime/components/MDC.vue +25 -33
- package/dist/runtime/components/MDC.vue.d.ts +140 -0
- package/dist/runtime/components/MDCCached.vue +117 -0
- package/dist/runtime/components/MDCCached.vue.d.ts +155 -0
- package/dist/runtime/components/MDCRenderer.vue +19 -13
- package/dist/runtime/components/MDCRenderer.vue.d.ts +11 -123
- package/dist/runtime/components/MDCSlot.vue.d.ts +2 -2
- package/dist/runtime/components/prose/ProseA.vue +5 -7
- package/dist/runtime/components/prose/ProseA.vue.d.ts +36 -0
- package/dist/runtime/components/prose/ProseBlockquote.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseCode.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseEm.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseH1.vue +7 -7
- package/dist/runtime/components/prose/ProseH1.vue.d.ts +17 -0
- package/dist/runtime/components/prose/ProseH2.vue +7 -7
- package/dist/runtime/components/prose/ProseH2.vue.d.ts +17 -0
- package/dist/runtime/components/prose/ProseH3.vue +7 -7
- package/dist/runtime/components/prose/ProseH3.vue.d.ts +17 -0
- package/dist/runtime/components/prose/ProseH4.vue +7 -7
- package/dist/runtime/components/prose/ProseH4.vue.d.ts +17 -0
- package/dist/runtime/components/prose/ProseH5.vue +7 -7
- package/dist/runtime/components/prose/ProseH5.vue.d.ts +17 -0
- package/dist/runtime/components/prose/ProseH6.vue +7 -7
- package/dist/runtime/components/prose/ProseH6.vue.d.ts +17 -0
- package/dist/runtime/components/prose/ProseHr.vue.d.ts +2 -0
- package/dist/runtime/components/prose/ProseImg.vue +15 -18
- package/dist/runtime/components/prose/ProseImg.vue.d.ts +41 -0
- package/dist/runtime/components/prose/ProseLi.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseOl.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseP.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProsePre.vue +4 -4
- package/dist/runtime/components/prose/ProsePre.vue.d.ts +69 -0
- package/dist/runtime/components/prose/ProseScript.vue +4 -4
- package/dist/runtime/components/prose/ProseScript.vue.d.ts +14 -0
- package/dist/runtime/components/prose/ProseStrong.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseTable.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseTbody.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseTd.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseTh.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseThead.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseTr.vue.d.ts +12 -0
- package/dist/runtime/components/prose/ProseUl.vue.d.ts +12 -0
- package/dist/runtime/highlighter/shiki.d.ts +1 -1
- package/dist/runtime/highlighter/shiki.js +9 -6
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/parser/cached.d.ts +2 -0
- package/dist/runtime/parser/cached.js +44 -0
- package/dist/runtime/parser/compiler.js +11 -9
- package/dist/runtime/parser/handlers/utils.js +6 -2
- package/dist/runtime/parser/index.js +9 -5
- package/dist/runtime/stringify/mdc-remark.js +63 -50
- package/dist/runtime/utils/slot.d.ts +1 -1
- package/dist/shared/{mdc.4762b8bc.d.ts → mdc.BkZUOs7X.d.mts} +2 -1
- package/dist/types.d.mts +5 -1
- package/package.json +32 -34
- package/dist/config.d.ts +0 -4
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -570
- package/dist/shared/mdc.4762b8bc.d.mts +0 -66
- package/dist/types.d.ts +0 -1
|
@@ -6,6 +6,8 @@ import { visit } from "unist-util-visit";
|
|
|
6
6
|
import { format } from "hast-util-format";
|
|
7
7
|
import { computeHighlightRanges, refineCodeLanguage } from "./utils.js";
|
|
8
8
|
const mdcRemarkElementType = "mdc-element";
|
|
9
|
+
const mdastTextComponentType = "textDirective";
|
|
10
|
+
const mdcTextComponentType = "textComponent";
|
|
9
11
|
const own = {}.hasOwnProperty;
|
|
10
12
|
export function mdcRemark(options) {
|
|
11
13
|
return function(node, _file) {
|
|
@@ -27,6 +29,26 @@ export function mdcRemark(options) {
|
|
|
27
29
|
...options?.nodeHandlers
|
|
28
30
|
}
|
|
29
31
|
});
|
|
32
|
+
visit(mdast, (node2) => node2.type === mdastTextComponentType, (node2, index, parent) => {
|
|
33
|
+
node2.type = mdcTextComponentType;
|
|
34
|
+
if (node2.name === "binding") {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (index && parent && parent.children) {
|
|
38
|
+
if (index > 0 && parent.children[index - 1].type === "text") {
|
|
39
|
+
const text = parent.children[index - 1];
|
|
40
|
+
if (!["\n", " ", " "].includes(text.value.slice(-1))) {
|
|
41
|
+
text.value += " ";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (index && index < parent.children.length - 1 && parent.children[index + 1].type === "text") {
|
|
45
|
+
const text = parent.children[index + 1];
|
|
46
|
+
if (!["\n", " ", " ", ",", "."].includes(text.value.slice(0, 1))) {
|
|
47
|
+
text.value = " " + text.value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
30
52
|
return mdast;
|
|
31
53
|
};
|
|
32
54
|
}
|
|
@@ -64,6 +86,13 @@ const mdcRemarkNodeHandlers = {
|
|
|
64
86
|
if (node.properties && node.properties.dataMdast === "ignore") {
|
|
65
87
|
return;
|
|
66
88
|
}
|
|
89
|
+
if (node.properties && (node.properties.className || node.properties["class-name"])) {
|
|
90
|
+
const pascal = Array.isArray(node.properties.className || "") ? node.properties.className : String(node.properties.className || "").split(" ");
|
|
91
|
+
const kebab = Array.isArray(node.properties["class-name"] || "") ? node.properties["class-name"] : String(node.properties["class-name"] || "").split(" ");
|
|
92
|
+
node.properties.class = [node.properties.class || "", ...pascal, ...kebab].filter(Boolean).join(" ");
|
|
93
|
+
Reflect.deleteProperty(node.properties, "className");
|
|
94
|
+
Reflect.deleteProperty(node.properties, "class-name");
|
|
95
|
+
}
|
|
67
96
|
if (own.call(state.handlers, node.tagName)) {
|
|
68
97
|
return state.handlers[node.tagName](state, node, parent) || void 0;
|
|
69
98
|
}
|
|
@@ -72,10 +101,10 @@ const mdcRemarkNodeHandlers = {
|
|
|
72
101
|
state.patch(node, result);
|
|
73
102
|
return result;
|
|
74
103
|
}
|
|
75
|
-
const isInlineElement = (parent?.children || []).some((child) => child.type === "text") || ["p", "li"].includes(parent?.tagName);
|
|
104
|
+
const isInlineElement = (parent?.children || []).some((child) => child.type === "text") || ["p", "li", "strong", "em", "span"].includes(parent?.tagName);
|
|
76
105
|
if (isInlineElement) {
|
|
77
106
|
return {
|
|
78
|
-
type:
|
|
107
|
+
type: mdastTextComponentType,
|
|
79
108
|
name: node.tagName,
|
|
80
109
|
attributes: node.properties,
|
|
81
110
|
children: state.all(node)
|
|
@@ -145,48 +174,27 @@ const mdcRemarkHandlers = {
|
|
|
145
174
|
meta
|
|
146
175
|
};
|
|
147
176
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
children: state.all(node)
|
|
162
|
-
};
|
|
163
|
-
state.patch(node, result);
|
|
164
|
-
return result;
|
|
165
|
-
},
|
|
166
|
-
video: (state, node) => {
|
|
167
|
-
return {
|
|
168
|
-
type: "textComponent",
|
|
169
|
-
name: "video",
|
|
170
|
-
attributes: node.properties,
|
|
171
|
-
children: state.toFlow(state.all(node))
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
"nuxt-img": (state, node) => {
|
|
175
|
-
return {
|
|
176
|
-
type: "textComponent",
|
|
177
|
-
name: "nuxt-img",
|
|
178
|
-
attributes: node.properties,
|
|
179
|
-
children: state.toFlow(state.all(node))
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
"nuxt-picture": (state, node) => {
|
|
183
|
-
return {
|
|
184
|
-
type: "textComponent",
|
|
185
|
-
name: "nuxt-picture",
|
|
186
|
-
attributes: node.properties,
|
|
187
|
-
children: state.toFlow(state.all(node))
|
|
188
|
-
};
|
|
177
|
+
button: (state, node) => {
|
|
178
|
+
if (
|
|
179
|
+
// @ts-expect-error: custom type
|
|
180
|
+
node.children?.find((child) => child.type === mdcRemarkElementType) || node.children?.find((child) => child.type === "text" && child.value.includes("\n"))
|
|
181
|
+
) {
|
|
182
|
+
return {
|
|
183
|
+
type: "containerComponent",
|
|
184
|
+
name: "button",
|
|
185
|
+
children: state.all(node),
|
|
186
|
+
attributes: node.properties
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return createTextComponent("button")(state, node);
|
|
189
190
|
},
|
|
191
|
+
span: createTextComponent("span"),
|
|
192
|
+
binding: createTextComponent("binding"),
|
|
193
|
+
iframe: createTextComponent("iframe"),
|
|
194
|
+
video: createTextComponent("video"),
|
|
195
|
+
"nuxt-img": createTextComponent("nuxt-img"),
|
|
196
|
+
"nuxt-picture": createTextComponent("nuxt-picture"),
|
|
197
|
+
br: createTextComponent("br"),
|
|
190
198
|
table: (state, node) => {
|
|
191
199
|
visit(node, (node2) => {
|
|
192
200
|
if (node2.type === mdcRemarkElementType) {
|
|
@@ -243,12 +251,17 @@ const mdcRemarkHandlers = {
|
|
|
243
251
|
};
|
|
244
252
|
state.patch(node, result);
|
|
245
253
|
return result;
|
|
246
|
-
},
|
|
247
|
-
br(state, node) {
|
|
248
|
-
return {
|
|
249
|
-
type: "textComponent",
|
|
250
|
-
name: "br",
|
|
251
|
-
attributes: node.properties
|
|
252
|
-
};
|
|
253
254
|
}
|
|
254
255
|
};
|
|
256
|
+
function createTextComponent(name) {
|
|
257
|
+
return (state, node) => {
|
|
258
|
+
const result = {
|
|
259
|
+
type: mdastTextComponentType,
|
|
260
|
+
name,
|
|
261
|
+
attributes: node.properties,
|
|
262
|
+
children: state.all(node)
|
|
263
|
+
};
|
|
264
|
+
state.patch(node, result);
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("
|
|
1
|
+
export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}>;
|
|
@@ -63,4 +63,5 @@ interface MdcConfig {
|
|
|
63
63
|
|
|
64
64
|
declare function defineConfig(config: MdcConfig): MdcConfig;
|
|
65
65
|
|
|
66
|
-
export {
|
|
66
|
+
export { defineConfig as d };
|
|
67
|
+
export type { Awaitable as A, HighlighterOptions as H, MdcConfig as M, RehypeHighlightOption as R, MdcThemeOptions as a, HighlightResult as b, Highlighter as c };
|
package/dist/types.d.mts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export { type Awaitable, type HighlightResult, type Highlighter, type HighlighterOptions, type defineConfig } from './
|
|
1
|
+
export { type Awaitable, type HighlightResult, type Highlighter, type HighlighterOptions, type defineConfig } from './shared/mdc.BkZUOs7X.mjs'
|
|
2
|
+
|
|
3
|
+
export { type DefaultHighlightLangs, type MdcConfig, type MdcThemeOptions, type RehypeHighlightOption, default } from './module.mjs'
|
|
4
|
+
|
|
5
|
+
export { type Comment, type CommentData, type Content, type Data, type Doctype, type DoctypeData, type Element, type ElementContent, type ElementContentMap, type ElementData, type Literal, type Literals, type MDCComment, type MDCData, type MDCElement, type MDCNode, type MDCParseOptions, type MDCParserResult, type MDCRenderOptions, type MDCRoot, type MDCStringifyOptions, type MDCText, type ModuleOptions, type Node, type NodePosition, type Nodes, type Parent, type Parents, type Properties, type RehypePlugin, type RemarkPlugin, type Root, type RootContent, type RootContentMap, type RootData, type Text, type TextData, type Toc, type TocLink, type UnistPlugin } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mdc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Nuxt MDC module",
|
|
5
5
|
"repository": "nuxt-modules/mdc",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
"types": "./dist/module.d.ts",
|
|
11
|
-
"import": "./dist/module.mjs",
|
|
12
|
-
"require": "./dist/module.cjs"
|
|
13
|
-
},
|
|
9
|
+
".": "./dist/module.mjs",
|
|
14
10
|
"./config": {
|
|
15
|
-
"types": "./dist/config.d.
|
|
11
|
+
"types": "./dist/config.d.mts",
|
|
16
12
|
"import": "./dist/config.mjs",
|
|
17
13
|
"require": "./dist/config.cjs"
|
|
18
14
|
},
|
|
@@ -41,19 +37,19 @@
|
|
|
41
37
|
"import": "./dist/runtime/*.js"
|
|
42
38
|
}
|
|
43
39
|
},
|
|
44
|
-
"main": "./dist/module.
|
|
45
|
-
"types": "./dist/types.d.
|
|
40
|
+
"main": "./dist/module.mjs",
|
|
41
|
+
"types": "./dist/types.d.mts",
|
|
46
42
|
"files": [
|
|
47
43
|
"dist"
|
|
48
44
|
],
|
|
49
45
|
"typesVersions": {
|
|
50
46
|
"*": {
|
|
51
47
|
"*": [
|
|
52
|
-
"./dist/*
|
|
53
|
-
"./dist/index.d.
|
|
48
|
+
"./dist/*",
|
|
49
|
+
"./dist/index.d.mts"
|
|
54
50
|
],
|
|
55
51
|
"config": [
|
|
56
|
-
"./dist/config.d.
|
|
52
|
+
"./dist/config.d.mts"
|
|
57
53
|
]
|
|
58
54
|
}
|
|
59
55
|
},
|
|
@@ -72,15 +68,17 @@
|
|
|
72
68
|
"verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
|
|
73
69
|
},
|
|
74
70
|
"dependencies": {
|
|
75
|
-
"@nuxt/kit": "^3.16.
|
|
76
|
-
"@shikijs/
|
|
71
|
+
"@nuxt/kit": "^3.16.2",
|
|
72
|
+
"@shikijs/langs": "^3.3.0",
|
|
73
|
+
"@shikijs/themes": "^3.3.0",
|
|
74
|
+
"@shikijs/transformers": "^3.3.0",
|
|
77
75
|
"@types/hast": "^3.0.4",
|
|
78
76
|
"@types/mdast": "^4.0.4",
|
|
79
77
|
"@vue/compiler-core": "^3.5.13",
|
|
80
78
|
"consola": "^3.4.2",
|
|
81
79
|
"debug": "4.4.0",
|
|
82
80
|
"defu": "^6.1.4",
|
|
83
|
-
"destr": "^2.0.
|
|
81
|
+
"destr": "^2.0.5",
|
|
84
82
|
"detab": "^3.0.2",
|
|
85
83
|
"github-slugger": "^2.0.0",
|
|
86
84
|
"hast-util-format": "^1.1.0",
|
|
@@ -88,25 +86,25 @@
|
|
|
88
86
|
"hast-util-to-string": "^3.0.1",
|
|
89
87
|
"mdast-util-to-hast": "^13.2.0",
|
|
90
88
|
"micromark-util-sanitize-uri": "^2.0.1",
|
|
91
|
-
"parse5": "^7.
|
|
89
|
+
"parse5": "^7.3.0",
|
|
92
90
|
"pathe": "^2.0.3",
|
|
93
91
|
"property-information": "^7.0.0",
|
|
94
92
|
"rehype-external-links": "^3.0.0",
|
|
95
93
|
"rehype-minify-whitespace": "^6.0.2",
|
|
96
94
|
"rehype-raw": "^7.0.0",
|
|
97
|
-
"rehype-remark": "^10.0.
|
|
95
|
+
"rehype-remark": "^10.0.1",
|
|
98
96
|
"rehype-slug": "^6.0.0",
|
|
99
97
|
"rehype-sort-attribute-values": "^5.0.1",
|
|
100
98
|
"rehype-sort-attributes": "^5.0.1",
|
|
101
99
|
"remark-emoji": "^5.0.1",
|
|
102
100
|
"remark-gfm": "^4.0.1",
|
|
103
|
-
"remark-mdc": "
|
|
101
|
+
"remark-mdc": "v3.6.0",
|
|
104
102
|
"remark-parse": "^11.0.0",
|
|
105
|
-
"remark-rehype": "^11.1.
|
|
103
|
+
"remark-rehype": "^11.1.2",
|
|
106
104
|
"remark-stringify": "^11.0.0",
|
|
107
105
|
"scule": "^1.3.0",
|
|
108
|
-
"shiki": "^3.
|
|
109
|
-
"ufo": "^1.
|
|
106
|
+
"shiki": "^3.3.0",
|
|
107
|
+
"ufo": "^1.6.1",
|
|
110
108
|
"unified": "^11.0.5",
|
|
111
109
|
"unist-builder": "^4.0.0",
|
|
112
110
|
"unist-util-visit": "^5.0.0",
|
|
@@ -114,26 +112,26 @@
|
|
|
114
112
|
"vfile": "^6.0.3"
|
|
115
113
|
},
|
|
116
114
|
"devDependencies": {
|
|
117
|
-
"@nuxt/devtools": "^2.
|
|
118
|
-
"@nuxt/eslint-config": "^1.
|
|
119
|
-
"@nuxt/module-builder": "^0.
|
|
120
|
-
"@nuxt/schema": "^3.16.
|
|
115
|
+
"@nuxt/devtools": "^2.4.0",
|
|
116
|
+
"@nuxt/eslint-config": "^1.3.0",
|
|
117
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
118
|
+
"@nuxt/schema": "^3.16.2",
|
|
121
119
|
"@nuxt/test-utils": "^3.17.2",
|
|
122
|
-
"@nuxt/ui": "^3.0.
|
|
120
|
+
"@nuxt/ui": "^3.0.2",
|
|
123
121
|
"@nuxtjs/mdc": "link:.",
|
|
124
|
-
"@types/node": "^22.
|
|
125
|
-
"eslint": "^9.
|
|
126
|
-
"nuxt": "^3.16.
|
|
122
|
+
"@types/node": "^22.14.1",
|
|
123
|
+
"eslint": "^9.25.1",
|
|
124
|
+
"nuxt": "^3.16.2",
|
|
127
125
|
"rehype": "^13.0.2",
|
|
128
|
-
"release-it": "^
|
|
129
|
-
"typescript": "5.8.
|
|
130
|
-
"vitest": "^3.
|
|
131
|
-
"vue-tsc": "^2.2.
|
|
126
|
+
"release-it": "^19.0.1",
|
|
127
|
+
"typescript": "5.8.3",
|
|
128
|
+
"vitest": "^3.1.2",
|
|
129
|
+
"vue-tsc": "^2.2.10"
|
|
132
130
|
},
|
|
133
131
|
"resolutions": {
|
|
134
132
|
"@nuxtjs/mdc": "workspace:*"
|
|
135
133
|
},
|
|
136
|
-
"packageManager": "pnpm@10.
|
|
134
|
+
"packageManager": "pnpm@10.9.0",
|
|
137
135
|
"release-it": {
|
|
138
136
|
"git": {
|
|
139
137
|
"commitMessage": "chore(release): release v${version}"
|
package/dist/config.d.ts
DELETED