refactor(editor): update editor configuration paths and values

This commit is contained in:
cfngc4594 2025-02-25 14:39:55 +08:00
parent d51c324ea9
commit 50d1f4cf8e
3 changed files with 8 additions and 8 deletions

View File

@ -5,12 +5,12 @@ import dynamic from "next/dynamic";
import { useTheme } from "next-themes"; import { useTheme } from "next-themes";
import normalizeUrl from "normalize-url"; import normalizeUrl from "normalize-url";
import { highlighter } from "@/lib/shiki"; import { highlighter } from "@/lib/shiki";
import { DEFAULT_PATH } from "@/config/path";
import { DEFAULT_VALUE } from "@/config/value";
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 { CODE_EDITOR_OPTIONS } from "@/constants/option";
import { SUPPORTED_LANGUAGE_SERVERS } from "@/config/language-server"; import { DEFAULT_EDITOR_PATH } from "@/config/editor/path";
import { DEFAULT_EDITOR_VALUE } from "@/config/editor/value";
import { SUPPORTED_LANGUAGE_SERVERS } from "@/config/lsp/language-server";
import { useCodeEditorOption, useCodeEditorState } from "@/store/useCodeEditor"; import { useCodeEditorOption, useCodeEditorState } from "@/store/useCodeEditor";
import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from "vscode-ws-jsonrpc"; import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from "vscode-ws-jsonrpc";
@ -100,8 +100,8 @@ export default function CodeEditor() {
return ( return (
<Editor <Editor
defaultLanguage={language} defaultLanguage={language}
defaultValue={DEFAULT_VALUE[language]} defaultValue={DEFAULT_EDITOR_VALUE[language]}
path={DEFAULT_PATH[language]} path={DEFAULT_EDITOR_PATH[language]}
theme={resolvedTheme === "light" ? "github-light-default" : "github-dark-default"} theme={resolvedTheme === "light" ? "github-light-default" : "github-dark-default"}
className="h-full" className="h-full"
options={mergeOptions} options={mergeOptions}

View File

@ -46,7 +46,7 @@ export default function MdxPreview({ source }: MdxPreviewProps) {
className: ["subheading-anchor"], className: ["subheading-anchor"],
ariaLabel: "Link to section", ariaLabel: "Link to section",
}, },
} },
], ],
[ [
rehypePretty, rehypePretty,

View File

@ -1,6 +1,6 @@
import { create } from "zustand"; import { create } from "zustand";
import * as monaco from "monaco-editor"; import * as monaco from "monaco-editor";
import { DEFAULT_LANGUAGE } from "@/config/language"; import { DEFAULT_EDITOR_LANGUAGE } from "@/config/editor/language";
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";
@ -16,7 +16,7 @@ interface CodeEditorState {
export const useCodeEditorState = create<CodeEditorState>((set) => ({ export const useCodeEditorState = create<CodeEditorState>((set) => ({
editor: null, editor: null,
language: DEFAULT_LANGUAGE, language: DEFAULT_EDITOR_LANGUAGE,
languageClient: null, languageClient: null,
setEditor: (editor) => set({ editor }), setEditor: (editor) => set({ editor }),
setLanguage: (language) => set({ language }), setLanguage: (language) => set({ language }),