Commit graph

11 commits

Author SHA1 Message Date
Marc Durdin
b05fda1c6a fix(web): selection direction and tests
Selection direction was not maintained in mutations, which could have
unexpected consequences. Added support for selection direction to input
and textarea.

The functions `getTextBeforeCaret()` and `getTextAfterCaret()` are named
somewhat incorrectly, as they actually get the text before and after the
active selection (and a collapsed zero-length selection is equivalent to
the caret). It would be worth renaming these in a future refactor.

This PR fixes the unit tests so that caret position is tested correctly
with an active selection -- the caret can be at either the start or the
end of the selection, corresponding with the direction in which the user
originally selected the text. It also fixes the assumptions around the
above named functions for `input` and `textarea` types.

Note that selection interactions are still buggy with prediction
selections; these bugs were present in 15.0.118-alpha and I will tackle
them in an upcoming commit.
2022-02-23 15:13:07 +11:00
Marc Durdin
cacbbee5cc fix(web): properly handle selection
Relates to #5853 and others.

Selection management was not working properly with the various
OutputTargets:

1. When there is a non-empty selection, rules have no context -- it's
   like new text.
2. Backspace over a selection deletes just the selection.
3. Typing a character replaces the selection, of course, and collapses
   the caret to the end of the new text.
4. `hasSelection` is a very strange name for `OutputTarget` descendants.
   It doesn't mean "has an active selection" but rather, kinda means
   "supports selection internally".
5. Added `isSelectionEmpty` which is used for some of the new selection
   rules above.

Note that the `touchAlias` OutputTarget class does not currently support
selection. I hope we can deprecate `touchAlias` with the use of
`inputMode` (#3030) in the future, rather than adding support for
selection.
2022-02-23 15:12:58 +11:00
jahorton
c0e48e649a refactor(web): OSK connection to active element 2021-09-01 09:44:00 +07:00
jahorton
431a9fc85a fix(web): hides touch-alias caret when keystroke causes focus change 2021-02-24 13:20:54 +07:00
jahorton
c03adea719 fix(web/engine): test-resource compile fix 2020-09-21 10:01:51 +07:00
jahorton
0c2c591e17 refactor(web/engine): application of predictive suggestions 2020-09-15 15:22:16 +07:00
jahorton
5c709f9468 chore(web/engine): post-rebase cleanup 2020-04-24 14:35:52 +07:00
jahorton
1eed004296 change(web): package rename + patchup 2020-04-24 13:53:39 +07:00
jahorton
373196dded change(web/engine): splits off the core/web/keyboard-processor module 2020-04-24 13:45:04 +07:00
jahorton
52e3f7e977 refactor(web): adds intermediate DOM-aware OutputTarget abstraction 2020-04-03 10:31:35 +07:00
jahorton
80a348f023 refactor(web/engine): moves DOM-based OutputTargets to own namespace
fix(web): more tweaks
2020-03-26 10:05:47 +07:00