monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Context Menu - customize appearance?

Open ShovalZ opened this issue 8 years ago • 10 comments

Monaco version 0.11.1-- I would like to customize the appearance of the context menu. I can achieve that easily by overwriting the CSS but it doesn't seem like that the CSS is a part of public API? or is it? Is there another way to customize the context menu appearance?

ShovalZ avatar Oct 23 '18 14:10 ShovalZ

There is no API to customize the look of the context menu except for writing/overwriting CSS

alexdima avatar Nov 11 '18 00:11 alexdima

Thanks! Is the CSS is public? is it save to overwrite it knowing that it wouldn't change? It's not mentioned to be public - so I wonder if it could be in a process of refactoring at some point. In this case, it could make a mass in my UI if I used the classes to overwrite CSS...

ShovalZ avatar Nov 11 '18 08:11 ShovalZ

Any update??

Alecyrus avatar Jan 05 '19 15:01 Alecyrus

I've been overwriting CSS for a few versions and it does change so I've been operating under the assumption it is non public and will change at any moment.

I would LOVE for this to be a supported feature.

smiles2424 avatar Dec 23 '19 17:12 smiles2424

Seems like since version 0.21 it's no longer possible to style using CSS (the context menu is rendered inside a shadow root). This makes this issue more important IMO.

guykr avatar Dec 13 '20 15:12 guykr

I would really like to change the background colour of the context menu

therealokoro avatar Feb 10 '21 09:02 therealokoro

Any news regarding this?

MYKEU avatar Mar 24 '21 14:03 MYKEU

It does drive me a little nuts because I can see VSCode customizing the appearance and including other features like submenus #1947 but none of these key features make it back upstream.

smiles2424 avatar Apr 02 '21 17:04 smiles2424

@smiles2424 are you still able to overwrite css or it is impossible now because of what guykr mentioned above?

cjinxin avatar Aug 20 '21 19:08 cjinxin

It is possible by overriding services when creating the editor.

For contextMenu, you can always pass 'contextMenuService' with instance of IContextMenuService class. Take a look at the default implementation to create your own.

monaco.editor.create(document.getElementById("editor"), {}, {
  'contextMenuService': {
      showContextMenu: (b) => console.log(b) 
    }
})

anujjamwal avatar Dec 20 '21 19:12 anujjamwal