Skip to content

feat(direction): populate TableAttrs.tableDirectionContext in pm-adapter (SD-3138 Phase 1B)#3285

Merged
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/SD-3138-phase-1b
May 14, 2026
Merged

feat(direction): populate TableAttrs.tableDirectionContext in pm-adapter (SD-3138 Phase 1B)#3285
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/SD-3138-phase-1b

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol commented May 14, 2026

Closes SD-3138 Phase 1B. Phase 1A (#3279) landed the getTableVisualDirection helper and migrated three consumers. The helper preferred a resolved TableDirectionContext but pm-adapter never wrote one — consumers fell through to the legacy fallback path on every read. This PR closes the loop.

What lands

  • Add tableDirectionContext?: TableDirectionContext to TableAttrs in @superdoc/contracts. Mirrors the directionContext field on ParagraphAttrs shipped by Wave 1a (SD-2776).
  • In pm-adapter/src/converters/table.ts, resolve the effective table direction from cascade-resolved table properties (style cascade + inline override) and write the result via resolveTableDirection.

Cascade semantics

Inline w:bidiVisual wins over the style cascade; explicit false overrides a cascade true per §17.4.1 + §17.17.4. Aliases (rightToLeft / bidiVisual) are normalized to a single signal per layer before layering inline over style, so an inline bidiVisual: false correctly overrides a style rightToLeft: true. Relies on the SD-3141 resolver-symmetry fix already in main.

Verified scenarios (6 new converter tests):

  • Inline rightToLeft: true'rtl'
  • Style cascade rightToLeft: true'rtl'
  • Inline false overriding style cascade true'ltr'
  • Alias-mixed inline bidiVisual: false overriding style rightToLeft: true'ltr'
  • No signal anywhere → undefined
  • tableDirectionContext.parentSection propagates from converterContext.sectionDirectionContext

Tests:

  • pm-adapter: 1836 tests pass (63 in table.test.ts, including the 6 above)
  • painter table: 174 tests pass

Layout-comparison heads-up: Adding tableDirectionContext to TableAttrs introduces a new field that the layout JSON serializer will emit for table-bearing documents. Expect schema-evolution diffs in pnpm layout:compare until the reference baseline is updated through the normal layout process; the diffs are additive (new field present in candidate, absent in reference) and not a behavior regression.

Sequencing: companion to #3279 (Phase 1A), #3283 (SD-3141 resolver symmetry — required, already merged), and #3284 (SD-3142 export preservation — independent, already merged). After this lands, all Wave 3 architectural foundation tickets close.

@caio-pizzol caio-pizzol requested a review from a team as a code owner May 14, 2026 10:54
@linear
Copy link
Copy Markdown

linear Bot commented May 14, 2026

SD-3138

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ter (SD-3138 Phase 1B)

Phase 1A (PR #3279) landed the getTableVisualDirection helper and
migrated three consumers. The helper preferred a resolved
TableDirectionContext but pm-adapter never wrote one - consumers fell
through to the legacy fallback path on every read.

Phase 1B closes the loop:

- Add tableDirectionContext?: TableDirectionContext to TableAttrs in
  @superdoc/contracts (mirrors directionContext on ParagraphAttrs from
  Wave 1a / SD-2776).
- In pm-adapter table.ts, resolve the effective table direction from
  cascade-resolved table properties (style cascade + inline override)
  and write the result via resolveTableDirection.

The cascade resolution uses style-engine's resolveTableProperties for
the style chain and `??` to layer inline on top. Because `??` treats
null/undefined as missing but preserves explicit false, inline
w:bidiVisual w:val="0" correctly overrides a style cascade true and
produces visualDirection: 'ltr' (relies on SD-3141 resolver symmetry).

After this lands, the helper's fast path is exercised at runtime:
- Inline true → 'rtl'
- Style cascade true → 'rtl'
- Inline false overriding style true → 'ltr'
- Absent signal → undefined

Tests:
- 4 new converter tests for the cascade scenarios above
- pm-adapter: 1836 tests pass
- painter table: 174 tests pass
@caio-pizzol caio-pizzol force-pushed the caio-pizzol/SD-3138-phase-1b branch from 263b06c to c52569c Compare May 14, 2026 11:17
@caio-pizzol caio-pizzol merged commit bb74ea2 into main May 14, 2026
68 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-3138-phase-1b branch May 14, 2026 11:36
@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.137

@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.135

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.92

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.107

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 v1.30.0-next.88

The release is available on GitHub release

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