Re:Wysiwtfftwomg
by 3pt14159 on Sunday October 20, 2013 @07:53PM
(#6582145)
This is why I'm so fucking angry at the state of contenteditable. It could have been awesome, but its a complete disaster. If you want anything good (say, autoembedding youtube videos) you essentially have to use text area and fake the whole thing. Like managing cursor state and switching elements.
[ Parent
| on HN ]
Contenteditable fails in many ways, but it's still something quite awesome and provides a good basis to build on. I built myself a wiki system because I find the current ones to be a huge pain to edit and I'm using contenteditable as the main tool. No need for separate editing pages, markup languages, or other nonsense - just click edit and make the changes immediately. I agree that contenteditable could have been way better, or in the very least more consistent between browsers.
At first I thought like you, until I started to deal with embed issues. For italics, bolding, and images, it works OK. Shitty to deal with handling some keyboard inputs, but not terrible. Beyond that, it is unmanageable though.
Yeah it's a nightmare, but you can wrangle it with enough work... try the demo here and see what you think: http://www.decalcms.com/tour/
It's good, but it lacks some features I want, like embeding youtube videos and allowing an arbitrary number of line breaks. But it is good and you should be very proud of it. I know how hard it is to make something this complex with contenteditable.
Hey, thanks for the kind words! You can actually embed snippets, just not in the short demo. If you put your email in at the end you get access to a more comprehensive demo that shows how image and object embedding work ... but disallowing arbitrary numbers if line breaks is actually a deliberate choice. One of the primary motivators is in making predictably formattted content so it's easier to repurpose into different contexts (eg. mobile devices or integrated into an application). Since hitting enter a bunch of times is usually a hacky way to fix a presentation issue that should be controlled with CSS we actually write code specifically to disable it.