mirror of
https://litchi.icu/ngc2207/judge4c-demo.git
synced 2025-05-18 12:56:34 +00:00
feat: 在代码片段编辑表单中添加状态管理,更新编辑器内容处理
This commit is contained in:
parent
0d8974b9f3
commit
415aa13a33
@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Snippet } from "@prisma/client";
|
||||
import { Editor } from "@monaco-editor/react";
|
||||
|
||||
@ -8,6 +9,12 @@ interface SnippetEditFormProps {
|
||||
}
|
||||
|
||||
export default function SnippetEditForm({ snippet }: SnippetEditFormProps) {
|
||||
const [code, setCode] = useState(snippet.code);
|
||||
|
||||
const handleEditorChange = (value: string = "") => {
|
||||
setCode(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Editor
|
||||
@ -16,6 +23,7 @@ export default function SnippetEditForm({ snippet }: SnippetEditFormProps) {
|
||||
language="c"
|
||||
defaultValue={snippet.code}
|
||||
options={{ minimap: { enabled: false } }}
|
||||
onChange={handleEditorChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user