Skip to content

fix(text-editor): render paragraphs and headings with dir="auto" for RTL text - #11148

Open
MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/editor-rtl-dir-auto
Open

MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/editor-rtl-dir-auto

Conversation

@MichaelUray

Copy link
Copy Markdown
Contributor

Fixes #8767

Problem and change

Paragraphs and headings in the editor and in the read-only markup renderers had no direction attribute, so every block inherited the LTR page direction. Hebrew or Arabic lines were left-aligned, and lines that mixed RTL text with English words had their punctuation and word order resolved against an LTR base, which scrambled them.

The editor kit now configures the paragraph and heading nodes with HTMLAttributes dir="auto", and the markup renderers (NodeContent, LiteNodeContent) set dir="auto" on the same blocks. Each block then takes its base direction from its first strong character. The attribute only exists in the rendered DOM. Stored markup and server-side HTML conversion are unchanged. Table header cells use text-align: start instead of left, so RTL headers align to the right.

Tests

No unit test (rendering attributes only). Checked manually on a self-hosted instance: a Hebrew/English line in a document and in a chat message renders right-to-left (dir="auto"), an English line left-to-right; stored content is unchanged.

…RTL text

Paragraphs and headings in the editor and in the read-only markup renderers had no direction attribute, so every block inherited the LTR page direction. Hebrew or Arabic lines were left-aligned, and lines that mixed RTL text with English words had their punctuation and word order resolved against an LTR base, which scrambled them.

The editor kit now configures the paragraph and heading nodes with HTMLAttributes dir="auto", and the markup renderers (NodeContent, LiteNodeContent) set dir="auto" on the same blocks. Each block then takes its base direction from its first strong character. The attribute only exists in the rendered DOM. Stored markup and server-side HTML conversion are unchanged. Table header cells use text-align: start instead of left, so RTL headers align to the right.

Fixes hcengineering#8767

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

right to left 2 lang issue

1 participant