Skip to content

Commit 15ab9c8

Browse files
caio-pizzolharbournick
authored andcommitted
refactor(painter-dom): rename rtl-paragraph feature to inline-direction (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.
1 parent c1bd82d commit 15ab9c8

5 files changed

Lines changed: 29 additions & 19 deletions

File tree

packages/layout-engine/painters/dom/src/features/feature-registry.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ export const RENDERING_FEATURES = {
3232
spec: '§17.3.1.31',
3333
},
3434

35-
// ─── RTL Paragraph ─────────────────────────────────────────────
35+
// ─── Inline Direction ──────────────────────────────────────────
36+
// Paragraph/run inline bidi handling. NOT table visual direction
37+
// (w:bidiVisual, §17.4.1), NOT writing mode (w:textDirection,
38+
// §17.3.1.41 paragraph / §17.4.72 cell; values in §17.18.93).
3639
// @spec ECMA-376 §17.3.1.1 (bidi), §17.3.2.30 (rtl)
3740
'w:bidi': {
38-
feature: 'rtl-paragraph',
39-
module: './rtl-paragraph',
41+
feature: 'inline-direction',
42+
module: './inline-direction',
4043
handles: ['w:pPr/w:bidi', 'w:rPr/w:rtl'],
4144
spec: '§17.3.1.1',
4245
},
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Inline Direction - rendering feature module
3+
*
4+
* Centralises paragraph base-direction and run-level RTL/bidi handling
5+
* used by DomPainter:
6+
* - Detecting whether a paragraph is RTL
7+
* - Applying dir="rtl" and the correct text-align to an element
8+
* - Resolving text-align for RTL vs LTR (justify -> right/left)
9+
* - Deciding whether segment-based (absolute) positioning is safe
10+
*
11+
* Scope is paragraph/run inline bidi handling only. Table visual
12+
* direction (w:bidiVisual, ECMA-376 §17.4.1) is a separate orthogonal
13+
* axis owned by the painter's table rendering path. Writing mode
14+
* (w:textDirection, ECMA-376 §17.3.1.41 paragraph / §17.4.72 cell;
15+
* values in §17.18.93 ST_TextDirection) is another separate axis.
16+
*
17+
* @ooxml w:pPr/w:bidi - paragraph bidirectional flag
18+
* @ooxml w:rPr/w:rtl - run-level right-to-left flag
19+
* @spec ECMA-376 §17.3.1.1 (bidi), §17.3.2.30 (rtl)
20+
*/
21+
22+
export { applyRtlStyles, shouldUseSegmentPositioning } from './rtl-styles.js';

packages/layout-engine/painters/dom/src/features/rtl-paragraph/rtl-styles.ts renamed to packages/layout-engine/painters/dom/src/features/inline-direction/rtl-styles.ts

File renamed without changes.

packages/layout-engine/painters/dom/src/features/rtl-paragraph/index.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/layout-engine/painters/dom/src/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ import {
125125
stampBetweenBorderDataset,
126126
type BetweenBorderInfo,
127127
} from './features/paragraph-borders/index.js';
128-
import { applyRtlStyles, shouldUseSegmentPositioning } from './features/rtl-paragraph/index.js';
128+
import { applyRtlStyles, shouldUseSegmentPositioning } from './features/inline-direction/index.js';
129129
import { convertOmmlToMathml } from './features/math/index.js';
130130

131131
/**

0 commit comments

Comments
 (0)