Invisible text should not be a fatal error

This commit is contained in:
Kovid Goyal 2020-09-13 10:02:08 +05:30
parent 639c0e1ecc
commit eecac78739
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 6 deletions

View File

@ -62,7 +62,7 @@ from read_book.touch import (
create_handlers as create_touch_handlers, reset_handlers as reset_touch_handlers
)
from read_book.viewport import scroll_viewport
from utils import debounce, html_escape, is_ios
from utils import debounce, is_ios
FORCE_FLOW_MODE = False
CALIBRE_VERSION = '__CALIBRE_VERSION__'
@ -707,11 +707,8 @@ class IframeBoss:
if current_layout_mode() is not 'flow':
snap_to_selection()
else:
if from_load:
self.send_message('error', title=_('Invisible text'), msg=_(
'The text <i>{}</i> is present on this page but not visible').format(html_escape(data.text)))
else:
self.send_message('find_in_spine', text=data.text, backwards=data.backwards, searched_in_spine=data.searched_in_spine)
msg_type = 'invisible_text' if from_load else 'find_in_spine'
self.send_message(msg_type, text=data.text, backwards=data.backwards, searched_in_spine=data.searched_in_spine)
def show_search_result(self, data, from_load):
self.last_search_at = window.performance.now()

View File

@ -264,6 +264,7 @@ class View:
'content_loaded': self.on_content_loaded,
'error': self.on_iframe_error,
'find_in_spine': self.on_find_in_spine,
'invisible_text': self.on_invisible_text,
'goto_doc_boundary': def(data): self.goto_doc_boundary(data.start);,
'handle_keypress': self.on_handle_keypress,
'handle_shortcut': self.on_handle_shortcut,
@ -594,6 +595,13 @@ class View:
def find(self, text, backwards):
self.iframe_wrapper.send_message('find', text=text, backwards=backwards, searched_in_spine=False)
def on_invisible_text(self, data):
warning_dialog(
_('Not found'), _('The text: <i>{}</i> is present on this page but not visible').format(html_escape(data.text)),
on_close=def():
self.search_overlay.show()
)
def on_find_in_spine(self, data):
if data.searched_in_spine:
warning_dialog(