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

[Bug] paste not working with right click

Open m4il3r17 opened this issue 1 month ago • 5 comments

Monaco Editor Playground Link

can you please fix a small bug when i try to paste a text with right click and click paste. any text i copy and try to paste when click right click with mouse and click paste and paste empty value "text"

m4il3r17 avatar Oct 29 '25 23:10 m4il3r17

We are encountering the same issue. Copy/Paste works but Paste fails silently.

You can even reproduce the issue in the Playground on the current latest version 0.54.0

I don't think it's a security issue because it used to work.

clement911 avatar Nov 04 '25 01:11 clement911

Here is an example where it works for example: https://graphql.org/swapi-graphql I think they use a slightly older version of monaco

clement911 avatar Nov 04 '25 01:11 clement911

Wanted to check in on the progress for a fix on this? We have had multiple client run into the issue. Even though there is a workaround for non-mobile users, it is frustrating.

carmen-stw avatar Dec 04 '25 19:12 carmen-stw

@carmen-stw what is your work around for non mobile users?

clement911 avatar Dec 05 '25 01:12 clement911

I've investigated this issue and identified the root cause. It appears to be a regression caused by a hard dependency on IProductService within the clipboard contribution code.

Root Cause Analysis: In vscode/src/vs/editor/contrib/clipboard/browser/clipboard.ts#L288 , the PasteAction implementation attempts to retrieve IProductService :

// ... inside PasteAction implementation
const productService = accessor.get(IProductService);
// ...

In the Monaco Editor Standalone environment, IProductService is not registered/available by default. This causes accessor.get(IProductService) to throw an "Unknown service" error immediately when the "Paste" action is triggered via the context menu.

This error halts the execution before the actual paste logic (or the document.execCommand fallback) can run, resulting in the silent failure observed.

Observation: The productService is only used later in the function for a telemetry check:

if (productService.quality !== 'stable') {
    // log telemetry
}

Temporary Workaround: You can fix this locally by removing the dependency on IProductService .

  1. Open node_modules/monaco-editor-core/esm/vs/editor/contrib/clipboard/browser/clipboard.js .
  2. Delete the import of IProductService and all references to productService within the file.
  3. Run npx patch-package monaco-editor-core to persist the changes.

Hope this helps until an official fix is released!

tuzixiangs avatar Dec 08 '25 06:12 tuzixiangs