mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 18:56:22 +00:00
Merge pull request #1472 from Antogin/feat/add-ability-to-clone-note
Feat/add ability to clone note
This commit is contained in:
@@ -441,6 +441,7 @@ class NoteList extends React.Component {
|
|||||||
|
|
||||||
const pinLabel = note.isPinned ? 'Remove pin' : 'Pin to Top'
|
const pinLabel = note.isPinned ? 'Remove pin' : 'Pin to Top'
|
||||||
const deleteLabel = 'Delete Note'
|
const deleteLabel = 'Delete Note'
|
||||||
|
const cloneNote = 'Clone Note'
|
||||||
|
|
||||||
const menu = new Menu()
|
const menu = new Menu()
|
||||||
if (!location.pathname.match(/\/home|\/starred|\/trash/)) {
|
if (!location.pathname.match(/\/home|\/starred|\/trash/)) {
|
||||||
@@ -453,6 +454,10 @@ class NoteList extends React.Component {
|
|||||||
label: deleteLabel,
|
label: deleteLabel,
|
||||||
click: this.deleteNote
|
click: this.deleteNote
|
||||||
}))
|
}))
|
||||||
|
menu.append(new MenuItem({
|
||||||
|
label: cloneNote,
|
||||||
|
click: this.cloneNote.bind(this)
|
||||||
|
}))
|
||||||
menu.popup()
|
menu.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,6 +548,42 @@ class NoteList extends React.Component {
|
|||||||
this.setState({ selectedNoteKeys: [] })
|
this.setState({ selectedNoteKeys: [] })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cloneNote () {
|
||||||
|
const { selectedNoteKeys } = this.state
|
||||||
|
const { dispatch, location } = this.props
|
||||||
|
const { storage, folder } = this.resolveTargetFolder()
|
||||||
|
const notes = this.notes.map((note) => Object.assign({}, note))
|
||||||
|
const selectedNotes = findNotesByKeys(notes, selectedNoteKeys)
|
||||||
|
const firstNote = selectedNotes[0]
|
||||||
|
const eventName = firstNote.type === 'MARKDOWN_NOTE' ? 'ADD_MARKDOWN' : 'ADD_SNIPPET'
|
||||||
|
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent(eventName)
|
||||||
|
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
|
||||||
|
dataApi
|
||||||
|
.createNote(storage.key, {
|
||||||
|
type: firstNote.type,
|
||||||
|
folder: folder.key,
|
||||||
|
title: firstNote.title + ' copy',
|
||||||
|
content: firstNote.content
|
||||||
|
})
|
||||||
|
.then((note) => {
|
||||||
|
const uniqueKey = note.storage + '-' + note.key
|
||||||
|
dispatch({
|
||||||
|
type: 'UPDATE_NOTE',
|
||||||
|
note: note
|
||||||
|
})
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
selectedNoteKeys: [uniqueKey]
|
||||||
|
})
|
||||||
|
|
||||||
|
hashHistory.push({
|
||||||
|
pathname: location.pathname,
|
||||||
|
query: {key: uniqueKey}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
importFromFile () {
|
importFromFile () {
|
||||||
const options = {
|
const options = {
|
||||||
filters: [
|
filters: [
|
||||||
|
|||||||
Reference in New Issue
Block a user