Fix twitter bug

- Closes #347
main
Mike Fix 7 years ago
parent 3bbb98a3a2
commit dd5a996e72

@ -73,7 +73,7 @@ class Editor extends React.Component {
this.props.onUpdate(this.state) this.props.onUpdate(this.state)
} }
getCarbonImage({ format } = { format: 'png' }) { getCarbonImage({ format, type } = { format: 'png' }) {
// if safari, get image from api // if safari, get image from api
if ( if (
navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Safari') !== -1 &&
@ -112,6 +112,7 @@ class Editor extends React.Component {
height height
} }
if (type === 'blob') {
if (format === 'svg') { if (format === 'svg') {
return domtoimage return domtoimage
.toSvg(node, config) .toSvg(node, config)
@ -124,6 +125,10 @@ class Editor extends React.Component {
return domtoimage.toBlob(node, config).then(blob => window.URL.createObjectURL(blob)) return domtoimage.toBlob(node, config).then(blob => window.URL.createObjectURL(blob))
} }
// Twitter needs regular dataurls
return domtoimage.toPng(node, config)
}
updateSetting(key, value) { updateSetting(key, value) {
this.setState({ [key]: value }) this.setState({ [key]: value })
} }
@ -131,7 +136,7 @@ class Editor extends React.Component {
save({ id: format = 'png' }) { save({ id: format = 'png' }) {
const link = document.createElement('a') const link = document.createElement('a')
return this.getCarbonImage({ format }).then(url => { return this.getCarbonImage({ format, type: 'blob' }).then(url => {
link.download = `carbon.${format}` link.download = `carbon.${format}`
link.href = url link.href = url
document.body.appendChild(link) document.body.appendChild(link)

Loading…
Cancel
Save