|
|
@ -200,14 +200,11 @@ class Editor extends React.Component {
|
|
|
|
export(format = 'png') {
|
|
|
|
export(format = 'png') {
|
|
|
|
const link = document.createElement('a')
|
|
|
|
const link = document.createElement('a')
|
|
|
|
|
|
|
|
|
|
|
|
const timestamp = this.state.timestamp ? `_${formatTimestamp()}` : ''
|
|
|
|
|
|
|
|
const prefix = this.state.filename || 'carbon'
|
|
|
|
const prefix = this.state.filename || 'carbon'
|
|
|
|
|
|
|
|
|
|
|
|
return this.getCarbonImage({ format, type: 'blob' }).then(url => {
|
|
|
|
return this.getCarbonImage({ format, type: 'blob' }).then(url => {
|
|
|
|
if (format === 'open') {
|
|
|
|
if (format !== 'open') {
|
|
|
|
link.target = '_blank'
|
|
|
|
link.download = `${prefix}.${format}`
|
|
|
|
} else {
|
|
|
|
|
|
|
|
link.download = `${prefix}${timestamp}.${format}`
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
link.href = url
|
|
|
|
link.href = url
|
|
|
|
document.body.appendChild(link)
|
|
|
|
document.body.appendChild(link)
|
|
|
@ -386,17 +383,6 @@ class Editor extends React.Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function formatTimestamp() {
|
|
|
|
|
|
|
|
const timezoneOffset = new Date().getTimezoneOffset() * 60000
|
|
|
|
|
|
|
|
const timeString = new Date(Date.now() - timezoneOffset)
|
|
|
|
|
|
|
|
.toISOString()
|
|
|
|
|
|
|
|
.slice(0, 19)
|
|
|
|
|
|
|
|
.replace(/:/g, '-')
|
|
|
|
|
|
|
|
.replace('T', '_')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return timeString
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isImage(file) {
|
|
|
|
function isImage(file) {
|
|
|
|
return file.type.split('/')[0] === 'image'
|
|
|
|
return file.type.split('/')[0] === 'image'
|
|
|
|
}
|
|
|
|
}
|
|
|
|