mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +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,
|
setPath,
|
||||||
setValue,
|
setValue,
|
||||||
} = useCodeEditorStore();
|
} = useCodeEditorStore();
|
||||||
const { monacoTheme } = useMonacoTheme();
|
const { currentTheme } = useMonacoTheme();
|
||||||
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
||||||
const monacoLanguageClientRef = useRef<MonacoLanguageClient | null>(null);
|
const monacoLanguageClientRef = useRef<MonacoLanguageClient | null>(null);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ export default function CodeEditor({
|
|||||||
return (
|
return (
|
||||||
<Editor
|
<Editor
|
||||||
language={language}
|
language={language}
|
||||||
theme={monacoTheme.id}
|
theme={currentTheme.id}
|
||||||
path={path}
|
path={path}
|
||||||
value={value}
|
value={value}
|
||||||
beforeMount={handleEditorWillMount}
|
beforeMount={handleEditorWillMount}
|
||||||
|
@ -22,7 +22,7 @@ interface MdxPreviewProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function MdxPreview({ source }: MdxPreviewProps) {
|
export default function MdxPreview({ source }: MdxPreviewProps) {
|
||||||
const { monacoTheme } = useMonacoTheme();
|
const { currentTheme } = useMonacoTheme();
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||||
const [mdxSource, setMdxSource] = useState<MDXRemoteSerializeResult | null>(null);
|
const [mdxSource, setMdxSource] = useState<MDXRemoteSerializeResult | null>(null);
|
||||||
@ -56,7 +56,7 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
|
|||||||
[
|
[
|
||||||
rehypePretty,
|
rehypePretty,
|
||||||
{
|
{
|
||||||
theme: monacoTheme.id,
|
theme: currentTheme.id,
|
||||||
keepBackground: false,
|
keepBackground: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -72,7 +72,7 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, [source, monacoTheme]);
|
}, [source, currentTheme]);
|
||||||
|
|
||||||
// Delay the serialize process to the next event loop to avoid flickering
|
// Delay the serialize process to the next event loop to avoid flickering
|
||||||
// when copying code to the editor and the MDX preview shrinks.
|
// when copying code to the editor and the MDX preview shrinks.
|
||||||
|
@ -5,9 +5,9 @@ import { MonacoThemeConfig } from "@/config/monaco-theme";
|
|||||||
export function useMonacoTheme() {
|
export function useMonacoTheme() {
|
||||||
const { resolvedTheme } = useTheme();
|
const { resolvedTheme } = useTheme();
|
||||||
|
|
||||||
const monacoTheme = resolvedTheme === "light" ? MonacoThemeConfig[MonacoTheme.GitHubLightDefault] : MonacoThemeConfig[MonacoTheme.GitHubDarkDefault];
|
const currentTheme = resolvedTheme === "light" ? MonacoThemeConfig[MonacoTheme.GitHubLightDefault] : MonacoThemeConfig[MonacoTheme.GitHubDarkDefault];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
monacoTheme,
|
currentTheme,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user