Repository navigation
Conversation
A caret whose paragraph moved to another page is repaired first; a caret on a page out of view then scrolls it into view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pierreneter
left a comment
There was a problem hiding this comment.
Thanks, both fixes look right to me. The append loops remove every document-sized spread in the Markdown and HTML import paths. The scroll mapping follows XlsxView (same 12,000,000 px cap). It changes nothing for documents under the cap, where scrollScale is 1 and scrollOffset is 0. Find, outline, comment and caret navigation all go through scrollToY / scrollByY, and the only raw scrollTop left (imgBox, DocxView.tsx:596) is a physical measurement, so it is correct as it is. This is from reading the code; I have not run it.
About merge order (not a defect in this PR): this conflicts with #8 in src/react/docx/DocxView.tsx, and the stack adds a scroll write of its own. The controller's gotoPage (DocxView.tsx:836 at #9's head fef4db0) does sc.scrollTop = Math.max(0, top - 16), a logical position written to the physical scrollTop. Past the cap, ctl.goto to a page lands about scrollScale times too far down. The stack is close to merging, so I'd rebase this onto main after it and send gotoPage (and the published cur page) through scrollToY / scrollY while resolving the conflict.
Non-blocking, worth a follow-up issue rather than more work here:
- Past the cap, the pages sit in the scrolled content and are moved by
top={tops[i] - scrollOffset}. A native scroll first moves them by the physical distance, and the next frame moves them the rest of the way. The same applies to scrolls the browser makes by itself in the contenteditable: caret into view on arrow keys or Enter at the bottom edge, and autoscroll while drag-selecting. The browser scrolls by the visual distance and the next render moves the contentscrollScaletimes as far, so the caret overshoots by(scale − 1)times the step. At the 50 MB file's scale (about 2) this is mild. It also re-renders every mounted page on each scroll frame. The spreadsheet avoids both because.de-grid-viewstays fixed in the viewport while the spacer scrolls. Moving one wrapper instead of each page would at least remove the re-renders. MAX_SCROLL_PXis now defined in bothDocxView.tsxandXlsxView.tsx. One shared constant would keep them from drifting apart.
Opening a 50 MB Markdown file fails with
Maximum call stack size exceededbecause the importer passes all parsed paragraphs to onepush(...items)call. After resolving that, the resulting 21,112-page document exceeds the browser’s element-height limit, leaving its final pages unreachable.This PR fixes both:
The existing DOM rendering and visual editing path are retained, with no new runtime dependencies.
Regression coverage includes 150,000-paragraph Markdown and HTML inputs, a 150,000-line code block, and a document beyond the browser’s scroll-height limit whose final page is reached, searched, edited and saved. The original 50 MB fixture now loads completely, and its final marker is reachable and searchable.
Validation
mainand pass with this change.git diff --checkpassed.The browser checks cover the new regressions plus existing document editing, selection, page setup and comments.