Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

278
Visualizações
How to disable undo (only from keyboard shortcut) in TinyMCE v5?

I am using TinyMCE v5 inline editor. I want to disable undo/redo only for keyboard shortcuts i.e. Command+Z and Command+Shift+Z

Below is my code

class TextBlock extends Component {

    handleChange = (newText) => {
       *** updating state with newText
    };

    handleBeforeAddUndo = () => {
        **** commented below code because it restricts undo/redo even on undo button click. I dont want that.**
        // return false; 
    };

    handleUndo = (args) => {
       // nothing here
    };

    render() {
        const { content } = this.props.block;
        return (
                <Editor
                    value={content}
                    inline={true}
                    tinymceScriptSrc={process.env.PUBLIC_URL + '/tinymce/js/tinymce/tinymce.min.js'}
                    init={{
                        height: 500,
                        menubar: false,
                        block_formats: 'Heading1=h1; Heading2=h2; Heading3=h3; Paragraph=p;',
                        plugins: ['lists link paste'],
                        setup: function (editor) {
                          
                            **NOTE: below i tried 'meta+z' but it doesn't work.**
                            editor.addShortcut('meta+g', 'custom undo', () => {
                                console.log('you pressed cmd+z');
                            });
                        },
                        toolbar1:
                            'undo redo | formatselect | bold italic link | forecolor backcolor |',
                        toolbar2:
                            'bullist numlist outdent indent| alignleft aligncenter alignright alignjustify  | removeformat',
                    }}
                    onEditorChange={(newText) => this.handleChange(newText)}
                    onBeforeAddUndo={this.handleBeforeAddUndo}
                    onUndo={this.handleUndo}
                />
        );
    }
}

How can I achieve this use case? Thank you all for the valuable time.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Regarding to the documentation I would try to set hasRedo():Boolean and hasUndo():Boolean values to false. Please try and tell does it work in your case?

https://www.tiny.cloud/docs/api/tinymce/tinymce.undomanager/#hasredo

setup : function(editor) {        
    editor.UndoManager.hasUndo(false)
    editor.UndoManager.hasRedo(false)
};
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda