Search code examples
monaco-editor

Disable Cut and Copy in context menu in Monaco editor


I am using monaco-editor, i see that cut and copy is added in the context menu in later versions. i want to remove these two options from context menu. Please let me know how can i achieve it?


Solution

  • Hide individual items with CSS

    I tried this code in the browser and it worked.

    // Hide from cut on
    .context-view li.action-item:nth-child(n + 9) {
        display: none !important;
    }
    
    // Show command palette
    .context-view li.action-item:last-child {
      display: flex !important;
    }
    

    Disable the entire menu with API

    monacoOptions = {
      // other options
      contextmenu: false
    }
    

    See Docs on IEditorConstructionOptions > contextmenu