Skip to content

fix: read font-size from inline style on HTML import#132

Merged
JohnMcLear merged 1 commit intomainfrom
fix/import-style-font-size
May 8, 2026
Merged

fix: read font-size from inline style on HTML import#132
JohnMcLear merged 1 commit intomainfrom
fix/import-style-font-size

Conversation

@JohnMcLear
Copy link
Copy Markdown
Member

Problem

getLineHTMLForExport emits class="font-size:<N>" on export and inlineAttribute.collectContentPre reads class on 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 touch context.styl, so externally-pasted size is silently dropped — and any DOCX import via ether/etherpad#7568 loses font sizes.

Fix

Wrap collectContentPre to also scan context.styl for font-size:.... Snap the value to the nearest supported toolbar size, with light-touch unit handling for px/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 as class="font-size:N" (or the data-font-size fallback). Covers 8, 14, 20.

Refs ether/etherpad#7568. Sister PRs: ether/ep_align#183 (text-align, merged), ether/ep_font_color#150 (color).

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).
@qodo-code-review
Copy link
Copy Markdown

ⓘ 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.

@JohnMcLear JohnMcLear merged commit 4caf541 into main May 8, 2026
3 checks passed
@JohnMcLear JohnMcLear deleted the fix/import-style-font-size branch May 8, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant