One font gate for every change; code blocks and the schema decide families
Branch review 5 on #83 found two more paths with no font wait of their own: a pasted code block (<pre> parses as code_block, whose text has no code mark, but the editor draws it as <pre><code> in Liberation Mono), and an HTML drop (ProseMirror's drop path never passed through handlePaste). The coordinator asked for the class to be closed: every change through one gate. The gate. fontGatePlugin is a ProseMirror transaction filter, and every local transaction passes it. It works out the families a transaction would put text in: the content its steps insert, the marks they add, and the stored marks it sets. If any family is not settled, the transaction is held and nothing is drawn. When the family arrives, or is committed because it is new and late, the held steps are rebased over every change made since, the way prosemirror-collab rebases unconfirmed steps, and applied. Paste, drop, input rules, typing, commands and picks all go through it. The per-path waits are gone: handlePaste's wait, the afterFaces command wrapper, and the editor's not-editable-until-loaded hold. Yjs-origin changes (collaborators, undo, redo) cannot be held at that boundary without the editor falling out of step with Yjs, so they are checked before they reach Yjs, by the same family rule. Picks still load first, so the latest pick wins. The schema decides. fixtures/schema.mjs is the editor's schema on its own, loadable in Node. familyOfNode and familyOfMark read families off it: a font_<key> mark is its family, and a spec with code: true (the code mark, the code_block node) is code's. The editor's walk over its log, the transaction gate and the collaborator byte scan all take their families from those two. Go's export.CodeNodes is held to the schema by TestCodeNodesAreTheSchemasCodeNodes, which runs node. Code blocks count in FamiliesUsed and are set as code in the PDF. The Rust renderer now draws code_block as <pre><code>, so the server's read view is in the code face before the editor mounts, not the body face until then. Tests, each failing first: - The engines check gains review 5's two cases, a pasted code block and an HTML drop, with the font 8 s late. After the action, every capture must be the picture before it or the final one, the final face must have loaded or been committed, and the per-frame font probe now runs in both engines. Chromium failed both before the gate and passes now. WebKit drew both in a stable face from the first frame in this harness, before and after the change, with no probe violation. - TestFontEveryInputPathWaitsForItsFamily is one table of input paths, each given a cold, slowed family: a pasted code block, a pasted font, a drop, a code toggle then typing, a list input rule after a code toggle, paste then undo and redo, and a collaborator's code block. The code-block paste and the drop failed before the gate. - The generator now walks the schema's own content expressions, with every mark the parent allows, and fails unless every node type and mark appeared across the set. The generative test checks the server-rendered DOM (editor bundle refused) and the mounted editor's DOM. Before the fix it reported the editor drawing code blocks in Liberation Mono, a family the gate had not waited for. - core/tests: renders_a_code_block_as_the_editor_does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 files changed,
+766
−395
AGENTS.md+23 −11core/src/fragment.rs+6 −0core/tests/fragment.rs+18 −0fixtures/editor-entry.js+117 −245fixtures/engines/first-reveal.mjs+84 −4fixtures/font-session.mjs+14 −2fixtures/generate-fragment.mjs+3 −0fixtures/generate-random-docs.mjs+83 −73fixtures/schema.mjs+176 −0fixtures/vectors/fragment/remote-codeblock.binbinaryinternal/core/testdata/docs_core.wasmbinaryinternal/docs/export_test.go+11 −4internal/docs/fonts_browser_test.go+152 −39internal/docs/fonts_engines_browser_test.go+2 −1internal/docs/static/editor.1abdb58cba7929f1.js+14 −0internal/docs/static/editor.2ef9718cfc019d1b.js+0 −14internal/docs/static/{fontsgate.6c5e7562118191ca.js => fontsgate.81c2a1963b36cad4.js}+1 −1internal/export/document.go+3 −0internal/export/pdf.go+21 −1internal/export/pdf_test.go+38 −0
CI passed — run details
Intent
AGENTS.mdLoading diff…
core/src/fragment.rsLoading diff…
core/tests/fragment.rsLoading diff…
fixtures/editor-entry.jsLoading diff…
fixtures/engines/first-reveal.mjsLoading diff…
fixtures/font-session.mjsLoading diff…
fixtures/generate-fragment.mjsLoading diff…
fixtures/generate-random-docs.mjsLoading diff…
fixtures/schema.mjsLoading diff…
fixtures/vectors/fragment/remote-codeblock.binLoading diff…
internal/core/testdata/docs_core.wasmLoading diff…
internal/docs/export_test.goLoading diff…
internal/docs/fonts_browser_test.goLoading diff…
internal/docs/fonts_engines_browser_test.goLoading diff…
internal/docs/static/editor.1abdb58cba7929f1.jsLoading diff…
internal/docs/static/editor.2ef9718cfc019d1b.jsLoading diff…
internal/docs/static/{fontsgate.6c5e7562118191ca.js => fontsgate.81c2a1963b36cad4.js}Loading diff…
internal/export/document.goLoading diff…
internal/export/pdf.goLoading diff…
internal/export/pdf_test.goLoading diff…