oficina / docs Public

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>
Paul Campbell pushed by paul@keymail.dev bb02b67b048d38b1cdec85d479132856e6335748 parent 6a92585
20 files changed, +766 −395
  • AGENTS.md +23 −11
  • core/src/fragment.rs +6 −0
  • core/tests/fragment.rs +18 −0
  • fixtures/editor-entry.js +117 −245
  • fixtures/engines/first-reveal.mjs +84 −4
  • fixtures/font-session.mjs +14 −2
  • fixtures/generate-fragment.mjs +3 −0
  • fixtures/generate-random-docs.mjs +83 −73
  • fixtures/schema.mjs +176 −0
  • fixtures/vectors/fragment/remote-codeblock.bin binary
  • internal/core/testdata/docs_core.wasm binary
  • internal/docs/export_test.go +11 −4
  • internal/docs/fonts_browser_test.go +152 −39
  • internal/docs/fonts_engines_browser_test.go +2 −1
  • internal/docs/static/editor.1abdb58cba7929f1.js +14 −0
  • internal/docs/static/editor.2ef9718cfc019d1b.js +0 −14
  • internal/docs/static/{fontsgate.6c5e7562118191ca.js => fontsgate.81c2a1963b36cad4.js} +1 −1
  • internal/export/document.go +3 −0
  • internal/export/pdf.go +21 −1
  • internal/export/pdf_test.go +38 −0

CI passed — run details

AGENTS.md

Loading diff…

core/src/fragment.rs

Loading diff…

core/tests/fragment.rs

Loading diff…

fixtures/editor-entry.js

Loading diff…

fixtures/engines/first-reveal.mjs

Loading diff…

fixtures/font-session.mjs

Loading diff…

fixtures/generate-fragment.mjs

Loading diff…

fixtures/generate-random-docs.mjs

Loading diff…

fixtures/schema.mjs

Loading diff…

fixtures/vectors/fragment/remote-codeblock.bin

Loading diff…

internal/core/testdata/docs_core.wasm

Loading diff…

internal/docs/export_test.go

Loading diff…

internal/docs/fonts_browser_test.go

Loading diff…

internal/docs/fonts_engines_browser_test.go

Loading diff…

internal/docs/static/editor.1abdb58cba7929f1.js

Loading diff…

internal/docs/static/editor.2ef9718cfc019d1b.js

Loading diff…

internal/docs/static/{fontsgate.6c5e7562118191ca.js => fontsgate.81c2a1963b36cad4.js}

Loading diff…

internal/export/document.go

Loading diff…

internal/export/pdf.go

Loading diff…

internal/export/pdf_test.go

Loading diff…