bind delete in annotation folder
This commit is contained in:
parent
0d76284684
commit
943d117c89
4 changed files with 25 additions and 7 deletions
|
|
@ -23,6 +23,8 @@ Ox.load({
|
|||
annotations.push(annotation)
|
||||
renderAnnotation(annotation)
|
||||
})
|
||||
} else if (event == 'removeAnnotation') {
|
||||
removeAnnotation(data.id)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -47,12 +49,15 @@ function deselectAnnotation(id) {
|
|||
})
|
||||
}
|
||||
|
||||
function removeAnnotation(a) {
|
||||
annotations = annotations.filter(function(annotation) {
|
||||
return annotation.cfiRange != a.dataset.epubcfi
|
||||
})
|
||||
reader.rendition.annotations.remove(a.dataset.epubcfi)
|
||||
Ox.$parent.postMessage('removeAnnotation', {id: a.dataset.id})
|
||||
function removeAnnotation(id) {
|
||||
var a = annotations.filter(function(a) { return a.id == id })[0]
|
||||
if (a) {
|
||||
annotations = annotations.filter(function(annotation) {
|
||||
return annotation.id != id
|
||||
})
|
||||
reader.rendition.annotations.remove(a.cfiRange)
|
||||
}
|
||||
Ox.$parent.postMessage('removeAnnotation', {id: id})
|
||||
}
|
||||
|
||||
function renderAnnotation(annotation) {
|
||||
|
|
@ -98,7 +103,7 @@ document.onreadystatechange = function () {
|
|||
reader.rendition.on('keydown', function(event) {
|
||||
if (event.key == 'Delete') {
|
||||
document.querySelectorAll('.epubjs-hl.selected').forEach(function(a) {
|
||||
removeAnnotation(a)
|
||||
removeAnnotation(a.dataset.id)
|
||||
})
|
||||
}
|
||||
if (event.key == 'n') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue