re-add contextmenu, add google search action

This commit is contained in:
Luck
2022-01-28 00:56:50 +00:00
parent 565fcbe630
commit 98b880773e

View File

@@ -30,16 +30,32 @@ export default function EditorTextArea({
function beforeMount(monaco) {
for (const [id, theme] of Object.entries(themes)) {
monaco.editor.defineTheme(id, makeMonacoTheme(theme));
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: true,
});
}
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: true,
});
}
function onMount(editor, monaco) {
editor.addAction({
id: 'search',
label: 'Search with Google',
contextMenuGroupId: '9_cutcopypaste',
contextMenuOrder: 5,
run: (editor) => {
const selection = editor.getSelection()
if (!selection.isEmpty()) {
const query = editor.getModel().getValueInRange(selection);
window.open('https://www.google.com/search?q=' + query, '_blank');
}
}
})
setEditor(editor);
setMonaco(monaco);
editor.focus();
}
@@ -73,7 +89,6 @@ export default function EditorTextArea({
renderValidationDecorations: false,
readOnly,
domReadOnly: readOnly,
contextmenu: false,
}}
beforeMount={beforeMount}
onMount={onMount}