WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#34329 closed defect (bug) (invalid)

Render TinyMCE views before applying wpautop to content

Reported by: danielbachhuber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords:
Focuses: Cc:

Description

wpautop is run on BeforeSetContent: https://core.trac.wordpress.org/browser/tags/4.3/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js#L115

mce views are rendered on SetContent: https://core.trac.wordpress.org/browser/tags/4.3/src/wp-includes/js/tinymce/plugins/wpview/plugin.js#L223

When using mce views to render shortcode previews, our render callback receives the full shortcode with wpautop unexpectedly applied. I'd expect to have the shortcode without wpautop yet applied, as is the behavior when rendering shortcodes on the_content

From https://github.com/fusioneng/Shortcake/issues/471

Change History (1)

#1 @azaozz
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Don't think this is possible. wpautop() is run on the HTML string before it is loaded in the editor. To initialize wpView we need the editor DOM that was created by loading that HTML string.

See the note in the code:

// When the editor's content has been updated and the DOM has been
// processed, render the views in the document.
editor.on( 'SetContent', function() {
        wp.mce.views.render();
});
Last edited 4 years ago by azaozz (previous) (diff)
Note: See TracTickets for help on using tickets.