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');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.