Skip to content

Commit 9171b5c

Browse files
committed
✔ First Commit
1 parent 0bbc4bc commit 9171b5c

File tree

8 files changed

+12867
-88
lines changed

8 files changed

+12867
-88
lines changed

package-lock.json

Lines changed: 12808 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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
{
2-
"name": "codemirror",
2+
"name": "codemirror-react",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"codemirror": "^5.48.0",
7+
"highlight.js": "^9.15.8",
68
"react": "^16.8.6",
9+
"react-codemirror": "^1.0.0",
10+
"react-codemirror2": "^6.0.0",
711
"react-dom": "^16.8.6",
812
"react-scripts": "3.0.1"
913
},
1014
"scripts": {
1115
"start": "react-scripts start",
12-
"build": "react-scripts build",
13-
"test": "react-scripts test",
14-
"eject": "react-scripts eject"
16+
"build": "react-scripts build"
1517
},
1618
"eslintConfig": {
1719
"extends": "react-app"

src/App.css

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
1-
.App {
2-
text-align: center;
3-
}
4-
5-
.App-logo {
6-
animation: App-logo-spin infinite 20s linear;
7-
height: 40vmin;
8-
pointer-events: none;
9-
}
10-
11-
.App-header {
12-
background-color: #282c34;
13-
min-height: 100vh;
14-
display: flex;
15-
flex-direction: column;
16-
align-items: center;
17-
justify-content: center;
18-
font-size: calc(10px + 2vmin);
19-
color: white;
20-
}
21-
22-
.App-link {
23-
color: #61dafb;
24-
}
25-
26-
@keyframes App-logo-spin {
27-
from {
28-
transform: rotate(0deg);
29-
}
30-
to {
31-
transform: rotate(360deg);
32-
}
33-
}
1+
.CodeMirror{
2+
font-family: monospace;
3+
font-size: 21pt;
4+
height: 100%;
5+
/* background-color: #44475a; */
6+
}

src/App.js

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React, { Component } from 'react';
2+
// import CodeMirror from 'react-codemirror';
3+
import 'codemirror/lib/codemirror.css';
4+
import './App.css'
5+
import {Controlled as CodeMirror} from 'react-codemirror2'
6+
import 'codemirror/mode/xml/xml'
7+
import 'codemirror/theme/dracula.css'
8+
49

5-
function App() {
6-
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10+
11+
export default class App extends Component {
12+
constructor(){
13+
super();
14+
this.state = {
15+
name: 'CodeMirror',
16+
code: ':)'
17+
};
18+
}
19+
20+
updateCode = (newCode) => {
21+
this.setState({
22+
code: newCode,
23+
});
24+
}
25+
26+
render() {
27+
const options = {
28+
lineNumbers: true,
29+
mode: 'xml',
30+
theme: 'dracula'
31+
};
32+
return (
33+
<div>
1034
<p>
11-
Edit <code>src/App.js</code> and save to reload.
35+
{this.state.code}
1236
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
23-
);
37+
{/* <CodeMirror value={this.state.code} onChange={this.updateCode} options={options} autoFocus={true} /> */}
38+
<CodeMirror
39+
value={this.state.code}
40+
options={options}
41+
onBeforeChange={(editor, data, code) => {
42+
this.setState({code});
43+
}}
44+
onChange={(editor, data, code) => {
45+
this.updateCode(code)
46+
}}
47+
/>
48+
</div>
49+
);
50+
}
2451
}
2552

26-
export default App;

src/App.test.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/index.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import './index.css';
43
import App from './App';
54
import * as serviceWorker from './serviceWorker';
65

src/logo.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)