Re: [editing] Use Cases (was: Leading with ContentEditable=Minimal)
Also check out Carota - a webbased editor with the ability to add complex elements (click the smiley) using the canvas element in order to get around the problems with contenteditable. http://earwicker.com/carota/ On Thu, Jul 3, 2014 at 11:33 AM, Johannes Wilm johan...@fiduswriter.org wrote: Do you mean browser developers or editor developers? Wouldn't this task force group be a good place? I've notified the Substance.io team about it. Some others that might be interested, that I haven't seen here yet: TinyMCE, Aloha, Wikimedia Wysywig editor, the WYSYWIG editor project of PLOS, HalloJS, Codemirror, Booktype (another project to write books in the browser), Firepad, ShareLatex, WriteLatex, WebODF, ICE (I have contributed most of the Chrome code to it, but I'm not part of the core developer team). Others? I don't know what your procedures are for such things, but maybe send them all an email? We may have to accept that a lot of projects are slightly tired of contenteditable/caret-moving fixing efforts, given that so many attempts to fix it have failed in the past. Lets make sure this doesn't happen this time. :) From my experience, the issues/use cases mentioned will cover just about all the main problems. I would personally move the DTP out of this, at least if DTP is to understood mainly as fragmentation stuff. That is very important, but the debates on fragmentation are there already and we should be able to find an agreement on cursor movement even if the issues around fragmentation cannot be resolved. On Thu, Jul 3, 2014 at 12:46 AM, Ryosuke Niwa rn...@apple.com wrote: Thank you Ben! It would be great if we could get more use cases from developers who are interested in improving editing API. Is there any communication channel we can use for that? - R. Niwa On Jul 2, 2014, at 3:12 PM, Ben Peters ben.pet...@microsoft.com wrote: Great discussion on this! I have added these to the Explainer Doc[1]. Please let me know what you think of the list so far. I would also like discuss this in the meeting next Friday[2], so anyone that can come would be great! Ben [1] http://w3c.github.io/editing-explainer/commands-explainer.html [2] http://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0011.html On Mon, Jun 30, 2014 at 10:33 PM, Johannes Wilm johan...@fiduswriter.org wrote: On Tue, Jul 1, 2014 at 4:39 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 30, 2014, at 1:43 PM, Johannes Wilm johan...@fiduswriter.org wrote: On Mon, Jun 30, 2014 at 10:01 PM, Ryosuke Niwa rn...@apple.com wrote: snip Web-based DTP application: The app can creates a document that contains pagination, columns, and a complex illustrations. It needs to let users edit any text that appears in the document. Each editable text needs to be accessible, and styles applied to text need to be backed by the application's internal model of the document. Yes, but wouldn't this require some fragmentation logic? To create something like what Quark Xpress was in the 1990s, I think you'd need CSS Regions or equivalent. It seems as if that would be a little outside of the scope of the caret moving logic, or how do you mean? I would find it great if this ever happens, but as I understand it the whole fragmentation debate was left aside for a while. CSS regions is still shipped in iOS/OS X Safari, and I don't expect it to go away anytime soon. CSS columns support is still in Blink as well. Furthermore, I don't think CSS WG is halting the work on fragmentations either. We should still keep it as a use case for the new editing API. In addition, I would suggest that you go talk with people in CSS WG and add your use case. Yes, I am aware of that. I spent a year creating a CSS Regions based book layout engine ( http://fiduswriter.github.io/pagination.js/ ) , so I am absolutely interested in fragmentation coming back one day. In the meantime I have created an ad-hoc solution using CSS columns ( http://fiduswriter.github.io/simplePagination.js/simplePagination.html ) The main difference is that the CSS fragmentation based version allows to combine it with contenteditable (text flowing from page to page while editing/writing it). Using Javascript/CSS multicolumns to create the same design means cutting up the DOM, so it has to be done after the text is written. We switched to this second approach when it became clear that CSS Regions would be removed from Chrome. The way we handle it is to let the user write the text in one large page with the footnotes off to the right. When the user hits CTRL+P, the current contents of the edited doc are copied, the original contents is hidden and the copied version is cut up into individual pages. By the time the user gets to the print preview, page numbers, headers, table of contents, footnotes, etc. have all been put in place.
Re: [editing] Use Cases (was: Leading with ContentEditable=Minimal)
Do you mean browser developers or editor developers? Wouldn't this task force group be a good place? I've notified the Substance.io team about it. Some others that might be interested, that I haven't seen here yet: TinyMCE, Aloha, Wikimedia Wysywig editor, the WYSYWIG editor project of PLOS, HalloJS, Codemirror, Booktype (another project to write books in the browser), Firepad, ShareLatex, WriteLatex, WebODF, ICE (I have contributed most of the Chrome code to it, but I'm not part of the core developer team). Others? I don't know what your procedures are for such things, but maybe send them all an email? We may have to accept that a lot of projects are slightly tired of contenteditable/caret-moving fixing efforts, given that so many attempts to fix it have failed in the past. Lets make sure this doesn't happen this time. :) From my experience, the issues/use cases mentioned will cover just about all the main problems. I would personally move the DTP out of this, at least if DTP is to understood mainly as fragmentation stuff. That is very important, but the debates on fragmentation are there already and we should be able to find an agreement on cursor movement even if the issues around fragmentation cannot be resolved. On Thu, Jul 3, 2014 at 12:46 AM, Ryosuke Niwa rn...@apple.com wrote: Thank you Ben! It would be great if we could get more use cases from developers who are interested in improving editing API. Is there any communication channel we can use for that? - R. Niwa On Jul 2, 2014, at 3:12 PM, Ben Peters ben.pet...@microsoft.com wrote: Great discussion on this! I have added these to the Explainer Doc[1]. Please let me know what you think of the list so far. I would also like discuss this in the meeting next Friday[2], so anyone that can come would be great! Ben [1] http://w3c.github.io/editing-explainer/commands-explainer.html [2] http://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0011.html On Mon, Jun 30, 2014 at 10:33 PM, Johannes Wilm johan...@fiduswriter.org wrote: On Tue, Jul 1, 2014 at 4:39 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 30, 2014, at 1:43 PM, Johannes Wilm johan...@fiduswriter.org wrote: On Mon, Jun 30, 2014 at 10:01 PM, Ryosuke Niwa rn...@apple.com wrote: snip Web-based DTP application: The app can creates a document that contains pagination, columns, and a complex illustrations. It needs to let users edit any text that appears in the document. Each editable text needs to be accessible, and styles applied to text need to be backed by the application's internal model of the document. Yes, but wouldn't this require some fragmentation logic? To create something like what Quark Xpress was in the 1990s, I think you'd need CSS Regions or equivalent. It seems as if that would be a little outside of the scope of the caret moving logic, or how do you mean? I would find it great if this ever happens, but as I understand it the whole fragmentation debate was left aside for a while. CSS regions is still shipped in iOS/OS X Safari, and I don't expect it to go away anytime soon. CSS columns support is still in Blink as well. Furthermore, I don't think CSS WG is halting the work on fragmentations either. We should still keep it as a use case for the new editing API. In addition, I would suggest that you go talk with people in CSS WG and add your use case. Yes, I am aware of that. I spent a year creating a CSS Regions based book layout engine ( http://fiduswriter.github.io/pagination.js/ ) , so I am absolutely interested in fragmentation coming back one day. In the meantime I have created an ad-hoc solution using CSS columns ( http://fiduswriter.github.io/simplePagination.js/simplePagination.html ) The main difference is that the CSS fragmentation based version allows to combine it with contenteditable (text flowing from page to page while editing/writing it). Using Javascript/CSS multicolumns to create the same design means cutting up the DOM, so it has to be done after the text is written. We switched to this second approach when it became clear that CSS Regions would be removed from Chrome. The way we handle it is to let the user write the text in one large page with the footnotes off to the right. When the user hits CTRL+P, the current contents of the edited doc are copied, the original contents is hidden and the copied version is cut up into individual pages. By the time the user gets to the print preview, page numbers, headers, table of contents, footnotes, etc. have all been put in place. Fragmentation would be great to have, but for now I would already sleep much better if we would have a more solid selection/caret-moving base to build upon. Semantic HTML WYSIWYG editor for a blogging platform: The editor needs to able to add both semantic and visual annotation to the document as it will
Re: [editing] Leading with ContentEditable=Minimal
On 30/06/2014 07:22 , Johannes Wilm wrote: Another use case: Create a track changes function within an editor (like https://github.com/NYTimes/ice ) that really should be run MVC in order to keep the code somewhat readable. Currently ICE breaks whenever any of the browser makers decide to change anything about contenteditable. Oh yeah, anything involving tracking, OT, or whatever temporal really, really can't use the markup as its model. I'm surprised ICE went that way, it must be terribly painful. -- Robin Berjon - http://berjon.com/ - @robinberjon
usecases Re: [editing] Leading with ContentEditable=Minimal
On Mon, 30 Jun 2014 10:54:36 +0300, Robin Berjon ro...@w3.org wrote: On 30/06/2014 07:22 , Johannes Wilm wrote: Another use case: Create a track changes function within an editor (like https://github.com/NYTimes/ice ) that really should be run MVC in order to keep the code somewhat readable. Currently ICE breaks whenever any of the browser makers decide to change anything about contenteditable. Oh yeah, anything involving tracking, OT, or whatever temporal really, really can't use the markup as its model. I'm surprised ICE went that way, it must be terribly painful. Create an extension that substitutes an editor adapted to the user's needs for a default editing setup in an application. -- Charles McCathie Nevile - web standards - CTO Office, Yandex cha...@yandex-team.ru Find more at http://yandex.com
Re: [editing] Leading with ContentEditable=Minimal
On Jun 29, 2014, at 10:22 PM, Johannes Wilm johan...@fiduswriter.org wrote: Another use case: Create a track changes function within an editor (like https://github.com/NYTimes/ice ) that really should be run MVC in order to keep the code somewhat readable. Currently ICE breaks whenever any of the browser makers decide to change anything about contenteditable. This is a great concrete use case. On Jun 26, 2014, at 3:24 PM, Olivier F teleclim...@gmail.com wrote: On Thu, Jun 26, 2014 at 3:51 AM, Robin Berjon ro...@w3.org wrote: On 24/06/2014 20:09 , Ben Peters wrote: Problems: * ContentEditable is too complex and buggy to be usable as-is * ContentEditable does not easily enable the wide range of editing scenarios Complex and buggy aren't necessarily show-stoppers. With hard work it should be possible to take the current Editing APIs draft and progressively iron out most of the kinks. It's difficult, but difficult things have been done before. The main problem here is that even if we did that we still wouldn't have a usable system. And I would say that the issue isn't so much that it doesn't enable scenarios more than that it works actively hard to make them hard to implement :) Maybe this can be captured as Does not support http://extensiblewebmanifesto.org/;. I agree with this. The problem is not complexity. I don't expect implementing a well-appointed custom content editor will be anything but complex. The problem is that contenteditable=true is a high-level API which by definition has to assume a lot and do a lot. This prevents custom behavior from being implemented without clashing with the helpful high level behavior that the UA is expected to do. Our goal should be to provide a set of low-level building blocks for text/content editing. I think that with cursor=true, and commandEvents, and improved Selection API we're headed in the right direction. I don't think we can set a goal without first enumerating use cases and the problem we're trying to solve. Use Cases: * Create a js framework that enables a WYSIWYG editor and works the same in all browsers with little browser-specific code This one is a bit vague as a use case. Are you thinking of a WYSIWYG editor you see on CMS or a blog editor? Or does it include something like EitherPad? I think we need to be much more concrete. * Use a js framework to insert a customized editor into an email client * Use a js framework to insert a customized editor into a blog * Use a js framework to insert a customized editor into a wiki Aren't those the same as the previous one? I agree these all seem the same. Here are a few other use cases I can think of: * Create a web-based structured content editor, where the allowable DOM elements and/or classes in the content are pre-defined. Could you elaborate on the use case of making such an editor? e.g. allowing only certain types of styling in comments. * A complete book/whatever editor, which can contain areas of non-editable content, nested editable content, etc... See fiduswriter.org, and what CKEditor are doing with widgets. Could you elaborate on how non-editable content appears/used inside an editable content? * Browser-based code editor. Currently CodeMirror and others go through amazing lengths to provide something that looks and behaves like a desktop code editor. * Browser based word art generator where end-user types some text and it renders in 3D along a curve and in rainbow colors on a canvas. These are great use cases. I'd throw in two more: Web-based DTP application: The app can creates a document that contains pagination, columns, and a complex illustrations. It needs to let users edit any text that appears in the document. Each editable text needs to be accessible, and styles applied to text need to be backed by the application's internal model of the document. Semantic HTML WYSIWYG editor for a blogging platform: The editor needs to able to add both semantic and visual annotation to the document as it will be published as a blog. Headings are to be marked up with h1. h2, etc... and each acronyms, abbreviations, and so forth are marked up with respective HTML elements. However, the editor also supports visual annotations such as bolding, italicizing, and enlarging text, each of which will be interpreted by the editor to respective underlying semantics in HTML. I picked these examples because they illustrate why separate building blocks are the right way to go. I would expect the developer of the structured content editor to leverage cursor=true, commandEvents and Selections API, and if it's available some sort of text insert mechanism. In contrast the word art developer would only leverage commandEvents and will have to draw their own cursor and selections along with their fancy curved 3D text. Thanks for a great list of use cases. Now we need a required set of
Re: [editing] Leading with ContentEditable=Minimal
On Mon, Jun 30, 2014 at 10:01 PM, Ryosuke Niwa rn...@apple.com wrote: snip On Jun 26, 2014, at 3:24 PM, Olivier F teleclim...@gmail.com wrote: snip I agree these all seem the same. Here are a few other use cases I can think of: * Create a web-based structured content editor, where the allowable DOM elements and/or classes in the content are pre-defined. Could you elaborate on the use case of making such an editor? e.g. allowing only certain types of styling in comments. We do that in Fidus Writer. Part of the point is to keep the structure of the document semantically defined. Users can't change font sizes of individual words, etc. . This is because one of the main tasks of scientific journal editors who currently receive drafts in Word or Libreoffice format have to undo all the manual styling the writers have added in order to get everything to look in a similar way. we simply take those styling possibilities away so that we can define the entire design through one stylesheet as well as easily convert to other formats, such as LaTex or an Epub, and be sure that we cover all formatting tags that were used. * A complete book/whatever editor, which can contain areas of non-editable content, nested editable content, etc... See fiduswriter.org, and what CKEditor are doing with widgets. Could you elaborate on how non-editable content appears/used inside an editable content? We also do that - for example in the case of formulas. Generally the text is editable near-Wysiwyg style. But when it comes to formulas, we let the user enter them in Latex format and display the result using mathjax. Each formula object within the text is a noneditable island. If the user clicks on it with the mouse, he can change the formula. Another example are figures: We want them to always be block elements and to have exactly one caption without styling. They are therefore non-editable isalnds and if the user clicks on them he can change the figure's display and the caption text. * Browser-based code editor. Currently CodeMirror and others go through amazing lengths to provide something that looks and behaves like a desktop code editor. * Browser based word art generator where end-user types some text and it renders in 3D along a curve and in rainbow colors on a canvas. These are great use cases. I'd throw in two more: - Web-based DTP application: The app can creates a document that contains pagination, columns, and a complex illustrations. It needs to let users edit any text that appears in the document. Each editable text needs to be accessible, and styles applied to text need to be backed by the application's internal model of the document. Yes, but wouldn't this require some fragmentation logic? To create something like what Quark Xpress was in the 1990s, I think you'd need CSS Regions or equivalent. It seems as if that would be a little outside of the scope of the caret moving logic, or how do you mean? I would find it great if this ever happens, but as I understand it the whole fragmentation debate was left aside for a while. - Semantic HTML WYSIWYG editor for a blogging platform: The editor needs to able to add both semantic and visual annotation to the document as it will be published as a blog. Headings are to be marked up with h1. h2, etc... and each acronyms, abbreviations, and so forth are marked up with respective HTML elements. However, the editor also supports visual annotations such as bolding, italicizing, and enlarging text, each of which will be interpreted by the editor to respective underlying semantics in HTML. Yes, and in order to keep things consistent he may want to disallow certain types of styling. A few years ago it was common to see people with Joomla sites who just pasted the text into the editor after copying it from a word processor. Each blog post therefore ended up having very different styling. I picked these examples because they illustrate why separate building blocks are the right way to go. I would expect the developer of the structured content editor to leverage cursor=true, commandEvents and Selections API, and if it's available some sort of text insert mechanism. In contrast the word art developer would only leverage commandEvents and will have to draw their own cursor and selections along with their fancy curved 3D text. Thanks for a great list of use cases. Now we need a required set of features/API for each use case. We can then evaluate whether what has been discussed thus far satisfy enough use cases or not. - R. Niwa -- Johannes Wilm Fidus Writer http://www.fiduswriter.o http://www.fiduswriter.com/rg
Re: DIsjoint ranges (was: contentEditable=minimal)
On Jun 23, 2014, at 8:23 AM, Robin Berjon ro...@w3.org wrote: On 06/06/2014 18:52 , Ryosuke Niwa wrote: On Jun 6, 2014, at 6:40 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:02 , Ryosuke Niwa wrote: I agree visual selection of bidirectional text is a problem worth solving but I don't think adding a generic multi-range selection support to the degree Gecko does is the right solution. I'd be interested to hear how you propose to solve it in another manner. Also note that that's not the only use case, there are other possibilities for disjoint selections, e.g. a table (naturally) or an editable surface with a non-editable island inside. Supporting disjoint range is probably necessary but adding the ability to manipulate each range separately seems excessive because that'll lead to selections with overlapping ranges, ranges in completely different locations that are not visually disjoint, etc... We might need to do something like exposing readonly multi-range selection. Readonly multiranges may be an option, but I can think of some issues (which perhaps we can address). Several people have mentioned the use case in which a script wants to observe selection changes in order to ensure that selections conform to certain constraints. Consider the following: abc 2 defg ABC 1 defg Let's imagine that the script wishes to constrain the selection to only that second line, that the user clicks at 1 and drags towards 2. You'd want the script to constrain the range such that it just selects ABC . If you only cancel the selection change, presumably it doesn't select anything at all here (and I'm also presuming that with such a gesture you don't get a selection change event for each character in between the two drag points — that would be a lot). What is weird in this scenario is that so long as the text is unidirectional you can manipulate the range, but the second B is a character in a different direction you can't. (And then again, *only* in browsers that support visually continuous selection across bidi boundaries — in others it would still work.) I don't think that this variability is good; it is likely to surprise developers. Another issue is that in some cases I believe that *visually* disjoint selections are the right thing to do. If you have an editing host that contains a readonly island, it should be possible for the author to make that island non-selectable so that you can select text from one side to the other but not the island itself. (Typically this enables the inlining of affordances.) Reconsidering your objection, I wonder if it really is a problem? Overlapping ranges: well, it would be weird, but basically it strikes me as a doctor it hurts when I do this problem, unless I'm missing something. Ranges in completely different locations that are not visually disjoint: well, if you do that, maybe you have a reason? Just because you can do something stupid with an API doesn't mean that it's a stupid API. One of the biggest problems with the existing editing API is that it's hard to use because it's high level and a lot of things could go wrong unless you're very careful. I don't think we want to introduce a yet another hard-to-use API if we can avoid it. For starters, most of author scripts completely ignore all but the first range, and applying editing operations to a multi-range selection is a nightmare. I don't disagree that it can be hard to handle, but I'm not sure that that's indicative of anything. Most scripts only handle one selection because AFAIK only Gecko ever supported more than one. Given Gecko itself doesn't handle applying editing operations to multiple ranges well from what I've heard, I'm not certain we can expect web developers to get them right especially in the context where disjoint multi-range selection is needed; e.g. bidirectional text, exotic layout model. I don't think that what is supported in any browser today in terms of contentEditable should be seen as a limitation on what Web developers can achieve. I'm very much certain that they can do better. Again, I have a hard time believing that a novice Web developer who has never seen bidirectional text in his life could get this right. It's the same issue as accessibility or IME issue we've been discussing in another thread. It's extremely easy to get corner cases wrong. Given the whole issue with the existing editing API is that it's buggy in edge cases, we need to be extremely careful not to introduce a yet another API that's error-prone. Thinking about this some more, I wonder if the problem is not less common than I initially thought, though. If you consider the following text: ltr rtl ltr You definitely need multiranges while the selection is in progress if you want visual continuity: [ltr rt]l ltr But when both ends of the selection are in text with the same
Re: [editing] Leading with ContentEditable=Minimal
On Jun 30, 2014, at 1:43 PM, Johannes Wilm johan...@fiduswriter.org wrote: On Mon, Jun 30, 2014 at 10:01 PM, Ryosuke Niwa rn...@apple.com wrote: snip On Jun 26, 2014, at 3:24 PM, Olivier F teleclim...@gmail.com wrote: snip I agree these all seem the same. Here are a few other use cases I can think of: * Create a web-based structured content editor, where the allowable DOM elements and/or classes in the content are pre-defined. Could you elaborate on the use case of making such an editor? e.g. allowing only certain types of styling in comments. We do that in Fidus Writer. Part of the point is to keep the structure of the document semantically defined. Users can't change font sizes of individual words, etc. . This is because one of the main tasks of scientific journal editors who currently receive drafts in Word or Libreoffice format have to undo all the manual styling the writers have added in order to get everything to look in a similar way. we simply take those styling possibilities away so that we can define the entire design through one stylesheet as well as easily convert to other formats, such as LaTex or an Epub, and be sure that we cover all formatting tags that were used. Interesting. That's a very good use case indeed. * A complete book/whatever editor, which can contain areas of non-editable content, nested editable content, etc... See fiduswriter.org, and what CKEditor are doing with widgets. Could you elaborate on how non-editable content appears/used inside an editable content? We also do that - for example in the case of formulas. Generally the text is editable near-Wysiwyg style. But when it comes to formulas, we let the user enter them in Latex format and display the result using mathjax. Each formula object within the text is a noneditable island. If the user clicks on it with the mouse, he can change the formula. Another example are figures: We want them to always be block elements and to have exactly one caption without styling. They are therefore non-editable islands and if the user clicks on them he can change the figure's display and the caption text. Ditto. * Browser-based code editor. Currently CodeMirror and others go through amazing lengths to provide something that looks and behaves like a desktop code editor. * Browser based word art generator where end-user types some text and it renders in 3D along a curve and in rainbow colors on a canvas. These are great use cases. I'd throw in two more: Web-based DTP application: The app can creates a document that contains pagination, columns, and a complex illustrations. It needs to let users edit any text that appears in the document. Each editable text needs to be accessible, and styles applied to text need to be backed by the application's internal model of the document. Yes, but wouldn't this require some fragmentation logic? To create something like what Quark Xpress was in the 1990s, I think you'd need CSS Regions or equivalent. It seems as if that would be a little outside of the scope of the caret moving logic, or how do you mean? I would find it great if this ever happens, but as I understand it the whole fragmentation debate was left aside for a while. CSS regions is still shipped in iOS/OS X Safari, and I don't expect it to go away anytime soon. CSS columns support is still in Blink as well. Furthermore, I don't think CSS WG is halting the work on fragmentations either. We should still keep it as a use case for the new editing API. In addition, I would suggest that you go talk with people in CSS WG and add your use case. Semantic HTML WYSIWYG editor for a blogging platform: The editor needs to able to add both semantic and visual annotation to the document as it will be published as a blog. Headings are to be marked up with h1. h2, etc... and each acronyms, abbreviations, and so forth are marked up with respective HTML elements. However, the editor also supports visual annotations such as bolding, italicizing, and enlarging text, each of which will be interpreted by the editor to respective underlying semantics in HTML. Yes, and in order to keep things consistent he may want to disallow certain types of styling. A few years ago it was common to see people with Joomla sites who just pasted the text into the editor after copying it from a word processor. Each blog post therefore ended up having very different styling. Could you elaborate more on what kind of inline styling you're thinking of? And how and why you want to allow/restrict certain styles? You're providing us of really important information here, and I really appreciate if you could give us more information here :) - R. Niwa
Re: [editing] Leading with ContentEditable=Minimal
On Tue, Jul 1, 2014 at 4:39 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 30, 2014, at 1:43 PM, Johannes Wilm johan...@fiduswriter.org wrote: On Mon, Jun 30, 2014 at 10:01 PM, Ryosuke Niwa rn...@apple.com wrote: snip - Web-based DTP application: The app can creates a document that contains pagination, columns, and a complex illustrations. It needs to let users edit any text that appears in the document. Each editable text needs to be accessible, and styles applied to text need to be backed by the application's internal model of the document. Yes, but wouldn't this require some fragmentation logic? To create something like what Quark Xpress was in the 1990s, I think you'd need CSS Regions or equivalent. It seems as if that would be a little outside of the scope of the caret moving logic, or how do you mean? I would find it great if this ever happens, but as I understand it the whole fragmentation debate was left aside for a while. CSS regions is still shipped in iOS/OS X Safari, and I don't expect it to go away anytime soon. CSS columns support is still in Blink as well. Furthermore, I don't think CSS WG is halting the work on fragmentations either. We should still keep it as a use case for the new editing API. In addition, I would suggest that you go talk with people in CSS WG and add your use case. Yes, I am aware of that. I spent a year creating a CSS Regions based book layout engine ( http://fiduswriter.github.io/pagination.js/ ) , so I am absolutely interested in fragmentation coming back one day. In the meantime I have created an ad-hoc solution using CSS columns ( http://fiduswriter.github.io/simplePagination.js/simplePagination.html ) The main difference is that the CSS fragmentation based version allows to combine it with contenteditable (text flowing from page to page while editing/writing it). Using Javascript/CSS multicolumns to create the same design means cutting up the DOM, so it has to be done after the text is written. We switched to this second approach when it became clear that CSS Regions would be removed from Chrome. The way we handle it is to let the user write the text in one large page with the footnotes off to the right. When the user hits CTRL+P, the current contents of the edited doc are copied, the original contents is hidden and the copied version is cut up into individual pages. By the time the user gets to the print preview, page numbers, headers, table of contents, footnotes, etc. have all been put in place. Fragmentation would be great to have, but for now I would already sleep much better if we would have a more solid selection/caret-moving base to build upon. - Semantic HTML WYSIWYG editor for a blogging platform: The editor needs to able to add both semantic and visual annotation to the document as it will be published as a blog. Headings are to be marked up with h1. h2, etc... and each acronyms, abbreviations, and so forth are marked up with respective HTML elements. However, the editor also supports visual annotations such as bolding, italicizing, and enlarging text, each of which will be interpreted by the editor to respective underlying semantics in HTML. Yes, and in order to keep things consistent he may want to disallow certain types of styling. A few years ago it was common to see people with Joomla sites who just pasted the text into the editor after copying it from a word processor. Each blog post therefore ended up having very different styling. Could you elaborate more on what kind of inline styling you're thinking of? And how and why you want to allow/restrict certain styles? You're providing us of really important information here, and I really appreciate if you could give us more information here :) For example a blog may decide not to allow any inline-css styling. And to emphasize words they may only want to allow bold and italics, but not underline and not a combination of italics and bold on the same word. Of course visually this may be achievable using a lot of !important statements in a general css file for the page. But the contents will turn messy and if users copy from a social media site to a word processor to a blog, and from there to another blog and then into their html-based email and then into another blog... things will end in disaster for certain at some point. -- Johannes Wilm Fidus Writer http://www.fiduswriter.org
Re: [editing] Leading with ContentEditable=Minimal
Another use case: Create a track changes function within an editor (like https://github.com/NYTimes/ice ) that really should be run MVC in order to keep the code somewhat readable. Currently ICE breaks whenever any of the browser makers decide to change anything about contenteditable. On Fri, Jun 27, 2014 at 12:24 AM, Olivier F teleclim...@gmail.com wrote: On Thu, Jun 26, 2014 at 3:51 AM, Robin Berjon ro...@w3.org wrote: On 24/06/2014 20:09 , Ben Peters wrote: Problems: * ContentEditable is too complex and buggy to be usable as-is * ContentEditable does not easily enable the wide range of editing scenarios Complex and buggy aren't necessarily show-stoppers. With hard work it should be possible to take the current Editing APIs draft and progressively iron out most of the kinks. It's difficult, but difficult things have been done before. The main problem here is that even if we did that we still wouldn't have a usable system. And I would say that the issue isn't so much that it doesn't enable scenarios more than that it works actively hard to make them hard to implement :) Maybe this can be captured as Does not support http://extensiblewebmanifesto.org/;. I agree with this. The problem is not complexity. I don't expect implementing a well-appointed custom content editor will be anything but complex. The problem is that contenteditable=true is a high-level API which by definition has to assume a lot and do a lot. This prevents custom behavior from being implemented without clashing with the helpful high level behavior that the UA is expected to do. Our goal should be to provide a set of low-level building blocks for text/content editing. I think that with cursor=true, and commandEvents, and improved Selection API we're headed in the right direction. Use Cases: * Create a js framework that enables a WYSIWYG editor and works the same in all browsers with little browser-specific code s/little/no/ ;-) * Use a js framework to insert a customized editor into an email client * Use a js framework to insert a customized editor into a blog * Use a js framework to insert a customized editor into a wiki Aren't those the same as the previous one? I agree these all seem the same. Here are a few other use cases I can think of: * Create a web-based structured content editor, where the allowable DOM elements and/or classes in the content are pre-defined. * A complete book/whatever editor, which can contain areas of non-editable content, nested editable content, etc... See fiduswriter.org, and what CKEditor are doing with widgets. * Browser-based code editor. Currently CodeMirror and others go through amazing lengths to provide something that looks and behaves like a desktop code editor. * Browser based word art generator where end-user types some text and it renders in 3D along a curve and in rainbow colors on a canvas. I picked these examples because they illustrate why separate building blocks are the right way to go. I would expect the developer of the structured content editor to leverage cursor=true, commandEvents and Selections API, and if it's available some sort of text insert mechanism. In contrast the word art developer would only leverage commandEvents and will have to draw their own cursor and selections along with their fancy curved 3D text. -- Johannes Wilm Fidus Writer http://www.fiduswriter.com
Re: [editing] Leading with ContentEditable=Minimal
On 24/06/2014 20:09 , Ben Peters wrote: Works for me. Should I just scare up a draft? It is likely to be a pretty short spec :) I'm really looking forward to getting things sorted out! But I think we may want to take a step back and make sure we all agree on the problem, goals, and use cases, as Ryosuke has been pushing for. We have several different proposed solutions. Does it make sense to very clearly state all of this before we press on too quickly? Sure, but this is just one of the moving parts we need, and I think it is well established that it is required. The existing contentEditable has many built-in behaviours that cannot be removed by browser vendors without breaking existing deployed code. This includes both native UI and default actions for many events. It's a small spec, it's just what is needed in order to enable the baseline behaviour. The meat is elsewhere :) I was proposing to start putting it together not because it's hard but to get a bit of momentum going. Problems: * ContentEditable is too complex and buggy to be usable as-is * ContentEditable does not easily enable the wide range of editing scenarios Complex and buggy aren't necessarily show-stoppers. With hard work it should be possible to take the current Editing APIs draft and progressively iron out most of the kinks. It's difficult, but difficult things have been done before. The main problem here is that even if we did that we still wouldn't have a usable system. And I would say that the issue isn't so much that it doesn't enable scenarios more than that it works actively hard to make them hard to implement :) Maybe this can be captured as Does not support http://extensiblewebmanifesto.org/;. Goals: * Make it easy to disable browser behavior in editing scenarios I don't think that we should make it easy to disable behaviour; behaviour should be minimal and well-contained by default. Put differently, maybe this should be Editing behaviour should be opt-in rather than opt-out? * Enumerate available actions in a given context before and after javascript adds/modifies behavior I'm not sure I understand what that is? Use Cases: * Create a js framework that enables a WYSIWYG editor and works the same in all browsers with little browser-specific code s/little/no/ ;-) * Use a js framework to insert a customized editor into an email client * Use a js framework to insert a customized editor into a blog * Use a js framework to insert a customized editor into a wiki Aren't those the same as the previous one? * Create a document editor that uses an HTML editor as a frontend but a different document model as a backend I don't know if we want to mention MVC and other such things? Perhaps just the general sanity of not using your rendering view as your model :) -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] Leading with ContentEditable=Minimal
On Thu, Jun 26, 2014 at 3:51 AM, Robin Berjon ro...@w3.org wrote: On 24/06/2014 20:09 , Ben Peters wrote: Problems: * ContentEditable is too complex and buggy to be usable as-is * ContentEditable does not easily enable the wide range of editing scenarios Complex and buggy aren't necessarily show-stoppers. With hard work it should be possible to take the current Editing APIs draft and progressively iron out most of the kinks. It's difficult, but difficult things have been done before. The main problem here is that even if we did that we still wouldn't have a usable system. And I would say that the issue isn't so much that it doesn't enable scenarios more than that it works actively hard to make them hard to implement :) Maybe this can be captured as Does not support http://extensiblewebmanifesto.org/;. I agree with this. The problem is not complexity. I don't expect implementing a well-appointed custom content editor will be anything but complex. The problem is that contenteditable=true is a high-level API which by definition has to assume a lot and do a lot. This prevents custom behavior from being implemented without clashing with the helpful high level behavior that the UA is expected to do. Our goal should be to provide a set of low-level building blocks for text/content editing. I think that with cursor=true, and commandEvents, and improved Selection API we're headed in the right direction. Use Cases: * Create a js framework that enables a WYSIWYG editor and works the same in all browsers with little browser-specific code s/little/no/ ;-) * Use a js framework to insert a customized editor into an email client * Use a js framework to insert a customized editor into a blog * Use a js framework to insert a customized editor into a wiki Aren't those the same as the previous one? I agree these all seem the same. Here are a few other use cases I can think of: * Create a web-based structured content editor, where the allowable DOM elements and/or classes in the content are pre-defined. * A complete book/whatever editor, which can contain areas of non-editable content, nested editable content, etc... See fiduswriter.org, and what CKEditor are doing with widgets. * Browser-based code editor. Currently CodeMirror and others go through amazing lengths to provide something that looks and behaves like a desktop code editor. * Browser based word art generator where end-user types some text and it renders in 3D along a curve and in rainbow colors on a canvas. I picked these examples because they illustrate why separate building blocks are the right way to go. I would expect the developer of the structured content editor to leverage cursor=true, commandEvents and Selections API, and if it's available some sort of text insert mechanism. In contrast the word art developer would only leverage commandEvents and will have to draw their own cursor and selections along with their fancy curved 3D text.
Re: [editing] Leading with ContentEditable=Minimal
On 23/06/2014 18:25 , Julie Parent wrote: Well stated. I like contentEditable=cursor. Works for me. Should I just scare up a draft? It is likely to be a pretty short spec :) -- Robin Berjon - http://berjon.com/ - @robinberjon
RE: [editing] Leading with ContentEditable=Minimal
-Original Message- On 23/06/2014 18:25 , Julie Parent wrote: Well stated. I like contentEditable=cursor. Works for me. Should I just scare up a draft? It is likely to be a pretty short spec :) I'm really looking forward to getting things sorted out! But I think we may want to take a step back and make sure we all agree on the problem, goals, and use cases, as Ryosuke has been pushing for. We have several different proposed solutions. Does it make sense to very clearly state all of this before we press on too quickly? I'm working on a draft now, and would like input. The list below takes a stab at it, but I'm sure there are others we should add and maybe some we don't need? Problems: * ContentEditable is too complex and buggy to be usable as-is * ContentEditable does not easily enable the wide range of editing scenarios * There are many ways to indicate user intentions and no clean way to understand them all * Accessibility tools have difficulty understanding what actions are available * Frameworks and sites may have difficulty understanding what is implemented, what should show up on toolbars and menus, and what needs to be polyfilled in editing scenarios Goals: * Make it easy to disable browser behavior in editing scenarios * Make it easy to implement custom behavior with appropriate APIs * Allow overwrite of behavior for a user intention from all actions that indicate that intention * Enumerate available actions in a given context before and after javascript adds/modifies behavior Use Cases: * Create a js framework that enables a WYSIWYG editor and works the same in all browsers with little browser-specific code * Use a js framework to insert a customized editor into an email client * Use a js framework to insert a customized editor into a blog * Use a js framework to insert a customized editor into a wiki * Create a document editor that uses an HTML editor as a frontend but a different document model as a backend * Empower complex editors to be accessible by enabling users to understand available behaviors with little accessibility-specific work from the framework or site
DIsjoint ranges (was: contentEditable=minimal)
On 06/06/2014 18:52 , Ryosuke Niwa wrote: On Jun 6, 2014, at 6:40 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:02 , Ryosuke Niwa wrote: I agree visual selection of bidirectional text is a problem worth solving but I don't think adding a generic multi-range selection support to the degree Gecko does is the right solution. I'd be interested to hear how you propose to solve it in another manner. Also note that that's not the only use case, there are other possibilities for disjoint selections, e.g. a table (naturally) or an editable surface with a non-editable island inside. Supporting disjoint range is probably necessary but adding the ability to manipulate each range separately seems excessive because that'll lead to selections with overlapping ranges, ranges in completely different locations that are not visually disjoint, etc... We might need to do something like exposing readonly multi-range selection. Readonly multiranges may be an option, but I can think of some issues (which perhaps we can address). Several people have mentioned the use case in which a script wants to observe selection changes in order to ensure that selections conform to certain constraints. Consider the following: abc 2 defg ABC 1 defg Let's imagine that the script wishes to constrain the selection to only that second line, that the user clicks at 1 and drags towards 2. You'd want the script to constrain the range such that it just selects ABC . If you only cancel the selection change, presumably it doesn't select anything at all here (and I'm also presuming that with such a gesture you don't get a selection change event for each character in between the two drag points — that would be a lot). What is weird in this scenario is that so long as the text is unidirectional you can manipulate the range, but the second B is a character in a different direction you can't. (And then again, *only* in browsers that support visually continuous selection across bidi boundaries — in others it would still work.) I don't think that this variability is good; it is likely to surprise developers. Another issue is that in some cases I believe that *visually* disjoint selections are the right thing to do. If you have an editing host that contains a readonly island, it should be possible for the author to make that island non-selectable so that you can select text from one side to the other but not the island itself. (Typically this enables the inlining of affordances.) Reconsidering your objection, I wonder if it really is a problem? Overlapping ranges: well, it would be weird, but basically it strikes me as a doctor it hurts when I do this problem, unless I'm missing something. Ranges in completely different locations that are not visually disjoint: well, if you do that, maybe you have a reason? Just because you can do something stupid with an API doesn't mean that it's a stupid API. For starters, most of author scripts completely ignore all but the first range, and applying editing operations to a multi-range selection is a nightmare. I don't disagree that it can be hard to handle, but I'm not sure that that's indicative of anything. Most scripts only handle one selection because AFAIK only Gecko ever supported more than one. Given Gecko itself doesn't handle applying editing operations to multiple ranges well from what I've heard, I'm not certain we can expect web developers to get them right especially in the context where disjoint multi-range selection is needed; e.g. bidirectional text, exotic layout model. I don't think that what is supported in any browser today in terms of contentEditable should be seen as a limitation on what Web developers can achieve. I'm very much certain that they can do better. Thinking about this some more, I wonder if the problem is not less common than I initially thought, though. If you consider the following text: ltr rtl ltr You definitely need multiranges while the selection is in progress if you want visual continuity: [ltr rt]l ltr But when both ends of the selection are in text with the same direction, you can revert to having a single range: [ltr rtl ltr] The problem being less common does not decrease the need to support for it, but it does decrease the odds that people will shoot themselves in the foot over relatively common cases. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On 17/06/2014 02:39 , Julie Parent wrote: I certainly understand the concern that it would be impossible to properly catch and cancel all events. But I think that is somewhat the point - it forces browser vendors to get these parts right. All changes to an editable dom must fire an event before the modifications are made, and must be cancelable. Further, I'd say that if the number of events you would need to preventDefault on grows larger than selection, command, and maybe clipboard then that implies that we are not building the right APIs. Apart from other problems with building on top of contentEditable=true (notably that you keep getting the native browser UI, which is likely very wrong) I'd be really worried that we'd be painting ourselves into a corner with this approach. If we realise a year or two from now that the design we picked isn't ideal and that we'd really need a new event type, the reliance on prevent everything I don't know about could severely constrain our options, and force us to shoehorn new functionality into existing events just to make sure we don't break existing content. I don't think that the (limited) benefits are really worth it. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] Leading with ContentEditable=Minimal
On 17/06/2014 02:12 , Julie Parent wrote: If Intention events are (temporarily) moved out of scope, I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? The way I see it, that is indeed *all* it would do (and serve as a sanity flag so that browsers know how to handle this cleanly). It *is* an explicit API to enable cursors. It has the advantage of reusing an existing name so that we don't have to worry about what happens when you specify both; and it's declarative because that's what you want for such a case (notably so that CSS can style what's editable cleanly). We could rename it contentEditable=cursor if that's cleaner — the idea is the same (and I certainly won't argue bikeshedding :). -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] Leading with ContentEditable=Minimal
Well stated. I like contentEditable=cursor. On Mon, Jun 23, 2014 at 9:21 AM, Robin Berjon ro...@w3.org wrote: On 17/06/2014 02:12 , Julie Parent wrote: If Intention events are (temporarily) moved out of scope, I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? The way I see it, that is indeed *all* it would do (and serve as a sanity flag so that browsers know how to handle this cleanly). It *is* an explicit API to enable cursors. It has the advantage of reusing an existing name so that we don't have to worry about what happens when you specify both; and it's declarative because that's what you want for such a case (notably so that CSS can style what's editable cleanly). We could rename it contentEditable=cursor if that's cleaner — the idea is the same (and I certainly won't argue bikeshedding :). -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] Leading with ContentEditable=Minimal
On Jun 22, 2014, at 9:19 PM, Julie Parent jpar...@google.com wrote: On Fri, Jun 20, 2014 at 8:47 PM, Ryosuke Niwa rn...@apple.com wrote: On Jun 17, 2014, at 1:44 PM, Julie Parent jpar...@google.com wrote: On Tue, Jun 17, 2014 at 12:22 PM, Olivier F teleclim...@gmail.com wrote: On Mon, Jun 16, 2014 at 5:48 PM, Julie Parent jpar...@google.com wrote: On Mon, Jun 16, 2014 at 5:23 PM, Ben Peters ben.pet...@microsoft.com wrote: On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? Agreed in general, but it would depend on how contentEditable='min' is actually defined. I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent. Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well? I really like cursor=true. I'm more confused about commandEvents=true as a separate attribute. - Do CommandEvents make any sense without a cursor? In particular, how does end-user focus an area that has commandEvents=true if there is no cursor? An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. They have to use a hidden focused contentEditable region in order to get all the events they need now, but it would be a much nicer solution for them to simply enable the events. How does that work in mobile? iOS for example shows lollipops at the end of selections to trigger editing actions such as copy, paste, etc... if a web content was drawing its own cursor, then these UIs can't be shown for the user. It seems to me that what they want is to use the native cursor and do every editing operation themselves. The sad answer, at least for the Docs case I was referring to, is that they aren't using web content on mobile, they are writing native apps. Your point is still valid, but I think the selection API would need to be significantly extended in order for them to make use of it, rather than doing their own thing. In particular, they want to be able to draw multiple cursors (the primary user selection and those of collaborators) I don't think cursors for collaborators need to be drawn by the UA since users won't be interacting with those directly. and to control the granularity of selection movement throughout different types of rich content, in a better way than you get by just using ce='false' regions inside an editable regions. Could you elaborate on what kind of granularity they need? It would be great to evolve to selection API to encompass these use cases as well, but I think that is outside the scope of this discussion. While we may not immediately satisfy all of their needs, we should still take their use cases into our consideration so that new API will be forward compatible with their use cases if any. - R. Niwa
Re: [editing] Leading with ContentEditable=Minimal
On Fri, Jun 20, 2014 at 8:47 PM, Ryosuke Niwa rn...@apple.com wrote: On Jun 17, 2014, at 1:44 PM, Julie Parent jpar...@google.com wrote: On Tue, Jun 17, 2014 at 12:22 PM, Olivier F teleclim...@gmail.com wrote: On Mon, Jun 16, 2014 at 5:48 PM, Julie Parent jpar...@google.com wrote: On Mon, Jun 16, 2014 at 5:23 PM, Ben Peters ben.pet...@microsoft.com wrote: On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? Agreed in general, but it would depend on how contentEditable='min' is actually defined. I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent. Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well? I really like cursor=true. I'm more confused about commandEvents=true as a separate attribute. - Do CommandEvents make any sense without a cursor? In particular, how does end-user focus an area that has commandEvents=true if there is no cursor? An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. They have to use a hidden focused contentEditable region in order to get all the events they need now, but it would be a much nicer solution for them to simply enable the events. How does that work in mobile? iOS for example shows lollipops at the end of selections to trigger editing actions such as copy, paste, etc... if a web content was drawing its own cursor, then these UIs can't be shown for the user. It seems to me that what they want is to use the native cursor and do every editing operation themselves. The sad answer, at least for the Docs case I was referring to, is that they aren't using web content on mobile, they are writing native apps. Your point is still valid, but I think the selection API would need to be significantly extended in order for them to make use of it, rather than doing their own thing. In particular, they want to be able to draw multiple cursors (the primary user selection and those of collaborators) and to control the granularity of selection movement throughout different types of rich content, in a better way than you get by just using ce='false' regions inside an editable regions. It would be great to evolve to selection API to encompass these use cases as well, but I think that is outside the scope of this discussion. I'm also not certain how we're going to expose an element with cursor=true but commandEvent=false or cursor=false but commandEvent=true to an assistive technology. - R. Niwa
Re: [editing] Leading with ContentEditable=Minimal
On Jun 17, 2014, at 1:44 PM, Julie Parent jpar...@google.com wrote: On Tue, Jun 17, 2014 at 12:22 PM, Olivier F teleclim...@gmail.com wrote: On Mon, Jun 16, 2014 at 5:48 PM, Julie Parent jpar...@google.com wrote: On Mon, Jun 16, 2014 at 5:23 PM, Ben Peters ben.pet...@microsoft.com wrote: On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? Agreed in general, but it would depend on how contentEditable='min' is actually defined. I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent. Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well? I really like cursor=true. I'm more confused about commandEvents=true as a separate attribute. - Do CommandEvents make any sense without a cursor? In particular, how does end-user focus an area that has commandEvents=true if there is no cursor? An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. They have to use a hidden focused contentEditable region in order to get all the events they need now, but it would be a much nicer solution for them to simply enable the events. How does that work in mobile? iOS for example shows lollipops at the end of selections to trigger editing actions such as copy, paste, etc... if a web content was drawing its own cursor, then these UIs can't be shown for the user. It seems to me that what they want is to use the native cursor and do every editing operation themselves. I'm also not certain how we're going to expose an element with cursor=true but commandEvent=false or cursor=false but commandEvent=true to an assistive technology. - R. Niwa
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On Jun 17, 2014, at 9:00 AM, Piotr Koszuliński p.koszulin...@cksource.com wrote: On Tue, Jun 17, 2014 at 2:39 AM, Julie Parent jpar...@google.com wrote: I certainly understand the concern that it would be impossible to properly catch and cancel all events. I'm not concerned only about this. I'm concerned about the fact that currently existing commands and editable-related features does not fit in a simple command APIs. But I think that is somewhat the point - it forces browser vendors to get these parts right. The spec should guide engines' developers, because there's a single spec and many engines. Even if all browser vendors will get these parts right, they may choose different paths. And then, in general, this will be not right and it will be a pain for developers. All changes to an editable dom must fire an event before the modifications are made, and must be cancelable. Further, I'd say that if the number of events you would need to preventDefault on grows larger than selection, command, and maybe clipboard then that implies that we are not building the right APIs. I don't think that number of events implies that we are building a bad API. Dozen of well defined events is better than three that do too much in an unclear way. Besides that, as an editor author I'm not only interested in preventing default action of features I don't want. I also want to hide them - remove them from browser UI like context menus, menu bar, or other widgets like special toolbar appearing over contenteditable on iOS. This makes the situation which spec has to describe much more complex. That's why I think it's better to focus on basics (http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0918.html) than on trying to make specification for every feature that was introduced in any engine in any away. This makes me think that we want something like a white list of editing features to enable in a given editable element or perhaps * to enable them all. e.g. div contenteditable=inline-style copy paste dragdrop/div - R. Niwa
Re: [editing] Leading with ContentEditable=Minimal
I think that first we need to clarify how we understand some terms/concepts, because I was confused many times and I'm afraid that I also haven't been understood correctly. 1. Separation of basic user intent events and rich command events. Examples: * user intent events - insert character (typing), move caret left, delete a letter, delete a word, insert paragraph break (enter/return), insert line break (shift+enter/return), etc. Additionally there are clipboard, undo and drag and drop events separated already, but they fall into this category. * rich command events - bold, indent, make numbered list, link, enable objects resizing, enable automatic quotes. At some point there were all included in the command events and in my opinion this started the confusion. User intent events are crucial for contentEditable=minimal, when rich command events may be useful for some better internationalization, but are not crucial (if browser does not try to do too much), because they usually are triggered by keystrokes. 2. Commands versus command events. These are separate things again for me - cE=minimal needs events, but does not need commands and entire execCommand/queryCommandState/Value/etc combo. A link command event may be fired when browser thinks that user wants to make a link even if there's no default action bound to that event. 3. Native UI. Again we have UI for basic interaction like the paste option in context menu and UI for rich options like bold or enabling/disabling auto quotes (see [1]). CE=minimal does not need rich options in any form - commands or UI. I'm not sure yet what about basic interaction like copy, cut, paste, spell checking, undo, redo, select all, but they definitely belong to a separate group and may be considered independently of the rich options. Do we agree about these three topics? At least from the separation POV, not necessarily about what cE=minimal needs. [1] http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0867.html On Mon, Jun 16, 2014 at 8:12 PM, Ben Peters ben.pet...@microsoft.com wrote: There’s been a good deal of discussion about the value of contentEditable=minimal. Some of us think that being able to cancel all browser actions with preventDefault on all Intention events is enough, while others believe that having a single way to stop browsers from taking action makes sense. I lean in the direction of the former, but there is another consideration- it will take more time to design and build Intention events in all cases, so why not work toward making contentEditable=minimal available, and then ship Intention events once we have a more complete story ready? -- Piotrek Koszuliński CKEditor JavaScript Lead Developer -- CKSource - http://cksource.com -- Follow CKEditor on: Twitter http://twitter.com/ckeditor | Facebook http://www.facebook.com/ckeditor | Google+ https://plus.google.com/107736718646302128806 | LinkedIn http://www.linkedin.com/company/cksource
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On Tue, Jun 17, 2014 at 2:39 AM, Julie Parent jpar...@google.com wrote: I certainly understand the concern that it would be impossible to properly catch and cancel all events. I'm not concerned only about this. I'm concerned about the fact that currently existing commands and editable-related features does not fit in a simple command APIs. But I think that is somewhat the point - it forces browser vendors to get these parts right. The spec should guide engines' developers, because there's a single spec and many engines. Even if all browser vendors will get these parts right, they may choose different paths. And then, in general, this will be not right and it will be a pain for developers. All changes to an editable dom must fire an event before the modifications are made, and must be cancelable. Further, I'd say that if the number of events you would need to preventDefault on grows larger than selection, command, and maybe clipboard then that implies that we are not building the right APIs. I don't think that number of events implies that we are building a bad API. Dozen of well defined events is better than three that do too much in an unclear way. Besides that, as an editor author I'm not only interested in preventing default action of features I don't want. I also want to hide them - remove them from browser UI like context menus, menu bar, or other widgets like special toolbar appearing over contenteditable on iOS. This makes the situation which spec has to describe much more complex. That's why I think it's better to focus on basics ( http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0918.html) than on trying to make specification for every feature that was introduced in any engine in any away. -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: [editing] Leading with ContentEditable=Minimal
On Tue, Jun 17, 2014 at 12:22 PM, Olivier F teleclim...@gmail.com wrote: On Mon, Jun 16, 2014 at 5:48 PM, Julie Parent jpar...@google.com wrote: On Mon, Jun 16, 2014 at 5:23 PM, Ben Peters ben.pet...@microsoft.com wrote: On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? Agreed in general, but it would depend on how contentEditable='min' is actually defined. I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent. Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well? I really like cursor=true. I'm more confused about commandEvents=true as a separate attribute. - Do CommandEvents make any sense without a cursor? In particular, how does end-user focus an area that has commandEvents=true if there is no cursor? An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. They have to use a hidden focused contentEditable region in order to get all the events they need now, but it would be a much nicer solution for them to simply enable the events. - If commandEvents are just events with no default action, can they not fire safely wherever cursor=true? If the page code does not listen for the event and react, nothing happens. If the page wants to do anything with a command event, it just needs to observe said event. True, and perhaps that could simply things. Events aren't free for the browser though, so there is a cost of having them fire needlessly. I'm assuming here that text insert is a commandEvent and that the page dev takes care of updating the DOM with inserted text (including partial edits with composition events). I guess that part is still up for debate :) I am further assuming CommandEvents refers to low level intent events like deleteToBeginningOfLine (although they could also eventually refer to boldSelection). I want to clarify that in my opinion cursor=true (or commandEvents=true) should in no way imply that the UA should show a WYSIWIG editing UI (bold buttons and context menu entries, etc...). My editor may be a code editor where a bold command makes no sense whatsoever and having bold button looks silly and confusing. I can imagine we would eventually create an API that allows page devs to tell the UA that certain WYSIWYG controls should be shown, and control their state, and they should fire commandEvents. This could be a nice additional building block for editor devs in the future. However the default should be don't show any UA-native WYSIWYG or text editing controls.
Re: [editing] Leading with ContentEditable=Minimal
On Tue, Jun 17, 2014 at 1:44 PM, Julie Parent jpar...@google.com wrote: On Tue, Jun 17, 2014 at 12:22 PM, Olivier F teleclim...@gmail.com wrote: On Mon, Jun 16, 2014 at 5:48 PM, Julie Parent jpar...@google.com wrote: On Mon, Jun 16, 2014 at 5:23 PM, Ben Peters ben.pet...@microsoft.com wrote: On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? Agreed in general, but it would depend on how contentEditable='min' is actually defined. I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent. Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well? I really like cursor=true. I'm more confused about commandEvents=true as a separate attribute. - Do CommandEvents make any sense without a cursor? In particular, how does end-user focus an area that has commandEvents=true if there is no cursor? An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. OK, I can see that. Would commandEvents=true fire cursor movement intents? Or is that strictly a byproduct of setting cursor=true? I can imagine pages that use commandEvents=true would want those events too. Maybe setting cursor=true only draws the cursor when the Element is focused and moves it around according to default behavior without firing events. But if the page wants to control that behavior they set commandEvents=true and cursor=true to intercept and prevent default cursor movements? They have to use a hidden focused contentEditable region in order to get all the events they need now, but it would be a much nicer solution for them to simply enable the events. I'm hopeful that these kind of machinations will be a thing of the past if we can create a good spec here... - If commandEvents are just events with no default action, can they not fire safely wherever cursor=true? If the page code does not listen for the event and react, nothing happens. If the page wants to do anything with a command event, it just needs to observe said event. True, and perhaps that could simply things. Events aren't free for the browser though, so there is a cost of having them fire needlessly. I'm assuming here that text insert is a commandEvent and that the page dev takes care of updating the DOM with inserted text (including partial edits with composition events). I guess that part is still up for debate :) I am further assuming CommandEvents refers to low level intent events like deleteToBeginningOfLine (although they could also eventually refer to boldSelection). I want to clarify that in my opinion cursor=true (or commandEvents=true) should in no way imply that the UA should show a WYSIWIG editing UI (bold buttons and context menu entries, etc...). My editor may be a code editor where a bold command makes no sense whatsoever and having bold button looks silly and confusing. I can imagine we would eventually create an API that allows page devs to tell the UA that certain WYSIWYG controls should be shown, and control their state, and they should fire commandEvents. This could be a nice additional building block for editor devs in the future. However the default should be don't show any UA-native
RE: [editing] Leading with ContentEditable=Minimal
On Tue, Jun 17, 2014 at 8:47 AM, Piotr Koszuliński p.koszulin...@cksource.com wrote: I think that first we need to clarify how we understand some terms/concepts, because I was confused many times and I'm afraid that I also haven't been understood correctly. 1. Separation of basic user intent events and rich command events. Examples: * user intent events - insert character (typing), move caret left, delete a letter, delete a word, insert paragraph break (enter/return), insert line break (shift+enter/return), etc. Additionally there are clipboard, undo and drag and drop events separated already, but they fall into this category. * rich command events - bold, indent, make numbered list, link, enable objects resizing, enable automatic quotes. At some point there were all included in the command events and in my opinion this started the confusion. User intent events are crucial for contentEditable=minimal, when rich command events may be useful for some better internationalization, but are not crucial (if browser does not try to do too much), because they usually are triggered by keystrokes. Why does it matter if there are 'basic' events like typing and 'rich' events like bold? If you only care about the 'basic' ones, you can just respond to those and ignore the rest. 2. Commands versus command events. These are separate things again for me - cE=minimal needs events, but does not need commands and entire execCommand/queryCommandState/Value/etc combo. A link command event may be fired when browser thinks that user wants to make a link even if there's no default action bound to that event. I agree that CE min would only have the events, not the default actions. I updated the explainer below with a more complete table in section 3.1. CE=true would have default actions. http://w3c.github.io/editing-explainer/commands-explainer.html
RE: [editing] Leading with ContentEditable=Minimal
On Tue, Jun 17, 2014 at 4:50 PM, Olivier F teleclim...@gmail.com wrote: On Tue, Jun 17, 2014 at 1:44 PM, Julie Parent jpar...@google.com wrote: An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. OK, I can see that. Would commandEvents=true fire cursor movement intents? Or is that strictly a byproduct of setting cursor=true? I can imagine pages that use commandEvents=true would want those events too. Maybe setting cursor=true only draws the cursor when the Element is focused and moves it around according to default behavior without firing events. But if the page wants to control that behavior they set commandEvents=true and cursor=true to intercept and prevent default cursor movements? A cursor is just a type of selection. It happens to not show up in non-editable content, but if it's there, it will fire Selection events just like any other selection. So commandEvents=true is not needed here.
Re: [editing] Leading with ContentEditable=Minimal
Oh right, of course. Thank-you. On Tue, Jun 17, 2014 at 5:00 PM, Ben Peters ben.pet...@microsoft.com wrote: On Tue, Jun 17, 2014 at 4:50 PM, Olivier F teleclim...@gmail.com wrote: On Tue, Jun 17, 2014 at 1:44 PM, Julie Parent jpar...@google.com wrote: An app can have a cursor that isn't a native browser cursor. For example, Google Docs does not use native browser cursors and draws their own, so that they can show multiple cursors for collaborators and control selections entirely the way they want. OK, I can see that. Would commandEvents=true fire cursor movement intents? Or is that strictly a byproduct of setting cursor=true? I can imagine pages that use commandEvents=true would want those events too. Maybe setting cursor=true only draws the cursor when the Element is focused and moves it around according to default behavior without firing events. But if the page wants to control that behavior they set commandEvents=true and cursor=true to intercept and prevent default cursor movements? A cursor is just a type of selection. It happens to not show up in non-editable content, but if it's there, it will fire Selection events just like any other selection. So commandEvents=true is not needed here.
[editing] Leading with ContentEditable=Minimal
There's been a good deal of discussion about the value of contentEditable=minimal. Some of us think that being able to cancel all browser actions with preventDefault on all Intention events is enough, while others believe that having a single way to stop browsers from taking action makes sense. I lean in the direction of the former, but there is another consideration- it will take more time to design and build Intention events in all cases, so why not work toward making contentEditable=minimal available, and then ship Intention events once we have a more complete story ready?
Re: [editing] Leading with ContentEditable=Minimal
If Intention events are (temporarily) moved out of scope, I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? On Mon, Jun 16, 2014 at 11:12 AM, Ben Peters ben.pet...@microsoft.com wrote: There’s been a good deal of discussion about the value of contentEditable=minimal. Some of us think that being able to cancel all browser actions with preventDefault on all Intention events is enough, while others believe that having a single way to stop browsers from taking action makes sense. I lean in the direction of the former, but there is another consideration- it will take more time to design and build Intention events in all cases, so why not work toward making contentEditable=minimal available, and then ship Intention events once we have a more complete story ready?
RE: [editing] Leading with ContentEditable=Minimal
On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent.
Re: [editing] CommandEvent and contentEditable=minimal Explainer
I certainly understand the concern that it would be impossible to properly catch and cancel all events. But I think that is somewhat the point - it forces browser vendors to get these parts right. All changes to an editable dom must fire an event before the modifications are made, and must be cancelable. Further, I'd say that if the number of events you would need to preventDefault on grows larger than selection, command, and maybe clipboard then that implies that we are not building the right APIs. On Sun, Jun 15, 2014 at 11:49 AM, Piotr Koszuliński p.koszulin...@cksource.com wrote: On Sun, Jun 15, 2014 at 5:15 AM, Olivier F teleclim...@gmail.com wrote: On Fri, Jun 13, 2014 at 11:37 AM, Ben Peters ben.pet...@microsoft.com wrote: On Fri, Jun 13, 2014 at 1:01 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 12, 2014, at 5:07 PM, Olivier F teleclim...@gmail.com wrote: Imagine as well a situation where a UA creates a new way to paste content, and to prevent confusion with paste they decide to create a new ua-prefixed event uaMagicPaste. Now our end-users have a way of pasting content into our editor's DOM without any intervention at all on our end, resulting in breakage and bugs. This is a good point. Registering for and calling preventDefault() on CommandEvent and BeforeSelectionChangeEvent will catch all new events in those categories, but ClipboardEvents must be listened to individually (Cut, Copy, Paste). We should consider whether we disallow new ClipboardEvent types or allow a generic ClipboardEvent listener, which would catch uaMagicPaste. I'll add a note to the Explainer for this. Yes, we could add ClipboardEvents and funnel all clipboard events through there, that would work. But I also noticed that Issue 3 was added: Do we need DragEvents too. And yes we do, good catch! It is totally possible to alter the DOM of a contentEditable by dragging something on top of it. I guess we can add DragEvents, but to me this illustrates why the practice of enumerating and capturing all current and future events to preventDefault them is not the right approach. For enumerate+preventDefault to work, every possible event that could change the cE's DOM has to fire correctly and cancel correctly. Every one. I can't help but to feel that there will always be something missing. Something we didn't think of in the spec, something the UA forgot to implement, some bug that prevents the event from being fully canceled, or some brand new interaction paradigm with its own event Class. Just one of these in effect in one major UA and editor devs all over are in pain. So long as enumerate+preventDefault is the only way for editor devs to control their editors, I'm concerned that there will be a constant source of difficulty trying to work around the leaks in the spec/ua/future, and that the end-user experience will continue to suffer as a result. I've got very similar feelings about all this. For years features have been randomly added to contentEditable=true and structuring them now seems for me as undoable. As I commented in [1] and [2] there are features related to contentEditable that do not fit in the CommandEvent and CommandQuery proposals very well. We agree that undo, clipboard and drag and drop interfaces have to be separated from commands. Why not other? Why all other features have to be pushed into commands section? If the commands' related APIs (I do not include very useful low level user intent events into that) and commands themselves will lack precision, then the only use that a cross-browser editor could make of them will be to disable everything. And we'll need to hope that we haven't disabled too much (e.g. clipboard events) or too few things, because imprecise spec will not clarify this. Less is better. Give us stable platform and we'll build great solutions on top of that. Make the platform unpredictable and we'll be fighting it the rest of our days. [1] http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0867.html [2] http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0876.html -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: [editing] Leading with ContentEditable=Minimal
On Mon, Jun 16, 2014 at 5:23 PM, Ben Peters ben.pet...@microsoft.com wrote: On Mon, Jun 16, 2014 at 5:12 PM, Julie Parent jpar...@google.com wrote: If Intention events are (temporarily) moved out of scope, I don’t think I’d say they’re out of scope, just that they will likely not be ready as quickly as we could do contentEditable=’minimal’. Do you agree with that? Agreed in general, but it would depend on how contentEditable='min' is actually defined. I think this leads us back to the question of what would contentEditable='minimal' do exactly? Enable collapsed selections and default handling of cursor movement ... anything else? Yes we need to define this default functionality. What does everyone think about this? If this is all it would do, then perhaps what we really want is an explicit API to enable cursors? I think we should still think of this as a path to a full story that includes Intention events. Are you saying that ultimately we would have something like this? div cursor=”true” commandEvents=”true”minimally editable content/div Like all other content, this would also get drag/drop, clipboard, and selection events. We would need 3 specs for this- Selection API, minimal editing (cursor-only editing?), and CommandEvent. Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well?
RE: [editing] Leading with ContentEditable=Minimal
On Mon, Jun 16, 2014 at 5:48 PM, Julie Parent jpar...@google.com wrote: Yes. I really like the idea of explicitly enabling what you want and of separating the concepts. Being able to turn on commandEvents independent of a cursor seems useful. An API like this leaves far fewer questions of what does it do? than contentEditable=minimal. What does cursor=true do? It turns on the ability for the user or developer to place a cursor, and default movement. It has nothing to do with dom modification. What does commandEvents=true do? It enables dispatching commandEvents. No ambiguity. However, this does make me think again about using beforeinput/input events rather than adding new CommandEvents, since those would include drag/drop and clipboard as well? The way I see it is that divnot editable at all/div would get clipboard and drag/drop events, like it does today. div commandEvents=truebuild an editor here/div would also get CommandEvents.
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On Sun, Jun 15, 2014 at 5:15 AM, Olivier F teleclim...@gmail.com wrote: On Fri, Jun 13, 2014 at 11:37 AM, Ben Peters ben.pet...@microsoft.com wrote: On Fri, Jun 13, 2014 at 1:01 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 12, 2014, at 5:07 PM, Olivier F teleclim...@gmail.com wrote: Imagine as well a situation where a UA creates a new way to paste content, and to prevent confusion with paste they decide to create a new ua-prefixed event uaMagicPaste. Now our end-users have a way of pasting content into our editor's DOM without any intervention at all on our end, resulting in breakage and bugs. This is a good point. Registering for and calling preventDefault() on CommandEvent and BeforeSelectionChangeEvent will catch all new events in those categories, but ClipboardEvents must be listened to individually (Cut, Copy, Paste). We should consider whether we disallow new ClipboardEvent types or allow a generic ClipboardEvent listener, which would catch uaMagicPaste. I'll add a note to the Explainer for this. Yes, we could add ClipboardEvents and funnel all clipboard events through there, that would work. But I also noticed that Issue 3 was added: Do we need DragEvents too. And yes we do, good catch! It is totally possible to alter the DOM of a contentEditable by dragging something on top of it. I guess we can add DragEvents, but to me this illustrates why the practice of enumerating and capturing all current and future events to preventDefault them is not the right approach. For enumerate+preventDefault to work, every possible event that could change the cE's DOM has to fire correctly and cancel correctly. Every one. I can't help but to feel that there will always be something missing. Something we didn't think of in the spec, something the UA forgot to implement, some bug that prevents the event from being fully canceled, or some brand new interaction paradigm with its own event Class. Just one of these in effect in one major UA and editor devs all over are in pain. So long as enumerate+preventDefault is the only way for editor devs to control their editors, I'm concerned that there will be a constant source of difficulty trying to work around the leaks in the spec/ua/future, and that the end-user experience will continue to suffer as a result. I've got very similar feelings about all this. For years features have been randomly added to contentEditable=true and structuring them now seems for me as undoable. As I commented in [1] and [2] there are features related to contentEditable that do not fit in the CommandEvent and CommandQuery proposals very well. We agree that undo, clipboard and drag and drop interfaces have to be separated from commands. Why not other? Why all other features have to be pushed into commands section? If the commands' related APIs (I do not include very useful low level user intent events into that) and commands themselves will lack precision, then the only use that a cross-browser editor could make of them will be to disable everything. And we'll need to hope that we haven't disabled too much (e.g. clipboard events) or too few things, because imprecise spec will not clarify this. Less is better. Give us stable platform and we'll build great solutions on top of that. Make the platform unpredictable and we'll be fighting it the rest of our days. [1] http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0867.html [2] http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0876.html -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On Fri, Jun 13, 2014 at 11:37 AM, Ben Peters ben.pet...@microsoft.com wrote: On Fri, Jun 13, 2014 at 1:01 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 12, 2014, at 5:07 PM, Olivier F teleclim...@gmail.com wrote: Imagine as well a situation where a UA creates a new way to paste content, and to prevent confusion with paste they decide to create a new ua-prefixed event uaMagicPaste. Now our end-users have a way of pasting content into our editor's DOM without any intervention at all on our end, resulting in breakage and bugs. This is a good point. Registering for and calling preventDefault() on CommandEvent and BeforeSelectionChangeEvent will catch all new events in those categories, but ClipboardEvents must be listened to individually (Cut, Copy, Paste). We should consider whether we disallow new ClipboardEvent types or allow a generic ClipboardEvent listener, which would catch uaMagicPaste. I'll add a note to the Explainer for this. Yes, we could add ClipboardEvents and funnel all clipboard events through there, that would work. But I also noticed that Issue 3 was added: Do we need DragEvents too. And yes we do, good catch! It is totally possible to alter the DOM of a contentEditable by dragging something on top of it. I guess we can add DragEvents, but to me this illustrates why the practice of enumerating and capturing all current and future events to preventDefault them is not the right approach. For enumerate+preventDefault to work, every possible event that could change the cE's DOM has to fire correctly and cancel correctly. Every one. I can't help but to feel that there will always be something missing. Something we didn't think of in the spec, something the UA forgot to implement, some bug that prevents the event from being fully canceled, or some brand new interaction paradigm with its own event Class. Just one of these in effect in one major UA and editor devs all over are in pain. So long as enumerate+preventDefault is the only way for editor devs to control their editors, I'm concerned that there will be a constant source of difficulty trying to work around the leaks in the spec/ua/future, and that the end-user experience will continue to suffer as a result.
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On Jun 12, 2014, at 5:07 PM, Olivier F teleclim...@gmail.com wrote: I have been reading this and have a comment: http://w3c.github.io/editing-explainer/commands-explainer.html Issue 11: We may not need contentEditable=minimal. The same thing can be accomplished by listening for commands and calling preventDefault on all of them. I think we need contentEditable=minimal even if it is theoretically possible to listen to all commands and preventDefault on them. Listening to all events and preventing their defaults has the following implications: - All CommandEvents and other things that can modify the state of the contents in our cE actually do fire events. - We are actually able to enumerate all events that could potentially modify the state of our contentEditable. - All of these events can be preventDefaulted. Given the transient nature of specs, implementations, and bugs I have a hard time believing that the theory that we can just listen to everything and prevent defaults has merit in practice. One can easily imagine that some features provided by the UA won't fire events. Or, no need to imagine: just look at undo called from context menu. Imagine as well a situation where a UA creates a new way to paste content, and to prevent confusion with paste they decide to create a new ua-prefixed event uaMagicPaste. Now our end-users have a way of pasting content into our editor's DOM without any intervention at all on our end, resulting in breakage and bugs. In practice, if we are left with the burden of listening to all events and preventing defaults we are left in very much the same situation we're trying to get away from. I don't have a strong opinion either way. However, can't you just whitelist the list of commands you allow and cancel everything else instead for this specific case? I guess you're concerned that it'll make things worse in some cases (e.g. new builtin browser features maybe disabled)? - R. Niwa
Re: [editing] CommandEvent and contentEditable=minimal Explainer
I have been reading this and have a comment: http://w3c.github.io/editing-explainer/commands-explainer.html Issue 11: We may not need contentEditable=minimal. The same thing can be accomplished by listening for commands and calling preventDefault on all of them. I think we need contentEditable=minimal even if it is theoretically possible to listen to all commands and preventDefault on them. Listening to all events and preventing their defaults has the following implications: - All CommandEvents and other things that can modify the state of the contents in our cE actually do fire events. - We are actually able to enumerate all events that could potentially modify the state of our contentEditable. - All of these events can be preventDefaulted. Given the transient nature of specs, implementations, and bugs I have a hard time believing that the theory that we can just listen to everything and prevent defaults has merit in practice. One can easily imagine that some features provided by the UA won't fire events. Or, no need to imagine: just look at undo called from context menu. Imagine as well a situation where a UA creates a new way to paste content, and to prevent confusion with paste they decide to create a new ua-prefixed event uaMagicPaste. Now our end-users have a way of pasting content into our editor's DOM without any intervention at all on our end, resulting in breakage and bugs. In practice, if we are left with the burden of listening to all events and preventing defaults we are left in very much the same situation we're trying to get away from. If cE=min were spec'd to be an editable surface that had everything (or almost) off by default, including future features, then these kinds of surprises wouldn't happen. As developers we'd much rather implement new APIs when we feel we can, rather than having to scramble to preventDefault on new features when they appear on our end-user's browsers one morning. Thank-you for considering this. - Oliver Forget
re: contentEditable=minimal
Hello Everyone, The idea of a contentEditable spec that is usable for developers gives me so much hope that I am drawn to make my very first comment on a W3 list. First, thank-you Ben Peters for the original post. I am an independent web developer who is frustrated because I feel there is a whole class of web-apps that are not seeing the light of day because current cE makes it too difficult. So, we really need this. By this, I mean the building blocks for a fully custom but highly functional and usable content editor in the browser. I have read every message on this topic in this list since May so I can see along with everybody else that this is a very complex problem. It sounds like we should be able to break the problem down into parts, so this is how I see things: 1. Create a cE=minimal/whatever spec that specifies that it does very little by default. Its behavior should be well-defined and highly predictable. It would actually do too little on its own to be called a rich editor, but the point is that it is a stable platform upon which we can build something new without surprises. Just this by itself would be helpful to developers. 2. Develop CommandEvents. Since cE=minimal does very little on its own, we'll have to make it do interesting stuff by listening for events. At first we'll have to listen for the standard keyboard combinations (Cmd-Backspace), but when CommandEvents hit the scene we'll be able to listen for 'deleteToBeginningOfLine'. This will allow us to make more functional editors with fewer lines of code and fewer bugs. Note that this would benefit both cE=min and cE=true. 3. Improve Selection and Range API and others. Right now there is no sane way for me to know where my content wraps, so it's near impossible to do my own implementation of 'deleteToBeginningOfLine', making it difficult to override. There are many other helpful APIs we could come up with that would help people developing editors, but first we need a stable surface to build on. I think if we start with #1, that will at least put devs in a sane place. Then we can make their lives easier with #2 and #3. I have an idea for what we could do for #1. I'll try to write it up in a separate email. Thank-you for reading. I look forward to discussing this further with everyone. Olivier Forget
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On 28/05/2014 01:39 , Julie Parent wrote: The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? I like the simplicity of this approach, but I have some concerns. As Travis points out, this implies that all events have to be cancellable in this context. This can lead to problems (like we had with mutations), it can also have performance implications. Another aspect that may be problematic is the case of UAs that provide a UI (like Safari Mobile) whenever they see contentEditable. I was hoping that contentEditable=minimal would serve as a sanity flag not to include that. In the above it's not possible. I am not sure that we can have this work properly without specifying the default behaviour, which as we all know is a terrible mess. If you don't have reliable default behaviour, can you really rely on the browser to DTRT for the cases you don't wish to handle? Won't you end up having to use a library anyway? Again, I'm all for the simplicity; I'm just worried about the snoring dragon. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On 05/06/2014 09:02 , Ryosuke Niwa wrote: I agree visual selection of bidirectional text is a problem worth solving but I don't think adding a generic multi-range selection support to the degree Gecko does is the right solution. I'd be interested to hear how you propose to solve it in another manner. Also note that that's not the only use case, there are other possibilities for disjoint selections, e.g. a table (naturally) or an editable surface with a non-editable island inside. For starters, most of author scripts completely ignore all but the first range, and applying editing operations to a multi-range selection is a nightmare. I don't disagree that it can be hard to handle, but I'm not sure that that's indicative of anything. Most scripts only handle one selection because AFAIK only Gecko ever supported more than one. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On 02/06/2014 23:01 , Ben Peters wrote: From: Robin Berjon [mailto:ro...@w3.org] I think that the latter is better because it gives the library the computed range that matches the operation, which as far as I can imagine is what you actually want to check (e.g. check that the newRange does not contain something unselectable, isn't outside a given boundary, etc.). The former requires getting a lot of details right in the spec, and those would become hard to handle at the script level. On some platforms a triple click (or some key binding) can select the whole line. This not only means that you need direction: both but also that the script needs a notion of line that it has no access to (unless the Selection API grants it). What makes up a word as a step also varies a lot (e.g. I tend to get confused by what Office apps think a word is as it doesn't match the platform's idea) and there can be interesting interactions with language (e.g. is passive-aggressive one word or two? What about co-operation?). But maybe you have a use case for providing the information in that way that I am not thinking of? This seems like it's getting pretty close to the browser just doing the selection. A browser would still have to figure out what the selection should look like in the version you suggest. Instead, maybe each site could decide what is thinks is a word (passive or passive-agressive). The line example is good, so maybe we should have a 'line' level selection just like the 'word' level? Yes, the way I see it the browser *always* figures out what the selection is; but the developer gets a chance to cancel (or modify) it. Yes my understanding is that today you get both. I'm not arguing against that as the events stand today, but when we talk about 'Intention Events' as an abstract type with certain properties like commandName, I think you should only get one of those (paste or command or beforeinput), and I'm suggesting that it should be paste in this case. Agreed, that's sanity. -- Robin Berjon - http://berjon.com/ - @robinberjon
Composition, IME, etc. (was: contentEditable=minimal)
On 05/06/2014 09:09 , Ryosuke Niwa wrote: On May 23, 2014, at 1:37 PM, Robin Berjon ro...@w3.org wrote: Semantically, autocorrect and compositing really are the same thing. They are not. Word substations and input method compositions are semantically different operations. Ok, I'll accept that depending on the level of abstraction at which you're looking at the problem they may or may not be the same thing. The core of the problem is this: there is a wide array of situations in which some form of indirect text input (deliberately going for a new term with no baggage) takes place. This includes (but is not limited to): • dead key composition (Alt-N, N - ñ) • assumed international composition (',e - é, if you just want an apostrophe you have to compose ',space) • inline composition for pretty much everything • popup composition • autocorrect • speed-typing input (T9, swiping inputs) In order to handle them you have two basic options: a) Let the browser handle them for you (possibly calling up some platform functionality). This works as closely to user expectations as a Web app can hope to get but how do you render it? If it touches your DOM then you lose the indirection you need for sensible editing; if it doesn't I don't know how you show it. b) Provide the app with enough information to do the right thing. This gives you the indirection, but doing the right thing can be pretty hard. I am still leaning towards (b) being the approach to follow, but I'll admit that that's mostly because I can't see how to make (a) actually work. If (b) is the way, then we need to make sure that it's not so hard that everyone gets it wrong as soon as the input is anything other than basic English. Note that if there is a degree of refinement such that we may want to make it possible for authors to style compositing-for-characters and compositing-for-autocorrect, then that ought to go into the styling system. In older versions of Windows, for example, the browser itself can't figure out what kind of style is used by IME. Korean and Japanese IME on Windows, for example, use bolded lines and dotted lines for opposite purposes. And we get bug reports saying that WebKit's rendering for Korean IME is incorrect because we decided to follow Japanese IME's convention. Right. In this case we need to distinguish between the browser not knowing and the Web app not knowing. If the browser doesn't know because the platform can't tell the difference between Korean and Japanese (a problem with which Unicode doesn't help) then there really isn't much that we can do to help the Web app. However if the browser knows, it can provide the app with information. I don't have enough expertise to know how much information it needs to convey — if it's mostly style that can be done (it might be unwieldy to handle but we can look at it). We /could/ consider adding a field to compositing events that would capture some form of ontology of input systems. But I think that's sort of far-fetched and we can get by with the above. (And yes, I'm using ontology on purpose. It wouldn't look good :) In my opinion, it's a requirement that input methods work and look native on editors that use this new API. IME is not a nice-to-have feature. It's a feature required for billions of people to type any text. That is *exactly* my point. At this point I believe that if we just added something like a compositionType = deadkey | kr | jp | t9 | autocorrect | ... field and leave it at that we're not helping anyone. The script will need to know not just how to render all of these but how they are supposed to look on each platform. That's why I am arguing for primitives that enable the script to do the right thing *without* having to know everything about all the possible IMEs. Having said that, I was initially hoping that a mixture of composition events plus IME API would cover a lot of ground already. Thinking about it some more, it's not enough. Can you help me come up with a list of aspects that need to be captured in order to enable the app to render the right UI? Or do you have another proposal? -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] CommandEvent and contentEditable=minimal Explainer
On Jun 6, 2014, at 6:27 AM, Robin Berjon ro...@w3.org wrote: On 28/05/2014 01:39 , Julie Parent wrote: The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? I like the simplicity of this approach, but I have some concerns. As Travis points out, this implies that all events have to be cancellable in this context. This can lead to problems (like we had with mutations), it can also have performance implications. I don't think it will cause problems like mutation events as long as we make execCommand non-reentrant. Asking whether each node can be removed or inserted could cause serious problems due to other precondition checks having been perfumed already at that point, but firing another event before running an execCommand implementation is easy safe since we already fire other events like beforeinput. Another aspect that may be problematic is the case of UAs that provide a UI (like Safari Mobile) whenever they see contentEditable. I was hoping that contentEditable=minimal would serve as a sanity flag not to include that. In the above it's not possible. This makes me think that what we need is a way to hook selection default editing behaviors optimally. However, we need to need a way to tell UA that an element is editable for assistive technology. Ideally, we don't need to rely on ARIA role for that. - R. Niwa
Re: contentEditable=minimal
On Jun 6, 2014, at 6:40 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:02 , Ryosuke Niwa wrote: I agree visual selection of bidirectional text is a problem worth solving but I don't think adding a generic multi-range selection support to the degree Gecko does is the right solution. I'd be interested to hear how you propose to solve it in another manner. Also note that that's not the only use case, there are other possibilities for disjoint selections, e.g. a table (naturally) or an editable surface with a non-editable island inside. Supporting disjoint range is probably necessary but adding the ability to manipulate each range separately seems excessive because that'll lead to selections with overlapping ranges, ranges in completely different locations that are not visually disjoint, etc... We might need to do something like exposing readonly multi-range selection. For starters, most of author scripts completely ignore all but the first range, and applying editing operations to a multi-range selection is a nightmare. I don't disagree that it can be hard to handle, but I'm not sure that that's indicative of anything. Most scripts only handle one selection because AFAIK only Gecko ever supported more than one. Given Gecko itself doesn't handle applying editing operations to multiple ranges well from what I've heard, I'm not certain we can expect web developers to get them right especially in the context where disjoint multi-range selection is needed; e.g. bidirectional text, exotic layout model. - R. Niwa
Re: Should minimal contentEditable default text input (was: contentEditable=minimal)
On May 29, 2014, at 3:50 PM, Julie Parent jpar...@gmail.com wrote: Without default text input, the current proposal for contentEditable=minimal is essentially just enabling cursors (drawing them, dispatching events, performing default actions). Rather than calling the mode minimal, which is ill-defined, why not explicitly call it what it is: cursor-only? Or, have contentEditable take a list of features to turn enable: contentEditable=enable-cursors enable-CommandEvents. Or, rather than tying this concept to contentEditable, with all the assumptions and complications that brings up, why not expose this building block as a completely separate attribute? Explicitly listing features to enable sounds like a superior approach. - R. Niwa
Re: Should minimal contentEditable default text input (was: contentEditable=minimal)
On May 26, 2014, at 1:25 AM, Anne van Kesteren ann...@annevk.nl wrote: On Mon, May 26, 2014 at 4:17 AM, Yoshifumi Inoue yo...@chromium.org wrote: To implement text composition with this, I would like to have wave underline, dotted underline, thick underline etc. Range.prototype.style seems complex in the context of overlapping ranges and such. Suddenly you're no longer applying CSS to a tree. Yeah, especially if we allow text layout to be affected by this, e.g. bolding, font size. That would require some fundamental changes to our engine (WebKit). We can probably add the ability to style text without affecting layout though; e.g. background color, underline. - R. Niwa
Re: Composition, IME, etc. (was: contentEditable=minimal)
On Jun 6, 2014, at 7:24 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:09 , Ryosuke Niwa wrote: On May 23, 2014, at 1:37 PM, Robin Berjon ro...@w3.org wrote: Semantically, autocorrect and compositing really are the same thing. They are not. Word substations and input method compositions are semantically different operations. Ok, I'll accept that depending on the level of abstraction at which you're looking at the problem they may or may not be the same thing. The core of the problem is this: there is a wide array of situations in which some form of indirect text input (deliberately going for a new term with no baggage) takes place. This includes (but is not limited to): • dead key composition (Alt-N, N - ñ) • assumed international composition (',e - é, if you just want an apostrophe you have to compose ',space) • inline composition for pretty much everything • popup composition • autocorrect • speed-typing input (T9, swiping inputs) In order to handle them you have two basic options: a) Let the browser handle them for you (possibly calling up some platform functionality). This works as closely to user expectations as a Web app can hope to get but how do you render it? If it touches your DOM then you lose the indirection you need for sensible editing; if it doesn't I don't know how you show it. b) Provide the app with enough information to do the right thing. This gives you the indirection, but doing the right thing can be pretty hard. I am still leaning towards (b) being the approach to follow, but I'll admit that that's mostly because I can't see how to make (a) actually work. If (b) is the way, then we need to make sure that it's not so hard that everyone gets it wrong as soon as the input is anything other than basic English. I'm not convinced b is the right approach. Note that if there is a degree of refinement such that we may want to make it possible for authors to style compositing-for-characters and compositing-for-autocorrect, then that ought to go into the styling system. In older versions of Windows, for example, the browser itself can't figure out what kind of style is used by IME. Korean and Japanese IME on Windows, for example, use bolded lines and dotted lines for opposite purposes. And we get bug reports saying that WebKit's rendering for Korean IME is incorrect because we decided to follow Japanese IME's convention. Right. In this case we need to distinguish between the browser not knowing and the Web app not knowing. If the browser doesn't know because the platform can't tell the difference between Korean and Japanese (a problem with which Unicode doesn't help) then there really isn't much that we can do to help the Web app. This predicates on using approach b. I'm not convinced that that's the right thing to do here. However if the browser knows, it can provide the app with information. I don't have enough expertise to know how much information it needs to convey — if it's mostly style that can be done (it might be unwieldy to handle but we can look at it). The problem here is that we don't know if underlining is the only difference input methods ever need. We could imagine future new UI paradigms would require other styling such as bolding text, enlarging the text for easier readability while typing, etc... We /could/ consider adding a field to compositing events that would capture some form of ontology of input systems. But I think that's sort of far-fetched and we can get by with the above. (And yes, I'm using ontology on purpose. It wouldn't look good :) In my opinion, it's a requirement that input methods work and look native on editors that use this new API. IME is not a nice-to-have feature. It's a feature required for billions of people to type any text. That is *exactly* my point. At this point I believe that if we just added something like a compositionType = deadkey | kr | jp | t9 | autocorrect | ... field and leave it at that we're not helping anyone. The script will need to know not just how to render all of these but how they are supposed to look on each platform. That's why I am arguing for primitives that enable the script to do the right thing *without* having to know everything about all the possible IMEs. Right. We need a primitive to support all without having to explicitly support each. Having said that, I was initially hoping that a mixture of composition events plus IME API would cover a lot of ground already. Thinking about it some more, it's not enough. Can you help me come up with a list of aspects that need to be captured in order to enable the app to render the right UI? Or do you have another proposal? The biggest difference between European alphabet substation (e.g. e - é) and CJK input methods (e.g. jintian - 今天) is that the former typically works on a single character at a time (i.e.
Re: contentEditable=minimal
On Jun 6, 2014, at 9:52 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 6, 2014, at 6:40 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:02 , Ryosuke Niwa wrote: I agree visual selection of bidirectional text is a problem worth solving but I don't think adding a generic multi-range selection support to the degree Gecko does is the right solution. I'd be interested to hear how you propose to solve it in another manner. Also note that that's not the only use case, there are other possibilities for disjoint selections, e.g. a table (naturally) or an editable surface with a non-editable island inside. Supporting disjoint range is probably necessary but adding the ability to manipulate each range separately seems excessive because that'll lead to selections with overlapping ranges, ranges in completely different locations that are not visually disjoint, etc... are visually disjoint. We might need to do something like exposing readonly multi-range selection. For starters, most of author scripts completely ignore all but the first range, and applying editing operations to a multi-range selection is a nightmare. I don't disagree that it can be hard to handle, but I'm not sure that that's indicative of anything. Most scripts only handle one selection because AFAIK only Gecko ever supported more than one. Given Gecko itself doesn't handle applying editing operations to multiple ranges well from what I've heard, I'm not certain we can expect web developers to get them right especially in the context where disjoint multi-range selection is needed; e.g. bidirectional text, exotic layout model. - R. Niwa
Re: Composition, IME, etc. (was: contentEditable=minimal)
On Jun 6, 2014, at 10:13 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 6, 2014, at 7:24 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:09 , Ryosuke Niwa wrote: On May 23, 2014, at 1:37 PM, Robin Berjon ro...@w3.org wrote: Semantically, autocorrect and compositing really are the same thing. They are not. Word substations and input method compositions are semantically different operations. Ok, I'll accept that depending on the level of abstraction at which you're looking at the problem they may or may not be the same thing. The core of the problem is this: there is a wide array of situations in which some form of indirect text input (deliberately going for a new term with no baggage) takes place. This includes (but is not limited to): • dead key composition (Alt-N, N - ñ) • assumed international composition (',e - é, if you just want an apostrophe you have to compose ',space) • inline composition for pretty much everything • popup composition • autocorrect • speed-typing input (T9, swiping inputs) In order to handle them you have two basic options: a) Let the browser handle them for you (possibly calling up some platform functionality). This works as closely to user expectations as a Web app can hope to get but how do you render it? If it touches your DOM then you lose the indirection you need for sensible editing; if it doesn't I don't know how you show it. b) Provide the app with enough information to do the right thing. This gives you the indirection, but doing the right thing can be pretty hard. I am still leaning towards (b) being the approach to follow, but I'll admit that that's mostly because I can't see how to make (a) actually work. If (b) is the way, then we need to make sure that it's not so hard that everyone gets it wrong as soon as the input is anything other than basic English. I'm not convinced b is the right approach. Note that if there is a degree of refinement such that we may want to make it possible for authors to style compositing-for-characters and compositing-for-autocorrect, then that ought to go into the styling system. In older versions of Windows, for example, the browser itself can't figure out what kind of style is used by IME. Korean and Japanese IME on Windows, for example, use bolded lines and dotted lines for opposite purposes. And we get bug reports saying that WebKit's rendering for Korean IME is incorrect because we decided to follow Japanese IME's convention. Right. In this case we need to distinguish between the browser not knowing and the Web app not knowing. If the browser doesn't know because the platform can't tell the difference between Korean and Japanese (a problem with which Unicode doesn't help) then there really isn't much that we can do to help the Web app. This predicates on using approach b. I'm not convinced that that's the right thing to do here. However if the browser knows, it can provide the app with information. I don't have enough expertise to know how much information it needs to convey — if it's mostly style that can be done (it might be unwieldy to handle but we can look at it). The problem here is that we don't know if underlining is the only difference input methods ever need. We could imagine future new UI paradigms would require other styling such as bolding text, enlarging the text for easier readability while typing, etc... We /could/ consider adding a field to compositing events that would capture some form of ontology of input systems. But I think that's sort of far-fetched and we can get by with the above. (And yes, I'm using ontology on purpose. It wouldn't look good :) In my opinion, it's a requirement that input methods work and look native on editors that use this new API. IME is not a nice-to-have feature. It's a feature required for billions of people to type any text. That is *exactly* my point. At this point I believe that if we just added something like a compositionType = deadkey | kr | jp | t9 | autocorrect | ... field and leave it at that we're not helping anyone. The script will need to know not just how to render all of these but how they are supposed to look on each platform. That's why I am arguing for primitives that enable the script to do the right thing *without* having to know everything about all the possible IMEs. Right. We need a primitive to support all without having to explicitly support each. Having said that, I was initially hoping that a mixture of composition events plus IME API would cover a lot of ground already. Thinking about it some more, it's not enough. Can you help me come up with a list of aspects that need to be captured in order to enable the app to render the right UI? Or do you have another proposal? The biggest difference between European alphabet substation (e.g. e - é) and CJK input methods (e.g. jintian -
Re: Composition, IME, etc. (was: contentEditable=minimal)
On Jun 6, 2014, at 10:13 AM, Ryosuke Niwa rn...@apple.com wrote: On Jun 6, 2014, at 7:24 AM, Robin Berjon ro...@w3.org wrote: On 05/06/2014 09:09 , Ryosuke Niwa wrote: On May 23, 2014, at 1:37 PM, Robin Berjon ro...@w3.org wrote: Semantically, autocorrect and compositing really are the same thing. They are not. Word substations and input method compositions are semantically different operations. Ok, I'll accept that depending on the level of abstraction at which you're looking at the problem they may or may not be the same thing. The core of the problem is this: there is a wide array of situations in which some form of indirect text input (deliberately going for a new term with no baggage) takes place. This includes (but is not limited to): • dead key composition (Alt-N, N - ñ) • assumed international composition (',e - é, if you just want an apostrophe you have to compose ',space) • inline composition for pretty much everything • popup composition • autocorrect • speed-typing input (T9, swiping inputs) In order to handle them you have two basic options: a) Let the browser handle them for you (possibly calling up some platform functionality). This works as closely to user expectations as a Web app can hope to get but how do you render it? If it touches your DOM then you lose the indirection you need for sensible editing; if it doesn't I don't know how you show it. b) Provide the app with enough information to do the right thing. This gives you the indirection, but doing the right thing can be pretty hard. I am still leaning towards (b) being the approach to follow, but I'll admit that that's mostly because I can't see how to make (a) actually work. If (b) is the way, then we need to make sure that it's not so hard that everyone gets it wrong as soon as the input is anything other than basic English. I'm not convinced b is the right approach. Note that if there is a degree of refinement such that we may want to make it possible for authors to style compositing-for-characters and compositing-for-autocorrect, then that ought to go into the styling system. In older versions of Windows, for example, the browser itself can't figure out what kind of style is used by IME. Korean and Japanese IME on Windows, for example, use bolded lines and dotted lines for opposite purposes. And we get bug reports saying that WebKit's rendering for Korean IME is incorrect because we decided to follow Japanese IME's convention. Right. In this case we need to distinguish between the browser not knowing and the Web app not knowing. If the browser doesn't know because the platform can't tell the difference between Korean and Japanese (a problem with which Unicode doesn't help) then there really isn't much that we can do to help the Web app. This predicates on using approach b. I'm not convinced that that's the right thing to do here. However if the browser knows, it can provide the app with information. I don't have enough expertise to know how much information it needs to convey — if it's mostly style that can be done (it might be unwieldy to handle but we can look at it). The problem here is that we don't know if underlining is the only difference input methods ever need. We could imagine future new UI paradigms would require other styling such as bolding text, enlarging the text for easier readability while typing, etc... We /could/ consider adding a field to compositing events that would capture some form of ontology of input systems. But I think that's sort of far-fetched and we can get by with the above. (And yes, I'm using ontology on purpose. It wouldn't look good :) In my opinion, it's a requirement that input methods work and look native on editors that use this new API. IME is not a nice-to-have feature. It's a feature required for billions of people to type any text. That is *exactly* my point. At this point I believe that if we just added something like a compositionType = deadkey | kr | jp | t9 | autocorrect | ... field and leave it at that we're not helping anyone. The script will need to know not just how to render all of these but how they are supposed to look on each platform. That's why I am arguing for primitives that enable the script to do the right thing *without* having to know everything about all the possible IMEs. Right. We need a primitive to support all without having to explicitly support each. Having said that, I was initially hoping that a mixture of composition events plus IME API would cover a lot of ground already. Thinking about it some more, it's not enough. Can you help me come up with a list of aspects that need to be captured in order to enable the app to render the right UI? Or do you have another proposal? The biggest difference between European alphabet substation (e.g. e - é) and CJK input methods (e.g. jintian -
Re: contentEditable=minimal
On May 22, 2014, at 1:52 AM, Jonas Sicking jo...@sicking.cc wrote: On Thu, May 1, 2014 at 5:31 PM, Ben Peters ben.pet...@microsoft.com wrote: Proposal To make this simpler for sites, frameworks, and browsers, it makes sense to enable a new, simpler version of contentEditable that provides basic functionality only. For the sake of discussion, call it contentEditable='minimal'. The functionality provided by the browser under contentEditable='minimal' would be as follows: * Caret drawing * Events such as Keyboard , Clipboard, Drag and Drop * Some keyboard input handling- caret movement, typing of characters including Input Method Editor input * Selection drawing and manipulation according to the new Selection API spec This sounds like a super promising approach. I agree. If I understand the proposal correctly, when the user does something that causes input, like pressing the enter key, we would fire a key event, but we wouldn't actually modify the DOM. Modifying the DOM would be the responsibility of the web page. Likewise, if the user pressed whatever key is platform convention for paste, we would fire an event which contains the clipboard data, but not mutate the DOM. Copying data from the event (i.e. from the clipboard) to the page would be the responsibility of the page. Is that correct? If so I like it a lot! I think it'll be nice to allow authors to enable default UA actions; e.g. auto paste into DOM. I'd like to expand, and clarify, the list of services that you propose that the UA provides: * Caret and selection drawing. * Drawing IME UI in response to user typing. * Events for clipboard and drag'n'drop (though the UA would not mutate the DOM in response to those events). * Cursor navigation, including reacting to touch events, mouse clicks and keyboard events. Cursor navigation would likely also fire cancelable events. * Turning keyboard events into events representing text input (but not mutate the DOM in response to those events). * The Selection API spec for selection manipulation. I.e. pressing a key on the keyboard would always fire a keyboard event, and then, as default action, possibly a cursor navigation event or a text input event, depending on what type of key was pressed. I'm unsure about what the proper way to handle text insertion is. I.e. how to handle the second to last bullet. Can we simply use the same events as we fire in input type=text and textarea, but don't actually mutate any DOM? Or is it awkward to fire beforeinput when there is no default action of mutating the DOM and firing input? And is it too much complexity to ask pages to deal with composition handling themselves? I think requiring pages to handle composition events will be bad because many people don't even know how input methods work, or for that latter, what input method is. Another approach would be to allow plain text input events to actually mutate the DOM as a default action. But allow that action to be cancelled. Note that we would never do anything more complex than mutate an existing text node, or insert a text node where the cursor is located. I.e. no elements would ever get added, removed, split, have attributes changed or otherwise be mutated. I think it would be nice for authors to explicitly enable such default behaviors. - R. Niwa
Re: contentEditable=minimal
On May 27, 2014, at 1:33 AM, Robin Berjon ro...@w3.org wrote: On 27/05/2014 01:47 , Ben Peters wrote: -Original Message- From: Robin Berjon On 26/05/2014 05:43 , Norbert Lindenberg wrote: Were any speakers of bidirectional languages in the room when this was discussed? I don't know what languages the others speak. That said, my recollection was that this was presented along the lines of we've had regular requests to support selecting text in geometric rather than logical orders. I have also heard these requests from the bi-directional experts here at Microsoft. A single, unbroken selection is what we're told users want, and multi-selection makes this possible. Thinking about this a little bit more: I don't imagine that the Selection API should prescribe the UI that browsers choose to support in order to select bidi text, on the contrary they should be allowed to innovate, experiment, follow various platform conventions, etc. But if we don't support multi-range selection, then only one model is possible which precludes unbroken selections. I think that this strongly pushes in the direction of supporting multiple ranges. I agree visual selection of bidirectional text is a problem worth solving but I don't think adding a generic multi-range selection support to the degree Gecko does is the right solution. For starters, most of author scripts completely ignore all but the first range, and applying editing operations to a multi-range selection is a nightmare. - R. Niwa
Re: contentEditable=minimal
On May 23, 2014, at 1:37 PM, Robin Berjon ro...@w3.org wrote: On 23/05/2014 21:32 , Jonas Sicking wrote: On Fri, May 23, 2014 at 4:43 AM, Robin Berjon ro...@w3.org wrote: On 23/05/2014 12:28 , Jonas Sicking wrote: And on mobile autocorrect of misspelled words is common, though that can probably be handled by moving the selection to the misspelled word and then writing the fixed word. Autocorrect should be handled like composition. Composition is pretty much what happens whenever you type some stuff and some other stuff comes out. (Technical definition.) I sadly don't think it's that simple. When compositing chinese characters, or characters like ü, an underline should be rendered during the composition and then removed once a character (or set of characters) is selected. This underline should not appear when typing on a mobile keyword, even if it supports autocorrect. It's not clear to me if the difference is just one of styling, or if there are semantic differences as well. Semantically, autocorrect and compositing really are the same thing. They are not. Word substations and input method compositions are semantically different operations. How that gets rendered may be another story, but I'll point out that there are mobile UIs in which the word being typed is underlined. Just because they're treated the same way in one platform doesn't allow us to treat them same in all platforms. It's crucial for editors on the Web to be able to use the same UI for on the platforms that do differentiate the two. Note that if there is a degree of refinement such that we may want to make it possible for authors to style compositing-for-characters and compositing-for-autocorrect, then that ought to go into the styling system. In older versions of Windows, for example, the browser itself can't figure out what kind of style is used by IME. Korean and Japanese IME on Windows, for example, use bolded lines and dotted lines for opposite purposes. And we get bug reports saying that WebKit's rendering for Korean IME is incorrect because we decided to follow Japanese IME's convention. We /could/ consider adding a field to compositing events that would capture some form of ontology of input systems. But I think that's sort of far-fetched and we can get by with the above. (And yes, I'm using ontology on purpose. It wouldn't look good :) In my opinion, it's a requirement that input methods work and look native on editors that use this new API. IME is not a nice-to-have feature. It's a feature required for billions of people to type any text. My assertion is that we don't want to use compositing events when typing on a keyboard which has autocorrect. (This might be a wrong assertion in which case none of this matters). Rather than composition events we fire events like: insert 'c' insert 'a' insert 'g' selection moved to start at index 0 and end at index 3 insert 'cat' insert ' ' However we've previously said that pages should be able to cancel or adjust selection moves. The question is what happens if the page changes the selection when autocorrect attempts to select the word to be fixed. Gotcha, and indeed you are correct. If autocorrect were implemented as a change of the selection followed by an insert of the correction, the application could unwillingly interfere with the selection and cause mayhem. But even if that weren't the case this would feel pretty hacky. Maybe you are thinking of this because on recent Androids when you autocorrect there's an animation that more or less makes it look like that's what's going on? Honestly, I really think that compositing events are the right abstraction here. We can get finicky on style tweaks, but they work for all compositing systems I can think of admittedly not *that* many but still quite a few). They would even work for T9! I strongly disagree. - R. Niwa
Re: contentEditable and forms (was: contentEditable=minimal)
On May 27, 2014, at 2:56 AM, Robin Berjon ro...@w3.org wrote: On 27/05/2014 09:19 , Piotr Koszuliński wrote: Yes, it should be possible to disable whichever feature you don't need. In some cases you don't need lists (because e.g. you're editing a text that will become a content of a paragraph). And in some cases you don't want bold/italic because your use case requires only structured HTML. So being able to handle such commands is a one thing. But first of all there should be no assumption that a user needs these buttons, because a browser just don't know about that. If I think that users need toolbar, I can render a custom one. Much agreed. The browser should not show any markup/styling affordance for cE=minimal. There's one more assumption that makes editing on mobile devices (especially low-res devices) very hard. It's that if user focuses editable, then he/she wants to type, so native keyboard should pop out. Very often it's true, but in some cases user may want to select some text and using toolbar apply styles or lists, etc. And when the keyboard is visible there's very little space to do that. If there was any API to control whether keyboard is visible, then we could achieve much better UX. There are quite a few things from forms that I think could usefully become available in an editing context. We could benefit from having the inputmode attribute be allowed on any editable piece of text. For the specific use case you cite, an additional keyword of none might make sense too. It possibly wouldn't hurt to have the placeholder attribute be available on all editable content, too. I'm less sure about the validation attributes (except perhaps required) but why not. Obviously validation attributes only make sense if the editable content can contribute to forms. But it would make a lot of sense that it could. Today you have to resort to ugly hacks in which you somehow copy over the edited content into a textarea. That's pretty daft: in most use cases you're going to be submitting the content. There was a discussion about participating in the form submission in general back in Feb: http://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0448.html There are several ways in which we could handle this. One is to have any element with cE=minimal contribute to the form data set (when inside a form, or possibly when using the form attribute if someone remembers what the use case for that thing was). That's interesting, but I get a sense that it conflates two features. Another approach is to add a submittable attribute that can make the innerHTML of any element contribute to the form data set. Thoughts? I think we should come up with a generic form participation mechanism that could be used for cE=minimal. - R. Niwa
RE: contentEditable=minimal
DOM L3 does require implementations to fire composition event for dead-key combinations, so insofar as the (Alt-`) combo results in a dead key for accent-grave (and other dead key combos mentioned below), the composition events should (or are supposed to) fire as a result. -Original Message- From: Ben Peters [mailto:ben.pet...@microsoft.com] Sent: Monday, June 2, 2014 2:00 PM To: Robin Berjon; Julie Parent Cc: Johannes Wilm; public-webapps@w3.org Subject: RE: contentEditable=minimal Great context. Thanks! Let me ask my question another way- should CompositionEvents be used when there isn't a composition? Should typing 'a' fire CompositionEnd? If not we still need a CommandEvent of type insertText, and it seems inconsistent not to fire it for all typing, doesn't it? From: Robin Berjon [mailto:ro...@w3.org] On 27/05/2014 01:52 , Ben Peters wrote: From: Robin Berjon [mailto:ro...@w3.org] On 23/05/2014 01:23 , Ben Peters wrote: As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted. But if you only get one event you can't render the composition as it is carrying out. I believe Composition Events are very important for IME input, but we should fire CommandEvent with Insert text for all text input, including IME. Are you saying we should use Composition Events even for non-IME input? I am not using an IME, and yet I could not type in French on my keyboard without composition. Obviously, if I switch to Kotoeri input, I'll get composition *and* an IME popup. But for regular French input (in a US keyboard) I need: é - Alt-E, E è - Alt-`, E à - Alt-`, A ô - Alt-I, O ü - Alt-U, U ñ - Alt-˜, N (for the occasional Spanish) (and a bunch more) Some older apps (you pretty much can't find them anymore) used to not display the composition as it was ongoing and only show the text after composition had terminated. That was survivable but annoying, and it only worked because composition in Latin-script languages is pretty trivial (except perhaps for all you Livonian speakers out there!), but I don't think it would be viable for more complex compositions. And even in simple cases it would confuse users to be typing characters with no rendering feedback. Without composition events you can't render the ongoing composition. See what's going on at: https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html - L81 That is basically inserting text in a range that's decorated to be underlined to show composition in progress. Composition updates *replace* the text in the range. And at the end the range is removed and text is inserted. The above is for Mac, but I have distant memories of using something similar on Windows called the US International Keyboard where you could have apostrophes compose as accents, etc.. I don't recall how it was rendered though. -- Robin Berjon - http://berjon.com/ - @robinberjon
RE: contentEditable=minimal
From: Robin Berjon [mailto:ro...@w3.org] I think we agree at the high level but might disagree over smaller details. You seem to want something that would roughly resemble the following: BeforeSelectionChange { direction: forward , step: word } whereas I would see something capturing information more along those lines: BeforeSelectionChange { oldRange: [startNode, startOffset, endNode, endOffset] , newRange: [startNode, startOffset, endNode, endOffset] } I think that the latter is better because it gives the library the computed range that matches the operation, which as far as I can imagine is what you actually want to check (e.g. check that the newRange does not contain something unselectable, isn't outside a given boundary, etc.). The former requires getting a lot of details right in the spec, and those would become hard to handle at the script level. On some platforms a triple click (or some key binding) can select the whole line. This not only means that you need direction: both but also that the script needs a notion of line that it has no access to (unless the Selection API grants it). What makes up a word as a step also varies a lot (e.g. I tend to get confused by what Office apps think a word is as it doesn't match the platform's idea) and there can be interesting interactions with language (e.g. is passive-aggressive one word or two? What about co-operation?). But maybe you have a use case for providing the information in that way that I am not thinking of? This seems like it's getting pretty close to the browser just doing the selection. A browser would still have to figure out what the selection should look like in the version you suggest. Instead, maybe each site could decide what is thinks is a word (passive or passive-agressive). The line example is good, so maybe we should have a 'line' level selection just like the 'word' level? Not all of those are separate, though. Voice input is just an input (or beforeinput) that's more than one character long. There's nothing wrong with that. So is pasting (though you need cleaning up). Composition you need to handle, but I would really, really hope that the platform gives you a delete event with a range that matches what it is expected to delete rather than have you support all the modifiers (which you'll get wrong for the user as they are platform specific). As seen in the code gist I posted, given such a delete event the scripting is pretty simple. I agree, except that I don't know why we want paste to fire two 'intention' events (paste and input). Seems like we should make it clear that the intention is insert text (type, voice, whatever), remove text (delete, including what text to remove), or paste (so you can clean it up). I don't think we want to fire both paste and input, but if my reading is correct that is the case today (or expected to be — this isn't exactly an area of high interop). Yes my understanding is that today you get both. I'm not arguing against that as the events stand today, but when we talk about 'Intention Events' as an abstract type with certain properties like commandName, I think you should only get one of those (paste or command or beforeinput), and I'm suggesting that it should be paste in this case. Ben
RE: contentEditable=minimal
Great context. Thanks! Let me ask my question another way- should CompositionEvents be used when there isn't a composition? Should typing 'a' fire CompositionEnd? If not we still need a CommandEvent of type insertText, and it seems inconsistent not to fire it for all typing, doesn't it? From: Robin Berjon [mailto:ro...@w3.org] On 27/05/2014 01:52 , Ben Peters wrote: From: Robin Berjon [mailto:ro...@w3.org] On 23/05/2014 01:23 , Ben Peters wrote: As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted. But if you only get one event you can't render the composition as it is carrying out. I believe Composition Events are very important for IME input, but we should fire CommandEvent with Insert text for all text input, including IME. Are you saying we should use Composition Events even for non-IME input? I am not using an IME, and yet I could not type in French on my keyboard without composition. Obviously, if I switch to Kotoeri input, I'll get composition *and* an IME popup. But for regular French input (in a US keyboard) I need: é - Alt-E, E è - Alt-`, E à - Alt-`, A ô - Alt-I, O ü - Alt-U, U ñ - Alt-˜, N (for the occasional Spanish) (and a bunch more) Some older apps (you pretty much can't find them anymore) used to not display the composition as it was ongoing and only show the text after composition had terminated. That was survivable but annoying, and it only worked because composition in Latin-script languages is pretty trivial (except perhaps for all you Livonian speakers out there!), but I don't think it would be viable for more complex compositions. And even in simple cases it would confuse users to be typing characters with no rendering feedback. Without composition events you can't render the ongoing composition. See what's going on at: https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html- L81 That is basically inserting text in a range that's decorated to be underlined to show composition in progress. Composition updates *replace* the text in the range. And at the end the range is removed and text is inserted. The above is for Mac, but I have distant memories of using something similar on Windows called the US International Keyboard where you could have apostrophes compose as accents, etc.. I don't recall how it was rendered though. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: [editing] CommandEvent and contentEditable=minimal Explainer
I agree it's better to let authors define what behavior they want from UA instead of defining the set of behaviors ourselves. Furthermore, I'd argue that we should separately have a mode where scripts would get intention events but UA wouldn't enact any builtin editing commands as default actions. This is useful for non-text editing applications such as drawing and presentation apps. - R. Niwa On May 28, 2014, at 1:39 PM, Ben Peters ben.pet...@microsoft.com wrote: Great idea! If Intention Events (Clipboard, Selection, Command) cover all of the editing operations that a site would want to handle themselves, we don’t need CE Min as a feature, only a concept that can achieved with preventDefault(). From: Julie Parent [mailto:jpar...@gmail.com] Sent: Tuesday, May 27, 2014 4:40 PM To: Ben Peters Cc: public-webapps@w3.org Subject: Re: [editing] CommandEvent and contentEditable=minimal Explainer The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? Then, if someone wants a region that just does basic text input, then they simply allow it: function handleCommand(evt){ switch (evt.commandType){ case 'insertText': // Let the browser do text insertion break; default: // Prevent all other magic evt.preventDefault(); } This hedges on the fact that CommandEvents would capture ALL the cases that contentEditable currently handles, and that the event would fire BEFORE the dom is modified, and that calling preventDefault would cancel the event, but isn't that a goal of this design anyway? Julie -- Forwarded message -- From: Ben Peters ben.pet...@microsoft.com Date: Thu, May 22, 2014 at 4:56 PM Subject: [editing] CommandEvent and contentEditable=minimal Explainer To: public-webapps@w3.org public-webapps@w3.org I have completed a first-draft explainer document [1], taking the generous feedback of many of you into account. There are 6 open issues on the document currently, and I'm sure there are others that I have missed. It would be great to know if this is heading in in the right direction. My vision is to use this a non-normative Explainer, and create 2 normative specs to go with it. The specs for contentEditable=minimal and CommandEvent should have first-drafts next week. Thanks! Ben [1] http://benjamp.github.io/commands-explainer.htm
Re: Should minimal contentEditable default text input (was: contentEditable=minimal)
On Fri, May 30, 2014 at 12:50 AM, Julie Parent jpar...@gmail.com wrote: Or, rather than tying this concept to contentEditable, with all the assumptions and complications that brings up, why not expose this building block as a completely separate attribute? Just a DOM API perhaps as you're not going to get far without scripting anyway? Interaction with contentEditable features will have to be defined. This could maybe throw if the element was already editable and if this is already active, maybe contentEditable stuff should have no effect. -- http://annevankesteren.nl/
Re: Should minimal contentEditable default text input (was: contentEditable=minimal)
Without default text input, the current proposal for contentEditable=minimal is essentially just enabling cursors (drawing them, dispatching events, performing default actions). Rather than calling the mode minimal, which is ill-defined, why not explicitly call it what it is: cursor-only? Or, have contentEditable take a list of features to turn enable: contentEditable=enable-cursors enable-CommandEvents. Or, rather than tying this concept to contentEditable, with all the assumptions and complications that brings up, why not expose this building block as a completely separate attribute? On Mon, May 26, 2014 at 1:25 AM, Anne van Kesteren ann...@annevk.nl wrote: On Mon, May 26, 2014 at 4:17 AM, Yoshifumi Inoue yo...@chromium.org wrote: Range.style is cool idea! I assume Range.detach() removes styles added Range.style. detach() is a no-op. http://dom.spec.whatwg.org/#dom-range-detach To implement text composition with this, I would like to have wave underline, dotted underline, thick underline etc. Range.prototype.style seems complex in the context of overlapping ranges and such. Suddenly you're no longer applying CSS to a tree. -- http://annevankesteren.nl/
Re: contentEditable=minimal
On Tue, May 27, 2014 at 11:01 AM, Robin Berjon ro...@w3.org wrote: On 25/05/2014 20:40 , Piotr Koszuliński wrote: Making some things unselectable might also be useful. IE has unselectable, there's also -moz-user-select and friends. But this is small fries for later I'd reckon. There are also nested non-editable islands. We built very important feature based on them - http://ckeditor.com/demo#widgets. Currently we block their selection by preventing mousedown and we handle left/right arrows. But cancelling selectionchange would allow us to control more cases in a cleaner way. I'd be curious to know what your take is on the best way to expose this. IE has an unselectable attribute, whereas Gecko and WebKit have a CSS property. In this thread we've been talking about using cancellable events for this (or if not cancellable, ones in which the selection can be modified on the fly). On instinct I would tend to think that this not a great usage of CSS, it's much more tied to behaviour at a lower level. But it sort of is one of those borderline things (as many of the properties that initially came from the CSS UI module). The scriptable option that we're consider is good in that it enables arbitrary cases, but it could be interesting to support a number of cases out of the box with a simpler (for developers) approach. Let's imagine the following DOM: div contenteditable=minimal pblah blah blah/p div class=widget unselectable.../div pblah blah blah/p /div If the cursor is at the beginning of the first p, you hold Shift, and click at the end of the second p, we could imagine that you'd get a Selection with two Ranges (one for each p) and not containing the unselectable widget. I *think* that's the most desirable default behaviour, and it's also one that can be pretty painful to control through script. In that sense an unselectable attribute would make sense. (I reckon that setting the widget to be cE=false would have the same effect, but it is nevertheless an orthogonal property.) WDYT? My previous email might be confusing because I mentioned only that CKEditor handles mousedown event. Actually, this is a tip of an iceberg :). I think that it may be an interesting case, because we were forced to overwrite most of browser behaviours when implementing the widget system. Also, this case is so complex that it's easier to start from what we experienced rather than saying that if X and Y will be possible, then our needs will be satisfied. I hope you forgive me this laziness :) The main requirements for the widget system were: 1. User must not be able to modify a non-editable part of widget. 2. Widget must be selectable as a whole (like an image). 3. Widget may contain editable fragments (nested editables). 4. There are block and inline widgets (surprisingly important requirement). 5. Widget may contain other widgets in its nested editables. So widgets may be nested multiple times. 6. Widget must be selectable by click, arrow keys, etc. It also has to be deletable by backspace/delete and copyable by CTRL+C. This is a structure that we used: div contenteditable=true !-- editor's main editable -- pfoo/p div contenteditable=false !-- widget wrapper -- p contenteditable=truenested editable/p pnon-editable content/p div contenteditable=true panother nested editable/p /div /div pfoo2 span contenteditable=falseinline widget/span/p /div Why did we choose contenteditable=false? At the beginning it was simply intuitive. We don't fully control the interaction methods (mouse, keyboard, selection), so let browser do that. Then we overwrote most of the interaction methods so currently the attribute is not so crucial. However, there's one aspect of interaction which we cannot control and I'm not sure if we'll ever be able - dynamically changing selection (its visual and logical aspect) around block widgets, their nested editables and a special case that complicates all this - blocks may be floated. Let's try to imagine how we could handle selection without using contenteditable=false. pfoo/p div class=widgetwidget/div pbar/p TC1: User clicks main editable's margin, on the side of the block widget. If he clicks closer to the top of the widget, we would like to place caret at the end of preceding editable block (foo^), and when closer to bottom, then in the following block (^bar). Without checking dimensions, that would not be doable, because browser would suggest a selection inside divwidget/div. On the other hand, we could consider always selecting entire widget if selection was proposed inside it. This seems to be a good option, especially taking into account that we may have multiple block widgets one after another, and then you cannot place selection between them anyway. TC2: Another aspect is selection normalisation. When we make a decision that entire block widget should be selected we want to be able to anchor the selection
RE: [editing] CommandEvent and contentEditable=minimal Explainer
Great idea! If Intention Events (Clipboard, Selection, Command) cover all of the editing operations that a site would want to handle themselves, we don’t need CE Min as a feature, only a concept that can achieved with preventDefault(). From: Julie Parent [mailto:jpar...@gmail.com] Sent: Tuesday, May 27, 2014 4:40 PM To: Ben Peters Cc: public-webapps@w3.org Subject: Re: [editing] CommandEvent and contentEditable=minimal Explainer The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? Then, if someone wants a region that just does basic text input, then they simply allow it: function handleCommand(evt){ switch (evt.commandType){ case 'insertText': // Let the browser do text insertion break; default: // Prevent all other magic evt.preventDefault(); } This hedges on the fact that CommandEvents would capture ALL the cases that contentEditable currently handles, and that the event would fire BEFORE the dom is modified, and that calling preventDefault would cancel the event, but isn't that a goal of this design anyway? Julie -- Forwarded message -- From: Ben Peters ben.pet...@microsoft.commailto:ben.pet...@microsoft.com Date: Thu, May 22, 2014 at 4:56 PM Subject: [editing] CommandEvent and contentEditable=minimal Explainer To: public-webapps@w3.orgmailto:public-webapps@w3.org public-webapps@w3.orgmailto:public-webapps@w3.org I have completed a first-draft explainer document [1], taking the generous feedback of many of you into account. There are 6 open issues on the document currently, and I'm sure there are others that I have missed. It would be great to know if this is heading in in the right direction. My vision is to use this a non-normative Explainer, and create 2 normative specs to go with it. The specs for contentEditable=minimal and CommandEvent should have first-drafts next week. Thanks! Ben [1] http://benjamp.github.io/commands-explainer.htm
RE: [editing] CommandEvent and contentEditable=minimal Explainer
Be careful with having events fire before the DOM is updated—at a minimum you’ll want to consider whether you will allow dangerous situations like the legacy MutationEvents could cause (start a change - pre-change notification - make another change - pre-change notification … unexpected things can happen (can be especially challenging to implement securely). HTML5’s focus event model nicely prevents these recursions from looping. I’ve proposed a similar mitigation for the “beforeinput” event of DOM Level 3 Events: https://www.w3.org/Bugs/Public/show_bug.cgi?id=25683 Seems like the Intention Events, if firing before the change is committed, might want a similar mitigation strategy. From: Ben Peters [mailto:ben.pet...@microsoft.com] Sent: Wednesday, May 28, 2014 1:40 PM To: Julie Parent Cc: public-webapps@w3.org Subject: RE: [editing] CommandEvent and contentEditable=minimal Explainer Great idea! If Intention Events (Clipboard, Selection, Command) cover all of the editing operations that a site would want to handle themselves, we don’t need CE Min as a feature, only a concept that can achieved with preventDefault(). From: Julie Parent [mailto:jpar...@gmail.com] Sent: Tuesday, May 27, 2014 4:40 PM To: Ben Peters Cc: public-webapps@w3.orgmailto:public-webapps@w3.org Subject: Re: [editing] CommandEvent and contentEditable=minimal Explainer The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? Then, if someone wants a region that just does basic text input, then they simply allow it: function handleCommand(evt){ switch (evt.commandType){ case 'insertText': // Let the browser do text insertion break; default: // Prevent all other magic evt.preventDefault(); } This hedges on the fact that CommandEvents would capture ALL the cases that contentEditable currently handles, and that the event would fire BEFORE the dom is modified, and that calling preventDefault would cancel the event, but isn't that a goal of this design anyway? Julie -- Forwarded message -- From: Ben Peters ben.pet...@microsoft.commailto:ben.pet...@microsoft.com Date: Thu, May 22, 2014 at 4:56 PM Subject: [editing] CommandEvent and contentEditable=minimal Explainer To: public-webapps@w3.orgmailto:public-webapps@w3.org public-webapps@w3.orgmailto:public-webapps@w3.org I have completed a first-draft explainer document [1], taking the generous feedback of many of you into account. There are 6 open issues on the document currently, and I'm sure there are others that I have missed. It would be great to know if this is heading in in the right direction. My vision is to use this a non-normative Explainer, and create 2 normative specs to go with it. The specs for contentEditable=minimal and CommandEvent should have first-drafts next week. Thanks! Ben [1] http://benjamp.github.io/commands-explainer.htm
Re: [editing] CommandEvent and contentEditable=minimal Explainer
But what is the default behaviour then? What will we be preventing? There's no accepted specification for current contentEditable=true AFAIK, so I thought that the goal of contentEditable=minimal is to avoid the need to write a specification for contentEditable=true. Otherwise, developers may demand from browser vendors that they fix their contentEditable=true implementations and I don't think that anyone wants that. Why not forget about contentEditable=true, make it deprecated and create specification only for algorithms needed by contentEditable=minimal and all required command events? On Wed, May 28, 2014 at 10:39 PM, Ben Peters ben.pet...@microsoft.comwrote: Great idea! If Intention Events (Clipboard, Selection, Command) cover all of the editing operations that a site would want to handle themselves, we don’t need CE Min as a feature, only a concept that can achieved with preventDefault(). *From:* Julie Parent [mailto:jpar...@gmail.com] *Sent:* Tuesday, May 27, 2014 4:40 PM *To:* Ben Peters *Cc:* public-webapps@w3.org *Subject:* Re: [editing] CommandEvent and contentEditable=minimal Explainer The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? Then, if someone wants a region that just does basic text input, then they simply allow it: function handleCommand(evt){ switch (evt.commandType){ case 'insertText': // Let the browser do text insertion break; default: // Prevent all other magic evt.preventDefault(); } This hedges on the fact that CommandEvents would capture ALL the cases that contentEditable currently handles, and that the event would fire BEFORE the dom is modified, and that calling preventDefault would cancel the event, but isn't that a goal of this design anyway? Julie -- Forwarded message -- From: *Ben Peters* ben.pet...@microsoft.com Date: Thu, May 22, 2014 at 4:56 PM Subject: [editing] CommandEvent and contentEditable=minimal Explainer To: public-webapps@w3.org public-webapps@w3.org I have completed a first-draft explainer document [1], taking the generous feedback of many of you into account. There are 6 open issues on the document currently, and I'm sure there are others that I have missed. It would be great to know if this is heading in in the right direction. My vision is to use this a non-normative Explainer, and create 2 normative specs to go with it. The specs for contentEditable=minimal and CommandEvent should have first-drafts next week. Thanks! Ben [1] http://benjamp.github.io/commands-explainer.htm -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
RE: [editing] CommandEvent and contentEditable=minimal Explainer
I don’t think we need to specify the default behavior. We can instead just say that all editing behaviors must fire Intention events that are cancellable. Any events that are already defined (like Clipboard) will continue to work, and others should fire CommandEvents as necessary. We will likely need to have a list of well-known Command Events (like bold, undo, etc) just so we can have a shape for the related CommandData object, but we don’t need to specify the default behavior of those events. From: Piotr Koszuliński [mailto:p.koszulin...@cksource.com] Sent: Wednesday, May 28, 2014 2:40 PM To: Ben Peters Cc: Julie Parent; public-webapps@w3.org Subject: Re: [editing] CommandEvent and contentEditable=minimal Explainer But what is the default behaviour then? What will we be preventing? There's no accepted specification for current contentEditable=true AFAIK, so I thought that the goal of contentEditable=minimal is to avoid the need to write a specification for contentEditable=true. Otherwise, developers may demand from browser vendors that they fix their contentEditable=true implementations and I don't think that anyone wants that. Why not forget about contentEditable=true, make it deprecated and create specification only for algorithms needed by contentEditable=minimal and all required command events? On Wed, May 28, 2014 at 10:39 PM, Ben Peters ben.pet...@microsoft.commailto:ben.pet...@microsoft.com wrote: Great idea! If Intention Events (Clipboard, Selection, Command) cover all of the editing operations that a site would want to handle themselves, we don’t need CE Min as a feature, only a concept that can achieved with preventDefault(). From: Julie Parent [mailto:jpar...@gmail.commailto:jpar...@gmail.com] Sent: Tuesday, May 27, 2014 4:40 PM To: Ben Peters Cc: public-webapps@w3.orgmailto:public-webapps@w3.org Subject: Re: [editing] CommandEvent and contentEditable=minimal Explainer The discussion of which minimal default handling to include with contenteditable=minimal makes me wonder if contentEditable=minimal is necessary at all. It quickly becomes a can of worms of *which* default handling should be included, and it seems likely to not satisfy every use case no matter which decisions are made. However, minimal is proposed as a building block because currently, disabling all default functionality of contentEditable=true is difficult/impossible. But with CommandEvents, shouldn't contentEditable=minimal be equivalent to: // Let editRegion be div contentEditable id='editRegion' var editRegion = document.getElementById(editRegion); editRegion.addEventListener(command, handleCommand); function handleCommand(evt){ evt.preventDefault(); } No default actions would be taken, but selection events would still fire and be handled. There would be no ambiguity. If implementing contentEditable=minimal on top of CommandEvents could just be a few lines of code, why complicate things by spec'ing another property? Then, if someone wants a region that just does basic text input, then they simply allow it: function handleCommand(evt){ switch (evt.commandType){ case 'insertText': // Let the browser do text insertion break; default: // Prevent all other magic evt.preventDefault(); } This hedges on the fact that CommandEvents would capture ALL the cases that contentEditable currently handles, and that the event would fire BEFORE the dom is modified, and that calling preventDefault would cancel the event, but isn't that a goal of this design anyway? Julie -- Forwarded message -- From: Ben Peters ben.pet...@microsoft.commailto:ben.pet...@microsoft.com Date: Thu, May 22, 2014 at 4:56 PM Subject: [editing] CommandEvent and contentEditable=minimal Explainer To: public-webapps@w3.orgmailto:public-webapps@w3.org public-webapps@w3.orgmailto:public-webapps@w3.org I have completed a first-draft explainer document [1], taking the generous feedback of many of you into account. There are 6 open issues on the document currently, and I'm sure there are others that I have missed. It would be great to know if this is heading in in the right direction. My vision is to use this a non-normative Explainer, and create 2 normative specs to go with it. The specs for contentEditable=minimal and CommandEvent should have first-drafts next week. Thanks! Ben [1] http://benjamp.github.io/commands-explainer.htm -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: contentEditable=minimal
On Tue, May 27, 2014 at 1:48 AM, Ben Peters ben.pet...@microsoft.comwrote: 5. There should be no native toolbars in cE=minimal (and other native UI interfering) like the one Safari opens on iOS if you have non-empty selection. I haven't yet checked exactly what's in the iOS toolbar, but generally I don't think we should dictate UI. Clearly on mobile we don't want to forbid browsers to bring up the virutal keyboard, which is a form of native UI. And the spellcheck UI that safari displays also doesn't seem bad if spellchecking is enabled. And UI for cut/copy/past that android renders seems good to render *somewhere* when there's selection. On iOS the contextual toolbar not only contains copy/cut options which are of course ok, but it also contains bold, italic and lists buttons. That's unacceptable and I assume this kind of native UI will not be implemented for cE=minimal. The goal of Command Event is to make this a non-issue. If sites respond to bold/italic/list commands they can handle this UI just fine. Are you concerned that a site may not use bold so the button would have no effect? Yes, it should be possible to disable whichever feature you don't need. In some cases you don't need lists (because e.g. you're editing a text that will become a content of a paragraph). And in some cases you don't want bold/italic because your use case requires only structured HTML. So being able to handle such commands is a one thing. But first of all there should be no assumption that a user needs these buttons, because a browser just don't know about that. If I think that users need toolbar, I can render a custom one. There's one more assumption that makes editing on mobile devices (especially low-res devices) very hard. It's that if user focuses editable, then he/she wants to type, so native keyboard should pop out. Very often it's true, but in some cases user may want to select some text and using toolbar apply styles or lists, etc. And when the keyboard is visible there's very little space to do that. If there was any API to control whether keyboard is visible, then we could achieve much better UX. -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: contentEditable=minimal
On 27/05/2014 01:47 , Ben Peters wrote: -Original Message- From: Robin Berjon On 26/05/2014 05:43 , Norbert Lindenberg wrote: Were any speakers of bidirectional languages in the room when this was discussed? I don't know what languages the others speak. That said, my recollection was that this was presented along the lines of we've had regular requests to support selecting text in geometric rather than logical orders. I have also heard these requests from the bi-directional experts here at Microsoft. A single, unbroken selection is what we're told users want, and multi-selection makes this possible. Thinking about this a little bit more: I don't imagine that the Selection API should prescribe the UI that browsers choose to support in order to select bidi text, on the contrary they should be allowed to innovate, experiment, follow various platform conventions, etc. But if we don't support multi-range selection, then only one model is possible which precludes unbroken selections. I think that this strongly pushes in the direction of supporting multiple ranges. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
Hi Ben, On 27/05/2014 02:07 , Ben Peters wrote: From: Robin Berjon [mailto:ro...@w3.org] Even without accounting for touch screens, you really want the platform to be the thing that knows what Ctrl-Shift-Left means so you don't have to support it yourself (and get it wrong often). Agree. One way to do this would be BeforeSelectionChange having a commandType indicating select forward and select by word. I think we agree at the high level but might disagree over smaller details. You seem to want something that would roughly resemble the following: BeforeSelectionChange { direction: forward , step: word } whereas I would see something capturing information more along those lines: BeforeSelectionChange { oldRange: [startNode, startOffset, endNode, endOffset] , newRange: [startNode, startOffset, endNode, endOffset] } I think that the latter is better because it gives the library the computed range that matches the operation, which as far as I can imagine is what you actually want to check (e.g. check that the newRange does not contain something unselectable, isn't outside a given boundary, etc.). The former requires getting a lot of details right in the spec, and those would become hard to handle at the script level. On some platforms a triple click (or some key binding) can select the whole line. This not only means that you need direction: both but also that the script needs a notion of line that it has no access to (unless the Selection API grants it). What makes up a word as a step also varies a lot (e.g. I tend to get confused by what Office apps think a word is as it doesn't match the platform's idea) and there can be interesting interactions with language (e.g. is passive-aggressive one word or two? What about co-operation?). But maybe you have a use case for providing the information in that way that I am not thinking of? Not all of those are separate, though. Voice input is just an input (or beforeinput) that's more than one character long. There's nothing wrong with that. So is pasting (though you need cleaning up). Composition you need to handle, but I would really, really hope that the platform gives you a delete event with a range that matches what it is expected to delete rather than have you support all the modifiers (which you'll get wrong for the user as they are platform specific). As seen in the code gist I posted, given such a delete event the scripting is pretty simple. I agree, except that I don't know why we want paste to fire two 'intention' events (paste and input). Seems like we should make it clear that the intention is insert text (type, voice, whatever), remove text (delete, including what text to remove), or paste (so you can clean it up). I don't think we want to fire both paste and input, but if my reading is correct that is the case today (or expected to be — this isn't exactly an area of high interop). -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On 25/05/2014 20:40 , Piotr Koszuliński wrote: Making some things unselectable might also be useful. IE has unselectable, there's also -moz-user-select and friends. But this is small fries for later I'd reckon. There are also nested non-editable islands. We built very important feature based on them - http://ckeditor.com/demo#widgets. Currently we block their selection by preventing mousedown and we handle left/right arrows. But cancelling selectionchange would allow us to control more cases in a cleaner way. I'd be curious to know what your take is on the best way to expose this. IE has an unselectable attribute, whereas Gecko and WebKit have a CSS property. In this thread we've been talking about using cancellable events for this (or if not cancellable, ones in which the selection can be modified on the fly). On instinct I would tend to think that this not a great usage of CSS, it's much more tied to behaviour at a lower level. But it sort of is one of those borderline things (as many of the properties that initially came from the CSS UI module). The scriptable option that we're consider is good in that it enables arbitrary cases, but it could be interesting to support a number of cases out of the box with a simpler (for developers) approach. Let's imagine the following DOM: div contenteditable=minimal pblah blah blah/p div class=widget unselectable.../div pblah blah blah/p /div If the cursor is at the beginning of the first p, you hold Shift, and click at the end of the second p, we could imagine that you'd get a Selection with two Ranges (one for each p) and not containing the unselectable widget. I *think* that's the most desirable default behaviour, and it's also one that can be pretty painful to control through script. In that sense an unselectable attribute would make sense. (I reckon that setting the widget to be cE=false would have the same effect, but it is nevertheless an orthogonal property.) WDYT? -- Robin Berjon - http://berjon.com/ - @robinberjon
Composition events (was: contentEditable=minimal)
On 27/05/2014 01:52 , Ben Peters wrote: Composition Events for IMEs, CommandEvents with type insertText for all text input (including after Composition Events for IMEs) I think we should be careful not to mix up composition events and IMEs. They may happen together, but IMEs have their own specific issues (e.g. popping up a window) that inline composition does not necessarily have. Also, IMEs can happen without composition: you could arguably popup a handwriting IME that would just insert text on commit without any composition taking place. To stick to what I think is the simplest case, diacritic composition, here is what I believe the current D3E specification says (not that it's really clear on the matter, but I'm assuming best case scenario). For ñ you basically get: compositionstart ˜ compositionend ñ From what you're saying above you'd like to replace that with: compositionstart ˜ input ñ I think we can make that work, it drops on event and moves the code around. If you look at the Twitter Box code: https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html-L102 It basically would need to move what's in the compositionend handler inside the beforeinput handler, with a check to see if compoRange exists (or the event has isComposing=true). (I'm assuming that compositionupdate stays as is since we need to update the rendering with it.) Is that the sort of flow you had in mind? PS: note I just noticed that the code in the Gist was not the latest I had and had a lot of TODO bits — I've udpated it to the latest. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On 27/05/2014 01:52 , Ben Peters wrote: From: Robin Berjon [mailto:ro...@w3.org] On 23/05/2014 01:23 , Ben Peters wrote: As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted. But if you only get one event you can't render the composition as it is carrying out. I believe Composition Events are very important for IME input, but we should fire CommandEvent with Insert text for all text input, including IME. Are you saying we should use Composition Events even for non-IME input? I am not using an IME, and yet I could not type in French on my keyboard without composition. Obviously, if I switch to Kotoeri input, I'll get composition *and* an IME popup. But for regular French input (in a US keyboard) I need: é - Alt-E, E è - Alt-`, E à - Alt-`, A ô - Alt-I, O ü - Alt-U, U ñ - Alt-˜, N (for the occasional Spanish) (and a bunch more) Some older apps (you pretty much can't find them anymore) used to not display the composition as it was ongoing and only show the text after composition had terminated. That was survivable but annoying, and it only worked because composition in Latin-script languages is pretty trivial (except perhaps for all you Livonian speakers out there!), but I don't think it would be viable for more complex compositions. And even in simple cases it would confuse users to be typing characters with no rendering feedback. Without composition events you can't render the ongoing composition. See what's going on at: https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html-L81 That is basically inserting text in a range that's decorated to be underlined to show composition in progress. Composition updates *replace* the text in the range. And at the end the range is removed and text is inserted. The above is for Mac, but I have distant memories of using something similar on Windows called the US International Keyboard where you could have apostrophes compose as accents, etc.. I don't recall how it was rendered though. -- Robin Berjon - http://berjon.com/ - @robinberjon
contentEditable and forms (was: contentEditable=minimal)
On 27/05/2014 09:19 , Piotr Koszuliński wrote: Yes, it should be possible to disable whichever feature you don't need. In some cases you don't need lists (because e.g. you're editing a text that will become a content of a paragraph). And in some cases you don't want bold/italic because your use case requires only structured HTML. So being able to handle such commands is a one thing. But first of all there should be no assumption that a user needs these buttons, because a browser just don't know about that. If I think that users need toolbar, I can render a custom one. Much agreed. The browser should not show any markup/styling affordance for cE=minimal. There's one more assumption that makes editing on mobile devices (especially low-res devices) very hard. It's that if user focuses editable, then he/she wants to type, so native keyboard should pop out. Very often it's true, but in some cases user may want to select some text and using toolbar apply styles or lists, etc. And when the keyboard is visible there's very little space to do that. If there was any API to control whether keyboard is visible, then we could achieve much better UX. There are quite a few things from forms that I think could usefully become available in an editing context. We could benefit from having the inputmode attribute be allowed on any editable piece of text. For the specific use case you cite, an additional keyword of none might make sense too. It possibly wouldn't hurt to have the placeholder attribute be available on all editable content, too. I'm less sure about the validation attributes (except perhaps required) but why not. Obviously validation attributes only make sense if the editable content can contribute to forms. But it would make a lot of sense that it could. Today you have to resort to ugly hacks in which you somehow copy over the edited content into a textarea. That's pretty daft: in most use cases you're going to be submitting the content. There are several ways in which we could handle this. One is to have any element with cE=minimal contribute to the form data set (when inside a form, or possibly when using the form attribute if someone remembers what the use case for that thing was). That's interesting, but I get a sense that it conflates two features. Another approach is to add a submittable attribute that can make the innerHTML of any element contribute to the form data set. Thoughts? -- Robin Berjon - http://berjon.com/ - @robinberjon
RE: contentEditable=minimal
+Gary and Masayuki --This seems very related to the discussion we are having regarding when to fire beforeinput. beforeinput might be duplicating some of the use-cases that the insertText command event might be supporting. -Original Message- From: Robin Berjon [mailto:ro...@w3.org] Sent: Tuesday, May 27, 2014 2:39 AM To: Ben Peters; Julie Parent Cc: Johannes Wilm; public-webapps@w3.org Subject: Re: contentEditable=minimal On 27/05/2014 01:52 , Ben Peters wrote: From: Robin Berjon [mailto:ro...@w3.org] On 23/05/2014 01:23 , Ben Peters wrote: As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted. But if you only get one event you can't render the composition as it is carrying out. I believe Composition Events are very important for IME input, but we should fire CommandEvent with Insert text for all text input, including IME. Are you saying we should use Composition Events even for non-IME input? I am not using an IME, and yet I could not type in French on my keyboard without composition. Obviously, if I switch to Kotoeri input, I'll get composition *and* an IME popup. But for regular French input (in a US keyboard) I need: é - Alt-E, E è - Alt-`, E à - Alt-`, A ô - Alt-I, O ü - Alt-U, U ñ - Alt-˜, N (for the occasional Spanish) (and a bunch more) Some older apps (you pretty much can't find them anymore) used to not display the composition as it was ongoing and only show the text after composition had terminated. That was survivable but annoying, and it only worked because composition in Latin-script languages is pretty trivial (except perhaps for all you Livonian speakers out there!), but I don't think it would be viable for more complex compositions. And even in simple cases it would confuse users to be typing characters with no rendering feedback. Without composition events you can't render the ongoing composition. See what's going on at: https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html-L81 That is basically inserting text in a range that's decorated to be underlined to show composition in progress. Composition updates *replace* the text in the range. And at the end the range is removed and text is inserted. The above is for Mac, but I have distant memories of using something similar on Windows called the US International Keyboard where you could have apostrophes compose as accents, etc.. I don't recall how it was rendered though. -- Robin Berjon - http://berjon.com/ - @robinberjon
RE: Composition events (was: contentEditable=minimal)
+Gary/Masayuki who can help with deciphering DOM L3 Events :-) -Original Message- From: Robin Berjon [mailto:ro...@w3.org] Sent: Tuesday, May 27, 2014 2:15 AM To: Ben Peters; Jonas Sicking Cc: public-webapps@w3.org Subject: Composition events (was: contentEditable=minimal) On 27/05/2014 01:52 , Ben Peters wrote: Composition Events for IMEs, CommandEvents with type insertText for all text input (including after Composition Events for IMEs) I think we should be careful not to mix up composition events and IMEs. They may happen together, but IMEs have their own specific issues (e.g. popping up a window) that inline composition does not necessarily have. Also, IMEs can happen without composition: you could arguably popup a handwriting IME that would just insert text on commit without any composition taking place. To stick to what I think is the simplest case, diacritic composition, here is what I believe the current D3E specification says (not that it's really clear on the matter, but I'm assuming best case scenario). For ñ you basically get: compositionstart ~ compositionend ñ From what you're saying above you'd like to replace that with: compositionstart ~ input ñ I think we can make that work, it drops on event and moves the code around. If you look at the Twitter Box code: https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html-L102 It basically would need to move what's in the compositionend handler inside the beforeinput handler, with a check to see if compoRange exists (or the event has isComposing=true). (I'm assuming that compositionupdate stays as is since we need to update the rendering with it.) Is that the sort of flow you had in mind? PS: note I just noticed that the code in the Gist was not the latest I had and had a lot of TODO bits - I've udpated it to the latest. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: Should minimal contentEditable default text input (was: contentEditable=minimal)
On Mon, May 26, 2014 at 4:17 AM, Yoshifumi Inoue yo...@chromium.org wrote: Range.style is cool idea! I assume Range.detach() removes styles added Range.style. detach() is a no-op. http://dom.spec.whatwg.org/#dom-range-detach To implement text composition with this, I would like to have wave underline, dotted underline, thick underline etc. Range.prototype.style seems complex in the context of overlapping ranges and such. Suddenly you're no longer applying CSS to a tree. -- http://annevankesteren.nl/
Re: contentEditable=minimal
On 26/05/2014 05:43 , Norbert Lindenberg wrote: On May 23, 2014, at 5:19 , Robin Berjon ro...@w3.org wrote: Which brings me to think: when we discussed this at the Summit, there was some agreement (between all four of us :) that it was a good idea to support multi-range selections. These are useful not just for tables, but also for bidi. The reason for the latter is that when selecting a line with multiple embedded directions (using a mouse), you want to have the visual selection be an unbroken line (as opposed to the crazy jumping around you get if you follow logical order). Were any speakers of bidirectional languages in the room when this was discussed? I don't know what languages the others speak. That said, my recollection was that this was presented along the lines of we've had regular requests to support selecting text in geometric rather than logical orders. If that turns out not to be the case and we can stick to single-range selections, it would certainly make the Selection API simpler. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On May 23, 2014, at 5:19 , Robin Berjon ro...@w3.org wrote: Which brings me to think: when we discussed this at the Summit, there was some agreement (between all four of us :) that it was a good idea to support multi-range selections. These are useful not just for tables, but also for bidi. The reason for the latter is that when selecting a line with multiple embedded directions (using a mouse), you want to have the visual selection be an unbroken line (as opposed to the crazy jumping around you get if you follow logical order). Were any speakers of bidirectional languages in the room when this was discussed? Norbert
RE: contentEditable=minimal
5. There should be no native toolbars in cE=minimal (and other native UI interfering) like the one Safari opens on iOS if you have non-empty selection. I haven't yet checked exactly what's in the iOS toolbar, but generally I don't think we should dictate UI. Clearly on mobile we don't want to forbid browsers to bring up the virutal keyboard, which is a form of native UI. And the spellcheck UI that safari displays also doesn't seem bad if spellchecking is enabled. And UI for cut/copy/past that android renders seems good to render *somewhere* when there's selection. On iOS the contextual toolbar not only contains copy/cut options which are of course ok, but it also contains bold, italic and lists buttons. That's unacceptable and I assume this kind of native UI will not be implemented for cE=minimal. The goal of Command Event is to make this a non-issue. If sites respond to bold/italic/list commands they can handle this UI just fine. Are you concerned that a site may not use bold so the button would have no effect?
RE: contentEditable=minimal
-Original Message- From: Robin Berjon [mailto:ro...@w3.org] Sent: Monday, May 26, 2014 1:41 AM To: Norbert Lindenberg Cc: Jonas Sicking; Piotr Koszuliński; Ben Peters; public-webapps Subject: Re: contentEditable=minimal On 26/05/2014 05:43 , Norbert Lindenberg wrote: On May 23, 2014, at 5:19 , Robin Berjon ro...@w3.org wrote: Which brings me to think: when we discussed this at the Summit, there was some agreement (between all four of us :) that it was a good idea to support multi-range selections. These are useful not just for tables, but also for bidi. The reason for the latter is that when selecting a line with multiple embedded directions (using a mouse), you want to have the visual selection be an unbroken line (as opposed to the crazy jumping around you get if you follow logical order). Were any speakers of bidirectional languages in the room when this was discussed? I don't know what languages the others speak. That said, my recollection was that this was presented along the lines of we've had regular requests to support selecting text in geometric rather than logical orders. If that turns out not to be the case and we can stick to single-range selections, it would certainly make the Selection API simpler. I have also heard these requests from the bi-directional experts here at Microsoft. A single, unbroken selection is what we're told users want, and multi-selection makes this possible.
RE: contentEditable=minimal
-Original Message- From: Robin Berjon [mailto:ro...@w3.org] On 23/05/2014 01:23 , Ben Peters wrote: As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted. But if you only get one event you can't render the composition as it is carrying out. I believe Composition Events are very important for IME input, but we should fire CommandEvent with Insert text for all text input, including IME. Are you saying we should use Composition Events even for non-IME input?
RE: contentEditable=minimal
From: Robin Berjon [mailto:ro...@w3.org] On 23/05/2014 11:55 , Jonas Sicking wrote: On Thu, May 22, 2014 at 3:59 AM, Piotr Koszuliński 5. Navigating with arrow keys, selection with SHIFT, CTRL modifier. Agreed. Developers have to deal with selection moving around anyway since they should handle touch screens. Even without accounting for touch screens, you really want the platform to be the thing that knows what Ctrl-Shift-Left means so you don't have to support it yourself (and get it wrong often). Agree. One way to do this would be BeforeSelectionChange having a commandType indicating select forward and select by word. But we should definitely fire events whenever cursor or selection is moved and enable the page to either cancel the movement, or adjust the location before it takes effect. Agreed. I also think that it is important that if the selection is allowed to have anchors both inside and outside the editing area then the editing MUST NOT retain focus. Anything else would lead to really annoying cases. Note: you keep saying things like cursor or selection. Can we agree that they are the same thing? A caret on its own is a selection with a single collapsed range (and a direction). Yes please:) Cursor and selection are the same thing. I think there might be a lot of boiler plate needed to implement plaintext editing. Not only are there normal beforeinput events to take into account. There's also things like composition events, backspace vs. delete, modifier+backspace/delete (deleting a word/line), voice-to-text input (provides data word-by-word), pasting, (bidi?), etc. It adds up pretty quickly. Not all of those are separate, though. Voice input is just an input (or beforeinput) that's more than one character long. There's nothing wrong with that. So is pasting (though you need cleaning up). Composition you need to handle, but I would really, really hope that the platform gives you a delete event with a range that matches what it is expected to delete rather than have you support all the modifiers (which you'll get wrong for the user as they are platform specific). As seen in the code gist I posted, given such a delete event the scripting is pretty simple. I agree, except that I don't know why we want paste to fire two 'intention' events (paste and input). Seems like we should make it clear that the intention is insert text (type, voice, whatever), remove text (delete, including what text to remove), or paste (so you can clean it up). -Ben
Re: contentEditable=minimal
native UI interfering) like the one Safari opens on iOS if you have non-empty selection. I haven't yet checked exactly what's in the iOS toolbar, but generally I don't think we should dictate UI. Clearly on mobile we don't want to forbid browsers to bring up the virutal keyboard, which is a form of native UI. And the spellcheck UI that safari displays also doesn't seem bad if spellchecking is enabled. And UI for cut/copy/past that android renders seems good to render *somewhere* when there's selection. Regarding text entry, I think this is the really hard decision that we need to make. I.e. should we only fire enough semantic input events, or also implement plaintext editing in addition. One interesting question is: Are pages generally happy with the plaintext editing of input type=text and textarea? Or do they find themselves often having to override their behavior using the events that browsers fire? What are the use cases of events like compositionstart and compositionend? Were they added in order to enable webpages to override composition related editing of input type=text and textarea? What about the beforeinput event? I think there might be a lot of boiler plate needed to implement plaintext editing. Not only are there normal beforeinput events to take into account. There's also things like composition events, backspace vs. delete, modifier+backspace/delete (deleting a word/line), voice-to-text input (provides data word-by-word), pasting, (bidi?), etc. It adds up pretty quickly. Some of these things pages will have to deal with no matter what. As has been pointed out, if the user selects across multiple elements and presses delete or 'a', then almost certainly the page will have to run application logic. Likewise if the cursor is placed right after an element but before a bunch of text, and the user then presses backspace. However it seems like if authors generally are ok with the plaintext editing that input type=text and textarea has, and then only have them worry about things like inserting elements to do styling or inserting document structure (lists, headers, paragraphs, etc), then that means less work for the author, and greater likelihood that text editing works as the user expects. I suspect that the right thing to do here is some experimentation. It would be very interesting to do a prototype implementation of contenteditable=minimal which never did any DOM mutations, not even for IME or text editing. Then see how much code needs to handle all of the plaintext editing features above. I'd also be interested trying out having the browser perform plain-text DOM mutations but make sure to keep the rules very simple. So if you select a stretch of text and press delete, we would not do any DOM mutation (or possibly we could delete just any text content, possibly leaving elements empty). Then see how much of a pain it would be to allow the page to apply its own rules like ensure all characters are lowercase or insert thousand separators in numbers or do syntax highlighting of JS code. Another thing that we should look at is the ability to style ranges rather than just elements. In Gecko we have an internal feature that allows us to style DOMRanges. This allows us to render a red dotted line under misspelled words and black line under composition characters. And do that without worrying about managing a lot of extra elements in the DOM. Right now pages are forced to sprinkle elements all over the DOM in order to do the same thing, which then makes editing that DOM more complex. It would be awesome to find ways to enable styling ranges which would allow them to keep a simpler DOM. / Jonas -- Piotrek Koszuliński CKEditor JavaScript Lead Developer -- CKSource - http://cksource.com -- Follow CKEditor on: Twitter http://twitter.com/ckeditor | Facebookhttp://www.facebook.com/ckeditor| Google+ https://plus.google.com/107736718646302128806 | LinkedInhttp://www.linkedin.com/company/cksource
Re: contentEditable=minimal
6. Spell check. When you want a native spell check you cannot override context menu. When you want custom context menu, you need custom spell check (which is extremely hard). And context menu is very important for many users because they used to look there for contextual options, so most editors override it. Therefore, a way control at least one of them (I guess it won't be a context menu, though that would be awesome) will be great. There's already a contextmenu feature in HTML, though I don't know if any other browser than Firefox implements it. And the spec has seen so much changes that I don't know how closely Firefox conforms to the spec. Anyhow, I think the ability to extend/replace the existing context menu is the way to go if that's what people need. Do you mean: http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#context-menus ? I didn't know about it. It doesn't seem to work on any browser yet, but it should be able to solve our problems. I hope it will be implemented soon. 5. There should be no native toolbars in cE=minimal (and other native UI interfering) like the one Safari opens on iOS if you have non-empty selection. I haven't yet checked exactly what's in the iOS toolbar, but generally I don't think we should dictate UI. Clearly on mobile we don't want to forbid browsers to bring up the virutal keyboard, which is a form of native UI. And the spellcheck UI that safari displays also doesn't seem bad if spellchecking is enabled. And UI for cut/copy/past that android renders seems good to render *somewhere* when there's selection. On iOS the contextual toolbar not only contains copy/cut options which are of course ok, but it also contains bold, italic and lists buttons. That's unacceptable and I assume this kind of native UI will not be implemented for cE=minimal. Another thing that we should look at is the ability to style ranges rather than just elements. In Gecko we have an internal feature that allows us to style DOMRanges. This allows us to render a red dotted line under misspelled words and black line under composition characters. And do that without worrying about managing a lot of extra elements in the DOM. Right now pages are forced to sprinkle elements all over the DOM in order to do the same thing, which then makes editing that DOM more complex. It would be awesome to find ways to enable styling ranges which would allow them to keep a simpler DOM. Wow! Such feature would be awesome. This reminds me about an idea mentioned in https://medium.com/medium-eng/122d8a40e480 that cE could be reimplemented with shadow DOM. It would be extremely powerful if caret and selection and styled ranges were real, accessible elements. Which brings me to think: when we discussed this at the Summit, there was some agreement (between all four of us :) that it was a good idea to support multi-range selections. These are useful not just for tables, but also for bidi. The reason for the latter is that when selecting a line with multiple embedded directions (using a mouse), you want to have the visual selection be an unbroken line (as opposed to the crazy jumping around you get if you follow logical order). It's definitely useful, though it does come with its problems. The question that opens up for me is: do we want to support multi-caret editing as well? The data model certainly supports it, but we have to account for it early if it's an option. At any rate, multi-range selections would be much easier to handle if we had something like Selection.forEachRange(function (r) {...}). Uh... multi-range selections. I find myself and my colleagues ignoring them. They add so much complexity to already complex tasks that we simply handle first range and ignore other. And I don't remember complains about that. They make some sense when selecting table columns but this is not a necessary feature and may be also handled by an editor by fake selection. Multiple carets are useful in code editors, but not a single text editor's end user know about them (and I believe they were removed from Firefox). I don't know the bidi case though. But if it could be handled without multi-range selections I would gladly forget about them. -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: contentEditable=minimal
* Cursor navigation, including reacting to touch events, mouse clicks and keyboard events. Cursor navigation would likely also fire cancelable events. Yes. Cursor navigation can be represented through selections (that may be collapsed). In general it is important that selection changes can be cancelled so that developers can carry out selection validation before accepting it. Making some things unselectable might also be useful. IE has unselectable, there's also -moz-user-select and friends. But this is small fries for later I'd reckon. There are also nested non-editable islands. We built very important feature based on them - http://ckeditor.com/demo#widgets. Currently we block their selection by preventing mousedown and we handle left/right arrows. But cancelling selectionchange would allow us to control more cases in a cleaner way. -- Piotrek Koszuliński CKEditor JavaScript Lead Developer
Re: Should minimal contentEditable default text input (was: contentEditable=minimal)
Range.style is cool idea! I assume Range.detach() removes styles added Range.style. To implement text composition with this, I would like to have wave underline, dotted underline, thick underline etc. Example:: http://www.w3.org/TR/2012/WD-ime-api-20120524/images/image13.png Also, we can use Range.style for highlighting find result and spelling error. -yosi On Fri, May 23, 2014 at 8:39 PM, Robin Berjon ro...@w3.org wrote: Starting a new thread for this specific topic as I think it's one of the important early points of contention. On 22/05/2014 12:59 , Piotr Koszuliński wrote: 3. Typing characters. It works in textarea and I think it should work out of the box in cE=minimal. Otherwise, cE=minimal will be useless for simple cases (mentioned Twitter), because you'll always need a pretty complex library to handle text input. Additionally, I don't remember any problem with typing characters, so this seems to work well already in cE=true. There's also the IME which scares me, but I don't have any experience with it. I hear your point about essentially making simple things simple, but I really want to resist supporting as much built-in behaviour as possible. Of course, it's a trade-off, but I think we should strive for the smallest possible amount of behaviour. Note that 1) the complexity of simple things by and large depends on the quality of the primitives we provide and 2) on the interoperability of what is supported. And the simpler the functionality, the more easily interoperable. Inserting text as the default behaviour for text input events has implications: Things get very weird if you support it when you have a caret (i.e. a collapsed selection) but not when you have a selection. And a selection can have arbitrary endpoints around and into an element. This means that typing with an active selection can do more than add some text to a node: it can delete or modify elements. Sure enough this can be described interoperably, but it does bring us back to issues we dislike. It also means that the browser needs to handle composition and its rendering, which while it is ongoing may produce relatively weird states in the DOM. I agree that the Twitter box is a good very basic example. It basically needs: 1) Words that start with @ or # to be a specific colour. 2) Links to be a different colour, and to have their characters counted as the shortened link rather than the full thing. 3) Newlines must be taken into account. 4) Characters beyond 140 are highlighted in red. I'm ignoring complications with files and the such. In fact, for the purpose of our use case it is only useful IMHO to look at how best to handle (3) and (4). I tried to bang together some code that would do the Twitter box, adding a few features along the way and documenting assumptions and issues. It looks like that (untested, off the top of my head): https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html It looks a bit scary, but if you remove the part that handles excess text and the wordy comments, you just get: https://gist.github.com/darobin/8a128f05106d0e02717b# file-like-textarea-html Granted, that's still a fair bit of boilerplate. But I think we have to take into account the following: • This is meant to be low-level. I'm happy to make things easier but only so long as we don't introduce magic. • We can make introduce some convenience methods for the non-obvious parts of the boilerplate. Just having Selection.replace(node|text...) or something like new Range(sNode, sOffset, eNode, eOffset) would make things a lot nicer. It's likely I've forgotten stuff though (notably paste filtering, which I'm unsure how to best handle here — see comments). Please review the code so that we have an idea for a baseline of what we'd like to get at the end. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On Thu, May 22, 2014 at 3:59 AM, Piotr Koszuliński p.koszulin...@cksource.com wrote: ## What should cE=minimal handle? Awesome feedback! ## What should cE=minimal handle? 1. Selection and caret drawing. 2. Selection API Agreed on both! 3. Typing characters. 4. Delete, backspace. I think these are the hard ones. More below. 5. Navigating with arrow keys, selection with SHIFT, CTRL modifier. Agreed. Developers have to deal with selection moving around anyway since they should handle touch screens. But we should definitely fire events whenever cursor or selection is moved and enable the page to either cancel the movement, or adjust the location before it takes effect. 6. Spell check. When you want a native spell check you cannot override context menu. When you want custom context menu, you need custom spell check (which is extremely hard). And context menu is very important for many users because they used to look there for contextual options, so most editors override it. Therefore, a way control at least one of them (I guess it won't be a context menu, though that would be awesome) will be great. There's already a contextmenu feature in HTML, though I don't know if any other browser than Firefox implements it. And the spec has seen so much changes that I don't know how closely Firefox conforms to the spec. Anyhow, I think the ability to extend/replace the existing context menu is the way to go if that's what people need. Adding spellchecking primitivies, and forcing webpages to implement their own spellcheck, seems like the wrong way to go about enabling pages to do their own context menus. ## What should not be handled by cE=minimal? 1. Bold, italic, list, link, blockquote and other commands creating content. 2. Enter key support. 3. Tables and images resizing. 4. Another thing that browser engines cannot do is trying to be... too smart? Strongly agree with all of these. 5. There should be no native toolbars in cE=minimal (and other native UI interfering) like the one Safari opens on iOS if you have non-empty selection. I haven't yet checked exactly what's in the iOS toolbar, but generally I don't think we should dictate UI. Clearly on mobile we don't want to forbid browsers to bring up the virutal keyboard, which is a form of native UI. And the spellcheck UI that safari displays also doesn't seem bad if spellchecking is enabled. And UI for cut/copy/past that android renders seems good to render *somewhere* when there's selection. Regarding text entry, I think this is the really hard decision that we need to make. I.e. should we only fire enough semantic input events, or also implement plaintext editing in addition. One interesting question is: Are pages generally happy with the plaintext editing of input type=text and textarea? Or do they find themselves often having to override their behavior using the events that browsers fire? What are the use cases of events like compositionstart and compositionend? Were they added in order to enable webpages to override composition related editing of input type=text and textarea? What about the beforeinput event? I think there might be a lot of boiler plate needed to implement plaintext editing. Not only are there normal beforeinput events to take into account. There's also things like composition events, backspace vs. delete, modifier+backspace/delete (deleting a word/line), voice-to-text input (provides data word-by-word), pasting, (bidi?), etc. It adds up pretty quickly. Some of these things pages will have to deal with no matter what. As has been pointed out, if the user selects across multiple elements and presses delete or 'a', then almost certainly the page will have to run application logic. Likewise if the cursor is placed right after an element but before a bunch of text, and the user then presses backspace. However it seems like if authors generally are ok with the plaintext editing that input type=text and textarea has, and then only have them worry about things like inserting elements to do styling or inserting document structure (lists, headers, paragraphs, etc), then that means less work for the author, and greater likelihood that text editing works as the user expects. I suspect that the right thing to do here is some experimentation. It would be very interesting to do a prototype implementation of contenteditable=minimal which never did any DOM mutations, not even for IME or text editing. Then see how much code needs to handle all of the plaintext editing features above. I'd also be interested trying out having the browser perform plain-text DOM mutations but make sure to keep the rules very simple. So if you select a stretch of text and press delete, we would not do any DOM mutation (or possibly we could delete just any text content, possibly leaving elements empty). Then see how much of a pain it would be to allow the page to apply its own rules like ensure all characters are lowercase or insert
Re: contentEditable=minimal
On 23/05/2014 01:23 , Ben Peters wrote: As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted. But if you only get one event you can't render the composition as it is carrying out. -- Robin Berjon - http://berjon.com/ - @robinberjon
Should minimal contentEditable default text input (was: contentEditable=minimal)
Starting a new thread for this specific topic as I think it's one of the important early points of contention. On 22/05/2014 12:59 , Piotr Koszuliński wrote: 3. Typing characters. It works in textarea and I think it should work out of the box in cE=minimal. Otherwise, cE=minimal will be useless for simple cases (mentioned Twitter), because you'll always need a pretty complex library to handle text input. Additionally, I don't remember any problem with typing characters, so this seems to work well already in cE=true. There's also the IME which scares me, but I don't have any experience with it. I hear your point about essentially making simple things simple, but I really want to resist supporting as much built-in behaviour as possible. Of course, it's a trade-off, but I think we should strive for the smallest possible amount of behaviour. Note that 1) the complexity of simple things by and large depends on the quality of the primitives we provide and 2) on the interoperability of what is supported. And the simpler the functionality, the more easily interoperable. Inserting text as the default behaviour for text input events has implications: Things get very weird if you support it when you have a caret (i.e. a collapsed selection) but not when you have a selection. And a selection can have arbitrary endpoints around and into an element. This means that typing with an active selection can do more than add some text to a node: it can delete or modify elements. Sure enough this can be described interoperably, but it does bring us back to issues we dislike. It also means that the browser needs to handle composition and its rendering, which while it is ongoing may produce relatively weird states in the DOM. I agree that the Twitter box is a good very basic example. It basically needs: 1) Words that start with @ or # to be a specific colour. 2) Links to be a different colour, and to have their characters counted as the shortened link rather than the full thing. 3) Newlines must be taken into account. 4) Characters beyond 140 are highlighted in red. I'm ignoring complications with files and the such. In fact, for the purpose of our use case it is only useful IMHO to look at how best to handle (3) and (4). I tried to bang together some code that would do the Twitter box, adding a few features along the way and documenting assumptions and issues. It looks like that (untested, off the top of my head): https://gist.github.com/darobin/8a128f05106d0e02717b#file-twitter-html It looks a bit scary, but if you remove the part that handles excess text and the wordy comments, you just get: https://gist.github.com/darobin/8a128f05106d0e02717b#file-like-textarea-html Granted, that's still a fair bit of boilerplate. But I think we have to take into account the following: • This is meant to be low-level. I'm happy to make things easier but only so long as we don't introduce magic. • We can make introduce some convenience methods for the non-obvious parts of the boilerplate. Just having Selection.replace(node|text...) or something like new Range(sNode, sOffset, eNode, eOffset) would make things a lot nicer. It's likely I've forgotten stuff though (notably paste filtering, which I'm unsure how to best handle here — see comments). Please review the code so that we have an idea for a baseline of what we'd like to get at the end. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On 23/05/2014 12:28 , Jonas Sicking wrote: And on mobile autocorrect of misspelled words is common, though that can probably be handled by moving the selection to the misspelled word and then writing the fixed word. Autocorrect should be handled like composition. Composition is pretty much what happens whenever you type some stuff and some other stuff comes out. (Technical definition.) Though one interesting edge case there is what happens if the page adjusts the selection as it's being moved to the word autocorrect wants to fix? I'm sorry, I don't understand the case you're thinking of? -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
you'll get wrong for the user as they are platform specific). As seen in the code gist I posted, given such a delete event the scripting is pretty simple. Some of these things pages will have to deal with no matter what. As has been pointed out, if the user selects across multiple elements and presses delete or 'a', then almost certainly the page will have to run application logic. Likewise if the cursor is placed right after an element but before a bunch of text, and the user then presses backspace. However it seems like if authors generally are ok with the plaintext editing that input type=text and textarea has, and then only have them worry about things like inserting elements to do styling or inserting document structure (lists, headers, paragraphs, etc), then that means less work for the author, and greater likelihood that text editing works as the user expects. I'm sorry, but I'm not sure that the above makes sense :) If people want plain text and *nothing* else, I have a great solution for them: textarea. If you have a situation that involves markup however, you need to handle it. And I really, really don't think that we will be doing anyone a service if we end up with a solution in which the browser will handle text for you UNLESS you have an element-spanning selection OR MAYBE backspace right after an element AND PERHAPS delete right before one, etc. in which case you have to run some application logic. Maybe I'm missing something and there's an easy way to disambiguate here, but it seems like the sort of path down which madness lies. Do you have some code to illustrate how it would work? I suspect that the right thing to do here is some experimentation. It would be very interesting to do a prototype implementation of contenteditable=minimal which never did any DOM mutations, not even for IME or text editing. Then see how much code needs to handle all of the plaintext editing features above. I think we can get a feel for that without having to polyfill cEmin first. That would be neat of course, but given the poor support of even very basic things like selections it's not a small project. Another thing that we should look at is the ability to style ranges rather than just elements. In Gecko we have an internal feature that allows us to style DOMRanges. This allows us to render a red dotted line under misspelled words and black line under composition characters. And do that without worrying about managing a lot of extra elements in the DOM. Yeah, I had the same idea, used it in my example. I think it makes a lot of sense. Right now pages are forced to sprinkle elements all over the DOM in order to do the same thing, which then makes editing that DOM more complex. It would be awesome to find ways to enable styling ranges which would allow them to keep a simpler DOM. It would actually be pretty awesome. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On Fri, May 23, 2014 at 4:43 AM, Robin Berjon ro...@w3.org wrote: On 23/05/2014 12:28 , Jonas Sicking wrote: And on mobile autocorrect of misspelled words is common, though that can probably be handled by moving the selection to the misspelled word and then writing the fixed word. Autocorrect should be handled like composition. Composition is pretty much what happens whenever you type some stuff and some other stuff comes out. (Technical definition.) I sadly don't think it's that simple. When compositing chinese characters, or characters like ü, an underline should be rendered during the composition and then removed once a character (or set of characters) is selected. This underline should not appear when typing on a mobile keyword, even if it supports autocorrect. It's not clear to me if the difference is just one of styling, or if there are semantic differences as well. Though one interesting edge case there is what happens if the page adjusts the selection as it's being moved to the word autocorrect wants to fix? I'm sorry, I don't understand the case you're thinking of? My assertion is that we don't want to use compositing events when typing on a keyboard which has autocorrect. (This might be a wrong assertion in which case none of this matters). Rather than composition events we fire events like: insert 'c' insert 'a' insert 'g' selection moved to start at index 0 and end at index 3 insert 'cat' insert ' ' However we've previously said that pages should be able to cancel or adjust selection moves. The question is what happens if the page changes the selection when autocorrect attempts to select the word to be fixed. / Jonas
Re: contentEditable=minimal
On Thu, May 1, 2014 at 5:31 PM, Ben Peters ben.pet...@microsoft.com wrote: Proposal To make this simpler for sites, frameworks, and browsers, it makes sense to enable a new, simpler version of contentEditable that provides basic functionality only. For the sake of discussion, call it contentEditable='minimal'. The functionality provided by the browser under contentEditable='minimal' would be as follows: * Caret drawing * Events such as Keyboard , Clipboard, Drag and Drop * Some keyboard input handling- caret movement, typing of characters including Input Method Editor input * Selection drawing and manipulation according to the new Selection API spec This sounds like a super promising approach. If I understand the proposal correctly, when the user does something that causes input, like pressing the enter key, we would fire a key event, but we wouldn't actually modify the DOM. Modifying the DOM would be the responsibility of the web page. Likewise, if the user pressed whatever key is platform convention for paste, we would fire an event which contains the clipboard data, but not mutate the DOM. Copying data from the event (i.e. from the clipboard) to the page would be the responsibility of the page. Is that correct? If so I like it a lot! I'd like to expand, and clarify, the list of services that you propose that the UA provides: * Caret and selection drawing. * Drawing IME UI in response to user typing. * Events for clipboard and drag'n'drop (though the UA would not mutate the DOM in response to those events). * Cursor navigation, including reacting to touch events, mouse clicks and keyboard events. Cursor navigation would likely also fire cancelable events. * Turning keyboard events into events representing text input (but not mutate the DOM in response to those events). * The Selection API spec for selection manipulation. I.e. pressing a key on the keyboard would always fire a keyboard event, and then, as default action, possibly a cursor navigation event or a text input event, depending on what type of key was pressed. I'm unsure about what the proper way to handle text insertion is. I.e. how to handle the second to last bullet. Can we simply use the same events as we fire in input type=text and textarea, but don't actually mutate any DOM? Or is it awkward to fire beforeinput when there is no default action of mutating the DOM and firing input? And is it too much complexity to ask pages to deal with composition handling themselves? Another approach would be to allow plain text input events to actually mutate the DOM as a default action. But allow that action to be cancelled. Note that we would never do anything more complex than mutate an existing text node, or insert a text node where the cursor is located. I.e. no elements would ever get added, removed, split, have attributes changed or otherwise be mutated. But if we can make the code that a page needs to write in order to handle the text mutation relatively simple, even when handling composition, then I think we should leave it up to the page. / Jonas
Re: contentEditable=minimal
On 22/05/2014 00:43 , Julie Parent wrote: I question whether contentEditable=minimal should actually handle text input. If the idea is to provide the base platform on which a developer can build the editing product of their dreams, isn't text insertion just another behavior they could potentially need to disable? Sorry if I was unclear. When I said handling text input, I did not mean text insertion. My point is that there's a spectrum of behaviour and we want to provide *some* handling for developers (otherwise it's really just too hard). Let us take the relatively simple issue with typing ñ on a keyboard setup that does not natively support the character. On my keyboard, that is done by first typing Alt-N, then N. At the more complete end of the spectrum, what we have today, without the developer doing anything, when I type Alt-N the DOM is modified to include a U+02DC SMALL TILDE (note: *not* U+0303 COMBINING TILDE) and that character is underlined in the rendering to let me know that it is awaiting a character to combine with. Interestingly, that information is not reflected in the DOM — I don't even know how you can handle it. In fact, editors that try to take over too much from the platform (in this case, Substance for instance) completely fail to allow this sort of text entry. At completely the other end of the spectrum (more or where developers find themselves today when they override as much as they can, out in the cold), all you get are two entirely independent keyboard events: one N with altKey set to true, and another N with altKey set to false. Unless you know all platform conventions (plus the user's keyboard layout) or you manage to enforce your own, which isn't friendly to users, you can't do anything useful with that. What I meant by having the browser handle text input, is that it needs to know the platform conventions so as to convey user intent to to the application correctly. When I hit Alt-N then N, the UA should relay something that looks like the following events (I'm deliberately not including keyup/down/etc. for simplicity): compositionstart \u0303 (combining tilde) compositionupdate ñ compositionend ñ (We might be able to do without the compositionupdate in this case, I'm including it because for more elaborate compositions it's needed.) I believe that this provides the appropriate level of abstraction to address the use case. Without the composition events (e.g. if you only send a text input event) the developer can't show the composition in progress to the user (which for complex compositions like Kotoeri is a non-starter); and with these events developers don't need to know about the platform's conventions for composition. Orthogonality is where it should be. As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. Stepping back, there are distinct concepts that all combine to form the current editing environment: 1. Selections: Enable selections, perform cursor movement, scoping the boundaries on which the selection can operate. 2. Input: Perform dom modifications, dispatch events, not limited to keyboard input, also includes IME, paste, drop, etc. 3. Spell check: Enable spell check, modify the dom (or dispatch an event) when the user selects a replacement 4. Formatting magic: bold when the user hits control + b, change directionality on Ctrl+LeftShift , etc. It sounds like contentEditable=minimal as proposed would only enable #1 and #2, and perhaps allow for #3? To break editing down into true building blocks, I think we need to provide developers a way to explicitly enable each of these systems separably, and not require the element to be contentEditable. My understanding (but this is all up for discussion, hence this thread) is that cE=minimal would only enable 1 (which is essentially enabling cursor as selections are already there anyway). All the other parts are handled by other pieces of functionality that may work elsewhere too (and in fact do, e.g. in input elements). The way I thought of cE=minimal when I pitched it at the Extensible Web Summit was basically regular HTML with a caret affordance. The exact behaviour of the caret is platform dependent (and may not be visual), it is only the way in which it is reported (in terms of the Selection API) to the application that matters. It makes for a pretty short spec — the previous paragraph is more than enough ;) -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
On 22/05/2014 10:52 , Jonas Sicking wrote: This sounds like a super promising approach. \o/ If I understand the proposal correctly, when the user does something that causes input, like pressing the enter key, we would fire a key event, but we wouldn't actually modify the DOM. Modifying the DOM would be the responsibility of the web page. That is the point yes. Using the DOM as both the model and view does not make sense for all editing, and this makes it possible to separate the two without hacks that override the browser. Your example of the enter key is, of course, one of the annoying ones. Sometimes you want a new line, sometimes you want the next element, sometimes you just want to navigate to the cell below. Enter may be a case in which a higher-level event is required so that you can respect the platform's convention for Enter vs Ctrl-Enter for instance. Likewise, if the user pressed whatever key is platform convention for paste, we would fire an event which contains the clipboard data, but not mutate the DOM. Copying data from the event (i.e. from the clipboard) to the page would be the responsibility of the page. Is that correct? If so I like it a lot! Entirely correct. Again, \o/. I'd like to expand, and clarify, the list of services that you propose that the UA provides: * Caret and selection drawing. Yes. And reporting that information accurately to the application (which can be pretty tricky for multi-range selections in tables or at bidi boundaries). cE=minimal enables caret drawing, the rest is done through the Selection API. * Drawing IME UI in response to user typing. Where applicable, yes. I would expect the IME API to play well here. * Events for clipboard and drag'n'drop (though the UA would not mutate the DOM in response to those events). Yes. ClipOps and DnD APIs. * Cursor navigation, including reacting to touch events, mouse clicks and keyboard events. Cursor navigation would likely also fire cancelable events. Yes. Cursor navigation can be represented through selections (that may be collapsed). In general it is important that selection changes can be cancelled so that developers can carry out selection validation before accepting it. Making some things unselectable might also be useful. IE has unselectable, there's also -moz-user-select and friends. But this is small fries for later I'd reckon. * Turning keyboard events into events representing text input (but not mutate the DOM in response to those events). Yes, possibly in a rather advanced manner. * The Selection API spec for selection manipulation. Right. Can we simply use the same events as we fire in input type=text and textarea, but don't actually mutate any DOM? Or is it awkward to fire beforeinput when there is no default action of mutating the DOM and firing input? Isn't that just a question of whether to reuse the same event name or pick a new one? And is it too much complexity to ask pages to deal with composition handling themselves? I think it's too much to ask for them to deal with composition, but they should deal with composition events. See my earlier posts for details. Dealing with composition events is certainly a bit of effort (not much though — the hardest part is knowing they exist) but we want to go low-level here. I think it's an acceptable level of complexity for library authors. Another approach would be to allow plain text input events to actually mutate the DOM as a default action. But allow that action to be cancelled. Note that we would never do anything more complex than mutate an existing text node, or insert a text node where the cursor is located. I.e. no elements would ever get added, removed, split, have attributes changed or otherwise be mutated. I don't think you can do that without ending up weird places. No elements would ever get mutated - what happens if I have a selection that contains an element (or parts of it)? Very quickly you'd end up either having to make the browser manipulate the DOM yourself (bad, really really bad), or in a situation in which some text events have a default action and some don't depending on the current state of the selection (possibly even worse). It's very tempting to try to do more for developer here, but I really think we should resist this impulse lest we end up with the a new mess that just works differently. But if we can make the code that a page needs to write in order to handle the text mutation relatively simple, even when handling composition, then I think we should leave it up to the page. I think that we can make it reasonably easy to handle composition by using composition events. -- Robin Berjon - http://berjon.com/ - @robinberjon
Re: contentEditable=minimal
Thanks Jonas for clarification. Now, I understand contentEditable=minmal doesn't modify DOM. For drawing IME UI, text composition, Blink inserts text node with text decoration to display on going text composition, IME UI. So, implementing contentEditable=minimal, Blink should remove text nodes at commit of text composition and dispatch text input event along with beforeinput.Is this correct? -yosi On Thu, May 22, 2014 at 5:52 PM, Jonas Sicking jo...@sicking.cc wrote: On Thu, May 1, 2014 at 5:31 PM, Ben Peters ben.pet...@microsoft.com wrote: Proposal To make this simpler for sites, frameworks, and browsers, it makes sense to enable a new, simpler version of contentEditable that provides basic functionality only. For the sake of discussion, call it contentEditable='minimal'. The functionality provided by the browser under contentEditable='minimal' would be as follows: * Caret drawing * Events such as Keyboard , Clipboard, Drag and Drop * Some keyboard input handling- caret movement, typing of characters including Input Method Editor input * Selection drawing and manipulation according to the new Selection API spec This sounds like a super promising approach. If I understand the proposal correctly, when the user does something that causes input, like pressing the enter key, we would fire a key event, but we wouldn't actually modify the DOM. Modifying the DOM would be the responsibility of the web page. Likewise, if the user pressed whatever key is platform convention for paste, we would fire an event which contains the clipboard data, but not mutate the DOM. Copying data from the event (i.e. from the clipboard) to the page would be the responsibility of the page. Is that correct? If so I like it a lot! I'd like to expand, and clarify, the list of services that you propose that the UA provides: * Caret and selection drawing. * Drawing IME UI in response to user typing. * Events for clipboard and drag'n'drop (though the UA would not mutate the DOM in response to those events). * Cursor navigation, including reacting to touch events, mouse clicks and keyboard events. Cursor navigation would likely also fire cancelable events. * Turning keyboard events into events representing text input (but not mutate the DOM in response to those events). * The Selection API spec for selection manipulation. I.e. pressing a key on the keyboard would always fire a keyboard event, and then, as default action, possibly a cursor navigation event or a text input event, depending on what type of key was pressed. I'm unsure about what the proper way to handle text insertion is. I.e. how to handle the second to last bullet. Can we simply use the same events as we fire in input type=text and textarea, but don't actually mutate any DOM? Or is it awkward to fire beforeinput when there is no default action of mutating the DOM and firing input? And is it too much complexity to ask pages to deal with composition handling themselves? Another approach would be to allow plain text input events to actually mutate the DOM as a default action. But allow that action to be cancelled. Note that we would never do anything more complex than mutate an existing text node, or insert a text node where the cursor is located. I.e. no elements would ever get added, removed, split, have attributes changed or otherwise be mutated. But if we can make the code that a page needs to write in order to handle the text mutation relatively simple, even when handling composition, then I think we should leave it up to the page. / Jonas
Re: contentEditable=minimal
Great news and a great idea. I totally second a concept of making contenteditable simpler and a lot more controllable for us, editors developers. Even if it would be possible to make cE=true interoperable, there are cases which depend on editor's logic. For example, in CKEditor Bold command may be totally blocked depending on content filter settings (you should not be able to create disallowed content). Similarly, enter, backspace/delete, end/home, undoredo, arrow keys, most of CTRL+ keystrokes, context menu, click-select - we already control them totally or at least in specific cases. And even if related features would become reliably stable, many times their behaviour should depend on editor's logic, configuration, and a use case in which editor is used. That's why a standard and reliable way to intercept them will be very helpful. Moreover, I understand very well how hard and time consuming maintaining cE implementation is. And currently we have 4 implementations - one in every browser engine. Then editors developers override significant amount of that work. This doesn't make sense. It would be beneficial for everyone if browser vendors could focus on the necessary minimum and editors developers on creating an editing framework and specific solutions on top of that. The frameworks would be something like jQuery for editable. They would simplify most common tasks, like applying Bold/Italic/etc styles, inserting HTML into selection, filtering, supporting enter key, etc. All of these operations are very complex and require rare knowledge about cE, selection, ranges and deep understanding of DOM. I was trying to imagine what cE=minimal would be then. CE=true pretends to be an entire WYSIWYG, from which you need to subtract the things which you don't like. CE=minimal could be the opposite - a textarea-like field. You would add your features to it rather than subtract from it. What's more, for some really basic use cases, like Twitter's compose tweet box, it would be a sufficient base without much additional code. ## What should cE=minimal handle? 1. Selection and caret drawing. 2. Selection API - I know that this is a separate topic, but in order to make building features on top of cE=minimal acceptably hard (and not extremely hard), the selection must be improved. I.e. selection in empty inline elements, selection in empty blocks, selection of non-editable (cE=false) content and nested editables, bogus brs, selection in tables, selection in multiple frames, etc. All those things are broken now. 3. Typing characters. It works in textarea and I think it should work out of the box in cE=minimal. Otherwise, cE=minimal will be useless for simple cases (mentioned Twitter), because you'll always need a pretty complex library to handle text input. Additionally, I don't remember any problem with typing characters, so this seems to work well already in cE=true. There's also the IME which scares me, but I don't have any experience with it. 4. Delete, backspace. Here I've got more doubts, because it's now broken in some engines (merging blocks, deleting inline elements, possibility to leave paragraph, etc.). But without native support for them cE=minimal requires JS implementation of them, and taking CTRL modifier into consideration, the implementation becomes big. So I think that delete and backspace should also work out of the box, but should implement the simplest possible algorithm, sufficient to work with paragraphs of text (Twitter case again). But their behaviour in lists, tables may be simplified, so the algorithm is generic and may not be good in terms of UX. That would be customised by editors that need tables and lists and other fancy features. Note: typing on a non-empty selection may trigger delete event + type event afterwards, so customising delete will customise typing. 5. Navigating with arrow keys, selection with SHIFT, CTRL modifier. Again, works in textarea, should work in cE=minimal. Additionally, implementing up/down keys in JavaScript seems to be extremely hard at the moment. 6. Spell check. When you want a native spell check you cannot override context menu. When you want custom context menu, you need custom spell check (which is extremely hard). And context menu is very important for many users because they used to look there for contextual options, so most editors override it. Therefore, a way control at least one of them (I guess it won't be a context menu, though that would be awesome) will be great. ## What should not be handled by cE=minimal? 1. Bold, italic, list, link, blockquote and other commands creating content. All of them are not crucial for simple cE=minimal use cases. Additionally, it's controversial whether b or strong, em or i, there are many ways how lists and blockquotes can be created out of selected contents, etc. You end up rewriting all of them if you need them in your editor. Therefore, I think it makes sense to not waste time trying to standardise them and then
Re: contentEditable=minimal
On 22/05/14 09:52, Jonas Sicking wrote: On Thu, May 1, 2014 at 5:31 PM, Ben Peters ben.pet...@microsoft.com wrote: Proposal To make this simpler for sites, frameworks, and browsers, it makes sense to enable a new, simpler version of contentEditable that provides basic functionality only. For the sake of discussion, call it contentEditable='minimal'. The functionality provided by the browser under contentEditable='minimal' would be as follows: * Caret drawing * Events such as Keyboard , Clipboard, Drag and Drop * Some keyboard input handling- caret movement, typing of characters including Input Method Editor input * Selection drawing and manipulation according to the new Selection API spec This sounds like a super promising approach. If I understand the proposal correctly, when the user does something that causes input, like pressing the enter key, we would fire a key event, but we wouldn't actually modify the DOM. Modifying the DOM would be the responsibility of the web page. Likewise, if the user pressed whatever key is platform convention for paste, we would fire an event which contains the clipboard data, but not mutate the DOM. Copying data from the event (i.e. from the clipboard) to the page would be the responsibility of the page. Is that correct? If so I like it a lot! I'd like to expand, and clarify, the list of services that you propose that the UA provides: * Caret and selection drawing. * Drawing IME UI in response to user typing. * Events for clipboard and drag'n'drop (though the UA would not mutate the DOM in response to those events). Ideally, we also would have events for undo and redo as generated by the browser's native UI, e.g. the chrome undo/redo menu items where these are provided by the browser. This is important as it allows a web page to manage its own undo/redo stack. * Cursor navigation, including reacting to touch events, mouse clicks and keyboard events. Cursor navigation would likely also fire cancelable events. * Turning keyboard events into events representing text input (but not mutate the DOM in response to those events). Yes, as this would allow browser based editors to take advantage of native input methods and avoid a dependency on the keyboard. * The Selection API spec for selection manipulation. I.e. pressing a key on the keyboard would always fire a keyboard event, and then, as default action, possibly a cursor navigation event or a text input event, depending on what type of key was pressed. I'm unsure about what the proper way to handle text insertion is. I.e. how to handle the second to last bullet. Can we simply use the same events as we fire in input type=text and textarea, but don't actually mutate any DOM? Or is it awkward to fire beforeinput when there is no default action of mutating the DOM and firing input? Getting the events, but not modifying the DOM sounds great. And is it too much complexity to ask pages to deal with composition handling themselves? No, but it is definitely something where a few excellent libraries would be expected to be widely used. Another approach would be to allow plain text input events to actually mutate the DOM as a default action. But allow that action to be cancelled. Note that we would never do anything more complex than mutate an existing text node, or insert a text node where the cursor is located. I.e. no elements would ever get added, removed, split, have attributes changed or otherwise be mutated. But if we can make the code that a page needs to write in order to handle the text mutation relatively simple, even when handling composition, then I think we should leave it up to the page. Simple text entry is easy, but Enter, Backspace and Delete are surprisingly hard, as I have found out in writing a cross browser library that takes over the handling of these keys, since my experiments showed that browsers varied in their treatment of them, and that browsers frequently don't behave in the way that people expect with common word processing software. -- Dave Raggett d...@w3.org http://www.w3.org/People/Raggett
RE: contentEditable=minimal
Let us take the relatively simple issue with typing ñ on a keyboard setup that does not natively support the character. On my keyboard, that is done by first typing Alt-N, then N. At the more complete end of the spectrum, what we have today, without the developer doing anything, when I type Alt-N the DOM is modified to include a U+02DC SMALL TILDE (note: *not* U+0303 COMBINING TILDE) and that character is underlined in the rendering to let me know that it is awaiting a character to combine with. Interestingly, that information is not reflected in the DOM — I don't even know how you can handle it. In fact, editors that try to take over too much from the platform (in this case, Substance for instance) completely fail to allow this sort of text entry. At completely the other end of the spectrum (more or where developers find themselves today when they override as much as they can, out in the cold), all you get are two entirely independent keyboard events: one N with altKey set to true, and another N with altKey set to false. Unless you know all platform conventions (plus the user's keyboard layout) or you manage to enforce your own, which isn't friendly to users, you can't do anything useful with that. What I meant by having the browser handle text input, is that it needs to know the platform conventions so as to convey user intent to to the application correctly. When I hit Alt-N then N, the UA should relay something that looks like the following events (I'm deliberately not including keyup/down/etc. for simplicity): compositionstart \u0303 (combining tilde) compositionupdate ñ compositionend ñ (We might be able to do without the compositionupdate in this case, I'm including it because for more elaborate compositions it's needed.) I believe that this provides the appropriate level of abstraction to address the use case. Without the composition events (e.g. if you only send a text input event) the developer can't show the composition in progress to the user (which for complex compositions like Kotoeri is a non-starter); and with these events developers don't need to know about the platform's conventions for composition. Orthogonality is where it should be. As I said I am unsure that the way in which composition events are described in DOM 3 Events is perfect, but that's only because I haven't used them in anger and they aren't supported much. My thought is that we can use CommandEvent with type=insertText. This would be the corollary to execComamnd(insertText), and the data would be the ñ that is about to be inserted.