From 1381e3764d0d54a8b51e5d670b0e3765087372dd Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Sat, 3 Feb 2024 23:13:23 -0800 Subject: [PATCH] Avoid placing the editor in focus while copying. --- _extensions/webr/qwebr-monaco-editor-element.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/_extensions/webr/qwebr-monaco-editor-element.js b/_extensions/webr/qwebr-monaco-editor-element.js index 980a73c4..5644e67e 100644 --- a/_extensions/webr/qwebr-monaco-editor-element.js +++ b/_extensions/webr/qwebr-monaco-editor-element.js @@ -146,13 +146,10 @@ globalThis.qwebrCreateMonacoEditorInstance = function (cellData) { // Add a click event listener to the reset button copyButton.onclick = function () { - // Ensure the editor is in focus - editor.focus(); - - // Retrieve data + // Retrieve current code data const data = editor.getValue(); - // Set the clipboard contents. + // Write code data onto the clipboard. navigator.clipboard.writeText(data || ""); };