refactor(direction): add getTableVisualDirection helper, migrate consumers (SD-3138)#3279
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…umers (SD-3138) Centralize the read of table visual direction (w:bidiVisual, ECMA-376 section 17.4.1) through one helper, mirroring the paragraph-axis pattern already established for getParagraphInlineDirection. - Add getTableVisualDirection(attrs) to @superdoc/contracts. Reads attrs.tableDirectionContext.visualDirection first (future-ready for when pm-adapter writes the resolved context onto TableAttrs), falls back to attrs.tableProperties.rightToLeft (or bidiVisual alias) for compatibility. - Migrate three consumers off raw reads: - layout-engine/src/layout-table.ts (table-frame X positioning) - painters/dom/src/table/renderTableFragment.ts (visual mirror gate) - super-editor/.../tableBoundaryNavigation.js (RTL cursor nav) Out of scope for this PR: - pm-adapter wiring that populates TableAttrs.tableDirectionContext. Phase 1B - the helper is future-ready but the context isn't written yet, so the fallback path is exercised today. - packages/super-editor/.../TableResizeOverlay.vue reads a different shape (tableMetadata.value.rtl); migration deferred to keep this PR scoped. Companion to SD-3134 and PRs #3272/#3273/#3278; under SD-2771 Wave 3. Tests: - 14 unit tests for getTableVisualDirection (precedence, alias, no signal, null fallback). - 174 painter table tests, 652 layout-engine tests, 189 super-editor table extension tests all pass.
30f4220 to
6079ba2
Compare
caio-pizzol
added a commit
that referenced
this pull request
May 14, 2026
…ection (SD-3141) (#3283) resolveTableDirection previously emitted visualDirection only for the explicit-true case, conflating "no signal" with "explicit false." Per ECMA-376 section 17.4.1 + 17.17.4, w:bidiVisual w:val="0" is an explicit-false that can override a style-cascade true. Cascade-override semantics match paragraph w:bidi, which resolveParagraphDirection already handles symmetrically. The table resolver had a gap. Add the missing else-if branch so an explicit false emits visualDirection: 'ltr'. The helper getTableVisualDirection added in SD-3138 (PR #3279) already returned 'ltr' for the legacy fallback path; this aligns the resolver with the helper so Phase 1B (pm-adapter wiring of tableDirectionContext) does not silently regress the explicit-false case from 'ltr' to undefined. Tests: - rightToLeft: false -> visualDirection: 'ltr' - bidiVisual: false -> visualDirection: 'ltr' - empty input -> visualDirection: undefined - rtl wins when mixed signals present - 24 existing direction tests still pass.
caio-pizzol
added a commit
that referenced
this pull request
May 14, 2026
…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
added a commit
that referenced
this pull request
May 14, 2026
…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
added a commit
that referenced
this pull request
May 14, 2026
…ter (SD-3138 Phase 1B) (#3285) 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
Contributor
|
🎉 This PR is included in vscode-ext v2.3.0-next.137 |
Contributor
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.135 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.92 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc-cli v0.8.0-next.107 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc v1.30.0-next.88 The release is available on GitHub release |
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.
Phase 1A of SD-3138 (under SD-2771 Wave 3). Centralizes the read of table visual direction (
w:bidiVisual, ECMA-376 §17.4.1) through one helper, mirroring the paragraph-axis pattern already established forgetParagraphInlineDirection.What lands
getTableVisualDirection(attrs)to@superdoc/contracts. Readsattrs.tableDirectionContext.visualDirectionfirst (future-ready for when pm-adapter writes the resolved context onto TableAttrs), falls back toattrs.tableProperties.rightToLeft(orbidiVisualalias) for compatibility.tableProperties.rightToLeftreads:layout-engine/src/layout-table.ts— table-frame X positioningpainters/dom/src/table/renderTableFragment.ts— visual mirror gate at paintsuper-editor/.../tableBoundaryNavigation.js— RTL cursor navigationOut of scope (separate phases)
TableAttrs.tableDirectionContext(Phase 1B — the helper is future-ready but the context isn't written yet, so the fallback path is exercised today).packages/super-editor/.../TableResizeOverlay.vuereads a different shape (tableMetadata.value?.rtl); migration deferred to keep this PR scoped.Why now
Before SD-3134 (PR #3272 merged) + #3273 (in review), several spots pre-mirrored for RTL. The fixes removed the worst offenders but the rule still relied on contributor memory. Centralizing the read via a helper makes the rule structural: there's one function to call, and future contributors who try to read
tableProperties.rightToLeftdirectly will be visible to the grep checks shipped in #3278.Verified
getTableVisualDirection(precedence, alias, no signal, null fallback).Companion / sequencing