Commit graph

184 commits

Author SHA1 Message Date
Marc Durdin
88ffb8bbd2 fix(web): adjust touch alias element positioning
Fixes #5942.

The touch alias element position was not consistent across all browsers,
leading to misalignment in some situations. Identified missing CSS to
make the positioning consistent, as far as I can tell, which led to the
additional benefit of reducing the per-browser special cases.
2022-03-22 08:38:12 +11:00
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
Marc Durdin
ac2cc93f2a fix(web): add readonly mode for rule behavior finalization
Relates to #5853.

Two things happened here:

1. Construction of Mocks made an assumption that the selection should
   always be deleted (outputTarget.ts:363). However, for NewContext and
   PostKeystroke processes, we don't want to change anything.

2. Even if nothing is changed, the transcription would emit what is
   in theory a no-op ruleTransform (insert="", deleteLeft=0,
   deleteRight=0). But apps would treat this as deleting the selection.

This fix goes a little broader than I would have preferred, but adds a
readonly mode to the transcription and mock model, so that we can
control explicitly when changes are applied to the text store.
2022-02-22 10:42:20 +11:00
Marc Durdin
0c0bb420b5
Merge pull request #5963 from keymanapp/feat/web/3621-newcontext-group
feat(web): Start of Sentence support - part 1 🕊
2022-01-17 12:04:29 +11:00
Marc Durdin
3f35cc0bf8 chore(web): Merge branch 'master' into feat/web/3621-newcontext-group 2021-11-29 10:22:22 +11:00
Marc Durdin
e98930dedb
Merge branch 'master' into fix/web/5779-font-scaling-in-osk 2021-11-29 09:12:15 +11:00
Marc Durdin
45821fcb1b fix(web): adjust tablet font scaling
This makes two corrections:

1. Removed an obsolete test for screen size based on dpi, which is
   unreliable, meant that we had been treating many Android tablets as
   phones (domManager.ts).
2. Font scale for Android tablets had some incorrect assumptions around
   keyboard height and devicePixelRatio, which I was able to simplify
   into a fixed ratio, and was much better across all devices I
   tested (however, all emulated in Chrome).
2021-11-29 08:56:41 +11:00
Marc Durdin
d6982898a8 fix(web): restore dragEnd function
Relates to #5947.

I resolved a merge conflict in #5947 in the wrong direction and
accidentally deleted the `dragEnd` function. This restores it.
2021-11-29 07:40:04 +11:00
Marc Durdin
c7b83f9f1f
Merge branch 'master' into fix/web/5944-save-focus-for-eurolatin-osk 2021-11-29 06:35:53 +11:00
Marc Durdin
f300e81381
Merge branch 'master' into fix/web/5909-shorten-setfocustimer 2021-11-24 07:11:34 +11:00
Marc Durdin
dcedb15b69 chore: cleanup comments and defines 2021-11-23 16:08:19 +11:00
Marc Durdin
bbbf1afce7 feat(web): basic support for newContext
Relates to #3621.

Adds basic support for `begin newContext`.
2021-11-23 15:00:47 +11:00
Marc Durdin
9162d575ce fix(web): support saving focus for custom OSK interactions
Fixes #5944.

If a custom OSK, such as sil_euro_latin, calls `keymanweb.KSF()` or
`keymanweb.saveFocus()`, this ensures that the next focus change is
ignored, which prevents the OSK from being dismissed as soon as it is
clicked on.

This is a regression, probably arising in version 10.0.

Note: `_SelectionChange` is no longer used or referenced, so I removed
it as part of this fix.
2021-11-19 12:58:53 +11:00
Marc Durdin
cceb2f35b5 fix(web): shorten setFocusTimer()
Fixes #5909.

The `setFocusTimer()` delay was 1000ms. However, it seems that a much
shorter delay accomplishes the same outcome for switching between
controls, as the important factor is to block asynchronously-arriving
events from cancelling the OSK / focus controls for touch alias
elements.

I have set the delay to 50ms. This is fast enough that a click in a
control followed by a click on the page area will always cancel the OSK,
but gives the space needed for queued focus/blur events have time to be
processed before cancelling the timer.
2021-11-19 11:22:21 +11:00
Marc Durdin
c2c7e00e94 fix(web): reset scroll anchor on touchend
Fixes #5313.
2021-11-17 10:37:01 +11:00
Darcy Wong
9136933c9e fix(web): Check parent element is defined before assigning 2021-11-02 11:22:08 +07:00
jahorton
09f4aed77e chore(web): Merge branch 'refactor/web/active-element-integrations' into refactor/web/osk-activation-and-visibility 2021-09-21 09:59:46 +07:00
jahorton
a6289f4f0f fix(web): detaches base-page touch handlers on shutdown 2021-09-21 09:55:11 +07:00
jahorton
b452092765 refactor(web): base page touch-handlers 2021-09-21 09:43:34 +07:00
jahorton
a1516d194d fix(web): focus-timer preserves activation on Android 2021-09-21 09:23:11 +07:00
jahorton
09de360789 fix(web): missed bits of last commit, adds some polish 2021-09-17 15:02:43 +07:00
jahorton
8826bec8fe fix(web): incorporates some review suggestions 2021-09-17 14:58:18 +07:00
jahorton
ffc381fcb6 chore(web): Merge branch 'refactor/web/active-element-integrations' into refactor/web/osk-activation-and-visibility 2021-09-17 08:38:49 +07:00
jahorton
430b636b22 fix(web): independent keyboard & touch-focus management 2021-09-15 10:28:58 +07:00
jahorton
29a8e3ad63 chore(web): extra sanity check for activeTarget management 2021-09-03 13:34:46 +07:00
jahorton
881a2759f2 chore(web): Merge branch 'refactor/web/active-element-integrations' into refactor/web/osk-activation-and-visibility 2021-09-03 12:45:51 +07:00
jahorton
68425763c6 fix(web): fixes touch-mode focusing issue in unit tests 2021-09-03 12:42:34 +07:00
jahorton
e8afd71491 refactor(web): _Show -> present(), presentAtPosition() 2021-09-01 09:44:34 +07:00
jahorton
f070df079d refactor(web): osk._Hide -> osk.startHide 2021-09-01 09:44:34 +07:00
jahorton
ffef7c2bd4 chore(web): mild cleanup 2021-09-01 09:44:31 +07:00
jahorton
fe797fe657 refactor(web): osk now controls own display state 2021-09-01 09:44:30 +07:00
jahorton
5cbb3cfeeb refactor(web): OSK view activeTarget, lastActiveTarget no longer tied to DOMManager 2021-09-01 09:44:29 +07:00
jahorton
a495bf421e chore(web): minor touch-up 2021-09-01 09:44:02 +07:00
jahorton
7fd62c51f4 refactor(web): centralizes element-oriented OSK display logic, polish for prior commits 2021-09-01 09:44:02 +07:00
jahorton
6971f09c4d refactor(web): activeElement, lastActiveElement as properties 2021-09-01 09:44:01 +07:00
jahorton
c0e48e649a refactor(web): OSK connection to active element 2021-09-01 09:44:00 +07:00
jahorton
1c0f596ee7 chore(web): reverts unneeded changes 2021-08-25 11:53:31 +07:00
jahorton
f27ddc6180 refactor(web): constructor takes devicespec; more pruning, centralization 2021-08-25 09:40:20 +07:00
jahorton
aebe4788a7 refactor(web): Anchored vs Floating OSKViews (pass 1) 2021-08-25 09:40:18 +07:00
Joshua Horton
f870355f21
Merge pull request #5506 from keymanapp/refactor/web/vkbd-touch-events
refactor(web): prep work for mouse-based use of touch events 👆
2021-08-23 09:57:02 +07:00
jahorton
4a2fec2d8f refactor(web): roots out embedded-tab code from source branch 2021-08-05 12:13:03 +07:00
jahorton
3066c1f246 chore(web): Merge branch 'master' into fix/web/final-match-group 2021-08-05 11:02:24 +07:00
jahorton
283b36eb00 change(web): moves uiTouchHandlerBase class 2021-07-30 08:15:14 +07:00
Darcy Wong
5d1a652314 Merge remote-tracking branch 'origin/master' into feat/web/add-keyboard-promise 2021-07-23 13:12:40 +07:00
jahorton
0a33ed863d chore(web): addresses review comments 2021-07-23 11:48:51 +07:00
jahorton
dbded0dd23 refactor(web): osk.prepare -> constructor, sync _Load 2021-07-07 11:46:12 +07:00
jahorton
7d08b2795f feat(web): delayed keyman.osk initialization 2021-07-07 11:45:27 +07:00
jahorton
e2ba78582e feat(web): prevents crash on null keyman.osk field 2021-07-07 11:45:27 +07:00
Darcy Wong
144125080b feat(web): Handle deferment of adding keyboards 2021-06-30 10:26:19 +07:00