3 ms·
designMode is already implemented/used by a lot of rich text editors. Usually, they have an iframe with designMode turned on, capture the code generated and th
by tdonia 17y ago
designMode is already implemented/used by a lot of rich text editors. Usually, they have an iframe with designMode turned on, capture the code generated and then run a clean up process to fix inconsistencies. That said, it's no panacea - the current implementations are not consistent at all - the code generated in designMode by the rendering engine can become quite ugly pretty quickly. Hopefully with the HTML5 execution there will be a bit more attention and care for this as it is really useful and a core part of Tim Berners-Lee's original vision - every page, editable.
- axod 17y agodesignMode is absolutely horrible though. When you press enter in the edit box, some browsers add a <br> tag, some start a new <p> tag, etc etc. It's a complete mess. Also the API is ridiculous. editableDocument.execCommand("Bold", false, null); execCommand? seriously?
- olavk 17y agoI wrote an article for Opera about designMode and contentEditable: http://dev.opera.com/articles/view/rich-html-editing-in-the-browser-part-1/ http://dev.opera.com/articles/view/rich-html-editing-in-the-... You are right it is messy. The API as apparently modelled over the IOleCommandTarget which is a Microsoft API for document-toolbar integration. They probably never expected it to become a cross-platform standard.
- axod 17y agoThanks, useful article. I hope one day they standardize that stuff into a usable DOM API.
- euroclydon 17y agoYeah, I just assumed I was missing something. document.execCommand() has an invisible argument that is the selected rendered HTML???