Skip to content

Commit bf8f3bb

Browse files
committed
Added CodeMirror for syntax highlighting
1 parent 582d81c commit bf8f3bb

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
<head>
44
<title>react-virtualized</title>
55
<meta charset="utf-8">
6-
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
7-
<link
8-
type='image/x-icon'
9-
rel='shortcut icon'
10-
>
6+
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
7+
<link type="image/x-icon" rel="shortcut icon" />
8+
<link rel="stylesheet" type="text/css" href="https://npmcdn.com/codemirror@5.17.0/lib/codemirror.css" />
9+
<link rel="stylesheet" type="text/css" href="https://codemirror.net/theme/dracula.css" />
1110
</head>
1211
<body>
13-
<div id='root'></div>
12+
<div id="root"></div>
1413
</body>
1514
</html>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"react": "^15.2.1",
123123
"react-addons-shallow-compare": "^15.2.1",
124124
"react-addons-test-utils": "^15.2.1",
125+
"react-codemirror": "^0.2.6",
125126
"react-dom": "^15.2.1",
126127
"react-transform-catch-errors": "^1.0.2",
127128
"react-transform-hmr": "^1.0.2",

source/demo/Wizard/Wizard.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
/* @flow */
22
import cn from 'classnames'
3+
import CodeMirror from 'react-codemirror'
34
import React, { Component } from 'react'
45
import { ContentBox, ContentBoxHeader } from '../ContentBox'
56
import styles from './Wizard.css'
67

8+
require('codemirror/mode/javascript/javascript')
9+
10+
const codeMirrorOptions = {
11+
mode: 'javascript',
12+
theme: 'dracula'
13+
}
14+
715
// @TODO Clean up this class; it's pretty hacky.
816
export default class Wizard extends Component {
917
constructor (props) {
@@ -37,8 +45,6 @@ export default class Wizard extends Component {
3745
nonCheckerboardPattern
3846
} = this._sanitizeState()
3947

40-
// @TODO Use react-highlighter for markup
41-
4248
return (
4349
<div>
4450
<ContentBox>
@@ -107,9 +113,10 @@ export default class Wizard extends Component {
107113
</ContentBox>
108114
<ContentBox>
109115
<ContentBoxHeader text='Suggested Starting Point' />
110-
<pre>
111-
{this._generateMarkup()}
112-
</pre>
116+
<CodeMirror
117+
options={codeMirrorOptions}
118+
value={this._generateMarkup()}
119+
/>
113120
</ContentBox>
114121
</div>
115122
)

0 commit comments

Comments
 (0)