forked from extern/easydiffusion
Disable when targeting input elements.
This commit is contained in:
parent
e25a94e815
commit
3a18606385
@ -427,15 +427,22 @@ function checkReadTextClipboardPermission (result) {
|
|||||||
navigator.permissions.query({ name: "clipboard-read" }).then(checkReadTextClipboardPermission, (reason) => console.log('clipboard-read is not available. %o', reason))
|
navigator.permissions.query({ name: "clipboard-read" }).then(checkReadTextClipboardPermission, (reason) => console.log('clipboard-read is not available. %o', reason))
|
||||||
|
|
||||||
document.addEventListener('paste', async (event) => {
|
document.addEventListener('paste', async (event) => {
|
||||||
|
if (event.target) {
|
||||||
|
const targetTag = event.target.tagName.toLowerCase()
|
||||||
|
// Disable when targeting input elements.
|
||||||
|
if (targetTag === 'input' || targetTag === 'textarea') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
const paste = (event.clipboardData || window.clipboardData).getData('text')
|
const paste = (event.clipboardData || window.clipboardData).getData('text')
|
||||||
const selection = window.getSelection()
|
const selection = window.getSelection()
|
||||||
console.log(selection)
|
console.log(selection)
|
||||||
console.log(selection.toString())
|
console.log(selection.toString())
|
||||||
if (selection.toString().trim().length <= 0 && await parseContent(paste)) {
|
if (selection.toString().trim().length <= 0 && await parseContent(paste)) {
|
||||||
event.preventDefault();
|
event.preventDefault()
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// Adds a copy and a paste icon if the browser grants permission to write to clipboard.
|
// Adds a copy and a paste icon if the browser grants permission to write to clipboard.
|
||||||
function checkWriteToClipboardPermission (result) {
|
function checkWriteToClipboardPermission (result) {
|
||||||
|
Loading…
Reference in New Issue
Block a user