Skip to content

refactor(painter-dom): rename rtl-paragraph feature to inline-direction (SD-2779)#3307

Merged
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/SD-2779-rename-rtl-paragraph-feature
May 14, 2026
Merged

refactor(painter-dom): rename rtl-paragraph feature to inline-direction (SD-2779)#3307
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/SD-2779-rename-rtl-paragraph-feature

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

The painter-dom feature module at features/rtl-paragraph/ handles two related but distinct OOXML elements: w:pPr/w:bidi (paragraph bidirectional flag) and w:rPr/w:rtl (run-level RTL trigger). Both belong to paragraph/run inline bidi handling. The rtl-paragraph folder name was inherited from earlier work and is now misleading - table visual direction (w:bidiVisual, §17.4.1) and writing mode (w:textDirection, §17.3.1.41 paragraph / §17.4.72 cell; values in §17.18.93 ST_TextDirection) are separate orthogonal axes owned elsewhere.

Rename the folder, import path, and feature-registry entry to inline-direction so the module name matches the axis. Add an explicit note (registry comment + index.ts JSDoc) calling out the orthogonal axes the module does NOT own, so a future reader who reaches for this folder for table direction or writing-mode work lands on the right pointer.

Internal file (rtl-styles.ts) and exported function names (applyRtlStyles, shouldUseSegmentPositioning, isRtlParagraph, resolveTextAlign) keep their RTL framing because they describe RTL detection and styling specifically. Only the feature folder name changes.

Tests: painter-dom 1070 pass. pnpm --filter @superdoc/painter-dom... build (transitive type check) clean.

Closes the direction-taxonomy cleanup wave alongside SD-2777 (#3279 + #3285) and SD-2778 (#3289 + #3290).

…on (SD-2779)

The painter-dom feature module previously called `features/rtl-paragraph/`
handles two related but distinct OOXML elements: w:pPr/w:bidi
(paragraph inline direction) and w:rPr/w:rtl (run inline direction).
Both belong to the inline-direction axis. Table visual direction
(w:bidiVisual) and writing mode (w:textDirection) are separate
orthogonal axes owned elsewhere.

Rename the folder + import path + feature-registry entry to
`inline-direction` so the module name matches the axis, and add an
explicit note (registry comment + index.ts JSDoc) calling out the
two orthogonal axes the module does NOT own.

Internal file (`rtl-styles.ts`) and exported function names
(`applyRtlStyles`, `shouldUseSegmentPositioning`, `isRtlParagraph`,
`resolveTextAlign`) keep their RTL framing because they describe RTL
detection and styling specifically. Only the feature folder name
changes.

Tests: painter-dom 1070 pass. Build sweep
(`pnpm --filter @superdoc/painter-dom... build`) clean.
…note

§17.18.93 is ST_TextDirection (the enum values), not the element location.
w:textDirection lives at §17.3.1.41 (paragraph) and §17.4.72 (cell).

Also soften the "inline direction" framing to "paragraph/run inline bidi
handling": w:rPr/w:rtl is a run-level bidi/RTL/CS trigger, not strictly a
paragraph base-direction signal.

Comment-only; no code change.
@caio-pizzol caio-pizzol requested a review from a team as a code owner May 14, 2026 17:45
@linear
Copy link
Copy Markdown

linear Bot commented May 14, 2026

SD-2779

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@caio-pizzol caio-pizzol merged commit c184083 into main May 14, 2026
70 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-2779-rename-rtl-paragraph-feature branch May 14, 2026 19:14
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 14, 2026

🎉 This PR is included in superdoc v1.30.0-next.95

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 14, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.101

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 14, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.147

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 14, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.145

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 14, 2026

🎉 This PR is included in superdoc-cli v0.8.0-next.116

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 14, 2026

🎉 This PR is included in superdoc-sdk v1.8.0-next.99

caio-pizzol added a commit that referenced this pull request May 16, 2026
…ine-direction

The shouldAssignPerRunRtlDir / normalizeRtlDateTokenForWordParity helpers
and their regexes (RTL_DATE_LIKE_TOKEN_RE, STRONG_RTL_CHAR_RE,
LATIN_DIGIT_NEUTRAL_ONLY_RE) lived at the bottom of renderer.ts. After
#3307 moved the rtl-paragraph feature folder to inline-direction with an
explicit axis scope, the renderer was the wrong home: these helpers are
paint-time decisions about how to project w:rPr/w:rtl onto a rendered
span's dir attribute, which is exactly what features/inline-direction
owns.

Extract into features/inline-direction/run-direction.ts:

- Combine the two-step decision (set dir=rtl? else set dir=ltr for
  date-like?) into a single resolveRunDirectionAttribute helper that
  returns 'rtl' | 'ltr' | null.
- Expose normalizeRtlDateTokenForWordParity alongside since it shares
  RTL_DATE_LIKE_TOKEN_RE.
- Inline the decision table as JSDoc, explicitly scoping the heuristic
  to current SD-3098 fixtures and pointing at the spec sections plus the
  known follow-up gaps (w:dir, w:bdo, w:lang/@bidi numeric, presentation
  forms).

Renderer collapses the per-span direction logic to one helper call.
22 new unit tests in run-direction.test.ts cover both branches of the
rtl-tagged decision table, the date-like ltr fallback for non-tagged
runs, and the regex coverage smoke tests.
msviderok pushed a commit to msviderok/superdoc that referenced this pull request May 16, 2026
…on (SD-2779) (superdoc-dev#3307)

* refactor(painter-dom): rename rtl-paragraph feature to inline-direction (SD-2779)

The painter-dom feature module previously called `features/rtl-paragraph/`
handles two related but distinct OOXML elements: w:pPr/w:bidi
(paragraph inline direction) and w:rPr/w:rtl (run inline direction).
Both belong to the inline-direction axis. Table visual direction
(w:bidiVisual) and writing mode (w:textDirection) are separate
orthogonal axes owned elsewhere.

Rename the folder + import path + feature-registry entry to
`inline-direction` so the module name matches the axis, and add an
explicit note (registry comment + index.ts JSDoc) calling out the
two orthogonal axes the module does NOT own.

Internal file (`rtl-styles.ts`) and exported function names
(`applyRtlStyles`, `shouldUseSegmentPositioning`, `isRtlParagraph`,
`resolveTextAlign`) keep their RTL framing because they describe RTL
detection and styling specifically. Only the feature folder name
changes.

Tests: painter-dom 1070 pass. Build sweep
(`pnpm --filter @superdoc/painter-dom... build`) clean.

* docs(direction): correct OOXML spec citations on the orthogonal-axis note

§17.18.93 is ST_TextDirection (the enum values), not the element location.
w:textDirection lives at §17.3.1.41 (paragraph) and §17.4.72 (cell).

Also soften the "inline direction" framing to "paragraph/run inline bidi
handling": w:rPr/w:rtl is a run-level bidi/RTL/CS trigger, not strictly a
paragraph base-direction signal.

Comment-only; no code change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants