How to get WP editors tinyMCE instances

If you wait for the SetupEditor event then you can access the editors:

add_action( 'admin_print_footer_scripts', function () {
    ?>
    <script type="text/javascript">
    jQuery(function ($) {
        if (typeof tinymce !== 'undefined') {
            tinymce.on('SetupEditor', function (editor) {
                if (editor.id === 'contentLeft') {
                    // Could use new 'input' event instead.
                    editor.on('change keyup paste', function (event) {
                        console.log('content=%s', this.getContent());
                    });
                }
            });
        }
    });
    </script>
    <?php
} );

Leave a Comment