Basically they hide your textarea and place an iframe as an editor field. They capture your input (text + formating) and write the corresponding HTML into the iframe. If you submit your form including the original textarea they copy the content of the iframe into the textarea and therefore the html code gets submitted.
Well, this is quite simplified.