āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/udecode/plate/(plugins)/(elements)/equation ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
title: Equation docs:
The fastest way to add equation functionality is with the MathKit, which includes pre-configured EquationPlugin and InlineEquationPlugin with Plate UI components.
EquationElement: Renders block equation elements.InlineEquationElement: Renders inline equation elements.Add the kit to your plugins:
import { createPlateEditor } from 'platejs/react';
import { MathKit } from '@/components/editor/plugins/math-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...MathKit,
],
});
</Steps>
npm install @platejs/math
Include the equation plugins in your Plate plugins array when creating the editor.
import { EquationPlugin, InlineEquationPlugin } from '@platejs/math/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
EquationPlugin,
InlineEquationPlugin,
],
});
Configure the plugins with custom components to render equation elements.
import { EquationPlugin, InlineEquationPlugin } from '@platejs/math/react';
import { createPlateEditor } from 'platejs/react';
import { EquationElement, InlineEquationElement } from '@/components/ui/equation-node';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
EquationPlugin.withComponent(EquationElement),
InlineEquationPlugin.withComponent(InlineEquationElement),
],
});
withComponent: Assigns EquationElement to render block equations and InlineEquationElement to render inline equations.You can add EquationToolbarButton to your Toolbar to insert equations.
EquationPluginPlugin for block equation elements.
InlineEquationPluginPlugin for inline equation elements.
tf.insert.equationtf.insert.inlineEquationInserts an inline equation.
<API name="insert.inlineEquation"> <APIParameters> <APIItem name="texExpression" type="string" optional> The LaTeX expression to insert. Empty equation if not provided. </APIItem> <APIItem name="options" type="InsertNodesOptions" optional> Options for the insert nodes transform. </APIItem> </APIParameters> </API>TEquationElementinterface TEquationElement extends TElement {
texExpression: string;
}
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā