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

<br> tag added before with pasteHtml in chrome

3 Answers 90 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Anil
Top achievements
Rank 1
Anil asked on 02 Feb 2015, 10:34 PM
Hi,

When adding content using pasteHtml method, it's adding <br> tag before the text in chrome browser due to which an extra line is appearing. This issue can also be reproduced using existing tool e.g. "Insert Time". The issue will be gone when you switch between HTML view and Design view. Check this screen cast: http://screencast.com/t/liOx9ryeIp1 

Any work-around to fix this issue?

I'm using "ASP.NET AJAX Q2 2014" (2014.2.724.40) version.

Also I'm disabling ConvertToXhtml, ConvertCharactersToEntities, ConvertFontToSpan, and RemoveScripts filters. And NewLineMode = EditorNewLineModes.Div.

Thanks,
Anil

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 05 Feb 2015, 12:18 PM

Hi Anil,

Can you reproduce this with our online demos, e.g., here or here?

I also tried with the following code:

<telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
<asp:Button ID="Button1" Text="paste programmatically" OnClientClick="pasteProgrammatically(); return false;" runat="server" />
<script>
    function pasteProgrammatically() {
        var editor = $find("<%=RadEditor1.ClientID%>");
        var currTime = new Date();
        editor.pasteHtml(currTime.toString());
    }
</script>

protected void Page_Load(object sender, EventArgs e)
{
    RadEditor1.DisableFilter(EditorFilters.ConvertCharactersToEntities);
    RadEditor1.DisableFilter(EditorFilters.ConvertToXhtml);
    RadEditor1.DisableFilter(EditorFilters.ConvertFontToSpan);
    RadEditor1.DisableFilter(EditorFilters.RemoveScripts);
    RadEditor1.NewLineMode=EditorNewLineModes.Div;
}

and things seemed to work fine for me (I am attaching here a short video as a reference.

What I can advise at this point is the following:

  1. upgrade to the latest version to see if this helps
  2. remove customizations you have on the editor one by one until you find the culprit
  3. consider using the OnCLientPasteHtml event to remove a leading <br> tag. Here is a basic example that you can use as base and tweak further according to your concrete case
    <telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml"></telerik:RadEditor>
    <asp:Button ID="Button1" Text="paste programmatically" OnClientClick="pasteProgrammatically(); return false;" runat="server" />
    <script>
        function pasteProgrammatically() {
            var editor = $find("<%=RadEditor1.ClientID%>");
            var currTime = new Date();
            editor.pasteHtml("<br>" + currTime.toString());
        }
         
        function OnClientPasteHtml(sender, args) {
            if ($telerik.isChrome) {
                alert("we are about to fix some content for Chrome");
                var currText = args.get_value();
                if (currText.indexOf("<br>") == 0) {
                    currText = currText.substring(4);
                }
                args.set_value(currText);
            }
        }
    </script>


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Anil
Top achievements
Rank 1
answered on 05 Feb 2015, 06:07 PM

Thanks Marin for your reply.

I cannot test exact scenario on the online demos that you have pointed out because you cannot disable filters in this demo and you cannot change the new line mode in this demo.

As per the video that you have attached, looks like you’re inserting in the same line. This scenario works fine for me too. I’m seeing this issue when inserting in new line. Check the scenario in this screen cast. So here are the steps to reproduce:

1. Click on insert time
2. Hit enter key to move to next line
3. Click on insert time again.

I have also tested by removing customization one by one and looks like ConvertToXhtml is creating the issue. When I enable this filter, its working correctly.

Also using OnCLientPasteHtml event doesn’t help as well because args.get_value() doesn’t have <br> added. Looks like its getting added ONLY when inserting (displaying) text into the editor.

Thanks
Anil

0
Marin Bratanov
Telerik team
answered on 10 Feb 2015, 09:44 AM

Hi Anil,

Can you confirm which is the version of the controls you are using and whether the problem persists in the latest one (Q1 2015 beta at the time of writing)? I am asking because this seems to work fine for me, I only get an nbsp which is expected in this case since a new element (div) was created and to get the cursor (selection) in it, there must be some content. I am attaching here a short video that shows the behavior on my end even when pressing Enter.

Also, we generally recommend that you do not disable the ConvertToXhtml filter, as it improves the content greatly. It should be disabled in highly specific scenarios, e.g., when you need to use custom (invalid in XHTML) tags.

If you cannot enable the ConvertToXhtml filter for some reason and you can reproduce this behavior with our latest version on a simple, runnable page, I advise that you open a support ticket and send it to us, so we can investigate the case.

Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Editor
Asked by
Anil
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Anil
Top achievements
Rank 1
Share this question
or