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

Merge pull request #3331 from kazuhitoyokoi/master-fixcopybutton2

Fix copy buttons on the debug window (another method)
This commit is contained in:
Nick O'Leary 2022-01-13 09:50:27 +00:00 committed by GitHub
commit 1e5ed2a2e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 26 deletions

View File

@ -946,28 +946,25 @@ RED.clipboard = (function() {
if (truncated) { if (truncated) {
msg += "_truncated"; msg += "_truncated";
} }
$("#red-ui-clipboard-hidden").val(value).focus().select(); navigator.clipboard.writeText(value).then(function () {
var result = document.execCommand("copy"); if (element) {
if (result && element) { var popover = RED.popover.create({
var popover = RED.popover.create({ target: element,
target: element, direction: 'left',
direction: 'left', size: 'small',
size: 'small', content: RED._(msg)
content: RED._(msg) });
}); setTimeout(function() {
setTimeout(function() { popover.close();
popover.close(); },1000);
},1000); popover.open();
popover.open(); }
} if (currentFocus) {
$("#red-ui-clipboard-hidden").val(""); $(currentFocus).focus();
if (currentFocus) { }
$(currentFocus).focus(); }).catch(err => { console.error("Failed to copy:",err) });
}
return result;
} }
function importNodes(nodesStr,addFlow) { function importNodes(nodesStr,addFlow) {
var newNodes = nodesStr; var newNodes = nodesStr;
if (typeof nodesStr === 'string') { if (typeof nodesStr === 'string') {
@ -1242,8 +1239,6 @@ RED.clipboard = (function() {
init: function() { init: function() {
setupDialogs(); setupDialogs();
$('<textarea type="text" id="red-ui-clipboard-hidden" tabIndex="-1">').appendTo("#red-ui-editor");
RED.actions.add("core:show-export-dialog",showExportNodes); RED.actions.add("core:show-export-dialog",showExportNodes);
RED.actions.add("core:show-import-dialog",showImportNodes); RED.actions.add("core:show-import-dialog",showImportNodes);

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 {