|
|
|
@ -55,6 +55,7 @@ class Editor extends React.Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.exportImage = this.exportImage.bind(this)
|
|
|
|
|
this.copyImage = this.copyImage.bind(this)
|
|
|
|
|
this.upload = this.upload.bind(this)
|
|
|
|
|
this.updateSetting = this.updateSetting.bind(this)
|
|
|
|
|
this.updateLanguage = this.updateLanguage.bind(this)
|
|
|
|
@ -181,7 +182,8 @@ class Editor extends React.Component {
|
|
|
|
|
// current font-family used
|
|
|
|
|
const fontFamily = this.state.fontFamily
|
|
|
|
|
try {
|
|
|
|
|
if (type === 'blob') {
|
|
|
|
|
// TODO consolidate type/format to only use one param
|
|
|
|
|
if (type === 'objectURL') {
|
|
|
|
|
if (format === 'svg') {
|
|
|
|
|
return (
|
|
|
|
|
domtoimage
|
|
|
|
@ -209,6 +211,10 @@ class Editor extends React.Component {
|
|
|
|
|
return await domtoimage.toBlob(node, config).then(blob => window.URL.createObjectURL(blob))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === 'blob') {
|
|
|
|
|
return await domtoimage.toBlob(node, config)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Twitter needs regular dataurls
|
|
|
|
|
return await domtoimage.toPng(node, config)
|
|
|
|
|
} finally {
|
|
|
|
@ -228,7 +234,7 @@ class Editor extends React.Component {
|
|
|
|
|
|
|
|
|
|
const prefix = options.filename || 'carbon'
|
|
|
|
|
|
|
|
|
|
return this.getCarbonImage({ format, type: 'blob' }).then(url => {
|
|
|
|
|
return this.getCarbonImage({ format, type: 'objectURL' }).then(url => {
|
|
|
|
|
if (format !== 'open') {
|
|
|
|
|
link.download = `${prefix}.${format}`
|
|
|
|
|
}
|
|
|
|
@ -242,6 +248,16 @@ class Editor extends React.Component {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
copyImage() {
|
|
|
|
|
return this.getCarbonImage({ format: 'png', type: 'blob' }).then(blob =>
|
|
|
|
|
navigator.clipboard.write([
|
|
|
|
|
new window.ClipboardItem({
|
|
|
|
|
'image/png': blob
|
|
|
|
|
})
|
|
|
|
|
])
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetDefaultSettings() {
|
|
|
|
|
this.updateState(DEFAULT_SETTINGS)
|
|
|
|
|
this.props.onReset()
|
|
|
|
@ -398,6 +414,7 @@ class Editor extends React.Component {
|
|
|
|
|
<ExportMenu
|
|
|
|
|
onChange={this.updateSetting}
|
|
|
|
|
exportImage={this.exportImage}
|
|
|
|
|
copyImage={this.copyImage}
|
|
|
|
|
exportSize={exportSize}
|
|
|
|
|
backgroundImage={backgroundImage}
|
|
|
|
|
/>
|
|
|
|
|