mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(store): add editor state to useCodeEditor store
This commit is contained in:
parent
adf59f8132
commit
5cabdda667
@ -6,15 +6,19 @@ import { SupportedLanguage } from "@/constants/language";
|
||||
import { MonacoLanguageClient } from "monaco-languageclient";
|
||||
|
||||
interface CodeEditorState {
|
||||
editor: monaco.editor.IStandaloneCodeEditor | null;
|
||||
language: SupportedLanguage;
|
||||
languageClient: MonacoLanguageClient | null;
|
||||
setEditor: (editor: monaco.editor.IStandaloneCodeEditor | null) => void;
|
||||
setLanguage: (language: SupportedLanguage) => void;
|
||||
setLanguageClient: (languageClient: MonacoLanguageClient | null) => void;
|
||||
}
|
||||
|
||||
export const useCodeEditorState = create<CodeEditorState>((set) => ({
|
||||
editor: null,
|
||||
language: DEFAULT_LANGUAGE,
|
||||
languageClient: null,
|
||||
setEditor: (editor) => set({ editor }),
|
||||
setLanguage: (language) => set({ language }),
|
||||
setLanguageClient: (languageClient) => set({ languageClient }),
|
||||
}));
|
||||
@ -23,5 +27,5 @@ export const useCodeEditorOption = create<monaco.editor.IEditorConstructionOptio
|
||||
fontSize: CODE_EDITOR_OPTIONS.fontSize,
|
||||
lineHeight: CODE_EDITOR_OPTIONS.lineHeight,
|
||||
setFontSize: (fontSize: number) => set({ fontSize }),
|
||||
setLineHeight: (lineHeight: number) => set({ lineHeight })
|
||||
}))
|
||||
setLineHeight: (lineHeight: number) => set({ lineHeight }),
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user