Frodik
Frodik

Reputation: 15455

How to make Google Chrome to stop automatically modify contenteditable elements HTML source?

I am using contenteditable attribute for a purpose of my own WYSIWYG editor. Most of the problems I solved myself, however one I can't figure out.

Contenteditable is acting little weird, because my editor generates XHTML code and as soon as I insert this code in contenteditable element, it modifies it to non-XHTML code, e.g.:

<h1>headline</h1><br />some text

modifies to:

<H1>headline</H1><BR>some text

There are more changes made by browser (I am using Google Chrome 7), but I think this example is good enough.

Is there a way how to change behaviour of contenteditable in Chrome, either not to touch the inserted code or to turn on "XHTML mode" ?

Upvotes: 0

Views: 864

Answers (2)

AlfonsoML
AlfonsoML

Reputation: 12690

Webkit is quite crappy with regards to the way that it handles contentEditable, you'll have to write a lot of code just for it.

You can look at the code existing in other editors like CKEditor and TinyMCE to see how nasty it can get.

Upvotes: 1

Quentin
Quentin

Reputation: 943568

Serving the document with a content-type of application/xhtml+xml should turn on XML mode.

Upvotes: 0

Related Questions