+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Paragrahs Style modifying code

Paragrahs Style modifying code

12 posts, 0 answered
  1. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    11 Aug 2010
    Link to this post
    Hi,

    I'm currently using the generic control with sitefinity.

    When, using the Radeditor, I type something like this:

    <div class="MyClass">My Content</div>

    I then go into the design mode, and apply an H1 using teh paragraph style on My Content, I expect somethign like this
    <div class="MyClass">
    <h1>My Content</h1>
    </div>

    But, radeditor seems to be changing the code into:
    <h1 class="MyClass">My Content</h1>

    Is there anyway to prevent this ?
    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Aug 2010
    Link to this post
    Hi Zyad Rujeedawa,

    The default behavior of the rad editor is to get the whole html you have marked and wrap it inside text styles. You can create a custom dropdown that gets selected text - getSelectionHtml method and then call pasteHtml. Another option is using set_html method

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    11 Aug 2010
    Link to this post
    Hello Ivan,

    I'm sorry but I don't quite understand.  Can you please give me some more details.
    Do I need to get the HTML again and then parse it ?
    is there any existing code available for us to have a look ?

    Please note that my problem is with the Generic content in SiteFinity.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Aug 2010
    Link to this post
    Hello Zyad Rujeedawa,

    In each of the links I sent you you will find a sample. The Generic Content wraps RadEditor control. The RadEditor is declared in GenericContentDesigner.ascx template. This is an embedded template that has to be mapped in case you are going to extend it - How to map a template

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    11 Aug 2010
    Link to this post
    Thanks Ivan,

    We'll be trying this, and let you know how it goes.

    Thanks,
    Zyad
  6. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    12 Aug 2010
    Link to this post
    Ivan,

    Works like a charm.

    Thanks a bunch.

    Zyad
  7. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    12 Aug 2010
    Link to this post
    Hello Ivan,

    One question:

    We've managed to add our tags by using the method below.
    How can we remove the tags ?

    From our custom drop down, we've selected HI.  We gain control of the selected content and then add the selected tags, and it becomes like this:
    <div class="MyClass">
    <h1>My Content</h1>
    </div>

    Perfect up to now.

    We then, from our custom dropdown, select H2 on the same text.  This time we get
    <div class="MyClass">
    <h1><h2>My Content<h2></h1>
    </div>

    How do we remove the H1 before the H2 is added ?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Aug 2010
    Link to this post
    Hi Zyad Rujeedawa,

    You can use regular expression to get the "H" tag and replace it with newly selected value. Another option is to get selected HTML, then get the text between  ">" and  "<" and replace the whole selected content using the above mentioned methods that you use to add the H1 tags

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    12 Aug 2010
    Link to this post
    That's what I did, but I don't seem to be able to get the selected text together with the HTML tags.
    I always get the text, without the HTML.

    I tried both
    getSelectionHtml()
    and
    getSelection
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Aug 2010
    Link to this post
    Hello Zyad Rujeedawa,

    getSelectionHtml() returns the HTML of the selection. You could take a look at the attached video.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Zyad Rujeedawa
    Zyad Rujeedawa avatar
    31 posts
    Registered:
    18 Feb 2010
    12 Aug 2010
    Link to this post
    Thanks.

    I found out that it only works in IE.

    Zyad
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Aug 2010
    Link to this post
    Hi Zyad Rujeedawa,

    You could try using RegEx to get the code between the tags. I do not see another option for now.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
12 posts, 0 answered