Repository navigation
fix(text-editor): render paragraphs and headings with dir="auto" for RTL text - #11148
Open
MichaelUray wants to merge 1 commit into
Open
MichaelUray wants to merge 1 commit into
MichaelUray wants to merge 1 commit into
Conversation
…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
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.
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.