mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(editor): add default editor options configuration
This commit is contained in:
parent
af23dd3289
commit
598ca75829
@ -11,11 +11,11 @@ import { highlighter } from "@/lib/shiki";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { shikiToMonaco } from "@shikijs/monaco";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { CODE_EDITOR_OPTIONS } from "@/constants/option";
|
||||
import { useMonacoTheme } from "@/hooks/use-monaco-theme";
|
||||
import { DEFAULT_EDITOR_PATH } from "@/config/editor/path";
|
||||
import { DEFAULT_EDITOR_VALUE } from "@/config/editor/value";
|
||||
import type { MonacoLanguageClient } from "monaco-languageclient";
|
||||
import { DefaultEditorOptionConfig } from "@/config/editor-option";
|
||||
import { SUPPORTED_LANGUAGE_SERVERS } from "@/config/lsp/language-server";
|
||||
import { useCodeEditorOptionStore, useCodeEditorStore } from "@/store/useCodeEditorStore";
|
||||
|
||||
@ -188,7 +188,7 @@ export default function CodeEditor() {
|
||||
}, [language]);
|
||||
|
||||
const mergeOptions = {
|
||||
...CODE_EDITOR_OPTIONS,
|
||||
...DefaultEditorOptionConfig,
|
||||
fontSize,
|
||||
lineHeight,
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { type editor } from "monaco-editor";
|
||||
|
||||
export const CODE_EDITOR_OPTIONS: editor.IEditorConstructionOptions = {
|
||||
export const DefaultEditorOptionConfig: editor.IEditorConstructionOptions = {
|
||||
autoIndent: "full",
|
||||
automaticLayout: true,
|
||||
contextmenu: true,
|
@ -2,9 +2,9 @@ import { create } from "zustand";
|
||||
import { type editor } from "monaco-editor";
|
||||
import { persist } from "zustand/middleware";
|
||||
import { JudgeResult } from "@/config/judge";
|
||||
import { CODE_EDITOR_OPTIONS } from "@/constants/option";
|
||||
import { SupportedLanguage } from "@/constants/language";
|
||||
import { MonacoLanguageClient } from "monaco-languageclient";
|
||||
import { DefaultEditorOptionConfig } from "@/config/editor-option";
|
||||
import { DEFAULT_EDITOR_LANGUAGE } from "@/config/editor/language";
|
||||
|
||||
interface CodeEditorState {
|
||||
@ -51,8 +51,8 @@ export const useCodeEditorStore = create<CodeEditorState>()(
|
||||
);
|
||||
|
||||
export const useCodeEditorOptionStore = create<editor.IEditorConstructionOptions>((set) => ({
|
||||
fontSize: CODE_EDITOR_OPTIONS.fontSize,
|
||||
lineHeight: CODE_EDITOR_OPTIONS.lineHeight,
|
||||
fontSize: DefaultEditorOptionConfig.fontSize,
|
||||
lineHeight: DefaultEditorOptionConfig.lineHeight,
|
||||
setFontSize: (fontSize: number) => set({ fontSize }),
|
||||
setLineHeight: (lineHeight: number) => set({ lineHeight }),
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user