Repository navigation
Don't shift FreeText clones by their font size (issue 22271) - #22378
Open
cestercian wants to merge 1 commit into
Open
cestercian wants to merge 1 commit into
cestercian wants to merge 1 commit into
Conversation
A cloned FreeText editor is positioned from its serialized rect, which already includes the baseline shift. getInitialTranslation() applied that shift again, and _moveAfterPaste() returns early for clones, so the editor moved up by its font size. Keep the padding compensation that getPDFRect() adds back, and skip only the font-size part.
This branch has not been deployed
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.
When a FreeText editor is recreated as a clone (
AnnotationEditorUIManager.findClonesForPage(), fed byclonePage(), which the viewer uses when pages are copied withenableSplitMerge),render()appliesgetInitialTranslation(). For FreeText that shift is the padding plus the font size, so the baseline sits where the user clicked. A pasted copy then replaces that position in_moveAfterPaste(), but a clone returns early there, so the shift stayed and the clone moved up by its font size.The padding part of the shift still has to be applied:
getPDFRect()adds it back, and dropping it moves the rect by--freetext-padding(2px). The serialized rect already includes the baseline shift, so a clone skips only the font-size part.Tested with a regression test in
test/integration/freetext_editor_spec.mjsthat serializes a FreeText editor, deserializes it as a clone, and expects the same rect. It failed by exactly the font size before the fix and passes with it. FreeText creation, copy/paste, and undo/redo were checked as well.npx gulp lintandnpx gulp unittestclipass.Fixes #22271