I've built a smaller function just like that, with contenteditable.
I used a hidden input field to store the html code in.
The editor is a div like this:
<div id="editor" contenteditable="true">
<!-- page to edit goes here -->
</div>
And with an hidden input:
<form name="storeForm">
<input type="hidden" name="store">
</form>
When the user presses the save button, I execute a javascript looking like this:
function store() {
document.storeForm.store.value = document.getElementById('editor').innerHTML;
}
This one passes the html code of the edited page in the hidden form field, then I store this in my mySQL database.
~monAmour