enter to add annotation
This commit is contained in:
parent
8ab9ac9588
commit
fedd0c7e80
4 changed files with 68 additions and 20 deletions
|
|
@ -49,6 +49,18 @@ function deselectAnnotation(id) {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
function deselectAllAnnotations() {
|
||||
var ids = []
|
||||
document.querySelectorAll('.epubjs-hl.selected').forEach(function(g) {
|
||||
g.classList.remove('selected')
|
||||
if (!Ox.contains(ids, id)) {
|
||||
ids.push(id)
|
||||
Ox.$parent.postMessage('deselectAnnotation', {id: id})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function removeAnnotation(id) {
|
||||
var a = annotations.filter(function(a) { return a.id == id })[0]
|
||||
if (a) {
|
||||
|
|
@ -83,6 +95,7 @@ function onHighlightClicked(e) {
|
|||
other.classList.remove('selected')
|
||||
})
|
||||
e.target.classList.add('selected')
|
||||
Ox.$parent.postMessage('selectAnnotation', {id: e.target.dataset.id})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,8 +119,12 @@ document.onreadystatechange = function () {
|
|||
removeAnnotation(a.dataset.id)
|
||||
})
|
||||
}
|
||||
if (event.key == 'n') {
|
||||
if (event.key == 'n' || event.keyCode == 13) {
|
||||
var selected = document.querySelector('.epubjs-hl.selected')
|
||||
if (currentSelection) {
|
||||
if (selected) {
|
||||
deselectAllAnnotations()
|
||||
}
|
||||
/*
|
||||
var range = currentSelection.contents.window.getSelection().getRangeAt(0)
|
||||
console.log(
|
||||
|
|
@ -124,6 +141,9 @@ document.onreadystatechange = function () {
|
|||
other.classList.remove('selected')
|
||||
})
|
||||
currentSelection = null
|
||||
} else if (selected) {
|
||||
console.log('editNote?', selected.dataset.id)
|
||||
|
||||
}
|
||||
}
|
||||
if (event.keyCode == 61 && event.shiftKey) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue