Repository navigation
Description
What’s broken?
@blocknote/math-block cannot be loaded in Node, so it cannot be used with ServerBlockNoteEditor from @blocknote/server-util (for example to export documents with equations to Markdown on the server).
Its entry dist/blocknote-math-block.js imports the KaTeX stylesheet as a side effect:
import "katex/dist/katex.min.css";
Node fails on that import:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for …/node_modules/katex/dist/katex.min.css
The same import also breaks some browser bundlers. Angular's esbuild based production build fails with "No loader is configured for .woff2", once for every KaTeX font the stylesheet references (seen with 0.54.2).
What did you expect to happen?
The package can be imported in Node, and the server side Markdown export of math blocks and inline math works. When the CSS import is stubbed out, the package loads and the export produces the expected $$…$$ and $…$.
A possible fix is to ship the stylesheet as a separate export (like @blocknote/mantine/style.css) that consumers import themselves.
Steps to reproduce
-
Install the packages
npm i @blocknote/[email protected] @blocknote/[email protected] @blocknote/[email protected] react@19 react-dom@19 yjs y-prosemirror y-protocols
-
Save as
repro.mjsand runnode repro.mjsimport { BlockNoteSchema } from "@blocknote/core"; import { ServerBlockNoteEditor } from "@blocknote/server-util"; import { createReactMathBlockSpec } from "@blocknote/math-block"; const schema = BlockNoteSchema.create().extend({ blockSpecs: { mathBlock: createReactMathBlockSpec() }, }); const editor = ServerBlockNoteEditor.create({ schema }); console.log(await editor.blocksToMarkdownLossy([{ type: "mathBlock", content: "a^2" }]));
-
Node throws
ERR_UNKNOWN_FILE_EXTENSIONonkatex.min.css
BlockNote version
0.54.2, 0.55.0 and 0.56.0
Environment
Node 24.18, React 19.3
Additional context
We use BlockNote in OpenProject with a Hocuspocus server that stores a Markdown copy of each document. As a workaround, we mirror the math specs on the server with static specs built with createBlockSpec.
Contribution
- I'd be interested in contributing a fix for this issue
Sponsor
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Activity