Revert copy-text change and apply alternative fix

Reverts PR #3331 and applies the alternative fix originally proposed
in PR #3329
This commit is contained in:
Nick O'Leary 2022-01-18 09:26:42 +00:00
parent 8b1f412255
commit dbefe6a560
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 25 additions and 17 deletions

View File

@ -946,23 +946,26 @@ RED.clipboard = (function() {
if (truncated) { if (truncated) {
msg += "_truncated"; msg += "_truncated";
} }
navigator.clipboard.writeText(value).then(function () { var clipboardHidden = $('<textarea type="text" id="red-ui-clipboard-hidden" tabIndex="-1">').appendTo(document.body);
if (element) { clipboardHidden.val(value).focus().select();
var popover = RED.popover.create({ var result = document.execCommand("copy");
target: element, if (result && element) {
direction: 'left', var popover = RED.popover.create({
size: 'small', target: element,
content: RED._(msg) direction: 'left',
}); size: 'small',
setTimeout(function() { content: RED._(msg)
popover.close(); });
},1000); setTimeout(function() {
popover.open(); popover.close();
} },1000);
if (currentFocus) { popover.open();
$(currentFocus).focus(); }
} clipboardHidden.remove();
}).catch(err => { console.error("Failed to copy:",err) }); if (currentFocus) {
$(currentFocus).focus();
}
return result;
} }
function importNodes(nodesStr,addFlow) { function importNodes(nodesStr,addFlow) {

View File

@ -356,6 +356,11 @@ button.red-ui-button-small
background: $secondary-background; background: $secondary-background;
} }
#red-ui-clipboard-hidden {
position: absolute;
top: -3000px;
}
.form-row .red-ui-editor-node-label-form-row { .form-row .red-ui-editor-node-label-form-row {
margin: 5px 0 0 50px; margin: 5px 0 0 50px;
label { label {