From 9c1e6ccb039c8f30f582b9635724f4e9dc7ab0be Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Oct 2020 17:05:19 +0530 Subject: [PATCH] html is anyway ignored in copy_selection --- src/pyj/read_book/ui.pyj | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/pyj/read_book/ui.pyj b/src/pyj/read_book/ui.pyj index ab8e357bf5..fadd779ede 100644 --- a/src/pyj/read_book/ui.pyj +++ b/src/pyj/read_book/ui.pyj @@ -84,29 +84,28 @@ class ReadUI: ui_operations.open_url = def(url): window.open(url, '_blank') ui_operations.copy_selection = def(text, html): - if not html: - # try using document.execCommand which on chrome allows the - # copy on non-secure origin if this is close to a user - # interaction event - active_elem = document.activeElement - ta = document.createElement("textarea") - ta.value = text - ta.style.position = 'absolute' - ta.style.top = window.innerHeight + 'px' - ta.style.left = window.innerWidth + 'px' - document.body.appendChild(ta) - ta.focus() - ta.select() - ok = False - try: - ok = document.execCommand('copy') - except: - pass - document.body.removeChild(ta) - if active_elem: - active_elem.focus() - if ok: - return + # try using document.execCommand which on chrome allows the + # copy on non-secure origin if this is close to a user + # interaction event + active_elem = document.activeElement + ta = document.createElement("textarea") + ta.value = text + ta.style.position = 'absolute' + ta.style.top = window.innerHeight + 'px' + ta.style.left = window.innerWidth + 'px' + document.body.appendChild(ta) + ta.focus() + ta.select() + ok = False + try: + ok = document.execCommand('copy') + except: + pass + document.body.removeChild(ta) + if active_elem: + active_elem.focus() + if ok: + return if not window.navigator.clipboard: return error_dialog(_('No clipboard access'), _( 'Your browser requires you to access the Content server over an HTTPS connection'