-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Full bidirectional (RTL) support #2610
Copy link
Copy link
Open
Labels
coreReconciler, DOM, Selection, Node, Events, CompositionReconciler, DOM, Selection, Node, Events, CompositionenhancementImprovement over existing featureImprovement over existing featuretext directionRelated to bidirectional text input (rtl, ltr)Related to bidirectional text input (rtl, ltr)
Metadata
Metadata
Assignees
Labels
coreReconciler, DOM, Selection, Node, Events, CompositionReconciler, DOM, Selection, Node, Events, CompositionenhancementImprovement over existing featureImprovement over existing featuretext directionRelated to bidirectional text input (rtl, ltr)Related to bidirectional text input (rtl, ltr)
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following is a short overview of bi-directional editing surfaces and my suggestion for improving Lexical’s implementation. (Continued from the Discord discussion)
Overview
Modern editing surfaces’ default behavior today is to support bi-directional content by setting the direction based on the first letter’s language. This can be seen in the current Lexical implementation, Apple Notes, Gmail, and Google Docs:
Screen.Recording.2022-07-07.at.10.54.24.mp4
One implementation detail crucial for longer-form and complex content (like a letter or an article) is maintaining the previous paragraph setting if the user manually sets it. Microsoft Office Word gets this correctly:
Screen.Recording.2022-07-07.at.10.57.01.mp4
The recordings demonstrate Hebrew, but the behavior is similar in Arabic.
Implementation Suggestions
The following are my suggestions for scalable bi-directional support in Lexical:
directionmanually set, it should be respected. (When parsing a serialized editor state, the current implementation dynamically evaluates the content, disregarding the provided configuration.)4.1. If the root node’s direction is manually set, it should be the default direction for child nodes.
4.2. When creating a following paragraph, if the previous paragraph has a manual direction set, it should be copied into the next paragraph.