mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewing annots should be triggered by double click/long tap not single click/tap
This commit is contained in:
parent
1b6c6f420b
commit
b468f72ba7
@ -275,7 +275,7 @@ class CreateAnnotation:
|
|||||||
ta.focus()
|
ta.focus()
|
||||||
),
|
),
|
||||||
E.div(
|
E.div(
|
||||||
_('To view the notes for a highlight, tap or click on it.'),
|
_('To view the notes for a highlight, long-tap or double click on it.'),
|
||||||
style='font-size-smaller; margin-left: 1rem; margin-right: 1rem'
|
style='font-size-smaller; margin-left: 1rem; margin-right: 1rem'
|
||||||
),
|
),
|
||||||
E.a(
|
E.a(
|
||||||
|
@ -3,13 +3,19 @@
|
|||||||
from __python__ import bound_methods, hash_literals
|
from __python__ import bound_methods, hash_literals
|
||||||
|
|
||||||
|
|
||||||
|
from read_book.globals import get_boss
|
||||||
|
|
||||||
|
|
||||||
def get_elements(x, y):
|
def get_elements(x, y):
|
||||||
nonlocal img_id_counter
|
nonlocal img_id_counter
|
||||||
ans = {'link': None, 'img': None}
|
ans = {'link': None, 'img': None, 'highlight': None}
|
||||||
for elem in document.elementsFromPoint(x, y):
|
for elem in document.elementsFromPoint(x, y):
|
||||||
if elem.tagName.toLowerCase() is 'a' and elem.getAttribute('href') and not ans.link:
|
if elem.tagName.toLowerCase() is 'a' and elem.getAttribute('href') and not ans.link:
|
||||||
ans.link = elem.getAttribute('href')
|
ans.link = elem.getAttribute('href')
|
||||||
elif elem.tagName.toLowerCase() is 'img' and elem.getAttribute('data-calibre-src') and not ans.img:
|
elif elem.tagName.toLowerCase() is 'img' and elem.getAttribute('data-calibre-src') and not ans.img:
|
||||||
ans.img = elem.getAttribute('data-calibre-src')
|
ans.img = elem.getAttribute('data-calibre-src')
|
||||||
|
elif elem.dataset?.calibreRangeWrapper:
|
||||||
|
annot_id = get_boss().annot_id_uuid_map[elem.dataset.calibreRangeWrapper]
|
||||||
|
if annot_id:
|
||||||
|
ans.highlight = annot_id
|
||||||
return ans
|
return ans
|
||||||
|
@ -271,6 +271,9 @@ class IframeBoss:
|
|||||||
if elements.img:
|
if elements.img:
|
||||||
self.send_message('view_image', calibre_src=elements.img)
|
self.send_message('view_image', calibre_src=elements.img)
|
||||||
return
|
return
|
||||||
|
if elements.highlight:
|
||||||
|
self.activate_annotation(elements.highlight)
|
||||||
|
return
|
||||||
r = word_at_point(gesture.viewport_x, gesture.viewport_y)
|
r = word_at_point(gesture.viewport_x, gesture.viewport_y)
|
||||||
if r:
|
if r:
|
||||||
s = document.getSelection()
|
s = document.getSelection()
|
||||||
@ -747,13 +750,17 @@ class IframeBoss:
|
|||||||
v'delete self.annot_id_uuid_map[crw]'
|
v'delete self.annot_id_uuid_map[crw]'
|
||||||
|
|
||||||
def add_highlight_listeners(self, wrapper):
|
def add_highlight_listeners(self, wrapper):
|
||||||
wrapper.addEventListener('click', self.highlight_wrapper_clicked)
|
wrapper.addEventListener('dblclick', self.highlight_wrapper_dblclicked)
|
||||||
|
|
||||||
def highlight_wrapper_clicked(self, ev):
|
def activate_annotation(self, uuid):
|
||||||
crw = ev.currentTarget.dataset.calibreRangeWrapper
|
|
||||||
uuid = self.annot_id_uuid_map[crw]
|
|
||||||
if uuid:
|
if uuid:
|
||||||
self.send_message('annotations', type='annotation-activated', uuid=uuid)
|
self.send_message('annotations', type='annotation-activated', uuid=uuid)
|
||||||
|
window.getSelection().removeAllRanges()
|
||||||
|
|
||||||
|
def highlight_wrapper_dblclicked(self, ev):
|
||||||
|
crw = ev.currentTarget.dataset.calibreRangeWrapper
|
||||||
|
ev.preventDefault(), ev.stopPropagation()
|
||||||
|
self.activate_annotation(self.annot_id_uuid_map[crw])
|
||||||
|
|
||||||
def copy_selection(self):
|
def copy_selection(self):
|
||||||
text = window.getSelection().toString()
|
text = window.getSelection().toString()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user