fix(direction): auto-detect paragraph base direction via dir="auto"#3714
Open
shri-scale wants to merge 2 commits into
Open
fix(direction): auto-detect paragraph base direction via dir="auto"#3714shri-scale wants to merge 2 commits into
shri-scale wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c010389625
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Contributor
Author
|
@caio-pizzol kindly review |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
c010389 to
3c99448
Compare
Paragraphs with no explicit w:bidi previously rendered without a `dir` attribute, which inherits the container base direction instead of auto-detecting from content. A fresh paragraph therefore could not pick up direction from the first strong character typed (Google-Docs behaviour). Render `dir="auto"` for unset paragraphs in both the editing node view (ParagraphNodeView) and the viewing painter (inline-direction/rtl-styles), so the browser resolves base direction per UAX superdoc-dev#9. Explicit `rightToLeft` true/false remain hard overrides (`dir="rtl"`/`"ltr"`). `setParagraphDirection` LTR now writes an explicit `false` so a deliberate LTR choice survives auto-detection (reverting to auto is `clearParagraphDirection`). This aligns the implementation with the direction README's stated intent; README updated. Adds unit coverage (ParagraphNodeView, rtl-styles, paragraphDirection) and a behaviour spec.
… line The painter splits a paragraph into separate `.superdoc-line` elements and stamped `dir="auto"` on each, so every wrapped line re-detected direction from its own first strong character (an RTL paragraph whose continuation line begins with Latin text wrongly flipped to LTR). Resolve the base direction once on the paragraph wrapper (`dir="auto"`); lines now inherit it via a new `inheritAuto` flag on `applyRtlStyles` (they leave `dir` unset in the auto case, keep explicit rtl/ltr). The container render path (table cells / text boxes) lacks a per-paragraph wrapper, so each paragraph's lines are grouped under a `display:contents` wrapper that carries the direction without affecting flex layout.
3c99448 to
accd6ce
Compare
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.
auto-detect paragraph base direction via dir="auto"
Problem
Paragraphs with no explicit
w:bidirender without adirattribute. An absentdirmakes the element inherit its container's base direction rather than auto-detecting from content — so a new/empty paragraph cannot pick up direction from the first strong character typed (e.g. typing Arabic on a fresh line stays LTR), and an editor embedded in an RTL/LTR shell takes the wrong base direction.Change
dir="auto"for direction-unset paragraphs in both the editing node view (ParagraphNodeView) and the viewing painter (inline-direction/rtl-styles), so the browser resolves base direction per UAX minimal core infra for existing functionality #9 from the first strong character.rightToLefttrue/false remain hard overrides →dir="rtl"/dir="ltr".setParagraphDirection({ direction: "ltr" })now writes an explicitfalse(previously it deleted the flag) so a deliberate LTR choice survives auto-detection; reverting to auto staysclearParagraphDirection().dirvsdir="auto"distinction.Tests
ParagraphNodeView, painterrtl-styles,paragraphDirection.tests/behavior/tests/formatting/auto-paragraph-direction.spec.ts— auto-detect RTL/LTR on typing, and manual override persistence.Note for reviewers
This changes the rendered
dirfor previously-undirected paragraphs (absent →auto), so visual snapshots may shift for documents containing such paragraphs. Those diffs should be reviewed and re-blessed.