Fix format state reporting relative em font size for heading elements - #3419
Draft
JiuqingSong with Copilot wants to merge 2 commits into
Draft
Fix format state reporting relative em font size for heading elements#3419JiuqingSong with Copilot wants to merge 2 commits into
em font size for heading elements#3419JiuqingSong with Copilot wants to merge 2 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix font size in h2 element formatting
Fix format state reporting relative Jul 29, 2026
em font size for heading elements
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 cursor/selection is inside a heading element (h1–h6),
getFormatState()returns the raw relative value (e.g.1.5emfor h2) instead of an absolute pt size, because the heading's default style is stored verbatim in the paragraph decorator format andpx2Ptonly convertspxunits.Root cause
fontSizeFormatHandlerstores the rawdefaultStyle.fontSizevalue (e.g.'1.5em'fromdefaultContentModelFormatMap) without normalization when there is no inlineelement.style.fontSize. InretrieveModelFormatState, this relative value from the decorator overrides the container's resolved absolute font size incurrentFormat, and then passes throughpx2Ptunchanged.Fix
retrieveModelFormatState.ts— Before the finalpx2Ptcall, resolve any remaining relativeem/%font size against the container's computed font size (obtained fromdomHelper.getContainerFormat()):If no
domHelperis available (legacy adapter path, unit tests without a DOM), the value is left as-is — no regression.retrieveModelFormatStateTest.ts— Three new cases:emdecorator format + domHelper → resolves to absolute pt (1.5em×16px=18pt)emdecorator format, no domHelper → graceful fallback, value unchanged%decorator format + domHelper → resolves to absolute pt (150%×16px=18pt)