re-add contextmenu, add google search action
This commit is contained in:
@@ -30,16 +30,32 @@ export default function EditorTextArea({
|
|||||||
function beforeMount(monaco) {
|
function beforeMount(monaco) {
|
||||||
for (const [id, theme] of Object.entries(themes)) {
|
for (const [id, theme] of Object.entries(themes)) {
|
||||||
monaco.editor.defineTheme(id, makeMonacoTheme(theme));
|
monaco.editor.defineTheme(id, makeMonacoTheme(theme));
|
||||||
|
}
|
||||||
|
|
||||||
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
||||||
noSemanticValidation: true,
|
noSemanticValidation: true,
|
||||||
noSyntaxValidation: true,
|
noSyntaxValidation: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function onMount(editor, monaco) {
|
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);
|
setEditor(editor);
|
||||||
setMonaco(monaco);
|
setMonaco(monaco);
|
||||||
|
|
||||||
editor.focus();
|
editor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +89,6 @@ export default function EditorTextArea({
|
|||||||
renderValidationDecorations: false,
|
renderValidationDecorations: false,
|
||||||
readOnly,
|
readOnly,
|
||||||
domReadOnly: readOnly,
|
domReadOnly: readOnly,
|
||||||
contextmenu: false,
|
|
||||||
}}
|
}}
|
||||||
beforeMount={beforeMount}
|
beforeMount={beforeMount}
|
||||||
onMount={onMount}
|
onMount={onMount}
|
||||||
|
|||||||
Reference in New Issue
Block a user