views:

412

answers:

1

I am developing a plug-in for CKEditor that needs to make some changes to the editor's content immediately before saving. In FCKeditor, I achieved this using the OnAfterLinkedFieldUpdate event but I haven't yet been able to find an equivalent way of doing this in CKEditor. I had hoped there would be a suitable event to hook into but there doesn't appear to be. Does anyone know of a way of doing this?

+5  A: 

You could use the getData event, but be careful because it's fired also for internal uses.

I've filed http://dev.fckeditor.net/ticket/5254 to recreate the previous event

AlfonsoML
In conjunction with creating my own handler for the submit event of the form?
Tim Down
That would be an alternate solution. In fact, that's the one that I would chose at the moment because it can be easier to handle it correctly until a proper event is generated by CKEditor (I don't really know what you want to do, so I'm guessing that it must be something complex that must be done only after updating the textarea)
AlfonsoML
My plug-in allows a user to embed pieces of content that are stored on a different server to the main HTML content. These are represented in the editor content as placeholder images to prevent them being edited in CKEditor. Immediately before the editor saves I want to replace these placeholder images with the HTML content they represent, and when the editor loads I want convert the special HTML into placeholders (which I can do with existing events). Perhaps there's another approach I should be taking?
Tim Down
Yes, in that case you should add your processing in a similar way to the handling of anchors or object tags: you would also want to show the HTML if they press the source button (but I guess that you might have removed that button so this isn't an issue for you).Unfortunately, I don't remember right now of a good sample about how to do that processing (FCKeditor had one such sample)
AlfonsoML
Thanks, you've been very helpful. Actually I'd probably prefer not to have it editable in source mode but I seem to remember seeing events for switching modes in CKEditor so it should be no problem.
Tim Down