Copied to clipboard

Flag this post as spam?

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


  • praveen 113 posts 164 karma points
    Apr 27, 2018 @ 07:00
    praveen
    0

    Rich Text Editor - out puts <P> tags at the beginning and the end </p>

    Hi,

    Rich Text Editor - out puts "

    " tags at the beginning and the end "

    " How can I remove the leading and the trailing "

    " tags. please help

    enter image description here

  • Mark 91 posts -18 karma points
    Apr 27, 2018 @ 08:12
    Mark
    100

    This is by design, the Rich Text Editor is meant to add HTML tags to your content. If you don't need HTML, try the text area.

  • praveen 113 posts 164 karma points
    Apr 27, 2018 @ 08:26
    praveen
    0

    Then how do we format the text in textarea

  • Søren Mastrup 122 posts 564 karma points c-trib
    Apr 30, 2018 @ 05:40
    Søren Mastrup
    1

    The text in the textarea cannot be formatted, if you need to format, use the Rich Text Editor (RTE)

    If you try to render the RTE, without using modelsbuilder, you will get the contents of the RTE as a string. That is why you see the HTML tags. For rendering the text as HTML, use Html.Raw(editorAliasHere).

    If you have access to Umbraco TV, then take a look here: https://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/razor-syntax/htmlraw/documentation/

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Apr 30, 2018 @ 09:10
    Lee Kelleher
    1

    Hi Praveen,

    Like the others have said, this is standard RTE behaviour out-of-the-box.

    Although, there are two hacky options - both of which are pretty old school! :-)

    1. Do it in the Razor template, using umbraco.library.RemoveFirstParagraphTag(text) ... (but consider this v4 legacy code, I'm sure it'll disappear in v8)
    2. Prevent TinyMCE from adding the <p> tags - by configuring the forced_root_block property - see a blog post (and comments) about it here: http://scottsdevblog.com/2011/08/get-rid-of-those-pesky-p-tags-in-umbracos-tinymce-editor/

    Personally, I'd go with option 1, (but I'd probably end up writing my own helper method for it).

    Cheers,
    - Lee

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Apr 30, 2018 @ 09:15
    Lee Kelleher
    2

    ooo, it's just occurred to me, @Umbraco.Field(alias) has a optional parameter for removeParagraphTags.

Please Sign in or register to post replies

Write your reply to:

Draft