import React from 'react' import CSSModules from 'browser/lib/CSSModules' import styles from './NewNoteModal.styl' import ModalEscButton from 'browser/components/ModalEscButton' import i18n from 'browser/lib/i18n' import { createMarkdownNote, createSnippetNote } from 'browser/lib/newNote' class NewNoteModal extends React.Component { constructor (props) { super(props) this.lock = false this.state = {} } componentDidMount () { this.refs.markdownButton.focus() } handleCloseButtonClick (e) { this.props.close() } handleMarkdownNoteButtonClick (e) { const { storage, folder, dispatch, location, params, config } = this.props if (!this.lock) { this.lock = true createMarkdownNote(storage, folder, dispatch, location, params, config).then(() => { setTimeout(this.props.close, 200) }) } } handleMarkdownNoteButtonKeyDown (e) { if (e.keyCode === 9) { e.preventDefault() this.refs.snippetButton.focus() } } handleSnippetNoteButtonClick (e) { const { storage, folder, dispatch, location, params, config } = this.props if (!this.lock) { this.lock = true createSnippetNote(storage, folder, dispatch, location, params, config).then(() => { setTimeout(this.props.close, 200) }) } } handleSnippetNoteButtonKeyDown (e) { if (e.keyCode === 9) { e.preventDefault() this.refs.markdownButton.focus() } } handleKeyDown (e) { if (e.keyCode === 27) { this.props.close() } } render () { return (