feat(code-editor): update default value for code editor based on language

This commit is contained in:
cfngc4594 2025-02-20 14:14:04 +08:00
parent 5d99032be9
commit d3d27768fb

View File

@ -5,6 +5,7 @@ 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_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 { useCodeEditorState } from "@/store/useCodeEditor"; import { useCodeEditorState } from "@/store/useCodeEditor";
@ -76,7 +77,7 @@ export default function CodeEditor() {
return ( return (
<DynamicEditor <DynamicEditor
defaultLanguage={language} defaultLanguage={language}
defaultValue="# include<stdio.h>" defaultValue={DEFAULT_VALUE[language]}
path="file:///main.c" path="file:///main.c"
theme={resolvedTheme === "light" ? "github-light-default" : "github-dark-default"} theme={resolvedTheme === "light" ? "github-light-default" : "github-dark-default"}
height="100%" height="100%"