Skip to content

fix(text-editor): scale paragraph content font with the size prop - #8147

Draft
tamas-sage wants to merge 1 commit into
masterfrom
fix/FE-7740-text-editor-content-font-size
Draft

fix(text-editor): scale paragraph content font with the size prop#8147
tamas-sage wants to merge 1 commit into
masterfrom
fix/FE-7740-text-editor-content-font-size

Conversation

@tamas-sage

Copy link
Copy Markdown
Contributor

Proposed behaviour

the editor should apply size-based paragraph typography consistently across all paragraph content, including links and mention pill text. The mapping should be small = global/font/static/comp/regular/S, medium = global/font/static/comp/regular/M, and large = global/font/static/comp/regular/L, while preserving bold and italic styling.

Current behaviour

the TextEditor size updates the surrounding editor styling, but paragraph content inside the editor does not consistently inherit the size-specific font token. The paragraph node still applies a fixed typography setup of 400 / 21px / 14px, so links and text inside mention pills can stay on the wrong font, which is most noticeable at large size.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

@tamas-sage
tamas-sage requested review from a team as code owners August 25, 2026 09:00
@tamas-sage
tamas-sage marked this pull request as draft August 25, 2026 09:00
@tamas-sage tamas-sage self-assigned this Aug 25, 2026
@tamas-sage
tamas-sage requested a lite review from Copilot August 27, 2026 11:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Carbon’s TextEditor typography so paragraph content (including links and mention pill text) scales with the size prop by relying on inherited paragraph font tokens, while retaining bold/italic formatting behavior.

Changes:

  • Apply size-based paragraph font tokens on the editor container via StyledTextEditor.
  • Update StyledSpanNode to avoid writing inline fontSize/lineHeight for paragraph preset spans so they inherit from the editor.
  • Update mention pill styling to inherit font, and add unit tests covering the new paragraph inline-style behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/text-editor/text-editor.style.ts Adds size→paragraph font token mapping and applies it on the editor container.
src/components/text-editor/text-editor.component.tsx Passes the computed size into StyledTextEditor so typography can be applied consistently.
src/components/text-editor/internal/nodes/styled-span.node.ts Skips inline font size/line height for paragraph preset spans to allow size-based inheritance.
src/components/text-editor/internal/nodes/styled-span.node.test.tsx Adds tests validating paragraph spans don’t set inline font size/line height, including transitions to/from other presets.
src/components/text-editor/internal/nodes/mention.node.ts Makes mention pill text inherit font so it scales with editor size.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +135 to +139
/**
* Whether this node uses the paragraph preset. Paragraph font size and line height
* are inherited from the editor so they can scale with its `size` prop, so they are
* deliberately not written as inline styles.
* @returns true when the node matches the paragraph preset
Comment on lines 16 to 21
color: var(--pill-generic-label-alt-default);
cursor: pointer;
display: inline-block;
font: var(--global-font-static-comp-regular-m);
font: inherit;
min-height: 20px;
padding: 0px var(--global-space-comp-s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants