|
|
@ -45,7 +45,6 @@ class Editor extends React.Component {
|
|
|
|
...DEFAULT_SETTINGS,
|
|
|
|
...DEFAULT_SETTINGS,
|
|
|
|
loading: true,
|
|
|
|
loading: true,
|
|
|
|
code: props.content,
|
|
|
|
code: props.content,
|
|
|
|
online: true,
|
|
|
|
|
|
|
|
preset: DEFAULT_PRESET_ID
|
|
|
|
preset: DEFAULT_PRESET_ID
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -87,8 +86,7 @@ class Editor extends React.Component {
|
|
|
|
...getSettings(localStorage),
|
|
|
|
...getSettings(localStorage),
|
|
|
|
// and then URL params
|
|
|
|
// and then URL params
|
|
|
|
...initialState,
|
|
|
|
...initialState,
|
|
|
|
loading: false,
|
|
|
|
loading: false
|
|
|
|
online: Boolean(window && window.navigator && window.navigator.onLine)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Makes sure the slash in 'application/X' is decoded
|
|
|
|
// Makes sure the slash in 'application/X' is decoded
|
|
|
@ -98,27 +96,17 @@ class Editor extends React.Component {
|
|
|
|
|
|
|
|
|
|
|
|
this.updateState(newState)
|
|
|
|
this.updateState(newState)
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('offline', this.setOffline)
|
|
|
|
|
|
|
|
window.addEventListener('online', this.setOnline)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isSafari =
|
|
|
|
this.isSafari =
|
|
|
|
window.navigator &&
|
|
|
|
window.navigator &&
|
|
|
|
window.navigator.userAgent.indexOf('Safari') !== -1 &&
|
|
|
|
window.navigator.userAgent.indexOf('Safari') !== -1 &&
|
|
|
|
window.navigator.userAgent.indexOf('Chrome') === -1
|
|
|
|
window.navigator.userAgent.indexOf('Chrome') === -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
|
|
|
window.removeEventListener('offline', this.setOffline)
|
|
|
|
|
|
|
|
window.removeEventListener('online', this.setOnline)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateState = updates => this.setState(updates, () => this.props.onUpdate(this.state))
|
|
|
|
updateState = updates => this.setState(updates, () => this.props.onUpdate(this.state))
|
|
|
|
|
|
|
|
|
|
|
|
updateCode = code => this.updateState({ code })
|
|
|
|
updateCode = code => this.updateState({ code })
|
|
|
|
updateAspectRatio = aspectRatio => this.updateState({ aspectRatio })
|
|
|
|
updateAspectRatio = aspectRatio => this.updateState({ aspectRatio })
|
|
|
|
updateTitleBar = titleBar => this.updateState({ titleBar })
|
|
|
|
updateTitleBar = titleBar => this.updateState({ titleBar })
|
|
|
|
setOffline = () => this.updateState({ online: false })
|
|
|
|
|
|
|
|
setOnline = () => this.updateState({ online: true })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async getCarbonImage(
|
|
|
|
async getCarbonImage(
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -293,7 +281,6 @@ class Editor extends React.Component {
|
|
|
|
backgroundImage,
|
|
|
|
backgroundImage,
|
|
|
|
backgroundMode,
|
|
|
|
backgroundMode,
|
|
|
|
aspectRatio,
|
|
|
|
aspectRatio,
|
|
|
|
online,
|
|
|
|
|
|
|
|
titleBar,
|
|
|
|
titleBar,
|
|
|
|
code,
|
|
|
|
code,
|
|
|
|
exportSize
|
|
|
|
exportSize
|
|
|
@ -348,7 +335,7 @@ class Editor extends React.Component {
|
|
|
|
getCarbonImage={this.getCarbonImage}
|
|
|
|
getCarbonImage={this.getCarbonImage}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<div className="buttons">
|
|
|
|
<div className="buttons">
|
|
|
|
{this.props.api.tweet && online && <TweetButton onClick={this.upload} />}
|
|
|
|
{this.props.api.tweet && <TweetButton onClick={this.upload} />}
|
|
|
|
<ExportMenu
|
|
|
|
<ExportMenu
|
|
|
|
onChange={this.updateSetting}
|
|
|
|
onChange={this.updateSetting}
|
|
|
|
export={this.export}
|
|
|
|
export={this.export}
|
|
|
|