Mathematics

Inline and block formulas rendered with KaTeX.

UIrich-text-editor-mathematicsView JSON

KaTeX renders the formulas, so the stylesheet has to be available. Without it the document still parses and the nodes stay editable, but the formulas render unstyled.

Preview

Installation

Add the item with the shadcn CLI, or copy the source manually.

pnpm dlx shadcn@latest add litingyes/blocove/rich-text-editor-mathematics

Requires a shadcn/ui project set up with Base UI primitives. Blocove is developed against the b0 preset, but it installs no base config or theme tokens: your own preset, fonts and colors stay in place.

Or install from the namespace after adding the registry: npx shadcn@latest add @blocove/rich-text-editor-mathematics

Typography is provided by shadcn/typeset. Copy typeset.css next to your stylesheet, import it after Tailwind and add the .typeset-docs preset. See the Rich text editor setup.

Usage

Install the KaTeX stylesheet
/* src/styles.css */@import "katex/dist/katex.min.css";

API Reference

Props accepted by the exported components.

EditorMathematics

Registers the KaTeX backed inline and block math nodes. Options pass through to the Mathematics extension.

PropTypeDefault
inlineOptionsOmit<InlineMathOptions, "katexOptions">-
blockOptionsOmit<BlockMathOptions, "katexOptions">-
katexOptionsKatexOptions-

EditorMathematicsToolbar

Toolbar control that inserts an inline or a block formula from a LaTeX source.

PropTypeDefault
classNamestring-