fix enter event

This commit is contained in:
j 2019-02-09 23:40:14 +05:30
parent dad9b53b54
commit 131a6a3215

View file

@ -47,14 +47,16 @@ window.addEventListener('keydown', function(event) {
removeAnnotation(selected.dataset.id) removeAnnotation(selected.dataset.id)
} }
} else if (event.key == 'n' || event.keyCode == 13) { } else if (event.key == 'n' || event.keyCode == 13) {
var selected = document.querySelector('.oml-annotation.selected') if (event.target.nodeName != 'INPUT') {
if (!window.getSelection().isCollapsed) { var selected = document.querySelector('.oml-annotation.selected')
createAnnotation() if (!window.getSelection().isCollapsed) {
} else if (selected) { createAnnotation()
console.log('editNote?', selected.dataset.id) } else if (selected) {
console.log('editNote?', selected.dataset.id)
}
event.stopPropagation()
event.preventDefault()
} }
event.stopPropagation()
event.preventDefault()
} }
}) })
window.addEventListener('mouseup', function(event) { window.addEventListener('mouseup', function(event) {
@ -91,7 +93,7 @@ function getHighlight() {
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y)); viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
}); });
var text = selection.toString(); var text = selection.toString();
var position = [pageNumber].concat(Ox.sort(selected.coords.map(function(c) { return [c[1], c[0]]}))[0]); var position = [pageNumber].concat(Ox.sort(selected.map(function(c) { return [c[1], c[0]]}))[0]);
return { return {
page: pageNumber, page: pageNumber,
position: position, position: position,