mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Go to anchor explicitly in the preview
This commit is contained in:
parent
50ed25a6d9
commit
883717039e
@ -1260,7 +1260,9 @@ class Boss(QObject):
|
||||
_('Editing files of type %s is not supported' % mt), show=True)
|
||||
editor = self.edit_file(name, syntax)
|
||||
if anchor and editor is not None:
|
||||
if not editor.go_to_anchor(anchor) and show_anchor_not_found:
|
||||
if editor.go_to_anchor(anchor):
|
||||
self.gui.preview.go_to_anchor(anchor)
|
||||
elif show_anchor_not_found:
|
||||
error_dialog(self.gui, _('Not found'), _(
|
||||
'The anchor %s was not found in this file') % anchor, show=True)
|
||||
|
||||
|
@ -492,6 +492,9 @@ class Preview(QWidget):
|
||||
def find_prev(self):
|
||||
self.find('prev')
|
||||
|
||||
def go_to_anchor(self, anchor):
|
||||
self.view._page.go_to_anchor(anchor)
|
||||
|
||||
def request_sync(self, tagname, href, lnum):
|
||||
if self.current_name:
|
||||
c = current_container()
|
||||
@ -501,7 +504,7 @@ class Preview(QWidget):
|
||||
else:
|
||||
name = c.href_to_name(href, self.current_name) if href else None
|
||||
if name == self.current_name:
|
||||
return self.view._page.go_to_anchor(urlparse(href).fragment)
|
||||
return self.go_to_anchor(urlparse(href).fragment)
|
||||
if name and c.exists(name) and c.mime_map[name] in OEB_DOCS:
|
||||
return self.link_clicked.emit(name, urlparse(href).fragment or TOP)
|
||||
self.sync_requested.emit(self.current_name, lnum)
|
||||
|
@ -336,7 +336,7 @@ class PreviewIntegration:
|
||||
address = get_sourceline_address(e)
|
||||
# Find the closest containing link, if any
|
||||
href = tn = ''
|
||||
while e and e != document.body and e != document and (tn is not 'a' or not href):
|
||||
while e and e is not document.body and e is not document and e is not document.documentElement and (tn is not 'a' or not href):
|
||||
tn = e.tagName.toLowerCase() if e.tagName else ''
|
||||
href = e.getAttribute('href')
|
||||
e = e.parentNode
|
||||
|
Loading…
x
Reference in New Issue
Block a user