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

Getting Line of Text RadEditor

2 Answers 50 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 2
Alex asked on 05 Apr 2010, 03:11 PM
I have a radEditor on a web page. Unfortunately, the way the text is saved and interpreted by another site (beyond my control), requires a css class to control each of the the bullet types. So what I have done is created a custom function every time the ordered and unordered lists are created. The problem now is, when I hit the bullet button twice, it no longer takes away the list item, it adds another list.

            Telerik.Web.UI.Editor.CommandList["InsertUnorderedList"] = function(commandName, editor, args) { 
                var selection = editor.getSelection(); 
                var selectedHTML = selection.getHtml(); 
 
                editor.pasteHtml("<ul class=ulolProdDesc><li>" + selectedHTML + "</li></ul>"); 
            } 


Is there any way to grab the line of text the cursor is on when you hit the button on the tool bar? Or is there a better way to do this (maybe like limiting the amount of list items a list can have?). When I try to use createRestorePoint() I get an undefined error, even though I'm not sure I can use it anyway. Thanks for the help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 06 Apr 2010, 12:42 PM
Hi Alex,

There is a better way to achieve your scenario and it is to set this class to the <ol> and <ul> tags when submitting the RadEditor's content. Here is an example:

<telerik:RadEditor ID="RadEditor1" Runat="server" OnClientSubmit="OnClientSubmit">
     <Content>
     <ul>
         <li>asdasd </li>
         <li>dsa </li>
         <li>das </li>
         <li>das </li>
         <li>das </li>
     </ul>
     </Content>
 </telerik:RadEditor>
  
 <script type="text/javascript">
 function OnClientSubmit(editor)
 {
     var unorderedLists = editor.get_document().getElementsByTagName("UL");
     for (i = 0; i < unorderedLists.length; i++) {
         var unorderedList = unorderedLists[i];
         unorderedList.className = "ulolProdDesc";
     }
 }
 </script>
 
 <asp:Button ID="Button1" runat="server" Text="Submit" />

Do the same for the OL tags.

All the best,
Rumen
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.
0
Alex
Top achievements
Rank 2
answered on 06 Apr 2010, 02:32 PM
it makes sense to do it that way, thanks
Tags
Editor
Asked by
Alex
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Alex
Top achievements
Rank 2
Share this question
or