Skip to content

Commit

Permalink
feat: add defaultSelector option
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Oct 11, 2024
1 parent 4293171 commit a352866
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export interface MountPlainShikiOptions {
*/
selector?: (theme: string) => string;

/**
* @description Root element selector with default theme.
*
* @default ":root"
*/
defaultSelector?: string;

/**
* @description Whether to listen for element update events and automatic rendering.
*
Expand Down Expand Up @@ -61,6 +68,7 @@ export function createPlainShiki(shiki: HighlighterCore) {
},
defaultTheme = "light",
selector = (theme) => `.${theme}`,
defaultSelector = ":root",
watch = true,
delay = 33.4
} = options;
Expand Down Expand Up @@ -93,7 +101,7 @@ export function createPlainShiki(shiki: HighlighterCore) {
if (!ranges) {
colorRanges.set(name, ranges = new Set());
const rule = `${
isDefault ? ":root" : selector(theme)
isDefault ? defaultSelector : selector(theme)
}::highlight(${name}) { color: ${color}; }`;
stylesheet.insertRule(rule);
}
Expand Down

0 comments on commit a352866

Please sign in to comment.