top | item 41833820

Word-like HTML inline edit with design mode

19 points| knlam | 1 year ago |til.secretgeek.net

10 comments

order

treflop|1 year ago

This (and the contenteditable attribute) were added in Internet Explorer 5.5 to let you create WYSIWYG editors and it was later reverse engineered and replicated in other browsers.

It is still the basis for a lot of WYSIWYG editors, but it's not perfect and sometimes provides too little control (produces messy HTML), so sometimes people avoid it and build a WYSIWYG editor from scratch using something like <canvas> (e.g. Google Docs) but this is way more effort.

Some of the O.G. WYSIWYG editors (e.g. CKEditor) still use "contenteditable" but patch over all the problems with it.

tgv|1 year ago

Why add 'designMode'? AFAIK, setting 'contenteditable' suffices, and you can use it with more precision.

bkyan|1 year ago

How do you save your changes with this?

ricardo81|1 year ago

You could potentially use document.querySelector('html').outerHTML and POST it somewhere