Changing the html for the editable div will directly cause problems - when you save, you wonβt be able to tell the difference between the change made by the user and what is done using the highlight script.
However, you can force the user to edit a simple text element, making it look like editing the selected element. Add a second div on top of your editable div with an event-pointer-style: none and a transparent background. As long as both elements have the same font size, you will edit the plain text version, but see the colors from the selected version.
If the font size is fixed, you can go ahead and use the text box instead of the editable div. I used this approach to get an syntax highlighting editor running on an iPad that does not support inline HTML editing.
source share