|
|
@ -15,7 +15,6 @@ import Settings from './Settings'
|
|
|
|
import Toolbar from './Toolbar'
|
|
|
|
import Toolbar from './Toolbar'
|
|
|
|
import Overlay from './Overlay'
|
|
|
|
import Overlay from './Overlay'
|
|
|
|
import Carbon from './Carbon'
|
|
|
|
import Carbon from './Carbon'
|
|
|
|
import api from '../lib/api'
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
THEMES,
|
|
|
|
THEMES,
|
|
|
|
THEMES_HASH,
|
|
|
|
THEMES_HASH,
|
|
|
@ -77,8 +76,8 @@ class Editor extends React.Component {
|
|
|
|
const initialState = Object.keys(queryParams).length ? queryParams : {}
|
|
|
|
const initialState = Object.keys(queryParams).length ? queryParams : {}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// TODO fix this hack
|
|
|
|
// TODO fix this hack
|
|
|
|
if (path.length >= 19 && path.indexOf('.') === -1) {
|
|
|
|
if (this.props.api.getGist && path.length >= 19 && path.indexOf('.') === -1) {
|
|
|
|
const { content, language } = await api.getGist(path)
|
|
|
|
const { content, language } = await this.props.api.getGist(path)
|
|
|
|
if (language) {
|
|
|
|
if (language) {
|
|
|
|
initialState.language = language.toLowerCase()
|
|
|
|
initialState.language = language.toLowerCase()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -122,12 +121,13 @@ class Editor extends React.Component {
|
|
|
|
// if safari, get image from api
|
|
|
|
// if safari, get image from api
|
|
|
|
const isPNG = format !== 'svg'
|
|
|
|
const isPNG = format !== 'svg'
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
|
|
|
|
this.props.api.image,
|
|
|
|
navigator.userAgent.indexOf('Safari') !== -1 &&
|
|
|
|
navigator.userAgent.indexOf('Safari') !== -1 &&
|
|
|
|
navigator.userAgent.indexOf('Chrome') === -1 &&
|
|
|
|
navigator.userAgent.indexOf('Chrome') === -1 &&
|
|
|
|
isPNG
|
|
|
|
isPNG
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
const encodedState = serializeState(this.state)
|
|
|
|
const encodedState = serializeState(this.state)
|
|
|
|
return api.image(encodedState)
|
|
|
|
return this.props.api.image(encodedState)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isPNG) {
|
|
|
|
if (isPNG) {
|
|
|
@ -207,7 +207,7 @@ class Editor extends React.Component {
|
|
|
|
upload() {
|
|
|
|
upload() {
|
|
|
|
this.setState({ uploading: true })
|
|
|
|
this.setState({ uploading: true })
|
|
|
|
this.getCarbonImage({ format: 'png' })
|
|
|
|
this.getCarbonImage({ format: 'png' })
|
|
|
|
.then(this.props.tweet.bind(null, this.state.code || DEFAULT_CODE))
|
|
|
|
.then(this.props.api.tweet.bind(null, this.state.code || DEFAULT_CODE))
|
|
|
|
// eslint-disable-next-line
|
|
|
|
// eslint-disable-next-line
|
|
|
|
.catch(console.error)
|
|
|
|
.catch(console.error)
|
|
|
|
.then(() => this.setState({ uploading: false }))
|
|
|
|
.then(() => this.setState({ uploading: false }))
|
|
|
@ -291,7 +291,7 @@ class Editor extends React.Component {
|
|
|
|
resetDefaultSettings={this.resetDefaultSettings}
|
|
|
|
resetDefaultSettings={this.resetDefaultSettings}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<div className="buttons">
|
|
|
|
<div className="buttons">
|
|
|
|
{this.props.tweet &&
|
|
|
|
{this.props.api.tweet &&
|
|
|
|
this.state.online && (
|
|
|
|
this.state.online && (
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
className="tweetButton"
|
|
|
|
className="tweetButton"
|
|
|
@ -369,6 +369,7 @@ function readAs(file) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Editor.defaultProps = {
|
|
|
|
Editor.defaultProps = {
|
|
|
|
|
|
|
|
api: {},
|
|
|
|
onUpdate: () => {}
|
|
|
|
onUpdate: () => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|