Read-only rendering of a document's blocks.
Release notes 2.4
Shared pages load twice as fast, and comments now stay on the sentence they're about.
Workspaces update over the next week. Nothing to do on your side.
What's new
- Comments anchored to a range of text
- Inline databases with saved views
- Table, board and list layouts
- Faster search across every page
Before you upgrade
Back up custom templates
Tell your team about the new shortcuts
const ready = checks.every((check) => check.passed)import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { fromMarkdown } from "./ui/uicontext/components/kit/Blocks.ts"import { BlocksView } from "./ui/uicontext/components/kit/EditorBlocks.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius, space } from "./ui/uicontext/components/tokens.stylex.ts"// A published page, read-only: the same blocks the editor writes, drawn as plain elements with no// editing. Use it for a shared page, a printout, a message preview or a version in history.const styles = stylex.create({ page: { inlineSize: "min(100%, 40rem)", paddingBlock: space.xl, paddingInline: { default: space.xxl, "@media (max-width: 600px)": space.lg }, borderRadius: radius.lg, borderWidth: 1, borderStyle: "solid", borderColor: color.line, backgroundColor: color.panel, },})let next = 0const releaseNotes = fromMarkdown( [ "# Release notes 2.4", "", "Shared pages load **twice as fast**, and comments now stay on the sentence they're about.", "", "> [!NOTE]", "> Workspaces update over the next week. Nothing to do on your side.", "", "## What's new", "", "- Comments anchored to a range of text", "- Inline databases with saved views", " - Table, board and list layouts", "- Faster search across every page", "", "## Before you upgrade", "", "- [x] Back up custom templates", "- [ ] Tell your team about the new shortcuts", "", "```ts", "const ready = checks.every((check) => check.passed)", "```", ].join("\n"), () => `note-${(next += 1)}`,)export const ReleaseNotes = <M>(h: Html.H<M>) => BlocksView(h, { blocks: releaseNotes, label: "Release notes 2.4", style: styles.page })Installation
pnpm dlx shadcn@latest add checkfu/uicontext/blocksUsage
import type { Block } from "./ui/uicontext/components/kit/Blocks.ts"import { BlocksView } from "./ui/uicontext/components/kit/EditorBlocks.ts"export const PublishedPage = <M>(h: Html.H<M>, page: { readonly title: string; readonly blocks: ReadonlyArray<Block> }) => BlocksView(h, { blocks: page.blocks, label: page.title })Examples
Toggles, pictures and code
Readers open and close toggles with a click or the keyboard; pictures keep their place while they load; code names its language.
Your first week
Everything you need to ship your first change by Friday.
Get access
Sign in to the workspace with your work email
Ask Priya Nair for the billing project
Run the app locally
bun install
bun run dev --port 5400Stuck for more than an hour? Post in the team channel. Someone will pair with you.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { type Block, makeBlock } from "./ui/uicontext/components/kit/Blocks.ts"import { BlocksView } from "./ui/uicontext/components/kit/EditorBlocks.ts"import { space } from "./ui/uicontext/components/tokens.stylex.ts"// An onboarding page someone shared: readers open the toggles themselves, pictures keep their size// while they load, and code says its language.const styles = stylex.create({ page: { inlineSize: "min(100%, 38rem)", paddingBlock: space.md } })const text = (value: string) => ({ text: value })const screenshot = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 240'><rect width='600' height='240' fill='%23f4f4f5'/><rect x='24' y='24' width='160' height='192' rx='10' fill='%23e4e4e7'/><rect x='208' y='24' width='368' height='40' rx='8' fill='%23e4e4e7'/><rect x='208' y='84' width='368' height='132' rx='10' fill='%23c7d2fe'/></svg>"const blocks: ReadonlyArray<Block> = [ makeBlock("o1", "heading2", [text("Your first week")]), makeBlock("o2", "paragraph", [text("Everything you need to ship your first change by Friday.")]), makeBlock("o3", "toggle", [text("Get access")], { collapsed: true }), makeBlock("o4", "todo", [text("Sign in to the workspace with your work email")], { indent: 1, checked: true }), makeBlock("o5", "todo", [text("Ask Priya Nair for the billing project")], { indent: 1, checked: false }), makeBlock("o6", "toggle", [text("Run the app locally")]), makeBlock("o7", "code", [text("bun install\nbun run dev --port 5400")], { indent: 1, language: "bash" }), makeBlock("o8", "image", [text("The dashboard you'll land on")], { image: { src: screenshot, alt: "The dashboard: a sidebar and a list of projects", width: 600, height: 240 } }), makeBlock("o9", "callout", [text("Stuck for more than an hour? Post in the team channel. Someone will pair with you.")], { color: "blue" }),]export const Onboarding = <M>(h: Html.H<M>) => BlocksView(h, { blocks, label: "Your first week", style: styles.page })Accessibility
- Headings are real
h2toh4, code ispreandcode, quotes areblockquote, and links are real links. - A to-do's box is a disabled checkbox named Done, so screen readers say whether it's checked. Nothing in it is editable or focusable except its links.