Skip to content

[Feature request] Per-paragraph-style lineHeight in htmlStyle #744

Description

@yagiz2000

Problem

There is no way to control line spacing per paragraph style. The only lever is the container style.lineHeight, which is global and exists on EnrichedTextInput only. Two consequences:

1. Read-only rendering can't do line spacing at all.

EnrichedTextInputNativeComponent.ts:401 declares lineHeight; EnrichedTextNativeComponent.ts declares none. Because EnrichedTextProps.style is typed as RN TextStyle, TypeScript happily accepts lineHeight and it is dropped before native — silently, with no warning.

On iOS EnrichedTextView.mm:616 reads scaledPrimaryLineHeight, but nothing ever calls setPrimaryLineHeight for that view (only EnrichedTextInputView.mm:234 does). On Android enriched/text/ has no EnrichedLineHeightSpan at all.

An app that edits with EnrichedTextInput and renders with EnrichedText therefore cannot make the two views match.

2. The global value behaves differently per platform.

Android's EnrichedLineHeightSpan.chooseHeight returns early for headings (EnrichedLineHeightSpan.kt:35), while iOS applies minimumLineHeight to every paragraph range (EnrichedTextInputView.mm:902-918).

For headings above the value this is invisible, but a heading whose natural leading falls below it diverges — with the default htmlStyle, h4/h5/h6 (16/14/12px) all sit under a typical body lineHeight of 24, so they open up on iOS and stay tight on Android.

Proposal

Accept lineHeight per tag in htmlStylep, li, h1h6, blockquote, codeblock — honored by both EnrichedText and EnrichedTextInput.

This is the direction the code already anticipates. EnrichedLineHeightSpan.kt:34 carries the comment:

In the future we may consider adding custom lineHeight support for each paragraph style

It also subsumes issue 1 without needing style.lineHeight parity on EnrichedText, since htmlStyle is already wired to both components, and it makes the heading question explicit per tag rather than an implicit platform difference.

Use case

A notes app where the editor and a read-only view render the same HTML and must look identical.

Version: 1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions