undo map even if conversion fails

main
Mike Fix 6 years ago
parent 999bbff7fe
commit 3b67c0a846

@ -125,7 +125,7 @@ class Editor extends React.Component {
}
}
getCarbonImage({ format, type } = { format: 'png' }) {
async getCarbonImage({ format, type } = { format: 'png' }) {
// if safari, get image from api
const isPNG = format !== 'svg'
if (
@ -150,7 +150,7 @@ class Editor extends React.Component {
if (isPNG) {
node.querySelectorAll('span[role="presentation"]').forEach(node => {
if (node.innerText && node.innerText.match(/%\S\S/)) {
if (node.innerText && node.innerText.match(/%\d\S/)) {
map.set(node, node.innerText)
node.innerText = encodeURIComponent(node.innerText)
}
@ -178,6 +178,7 @@ class Editor extends React.Component {
height
}
try {
if (type === 'blob') {
if (format === 'svg') {
return domtoimage
@ -188,14 +189,16 @@ class Editor extends React.Component {
.then(data => window.URL.createObjectURL(data))
}
return domtoimage
.toBlob(node, config)
.then(blob => window.URL.createObjectURL(blob))
.then(undoMap)
return await domtoimage.toBlob(node, config).then(blob => window.URL.createObjectURL(blob))
}
// Twitter needs regular dataurls
return domtoimage.toPng(node, config).then(undoMap)
return await domtoimage.toPng(node, config)
} catch (error) {
throw error
} finally {
undoMap()
}
}
updateSetting(key, value) {

Loading…
Cancel
Save