@@ -19,17 +19,28 @@ import {
1919import { Tabs , TabsContent , TabsList , TabsTrigger } from "@/components/ui/tabs"
2020import { Textarea } from "@/components/ui/textarea"
2121
22+ import "@uiw/react-textarea-code-editor/dist.css"
23+ import { useTheme } from "next-themes"
24+
2225const MarkdownPreview = dynamic < MarkdownPreviewProps > (
2326 ( ) => import ( "@uiw/react-markdown-preview" ) ,
2427 {
2528 ssr : false ,
2629 }
2730)
2831
32+ const CodeEditor = dynamic (
33+ ( ) => import ( "@uiw/react-textarea-code-editor" ) . then ( ( mod ) => mod . default ) ,
34+ { ssr : false }
35+ )
2936export default function IndexPage ( ) {
37+ const { theme } = useTheme ( )
38+
3039 let model = "gpt-3.5-turbo"
31- let [ md , setMd ] = useState ( "# Hello" )
32- let [ sent , setSent ] = useState ( false )
40+ const [ md , setMd ] = useState ( "# Hello" )
41+ const [ sent , setSent ] = useState ( false )
42+ const [ template , setTemplate ] = React . useState ( `` )
43+ const [ codeSn , setCodeSn ] = useState ( "" )
3344
3445 async function getDoc ( ) {
3546 let key : string = ( document . getElementById ( "pwr" ) as HTMLInputElement ) . value
@@ -38,11 +49,6 @@ export default function IndexPage() {
3849 alert ( "Specify a valid key." )
3950 return
4051 }
41- let template = (
42- document . getElementById ( "templatetxt" ) as HTMLTextAreaElement
43- ) . value
44- let codeSn = ( document . getElementById ( "codesnippet" ) as HTMLTextAreaElement )
45- . value
4652 const configuration = new Configuration ( {
4753 apiKey : key ,
4854 } )
@@ -142,14 +148,32 @@ export default function IndexPage() {
142148 < div className = "space-y-2" >
143149 < h2 className = "text-2xl font-bold" > Settings</ h2 >
144150 < h3 className = "text-xl font-bold" > Template</ h3 >
145- < Textarea
146- id = "templatetxt"
151+ < CodeEditor
152+ className = "rounded-md border border-input"
153+ value = { template }
154+ language = "markdown"
147155 placeholder = "Paste your markdown documentation template here."
156+ onChange = { ( evn ) => setTemplate ( evn . target . value ) }
157+ padding = { 15 }
158+ data-color-mode = { theme == "light" ? "light" : "dark" }
159+ style = { {
160+ fontFamily :
161+ "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace" ,
162+ } }
148163 />
149164 < h3 className = "text-xl font-bold" > Code Snippet</ h3 >
150- < Textarea
151- id = "codesnippet"
165+ < CodeEditor
166+ className = "rounded-md border border-input"
167+ value = { codeSn }
168+ language = "markdown"
152169 placeholder = "Paste your code snippet here."
170+ onChange = { ( evn ) => setCodeSn ( evn . target . value ) }
171+ padding = { 15 }
172+ data-color-mode = { theme == "light" ? "light" : "dark" }
173+ style = { {
174+ fontFamily :
175+ "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace" ,
176+ } }
153177 />
154178 < h3 className = "text-xl font-bold" > Model</ h3 >
155179 < div className = "flex items-center space-x-2" >
0 commit comments