javascript - Copy Excel table data to TinyMCE editor -


i'm using tinymce editor allow users create content articles. allows users copy , paste excel , word content editor.

when copy excel table editor, header row treated div element. noticed header rows td has <b>. when remove <b> tag header row works expected. sample content follows:

<table>  <tr>     <b> <td></td></b>     <b> <td></td></b>     <b> <td></td></b>     <b> <td></td></b>  </tr>  <tr>      <td></td>      <td></td>      <td></td>      <td></td>             </tr>  <tr>     <td></td>     <td></td>     <td></td>     <td></td>  </tr> </table>  

sample table i'm coping excel

table i'm coping excel

output in editor

enter image description here

editor configuration follows:

paste_retain_style_properties: "all", paste_strip_class_attributes: "none", extended_valid_elements: "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],table[style|class|border=2|width|cellspacing|cellpadding|bgcolor],colgroup,col[style|width],tbody,tr[style|class],td[style|class|colspan|rowspan|width|height],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", 

any idea header row editor or proper way extract <table> tag , remove <b> tags content?

i'm not sure meant "extract <table> tag", remove <b> configure paste_preprocess option paste plugin. should job:

paste_preprocess: function(plugin, args) {  console.log(args.content); // content  args.content = args.content.replace(/<b>\s*<td>([^td]+)<\/td>\s*<\/b>/gmi, "<td>$1</td>"); } 

https://www.tinymce.com/docs/plugins/paste/#paste_preprocess