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

[Input Events] Word deletion #125

Closed
ayg opened this issue Apr 19, 2016 · 14 comments
Closed

[Input Events] Word deletion #125

ayg opened this issue Apr 19, 2016 · 14 comments

Comments

@ayg
Copy link
Contributor

ayg commented Apr 19, 2016

The spec knows about "forward" and "backward". But you can also do word deletion by holding down Ctrl with backspace/delete.

@chong-z
Copy link

chong-z commented Apr 21, 2016

Also I was wondering is there any particular reason we want to use forward and backward instead of the content to be deleted? (At least for input since beforeinput can get content to be deleted from targetRange)

@ojanvafai seems disagree with forward and backward.

@johanneswilm
Copy link
Contributor

@choniong Forward and backward give an indication of where the caret will be after the deletion. In the most simple case -- content is just being deleted -- it won't make a difference. But if the JS interrupts the deletion and does something else -- for example for a tracked changes feature where the content will be crossed out rather than actually deleted -- it matters which direction the deletion is happening in.

For example:

[...] = selection, | = collapsed selection

This is a [piece of text].

User hits BackSpace or Delete.

In a simple case (and default behavior if deletion is enabled) the result is:

This is a |.

In a tracked changes situation, it is important to be able to differentiate between the result of BackSpace:

This is a |piece of text.

And Delete

This is a piece of text|.

@johanneswilm
Copy link
Contributor

@ayg Indeed. I think we need DeleteWordBackward and DeleteWordForward as well.

@ojanvafai
Copy link

@johanneswilm reusing the data field for this makes no sense to me. That's the part I'm objecting to. If we had DeleteForward, DeleteBackword, DeleteWordBackword and DeleteWordForward, does that solve the same problem without needing to use the data field?

@choniong I was confused in our code review...I don't think the data field should have any value for these command types. I guess it should be null? Instead, the target range should point to what's going to be deleted.

@johanneswilm
Copy link
Contributor

@ojanvafai: Yes, I agree. I think that solves everything, and it's much cleaner.

@chong-z
Copy link

chong-z commented Apr 21, 2016

@ojanvafai sorry for misunderstanding your comments...

BTW do we care about Line deletion? e.g. Command+Backspace on Mac
Or do we just fire DeleteBackword with a target range?

@ojanvafai
Copy link

What makes the most sense to me is to have a different edit type for each of these. So we'd have DeleteLineBackward and DeleteLineForward as well. That gives web authors the ability to understand the semantic thing the user was trying to do and react appropriately instead of needing to reverse engineer what the user was trying to do from the target range.

FWIW, you didn't misunderstand my comments, I just said something wrong. :)

@johanneswilm
Copy link
Contributor

johanneswilm commented Apr 22, 2016

I would want to put this into the draft immediately. However, the current way of doing it is the result of a resolution at our F2F meeting "RESOLUTION: one delete event with data for forward/backward". It used to be two different types.

I have sent a mail about this to the mailing list: https://lists.w3.org/Archives/Public/public-editing-tf/2016Apr/0011.html

@ojanvafai
Copy link

FWIW, I'm open to other solutions as well. We could add a new field to the
event for this. I just think that data should be used exclusively for
user-inserted data.

On Fri, Apr 22, 2016 at 7:26 AM Johannes Wilm notifications@github.com
wrote:

I would want to put this into the draft immediately. However, the current
way of doing it is the resolut of a a resolution at our F2F meeting "RESOLUTION:
one delete event with data for forward/backward"
https://www.w3.org/2015/08/24-webapps-minutes.html. It used to be two
different types. I will send an email out to the mailing list everyone is
OK with reverting this.


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#125 (comment)

@ayg
Copy link
Contributor Author

ayg commented May 1, 2016

If Mac supports line deletion, we should definitely support that as well. Firefox has code for it.

Having separate inputTypes sounds like the best idea to me.

@johanneswilm
Copy link
Contributor

Having different inputTypes or having a new field both seem like reasonable suggestions. it seems like here most favor different inputTypes, and there has been no protest on the list about it either.

@johanneswilm
Copy link
Contributor

johanneswilm commented May 20, 2016

I have tried to contact those who according to the minutes seemed to have an interest in this question, and I have only received no response or positive responses toward the above mentioned proposal of splitting it into several. It seems that all possible effort has been made to see if there were opposing views. I will therefore now make the change in the draft.

johanneswilm added a commit that referenced this issue May 20, 2016
…eteLine/deleteWord/deleteContent/deleteComposedCharacter[Backward/Forward], #125
@johanneswilm
Copy link
Contributor

I tried to figure out how to define deleteContent as opposed to deleteLine and deleteWord. At frist I thought maybe saying the user wants to delete a character. But it may actually be at the start of a block element, so that deleteContentBackward would indicate a wish to merge paragraphs. Or it may be after a table, in which case it may mean to wish to delete the entire table. So I added to the description "this intention is not covered by another inputType" (and such other inputTypes would be deleteLine/deleteWord). But I'm not sure that is the best possible way of formulating it.

This hasn't been talked about, but what makes out a word or a line can be difficult to figure out. So probably it would be a good idea to have the target range point to what the the browser thinks is a line or a word in the given direction. Then the author can decide whether to go with the browser's idea of a word/line or whether to define his/her own.

@johanneswilm
Copy link
Contributor

Changed in draft document. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants