Skip to content
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

add delete-to-start/end-of-line #445

Open
3 tasks
bantic opened this issue Aug 3, 2016 · 2 comments
Open
3 tasks

add delete-to-start/end-of-line #445

bantic opened this issue Aug 3, 2016 · 2 comments

Comments

@bantic
Copy link
Collaborator

bantic commented Aug 3, 2016

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#move to handle a "line" unit

see #403

@kevinansfield
Copy link
Collaborator

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?

@mixonic
Copy link
Contributor

mixonic commented Jul 10, 2018

@kevinansfield I'm actually looking at being able to operate without the keypress events as part of a solution for #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 arrow you 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.

kevinansfield added a commit to kevinansfield/mobiledoc-kit that referenced this issue Jul 31, 2018
refs bustle#445
- add `Position.atStartOfLine` method that takes an existing position from which to find the start of it's line
- add `line` unit for use in `editor.performDelete`
- update delete key event handler to pass `line` unit when <kbd>Meta+Backspace</kbd> is pressed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants