Classic Text does not show all buttons from TinyMCE Advanced
Issue Overview
If the TinyMCE Advanced plugin is loaded as well as Gutenberg it should be possible to set the buttons on the classic text block. This mostly works but some buttons do not show up because the plugin required is not loaded.
CC @azaozz
Example
With the following settings in TinyMCE Advanced:

Gutenberg looks like:

But the default wordpress editor looks like this:
Note that the "image" and "table" (3rd line) buttons are not shown on Gutenberg but they are on the default.
Steps to Reproduce (for bugs)
- Install and activate the "TinyMCE Advanced" plugin from the GUI
- Ensure a button that require a plugin is enabled on the TinyMCE Advanced settings page
- View a "Classic Text" block on Gutenberg
Note I am using a docker image to run wordpress though I don't believe that this should have any impact for this particular problem.
Expected Behavior
I expect all the required plugins for showing buttons to be loaded in Gutenberg. For example in the default wordpress the revelent editor settings have the values:
>> tinyMCE.activeEditor.settings.toolbar1
"formatselect,bold,italic,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,spellchecker,dfw"
>> tinyMCE.activeEditor.settings.toolbar2
"fontselect,fontsizeselect,forecolor,removeformat,outdent,indent,wp_more"
>> tinyMCE.activeEditor.settings.toolbar3
"pastetext,charmap,image,table,wp_help"
>> tinyMCE.activeEditor.settings.plugins
"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview,image table advlist wptadv"
>> tinyMCE.activeEditor.settings.external_plugins
{
"table": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/table/plugin.min.js",
"advlist": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/advlist/plugin.min.js",
"wptadv": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/wptadv/plugin.min.js"
}
I should note that there is a possibly relevant anomaly in the plugins string. All the preexisting plugins have commas between them but the "TinyMCE Advanced" added plugins (image, table, advlist, wptadv) are space separated.
Current Behavior
Currently all except one of the plugins added by TinyMCE Advanced is being lost in Gutenberg. The relevant editor settings are as follows:
>> tinyMCE.activeEditor.settings.toolbar1
"formatselect,bold,italic,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,spellchecker,kitchensink"
>> tinyMCE.activeEditor.settings.toolbar2
"fontselect,fontsizeselect,forecolor,removeformat,outdent,indent,wp_more"
>> tinyMCE.activeEditor.settings.toolbar3
"pastetext,charmap,image,table,wp_help"
>> tinyMCE.activeEditor.settings.plugins
"charmap colorpicker hr lists media paste tabfocus textcolor fullscreen wordpress wpautoresize wpeditimage wpemoji wpgallery wplink wpdialogs wptextpattern wpview wptadv"
>> tinyMCE.activeEditor.settings.external_plugins
{
"wptadv": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/wptadv/plugin.min.js"
}
Possible Solution
I found that if I checked out the plugin from git ( https://github.com/wp-plugins/tinymce-advanced.git ) and referenced the folder instead of installing it from the Wordpress GUI it worked in Gutenberg. It may be that the solution is simply to update the version that Wordpress installs to the latest available git version.
Note that this does not resolve the previously noted anomaly where in the default wordpress the plugins added by "TinyMCE Advanced" are separated by space instead of commas.
Default wordpress with "TinyMCE Advanced" plugin from Git install

>> tinyMCE.activeEditor.settings.toolbar1
"formatselect,bold,italic,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,spellchecker,dfw"
>> tinyMCE.activeEditor.settings.toolbar2
"fontselect,fontsizeselect,forecolor,removeformat,outdent,indent,wp_more"
>> tinyMCE.activeEditor.settings.toolbar3
"pastetext,charmap,image,table,wp_help"
>> tinyMCE.activeEditor.settings.plugins
"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview,image table advlist"
>> tinyMCE.activeEditor.settings.external_plugins
{
"table": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/table/plugin.min.js",
"advlist": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/advlist/plugin.min.js"
}
Gutenberg with "TinyMCE Advanced" plugin from Git install

>> tinyMCE.activeEditor.settings.toolbar1
"formatselect,bold,italic,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,spellchecker,kitchensink"
>> tinyMCE.activeEditor.settings.toolbar2
"fontselect,fontsizeselect,forecolor,removeformat,outdent,indent,wp_more"
>> tinyMCE.activeEditor.settings.toolbar3
"pastetext,charmap,image,table,wp_help"
>> tinyMCE.activeEditor.settings.plugins
"charmap colorpicker hr lists media paste tabfocus textcolor fullscreen wordpress wpautoresize wpeditimage wpemoji wpgallery wplink wpdialogs wptextpattern wpview image table advlist"
>> tinyMCE.activeEditor.settings.external_plugins
{
"table": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/table/plugin.min.js",
"advlist": "http://localhost:8080/wp-content/plugins/tinymce-advanced/mce/advlist/plugin.min.js"
}
Related Issues and/or PRs
None known.
The TinyMCE Advanced plugin doesn't support Gutenberg (yet). Two reasons:
- The settings for the current editor are outputted from PHP. There are a number of filters and actions to control it. Gutenberg is JS based and these filters don't (and can't) exist there.
- TinyMCE is used quite differently in Gutenberg. In the current editor there is only one instance of it and all settings can be changed easily. In Gutenberg there are many instances and with different configurations.
And yes, I agree that we need better "extensibility" in Gutenberg so plugins can add or change block settings. The more "locked down" the editor is, the more plugins will try to hack around it to be able to add stuff they want.
The settings for the current editor are outputted from PHP. There are a number of filters and actions to control it. Gutenberg is JS based and these filters don't (and can't) exist there.
Actually they are exported to JS in lib/client-assets.php:
wp_localize_script( 'wp-editor', 'wpEditorL10n', array(
'tinymce' => array(
'baseURL' => includes_url( 'js/tinymce' ),
'suffix' => SCRIPT_DEBUG ? '' : '.min',
'settings' => apply_filters( 'tiny_mce_before_init', array(
'external_plugins' => apply_filters( 'mce_external_plugins', array() ),
'plugins' => array_unique( apply_filters( 'tiny_mce_plugins', array(
'charmap',
'colorpicker',
'hr',
'lists',
'media',
'paste',
'tabfocus',
'textcolor',
'fullscreen',
'wordpress',
'wpautoresize',
'wpeditimage',
'wpemoji',
'wpgallery',
'wplink',
'wpdialogs',
'wptextpattern',
'wpview',
) ) ),
'toolbar1' => implode( ',', array_merge( apply_filters( 'mce_buttons', array(
'formatselect',
'bold',
'italic',
'bullist',
'numlist',
'blockquote',
'alignleft',
'aligncenter',
'alignright',
'link',
'unlink',
'wp_more',
'spellchecker',
), 'editor' ), array( 'kitchensink' ) ) ),
'toolbar2' => implode( ',', apply_filters( 'mce_buttons_2', array(
'strikethrough',
'hr',
'forecolor',
'pastetext',
'removeformat',
'charmap',
'outdent',
'indent',
'undo',
'redo',
'wp_help',
), 'editor' ) ),
'toolbar3' => implode( ',', apply_filters( 'mce_buttons_3', array(), 'editor' ) ),
'toolbar4' => implode( ',', apply_filters( 'mce_buttons_4', array(), 'editor' ) ),
), 'editor' ),
),
) );
TinyMCE is used quite differently in Gutenberg. In the current editor there is only one instance of it and all settings can be changed easily. In Gutenberg there are many instances and with different configurations.
True for most blocks but the "Classic Text" block aims to be backwards compatible with the old Wordpress editor which is why this is important.
Hey @azaozz : with your knowledge of how TinyMCE Advanced works, do you see any bugs in the code snippet above that could be stopping it from functioning and loading all the plugins? Thx
It's a problem with the order of PHP filters. See #3019. Seems to all work fine for me with that.
Right, TinyMCE Advanced adds (TinyMCE) plugins according to the buttons the user has chosen. To find out which plugins to load it needs to "see" the chosen buttons which happens when the toolbars are loaded.
It is pre-loading all settings on an earlier hook, 'wp_editor_settings' which is not fired here. Will fix it to pre-load the settings before the 'mce_external_plugins' filter too.