File tree Expand file tree Collapse file tree 3 files changed +72
-4
lines changed
Expand file tree Collapse file tree 3 files changed +72
-4
lines changed Original file line number Diff line number Diff line change 3838 "vite" : " ^7.1.7"
3939 },
4040 "dependencies" : {
41+ "@codemirror/lang-javascript" : " ^6.2.4" ,
42+ "@codemirror/theme-one-dark" : " ^6.1.3" ,
43+ "@codemirror/view" : " ^6.38.7" ,
4144 "@prisma/adapter-pg" : " ^6.19.0" ,
4245 "@prisma/client" : " ^6.19.0" ,
46+ "svelte-codemirror-editor" : " ^2.1.0" ,
4347 "valibot" : " ^1.1.0"
4448 }
4549}
Original file line number Diff line number Diff line change 99 import { CodeManager } from " $lib/models/CodeManager.svelte" ;
1010 import BoardModals from " $lib/components/BoardModals.svelte" ;
1111 import CodeModals from " $lib/components/CodeModals.svelte" ;
12+ import CodeMirror from " svelte-codemirror-editor" ;
13+ import { javascript } from " @codemirror/lang-javascript" ;
14+ import { oneDark } from " @codemirror/theme-one-dark" ;
15+ import { EditorView } from " @codemirror/view" ;
1216
1317 let editingCode = $state (lifeGameJS );
1418 let appliedCode = $state (lifeGameJS );
108112 editingCode = code ;
109113 }
110114 }
115+
116+ const editorTheme = EditorView .theme ({
117+ " &" : {
118+ height: " 100%" ,
119+ maxHeight: " 100%" ,
120+ },
121+ " .cm-scroller" : {
122+ overflow: " auto" ,
123+ maxHeight: " 100%" ,
124+ },
125+ " .cm-content, .cm-gutter" : {
126+ minHeight: " 100%" ,
127+ },
128+ });
111129 </script >
112130
113131<div class =" navbar bg-[#E0E0E0] shadow-sm" >
248266 showEditor ? " basis-[40%] opacity-100" : " basis-0 opacity-0" ,
249267 ]}
250268 >
251- <textarea
252- bind:value ={editingCode }
253- class =" w-full h-full border-none p-4 font-mono bg-black text-[#0f0]"
254- ></textarea >
269+ <div class =" w-full h-full overflow-y-auto" >
270+ <CodeMirror
271+ bind:value ={editingCode }
272+ lang ={javascript ()}
273+ theme ={oneDark }
274+ extensions ={[editorTheme ]}
275+ />
276+ </div >
255277 </div >
256278</div >
257279
You can’t perform that action at this time.
0 commit comments