|
|
@ -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
|
|
|
|
// if safari, get image from api
|
|
|
|
const isPNG = format !== 'svg'
|
|
|
|
const isPNG = format !== 'svg'
|
|
|
|
if (
|
|
|
|
if (
|
|
|
@ -150,7 +150,7 @@ class Editor extends React.Component {
|
|
|
|
|
|
|
|
|
|
|
|
if (isPNG) {
|
|
|
|
if (isPNG) {
|
|
|
|
node.querySelectorAll('span[role="presentation"]').forEach(node => {
|
|
|
|
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)
|
|
|
|
map.set(node, node.innerText)
|
|
|
|
node.innerText = encodeURIComponent(node.innerText)
|
|
|
|
node.innerText = encodeURIComponent(node.innerText)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -178,24 +178,27 @@ class Editor extends React.Component {
|
|
|
|
height
|
|
|
|
height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (type === 'blob') {
|
|
|
|
try {
|
|
|
|
if (format === 'svg') {
|
|
|
|
if (type === 'blob') {
|
|
|
|
return domtoimage
|
|
|
|
if (format === 'svg') {
|
|
|
|
.toSvg(node, config)
|
|
|
|
return domtoimage
|
|
|
|
.then(dataUrl => dataUrl.replace(/ /g, ' '))
|
|
|
|
.toSvg(node, config)
|
|
|
|
.then(uri => uri.slice(uri.indexOf(',') + 1))
|
|
|
|
.then(dataUrl => dataUrl.replace(/ /g, ' '))
|
|
|
|
.then(data => new Blob([data], { type: 'image/svg+xml' }))
|
|
|
|
.then(uri => uri.slice(uri.indexOf(',') + 1))
|
|
|
|
.then(data => window.URL.createObjectURL(data))
|
|
|
|
.then(data => new Blob([data], { type: 'image/svg+xml' }))
|
|
|
|
|
|
|
|
.then(data => window.URL.createObjectURL(data))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await domtoimage.toBlob(node, config).then(blob => window.URL.createObjectURL(blob))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return domtoimage
|
|
|
|
// Twitter needs regular dataurls
|
|
|
|
.toBlob(node, config)
|
|
|
|
return await domtoimage.toPng(node, config)
|
|
|
|
.then(blob => window.URL.createObjectURL(blob))
|
|
|
|
} catch (error) {
|
|
|
|
.then(undoMap)
|
|
|
|
throw error
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
undoMap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Twitter needs regular dataurls
|
|
|
|
|
|
|
|
return domtoimage.toPng(node, config).then(undoMap)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateSetting(key, value) {
|
|
|
|
updateSetting(key, value) {
|
|
|
|