diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 1edb2fb2..f9604469 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -38,6 +38,9 @@ class NoteList extends React.Component { this.focusHandler = () => { this.refs.list.focus() } + this.alertIfSnippetHnalder = () => { + this.alertIfSnippet() + } this.state = { } @@ -48,6 +51,7 @@ class NoteList extends React.Component { ee.on('list:next', this.selectNextNoteHandler) ee.on('list:prior', this.selectPriorNoteHandler) ee.on('list:focus', this.focusHandler) + ee.on('list:isMarkdownNote', this.alertIfSnippetHnalder) } componentWillReceiveProps (nextProps) { @@ -66,6 +70,7 @@ class NoteList extends React.Component { ee.off('list:next', this.selectNextNoteHandler) ee.off('list:prior', this.selectPriorNoteHandler) ee.off('list:focus', this.focusHandler) + ee.off('list:isMarkdownNote', this.alertIfSnippetHnalder) } componentDidUpdate (prevProps) { @@ -305,6 +310,20 @@ class NoteList extends React.Component { }) } + alertIfSnippet() { + let { location } = this.props + let targetIndex = _.findIndex(this.notes, (note) => { + return note.storage + '-' + note.key === location.query.key + }) + if (this.notes[targetIndex].type === 'SNIPPET_NOTE') { + dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'warning', + message: 'Sorry!', + detail: 'md/text import is available only a markdown note.' + }) + } + } + render () { let { location, notes, config } = this.props let sortFunc = config.sortBy === 'CREATED_AT' diff --git a/lib/main-menu.js b/lib/main-menu.js index 9ae151ea..9a95fe1d 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -68,12 +68,14 @@ var file = { { label: 'Plain Text (.txt)', click () { + mainWindow.webContents.send('list:isMarkdownNote') mainWindow.webContents.send('export:save-text') } }, { label: 'MarkDown (.md)', click () { + mainWindow.webContents.send('list:isMarkdownNote') mainWindow.webContents.send('export:save-md') } }