Hi devs,
I'm trying to integrate the new WYSIWYG editor into XWiki's page editing
mechanism and I'm having an issue regarding how the edited content is
being submitted.
Right now (correct me if I'm wrong) when the user clicks "Save & View"
the
edit form is submitted having a "content" field filled with the result of
converting editor's HTML output to XWiki syntax. Two things should be
noted:
* the conversion takes place on the client side, in JavaScript code;
* the save action, on the server side, expects XWiki code, not (X)HTML.
In the case of the new WYSIWYG editor, converting the (X)HTML to XWiki on
the client side is out of discussion. I must use the new rendering module,
which is written in Java. In order to smoothly integrate the new editor I
have to make sure the save action gets the XWiki code it expects.
Asynchronously retrieving the result of the conversion before submitting
the edit form is tricky due to the fact that the user can click "Save &
View" before the response arrives.
In light of this, Sergiu suggested me the following 2 solutions:
A) Retrieve the conversion synchronously
This would be easy if GWT would allow it. Instead I'd have to write
error-prone code using timeout to wait for the response and then release
the form submit.
B) Use a servlet filter
I'd have to write a servlet filter that detects the save action,
determines the editor (wysiwyg, new_wysiwyg, wiki etc.) and the syntax of
the submitted content (XWiki by default, XHTML for the new editor) and
makes the conversion, if needed.
I prefer the second solution. WDYT?
Regards,
Marius