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