|
|
@ -23,10 +23,11 @@ class Carbon extends React.Component {
|
|
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
this.state = {
|
|
|
|
loading: true,
|
|
|
|
loading: true,
|
|
|
|
language: props.config.language
|
|
|
|
language: props.config.language,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.handleLanguageChange = this.handleLanguageChange.bind(this)
|
|
|
|
this.handleLanguageChange = this.handleLanguageChange.bind(this)
|
|
|
|
|
|
|
|
this.codeUpdated = this.codeUpdated.bind(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
componentDidMount() {
|
|
|
@ -41,6 +42,11 @@ class Carbon extends React.Component {
|
|
|
|
this.handleLanguageChange(newProps.children, { customProps: newProps })
|
|
|
|
this.handleLanguageChange(newProps.children, { customProps: newProps })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
codeUpdated (newCode) {
|
|
|
|
|
|
|
|
this.handleLanguageChange(newCode)
|
|
|
|
|
|
|
|
this.props.updateCode(newCode)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleLanguageChange(newCode, config) {
|
|
|
|
handleLanguageChange(newCode, config) {
|
|
|
|
const props = (config && config.customProps) || this.props
|
|
|
|
const props = (config && config.customProps) || this.props
|
|
|
|
|
|
|
|
|
|
|
@ -93,7 +99,7 @@ class Carbon extends React.Component {
|
|
|
|
{ config.windowControls ? <WindowControls theme={config.windowTheme} /> : null }
|
|
|
|
{ config.windowControls ? <WindowControls theme={config.windowTheme} /> : null }
|
|
|
|
<CodeMirror
|
|
|
|
<CodeMirror
|
|
|
|
className={`CodeMirror__container window-theme__${config.windowTheme} ${config.dropShadow ? 'dropshadow' : ''}`}
|
|
|
|
className={`CodeMirror__container window-theme__${config.windowTheme} ${config.dropShadow ? 'dropshadow' : ''}`}
|
|
|
|
onChange={this.handleLanguageChange}
|
|
|
|
onChange={this.codeUpdated}
|
|
|
|
value={this.props.children}
|
|
|
|
value={this.props.children}
|
|
|
|
options={options}
|
|
|
|
options={options}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|