mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +00:00
refactor(editor): update Monaco editor type imports and state to use editor
from monaco-editor
This commit is contained in:
parent
1893faad00
commit
4ad9bac50b
@ -1,6 +1,6 @@
|
|||||||
import * as monaco from "monaco-editor"
|
import { type editor } from "monaco-editor";
|
||||||
|
|
||||||
export const CODE_EDITOR_OPTIONS: monaco.editor.IEditorConstructionOptions = {
|
export const CODE_EDITOR_OPTIONS: editor.IEditorConstructionOptions = {
|
||||||
autoIndent: "full",
|
autoIndent: "full",
|
||||||
automaticLayout: true,
|
automaticLayout: true,
|
||||||
contextmenu: true,
|
contextmenu: true,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import * as monaco from "monaco-editor";
|
import { type editor } from "monaco-editor";
|
||||||
import { CODE_EDITOR_OPTIONS } from "@/constants/option";
|
import { CODE_EDITOR_OPTIONS } from "@/constants/option";
|
||||||
import { SupportedLanguage } from "@/constants/language";
|
import { SupportedLanguage } from "@/constants/language";
|
||||||
import { MonacoLanguageClient } from "monaco-languageclient";
|
import { MonacoLanguageClient } from "monaco-languageclient";
|
||||||
@ -7,12 +7,12 @@ import { persist, createJSONStorage } from "zustand/middleware";
|
|||||||
import { DEFAULT_EDITOR_LANGUAGE } from "@/config/editor/language";
|
import { DEFAULT_EDITOR_LANGUAGE } from "@/config/editor/language";
|
||||||
|
|
||||||
interface CodeEditorState {
|
interface CodeEditorState {
|
||||||
editor: monaco.editor.IStandaloneCodeEditor | null;
|
editor: editor.IStandaloneCodeEditor | null;
|
||||||
language: SupportedLanguage;
|
language: SupportedLanguage;
|
||||||
languageClient: MonacoLanguageClient | null;
|
languageClient: MonacoLanguageClient | null;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
result: string | null;
|
result: string | null;
|
||||||
setEditor: (editor: monaco.editor.IStandaloneCodeEditor | null) => void;
|
setEditor: (editor: editor.IStandaloneCodeEditor | null) => void;
|
||||||
setLanguage: (language: SupportedLanguage) => void;
|
setLanguage: (language: SupportedLanguage) => void;
|
||||||
setLanguageClient: (languageClient: MonacoLanguageClient | null) => void;
|
setLanguageClient: (languageClient: MonacoLanguageClient | null) => void;
|
||||||
setLoading: (loading: boolean) => void;
|
setLoading: (loading: boolean) => void;
|
||||||
@ -41,7 +41,7 @@ export const useCodeEditorState = create<CodeEditorState>()(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const useCodeEditorOption = create<monaco.editor.IEditorConstructionOptions>((set) => ({
|
export const useCodeEditorOption = create<editor.IEditorConstructionOptions>((set) => ({
|
||||||
fontSize: CODE_EDITOR_OPTIONS.fontSize,
|
fontSize: CODE_EDITOR_OPTIONS.fontSize,
|
||||||
lineHeight: CODE_EDITOR_OPTIONS.lineHeight,
|
lineHeight: CODE_EDITOR_OPTIONS.lineHeight,
|
||||||
setFontSize: (fontSize: number) => set({ fontSize }),
|
setFontSize: (fontSize: number) => set({ fontSize }),
|
||||||
|
Loading…
Reference in New Issue
Block a user