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

How to simply create a paragraph ?

9 Answers 100 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Laurent
Top achievements
Rank 1
Laurent asked on 04 Aug 2009, 03:14 PM
And by paragraph, I mean surround a block of text with a <p> tag.

I tried : the new paragraph tool and the formatblock tool.

Problem with the new paragraph tool : when hit, it erases the selected text (ok, it's "new" paragraph, no problem with that) but after hitting the button, the cursor is outside the paragaph. °_° ! That part looks quite strange for my end-users.

Problem with the formatblock tool : as long as it seems they is no solution with the "new paragraph" tool, I tried to use the formatblock. Our goal is to copy/paste big blocks of plain text, and format it. That part is a H2, that one is a H3 ... oh, and that one is P. So I configure my toolfile like this :

<paragraphs>
<paragraph name="Clear" value="&lt;body>" />
<paragraph name="&lt;p>Paragraphe&lt;/p>" value="&lt;P>" />
<paragraph name="SillyTag" value="&lt;SillyTag>" />
<paragraph name="&lt;H1>Heading 1&lt;/H1>" value="&lt;H1>" />
<paragraph name="&lt;H2 style='font-family: Trebuchet MS;'>Heading 2&lt;/H2>" value="&lt;H2 style='font-family: Trebuchet MS;'>" />
<paragraph name="&lt;H3 class='serif'>Heading 3&lt;/H3>" value="&lt;H3 class='serif'>" />
</paragraphs>

When I select text, and then choose the formatting, everything works fine ... except for the P :-/ If I choose "SillyTag", I got : <sillytag>some text </sillytag>. Why does the P tag have a peculiar behavior ? How can I surround the selected text with a P tag ?

I succeded having text surrounded by a P tag, but for that I select the text, choose H1, than choose P :-/

Thanks in advance for the answer.

9 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 07 Aug 2009, 01:08 PM
Hi Laurent,

You are correct that - for historical reasons - the P tag command would get special treatment in IE.
We have recognized that this is not necessary anymore as it creates inconsistent behavior across browsers, and that the behavior would be better to change.

The next Internal Build will feature this change, and the coming Q2 2009 SP1 to be released later in August will have the change integrated into the editor officially as well.


Sincerely yours,
Tervel
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.
0
Laurent
Top achievements
Rank 1
answered on 11 Sep 2009, 09:33 AM
Hi,

We have installed the lastest version of ASP.Net Controls (2009 Q2 SP1), and we still have the problem.

We checked the online demo and there is the problem there too.

What's the status about that issue ?
0
Kara Eser
Top achievements
Rank 1
answered on 15 Sep 2009, 01:56 PM
yes, I have also  this problem . Are there any solve method?
0
Rumen
Telerik team
answered on 16 Sep 2009, 01:31 PM
Hi guys,

RadEditor uses the InsertParagraph execCommand implementation of the browser to insert a new paragraph. You can customize this tool by overriding the browser command and make it work as per your requirements. You can use the following code as a base for your implementation:

<script type="text/javascript">  
function OnClientCommandExecuting(editor, args)  
{  
   //The command name  
   var commandName = args.get_commandName();   
   if ("InsertParagraph" == commandName)  
   {  
       if ($telerik.isIE) 
       { 
           var range = editor.get_document().selection.createRange();  
           if (range.pasteHTML)  
           {  
                range.pasteHTML("<p>");  
                range.select();  
                range.moveEnd("character", 1);  
                range.moveStart("character", 1);  
                range.collapse(false);  
           }  
           args.set_cancel(true);  
       } 
   }  
}  
</script>  
<telerik:radeditor runat="server" OnClientCommandExecuting="OnClientCommandExecuting" ID="RadEditor1"> </telerik:radeditor>  

Laurent: You cannot define a FormatBlock tool item like this

  <paragraph name="SillyTag" value="&lt;SillyTag>" />

because the SillyTag is not valid HTML element.

To apply a paragraph use the following syntax to define a paragraph item in the FormatBlock tool:

    <paragraph name="&lt;p>Paragraphe&lt;/p>" value="&lt;P style='color:black;'>" />

Please, note that the FixEnclosingP filter is enabled by default and you should turn it off - in other case the editor will remove a paragraph if the whole content is inside it. More information is available here.

Kind regards,
Rumen
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.
0
Laurent
Top achievements
Rank 1
answered on 16 Sep 2009, 02:00 PM
Thank you for the answer, I will check this as soon as possible (I hope before friday).

For the sillyTag, as its name suggests, it was a stupid test to check if my syntax of the tool configuration was good. I could have tested with anything else ;-) I really was surprised that the "p" didn't work !

And in your sample, you add a style attribute on the p tag. Why ? Has it to be there for having the p tag working ?
0
Laurent
Top achievements
Rank 1
answered on 18 Sep 2009, 02:33 PM
Hi,

I tested the trick, and there still is a little problem. The InsertParagraph works fine now, except when the editor is empty. I click on the tool, type some text, and got this :

<p>&nbsp;</p>
some text

I'm not familiar with the TextRange, so if someone has an idea to solve this last issue :-)
0
Rumen
Telerik team
answered on 21 Sep 2009, 11:13 AM
Hi Laurent,

The provided code for overriding the InsertParagraph command was just a basic example and we do not support it. If you cannot modify it to fully achieve your scenario then you can hide this tool and set the RadEditor's NewLineBr property to "false", e.g.

<telerik:radeditor runat="server" NewLineBr="false" ID="RadEditor1"></telerik:radeditor> 

Therefore the editor will wrap the content in P tags when the Enter key is pressed.

As to the FormatBlock tool: You can define a P tag item without a class attribute and it should work without problems too: <paragraph name="&lt;p>Paragraphe&lt;/p>" value="&lt;P>" />
Please, see the attached video for more information.

All the best,
Rumen
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.
0
Devin
Top achievements
Rank 1
answered on 02 Feb 2010, 10:57 PM
Hi Rumen,
I tried this and it works in FireFox but not Google Chrome.  FireFox gives me this:

<p>test</p>
<p>test</p>
<p>test</p>

But Chrome gives me this:

test
<div>test</div>
<div>test</div>

Can you please advise?

Thanks,
Devin
0
Rumen
Telerik team
answered on 05 Feb 2010, 03:00 PM
Hi Devin,

For the time being the NewLineBr property works only in IE and Firefox.
One of our main goals for the Q1 2010 release is enhance the editor to produce 100% identical output in all browsers. The release is scheduled for March' 2010.

Best wishes,
Rumen
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Editor
Asked by
Laurent
Top achievements
Rank 1
Answers by
Tervel
Telerik team
Laurent
Top achievements
Rank 1
Kara Eser
Top achievements
Rank 1
Rumen
Telerik team
Devin
Top achievements
Rank 1
Share this question
or