mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 11:57:02 -04:00
Shiki settings preview (#297)
This commit is contained in:
parent
49b45d8262
commit
2d08dd8a9c
6 changed files with 48 additions and 6 deletions
|
@ -18,8 +18,19 @@
|
|||
|
||||
import { useSettings } from "@api/settings";
|
||||
|
||||
import { shiki } from "../api/shiki";
|
||||
import { ShikiSettings } from "../types";
|
||||
|
||||
export function useShikiSettings(settings: (keyof ShikiSettings)[]) {
|
||||
return useSettings(settings.map(setting => `plugins.ShikiCodeblocks.${setting}`)).plugins.ShikiCodeblocks as ShikiSettings;
|
||||
export function useShikiSettings(settingKeys: (keyof ShikiSettings)[], overrides?: Record<string, any>) {
|
||||
const settings = useSettings(settingKeys.map(key => `plugins.ShikiCodeblocks.${key}`)).plugins.ShikiCodeblocks as ShikiSettings;
|
||||
|
||||
const withOverrides = { ...settings, ...overrides };
|
||||
|
||||
const themeUrl = withOverrides.customTheme || withOverrides.theme;
|
||||
if (themeUrl !== shiki.currentThemeUrl) shiki.setTheme(themeUrl);
|
||||
|
||||
return {
|
||||
...withOverrides,
|
||||
isThemeLoading: themeUrl !== shiki.currentThemeUrl,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue