2024-11-12 08:01:37 +00:00
|
|
|
"use client";
|
|
|
|
|
2024-11-12 08:10:16 +00:00
|
|
|
import { useState } from "react";
|
2024-11-12 08:01:37 +00:00
|
|
|
import { Snippet } from "@prisma/client";
|
2024-11-12 08:06:43 +00:00
|
|
|
import { Editor } from "@monaco-editor/react";
|
2024-11-12 08:01:37 +00:00
|
|
|
|
|
|
|
interface SnippetEditFormProps {
|
|
|
|
snippet: Snippet;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function SnippetEditForm({ snippet }: SnippetEditFormProps) {
|
2024-11-12 08:10:16 +00:00
|
|
|
const [code, setCode] = useState(snippet.code);
|
|
|
|
|
|
|
|
const handleEditorChange = (value: string = "") => {
|
|
|
|
setCode(value);
|
|
|
|
};
|
|
|
|
|
2024-11-12 08:06:43 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Editor
|
|
|
|
height="40vh"
|
|
|
|
theme="vs-light"
|
|
|
|
language="c"
|
|
|
|
defaultValue={snippet.code}
|
|
|
|
options={{ minimap: { enabled: false } }}
|
2024-11-12 08:10:16 +00:00
|
|
|
onChange={handleEditorChange}
|
2024-11-12 08:06:43 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2024-11-12 08:01:37 +00:00
|
|
|
}
|