The FCKeditorAPI should keep working after changing from design to source mode. If you try to keep a reference to the document that won't work, but the API should give you always a reference to the current element.
Thanks Alfonso, I was indeed storing a reference as a property of my controller. Recreating the reference each time it is used has simplified the problem but not erradicated it.
I make the reference like this:
var editor = FCKeditorAPI.GetInstance('myEditor'); var ammendedHTML = editor.EditorDocument.body.innerHTML;
in the save button's Execute method.
When the editor is in design mode this works fine but when it is in html mode it produces a "editor.EditorDocument has no properties" error on the second line. This occurs only in html mode - when I was storing the reference this would occur even if the editor had been switched to html mode and then back to design mode.
My mistake was using "editor.EditorDocument.body.innerHTML" while the editor is in source mode rather than using the GetHTML() , GetXHTML() , SetHTML() methods. In source mode it seems that the reference returned by FCKeditorAPI.GetInstance('myEditor'); no longer has the EditorDocument property.
I thought I had got the snippet using innerHTML from the faq but no matter :p
So in short use the Get/SetHTML() methods, dont set and read the innerHTML.
Now the EditorDocument is destroyed when switching to source mode, but previously if you did use its innerHTML it would only seem to work, because in fact you were reading the innerHTML of an object that it isn't on the screen, so you lose all the changes done while in source mode.
The correct way to work is to use the GetXHTML (GetHTML is just an alias for backward compatibility)
Ah ok that makes sense. Thanks for the clarification.
Everything is working nicely in FF now but I have an (obligatry) IE(only tested in ie6) bug. If the editor is in source mode I cant set the contents with SetHTML (works fine in design mode).
I'll keep looking and reply to myself if i find something - is that bad form?
That reference in the Wiki is just a bug in Firefox, and it shouldn't be related at all to any problem that you might experience with IE.
I've tested with the sample 8 and I don't have any problem to get or set the contents in source mode.
But doing "editor.EditMode = 0;" might lead to problems, I'm not sure but it doesn't seems right to me, after all you are just flipping a variable stating the current mode of the editor instead of really forcing a change of editing mode.
RE: Further API object issue
RE: Further API object issue
I make the reference like this:
var editor = FCKeditorAPI.GetInstance('myEditor');
var ammendedHTML = editor.EditorDocument.body.innerHTML;
in the save button's Execute method.
When the editor is in design mode this works fine but when it is in html mode it produces a "editor.EditorDocument has no properties" error on the second line. This occurs only in html mode - when I was storing the reference this would occur even if the editor had been switched to html mode and then back to design mode.
Ho hum - I will post back if i figure it out.
Tromm
RE: Further API object issue
just a note to report my solution.
My mistake was using "editor.EditorDocument.body.innerHTML" while the editor is in source mode rather than using the GetHTML() , GetXHTML() , SetHTML() methods. In source mode it seems that the reference returned by FCKeditorAPI.GetInstance('myEditor'); no longer has the EditorDocument property.
I thought I had got the snippet using innerHTML from the faq but no matter :p
So in short use the Get/SetHTML() methods, dont set and read the innerHTML.
Tromm
RE: Further API object issue
Now the EditorDocument is destroyed when switching to source mode, but previously if you did use its innerHTML it would only seem to work, because in fact you were reading the innerHTML of an object that it isn't on the screen, so you lose all the changes done while in source mode.
The correct way to work is to use the GetXHTML (GetHTML is just an alias for backward compatibility)
RE: Further API object issue
Everything is working nicely in FF now but I have an (obligatry) IE(only tested in ie6) bug. If the editor is in source mode I cant set the contents with SetHTML (works fine in design mode).
I'll keep looking and reply to myself if i find something - is that bad form?
RE: Further API object issue
http://wiki.fckeditor.net/Troubleshooti ... ab9d551417
RE: Further API object issue
I've tested with the sample 8 and I don't have any problem to get or set the contents in source mode.
But doing "editor.EditMode = 0;" might lead to problems, I'm not sure but it doesn't seems right to me, after all you are just flipping a variable stating the current mode of the editor instead of really forcing a change of editing mode.