PasteHTML issue

Last post 11-21-2011, 10:58 AM by syedrazi. 12 replies.
Sort Posts: Previous Next
  •  11-07-2011, 12:08 PM 71198

    PasteHTML issue

    I am using PasteHTML in javascript to insert a block of HTML code in to the editor that contains a table.
      
    This is the javascript code:
     
    var edtEmail = document.getElementById('<%= edtEmail.ClientID %>');
    edtEmail.ExecCommand('PasteHTML', false, arg.html);
    The problem is that if I insert another table, the html code gets inserted inside the last column of the first table just inserted instead of inserting the table in a new line.
     
    I tried different things, and adding a <br> after the first table seems to place the table in the right position, but the problem is that the second table doesn't display until I go to "preview" or "html" tab. Then if I come back to the Edit tab, it works fine.
     
    This is the additional line I added after the above 2 lines.
    edtEmail.ExecCommand('PasteHTML', false, "<br>");
     
     Is there a way to refresh the editor or force it to display the html? Also, any idea how to set the cursor position? Why doesn't PasteHTML work properly, and why does it seem to paste the second table in the wrong position? If I manually place the cursor somewhere, and use PasteHTML, it places the second table in the right place.
     
    Here is an example of the html code being inserted:
     
     
    <table style="border-width: 1px; border-style: solid; width: 100%; font-size: 10pt; border-collapse: collapse; table-layout: auto;">
    <tbody>
    <tr>
    <td rowspan="4"><img src="https://www.car-research.com/carinteractive/vimages/807/T11146A/329f6cda-5ef9-4137-8e64-4033eaaa0026.jpg" width="120" alt="" /></td>
    <td><strong>2006 FORD F150 Harley-Davidson</strong></td>
    <td>Exterior Color: Black - (Black)</td>
    <td style="font-size: large;" rowspan="4"><strong>$27,995.00</strong></td>
    </tr>
    <tr>
    <td>VIN: 1FTRX14526FA00778</td>
    <td>Interior Color: Black Leather</td>
    </tr>
    <tr>
    <td>Stock #: T11146A</td>
    <td>Engine: 5.4L</td>
    </tr>
    <tr>
    <td>Miles: 58636</td>
    <td>Transmission: Automatic</td>
    </tr>
    </tbody>
    </table>
     
     
  •  11-08-2011, 7:29 AM 71220 in reply to 71198

    Re: PasteHTML issue

    Hi syedrazi,
     
    Please try the example below. By default, the editor has a table in it. Then click the set table button will as another table. It works fine for me.
     
    <%@ Page Language="C#" %>

    <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>

    <body>
        <form id="form1" runat="server">
            <CE:Editor ID="editor1" runat="server">
            </CE:Editor>
            <input type="button" value="Set TAble" onclick="setTable()" />
        </form>
    </body>
    </html>

    <script>
    var myTable="<table><tr><td>test</td></tr></table>";
    function CuteEditor_OnInitialized(editor)
    {
        editor.ExecCommand('PasteHTML', false, myTable);
    }
    function setTable()
    {
       
       var editor1=document.getElementById("<%= editor1.ClientID %>");
       editor1.ExecCommand('PasteHTML', false, myTable);

    }
    </script>
     
    Regards,
     
    Ken
  •  11-08-2011, 3:16 PM 71233 in reply to 71220

    Re: PasteHTML issue

    Hi Ken
     
    Thanks for your reply.
     
    Actually on my end, I can easily reproduce the problem with the code you sent! If you press the "Set Table" button multiple times, the new tables start getting inserted inside the first ones after a couple of clicks.
     
    I modified your example a little bit to insert the table I'm inserting, and you can test it to see it keeps inserting within the table.
     
    If you place the cursor inside the first table, and then press "Set Table" button multiple times, you will see it keeps getting inserted inside the first table that was inserted.
     
    Actually, you don't even need the original table and the insert command does not have to be inside a table (the editor text can be blank), and the same thing still happens.
     
    Here is the code:
     
    1.     <input type="button" value="Set Table" onclick="setTable()" />  
    2.     <br />  
    3.     <CE:Editor ID="edtEmail" runat="server" Width="100%" Height="520px" AutoConfigure="Simple"  
    4.         ThemeType="Office2007" URLType="Absolute" EnableStripStyleTagsCodeInjection="False" />  
    5. </div>  
    6. <script type="text/javascript">  
    7.     var myTable = '<table bgcolor="#ffffff">' +  
    8.     '    <tbody>' +  
    9.     '        <tr>' +  
    10.     '            <td valign="top" align="center">' +  
    11.     '            <table border="0" cellspacing="0" cellpadding="0" width="600" bgcolor="#ffffff">' +  
    12.     '                <tbody>' +  
    13.     '                    <tr>' +  
    14.     '                        <td style="width: 608px; height: 19px;" align="center">' +  
    15.     '                        <div align="center">&nbsp;</div>' +  
    16.     '                        </td>' +  
    17.     '                    </tr>' +  
    18.     '                    <tr>' +  
    19.     '                        <td align="left"></td>' +  
    20.     '                    </tr>' +  
    21.     '                </tbody>' +  
    22.     '            </table>' +  
    23.     '        </tr>' +  
    24.     '    </tbody>' +  
    25.     '</table>';  
    26.   
    27.     var insertItem = '<table style="border-width: 1px; border-style: solid; width: 100%; font-size: 10pt;' +  
    28.     '   border-collapse: collapse; table-layout: auto;">' +  
    29.     '   <tbody>' +  
    30.     '       <tr>' +  
    31.     '           <td rowspan="4">' +  
    32.     '               <img src="https://www.car-research.com/carinteractive/vimages/79/C5181/06528ba2-a0fa-435e-819d-596bcfeb2859.jpg"' +  
    33.     '                   width="120" alt="" />' +  
    34.     '           </td>' +  
    35.     '           <td>' +  
    36.     '               <strong><a href="http://www.car-research.com/carinteractive/WebXRM/Vehicle/VehicleEBrochure.aspx?xdealerid=79&amp;stocknum=C5181"' +  
    37.     '                   target="_blank">2009 Mazda RX8 COUPE 4 DOOR </a></strong>' +  
    38.     '           </td>' +  
    39.     '            <td>' +  
    40.     '                Exterior Color: Velocity Red' +  
    41.     '            </td>' +  
    42.     '            <td style="font-size: large;" rowspan="4">' +  
    43.     '                <strong>$27,500.00</strong>' +  
    44.     '            </td>' +  
    45.     '        </tr>' +  
    46.     '        <tr>' +  
    47.     '            <td>' +  
    48.     '                VIN: JM1FE17P790401904' +  
    49.     '            </td>' +  
    50.     '            <td>' +  
    51.     '                Interior Color: Black Cloth' +  
    52.     '            </td>' +  
    53.     '        </tr>' +  
    54.     '        <tr>' +  
    55.     '            <td>' +  
    56.     '                Stock #: C5181' +  
    57.     '            </td>' +  
    58.     '            <td>' +  
    59.     '                Engine: Rotary engine' +  
    60.     '            </td>' +  
    61.     '        </tr>' +  
    62.     '        <tr>' +  
    63.     '            <td>' +  
    64.     '                Miles: 19' +  
    65.     '            </td>' +  
    66.     '            <td>' +  
    67.     '                Transmission:' +  
    68.     '            </td>' +  
    69.     '        </tr>' +  
    70.     '    </tbody>' +  
    71.     '</table>';  
    72.   
    73.     function CuteEditor_OnInitialized(editor) {  
    74.         editor.ExecCommand('PasteHTML'false, myTable);  
    75.     }  
    76.     function setTable() {  
    77.   
    78.         var editor1 = document.getElementById("<%= edtEmail.ClientID %>");  
    79.         editor1.ExecCommand('PasteHTML'false, insertItem);  
    80.   
    81.     }  
    82. </script>  
    Filed under: ,
  •  11-09-2011, 6:47 AM 71287 in reply to 71233

    Re: PasteHTML issue

    Hi syedrazi,
     
    I think you are using the old version. Can you download the latest version below and try again?
     
     http://www.cutesoft.net/downloads/folders/21904/download.aspx 
     
    Regards,
     
    Ken
  •  11-09-2011, 10:07 AM 71298 in reply to 71287

    Re: PasteHTML issue

    I just recently purchased CuteEditor, and I downloaded and started using it the first time was less than a month ago.
     
    The fileversion I'm using is CuteEditor 6.6 Build 2011-09-12. I upgraded it to the latest one from the link you provided above, and I still get the exact same problem.
     
    Did you try clicking your demo and clicked on the "Set Table" button several times? The first time is always okay, and the problem happens on the 3rd click. The cursor should always be placed after the table, and this should not happen.
     
     
  •  11-09-2011, 11:22 AM 71300 in reply to 71287

    Re: PasteHTML issue

    Is there a way to set cursor position in the Editor?
  •  11-10-2011, 6:46 AM 71312 in reply to 71300

    Re: PasteHTML issue

    Hi syedrazi,
     
    No, for now can't achieve it.
     
    Regards,
     
    Ken
  •  11-10-2011, 9:20 AM 71317 in reply to 71312

    Re: PasteHTML issue

    Ok, if we can't set the position, then please provide a fix for the table pasting issue.
     
    Were you able to reproduce it? Did you try clicking your demo and clicked on the "Set Table" button several times? The first time is always okay, and the problem happens on the 3rd or 4th click. The cursor should always be placed after the table, and this should not happen.
    Please advise.
     
  •  11-11-2011, 6:14 AM 71339 in reply to 71317

    Re: PasteHTML issue

    Hi syedrazi,
     
    I can not reporduce this issue on my demo page.
     
    Can you download the latest version and try again?
     
    Latest version downloads http://www.cutesoft.net/downloads/folders/21904/download.aspx
     
    Regards,
     
    Ken
  •  11-11-2011, 10:10 AM 71344 in reply to 71339

    Re: PasteHTML issue

    Hi Ken
     
    I already did, and I can still easily produce the problem. What can we do?
  •  11-14-2011, 2:11 PM 71376 in reply to 71339

    Re: PasteHTML issue

    Ken, I did update to the latest version of CuteEditor, but I can still produce the problem. Btw, I just realized that this only happens on Internet Explorer, and Chrome or Firefox seem to work just fine. I tried it on IE9.
    Filed under:
  •  11-15-2011, 6:12 AM 71385 in reply to 71376

    Re: PasteHTML issue

    HI syedrazi,
     
    Yes, I can reproduce this issue on IE9 too. I have reported this issue to the development team. Once issue is resolved, I will keep you posted.
     
     Regards,
     
    Ken
  •  11-21-2011, 10:58 AM 71561 in reply to 71385

    Re: PasteHTML issue

    Hi
     
    Any update on this? We have users complaining daily about this and we really need a resolution.
     
    Thanks
     
    -Razi
    Filed under:
View as RSS news feed in XML