refactor: extract font-readiness from PagedEditor into core controller#149
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughInitial-layout font readiness utilities move from ChangesFont readiness extraction
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PagedEditor
participant fontReadiness
participant DocumentFonts
PagedEditor->>fontReadiness: waitForInitialLayoutFonts(documentModel, pmDoc)
fontReadiness->>fontReadiness: collect required font faces
fontReadiness->>DocumentFonts: load font-face queries
DocumentFonts-->>fontReadiness: readiness or timeout result
fontReadiness-->>PagedEditor: boolean readiness result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors the initial-layout font-readiness logic by moving it out of the React-specific PagedEditor.tsx component into a framework-neutral @stll/folio-core/controller/fontReadiness module, along with corresponding unit tests. Feedback on the changes highlights two potential runtime issues: a potential TypeError when accessing properties of documentModel.package if package is undefined, and a potential ReferenceError when calling window.setTimeout in non-browser environments (such as SSR or headless environments) where window is not defined.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
8ddd825 to
75e4841
Compare
First slice of moving orchestration out of the 6k-line PagedEditor.tsx God component into the framework-neutral core controller. Move the initial-layout font-readiness logic (font-face collection from the document model + PM content, the load gate, and the browser font-set probe) into @stll/folio-core/controller/fontReadiness. The existing font-collection test moves to core alongside the code (plus two new cases: the SSR/headless guard and the null-model default floor). PagedEditor imports the functions instead of defining them; INITIAL_FONT_READY_SUPPRESSION_MS (React effect policy) stays behind. Arch tests (react-free-core, layer-boundaries, model-purity) green; no public API change.
75e4841 to
4ee4735
Compare
First slice of the God-module extraction (audit's #1 structural item): carve orchestration out of
packages/react/src/paged-editor/PagedEditor.tsx(~6,150 lines) into the framework-neutral core controller, leaving the React file as a lifecycle+DOM shell.What moved
collectInitialLayoutFontFaces,collectInitialLayoutFontFamilies,documentFontsAreLoaded,getDocumentFontSet,waitForInitialLayoutFonts(+ their private helpers/constants) →@stll/folio-core/controller/fontReadiness. This logic decides which font faces a document needs (from its model + ProseMirror content), gates the first layout on them loading, and probes the browser font set.Why this slice first
.tsx.documentFontsAreLoadedis duplicated in the Vue adapter and is already an injected dependency of the core layout pipeline; a fast-follow can point Vue at this same module.loadingdone, never in the pagination inner loop.Boundary safety
document.fonts/windoware only touched at call time (same pattern as the existingbrowserClock), so the module stays importable in non-browser hosts.react-free-core,layer-boundaries, andmodel-purityarch tests all stay green.Verification
typecheck(all 7 packages),lint,format:checkcleanlayoutPipelinetest (consumes thedocumentFontsAreLoadedseam) greeninteractionsjobFollow-ups (separate PRs): point the Vue adapter's
documentFontsAreLoadedat this module; then the next slices (buildLayoutInputSignature, pointer pipeline, HF lifecycle).Summary by CodeRabbit
Bug Fixes
Refactor