feat: support paragraph between borders (w:pBdr/w:between)#2324
Open
caio-pizzol wants to merge 10 commits intomainfrom
Open
feat: support paragraph between borders (w:pBdr/w:between)#2324caio-pizzol wants to merge 10 commits intomainfrom
caio-pizzol wants to merge 10 commits intomainfrom
Conversation
6 tasks
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70de4d7213
ℹ️ 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".
packages/layout-engine/painters/dom/src/features/paragraph-borders/group-analysis.ts
Show resolved
Hide resolved
70de4d7 to
4110a37
Compare
Flow `w:between` borders through the rendering pipeline so consecutive paragraphs sharing the same border definition display a horizontal separator line between them. - Add `between` to `ParagraphBorders` contract type - Include `between` in `normalizeParagraphBorders` side iteration - Add `bw:` segment to `hashParagraphBorders` in both hash util files - Add `computeBetweenBorderFlags` to pre-compute which fragments need the between border, following the `computeSdtBoundaries` pattern - Render between border as CSS `border-bottom` on decoration overlay - Handle header/footer sections, page splits, and patch invalidation - Add 55+ tests covering edge cases
Cover the patch path in renderer.ts where a fragment switches in/out of a between-border group, verifying the DOM node is rebuilt when the betweenBorderMismatch flag flips.
Extract paragraph border rendering into feature module at features/paragraph-borders/ with improved between-border support. - BetweenBorderInfo type replaces boolean flag, carrying gap extension and top suppression data per fragment - Border layers extend into spacing gaps for continuous group borders - Top borders suppressed for non-first group members - nil/none between borders no longer form groups - Feature registry maps OOXML elements to rendering modules
4110a37 to
80eff63
Compare
- Extract getFragmentHeight from renderer.ts, reuse from group-analysis - Extract stampBetweenBorderDataset helper for consistent dataset stamping - Move BlockLookup types to single source of truth in types.ts - Add column break guard (frag.x !== next.x) to prevent cross-column grouping - Add tests for suppressTopBorder, gap extension, and column breaks
- 16 tests for indent-aware border box sizing (left, right, firstLine, hanging, NaN/Infinity clamping, combined indents) - Remove orphaned between-borders-comprehensive.docx from test-data/
Word groups consecutive paragraphs with matching borders into a single
bordered box even when w:between is nil/none — it just omits the
separator. SuperDoc was skipping grouping entirely for nil/none between,
rendering each paragraph as a separate bordered box.
- Preserve between: {style: 'none'} during normalization so downstream
can distinguish "explicitly nil/none" from "no between element"
- Change grouping check to allow nil/none between through
- Add suppressBottomBorder flag for nil/none groups (extend gap without
drawing a separator)
The OOXML `space` attribute on w:pBdr sides specifies the distance between the border line and the paragraph text (in points). Word uses this to create visible padding inside bordered paragraphs. - Add computeBorderSpaceExpansion() to convert space values to px - Expand the border/shading layers outward by the space amount - Suppress top/bottom space within between-border groups where those sides are already handled by gap extension
With box-sizing: border-box, CSS borders are drawn inside the element. The border layer must expand by space + borderWidth (not just space) so the border's inner edge sits at the correct distance from text. The shading layer only needs space expansion since it has no CSS borders.
The between border was flush against the next paragraph's text. Now: - First paragraph reduces gap extension by between.space, positioning the between border higher in the spacing gap - Second paragraph extends upward by between.space to maintain continuous left/right borders through the gap
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.
No description provided.