Oh well, I had no choice but to hack my way into the DOM in order to remove the "Command Palette".
It's very far from ideal and it also doesn't really disable the F1
shortcut but it's only thing I have for now:
private onContextMenu() {
const menuItems = document.querySelector(".monaco-menu .actions-container");
if (menuItems && menuItems.childNodes && menuItems.childNodes.length > 0) {
for (let i = 0; i < menuItems.childNodes.length; i++) {
const menuItem = menuItems.childNodes[i];
if (menuItem.innerText.indexOf("Command Palette") !== -1) {
// remove "Command Pallete" item and it's separator from the menu
menuItems.removeChild(menuItem); // the "Command Palette" item
menuItems.removeChild(menuItems.childNodes[i - 1]); // the separator item before "Command Palette"
}
}
}
}
Another solution, which is not really much better than editing the dom.
When creating the editor, you may override the storage service. When F1
is pressed, the storage service look for the key commandPalette.mru.counter
. If you throw an error in this case, the command palette will not be shown.
monaco.editor.create(domElement, options, {
storageService: {
get() {},
remove() {},
getNumber(key: string) { if(key === 'commandPalette.mru.counter') throw new Error(); return 0; },
getBoolean(key: string) {},
store() {},
onWillSaveState() {},
onDidChangeStorage() {},
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.