Support » Plugin: Display Custom Fields - wpView » TinyMCE wpview plugin creates line breaks after shortcodes

  • Hi, we have discovered an issue inside WordPress’s TinyMCE plugin called “wpview”. (It’s the plugin which renders the shortcode inside the WYSIWYG editor.) Anyway, when you switch from “visual” to “text” OR when you save, the plugin converts the rendered HTML back to the raw shortcode. The problem is that when this happens, it wraps the shortcode in a <p> tag, and then when you go to text view, it adds a line break. This is what gets saved to the post_content:

    [shortcode_a blah="1"]
    [shortcode_a blah="2"]

    In theory, if a user creates to consecutive shortcodes in the editor without explicitly adding a line break, we would expect it to save like this:

    [shortcode_a blah="1"][shortcode_a blah="2"]

    If the user did not want a line break after the shortcode, there’s nothing they can do to get rid of it. Anyway, I want to submit this change to WordPress, but I wanted to post here first to see if anybody can think of a legitimate reason why we need to keep the <p> tags. Here’s the code file:

    /wp-includes/js/tinymce/plugins/wpview/plugin.js (Line 22)

    // Replace view tags with their text.
    function resetViews( content ) {
    	function callback( match, $1 ) {
    		return '<p>' + window.decodeURIComponent( $1 ) + '</p>';
    	if ( ! content ) {
    		return content;
    	return content
    		.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g, callback )
    		.replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, callback );

    We are considering removing the <p> tags from the callback function. Do you have any thoughts as to why this should be kept and why we should not submit this fix back to WordPress?

Viewing 1 replies (of 1 total)
  • Sorry, I accidentally submitted this here, but it’s not related to this plugin. It’s related to the WP core tinyMCE plugin called “wpview”

Viewing 1 replies (of 1 total)
  • The topic ‘TinyMCE wpview plugin creates line breaks after shortcodes’ is closed to new replies.