|
|
@ -143,12 +143,7 @@ class Editor extends React.Component {
|
|
|
|
save({ id: format = 'png' }) {
|
|
|
|
save({ id: format = 'png' }) {
|
|
|
|
const link = document.createElement('a')
|
|
|
|
const link = document.createElement('a')
|
|
|
|
|
|
|
|
|
|
|
|
const timezoneOffset = (new Date()).getTimezoneOffset() * 60000
|
|
|
|
const timestamp = this.state.timestamp ? `_${formatTimestamp()}` : ''
|
|
|
|
const timeString = (new Date(Date.now() - timezoneOffset)).toISOString()
|
|
|
|
|
|
|
|
.slice(0, 19)
|
|
|
|
|
|
|
|
.replace(/:/g,'-')
|
|
|
|
|
|
|
|
.replace('T','_')
|
|
|
|
|
|
|
|
const timestamp = this.state.timestamp ? `_${timeString}` : ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.getCarbonImage({ format, type: 'blob' }).then(url => {
|
|
|
|
return this.getCarbonImage({ format, type: 'blob' }).then(url => {
|
|
|
|
link.download = `carbon${timestamp}.${format}`
|
|
|
|
link.download = `carbon${timestamp}.${format}`
|
|
|
@ -292,6 +287,17 @@ 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'
|
|
|
|
}
|
|
|
|
}
|
|
|
|