mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-18 15:26:36 +00:00
refactor(hooks): rename monacoTheme to currentTheme in useMonacoTheme
This commit is contained in:
parent
24b5d96913
commit
154b66d524
@ -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}
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user