Added copy/cut/paste functions for pop-up menu

This commit is contained in:
ebolam
2022-09-21 13:21:26 -04:00
parent 931b912811
commit daa24bb0c3

View File

@@ -2321,19 +2321,16 @@ function retry_from_here() {
}
}
function push_to_clipboard() {
navigator.permissions.query({name: "clipboard-write"}).then((result) => {
if (result.state === "granted" || result.state === "prompt") {
navigator.clipboard.writeText(getSelectionText());
}
});
function copy() {
document.execCommand("copy")
}
function push_from_clipboard(el = document.activeElement) {
const [start, end] = [el.selectionStart, el.selectionEnd];
navigator.clipboard.readText().then(
(clipText) => el.setRangeText(clipText, start, end, 'select'));
function paste() {
document.execCommand("paste")
}
function cut() {
document.execCommand("cut")
}
function getSelectionText() {