Support

Account

Home Forums General Issues TinyMCE Filter inside Gutenberg block stops field from saving Reply To: TinyMCE Filter inside Gutenberg block stops field from saving

  • The problem is that the custom “setup” function is overriding the ACF one, which prevents ACF from listening to the “change” event of the TinyMCE instance.

    Without this listener, the ACF Block won’t be able to detect a “change”, which prevents it from saving/updating.

    The solution is to create a backup of the original setup function and call that within the custom one. Like so:

    function custom_acf_tinymce() {
    ?>
    <script>
    acf.add_filter('wysiwyg_tinymce_settings', function(mceInit, id, $field) {
    	var _setup = mceInit.setup;
    	mceInit.setup = function(editor) {
    		_setup.apply(this, arguments);
    		editor.on('click', function(e) {
    			console.log('Editor was clicked');
    		});
    	};
    	return mceInit;
    });
    </script>
    <?php
    }
    add_action('acf/input/admin_footer', 'custom_acf_tinymce');