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
Name | Type | Default | Description |
---|---|---|---|
editor | Editor | null | null | The Tiptap editor instance |
text | string | - | Text to display alongside the icon |
hideWhenUnavailable | boolean | false | Whether to hide the button when mathematics is unavailable |
formula | string | "" | 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