File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ A CodeMirror extension that provides C# syntax highlighting and language support
88``` ts
99import { EditorState } from ' @codemirror/state' ;
1010import { EditorView } from ' @codemirror/view' ;
11- import { csharp } from " @replit/codemirror-lang-csharp" ;
11+ import { csharp } from ' @replit/codemirror-lang-csharp' ;
1212import { basicSetup } from ' codemirror' ;
1313
1414new EditorView ({
@@ -17,13 +17,13 @@ new EditorView({
1717using System;
1818namespace Test
1919{
20- class Program
21- {
22- public static void Main(string[] args)
20+ class Program
2321 {
24- Console.WriteLine("Hello, world!");
22+ public static void Main(string[] args)
23+ {
24+ Console.WriteLine("Hello, world!");
25+ }
2526 }
26- }
2727}
2828` ,
2929 extensions: [basicSetup , csharp ()],
Original file line number Diff line number Diff line change 1+ : root {
2+ color-scheme : dark;
3+ }
4+
5+ body ,
6+ html {
7+ width : 100% ;
8+ height : 100% ;
9+ }
10+
11+ body {
12+ margin : 0 ;
13+ overflow : hidden;
14+ }
15+
16+ div .split-view {
17+ width : 100% ;
18+ height : 100% ;
19+ display : flex;
20+ gap : 0.3rem ;
21+ }
22+
23+ div .split-view # editor ,
24+ div .split-view # syntax {
25+ display : flex;
26+ width : 50% ;
27+ overflow : auto;
28+ }
29+
30+ div .split-view # editor .cm-editor ,
31+ div .split-view # syntax pre {
32+ flex : 1 ;
33+ outline : none;
34+ overflow : inherit;
35+ }
36+
37+ div .split-view # syntax pre {
38+ margin : 0 ;
39+ padding : 4px 2px 4px 6px ;
40+ }
41+
42+ @media (max-width : 767px ) {
43+ div .split-view {
44+ flex-direction : column;
45+ }
46+
47+ div .split-view # editor ,
48+ div .split-view # syntax {
49+ width : 100% ;
50+ height : 50% ;
51+ }
52+ }
Original file line number Diff line number Diff line change 44< head >
55 < meta charset ="UTF-8 " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7- < title > Vite App</ title >
8- < style >
9- : root {
10- color-scheme : dark;
11- }
12- </ style >
7+ < title > codemirror-lang-csharp</ title >
8+ < meta name ="description " content ="A C# mode for CodeMirror 6 ">
9+ < link rel ="icon " href ="https://avatars.githubusercontent.com/u/983194 ">
10+ < link rel ="stylesheet " href ="./index.css " />
11+ < script type ="module " src ="./index.ts "> </ script >
1312</ head >
1413
15- < body class ="replit-ui-theme-root dark ">
16- < div id ="editor "> </ div >
17- < script type ="module " src ="./index.ts "> </ script >
14+ < body >
15+ < div class ="split-view ">
16+ < div id ="editor "> </ div >
17+ < div id ="syntax "> </ div >
18+ </ div >
1819</ body >
1920
2021</ html >
Original file line number Diff line number Diff line change @@ -233,6 +233,10 @@ namespace osu.Game.Rulesets
233233}
234234`
235235
236+ const syntax = document . createElement ( 'pre' ) ;
237+ syntax . className = 'ͼo' ;
238+ document . getElementById ( 'syntax' ) ! . appendChild ( syntax ) ;
239+
236240new EditorView ( {
237241 state : EditorState . create ( {
238242 doc,
@@ -242,15 +246,14 @@ new EditorView({
242246 oneDark ,
243247 keymap . of ( [ indentWithTab ] ) ,
244248 indentUnit . of ( ' ' ) ,
245- EditorView . lineWrapping ,
246249 EditorView . updateListener . of ( e => {
247250 if ( e . docChanged ) {
248251 const doc = e . state . doc . toString ( ) ;
249- console . log ( printTree ( parser . parse ( doc ) , doc ) ) ;
252+ syntax . textContent = printTree ( parser . parse ( doc ) , doc ) ;
250253 }
251254 } ) ] ,
252255 } ) ,
253256 parent : document . querySelector ( '#editor' ) ! ,
254257} ) ;
255258
256- console . log ( printTree ( parser . parse ( doc ) , doc ) ) ;
259+ syntax . textContent = printTree ( parser . parse ( doc ) , doc ) ;
You can’t perform that action at this time.
0 commit comments