[kupu-dev] kupu error when I try to insert some custom code
Jordi Martinez
jordim at guellconsulting.com
Wed Oct 22 13:30:59 CEST 2008
Jordi Martinez escribió:
> Hi!
> I create a kupu tool with this code:
>
> function FoneticaTool() {
> this.initialize = function(editor) {
> this.editor = editor;
> this.editor.logMessage(_('Fonetica tool initialized'));
> };
>
> this.createFonetica = function(texte) {
> var sel = this.editor.getSelection();
> var tnode = this.editor.getInnerDocument().createTextNode(texte);
> sel.replaceWithNode(tnode, true);
>
> this.editor.logMessage(_('Fonetica inserted'));
> this.editor.updateState();
> this.editor.focusDocument();
> return tnode;
> };
> }
>
> FoneticaTool.prototype = new KupuTool;
>
> I add all the needed stuff in their places and all works ok except the
> createFonetica function
>
> The error line is
>
> sel.replaceWithNode(tnode, true);
>
> and the error is
>
> uncaught exception: [Exception... "Component returned failure code:
> 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsISelection.getRangeAt]"
> nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame ::
> http://192.168.1.38:8110/esadir/kupuhelpers.js :: anonymous :: line
> 443" data: no]
>
> Line 0
>
> If I try to see the texte content (with an alert, for instance) the
> content is ok
>
> Anyone has any clue with this problem?
>
> To Guido: I copy this code from a mail sended by you trying to help me
>
> Thanks!
> _______________________________________________
> kupu-dev mailing list
> kupu-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/kupu-dev
>
>
Some new clues:
With IE6 this code works better that with Mozilla (at least inserts
something)
If there are some selected text, the editor replaces the selected text
ok but if there aren't the editor put the insertion at the beginning of
the current node
With Mozilla only raises the exception and don't do anything more
What make me go crazy is that I copy the createFonetica code from the
ImageTool
In the image tool works perfect but in mine don't
Could you point me where the problem is?
Guido, please!
More information about the kupu-dev
mailing list