-
Notifications
You must be signed in to change notification settings - Fork 183
Add TouchPlugin to handle text selection by touch #3151
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements touch selection repositioning behavior to improve text cursor placement on touch devices. When users tap within 6 characters of a word's beginning or end, the cursor moves to the nearest word boundary; otherwise, it remains at the original tap position.
Key changes:
- Add new
repositionTouchSelectionfunction with word boundary detection logic - Integrate touch selection handling into the SelectionPlugin with timeout delay
- Export the
adjustWordSelectionutility function for reuse
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| repositionTouchSelection.ts | New module implementing touch selection repositioning logic with 6-character threshold |
| SelectionPlugin.ts | Integration of touch selection handler with 200ms timeout and import addition |
| index.ts | Export of adjustWordSelection utility function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/roosterjs-content-model-core/lib/corePlugin/selection/repositionTouchSelection.ts
Outdated
Show resolved
Hide resolved
packages/roosterjs-content-model-core/lib/corePlugin/selection/repositionTouchSelection.ts
Outdated
Show resolved
Hide resolved
packages/roosterjs-content-model-core/lib/corePlugin/selection/repositionTouchSelection.ts
Outdated
Show resolved
Hide resolved
packages/roosterjs-content-model-core/lib/corePlugin/selection/SelectionPlugin.ts
Outdated
Show resolved
Hide resolved
…soft/roosterjs into u/nguyenvi/touch-selection
Add Touch Plugin, Pointer Event type (pointer up, pointer down).
Use DomEventPlugin to recognize pointer event and trigger newly created pointer plugin event. Touch Plugin event will be used to handle cursor selection for text.
(Spec: For touch selection, move the cursor to the beginning or end of the word if they tap within 6 characters of the beginning/end. If not, then place the cursor where they originally tapped.)