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

Unwanted Paragrahp added

1 Answer 25 Views
Editor
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 03 Mar 2009, 01:20 AM
Hi,

I do the following:

I have on line in my editor content.
I mark this line - and choose "Heading 1" from the drop down.

So what I expect is:
Before:
My Line of Text
After Heading 1:
<h1>My Line of Text</h1>

But what I get is
<h1>My Line of Text</h1>
<p> </p>

How can I turn this "add extra paragraph behaviour" of?

Regards

Manfred

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 Mar 2009, 10:22 AM
Hello Manfred,

I tried to reproduce the problem but I noticed that the editor produced different content from the provided one, e.g.
<h1>
<p>My Line of Text </p>
</h1>

You can see that the p tags are inside the heading 1 tags. For your convenience I attached a video demonstrating my test.

If this is your scenario then you can fix it using the following code solution:

<script type="text/javascript">  
function OnClientCommandExecuting(editor, args)  
{  
    if (args.get_commandName() == "FormatBlock")  
    {  
        var sel = editor.getSelectionHtml();     
        if (!sel) return//No selection? Do nothing - let the browser handle it!           
        //Delete current selection, but paste its contents - hence you eliminate the P tag.  
        editor.get_document().execCommand("Delete"nullfalse);              
        editor.pasteHtml(sel);            
    }  
}  
</script>   
  
<telerik:RadEditor runat="server" ID="RadEditor1"       
OnClientCommandExecuting="OnClientCommandExecuting" >    
    <Content>  
        My Line of Text  
    </Content>  
</telerik:RadEditor>  

If your scenario is other, please open a support ticket and send a video demonstrating the problem and sample working project that I can examine and recreate the issue on my end.

All the best,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Share this question
or