I paste this msword content to radeditor
Test de formulaire
Avec du rouge
Du bleu
Et du vert
User highlight Test de formulaire and click custom button with this code :var selection = String(editor.getSelectionHtml());
//selection = selection.replace("<q>", "");
//selection = selection.replace("</q>", "");
//selection = selection.replace("<Q>", "");
//selection = selection.replace("</Q>", "");
//Remove all custom tags before insert new custom tags
var html = editor.get_html(false);
html = html.replace("<q>", "");
html = html.replace("</q>", "");
html = html.replace("<Q>", "");
html = html.replace("</Q>", "");
var newhtml = html.replace(selectedText, '<q>' + selectedText + '</q>');
//var newhtml = html.replace(selection, '<q>' + selection + '</q>');
editor.set_html(newhtml);
//Set schedule text
var txtScheduleText = $find("<%=txtScheduleText.ClientID%>");
txtScheduleText.set_mode(4);
txtScheduleText.set_html(selection);
txtScheduleText.set_mode(4);
This code must replace selectedhtml text like this : <FONT size=3 face=calibri>Ceci est un test</FONT> by <q><FONT size=3 face=calibri>Ceci est un test</FONT></q>
The problem is that when i call var newhtml = html.replace(selection, '<q>' + selection + '</q>'); selection not exist in html because html look like this with msword special tag :
<FONT face=georgia>
<P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT size=3 face=calibri>Ceci est un test<?xml:namespace prefix = o /><o:p></o:p></FONT></P>
<P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT color=#ff0000 size=3 face=calibri>En rouge<o:p></o:p></FONT></P>
<P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT color=#00b0f0 size=3 face=calibri>En bleu<o:p></o:p></FONT></P>
<P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><FONT color=#00b050 size=3 face=calibri>En vert<o:p></o:p></FONT></P></FONT>
Do you have a valid solution to replace my html selection ?