+
+
\ No newline at end of file
diff --git a/playground/app/components/nav-button.vue b/playground/app/components/plain-button.vue
similarity index 86%
rename from playground/app/components/nav-button.vue
rename to playground/app/components/plain-button.vue
index 3010de2..323ac5d 100644
--- a/playground/app/components/nav-button.vue
+++ b/playground/app/components/plain-button.vue
@@ -1,7 +1,5 @@
@@ -15,17 +18,14 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/playground/app/components/theme-button.vue b/playground/app/components/theme-button.vue
index 64e6157..466e8cd 100644
--- a/playground/app/components/theme-button.vue
+++ b/playground/app/components/theme-button.vue
@@ -1,5 +1,5 @@
- & {
+export type UsePlainShikiOptions = Omit & {
lang: MaybeRefOrGetter;
+ themes: MaybeRefOrGetter>;
};
+let shiki: HighlighterCore;
+
export default function(el: MaybeRefOrGetter, options: UsePlainShikiOptions) {
const target = toRef(el);
const lang = toRef(options.lang);
+ const themes = toRef(options.themes);
let plain: CreatePlainShikiReturns;
let ctx: ReturnType<(typeof plain)["mount"]>;
- const { trigger } = watchTriggerable([target, lang], () => {
+ const { trigger } = watchTriggerable([target, lang, themes], async () => {
ctx?.dispose();
+
if (target.value) {
+ await shiki?.loadLanguage(bundledLanguages[lang.value]);
+ for (const theme of Object.values(themes.value)) {
+ await shiki?.loadTheme(bundledThemes[theme]);
+ }
+
ctx = plain?.mount(target.value, {
...options,
- lang: lang.value
+ lang: lang.value,
+ themes: themes.value
});
}
});
tryOnMounted(async () => {
- const shiki = await createHighlighter({
- langs: ["html", "css", "js", "ts"],
- themes: Object.values(options.themes ?? {}).filter((theme) => theme !== void 0),
+ shiki ??= await createHighlighterCore({
engine: createJavaScriptRegexEngine()
});