5 ms·
Unfortunately this approach also introduces new classes of bugs, when the browser's editing facilities collide with those provided by the component. For example
by ridiculous_fish 11y ago
Unfortunately this approach also introduces new classes of bugs, when the browser's editing facilities collide with those provided by the component. For example, on OS X, type any letter and then choose Edit->Undo; nothing will happen. This sort of thing is generally impossible to fix since there's no undo event in HTML.
- danabramov 11y agoI just tried that in http://facebook.github.io/draft-js/ http://facebook.github.io/draft-js/, and Edit -> Undo worked for me.
- ridiculous_fish 11y agoHmm, what were your steps where it worked? Undo and other text editing facilities aren't completely nonfunctional, they just become broken and unpredictable. For example, these steps: 1. Load http://facebook.github.io/draft-js/ http://facebook.github.io/draft-js/ 2. Click in the text box 3. Type 'hello' on the keyboard 4. Using the mouse, choose Edit -> Undo The text box will show "h" instead of being empty. Do you see this too? Note that cmd-Z won't reproduce this since the page tries to handle that itself to work around these bugs.
- danabramov 11y agoGood catch. Maybe worth filing an issue?
- the_mitsuhiko 11y agoAgainst what? Html5? ;)
- Reinmar 11y agoWell... yes :D [1] (AFAIR this case is covered by [2]). The Editing Task Force is working on opening necessary APIs so editor implementors could integrate with all the native features. I wrote an article about the effort [3]. It's a bit outdated now, but explains what are the goals. [1] https://github.com/w3c/editing/issues https://github.com/w3c/editing/issues [2] https://github.com/w3c/editing/issues/79 https://github.com/w3c/editing/issues/79 [3] https://medium.com/content-uneditable/fixing-contenteditable-1a9a5073c35d https://medium.com/content-uneditable/fixing-contenteditable...
- eloisant 11y agoIt surely does, because it's a crucial feature for a text editor, but the developers had to implement and undo/redo stack in their lib. Anyway this approach is the only good one if you don't want to produce crappy HTML that will end up on your site. TinyMCE and the rest are obsolete, and editors like DraftJS or mobiledoc-kit are the only viable solutions until browsers offer a new, not broken alternative to content-editable.
- underwater 11y agoYes, you're right. No solution is perfect. I was involved in a project that used contentEditable DOM as the source of truth before I had a chance to work with Draft, and I believe that Draft's model is the best compromise. Draft does a lot to handle the edge cases where it's possible. IME and spellcheck are two of the big ones.