mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
html is anyway ignored in copy_selection
This commit is contained in:
parent
87629e32a7
commit
9c1e6ccb03
@ -84,29 +84,28 @@ class ReadUI:
|
|||||||
ui_operations.open_url = def(url):
|
ui_operations.open_url = def(url):
|
||||||
window.open(url, '_blank')
|
window.open(url, '_blank')
|
||||||
ui_operations.copy_selection = def(text, html):
|
ui_operations.copy_selection = def(text, html):
|
||||||
if not html:
|
# try using document.execCommand which on chrome allows the
|
||||||
# try using document.execCommand which on chrome allows the
|
# copy on non-secure origin if this is close to a user
|
||||||
# copy on non-secure origin if this is close to a user
|
# interaction event
|
||||||
# interaction event
|
active_elem = document.activeElement
|
||||||
active_elem = document.activeElement
|
ta = document.createElement("textarea")
|
||||||
ta = document.createElement("textarea")
|
ta.value = text
|
||||||
ta.value = text
|
ta.style.position = 'absolute'
|
||||||
ta.style.position = 'absolute'
|
ta.style.top = window.innerHeight + 'px'
|
||||||
ta.style.top = window.innerHeight + 'px'
|
ta.style.left = window.innerWidth + 'px'
|
||||||
ta.style.left = window.innerWidth + 'px'
|
document.body.appendChild(ta)
|
||||||
document.body.appendChild(ta)
|
ta.focus()
|
||||||
ta.focus()
|
ta.select()
|
||||||
ta.select()
|
ok = False
|
||||||
ok = False
|
try:
|
||||||
try:
|
ok = document.execCommand('copy')
|
||||||
ok = document.execCommand('copy')
|
except:
|
||||||
except:
|
pass
|
||||||
pass
|
document.body.removeChild(ta)
|
||||||
document.body.removeChild(ta)
|
if active_elem:
|
||||||
if active_elem:
|
active_elem.focus()
|
||||||
active_elem.focus()
|
if ok:
|
||||||
if ok:
|
return
|
||||||
return
|
|
||||||
if not window.navigator.clipboard:
|
if not window.navigator.clipboard:
|
||||||
return error_dialog(_('No clipboard access'), _(
|
return error_dialog(_('No clipboard access'), _(
|
||||||
'Your browser requires you to access the Content server over an HTTPS connection'
|
'Your browser requires you to access the Content server over an HTTPS connection'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user