Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kim Grandgagnage 63 posts 87 karma points
    Feb 07, 2011 @ 15:01
    Kim Grandgagnage
    0

    Remove empty paragraph tags in tinymce

    When my customer uses a tinymce editor in the backend of Umbraco, sometime empty paragraph lines are generated like <p>&nbsp;</p>

    This results in the fact that there is a lot of white space on the page.

    Is there a way to automatically get rid of these empty paragraph tags when the node is saved?

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 07, 2011 @ 16:02
    bob baty-barr
    2

    if you are using jquery in your site, you can use this in your doc.ready section...

    $("p:empty").remove();
  • Christer Josefsson 55 posts 93 karma points
    Feb 07, 2011 @ 21:50
    Christer Josefsson
    4

    Hi,

    You should change settings for validElements in tinyMceConfig.config, look for #p in the file and change it to -p.

    This link will explain the different characters meaning.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 08, 2011 @ 06:10
    bob baty-barr
    0

    hey, i have found that the P tags are not truly empty... they have a non-breaking space... so this code would actually kill the paragraph tags left stranded by the insert macro into RTE issue...

    $("p").each(function() {
    var $this = $(this);
    if ($this.html() === "&nbsp;") {
    $this.remove();
    }
    });
  • Luke Johnson 61 posts 80 karma points
    Jun 30, 2011 @ 16:41
    Luke Johnson
    0

    A server-side solution is:

     

    <%  string[] tags ={"&nbsp;","<p>","</p>"};
       
    string str1 ="<p>&nbsp;</p>";
       
    foreach(var tag in tags)
       
    {
            str1
    = str1.Replace(tag,"");
       
    }
    %> 

     

    Via: http://stackoverflow.com/questions/4408058/how-to-remove-blank-pnbsp-p-tags-at-end-of-paragraph

  • Hamish 96 posts 154 karma points
    Oct 26, 2011 @ 23:23
    Hamish
    1

    I think the approach on the following page is better than using jQuery/javascript:
    http://our.umbraco.org/forum/using/ui-questions/6266-Empty-p-tag-when-inserting-macro-into-text-editor

    My thoughts are that you should only be using jQuery/javascript to enhance the user experience and functionality. This can easily be resolved on the server side without having to bog down the users browser with extra javascript calls.

  • Bipin Kataria 29 posts 60 karma points
    Dec 27, 2014 @ 06:12
    Bipin Kataria
    1

    You guys can easly do it using TinyMCE settings.

    1. Go to "tinyMceConfig.config" file under "config" folder.
    2. Search for or go to "<customConfig>" section.
    3. Add new line as: <config key="forced_root_block"></config>

    This will not generate <p> tag in CMS Editor. So, you can write your content as you like. :) If you want to change it to something else then change it accordingly. For e.g. If you want to use <div> tag then change it to: <config key="forced_root_block">div</config>

    Thanks,
    Bipin

  • Thomas 319 posts 606 karma points c-trib
    Sep 28, 2017 @ 12:31
    Thomas
    0

    7.7.1 - won't work ?

  • Vladimir Knobel 95 posts 171 karma points
    Jan 22, 2018 @ 10:45
    Vladimir Knobel
    0

    It seems that you need to add

    <config key="forced_root_block">false</config> 
    

    for it to work.
    Leaving it empty doesn't work for me in 7.7.2.

Please Sign in or register to post replies

Write your reply to:

Draft