diff --git a/components/Editor.js b/components/Editor.js index f684c1b..d0705cb 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -231,10 +231,10 @@ class Editor extends React.Component { } } - export(format = 'png') { + export(format = 'png', options = {}) { const link = document.createElement('a') - const prefix = this.state.filename || 'carbon' + const prefix = options.filename || 'carbon' return this.getCarbonImage({ format, type: 'blob' }).then(url => { if (format !== 'open') { diff --git a/components/ExportMenu.js b/components/ExportMenu.js index 697dc4c..14825a4 100644 --- a/components/ExportMenu.js +++ b/components/ExportMenu.js @@ -45,14 +45,19 @@ const CopyEmbed = withRouter(({ router: { asPath }, mapper, title, margin }) => const popoutStyle = { width: '280px', right: 0 } class ExportMenu extends React.PureComponent { + input = React.createRef() + handleInputChange = ({ target: { name, value } }) => this.props.onChange(name, value) handleExportSizeChange = selectedSize => () => this.props.onChange('exportSize', selectedSize) - handleExport = format => () => this.props.export(format) + handleExport = format => () => + this.props.export(format, { + filename: this.input.current.value + }) render() { - const { exportSize, filename, isVisible, toggleVisibility, disablePNG } = this.props + const { exportSize, isVisible, toggleVisibility, disablePNG } = this.props return (