Insert math formulas with this button

A button for inserting mathematical formulas in the editor using the Mathematics extension.

Install

npx @tiptap/cli add mathematics-button

Usage

import { MathematicsButton } from '@/components/tiptap-ui/mathematics-button'
import { useEditor, EditorContent } from '@tiptap/react'
import { Mathematics } from '@tiptap-pro/extension-mathematics'

import '@/registry/tiptap-node/paragraph-node/paragraph-node.scss'

import 'katex/dist/katex.min.css'

export default function MyEditor() {
  const editor = useEditor({
    extensions: [
      // ... other extensions
      Mathematics,
    ],
  })

  return (
    <div>
      <div className="toolbar">
        <MathematicsButton editor={editor} />
      </div>
      <EditorContent editor={editor} />
    </div>
  )
}

Props

NameTypeDefaultDescription
editorEditor | nullnullThe Tiptap editor instance
textstring-Text to display alongside the icon
hideWhenUnavailablebooleanfalseWhether to hide the button when mathematics is unavailable
formulastring""Optional mathematical formula to insert. Ex: "&\LaTeX&"

Requirements

Used reference components

  • use-tiptap-editor (hook)
  • button (primitive)
  • sigma-icon (icon)

Open source feature(s)

  • katex

Pro feature(s)

  • @tiptap-pro/extension-mathematics