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