@shikijs/vitepress-twoslash 1.0.0-beta.6 → 1.0.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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +10 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ interface VitePressPluginTwoslashOptions extends TransformerTwoslashOptions, Two
|
|
|
25
25
|
* Requires adding `twoslash` to the code block explicitly to run twoslash
|
|
26
26
|
* @default true
|
|
27
27
|
*/
|
|
28
|
-
explicitTrigger?:
|
|
28
|
+
explicitTrigger?: TransformerTwoslashOptions['explicitTrigger'];
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Create a Shiki transformer for VitePress to enable twoslash integration
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface VitePressPluginTwoslashOptions extends TransformerTwoslashOptions, Two
|
|
|
25
25
|
* Requires adding `twoslash` to the code block explicitly to run twoslash
|
|
26
26
|
* @default true
|
|
27
27
|
*/
|
|
28
|
-
explicitTrigger?:
|
|
28
|
+
explicitTrigger?: TransformerTwoslashOptions['explicitTrigger'];
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Create a Shiki transformer for VitePress to enable twoslash integration
|
package/dist/index.mjs
CHANGED
|
@@ -71,6 +71,9 @@ function rendererFloatingVue(options = {}) {
|
|
|
71
71
|
popupDocsTags: {
|
|
72
72
|
class: `twoslash-popup-docs twoslash-popup-docs-tags ${classMarkdown}`
|
|
73
73
|
},
|
|
74
|
+
popupError: {
|
|
75
|
+
class: `twoslash-popup-error ${classMarkdown}`
|
|
76
|
+
},
|
|
74
77
|
errorToken: errorRendering === "line" ? void 0 : {
|
|
75
78
|
tagName: "v-menu",
|
|
76
79
|
properties: {
|
|
@@ -155,14 +158,18 @@ function renderMarkdownInline(md, context) {
|
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
function transformerTwoslash(options = {}) {
|
|
161
|
+
const {
|
|
162
|
+
explicitTrigger = true
|
|
163
|
+
} = options;
|
|
158
164
|
const twoslash = createTransformerFactory(
|
|
159
165
|
createTwoslasher()
|
|
160
166
|
)({
|
|
161
167
|
langs: ["ts", "tsx", "js", "jsx", "json", "vue"],
|
|
162
|
-
explicitTrigger: true,
|
|
163
168
|
renderer: rendererFloatingVue(options),
|
|
164
|
-
...options
|
|
169
|
+
...options,
|
|
170
|
+
explicitTrigger
|
|
165
171
|
});
|
|
172
|
+
const trigger = explicitTrigger instanceof RegExp ? explicitTrigger : /\btwoslash\b/;
|
|
166
173
|
return {
|
|
167
174
|
...twoslash,
|
|
168
175
|
name: "@shikijs/vitepress-twoslash",
|
|
@@ -170,7 +177,7 @@ function transformerTwoslash(options = {}) {
|
|
|
170
177
|
const cleanup = options2.transformers?.find((i) => i.name === "vitepress:clean-up");
|
|
171
178
|
if (cleanup)
|
|
172
179
|
options2.transformers?.splice(options2.transformers.indexOf(cleanup), 1);
|
|
173
|
-
if (options2.meta?.__raw?.
|
|
180
|
+
if (!explicitTrigger || options2.meta?.__raw?.match(trigger)) {
|
|
174
181
|
const vPre = options2.transformers?.find((i) => i.name === "vitepress:v-pre");
|
|
175
182
|
if (vPre)
|
|
176
183
|
options2.transformers?.splice(options2.transformers.indexOf(vPre), 1);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/vitepress-twoslash",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "Enable Twoslash support in VitePress",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"mdast-util-from-markdown": "^2.0.0",
|
|
53
53
|
"mdast-util-gfm": "^3.0.0",
|
|
54
54
|
"mdast-util-to-hast": "^13.1.0",
|
|
55
|
-
"twoslash-vue": "^0.1.
|
|
55
|
+
"twoslash-vue": "^0.1.2",
|
|
56
56
|
"vue": "^3.4.15",
|
|
57
|
-
"@shikijs/twoslash": "1.0.0
|
|
58
|
-
"shiki": "1.0.0
|
|
57
|
+
"@shikijs/twoslash": "1.0.0",
|
|
58
|
+
"shiki": "1.0.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|