mousetrap icon indicating copy to clipboard operation
mousetrap copied to clipboard

Tinymce 4 support

Open nikmauro opened this issue 9 years ago • 2 comments

hello i have problem with tinymce editor i use the global plugin, this code not working inside tinymce, any suggestion?

Mousetrap.bindGlobal(['ctrl+s', 'command+s'], function (e) {
        if (e.preventDefault) {
            e.preventDefault();
        } else {
            e.returnValue = false;
        }
        my_func_here();
    });

nikmauro avatar Mar 19 '15 11:03 nikmauro

When an editor is rendered you can bind mousetrap to the editor's (iframe) body element.

function handleSaveKeyboardShortcut(e) {
    if (e.preventDefault) {
        e.preventDefault();
    } else {
        e.returnValue = false;
    }
    my_func_here();
}

Mousetrap.bindGlobal(['ctrl+s', 'command+s'], handleSaveKeyboardShortcut);

// When an editor is rendered...
Mousetrap(editor.contentWindow.document.body).bind(['ctrl+s', 'command+s'], handleSaveKeyboardShortcut);

mattheyan avatar May 27 '15 15:05 mattheyan

thank you! @mattheyan

kocoten1992 avatar Jun 25 '21 04:06 kocoten1992