mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Alert users try to export md/txt in SNIPPET
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user