From 2c7caa09cfb4dd0043e2d7a6e3cc55bb2bf46fc1 Mon Sep 17 00:00:00 2001 From: Krzysztof G <60067306+gikf@users.noreply.github.com> Date: Wed, 18 Oct 2023 22:43:24 +0200 Subject: [PATCH] feat(client): select all and copy monaco command (#51963) --- .../templates/Challenges/classic/editor.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/src/templates/Challenges/classic/editor.tsx b/client/src/templates/Challenges/classic/editor.tsx index 0534ded34b1..ae1e7d5b515 100644 --- a/client/src/templates/Challenges/classic/editor.tsx +++ b/client/src/templates/Challenges/classic/editor.tsx @@ -567,6 +567,24 @@ const Editor = (props: EditorProps): JSX.Element => { ], run: toggleAriaRoledescription }); + editor.addAction({ + id: 'select-all-and-copy', + label: 'Select All and Copy', + contextMenuGroupId: '9_cutcopypaste', + contextMenuOrder: 3, + run: () => { + const fullSelection = editor.getModel()?.getFullModelRange(); + if (fullSelection) { + editor.setSelection(fullSelection); + const data = editor.getModel()?.getValueInRange(fullSelection); + if (data) { + navigator.clipboard + .writeText(data) + .catch(err => console.error(err)); + } + } + } + }); editor.onDidFocusEditorWidget(() => props.setEditorFocusability(true)); // aria-roledescription is on (true) by default, check if it needs