- Code: Select all
if(evt.keyCode==13 && !evt.shiftKey) //RETURN key
{
//cleanup <br><br> between paragraphs
nodes=editor().childNodes;
for(var x=0;x<nodes.length;x++)
{
if(nodes.item(x).nodeName.toLowerCase()=="br") editor().removeChild(nodes.item(x));
}
}
this works pretty well, but browser do not check all nodes.
- Code: Select all
if(evt.keyCode==13 && !evt.shiftKey) //RETURN key
{
//cleanup <br><br> between paragraphs
nodes=editor().childNodes;
ifbr=getSelectedContainer().previousSibling.previousSibling;
if(ifbr.nodeName.toLowerCase()=="br") editor.removeChild(ifbr);
}
also the function getCleanHTML(), it counts every char in edited text!!!..., it can be done in other way, using getSelectedContainer().innerHTML(getSelectedContainer().innerHTML=getCleanHTML(getSelectedContainer().innerHTML)), i.e. lets suppose that all changes were made in current container. Of course there are problem after pasting text, i think that only way to solve it is using str.replace method, but this is not DOM ideology:(
hope this will help to make wym better:)