microsoft / monaco-editor

A browser based code editor
https://microsoft.github.io/monaco-editor/
MIT License
40.36k stars 3.59k forks source link

[Bug] : Editor allows ctrl+v to paste but disables when using context menu paste option. #4069

Open rohan220217 opened 1 year ago

rohan220217 commented 1 year ago

Reproducible in vscode.dev or in VS Code Desktop?

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.40.0#XQAAAAKZAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwztL3RgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKimARHSWlrTPOQHROITHxmAeFEs9_m3VHdSe7_Etv6Wpgzto0GSqI-Jbjpg6g3FsuE6sHNUsN9V6wL_ETQPRnm_0aVo0fnziUFXcOKdl1dN60w7lo6ksZk1GRLNRnJzi9yrBvdxj-pa6H0kcgR-V1FdTlNpR7fWF7jGnobpdtU4tU4Ok5mfapbCHRX_5CfbVQlilb4b4QPhbGF5wSQdSxStmNDURCQPPKXXN6-iGReKsXwlrZXF1IfthvhSOF2m1G9p67XrkF8_-693Eg

Monaco Editor Playground Code

const value = /* set from `myEditor.getModel()`: */ `function hello() {
    alert('Hello world!');
    alert('Hello world!');
}`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
    value,
    language: "javascript",
    automaticLayout: true,
    pasteAs: {
        enabled: false,
    },

});

Reproduction Steps

Just visited this doc link: https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IEditorOptions.html#pasteAs and added in the code but it is not working correctly. I want to disable paste option using ctrl+v

Actual (Problematic) Behavior

Context menu paste option is disabled after using pasteAs: { enabled: false, }, but ctrl+v is pasting content as usual

Expected Behavior

It should disable all types of pasting e.g. ctrl+v, context menu paste option, etc...

Additional Context

No response

LiWeny16 commented 9 months ago

The same problem