5 ms·
I find it sad (to annoying) that these projects still use actual form elements instead of `contenteditable`, even though they're quite obviously full-JS (and pr
by masklinn 14y ago
I find it sad (to annoying) that these projects still use actual form elements instead of `contenteditable`, even though they're quite obviously full-JS (and probably not going to be submitted through HTML forms), given the difficulty of correctly styling, integrating and interacting with form elements.
The web is in dire need of a library correctly reimplementing "form behaviors" (events, mostly) on top of contenteditable, and allowing those behaviors to be applied to arbitrary (to the extent that browser implementations allow) elements on the fly.
edit: just in case, don't take me wrong, HTML forms should stay and I'm an advocate of less javascript everywhere as it tends to be mandated in places where it has no reason to be (and to ultimately decrease usability rather than enhance it), but if you're going to do "edit in place" and rich web applications which require javascript to run — and using the library linked above would probably qualify as you can't do anything without JS enabled and a fairly recent browser running it. And in those cases, HTML form elements tend to be a hindrance more than a help.
- laktek 14y agoHave you seen Aloha Editor(http://aloha-editor.org http://aloha-editor.org)? Its behavior is built on `contenteditable`.
- gidan 14y agoAloha editor is 1MB in size..
- masklinn 14y agoAloha is an RTE, I'm not talking about RTEs in my comment I'm talking about bare, basic fields. Such as the one I'm typing/editing this comment in.
- laktek 14y agoAloha is not a traditional WYISWYG editor contained in a textarea. You can apply it to any HTML element in a page, which would turn them in to editables (check this example of math editing - http://wysiwhat.github.com/Aloha-Editor/cnx.html http://wysiwhat.github.com/Aloha-Editor/cnx.html)
- scribu 14y agoDoesn't work in Firefox. OT: Am I the only one annoyed by this "viewed best in Chrome" trend? Reminds me of those old "Best in IE" badges.
- fredsted 14y agoWorks fine in Firefox 17, try updating your browser.
- Surio 14y agoNo, you are not alone. And I am sad to miffed at lack of support for Opera too. There was a jquery fundamentals website that had the same problem. To compound matters, Chrome font rendering is godawfully bad on my machine.
- masklinn 14y ago> Aloha is not a traditional WYISWYG editor contained in a textarea. Did you miss the part where I said I wasn't talking about RTE? I don't care that it's implemented using something which was introduced to build RTEs in the first place and has been used for exactly that for the past 12 years or so (which does happen to make contenteditable-based RTEs traditional, as are designMode-based ones, despite your apparent assertion to the contrary), my original comment is not about rich text edition.
- fox91 14y agoI really love Hallo.js http://hallojs.org/ http://hallojs.org/ It's based on contenteditable and it's very lightweight
- deleted 14y ago[deleted]
- ot 14y agoI don't see why contenteditable should be better than form elements. contenteditable is meant for formatted text, not plain text entry. For example, if you cut&paste formatted text into a contenteditable, it will keep the formatting [1]. Then you have to intercept the paste event and sanitize the text. Also, the selection model is a mess and slightly incompatible among browsers (although this might be fixed in modern browsers, I haven't looked into it for a while). What are the benefits of contenteditable that justify to go into all this trouble? [1] http://stackoverflow.com/questions/3306205/how-to-avoid-webkit-contenteditable-copy-paste-resulting-in-unwanted-css http://stackoverflow.com/questions/3306205/how-to-avoid-webk...
- masklinn 14y ago> contenteditable is meant for formatted text, not plain text entry. contenteditable is meant for editing content, what kind of content you edit with it is up to you. > What are the benefits of contenteditable that justify to go into all this trouble? Coherent and simple styling and integration, avoidance of reflow (especially when toggling between editable and non-editable)
- jazzduck 14y agoAs a developer, why the hell do I need stylized text when I'm having a user fill out, say, a shipping form? Why should I have to worry about whether someone applied italics to their zip code? Should I really have to try to make the thermal label printer print out Zapf Dingbats if someone pastes that in there? Also, forms go far beyond text input. Are you seriously suggesting that dropdown menus, multi-select boxes, sliders, radio buttons, datepickers, etc. should all be reimplemented on top of a rich text element?
- csulok 14y ago>> I find it sad (to annoying) that these projects still use actual form elements instead of `contenteditable`, even though they're quite obviously full-JS (and probably not going to be submitted through HTML forms), given the difficulty of correctly styling, integrating and interacting with form elements. I think this is because of performance. form elements are rendered differently and actions mostly result in a limited repaint and a couple events fired. contenteditable DOM elements are a lot more work to update.
- masklinn 14y agoI'm not sure about this hypothesis, when making a field editable requires inserting a bunch of dom nodes and trying to position your brand new input at the right place, it should be way more repaint that the NOOP of adding an attribute to the element.
- waskosky 14y agoPerhaps the main issue lies with the relative inability to detect the presence of support: https://github.com/Modernizr/Modernizr/wiki/Undetectables https://github.com/Modernizr/Modernizr/wiki/Undetectables Android Gingerbread devices do not support it, and they are still the largest percentage of Android devices accessing Google Play: http://developer.android.com/about/dashboards/index.html http://developer.android.com/about/dashboards/index.html So it seems that a user agent detection and fallback for Android < 3.0 devices is still a great necessity, and it is difficult to say just how many other devices fall into this category. This next link is the most comprehensive list of support I could find, and although the support does seem widespread at this point, there are probably still too many user agent unknowns for someone wanting to make a mobile friendly library around the feature: http://caniuse.com/#feat=contenteditable http://caniuse.com/#feat=contenteditable