Sorry for the late reply. I didn't use the method which Jake has used.
Instead, I had a computed text in which I created a text area which is used to
display the HTML editor. I also created a hidden html text field with the same
name as the text area. Now while submitting I use editor.getHTML() and get the
html behind the text area and copy the value to the hidden field. So when I
save the document, html is saved in the hidden field.