fix: match inline suggestion font to caret element in contenteditable editors#345
Merged
bartekplus merged 3 commits intomasterfrom Mar 23, 2026
Merged
Conversation
… editors On TinyMCE and similar contenteditable editors, the inline suggestion ghost was reading computed styles from the outer container (e.g. <body>) instead of the element at the caret (e.g. <h1>, <p>). This caused wrong font family, size, and weight. Additionally, the ghost used the element's computed lineHeight which includes leading, shifting the suggestion text below the actual baseline. - Add resolveCaretElement() to find the DOM element at the caret position via the Selection API and copy its computed font styles - Use caretRect.height as the ghost lineHeight/height instead of the computed lineHeight to align the text baseline with the caret Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…undary selections P1: Replace height/overflow clamp with a top-offset approach. The ghost now keeps the element's computed lineHeight and shifts top upward by half the leading (lineHeight - caretHeight) / 2, so multi-line suggestions that wrap via pre-wrap + maxWidth are no longer truncated after the first line. P2: Handle wrapper-boundary selections (Lexical/Reddit pattern) where the caret is at (wrapperDiv, offset). resolveCaretElement now descends into the block child at the anchor offset instead of returning the wrapper, matching ContentEditableAdapter.findInnermostBlockContainingRange behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
<h1>,<p>,<span>) instead of the outer contenteditable container (e.g.<body>)caretRect.heightas the ghost'slineHeight/heightto prevent baseline misalignment caused by CSS leadingresolveCaretElement()helper that uses the Selection API to find the correct style sourceTest plan
<input>/<textarea>fields🤖 Generated with Claude Code