-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should cE=events (or cE=whatever now) handle selection? #71
Comments
I think we need to depend on the selection API being in place. I can see it being attractive to replicate everything we need here, just to make sure that it's there when we need it, but currently it seems that the Selection API is more on track to getting into browsers than this spec. Also notice that this is supposed to be a first module, and later modules should then be able to remove large pieces of JavaScript polyfills. This is only supposed to be functional, not represent the ideal division of labor between browsers and JS editors. But maybe we can add some examples into the spec about how certain operations are done, and in those link to the Selection API spec, just to make sure that UA developers get the point. |
And as you can see from this discussion: #52 , we added two extra intentions connected to selections that are not keyboard-related: select word, block and all. We can reopen that issue if you feel you want to add even more there. |
If I understand correctly, the goal of this exercise is to gut out most of the complexity from contentEditable, while still allowing JavaScript components to implement rich text editors. I think what both CKEditor and ProseMirror (and CodeMirror on mobile, to a certain extent) are doing (leave selection to browser, but intercept editing actions) illustrates the way forward pretty clearly. Those could basically keep working the way they work now, just switching to a different contentEditable mode, and handling some new events. Removing the cursor/selection entirely would be a disaster, I expect. You can implement proper cursor motion using just existing APIs, but it is a big, complicated problem (bidi text is hard to reason about). People wouldn't bother. You can't, as far as I can see, allow people to manipulate selection and place the cursor on touch platforms without having the browser be aware of the selection. (This is why CodeMirror, which has most of this stuff already implemented, does enable contentEditable on such platforms.) The same, by the way, goes for screen readers -- those get lost easily if the selection isn't managed by the user agent. So a good start would be to leave selection, focus, and cursor display in scope for the new contentEditable approach, but entirely disable built-in editing, filling the gaps that leaves (IME input, spell correction, ...) with better events. That would be all I'd need to make CodeMirror and ProseMirror work. |
Ok, good points, I think we can summarize this as that we leave caret movement as default actions, but we do not specify how the caret moves, so that the various UAs can take care of that. A later spec can then bring in "standardized caret movement". |
The discussion started in #56 (#56 (comment)).
So far the plan is, as I understand, that
cE=events
will only fire events and nothing will actually happen there.The current input event list includes such input types as
caretRight
,caretUp
,caretEndNextWord
, etc. Thread #56 also discusses caret movements.But selection is not only about caret movements. Hence, the following two topics seem to be totally uncovered right now:
If an implementation must handle all actions like
mousedown
,touchstart
, etc. (or adequate intention events) incE=events
, then these two topics need analysis and I predict that this is not going to be easy.Moreover, the selection works on a normal (non-editable) websites already. I can drag over a text to select it, use Shift+Arrows to select more (note: this is nearly equal to caret movements), etc. Will all this be left without any default action in
cE=events
? That would be quite odd.Furthermore, is the above behaviour spec-ed? I don't think so. Does it need to be? It'd be great, but I guess it's tough and it's not critical at the same time as it's harmless.And last but not least, if
cE=events
is supposed to leave the entire selection behaviour (except rendering) to the implementations, then why shouldn't it drop the native behaviour of drop the drag too? Sounds like we're going too far? IMO dropping selection is already going too far.Make browser responsible for the selection and its changes in
cE=events
Let me list few reasons why I think so.
beforeselectionchange
event).cE=events
without a necessary methods from the Selection API to back up a fully custom implementation will be useless (or of a limited functionality). This may delay the readiness of the whole ecosystem.mousedown
,mouseup
, etc. I can prevent all the events and even build a custom drag and drop system (see how dnd of blocks works here), but as developer I don't need to implement everything from scratch. I also don't expect that the placement and rendering of a "drop caret" is spec-ed and as you can see the API works without that.cE=events
drops, the more analysis we must make. This will delay the whole feature, instead of speeding it up.To conclude:
cE=events
without selection handler will not be functional unless every API is implemented.cE=events
user actions should not modify the content, but they may cause other actions (like selection changes, related scrolling, zooming, whatever). This sounds for me as a good rule of thumb when deciding what to drop.The text was updated successfully, but these errors were encountered: