1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Alert users try to export md/txt in SNIPPET

This commit is contained in:
asmsuechan
2017-01-20 18:56:33 +09:00
parent f48864a2e7
commit 221b6a2938
2 changed files with 21 additions and 0 deletions

View File

@@ -38,6 +38,9 @@ class NoteList extends React.Component {
this.focusHandler = () => { this.focusHandler = () => {
this.refs.list.focus() this.refs.list.focus()
} }
this.alertIfSnippetHnalder = () => {
this.alertIfSnippet()
}
this.state = { this.state = {
} }
@@ -48,6 +51,7 @@ class NoteList extends React.Component {
ee.on('list:next', this.selectNextNoteHandler) ee.on('list:next', this.selectNextNoteHandler)
ee.on('list:prior', this.selectPriorNoteHandler) ee.on('list:prior', this.selectPriorNoteHandler)
ee.on('list:focus', this.focusHandler) ee.on('list:focus', this.focusHandler)
ee.on('list:isMarkdownNote', this.alertIfSnippetHnalder)
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {
@@ -66,6 +70,7 @@ class NoteList extends React.Component {
ee.off('list:next', this.selectNextNoteHandler) ee.off('list:next', this.selectNextNoteHandler)
ee.off('list:prior', this.selectPriorNoteHandler) ee.off('list:prior', this.selectPriorNoteHandler)
ee.off('list:focus', this.focusHandler) ee.off('list:focus', this.focusHandler)
ee.off('list:isMarkdownNote', this.alertIfSnippetHnalder)
} }
componentDidUpdate (prevProps) { 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 () { render () {
let { location, notes, config } = this.props let { location, notes, config } = this.props
let sortFunc = config.sortBy === 'CREATED_AT' let sortFunc = config.sortBy === 'CREATED_AT'

View File

@@ -68,12 +68,14 @@ var file = {
{ {
label: 'Plain Text (.txt)', label: 'Plain Text (.txt)',
click () { click () {
mainWindow.webContents.send('list:isMarkdownNote')
mainWindow.webContents.send('export:save-text') mainWindow.webContents.send('export:save-text')
} }
}, },
{ {
label: 'MarkDown (.md)', label: 'MarkDown (.md)',
click () { click () {
mainWindow.webContents.send('list:isMarkdownNote')
mainWindow.webContents.send('export:save-md') mainWindow.webContents.send('export:save-md')
} }
} }