add delete-to-start/end-of-line
On Mac, pressing meta+delete deletes from the cursor position to the start of the line. We would like to have this work properly in mobiledoc-kit as well. Need to:
- [ ] add positioning heuristics to detect the position in a section that matches the start or end of its visual line (see Position#atPoint for an example of where we currently do something similar)
- [ ] listen for delete key with meta also pressed in EventManager
- [ ] update
Position#moveto handle a"line"unit
see #403
Similar to my comment here regarding the alt+backspace behaviour, removing the custom delete key handler allows meta+delete to function.
Perhaps we can find a solution that leverages the default browser behaviour and mobiledoc-kit's mutation observer rather than trying to re-implement OS behaviour?
@kevinansfield I'm actually looking at being able to operate without the keypress events as part of a solution for https://github.com/bustle/mobiledoc-kit/issues/589.
We use key events for a few reasons:
- Our renderer has not really been a full diffing engine. When any marker in a section has changed, we simply re-render all the contents of the section. My work right now is to make that part of the render more detailed in its tracking. This should allow us to re-parse and then re-use the DOM a bit more often.
- Some browsers don't inject characters the same way. I don't have an example right now, but an ok thought-experiment would be to consider what happens when a user hits
enter. Do we get a<br>in the<p>? Or a new<p>? After we re-parse we may need to correct the DOM, which is possibly just tricky. - Some native selection mechanics will break down around cards or atoms. For example when you are holding
shift + left arrowyou want one arrow press to traverse the entire atom. Not all browsers will do that. Re-parsing the selection and recreating it is much more tricky than accurately modeling the selection semantics, IMO.
So that is to say I'm not so sure we should simply remove the delete handler and call it a day. We would need to ensure that our own test suite still passes and all our known browsers continue to work properly.