Skip to content
FrameworkJavaScript

Equation tool: inline LaTeX math

Renders inline math (LaTeX) with KaTeX. Activated with Cmd/Ctrl+Shift+E — wraps the selected text, or a formula typed into the popover input, in a `<span data-latex="...">`. The LaTeX source is kept in the `data-latex` attribute so the formula round-trips through save/load, while the rendered KaTeX markup is regenerated on load.

Import

TypeScript
import { Equation } from '@bloklabs/core/tools';

Save Data

TypeScript
// Stored as HTML inside the block's text field.
// The LaTeX source lives in the data-latex attribute:
// '<span data-latex="E = mc^2"></span>'
JSON
{
  "type": "paragraph",
  "data": {
    "text": "Einstein wrote <span data-latex=\"E = mc^2\"></span>"
  }
}

Usage Example

TypeScript
import { Blok } from '@bloklabs/core';
import { Equation } from '@bloklabs/core/tools';

const editor = new Blok({
  holder: 'editor',
  tools: {
    equation: Equation,
  },
});