[kupu-dev] kupu error when I try to insert some custom code

Guido Wesdorp johnny at johnnydebris.net
Sat Oct 25 12:22:26 CEST 2008


Jordi Martinez wrote:
>         var tnode = this.editor.getInnerDocument().createTextNode(texte);
>         sel.replaceWithNode(tnode, true);            
>   
I have the feeling replaceWithNode doesn't work well with text nodes... 
I wanted to try this out properly before responding, unfortunately I 
don't seem to find the time to do so, so no promises, just a guess... :|

You may want to try a work-around like this:

var doc = this.editor.getInnerDocument();
var tempnode = doc.createElement('span');
var tnode = doc.createTextNode(texte);
sel.replaceWithNode(tempnode, true);
tempnode.parentNode.replaceChild(tempnode, tnode);
sel.selectNodeContents(tnode);

Again, not sure if it works, but may be worth a try...

Cheers,

Guido


More information about the kupu-dev mailing list