mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-21 11:04:47 -05:00
feat(client): select all and copy monaco command (#51963)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user