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

pastehtml and comments

1 Answer 45 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Brad McBride
Top achievements
Rank 1
Brad McBride asked on 26 Oct 2010, 07:50 PM
I am working with the editor control and I am providing a few buttons that will allow the user to insert some pre-defined HTML content. This is easy enough to do using the pasteHtml method but it isn't pasting all of the HTML text I'm passing into it. There are some comments I've added to these snippets so that I can tell if the code was auto-inserted in case there are issues in the future and troubleshooting needs to be done on the pages the editor is generating. I have noticed that if I am in HTML view that the comment is pasted as expected but not when I am in Design view. The people who use this tool know little/nothing about editing raw HTML so I cannot count on them to use the HTML view to insert comments (in fact we are considering disabling editing in HTML view per the KB article).

For example, we have lists that contains a fairly standard sets of bullet points that the users would like to just click a button to insert into a document. I would like to insert something like this:

<!-- Below UL Auto Inserted -->
<UL>
<LI>Item 1</LI>
<LI>Item 2</LI>
<LI>Item 3</LI>
</UL>
<!-- Above UL Auto Inserted -->

It will get pasted into the editor widow with the following HTML
<p>&nbsp;</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<p style="text-align: left;" class="style20"><!-- Above UL Auto Inserted --></p>

As you can see, the second comment is included in the pasted HTML but the opening comment is not. Additionally, the editor has inserted a <p> around the second comment and has inherited the styles of the paragraph where the cursor was located when the paste opperation was completed. Is there a workaround for this so that the opening comment will be pasted into the window and a way to prevent the paragraph from being placed around the second one?

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 28 Oct 2010, 04:39 PM
Hi Brad,

We are aware of this problem and are working on fixing it. To avoid this problem you the content of RadEditor should not start with a comment tag, a simple &nbsp is enough, e.g:
<telerik:RadEditor ID="RadEditor1" runat="server">
</telerik:RadEditor>
 
<asp:Button ID="Button1" runat="server" Text="Paste HTML" OnClientClick="doSomething(); return false;" />
<script type="text/javascript">
    function doSomething()
    {
        var content = " <!-- Below UL Auto Inserted -->"
                    + "<UL>"
                    + "<LI>Item 1</LI>"
                    + "<LI>Item 2</LI>"
                    + "<LI>Item 3</LI>"
                    + "</UL>"
                     + "<!-- Above UL Auto Inserted -->";
 
 
        $find("<%= RadEditor1.ClientID %>").pasteHtml(content);
    }
</script>


Sincerely yours,
Dobromir
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
Tags
Editor
Asked by
Brad McBride
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or