fix: read font-size from inline style on HTML import#132
Merged
JohnMcLear merged 1 commit intomainfrom May 8, 2026
Merged
Conversation
ep_font_size emits 'class="font-size:<N>"' on export. The factory also reads class on import, so the export → import round-trip works for our own output. External HTML (Word/DOCX via mammoth, pasted markup) uses the standard CSS form 'style="font-size:14px"'. The factory does not touch context.styl, so any externally-pasted size was silently dropped. Read 'font-size:...' from the inline style attribute and snap the value to the nearest supported toolbar size. Handles px, pt, em, rem with light-touch unit conversion. Refs ether/etherpad#7568. Sister PRs: ep_align#183 (text-align, merged), ep_font_color#150 (color).
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
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.
Problem
getLineHTMLForExportemitsclass="font-size:<N>"on export andinlineAttribute.collectContentPrereadsclasson import — so our own export → import round-trip works.External HTML (Word/DOCX via mammoth, pasted from a browser) uses the standard CSS form
style="font-size:14px". The factory doesn't touchcontext.styl, so externally-pasted size is silently dropped — and any DOCX import viaether/etherpad#7568loses font sizes.Fix
Wrap
collectContentPreto also scancontext.stylforfont-size:.... Snap the value to the nearest supported toolbar size, with light-touch unit handling forpx/pt/em/rem.Tests
static/tests/backend/specs/api/exportHTML.ts: new context block, three test cases asserting that a pad imported with<span style="font-size:Npx">styled</span>re-exports asclass="font-size:N"(or thedata-font-sizefallback). Covers8,14,20.Refs
ether/etherpad#7568. Sister PRs:ether/ep_align#183(text-align, merged),ether/ep_font_color#150(color).