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

Ctrl + backspace doesn't delete the entire word #3086

Closed
Reinmar opened this issue Mar 16, 2017 · 13 comments · Fixed by ckeditor/ckeditor5-typing#138
Closed

Ctrl + backspace doesn't delete the entire word #3086

Reinmar opened this issue Mar 16, 2017 · 13 comments · Fixed by ckeditor/ckeditor5-typing#138
Assignees
Labels
package:typing type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Mar 16, 2017

Reported in #414.

@fredck
Copy link
Contributor

fredck commented Mar 16, 2017

After a quick test, it seems that browsers support word deletion using word boundaries common to the English language, with no special support for other languages.

For example, when pasting Japanese text, which doesn't use spaces between words, the whole line of text is deleted.

In fact, the only special behavior is that it deletes line by line, not the whole text.

@Reinmar
Copy link
Member Author

Reinmar commented Mar 16, 2017

Check this:

ພາສາຈີນແມ່ນພາສາໜຶ່ງທີ່ເວົ້າໃນປະເທດຈີນ.

And this:

にほんごの クラスは かようびと もくようびです。

In my case, alt+backspace deletes bigger pieces of this text, but definitely not whole lines. Ctrl+backspace works like backspace.

So, first of all, at least on macOS, alt+backspace means "delete word". I don't think that Ctrl+backspace has some special meaning. How's it on Windows?.

Second of all, it's really not that simple.

@Reinmar
Copy link
Member Author

Reinmar commented Jul 10, 2017

DUP reported in #501.

@fredck
Copy link
Contributor

fredck commented Jul 10, 2017

I'm fine if we bring support for western languages first, before thinking to come with the perfect solution for all languages.

@Reinmar
Copy link
Member Author

Reinmar commented Jul 12, 2017

Turns out that this gets heavily irritating for people who got used to this keystroke (e.g. to fix up typos).

So, a temporary solution could be to discover ctrl+backspace (windows) or alt+backspace (macos) and delete the entire word by looking back to the previous space (foo bar^ => foo ^).

However, it seems that one day we'll need to start depending on mutations for this to work reliably anyway. There are two problems with handling backspace manually – Android (where there's no key code for backspace) and languages where "word" has a different shape in the text. Also, there may be other kinds of keystrokes like "delete the whole line" and by handling mutations we'd handle them too.

This is a bigger task, though, due to all the tiny little details like diff failing on comparing "xxx^" with "xx^" (so we don't know which letter was removed), combined characters, IME (where selection isn't collapsed), the problems with inline styles, etc, etc. But all these things are also the reason to actually use mutations because if we make those heuristics good, we have a chance to handle all kinds of unexpected keystrokes and environments.

@ryanfeeley
Copy link

Will be glad to see this live, lots of requests for it in Firefox Notes.

@jodator
Copy link
Contributor

jodator commented Feb 6, 2018

So, a temporary solution could be to discover ctrl+backspace (windows) or alt+backspace (macos) and delete the entire word by looking back to the previous space (foo bar^ => foo ^).

This is actually partially supported by Delete plugin:

https://github.com/ckeditor/ckeditor5-typing/blob/9b55a32202084ca310e4c56f6f87e6a677a099a5/src/delete.js#L36-L40

The problems in my opinion lays here:

https://github.com/ckeditor/ckeditor5-engine/blob/adf1043096b4042e1f0240a0c3553addbe1773e7/src/model/utils/modifyselection.js#L120.

As it appears that modifySelection() does not support unit=word option - the tests are only for character or codePoint:

https://github.com/ckeditor/ckeditor5-engine/blob/1640a51447d14acf3a961a5d316f6dc0c2e65d83/tests/model/utils/modifyselection.js#L25.

I'll try to dig more into it and to implement unit=word handling there.

@Reinmar
Copy link
Member Author

Reinmar commented Feb 6, 2018

As it appears that modifySelection() does not support unit=word option - the tests are only for character or codePoint:

Yep. We predicted this thing but never fully implemented it.

@jodator
Copy link
Contributor

jodator commented Feb 7, 2018

@Reinmar how broad should we go with implementing this?

A space only solution is I understand a minimal solution but maybe we should add other punctuation symbols (,.-)?

As a reference here is Unicode Word Boundary specification.

@Reinmar
Copy link
Member Author

Reinmar commented Feb 7, 2018

Max 3MH broad ;)

@Reinmar
Copy link
Member Author

Reinmar commented Feb 16, 2018

Closed with ckeditor/ckeditor5-engine#1287. Great job!

@Reinmar Reinmar closed this as completed Feb 16, 2018
@jodator
Copy link
Contributor

jodator commented Feb 16, 2018

To have everything right in papers - I'm reopening this as there is still a PR awaiting in this repository which will enable Ctrl+Backspace to work also on non-mac computers :).

@jodator jodator reopened this Feb 16, 2018
Reinmar referenced this issue in ckeditor/ckeditor5-typing Feb 20, 2018
Fix: Properly discover delete-word keyboard modifier on mac and non-mac computers. Closes #92.
@vladikoff
Copy link

Awesome! Thanks for fixing this!

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-typing Oct 9, 2019
@mlewand mlewand added this to the iteration 14 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:typing labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:typing type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
6 participants