fix enter event

This commit is contained in:
j 2019-02-09 23:40:14 +05:30
parent dad9b53b54
commit 131a6a3215
1 changed files with 10 additions and 8 deletions

View File

@ -47,6 +47,7 @@ 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) {
if (event.target.nodeName != 'INPUT') {
var selected = document.querySelector('.oml-annotation.selected') var selected = document.querySelector('.oml-annotation.selected')
if (!window.getSelection().isCollapsed) { if (!window.getSelection().isCollapsed) {
createAnnotation() createAnnotation()
@ -56,6 +57,7 @@ window.addEventListener('keydown', function(event) {
event.stopPropagation() event.stopPropagation()
event.preventDefault() event.preventDefault()
} }
}
}) })
window.addEventListener('mouseup', function(event) { window.addEventListener('mouseup', function(event) {
var selection = window.getSelection() var selection = window.getSelection()
@ -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,