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

[beforeinput] Add InputType 'deleteByKill', 'insertFromYank' and 'transpose' #148

Closed
chong-z opened this issue Aug 24, 2016 · 8 comments
Closed

Comments

@chong-z
Copy link

chong-z commented Aug 24, 2016

On MacOS the hotkey ctrl-t will transpose the two character besides cursor (Chrome and Safari), e.g.

  1. a|b => ba|
  2. ab|$ => ba|$

Should we:

  1. Create a separate InputType, or
  2. Just fire insertText with the target range?
@johanneswilm
Copy link
Contributor

What is the usecase for this? Typing errors?

@chong-z
Copy link
Author

chong-z commented Aug 24, 2016

Did some search and cannot find more info about it...(I don't actually use it)
Should just be the emacs style hotkeys in Mac OS (similar to ctrl-k for Kill and ctrl-y for Yank).

I think it's not worth adding new InputTypes since nobody uses it (I assume?), but as they are modifying DOM we should at least have some notes about the expected events, e.g.:

  1. Fire InputType=deleteContentForward for Kill
  2. Fire InputType=insertText for Yank
  3. Fire InputType=insertText with target ranges for Transpose

@johanneswilm
Copy link
Contributor

I think it's not worth adding new InputTypes since nobody uses it (I assume?)

I think this has to depend on, whether someone uses it (as you say) and whether this functionality can be interpreted in some way to make a change of semantic significance that applies to a different range than the default handling. For example, how does ctrl+t behave around element boundaries? Does it only ever make changes within a single text node?

@chong-z
Copy link
Author

chong-z commented Aug 24, 2016

For example, how does ctrl+t behave around element boundaries?

It won't pass editing boundary nor paragraph boundary.

Does it only ever make changes within a single text node?

It could pass <b> or <i>, and does the similar thing as select and paste reversed plaintext.

Apple's reference NSResponder - transpose:.

@johanneswilm
Copy link
Contributor

It could pass <b> or <i>, and does the similar thing as select and paste reversed plaintext.

I see. Then this may be somewhat more complicated. Element boundaries have at times a meaning within the editor that the browser isn't aware of.

Say for example, that a particular editor puts span-elements around all words or syllables if the word is longer than ten letters for the purpose of tracking their position or alike. As long as the spans are not styled, the end user doesn't notice this. If now the user intents to "transpose" two characters, but the JS doesn't ever know that this was the intention of the end user and instead only gets to know that the end user has asked for changing some things in and out of two span-elements that happen to end/start in-between the two letters in question, this could lead to all kinds of misunderstandings. Does this makes ense?

So I would say this has to get its own intention. Same with yank/kill. It doesn't take that much for us to define them, and if Apple finds out that really no-one uses them, they can remove them from Mac OS X and we can remove them from a future version of the spec.

@chong-z
Copy link
Author

chong-z commented Aug 24, 2016

Say for example, that a particular editor puts span-elements around all words or syllables if the word is longer than ten letters for the purpose of tracking their position or alike. As long as the spans are not styled, the end user doesn't notice this. If now the user intents to "transpose" two characters, but the JS doesn't ever know that this was the intention of the end user and instead only gets to know that the end user has asked for changing some things in and out of two span-elements that happen to end/start in-between the two letters in question, this could lead to all kinds of misunderstandings. Does this makes ense?

OK, so for example the default behavior for Transpose is similar to Paste

  • Bold|Italic -> BolId|talic (Where I was moved into <b>)

JS might want to detect Transpose and override it to

  • Bold|Italic -> BolId|talic (Swap character but keeps style)

So I would say this has to get its own intention. Same with yank/kill. It doesn't take that much for us to define them, and if Apple finds out that really no-one uses them, they can remove them from Mac OS X and we can remove them from a future version of the spec.

OK, so how about:

  1. deleteByKill (similar to cut)
  2. insertFromYank (similar to paste)
  3. transpose

@johanneswilm
Copy link
Contributor

OK, so for example the default behavior for Transpose is similar to Paste

  • Bold|Italic -> BolId|talic (Where I was moved into <b>)

JS might want to detect Transpose and override it to

  • Bold|Italic -> BolId|talic (Swap character but keeps style)

That's possible. I was thinking of a case such as:

...<span data-element="101" data-length="3">pic|</span><span data-element="102" data-length="4">ture</span>...

The spans above are something used by the JS editor and what the meaning of data-element and data-length is only clear to the JS. The browser doesn't know what this is. So say the user now hits ctrl+t. The browser may think it can join the two spans or maybe move one extra letter into the first span without increasing the data-length attribute of one and increase the one of the other. So this will have to be handled by JS. But if the JS only receives a beforeinput replaceContent event which says that the user intents to do some complex changes to the two spans, it may be quite difficult for the JS to understand that this was really about transposing.

OK, so how about:

  1. deleteByKill (similar to cut)
  2. insertFromYank (similar to paste)
  3. transpose

That sounds good to me.

@chong-z chong-z changed the title [beforeinput] InputType for MacOS Transpose (ctrl-t) [beforeinput] Add InputType 'deleteByKill', 'insertFromYank' and 'transpose' Aug 24, 2016
@johanneswilm
Copy link
Contributor

This issue was moved to w3c/input-events#20

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

2 participants