1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Use clipboard.writeText() instead of execCommand("copy")

This commit is contained in:
Kazuhito Yokoi 2022-01-07 11:49:26 +09:00
parent b00282590d
commit ba794ba58c
2 changed files with 17 additions and 25 deletions

View File

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

View File

@ -356,10 +356,6 @@ 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 {