Skip to content

feat: editor chrome - chips, paste, print, theme, localisation (M10d) - #150

Closed
maxsam4 wants to merge 9 commits into
0xPolygon:stack/collab-m2c-tabsfrom
maxsam4:collab-m10d-chrome
Closed

maxsam4 wants to merge 9 commits into
0xPolygon:stack/collab-m2c-tabsfrom
maxsam4:collab-m10d-chrome

Conversation

@maxsam4

@maxsam4 maxsam4 commented Nov 19, 2026

Copy link
Copy Markdown

Stacked on #149 (M2c), which is stacked on #148 (M2b) and #146 (M2a). Review the nine commits from fix(web): versions from before a document went live… onward; until #149 merges, this PR's diff against master includes the lower PRs.

Summary

M10d of the collaboration plan: the editor surface and chrome.

  • Inline chips (packages/blocks/src/chips.tsx, one line in the schema). @ mentions a person; the slash menu gains Date and Dropdown. They are inline content, so they work in paragraphs and table cells. Props are editor-writable, so nothing is looked up from them: a mention keeps the person's id and the name it was made with (never an email), and serialised pages show text only. Markdown, text and static output read a chip as @name, the date or the chosen value.
  • Rich paste. BlockNote's stock paste already takes Google Docs, Word, Notion and web HTML. Markdown now goes to POST /api/convert/markdown (the importer's parser), so a paste and an upload give the same blocks. Front matter stays as a source block, ids are assigned on insert, the cursor block is captured before the request, and a failed request pastes plain text. The route is documents:write, with a body limit before parsing (413) and a per-user rate limit.
  • Static rendering, export, print. The static rendering now has a small stylesheet that follows light and dark (the companion's data-theme in Primer, the viewer's colour scheme on a share). /d/:docId/print shows /api/documents/:docId/print in a sandboxed frame: a checkpoint's static.html (?version=n), or the live state rendered by the same code, with a print stylesheet (always light) and a script that opens the print dialog. Printing from the live view prints the live state, not a stale checkpoint. The menu offers Markdown, HTML and Print / PDF. Shares already serve the published checkpoint's static.html; a test pins that.
  • Theme and localisation. The BlockNote theme follows Primer's tokens. Every user-facing string in apps/web/src moves to i18n/en.json, read through t(key, vars) (no library), with de, es, fr, ja and zh chosen from navigator.language; BlockNote's dictionary uses the same resolver. A lint test fails on a UI literal left in JSX text, readable attributes, feedback properties or prose strings, so later PRs that add UI text need keys in every locale file.
  • Known gap fixed. Versions from before a document went live showed in History but selected as "not found". VersionSummaryDTO.bundled marks checkpoints; selecting an older version opens it in the legacy version viewer.

Notes and deviations

  • Inline chips are M10a.3 in the plan; they are built here as asked. Chips do not notify the mentioned person (M10a.3's notifier test), which needs a document-change hook, so mentions are display-only for now.
  • The plan names detectMarkdown, which BlockNote does not export. The paste hook wraps editor.pasteMarkdown, so BlockNote's own detection still decides what is Markdown.
  • The dropdown's options are asked for with window.prompt when it is inserted.
  • Translations (de, es, fr, ja, zh) are machine-written and need a native review, especially the sentence fragments in the share, NotebookLM and events-grant dialogs. packages/blocks's source block still has two English labels (Preview, Source), outside apps/web/src.
  • Email digests: no digest sender exists at this base. exportHtml is the renderer they will use.
  • docs/…/authoring.md does not exist at this base, so there is no section to add.

Test evidence

  • CI order run locally, all green: codegen-drift-check, db:migrate:test, typecheck, -r build, test (api 93 files / 880 tests, web 34 / 349, blocks 2 / 3, mcp 5 / 124), audit --audit-level=high (one low finding).
  • New tests:
    • versions from before the document went live are listed as not bundled and a web test that selecting one opens the viewer;
    • share link of a live doc serves the published checkpoint, not live state;
    • print renders the checkpoint or the live state, light and sandboxed;
    • pasted Markdown becomes the same blocks as an upload, front matter and bad bodies, an oversized body refused with 413 before parsing, and the rate limit;
    • chips: a chip in a paragraph and a table cell survives Markdown, text and the static page with no inputs, and forged props produce no element or handler;
    • editor uses the dark theme when Primer is dark, every locale file has every key in en.json, and no JSX text literal remains outside i18n.
  • Real browser (Chrome via Playwright, pnpm dev API in mock auth plus Vite):
    • typing @ listed a person and inserted @Mock Reviewer; /date inserted a date chip;
    • pasting Google Docs HTML gave a heading, bold, link and list, and pasting Markdown text gave a heading, table and list through the importer;
    • dark mode set data-color-scheme="dark" with Primer's dark tokens;
    • Export Markdown downloaded the document including the chips, and /d/:docId/print rendered it and produced a PDF;
    • a checkpoint opened as a top-level page in a dark colour scheme had a dark background, text chips and no inputs;
    • a read-only viewer saw a non-editable editor, and a de-DE browser showed German chrome and library.
    • The browser check found a real bug: under tsx the chips rendered blank in server output (React is not defined, swallowed); fixed with an explicit JSX runtime pragma.

🤖 Generated with Claude Code

maxsam4 and others added 9 commits November 19, 2026 22:08
…on viewer

History listed every version, but selecting one from before the document went
live asked for a Y.Doc that was never captured, so it showed 'not found'. The
versions list now says which versions are bundled checkpoints; selecting an
older one opens it in the legacy read-only viewer, which already renders its
stored HTML.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The static rendering (a checkpoint's static.html) carried BlockNote's
structural CSS but no colours, so a share or a checkpoint view in dark mode
was dark text on white. It now has a small stylesheet that follows the
companion's data-theme in Primer and the viewer's colour scheme on a share.

Print / PDF is /d/:docId/print: a sandboxed frame on
/api/documents/:docId/print, which serves a checkpoint's static.html (or the
live state, rendered by the same code) with a print stylesheet and a script
that opens the print dialog; print is always light. A test pins that a share
link of a live document serves the published checkpoint, not live state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
BlockNote's paste already takes HTML from Google Docs, Word, Notion and the
web. What Primer changes is Markdown: text BlockNote recognises as Markdown
goes to POST /api/convert/markdown, the importer's parser, so a paste and an
upload of the same text give the same blocks. Front matter stays in the paste
as a source block, ids are assigned by the editor on insert, and the cursor
block is captured before the request so the result lands where the paste was.
The route is documents:write and capped at 1M characters.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Three inline content types in Primer's schema (each its own file in
packages/blocks), usable in paragraphs and table cells: @ mentions a person,
and the slash menu gains Date and Dropdown. A chip's props are editor-writable,
so nothing looks anything up from them: a mention keeps the person's id and the
name it was made with, never an email, and serialised pages show only text
(no inputs). Text export reads a chip as @name, the date or the chosen value.

The convert route also gets a body limit before parsing and a per-user rate
limit, so an oversized paste is refused without being buffered.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
chips.tsx was blank in the server's Markdown, HTML and print output when the
API ran under tsx (dev), because tsx didn't pick up packages/blocks's
react-jsx setting and the server render threw 'React is not defined', which
the export swallowed. The pragma makes the JSX runtime explicit in both files
that hold JSX. Found in the browser check; vitest uses the automatic runtime
so the tests passed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Every user-facing string in apps/web/src moves to en.json and is read through
t(key, vars), with no library. de, es, fr, ja and zh are picked from
navigator.language (en otherwise), and BlockNote's own dictionary comes from
the same resolver. Tests: every locale has every key and placeholder in
en.json, the language picks the locale, and a lint test fails on a user-facing
literal left in JSX text, readable attributes, feedback properties or prose
strings, so a new literal in a later change fails CI until it is added to
en.json (and the other locale files).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@maxsam4
maxsam4 changed the base branch from master to stack/collab-m2c-tabs November 19, 2026 19:27
@maxsam4
maxsam4 force-pushed the stack/collab-m2c-tabs branch 6 times, most recently from 77a0995 to 099348a Compare November 19, 2026 19:36
@maxsam4
maxsam4 force-pushed the stack/collab-m2c-tabs branch 2 times, most recently from 02de106 to 88b29ca Compare November 19, 2026 20:10
@maxsam4
maxsam4 force-pushed the stack/collab-m2c-tabs branch 2 times, most recently from 68f1ccb to 1c18da6 Compare November 19, 2026 20:17
@maxsam4
maxsam4 force-pushed the stack/collab-m2c-tabs branch 2 times, most recently from b1c373d to 62c1116 Compare November 19, 2026 20:33
@maxsam4
maxsam4 force-pushed the stack/collab-m2c-tabs branch 2 times, most recently from 8a69213 to dd12399 Compare November 19, 2026 20:56
@maxsam4

maxsam4 commented Nov 19, 2026

Copy link
Copy Markdown
Author

Replaced by #171, part of the native stacked PR chain (#162 → #182). Review history stays here.

@maxsam4 maxsam4 closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant