[Bug] Paste action in Context Menu does not work and cannot be removed by api
Reproducible in vscode.dev or in VS Code Desktop?
- [x] Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- [ ] Not reproducible in the monaco editor playground
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.54.0#example-creating-the-editor-hello-world
Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `function hello() {
alert('Hello world!');
}`;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "javascript",
automaticLayout: true,
});
Reproduction Steps
- Open the monaco editor playground in Chrome, Brave, etc OR Safari (I have only done this on MacOS Tahoe 26.0.1 but I think it should be any OS, could use some confirmation)
- Copy some text (in or outside the editor does not matter) so that you have some text on your clipboard
- Click into the main editor window and right click to show the context menu.
- Find the Paste item and click it
- Notice that nothing is pasted
https://github.com/user-attachments/assets/95b8ecaf-8469-4627-811b-72f5b3d0a438
Actual (Problematic) Behavior
Clicking the Paste context menu item/action does nothing, user is not prompted for access to the clipboard and no paste occurs.
Expected Behavior
I would expect thata user of the editor would be asked to give permission to the clipboard API to perform a Paste or at least be able to disable this context menu item easily and replace it with my own custom action that works.
Additional Context
In my own code (not shown here) I can (and am) just adding my own Paste command which actually does the correct behavior (it doesn't rely on execCommand('paste') so all I really want to do with my change here is allow someone like me to express that I don't want the built in Paste context menu item since it doesn't work.
Also, you will not see this bug in firefox because it is just known in firefox that paste isn't available and so it appears to already be taken into account in the logic.
Please note that I submitted a PR that allows you to remove the Paste option.
At some point be open to creating an additional PR to just remove the need to use execCommand('paste') but probably need to learn a bit more about the status of the Clipboard API, especially in extensions and other environments.
My current use case in contributing the PR that removes the Paste option is that people would be able to turn off paste and then add a custom, working paste command for the environment(s) they actually care to support in their usage of monaco.