mirror of
https://github.com/BoostIo/Boostnote
synced 2026-01-03 03:59:18 +00:00
Add a feature which enables to link between notes
This commit is contained in:
@@ -47,6 +47,7 @@ class NoteList extends React.Component {
|
||||
this.alertIfSnippet()
|
||||
}
|
||||
this.importFromFileHandler = this.importFromFile.bind(this)
|
||||
this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this)
|
||||
|
||||
this.jumpToTopHandler = () => {
|
||||
this.jumpToTop()
|
||||
@@ -65,6 +66,7 @@ class NoteList extends React.Component {
|
||||
ee.on('list:top', this.jumpToTopHandler)
|
||||
ee.on('list:jumpToTop', this.jumpToTopHandler)
|
||||
ee.on('import:file', this.importFromFileHandler)
|
||||
ee.on('list:jump', this.jumpNoteByHash)
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
@@ -87,6 +89,7 @@ class NoteList extends React.Component {
|
||||
ee.off('list:top', this.jumpToTopHandler)
|
||||
ee.off('list:jumpToTop', this.jumpToTopHandler)
|
||||
ee.off('import:file', this.importFromFileHandler)
|
||||
ee.off('list:jump', this.jumpNoteByHash)
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
@@ -179,6 +182,32 @@ class NoteList extends React.Component {
|
||||
ee.emit('list:moved')
|
||||
}
|
||||
|
||||
jumpNoteByHashHandler (event, noteHash) {
|
||||
// first argument event isn't used.
|
||||
if (this.notes == null || this.notes.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const { router } = this.context
|
||||
const { location } = this.props
|
||||
|
||||
let targetIndex = _.findIndex(this.notes, (note) => {
|
||||
console.log(note.storage+'-'+note.key)
|
||||
return note.storage + '-' + note.key === noteHash
|
||||
})
|
||||
|
||||
if (targetIndex < 0) targetIndex = 0
|
||||
|
||||
router.push({
|
||||
pathname: location.pathname,
|
||||
query: {
|
||||
key: this.notes[targetIndex].storage + '-' + this.notes[targetIndex].key
|
||||
}
|
||||
})
|
||||
|
||||
ee.emit('list:moved')
|
||||
}
|
||||
|
||||
handleNoteListKeyDown (e) {
|
||||
if (e.metaKey || e.ctrlKey) return true
|
||||
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
.update-icon
|
||||
color $brand-color
|
||||
|
||||
.note-hash
|
||||
display inline
|
||||
line-height 24px
|
||||
padding-left 5px
|
||||
font-size 11px
|
||||
color $ui-button-color
|
||||
|
||||
body[data-theme="dark"]
|
||||
.root
|
||||
background-color $ui-dark-noteDetail-backgroundColor
|
||||
|
||||
@@ -48,6 +48,7 @@ class StatusBar extends React.Component {
|
||||
|
||||
render () {
|
||||
let { config, status } = this.context
|
||||
const { location } = this.props
|
||||
|
||||
return (
|
||||
<div className='StatusBar'
|
||||
@@ -60,6 +61,7 @@ class StatusBar extends React.Component {
|
||||
{Math.floor(config.zoom * 100)}%
|
||||
</button>
|
||||
|
||||
<div styleName='note-hash'>#{location.query.key}</div>
|
||||
<div styleName='blank' />
|
||||
|
||||
{status.updateReady
|
||||
|
||||
Reference in New Issue
Block a user