mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Book details: Open links in comments fields in the same window rather than a new window
This commit is contained in:
parent
7a5bf8be33
commit
909654fa39
@ -124,7 +124,7 @@ def adjust_iframe_height(iframe):
|
|||||||
def setup_iframe(iframe):
|
def setup_iframe(iframe):
|
||||||
de = adjust_iframe_height(iframe)
|
de = adjust_iframe_height(iframe)
|
||||||
for a in de.querySelectorAll('a[href]'):
|
for a in de.querySelectorAll('a[href]'):
|
||||||
a.setAttribute('target', '_blank')
|
a.setAttribute('target', '_parent')
|
||||||
|
|
||||||
def forward_touch_events(ev):
|
def forward_touch_events(ev):
|
||||||
container = window.top.document.getElementById(render_book.container_id)
|
container = window.top.document.getElementById(render_book.container_id)
|
||||||
@ -158,9 +158,9 @@ def adjusting_sandboxed_html(html, extra_css):
|
|||||||
css = f'\n\n:root {{ color-scheme: {color_scheme()} }}\n\nhtml, body {{ overflow: hidden; color: rgba({color[0]}, {color[1]}, {color[2]}, {color[3]}) }}'
|
css = f'\n\n:root {{ color-scheme: {color_scheme()} }}\n\nhtml, body {{ overflow: hidden; color: rgba({color[0]}, {color[1]}, {color[2]}, {color[3]}) }}'
|
||||||
if extra_css:
|
if extra_css:
|
||||||
css += '\n\n' + extra_css
|
css += '\n\n' + extra_css
|
||||||
# allow-same-origin is needed for resizing and allow-popups is needed for
|
# allow-same-origin is needed for resizing and allow-top-navigation is
|
||||||
# target="_blank"
|
# needed for links with target="_parent"
|
||||||
ans = sandboxed_html(html, css, 'allow-same-origin allow-popups allow-popups-to-escape-sandbox')
|
ans = sandboxed_html(html, css, 'allow-same-origin allow-top-navigation-by-user-activation')
|
||||||
ans.addEventListener('load', def(ev): setup_iframe(ev.target);)
|
ans.addEventListener('load', def(ev): setup_iframe(ev.target);)
|
||||||
ans.style.height = '50vh'
|
ans.style.height = '50vh'
|
||||||
ans.dataset.last_window_width = '0'
|
ans.dataset.last_window_width = '0'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user