Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 28e8628

Browse files
committed
Replaced regular text areas with code editor
1 parent 167c5d0 commit 28e8628

File tree

3 files changed

+276
-11
lines changed

3 files changed

+276
-11
lines changed

app/page.tsx

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,28 @@ import {
1919
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
2020
import { Textarea } from "@/components/ui/textarea"
2121

22+
import "@uiw/react-textarea-code-editor/dist.css"
23+
import { useTheme } from "next-themes"
24+
2225
const 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+
)
2936
export 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">

package-lock.json

Lines changed: 240 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@radix-ui/react-select": "^1.2.1",
1818
"@radix-ui/react-tabs": "^1.0.3",
1919
"@uiw/react-markdown-preview": "^4.1.13",
20+
"@uiw/react-textarea-code-editor": "^2.1.1",
2021
"class-variance-authority": "^0.4.0",
2122
"clsx": "^1.2.1",
2223
"cmdk": "^0.2.0",

0 commit comments

Comments
 (0)