question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support showing the native context menu (with copy/paste)

See original GitHub issue

monaco-editor version: 0.12.0 Browser: Google Chrome OS: macOS Steps or JS usage snippet reproducing the issue: When disabling context menu (contextmenu: false), highlighting a text and right clicking it will open context menu with missing actions (Cut/Paste/Copy/Select All)

context

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
neptuniancommented, Nov 29, 2018

I don’t want to use the custom Monaco menu so i set contextmenu: false. But i want the native browser menu to still be able to copy paste. Is this possible?

1reaction
elslooocommented, Nov 29, 2019

Setting contenteditable="true" on the <div class="monaco-editor"> seems to bring copy and paste back to the native context menu (Mac Chrome) while surprisingly not harming everything else.

Unfortunately in WebKit / Safari, this does allow editing the content of tooltips too (e.g. error messages, hover tooltips).

However, If (like me) you’re only interested in WebKit (e.g. embedding in a native app), I can recommend adding a CSS rule:

.monaco-editor .view-line {
    -webkit-user-modify: read-write-plaintext-only;
}

This will set contentEditable on every view-line individually (which contains only the syntax highlighted text, not the tooltips, etc). It’s not perfect; the class names may change in the future. Just make sure to check if it’s still working every time you update to a newer version of monaco.

It also seems compatible with Chrome (tested), Edge and Opera (both untested).

Read more comments on GitHub >

github_iconTop Results From Across the Web

AO 2.x: How to show or hide the Cut, Copy & Paste entries in ...
When opening the Context Menu for a cell that belongs to an AO data source, Analysis Office does hide most of the Excel...
Read more >
Copy/Paste using the context menu doesn't work - Syncfusion
In Document editor, we use our own context menu to display the Word editor specific menu items. So, retrieving the data from system ......
Read more >
How to add a copy/paste context menu to browser element in ...
Connect it to whatever you want, here am making it the context menu of the browser element by giving the id of menu...
Read more >
Disable Or Enable Windows 11 Context Menu How To Guide
That also refinement contextual file operations in the right-click context menu, and share dialog shares its design aspects. The context menu is ...
Read more >
Creating a React context menu - LogRocket Blog
You can see options like copy, paste, and cut if you highlight text. You may also see customized context menus on email or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found