Monaco Editor Delete 2 characters

92 views Asked by At

I use monaco-editor for my React project, and when I delete data in monaco-editor, it's delete 2 character.

This is my code:

   useEffect(() => {
    const editorContainer = document.getElementById('monaco-mermaid');
    const monacoEditor = monaco.editor.create(editorContainer, {
        language: 'mermaid',
        minimap: {
            enabled: false
        },
        fontWeight: '600',
        fontSize: '14px',
        overviewRulerLanes: 0,
        quickSuggestions: false,
    });

    let isChangePending = false;

    monacoEditor.onDidChangeModelContent(() => {
        if (!isChangePending) {
            isChangePending = true;
            setTimeout(() => {
                const newValue = monacoEditor.getValue();
                handleChangeCode(newValue);
                isChangePending = false;
            }, 0);
        }
    });

    monaco.editor.setTheme('mermaid')
    initEditor(monaco);
},[])

Please help me !!!

0

There are 0 answers