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

Loading…
Cancel
Save