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

[Solved] Extending the Paragraph Style dropdown

3 Answers 198 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mark Davis
Top achievements
Rank 1
Mark Davis asked on 31 Jan 2008, 01:02 AM
I want to extend the paragraph style dropdown to enable the user to select one of the following:

Name="Code (C#)" Tag="PRE CLASS="cs""
Name="Code (C++)" Tag="PRE CLASS="cpp"", etc

but is appears that the attribute is ignored when the selected text has the tag applied. Is there any way to get around this? Basically, we want to process each code type differently on the server.

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Feb 2008, 08:54 AM
Hello Mark,

Here is an example demonstrating how to define the Format Block Dropdown items so that they include class attributes:

<telerik:radeditor runat="server" ID="RadEditor1">
    <Paragraphs>
       <telerik:EditorParagraph Title="Code (C#)" Tag="<PRE CLASS='cs'>" />
       <telerik:EditorParagraph Title="Code (C++)" Tag="<PRE CLASS='cpp'>" />
       <telerik:EditorParagraph Title="Heading 3" Tag="<H3>" />
   </Paragraphs>
</telerik:radeditor>



All the best,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mark Davis
Top achievements
Rank 1
answered on 07 Feb 2008, 10:22 PM
Thanks - that works, with the exception that when the <PRE CLASS="cs"> text is then formatted with <P> (Normal), the resulting HTML is <P CLASS="cs">. Do you know any way to remove the CLASS attribute in this situation? <P CLASS=""> doesn't work.
0
Rumen
Telerik team
answered on 11 Feb 2008, 04:28 PM
Hi Mark,

Here is an example how to strip the class attribute:

<script type="text/javascript">
function OnClientCommandExecuted(sender, args)
{

    if (args.get_commandName() == "FormatBlock"
     && args.get_value() == "<body>")
    {           
        var p = sender.getSelectedElement();
                       
        if (p.tagName == "P")
        {
            p.removeAttribute("className");
            p.removeAttribute("class");
        }
    }
}

</script>
<telerik:radeditor runat="server"
OnClientCommandExecuted="OnClientCommandExecuted"

ID="RadEditor1">
    <Content>
        sample content
    </Content>
    <Paragraphs>
        <telerik:EditorParagraph Title="Code (C#)" Tag="<PRE CLASS='cs'>" />
        <telerik:EditorParagraph Title="Code (C++)" Tag="<PRE CLASS='cpp'>" />
        <telerik:EditorParagraph Title="Normal" Tag="<body>" />
    </Paragraphs>
</telerik:radeditor>


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
Mark Davis
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Mark Davis
Top achievements
Rank 1
Share this question
or