fix(editor): keep text insertion at the tapped page position - #27
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Text insertion could land away from the tap—or on another page—after scrolling or zooming. The overlay moved inside the transformed canvas in #8, but its tap handler still treated local touch coordinates as screen coordinates and inverted the viewport a second time.
Use the overlay's local coordinates directly to select the page and position the text box. Reject taps outside the notebook, including its trailing boundary and invalid coordinates.
Validation: all five new handler-level regression tests failed before the fix and pass afterward; the full suite passes 61 tests, TypeScript passes, and
git diff --checkis clean. Tests cover three zoom/scroll configurations, multiple pages, edges, empty notebooks, and invalid taps. Simplify and security reviews found no remaining issues. Native verification also passed on an iPad Pro simulator: bundled the candidate JavaScript into the unchanged native simulator app, inserted text on the first page and after scrolling onto the second, then relaunched and confirmed both positions persisted. Exported the notebook through the real app and verified the resulting PDF contained both text boxes and a rotated inserted image on 612 × 792-point pages. Simulator logs showed OS haptics/share-sheet diagnostics, with no observed JavaScript failure.