TY

/claim #741 /fixes #741

Description:

Custom Block for KaTeX Equations (#741)

This PR adds a new custom block for rendering LaTeX equations using KaTeX, addressing the feature request in #741. The block provides a user-friendly interface for inputting and editing mathematical expressions directly in the editor, similar to Notion’s equation feature.

Changes

  • New Block Implementation: Added packages/core/src/blocks/Equation/block.ts defining the equation block spec.

    • Config: Stores LaTeX code in props.latex.
    • Content: “none” (no inline content, as LaTeX is prop-based).
    • Parse: Detects <div class="equation" data-latex="..."> from HTML.
    • Render: Editable div for LaTeX input with live KaTeX preview below. Updates on input.
    • toExternalHTML: Renders KaTeX HTML with data-latex attribute for serialization.
  • Integration:

    • Exported from packages/core/src/blocks/index.ts.
    • Added to defaultBlockSpecs in packages/core/src/blocks/defaultBlocks.ts for default schema inclusion.
    • Imported in defaultBlocks.ts from the Equation block file.
  • Dependencies: Added katex to @blocknote/core dependencies for rendering.

  • Keyboard Shortcut: Cmd/Ctrl + Alt + E to insert a new equation block at the cursor position.

  • TypeScript Fixes: Adjusted spec structure using createBlockSpec with proper overloads to resolve type errors.

Usage

  • Insert via shortcut or slash menu (if extended).
  • Edit the LaTeX code in the input field; the preview updates live.
  • Invalid LaTeX shows “Invalid LaTeX” in red.
  • Exports to HTML with rendered KaTeX for static documents.

Claim

Total prize pool $100
Total paid $0
Status Pending
Submitted September 19, 2025
Last updated September 19, 2025

Contributors

EX

Excellencedev

@Excellencedev

100%

Sponsors

BL

BlockNote

@BlockNote

$100