diff --git a/components/Editor.js b/components/Editor.js index e5c1241..6f8b8c7 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -73,13 +73,13 @@ class Editor extends React.Component { online: Boolean(window && window.navigator && window.navigator.onLine) }) - window.addEventListener('offline', this.setOffline); - window.addEventListener('online', this.setOnline); + window.addEventListener('offline', this.setOffline) + window.addEventListener('online', this.setOnline) } componentWillUnmount() { - window.removeEventListener('offline', this.setOffline); - window.removeEventListener('online', this.setOnline); + window.removeEventListener('offline', this.setOffline) + window.removeEventListener('online', this.setOnline) } componentDidUpdate() { @@ -101,7 +101,7 @@ class Editor extends React.Component { if (isPNG) { document.querySelectorAll('.CodeMirror-line > span > span').forEach(n => { if (n.innerText && n.innerText.match(/%\S\S/)) { - n.innerText = encodeURIComponent(n.innerText); + n.innerText = encodeURIComponent(n.innerText) } }) } @@ -245,15 +245,16 @@ class Editor extends React.Component { resetDefaultSettings={this.resetDefaultSettings} />
- {this.props.tweet && this.state.online && ( -
@@ -298,16 +299,16 @@ class Editor extends React.Component { } function formatTimestamp() { - const timezoneOffset = (new Date()).getTimezoneOffset() * 60000 - const timeString = (new Date(Date.now() - timezoneOffset)).toISOString() + const timezoneOffset = new Date().getTimezoneOffset() * 60000 + const timeString = new Date(Date.now() - timezoneOffset) + .toISOString() .slice(0, 19) - .replace(/:/g,'-') - .replace('T','_') + .replace(/:/g, '-') + .replace('T', '_') - return timeString; + return timeString } - function isImage(file) { return file.type.split('/')[0] === 'image' } diff --git a/components/Header.js b/components/Header.js index 5bd713d..e0a1754 100644 --- a/components/Header.js +++ b/components/Header.js @@ -9,8 +9,8 @@ const Header = ({ enableHeroText }) => ( {enableHeroText ? (

- Create and share beautiful images of your source code.
Start typing or drop a file - into the text area to get started. + Create and share beautiful images of your source code. +
Start typing or drop a file into the text area to get started.

) : null} diff --git a/components/Meta.js b/components/Meta.js index ee01293..27b7e13 100644 --- a/components/Meta.js +++ b/components/Meta.js @@ -36,7 +36,7 @@ export default () => { Carbon - + @@ -123,8 +135,10 @@ class Settings extends React.Component { selected={this.props.exportSize || '2x'} onChange={this.props.onChange.bind(null, 'exportSize')} /> + Reset settings} + center={true} enabled={false} onChange={this.props.resetDefaultSettings} /> @@ -186,6 +200,10 @@ class Settings extends React.Component { .settings-settings > :global(.collapse) { border-bottom: none; } + + .red { + color: red; + } `} diff --git a/components/Slider.js b/components/Slider.js index b049f6f..1ce0231 100644 --- a/components/Slider.js +++ b/components/Slider.js @@ -13,7 +13,7 @@ export default class extends React.Component { render() { const minValue = this.props.minValue || 0 const maxValue = this.props.maxValue || 100 - const step = 'step' in this.props ? this.props.step : 1; + const step = 'step' in this.props ? this.props.step : 1 return (
diff --git a/handlers/image.js b/handlers/image.js index 09962d0..fd1eefc 100644 --- a/handlers/image.js +++ b/handlers/image.js @@ -26,7 +26,8 @@ module.exports = browser => async (req, res) => { filter: n => { // %[00 -> 19] cause failures if ( - n.innerText && n.innerText.match(/%\S\S/) && + n.innerText && + n.innerText.match(/%\S\S/) && n.className && n.className.startsWith('cm-') // is CodeMirror primitive string ) { diff --git a/lib/routing.js b/lib/routing.js index 4c09eb2..c6dc8d8 100644 --- a/lib/routing.js +++ b/lib/routing.js @@ -52,9 +52,8 @@ const reverseMappings = mappings.map(mapping => export const serializeState = state => { const stateString = encodeURIComponent(JSON.stringify(state)) - return encodeURIComponent(typeof window !== 'undefined' - ? btoa(stateString) - : Buffer.from(stateString).toString('base64') + return encodeURIComponent( + typeof window !== 'undefined' ? btoa(stateString) : Buffer.from(stateString).toString('base64') ) } diff --git a/lib/util.js b/lib/util.js index bb2696c..48fa357 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,4 +1,6 @@ import morph from 'morphmorph' +import prettier from 'prettier/standalone' +import babylonParser from 'prettier/parser-babylon' const KEY = 'CARBON_STATE' @@ -40,3 +42,11 @@ export const fileToDataURL = blob => reader.onload = e => res(e.target.result) reader.readAsDataURL(blob) }) + +export const formatCode = code => + prettier.format(code, { + parser: 'babylon', + plugins: [babylonParser], + semi: false, + singleQuote: true + })