feat(editor): add default editor options configuration

This commit is contained in:
cfngc4594 2025-03-04 21:02:16 +08:00
parent af23dd3289
commit 598ca75829
3 changed files with 6 additions and 6 deletions

View File

@ -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,
};

View File

@ -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,

View File

@ -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 }),
}));