Opened 6 years ago
Closed 6 years ago
#45893 closed defect (bug) (maybelater)
tinyMCEPreInit.load_ext() isn't called for TinyMCE external plugins in block editor
Reported by: | danielbachhuber | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.0 |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
In the Classic Editor, a TinyMCE plugin registered with the mce_external_plugins
filter will be loaded with the following:
<script type='text/javascript' src='http://tastyrecipes.test/wp-includes/js/tinymce/langs/wp-langs-en.js?ver=4800-20180716'></script> <script type="text/javascript"> tinyMCEPreInit.load_ext("http://tastyrecipes.test/wp-content/plugins/tasty-links/assets/js", "en"); ( function() { var init, id, $wrap;
This is generated in WP_Editor
:
- https://core.trac.wordpress.org/browser/tags/5.0/src/wp-includes/class-wp-editor.php#L507
- https://core.trac.wordpress.org/browser/tags/5.0/src/wp-includes/class-wp-editor.php#L1529
The block editor's wp_tinymce_inline_scripts()
doesn't perform the same, which means TinyMCE external plugins aren't executed for editor instances on the page (only the Classic Block instances).
I'm not sure whether this was intentional or unintentional, or even what the expected behavior is!
Change History (1)
Note: See
TracTickets for help on using
tickets.
After much struggle, I managed to track down the problem:
wp_editor( '', 'tasty-recipes-editor', array( 'teeny' => true ) );
. This instance isn't ever rendered. Rather, we then stealtinyMCEPreInit.mceInit['tasty-recipes-editor']
when we calltinyMCE.init()
for our dynamic text fields.WP_Editor->editor_js()
. However, TinyMCE is initialized in Gutenberg withprint_default_editor_scripts()
. The former makes thetinyMCEPreInit.load_ext()
call while the latter does not.I was able to work around this by filtering TeenyMCE init and always including our external plugin:
Closing this as
maybelater
as I don't think it's worth spending time fixing.