diff --git a/.all-contributorsrc b/.all-contributorsrc
index 8a8c199..a7c67e5 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -257,6 +257,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "martinfrancois",
+ "name": "François Martin",
+ "avatar_url": "https://avatars1.githubusercontent.com/u/14319020?v=4",
+ "profile": "https://github.com/martinfrancois",
+ "contributions": [
+ "code"
+ ]
}
]
}
diff --git a/README.md b/README.md
index c89386e..747f2ab 100644
--- a/README.md
+++ b/README.md
@@ -78,5 +78,5 @@ Thanks goes out to all these wonderful people ([emoji key](https://github.com/ke
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [
otobrglez](https://github.com/otobrglez)
[💻](https://github.com/dawnlabs/carbon/commits?author=otobrglez "Code") | [
darahak](https://github.com/darahak)
[📖](https://github.com/dawnlabs/carbon/commits?author=darahak "Documentation") | [
dom96](https://github.com/dom96)
[💻](https://github.com/dawnlabs/carbon/commits?author=dom96 "Code") | [
elrumordelaluz](https://github.com/elrumordelaluz)
[💻](https://github.com/dawnlabs/carbon/commits?author=elrumordelaluz "Code") | [
cjb](https://github.com/cjb)
[💻](https://github.com/dawnlabs/carbon/commits?author=cjb "Code") | [
Krzysztof-Cieslak](https://github.com/Krzysztof-Cieslak)
[💻](https://github.com/dawnlabs/carbon/commits?author=Krzysztof-Cieslak "Code") | [
fernahh](https://github.com/fernahh)
[📖](https://github.com/dawnlabs/carbon/commits?author=fernahh "Documentation") |
| [
g3r4n](https://github.com/g3r4n)
[💻](https://github.com/dawnlabs/carbon/commits?author=g3r4n "Code") | [
Mat Gadd](http://drarok.com/)
[🐛](https://github.com/dawnlabs/carbon/issues?q=author%3ADrarok "Bug reports") [💻](https://github.com/dawnlabs/carbon/commits?author=Drarok "Code") | [
Brad Davies](https://bradlab.co.uk)
[🐛](https://github.com/dawnlabs/carbon/issues?q=author%3Avarbrad "Bug reports") [💻](https://github.com/dawnlabs/carbon/commits?author=varbrad "Code") | [
Rafael Câmara](http://www.rafaelcamaram.com/)
[💻](https://github.com/dawnlabs/carbon/commits?author=rafaelcamaram "Code") | [
Gleb Bahmutov](https://glebbahmutov.com/)
[⚠️](https://github.com/dawnlabs/carbon/commits?author=bahmutov "Tests") [🔧](#tool-bahmutov "Tools") | [
Iván Munguía](https://ivan-munguia.netlify.com)
[💻](https://github.com/dawnlabs/carbon/commits?author=warborn "Code") | [
Dillon Mulroy](https://dillonmulroy.com)
[💻](https://github.com/dawnlabs/carbon/commits?author=dmmulroy "Code") |
-| [
Nihad Abbasov](https://github.com/NARKOZ)
[💻](https://github.com/dawnlabs/carbon/commits?author=NARKOZ "Code") | [
Hugo Torzuoli](https://torzuolih.github.io)
[📖](https://github.com/dawnlabs/carbon/commits?author=TorzuoliH "Documentation") | [
Bruno C. Couto](https://github.com/bruno02221)
[💻](https://github.com/dawnlabs/carbon/commits?author=bruno02221 "Code") | [
Mark Molnar](https://github.com/molnarmark)
[💻](https://github.com/dawnlabs/carbon/commits?author=molnarmark "Code") | [
Takahiko Inayama](https://www.behance.net/tetra2000)
[💻](https://github.com/dawnlabs/carbon/commits?author=TETRA2000 "Code") |
+| [
Nihad Abbasov](https://github.com/NARKOZ)
[💻](https://github.com/dawnlabs/carbon/commits?author=NARKOZ "Code") | [
Hugo Torzuoli](https://torzuolih.github.io)
[📖](https://github.com/dawnlabs/carbon/commits?author=TorzuoliH "Documentation") | [
Bruno C. Couto](https://github.com/bruno02221)
[💻](https://github.com/dawnlabs/carbon/commits?author=bruno02221 "Code") | [
Mark Molnar](https://github.com/molnarmark)
[💻](https://github.com/dawnlabs/carbon/commits?author=molnarmark "Code") | [
Takahiko Inayama](https://www.behance.net/tetra2000)
[💻](https://github.com/dawnlabs/carbon/commits?author=TETRA2000 "Code") | [
François Martin](https://github.com/martinfrancois)
[💻](https://github.com/dawnlabs/carbon/commits?author=martinfrancois "Code") |
diff --git a/pages/editor.js b/pages/editor.js
index f1fb5b1..8d43576 100644
--- a/pages/editor.js
+++ b/pages/editor.js
@@ -14,6 +14,7 @@ import Settings from '../components/Settings'
import Toolbar from '../components/Toolbar'
import Overlay from '../components/Overlay'
import Carbon from '../components/Carbon'
+import ArrowDown from '../components/svg/Arrowdown'
import api from '../lib/api'
import {
THEMES,
@@ -67,6 +68,7 @@ class Editor extends React.Component {
...DEFAULT_SETTINGS,
uploading: false,
code: props.content,
+ saveAs: 'png',
_initialState: this.props.initialState
},
this.props.initialState
@@ -99,7 +101,7 @@ class Editor extends React.Component {
saveState(localStorage, s)
}
- getCarbonImage() {
+ getCarbonImage({ format } = { format: 'png' }) {
const node = document.getElementById('export-container')
const exportSize = (EXPORT_SIZES_HASH[this.state.exportSize] || DEFAULT_EXPORT_SIZE).value
@@ -116,7 +118,9 @@ class Editor extends React.Component {
: node.offsetHeight * exportSize
}
- return domtoimage.toPng(node, config)
+ return format.toLowerCase() === 'svg'
+ ? domtoimage.toSvg(node, config)
+ : domtoimage.toPng(node, config)
}
updateCode(code) {
@@ -131,10 +135,10 @@ class Editor extends React.Component {
this.setState({ titleBar })
}
- save() {
- this.getCarbonImage().then(dataUrl => {
+ save({ format } = { format: 'png' }) {
+ this.getCarbonImage({ format }).then(dataUrl => {
const link = document.createElement('a')
- link.download = 'carbon.png'
+ link.download = 'carbon.' + format
link.href = dataUrl
document.body.appendChild(link)
link.click()
@@ -149,7 +153,7 @@ class Editor extends React.Component {
upload() {
this.setState({ uploading: true })
- this.getCarbonImage()
+ this.getCarbonImage({ format: 'png' })
.then(api.tweet)
.then(() => this.setState({ uploading: false }))
.catch(err => {
@@ -195,7 +199,17 @@ class Editor extends React.Component {
color="#57b5f9"
style={{ marginRight: '8px' }}
/>
-
+