mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Handle links with a target in the standalone viewer
This commit is contained in:
parent
566bfe6df2
commit
c7a2178d24
@ -279,7 +279,8 @@ class WebPage(QWebEnginePage):
|
|||||||
return True
|
return True
|
||||||
if url.scheme() in (FAKE_PROTOCOL, 'data'):
|
if url.scheme() in (FAKE_PROTOCOL, 'data'):
|
||||||
return True
|
return True
|
||||||
safe_open_url(url)
|
if url.scheme() in ('http', 'https'):
|
||||||
|
safe_open_url(url)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def go_to_anchor(self, anchor):
|
def go_to_anchor(self, anchor):
|
||||||
|
@ -15,7 +15,7 @@ from read_book.flow_mode import (
|
|||||||
)
|
)
|
||||||
from read_book.footnotes import is_footnote_link
|
from read_book.footnotes import is_footnote_link
|
||||||
from read_book.globals import (
|
from read_book.globals import (
|
||||||
current_book, current_layout_mode, current_spine_item, set_boss,
|
current_book, current_layout_mode, current_spine_item, runtime, set_boss,
|
||||||
set_current_spine_item, set_layout_mode
|
set_current_spine_item, set_layout_mode
|
||||||
)
|
)
|
||||||
from read_book.mathjax import apply_mathjax
|
from read_book.mathjax import apply_mathjax
|
||||||
@ -380,6 +380,10 @@ class IframeBoss:
|
|||||||
link_attr = 'data-' + self.book.manifest.link_uid
|
link_attr = 'data-' + self.book.manifest.link_uid
|
||||||
for a in document.body.querySelectorAll('a[{}]'.format(link_attr)):
|
for a in document.body.querySelectorAll('a[{}]'.format(link_attr)):
|
||||||
a.addEventListener('click', self.link_activated)
|
a.addEventListener('click', self.link_activated)
|
||||||
|
if runtime.is_standalone_viewer:
|
||||||
|
# links with a target get turned into requests to open a new window by Qt
|
||||||
|
for a in document.body.querySelectorAll('a[target]'):
|
||||||
|
a.removeAttribute('target')
|
||||||
|
|
||||||
def link_activated(self, evt):
|
def link_activated(self, evt):
|
||||||
link_attr = 'data-' + self.book.manifest.link_uid
|
link_attr = 'data-' + self.book.manifest.link_uid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user