Copied to clipboard

Flag this post as spam?

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


  • Jason Denousse 16 posts 46 karma points
    May 08, 2015 @ 11:14
    Jason Denousse
    0

    How to remove paragraph tags in RTE

    I am using the rich text editor for a user to insert images. It has a macro attached to it to allow to insert flash.

    When ever i insert a file whether it be image or flash, the rte automatically adds a

    tag, which means that my content isnt flush to the screen.

    I remove the

    ttags from the html source editor from the RTE but once isave the content, the tag comes back.

     

    Any thoughts how i can get rid of these

    tags?

  • Dennis Aaen 4432 posts 17885 karma points admin hq c-trib
    May 08, 2015 @ 11:35
    Dennis Aaen
    0

    Hi Jason, 

    If you go to /umbraco/lib/tinymce you will see the tinymce.min.js file in there.

    To be able to make the change described you need to run the minified code to for exampe you can use http://www.jspretty.com/  - If your editor does not provide this option  and once the code is modfied you can copy/paste it into http://marijnhaverbeke.nl/uglifyjs to uglify it again. Make sure to search for "forcedrootblock" I think you will see 19 results and it is the last result you need to edit.

    You should be aware that making changes to core files they will of disappear if you decide to do an upgrade. Then you have to do the modification once again.

    Hope this helps,

    /Dennis

  • Urvish 252 posts 770 karma points
    May 08, 2015 @ 11:37
    Urvish
    0

    Hi Jason Denousse,

    This is the well know issue with RTE.

    What I would suggest you is that remove the paragraph from the view or controller using sub-string or any other method.

    Regards,

    Urvish Mandaliya

  • Urvish 252 posts 770 karma points
    May 08, 2015 @ 11:40
    Urvish
    1

    or you can use

    @umbraco.library.RemoveFirstParagraphTag(page.product.ToString())
    

    Hope this helps.

    Regards,

    Urvish Mandaliya

  • Marco Teodoro 60 posts 134 karma points
    Aug 06, 2019 @ 09:59
    Marco Teodoro
    0

    Hi @Urvish, do you know if this was converted to V8. I Was looking at the Source code in the HtmlHelperRenderExtensions but can't find this method.

  • Jason Denousse 16 posts 46 karma points
    May 08, 2015 @ 11:48
    Jason Denousse
    0

    Hi Dennis

    Thanks for your reply, however, I've looked on my server and do not have /umbraco/lib/tinymce as a directory and have searched for tinymce.min.js file and do not have that either.

    I am using Umbraco v6.0.6 if that makes a difference.

    However, would adding an entry to he TinyMCE.css work?

    And Urvish, i can remove the paragraph from the view and  controller, but it reappears once publishing.

  • Jason Denousse 16 posts 46 karma points
    May 08, 2015 @ 11:49
    Jason Denousse
    0

    Hi Urvish

    Sorry to sound ignorant but where would i enter that line you have given me?

  • Urvish 252 posts 770 karma points
    May 08, 2015 @ 11:54
    Urvish
    0

    Hi Jason,

    You can add this line in the View where you fetching the values from the RTE.

    @umbraco.library.RemoveFirstParagraphTag(Model.YourPropertyValue.ToString())
    

    Regards,

    Urvish Mandaliya

  • Urvish 252 posts 770 karma points
    May 08, 2015 @ 12:02
    Urvish
    0

    It doesn't matter that p tag reappears after publishing when you truncate that p tag from the RTE value.

    At the end you will not see p tag in front end.

    Means you have written a code to remove p tag in view that it doesn't matter p tag appears after publishing.

    Regards,

    Urvish Mandaliya

  • Jason Denousse 16 posts 46 karma points
    May 08, 2015 @ 12:16
    Jason Denousse
    0

    Sorry Urvish

    Your terminology is confusing me, when you say "View where you fetching the values from the RTE" are you talking about the css file, or the config file, or somewhere else?

    I'm using TinyMCE v3 wysiwyg as the property editor for my RichText editor data type.

    I tried adding "<config key="forced_root_block"></config>" to <customConfig> section of the TinyMceConfig.config bt this didnt work either, still seeing <p> tags.

  • Jan Skovgaard 11241 posts 23387 karma points MVP 6x admin c-trib
    May 08, 2015 @ 12:18
    Jan Skovgaard
    0

    Hi Jason

    May I ask what specific version of Umbraco you're using? The path Dennis mentioned in the first post should be correct and contain the tinymce.min.js if you're on Umbraco 7.x - If not then it's probably located in the /umbraco_client folder somewhere.

    But if the approach Urvish suggests above does the trick for you then there is no need to modify this file. It has the downside that you'll need to do it again if you need to upgrade Umbraco. So if you can fix it another way then that's probably more ideal.

    Just got curious now :)

    /Jan

  • Jason Denousse 16 posts 46 karma points
    May 08, 2015 @ 12:38
    Jason Denousse
    0

    Hi Jan

    I'm using version 6.0.6. I have 3 files, tiny_mce.js, tiny_mce_popup.js and tiny_mce_src.js.

    I haven't used Urvish's solution yet as I am still unsure of where to enter the entry he has given men.

    I'm using TinyMCE v3.

  • Urvish 252 posts 770 karma points
    May 08, 2015 @ 12:47
    Urvish
    0

    Hi Jason,

    I am talking about the template that means the views that means the .cshtml file.

    You can write code when you fetch values.

    Like for Example,

    We fetch title from the Content page inside template (View) like @Model.Title.

    So likewise you can get the RTE value like @Model.PropertyValue.ToString() ---

    So this value you need to pass to the @umbraco.library.RemoveFirstParagraphTag method.

    Ultimately , you need to write below code to get property value with first paragraph tag removed which is added by default from RTE.

    @umbraco.library.RemoveFirstParagraphTag(Model.YourPropertyValue.ToString())
    

    So , you do't need to do any change in .css or and any .js files.

    And when I am writing the code lik @umbraco then it means it supposed to be written in the Template(VIEW).

    Let me know if you still not able to understand. I can explain you with image.

    Regards,

    Urvish Mandaliya

  • Jason Denousse 16 posts 46 karma points
    May 08, 2015 @ 13:23
    Jason Denousse
    0

    Hi Urvish

    I think i know what you mean now, however, my templates are all designed in aspx pages, for example, this is what my template looks like:

    "<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">

    <umbraco:Item field="flash" runat="server" />

    </asp:Content>"

    As you can see very simple page, the macro allows me to add in flash, or use the inesert image tool from the TinyMCE. However, the p tags still insert. I think you are perhaps using a different format of templating to myself.

  • Jan Skovgaard 11241 posts 23387 karma points MVP 6x admin c-trib
    May 11, 2015 @ 07:08
    Jan Skovgaard
    0

    Hi Jason

    Just to confirm - Yes you and urvish are rendering the content differently. You're not using macros - You're using umbraco:Item, which is not the same.

    I just checked and it turns out my memory is not that bad :) In Umbraco versions lower than 7 the tinymce script is placed in the /Umbraco_Client/TinyMCE/ folder - There is a minified tinymce.js file, which is probably the one you need to look in.

    You can also try changing the way you're rendering the flash by using a Razor macro instead. Then what urvish describes about should be possible however it might take a variation.

    Hope this helps.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft