diff --git a/components/Editor.js b/components/Editor.js index 6a3ab44..cf396cd 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -34,7 +34,7 @@ import { DEFAULT_LANGUAGE } from '../lib/constants' import { serializeState, getQueryStringState } from '../lib/routing' -import { getState, escapeHtml, unescapeHtml } from '../lib/util' +import { getState, escapeHtml, unescapeHtml, formatCode } from '../lib/util' import LanguageIcon from './svg/Language' import ThemeIcon from './svg/Theme' @@ -264,6 +264,13 @@ class Editor extends React.Component { } } + format = () => + formatCode(this.state.code) + .then(this.updateCode) + .catch(() => { + // create toast here in the future + }) + render() { const { loading, @@ -329,6 +336,7 @@ class Editor extends React.Component { {...config} onChange={this.updateSetting} resetDefaultSettings={this.resetDefaultSettings} + format={this.format} />
{this.props.api.tweet && diff --git a/components/Settings.js b/components/Settings.js index f102b01..6f134a2 100644 --- a/components/Settings.js +++ b/components/Settings.js @@ -7,7 +7,7 @@ import Slider from './Slider' import Toggle from './Toggle' import WindowPointer from './WindowPointer' import { COLORS } from '../lib/constants' -import { toggle, formatCode } from '../lib/util' +import { toggle } from '../lib/util' import SettingsIcon from './svg/Settings' import * as Arrows from './svg/Arrows' //import Remove from './svg/Remove' @@ -304,13 +304,6 @@ class Settings extends React.PureComponent { handleClickOutside = () => this.setState({ isVisible: false }) - format = () => - formatCode(this.props.code) - .then(this.props.onChange.bind(this, 'code')) - .catch(() => { - // create toast here in the future - }) - selectMenu = selectedMenu => () => this.setState({ selectedMenu }) renderContent = () => { @@ -341,7 +334,7 @@ class Settings extends React.PureComponent { /> ) case 'Misc': - return + return default: return null }