profile
viewpoint

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

microsoft/monaco-editor

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: '' } ] );
useful!
source:https://uonfu.com/
Github User Rank List