Repository navigation
feat(docx): tables and paragraphs split across pages, header rows repeated, keep rules - #42
Open
pierreneter wants to merge 9 commits into
Open
pierreneter wants to merge 9 commits into
pierreneter wants to merge 9 commits into
Conversation
…its style and the document defaults Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en rows, header rows repeated The pure page cutter, given where each block's lines or rows are: what does not fit a page goes on on the next one, one line or row taller than a page makes its page grow, text columns are filled the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t one, its header rows repeated The measure pass reads where the rows of a table are; pages cut it between rows. The pages after the first start with a copy of the header rows (shown, not editable). A merged cell cut by a page end keeps its text on its first page and goes on below as an empty cell; one whose text would not fit above the cut keeps those rows together. Text columns are laid out as columns of their own, filled like pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… next one, split between two lines The measure pass reads where each line of a paragraph is, and for the paragraphs a page in view cuts, the offset each line starts at; the page shows the lines that fit, the next page the rest, with the same line breaks (no first-line indent or space before on the second part, the first part's last line justified when the paragraph is). Keep rules choose the cut: widow / orphan control, keep lines together, keep with next. A split paragraph is edited as one: its parts carry the offsets they hold, and the DOM <-> offset mapping goes across them (caret, selection, find highlights, comment drafts, collaborators' cursors). Arrow keys step over the page end one character; typing that moves the page end keeps the caret on the side it was typed on; edited paragraphs are measured again before the page is painted; the pages stay as they are while an input method composes. Printing waits until every cut paragraph is read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed without looking at their lines, typing cuts the pages once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mment over the page end, a Word 97 file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ss the page end Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Widow control absent from a DOCX now means on, as Word reads it. The Word 97 and RTF converters write it only where a paragraph or style has it, so the paragraphs of those files without it came out with it on. Their document defaults now say it is off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Part of #30: plan items 1 to 3, in the current (browser) layout.
The DOCX view now splits blocks across pages instead of moving them whole:
keepNextandkeepLines.Editing works across the page cut. Pages grow taller than the paper only for a single line or row that is taller than the page. Rendering stays DOM, and the browser still breaks lines. The
pageLayoutoption and theexactmode are later work. Item 4, fonts, is in #39.What changed
types.ts,styles.ts):keepLinesandwidowControlare read from the paragraph, its style chain and the document defaults.widowControlis absent it counts as on, as Word reads it.paginate.ts(pure):from/to(where its first block starts and its last block stops) andcols.keepLines, which is ignored for a paragraph taller than a page;keepNextchains, which include the first part of the next block. A chain taller than a page is let go, so nothing is pushed forever.measure.ts(new):Range. OneRangeper paragraph made DOM removals very slow in Chrome.render.tsx:[from, to). A later part starts with copies of the header rows: nodata-pa, not editable, not found twice by find. A merged cell is clipped at the cut and continues as an empty cell.[from, to).DocxView.tsx:pageOfPos) know offsets and rows. Scroll-to-caret, find, comment reveal and the outline use them.input.ts, the one place where DOM and offsets meet:paraEl()picks the part that shows an offset, with an upstream bias at the cut.posFromDomanddomFromPoswork across parts;paraRanges()gives one range per part.reflow()restores the caret after a re-layout.DocxEditor.ts: an edited block keeps its old height and lines, with line starts shifted by the edit, until it is measured again.collab/docx.ts: a collaborator's selection is drawn part by part.docs/features.md,README.md, and a new "DOCX pages" section indocs/development.md.e2e/docx-page.spec.tschecked CSScolumn-count. It now checks for the column boxes.Tests
test/docx-builder.ts(new): a minimal DOCX builder.test/docx-keep.test.ts:keepLinesandwidowControlread from the paragraph, its style (includingbasedOn) and the document defaults;test/docx-paginate.test.ts(19 tests):keepLines,keepNext(a chain, before a table, a page break after it), and a chain taller than a page.e2e/docx-split.spec.ts(18 tests in Chromium):\nline breaks and a hanging indent.keepLines,keepNextchains, and a caption kept with its table..doc, and print.On
main, all 18 e2e tests and both earlier keep tests fail.Results
In the Linux test VM with Bun 1.4.4:
bun testdocx,docx-qa2,docx-hf,docx-track,docx-table,docx-page,docx-split,comments,comments-collab,collab,legacy,viewer,file-menu,security,permissions)After the converter fix and the rebase onto
af19290, I re-ran typecheck, the whole unit suite, thelegacyanddocx-splite2e specs, and the build.docx-track"typing is underlined" can flake, as it does onmain: tracked-change dates have one-second resolution. #38 says more about this.Performance
Measured with
large-doc.docxin the shared VM, on the Vite dev server with the React development build.mainThe extra load time comes from about 20% more measure batches, because reading lines makes each batch slower, plus
paginateat about 0.5 s in total. Two README / features rows (2073 pages in about 2 s; 7 ms per keystroke) were measured on a Mac and should be measured again there, since the page count changes.Not done
cantSplithas no effect and is not parsed.keepNextparagraph is moved whole;Merging
src/react/docx/DocxView.tsxanddocs/features.md. feat: the host supplies font files, and documents are laid out once they are loaded #39's scroll anchor sums block heights from the page start, so it has to account for parts.DocxView.tsxscroll targets;RichInput.crossPartininput.tsscrolls by pixels, so it would need fix(markdown): avoid import stack overflow and keep final pages reachable #31's logical-to-physical mapping.🤖 Generated with Claude Code