move format code into editor and make it work again

main
Mike Fix 6 years ago
parent 0aa7432022
commit 90a0ead95b

@ -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}
/>
<div className="buttons">
{this.props.api.tweet &&

@ -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 <MiscSettings format={this.format} reset={this.props.resetDefaultSettings} />
return <MiscSettings format={this.props.format} reset={this.props.resetDefaultSettings} />
default:
return null
}

Loading…
Cancel
Save