This is a migrated thread and some comments may be shown as answers.

[Solved] Setting RADEditor to headings only

1 Answer 66 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Xan
Top achievements
Rank 1
Xan asked on 14 Dec 2009, 04:57 PM
Currently we are using the RADEditor in a Content Management System for allowing users to add/update news articles for their websites.  This gives the user a great amount of flexibility to for adding images, documents. etc to the news articles.  Currenly each news article contains a heading and summary for displaying news in a simple list with a read article link for retrieving the complete article.  The heading and summary fields are standard asp:TextBox controls. 

The latest request has been to provide an option for linking the heading to a PDF file as well as attach a thumbnail image to the heading.  Since the RADEditor already provides for this I was going to use a very basic toolbar that only displays the ImageManager and LinkManager button to allow users to add this to the heading. 

What I would like to know is if it would be possible to set the default tag for the Editor to a heading tag as this should be the only option for our news headings?

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 15 Dec 2009, 04:10 PM
Hi Xan,

If I understand your question correctly, you want to set a <h> tag to surround the RadEditor's content by default.
RadEditor does not provide such functionality out-of-the-box, however, this can be achieved by wrapping the content when it is submitted with the required heading tag. For example:

<telerik:RadEditor ID="RadEditor1" runat="server" OnClientSubmit="OnClientSubmit">
</telerik:RadEditor>
<script type="text/javascript">
    function OnClientSubmit(editor, args) {
        var oldContentValue = editor.get_html();
        //check if the content is already wrapped with heading tag
        if (!oldContentValue.match(/<h1>(.*)<\/h1>/gi)) {
            newContentValue = '<h1>' + oldContentValue + '</h1>';
        } else {
            newContentValue = oldContentValue;
        }
        editor.set_html(newContentValue);
    }
</script>

I hope this help you solve your issue. 


Best wishes,
Dobromir
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
Xan
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or