Skip to content

Commit 4b61e33

Browse files
committed
feat(vitepress): make classes configurable
1 parent f54cbf6 commit 4b61e33

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

packages/shikiji-twoslash/style-rich.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
background-color: var(--twoslash-error-bg);
128128
border-left: 3px solid var(--twoslash-error-color);
129129
color: var(--twoslash-error-color);
130-
padding: 6px 6px;
130+
padding: 6px 12px;
131131
margin: 0.2em 0;
132132
}
133133

packages/vitepress-plugin-twoslash/src/renderer-floating-vue.ts

+25-9
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,34 @@ import type { ShikijiTransformerContext, ShikijiTransformerContextCommon } from
55
import { gfmFromMarkdown } from 'mdast-util-gfm'
66
import { fromMarkdown } from 'mdast-util-from-markdown'
77
import { defaultHandlers, toHast } from 'mdast-util-to-hast'
8-
import type { VitePressPluginTwoslashOptions } from 'vitepress-plugin-twoslash'
98

109
export { defaultHoverInfoProcessor }
1110

12-
export function rendererFloatingVue(options: VitePressPluginTwoslashOptions & RendererRichOptions = {}): TwoslashRenderer {
13-
const classCopyIgnore = 'vp-copy-ignore'
14-
const classFloatingPanel = 'twoslash-floating'
15-
const classCode = 'vp-code'
16-
const classMarkdown = 'vp-doc'
17-
const floatingVueTheme = 'twoslash'
18-
const floatingVueThemeQuery = 'twoslash-query'
19-
const floatingVueThemeCompletion = 'twoslash-completion'
11+
export interface TwoslashFloatingVueOptions {
12+
classCopyIgnore?: string
13+
classFloatingPanel?: string
14+
classCode?: string
15+
classMarkdown?: string
16+
17+
floatingVueTheme?: string
18+
floatingVueThemeQuery?: string
19+
floatingVueThemeCompletion?: string
20+
}
21+
22+
export interface TwoslashFloatingVueRendererOptions extends RendererRichOptions, TwoslashFloatingVueOptions {
23+
floatingVue?: TwoslashFloatingVueOptions
24+
}
25+
26+
export function rendererFloatingVue(options: TwoslashFloatingVueRendererOptions = {}): TwoslashRenderer {
27+
const {
28+
classCopyIgnore = 'vp-copy-ignore',
29+
classFloatingPanel = 'twoslash-floating',
30+
classCode = 'vp-code',
31+
classMarkdown = 'vp-doc',
32+
floatingVueTheme = 'twoslash',
33+
floatingVueThemeQuery = 'twoslash-query',
34+
floatingVueThemeCompletion = 'twoslash-completion',
35+
} = options.floatingVue || {}
2036

2137
const hoverBasicProps = {
2238
'class': 'twoslash-hover',

0 commit comments

Comments
 (0)