feat(compose): auto-detect RTL text direction while writing#469
Open
shukiv wants to merge 1 commit into
Open
Conversation
Hebrew/Arabic now flip to right-to-left automatically while writing, per paragraph, using the browser's bidi detection. - rich-text-editor: extend the Paragraph/Heading nodes with a 'dir' attribute defaulting to 'auto', so each block picks its direction from its first strong character (mixed LTR/RTL paragraphs each align correctly). The attribute is serialized via the ProseMirror DOM serializer, so the sent HTML carries dir=auto and recipients see the same direction. Also set dir=auto on the editor root. - email-composer: dir=auto on the subject input and the plain-text body textarea. No new dependency - pure dir=auto.
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.
What
The compose surface now auto-detects text direction: typing Hebrew, Arabic,
or any RTL script flips that paragraph to right-to-left, per paragraph, while
LTR text stays left-to-right. Mixed messages (some RTL lines, some LTR) each
align correctly.
How
Pure
dir="auto"— the browser's built-in bidi detection picks direction fromeach block's first strong character. No new dependency.
ParagraphandHeadingnodes are extended with adirattribute defaulting toauto, so every block rendersdir="auto".Because
serializeEditorContentuses ProseMirror'sDOMSerializer, theattribute is preserved in the sent HTML — so recipients see the same
direction, not just the author. The editor root also gets
dir="auto".dir="auto"on the subject input and the plain-text bodytextarea, so those fields flip too.
Notes
an English one each get the right direction.
diron pasted/quoted content is preserved (the attribute parses theelement's existing
dir).its iframe, where the email's own markup controls direction.
Test plan
npm run typecheck,npm run build— greendir="auto"(recipient sees RTL)