refactor(hooks): rename monacoTheme to currentTheme in useMonacoTheme

This commit is contained in:
cfngc4594 2025-03-19 14:58:11 +08:00
parent 24b5d96913
commit 154b66d524
3 changed files with 7 additions and 7 deletions

View File

@ -53,7 +53,7 @@ export default function CodeEditor({
setPath,
setValue,
} = useCodeEditorStore();
const { monacoTheme } = useMonacoTheme();
const { currentTheme } = useMonacoTheme();
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
const monacoLanguageClientRef = useRef<MonacoLanguageClient | null>(null);
@ -149,7 +149,7 @@ export default function CodeEditor({
return (
<Editor
language={language}
theme={monacoTheme.id}
theme={currentTheme.id}
path={path}
value={value}
beforeMount={handleEditorWillMount}

View File

@ -22,7 +22,7 @@ interface MdxPreviewProps {
}
export default function MdxPreview({ source }: MdxPreviewProps) {
const { monacoTheme } = useMonacoTheme();
const { currentTheme } = useMonacoTheme();
const [error, setError] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [mdxSource, setMdxSource] = useState<MDXRemoteSerializeResult | null>(null);
@ -56,7 +56,7 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
[
rehypePretty,
{
theme: monacoTheme.id,
theme: currentTheme.id,
keepBackground: false,
},
],
@ -72,7 +72,7 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
} finally {
setIsLoading(false);
}
}, [source, monacoTheme]);
}, [source, currentTheme]);
// Delay the serialize process to the next event loop to avoid flickering
// when copying code to the editor and the MDX preview shrinks.

View File

@ -5,9 +5,9 @@ import { MonacoThemeConfig } from "@/config/monaco-theme";
export function useMonacoTheme() {
const { resolvedTheme } = useTheme();
const monacoTheme = resolvedTheme === "light" ? MonacoThemeConfig[MonacoTheme.GitHubLightDefault] : MonacoThemeConfig[MonacoTheme.GitHubDarkDefault];
const currentTheme = resolvedTheme === "light" ? MonacoThemeConfig[MonacoTheme.GitHubLightDefault] : MonacoThemeConfig[MonacoTheme.GitHubDarkDefault];
return {
monacoTheme,
currentTheme,
};
}