mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
@@ -45,7 +45,7 @@ const TagElementList = (tags) => {
|
|||||||
* @param {Function} handleDragStart
|
* @param {Function} handleDragStart
|
||||||
* @param {string} dateDisplay
|
* @param {string} dateDisplay
|
||||||
*/
|
*/
|
||||||
const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu, handleDragStart }) => (
|
const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu, handleDragStart, pathname }) => (
|
||||||
<div styleName={isActive
|
<div styleName={isActive
|
||||||
? 'item--active'
|
? 'item--active'
|
||||||
: 'item'
|
: 'item'
|
||||||
@@ -72,6 +72,9 @@ const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteCont
|
|||||||
{note.isStarred
|
{note.isStarred
|
||||||
? <i styleName='item-star' className='fa fa-star' /> : ''
|
? <i styleName='item-star' className='fa fa-star' /> : ''
|
||||||
}
|
}
|
||||||
|
{note.isPinned && !pathname.match(/\/home|\/starred|\/trash/)
|
||||||
|
? <i styleName='item-pin' className='fa fa-map-pin' /> : ''
|
||||||
|
}
|
||||||
{note.type === 'MARKDOWN_NOTE'
|
{note.type === 'MARKDOWN_NOTE'
|
||||||
? <TodoProcess todoStatus={getTodoStatus(note.content)} />
|
? <TodoProcess todoStatus={getTodoStatus(note.content)} />
|
||||||
: ''
|
: ''
|
||||||
@@ -101,6 +104,7 @@ NoteItem.propTypes = {
|
|||||||
isTrashed: PropTypes.bool.isRequired
|
isTrashed: PropTypes.bool.isRequired
|
||||||
}),
|
}),
|
||||||
handleNoteClick: PropTypes.func.isRequired,
|
handleNoteClick: PropTypes.func.isRequired,
|
||||||
|
handleNoteContextMenu: PropTypes.func.isRequired,
|
||||||
handleDragStart: PropTypes.func.isRequired,
|
handleDragStart: PropTypes.func.isRequired,
|
||||||
handleDragEnd: PropTypes.func.isRequired
|
handleDragEnd: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { hashHistory } from 'react-router'
|
|||||||
import markdown from 'browser/lib/markdown'
|
import markdown from 'browser/lib/markdown'
|
||||||
import { findNoteTitle } from 'browser/lib/findNoteTitle'
|
import { findNoteTitle } from 'browser/lib/findNoteTitle'
|
||||||
import stripgtags from 'striptags'
|
import stripgtags from 'striptags'
|
||||||
|
import store from 'browser/main/store'
|
||||||
|
|
||||||
const { remote } = require('electron')
|
const { remote } = require('electron')
|
||||||
const { Menu, MenuItem, dialog } = remote
|
const { Menu, MenuItem, dialog } = remote
|
||||||
@@ -251,7 +252,7 @@ class NoteList extends React.Component {
|
|||||||
if (location.pathname.match(/\/searched/)) {
|
if (location.pathname.match(/\/searched/)) {
|
||||||
const searchInputText = document.getElementsByClassName('searchInput')[0].value
|
const searchInputText = document.getElementsByClassName('searchInput')[0].value
|
||||||
if (searchInputText === '') {
|
if (searchInputText === '') {
|
||||||
return this.contextNotes
|
return this.sortByPin(this.contextNotes)
|
||||||
}
|
}
|
||||||
return searchFromNotes(this.contextNotes, searchInputText)
|
return searchFromNotes(this.contextNotes, searchInputText)
|
||||||
}
|
}
|
||||||
@@ -283,6 +284,14 @@ class NoteList extends React.Component {
|
|||||||
return folderNoteKeyList.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
return folderNoteKeyList.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortByPin (unorderedNotes) {
|
||||||
|
const pinnedNotes = unorderedNotes.filter((note) => {
|
||||||
|
return note.isPinned
|
||||||
|
})
|
||||||
|
|
||||||
|
return pinnedNotes.concat(unorderedNotes)
|
||||||
|
}
|
||||||
|
|
||||||
handleNoteClick (e, uniqueKey) {
|
handleNoteClick (e, uniqueKey) {
|
||||||
let { router } = this.context
|
let { router } = this.context
|
||||||
let { location } = this.props
|
let { location } = this.props
|
||||||
@@ -344,16 +353,56 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNoteContextMenu (e, uniqueKey) {
|
handleNoteContextMenu (e, uniqueKey) {
|
||||||
this.handleNoteClick(e, uniqueKey)
|
const { location } = this.props
|
||||||
|
let targetIndex = _.findIndex(this.notes, (note) => {
|
||||||
|
return note != null && uniqueKey === `${note.storage}-${note.key}`
|
||||||
|
})
|
||||||
|
let note = this.notes[targetIndex]
|
||||||
|
const label = note.isPinned ? 'Remove pin' : 'Pin to Top'
|
||||||
|
|
||||||
let menu = new Menu()
|
let menu = new Menu()
|
||||||
|
if (!location.pathname.match(/\/home|\/starred|\/trash/)) {
|
||||||
|
menu.append(new MenuItem({
|
||||||
|
label: label,
|
||||||
|
click: (e) => this.pinToTop(e, uniqueKey)
|
||||||
|
}))
|
||||||
|
}
|
||||||
menu.append(new MenuItem({
|
menu.append(new MenuItem({
|
||||||
label: 'Delete Note',
|
label: 'Delete Note',
|
||||||
click: () => ee.emit('detail:delete')
|
click: (e) => this.deleteNote(e, uniqueKey)
|
||||||
}))
|
}))
|
||||||
menu.popup()
|
menu.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pinToTop (e, uniqueKey) {
|
||||||
|
const { data, params } = this.props
|
||||||
|
const storageKey = params.storageKey
|
||||||
|
const folderKey = params.folderKey
|
||||||
|
|
||||||
|
const currentStorage = data.storageMap.get(storageKey)
|
||||||
|
const currentFolder = _.find(currentStorage.folders, {key: folderKey})
|
||||||
|
|
||||||
|
const targetIndex = _.findIndex(this.notes, (note) => {
|
||||||
|
return note != null && `${note.storage}-${note.key}` === uniqueKey
|
||||||
|
})
|
||||||
|
let note = this.notes[targetIndex]
|
||||||
|
note.isPinned = !note.isPinned
|
||||||
|
|
||||||
|
dataApi
|
||||||
|
.updateNote(note.storage, note.key, note)
|
||||||
|
.then((note) => {
|
||||||
|
store.dispatch({
|
||||||
|
type: 'UPDATE_NOTE',
|
||||||
|
note: note
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteNote (e, uniqueKey) {
|
||||||
|
this.handleNoteClick(e, uniqueKey)
|
||||||
|
ee.emit('detail:delete')
|
||||||
|
}
|
||||||
|
|
||||||
importFromFile () {
|
importFromFile () {
|
||||||
const { dispatch, location } = this.props
|
const { dispatch, location } = this.props
|
||||||
|
|
||||||
@@ -420,12 +469,13 @@ class NoteList extends React.Component {
|
|||||||
: config.sortBy === 'ALPHABETICAL'
|
: config.sortBy === 'ALPHABETICAL'
|
||||||
? sortByAlphabetical
|
? sortByAlphabetical
|
||||||
: sortByUpdatedAt
|
: sortByUpdatedAt
|
||||||
this.notes = notes = this.getNotes()
|
const sortedNotes = location.pathname.match(/\/home|\/starred|\/trash/)
|
||||||
.sort(sortFunc)
|
? this.getNotes().sort(sortFunc)
|
||||||
.filter((note) => {
|
: this.sortByPin(this.getNotes().sort(sortFunc))
|
||||||
// this is for the trash box
|
this.notes = notes = sortedNotes.filter((note) => {
|
||||||
if (note.isTrashed !== true || location.pathname === '/trashed') return true
|
// this is for the trash box
|
||||||
})
|
if (note.isTrashed !== true || location.pathname === '/trashed') return true
|
||||||
|
})
|
||||||
|
|
||||||
let noteList = notes
|
let noteList = notes
|
||||||
.map(note => {
|
.map(note => {
|
||||||
@@ -451,6 +501,7 @@ class NoteList extends React.Component {
|
|||||||
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
|
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
|
||||||
handleNoteClick={this.handleNoteClick.bind(this)}
|
handleNoteClick={this.handleNoteClick.bind(this)}
|
||||||
handleDragStart={this.handleDragStart.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
|
pathname={location.pathname}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ function validateInput (input) {
|
|||||||
validatedInput.isTrashed = !!input.isTrashed
|
validatedInput.isTrashed = !!input.isTrashed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input.isPinned !== undefined) {
|
||||||
|
validatedInput.isPinned = !!input.isPinned
|
||||||
|
}
|
||||||
|
|
||||||
validatedInput.type = input.type
|
validatedInput.type = input.type
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
case 'MARKDOWN_NOTE':
|
case 'MARKDOWN_NOTE':
|
||||||
@@ -104,6 +108,7 @@ function updateNote (storageKey, noteKey, input) {
|
|||||||
noteData.isStarred = false
|
noteData.isStarred = false
|
||||||
noteData.isTrashed = false
|
noteData.isTrashed = false
|
||||||
noteData.tags = []
|
noteData.tags = []
|
||||||
|
noteData.isPinned = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noteData.type === 'SNIPPET_NOTE') {
|
if (noteData.type === 'SNIPPET_NOTE') {
|
||||||
|
|||||||
Reference in New Issue
Block a user