New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paste shows warning in Google Chrome #2183
Comments
@borremosch I think that's how it works, Please refer this issue
I think this is because , paste in context menu is available only after 0.21.0 |
Shouldn't the prompt trigger only when the clipboard was not accessed through any user interaction? Since the clipboard access is following a mouse click I would expect the prompt to be skipped.
That makes total sense |
Monaco seems to use a custom context menu and not the native context menu of the browser. So it may look like a mouse click , but internally it is going to trigger a javascript function which in turn access the navigator.clipboard
Yes , I too wish pasting happens this way @bpasero, Is it possible to modify the paste function without prompt? Now-a-days, Browser's native context menu does that without a prompt |
The "Paste" action was not present in the editor menu before as far as I can tell, and now that we have it, the browser will show the warning, that is just a security feature of the browser. I am not sure what we can do here or what changed? |
@bpasero As the browser's default context menu does paste without prompt there might be a way we can also implement it without that prompt. I thought Browser is using some API ( other than navigator ) to achieve this, In that case we can also use that API and do the paste action. But I'm not sure that kind of API exists. The main problem here is the UX of the paste action. |
When right clicking in the editor, you don't get a native context menu, you see a custom context menu rendered with DOM nodes. That is why we can render custom actions, like rename, or go to definition etc. When clicking on Paste in the editor context menu, you are basically clicking on a DOM node from the browser's point of view. There is no paste event, there is a click event. In the implementation of that click we end up using browser API to read from the clipboard. That browser API will prompt the user and ask for permission. When pressing ctrl+v in the editor, the browser generates a paste event. We read the data from the paste event, which does not create any user prompts. The only way to get a context menu paste without a prompt is to give up our custom context menu and use the native browser context menu. We had that a very very long time ago and will not go in that direction ever again. |
monaco-editor version: 0.21.2
Browser: Chrome 86.0.4240.75
OS: Windows 10
Playground code that reproduces the issue: https://microsoft.github.io/monaco-editor/
Right clicking and choosing
paste
from the context menu shows a warning dialog statingmicrosoft.github.io wants to see text and images copied to the clipboard
. Copying from the context menu or pasting through CTRL+V does not cause the warning to appear. This behavior does not seem to be present in older versions of Monaco.The text was updated successfully, but these errors were encountered: