|
|
|
@ -19,21 +19,8 @@ const DEFAULT_SETTINGS = {
|
|
|
|
|
language: 'javascript'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CodeImage extends React.Component {
|
|
|
|
|
constructor (props) {
|
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
code: this.props.children
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateCode (newCode) {
|
|
|
|
|
this.setState({ code: newCode })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
const config = Object.assign(DEFAULT_SETTINGS, this.props.config)
|
|
|
|
|
const CodeImage = (props) => {
|
|
|
|
|
const config = Object.assign(DEFAULT_SETTINGS, props.config)
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
lineNumbers: false,
|
|
|
|
@ -51,12 +38,10 @@ class CodeImage extends React.Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div id='section'>
|
|
|
|
|
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/codemirror.min.css'/>
|
|
|
|
|
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/theme/dracula.min.css'/>
|
|
|
|
|
<div id='container' style={containerStyle}>
|
|
|
|
|
<div id="section">
|
|
|
|
|
<div id="container" style={containerStyle}>
|
|
|
|
|
{ true ? <WindowControls /> : null }
|
|
|
|
|
<CodeMirror className="CodeMirrorContainer" value={this.state.code} onChange={this.updateCode} options={options} />
|
|
|
|
|
<CodeMirror className="CodeMirrorContainer" value={props.children} options={options} />
|
|
|
|
|
</div>
|
|
|
|
|
<style jsx>{`
|
|
|
|
|
#section {
|
|
|
|
@ -69,6 +54,5 @@ class CodeImage extends React.Component {
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default CodeImage
|
|
|
|
|