Ask questionsMonaco paste event

Hey, is there support in Monaco for a paste event which can be used to set a custom callback? Or should we instead add an event listener on Monaco's container element?

Cheers, Tim


Answer questions wufeng87

Ctrl+Z the output you removed will comeout again.

@FrankFang this is my way

this.editor.onDidPaste( ( e ) => {
    this.pastePosition = e;
} )
// in paste event 
const selection = this.editor.getSelection( );

const range = new monaco.Range(
    this.pastePosition.startLineNumber || selection.endLineNumber,
    this.pastePosition.startColumn || selection.endColumn,
    this.pastePosition.endLineNumber || selection.endLineNumber,
    this.pastePosition.endColumn || selection.endColumn,

this.editor.executeEdits( '', [ { range, text: '' } ] );

Related questions

Monarch: How do you add "@keywords" key to "language object"? (undocumented) hot 3
Error: Cannot find module 'monaco-editor/esm/vs/editor/contrib/gotoSymbol/goToCommands' hot 2
Removing the tooltip on the read-only editor that says 'cannot edit in read-only editor' hot 1
Registering/Providing custom Commands/CodeActions hot 1
How to get the line count including line wraps hot 1
Error: Cannot find module 'monaco-editor/esm/vs/editor/contrib/goToDefinition/goToDefinitionCommands' hot 1
TypeScript declaration preview from extra lib results in error hot 1
Editor props/extends the actual width of the parent that is a flexbox item hot 1
Problem with insane.js while using monaco-editor@0.18.0 hot 1
Change the language of an existing editor hot 1
javascript/typescript typedefs lost when webworker times out hot 1
Can't scroll in firefox hot 1
How to add simple custom language support? hot 1
monaco-editor polute the global variables, making incompatible with other JS libraries, such as CodeMirror, RequireJS, SeaJS, etc. hot 1
Highlight merge conflicts in monaco like in VSCode hot 1
Github User Rank List