((r) => {
// connect the signal node to the cell using the `pipe` operator.
// The pipe operator will execute the callback whenever the signal node changes.
r.link(
r.pipe(
mySignal$,
r.o.map((v) => `mySignal has been called ${v} times`)
),
myCell$
)
})
Following the approach above, you can access and interact with the built-in cells and signals that the package exports. As a convention, the Cells and Signals are suffixed with `$`. You would most likely need to interact with `rootEditor$` (the Lexical instance), `activeEditor$` (can be the root editor or one of the nested editors). Signals like `createRootEditorSubscription$` and `createActiveEditorSubscription$` let you [hook](https://lexical.dev/docs/concepts/commands#editorregistercommand)
up to the [Lexical editor commands](https://lexical.dev/docs/concepts/commands#editorregistercommand)
.
Some of the plugins expose signals that let you insert certain node types into the editor. For example, the `codeBlockPlugin` has an `insertCodeBlockNode$` that can be used to insert a code block into the editor.
Accessing the state from React
------------------------------
Gurx provides a set of hooks that let you access the state from React. Use `useCellValue` or `useCellValues` to get the values of certain cells - the components will re-render when the cell(s) emit new values. To publish a value into a cell, signal, or action, use the `usePublisher` hook.
export const DiffSourceToggleWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => {
// access the viewMode node value
const viewMode = useCellValue(viewMode$)
// a function that will publish a new value into the viewMode cell
const changeViewMode = usePublisher(viewMode$)
return (
<>
{viewMode === 'rich-text' ? (
children
) : viewMode === 'diff' ? (
Diff mode
) : (
Source mode
)}
, value: 'rich-text' },\
{ title: 'Diff mode', contents: , value: 'diff' },\
{ title: 'Source', contents: , value: 'source' }\
]}
onChange={(value) => changeViewMode(value || 'rich-text')}
/>
>
)
}
Creating a custom plugin
------------------------
For simpler use cases, you might not need to explicitly declare a new plugin. If you declare a set of cells/signals and then use them in a React component, they will be automatically included in the Editor's realm. However, if you need to run some custom initialization logic or if you need to parameterize a certain behavior, the plugin format is the way to go. A common reason for a plugin might be the customization of the Markdown import/export behavior. The code below is an annotated version of the Headings plugin with some parts removed for brevity. You can browse the source of the editor and its plugins for more examples.
//... imports
import { LexicalHeadingVisitor } from './LexicalHeadingVisitor'
import { MdastHeadingVisitor } from './MdastHeadingVisitor'
// A gurx cell that contains list of all heading levels that can be used in the editor.
export const allowedHeadingLevels$ = Cell>(ALL_HEADING_LEVELS, (r) => {
// Creates a subscription for the root editor for the purpose of makin ctrl+alt+(1|2|3) convert the current selection into a heading.
// the createRootEditorSubscription$ is a signal exposed by the core plugin.
r.pub(createRootEditorSubscription$, (theRootEditor) => {
return theRootEditor.registerCommand(
KEY_DOWN_COMMAND,
(event) => {
// omitted for brevity - see the lexical docs for more info on editor commands.
},
COMMAND_PRIORITY_LOW
)
})
})
// The actual plugin.
// The generic type parameter is used to specify the params accepted by the resulting function.
// Those params are passed to the init/update functions.
export const headingsPlugin = realmPlugin<{
/**
* Allows you to limit the headings used in the editor. Affects the block type dropdown and the keyboard shortcuts.
* @default [1, 2, 3, 4, 5, 6]
*/
allowedHeadingLevels?: ReadonlyArray
}>({
init(realm) {
// In here, we publish the necessary import/export visitors (omitted here, check the full source in github) into their respective signals.
// That's how the editor knows how to convert the MDAST Heading nodes into lexical nodes and vice versa.
// We're also registering the necessary Lexical node (HeadingNode) for the Lexical editor instance.
realm.pubIn({
[addActivePlugin$]: 'headings',
[addImportVisitor$]: MdastHeadingVisitor,
[addLexicalNode$]: HeadingNode,
[addExportVisitor$]: LexicalHeadingVisitor
})
},
update(realm, params) {
// The update function is called with each re-render.
// re-publishing into the allowedHeadingLevels$ cell means that you can change the allowed heading levels at any time (not just when the component mounts).
//
realm.pub(allowedHeadingLevels$, params?.allowedHeadingLevels ?? ALL_HEADING_LEVELS)
}
})
Markdown / Editor state conversion
----------------------------------
The markdown import/export visitors are used for processing the markdown input/output.
The easiest way for you to get a grip of the mechanism is to take a look at the [core plugin visitors](https://github.com/mdx-editor/editor/tree/main/src/plugins/core)
, that are used to process the basic nodes like paragraphs, bold, italic, etc. The registration of each visitor looks like this (excerpt from the `core` plugin):
// core import visitors
realm.pub(addImportVisitor$, MdastRootVisitor)
realm.pub(addImportVisitor$, MdastParagraphVisitor)
realm.pub(addImportVisitor$, MdastTextVisitor)
realm.pub(addImportVisitor$, MdastFormattingVisitor)
realm.pub(addImportVisitor$, MdastInlineCodeVisitor)
// core export visitors
realm.pub(addExportVisitor$, LexicalRootVisitor)
realm.pub(addExportVisitor$, LexicalParagraphVisitor)
realm.pub(addExportVisitor$, LexicalTextVisitor)
realm.pub(addExportVisitor$, LexicalLinebreakVisitor)
Interacting with Lexical
------------------------
The MDXEditor rich-text editing is built on top of the [Lexical framework](https://lexical.dev)
and its node model. In addition to the out-of-the-box nodes (like paragraph, heading, etc), MDXEditor implements a set of custom nodes that are used for the advanced editors (like the table editor, the image editor, and the code block editor).
Lexical is a powerful framework, so understanding its concepts is a challenge on its own. After [the docs themselves](https://lexical.dev/)
, A good place to start learning by example is the [Lexical playground source code](https://github.com/facebook/lexical/tree/main/packages/lexical-playground)
.
_Note: Lexical has its own react-based plugin system, which MDXEditor does not use._
* [The state management model](#the-state-management-model)
* [Accessing the state from React](#accessing-the-state-from-react)
* [Creating a custom plugin](#creating-a-custom-plugin)
* [Markdown / Editor state conversion](#markdown--editor-state-conversion)
* [Interacting with Lexical](#interacting-with-lexical)
---
# Theming | MDXEditor
Theming
=======
Styling the editor elements
---------------------------
The structural styling of the component is done through CSS module class names, which have auto-generated suffixes that can change between versions. The key DOM elements of the component have "public" CSS classes that you can safely target with your own CSS.
* `mdxeditor` - Set at the root element of the editor and the container for the pop-ups/tooltips.
* `mdxeditor-popup-container` assigned to the popup container. Use this if you're using MDXEditor with a framework like MUI and you need to override the z-index of the popups.
* `mdxeditor-toolbar` - The toolbar container.
* `mdxeditor-root-contenteditable` - The root `contentEditable` element, managed by Lexical.
* `mdxeditor-diff-source-wrapper` - If you're using the `diffSourcePlugin`, it injects an element around the editor so that you can toggle between the rich text and source / diff mode. This CSS class is assigned to that wrapper.
* `mdxeditor-rich-text-editor`, `mdxeditor-source-editor`, `mdxeditor-diff-editor` - If you're using the `diffSourcePlugin`, these classes are assigned to the rich text, source and diff editor root elements, respectively.
* `mdxeditor-select-content` - assigned to the Radix UI `Select.Content` component - useful if you want to style the select dropdowns, for example to limit their size on smaller viewports.
Customizing the editor colors
-----------------------------
The editor UI (toolbar, dialogs, etc) colors and fonts are defined as CSS variables attached to the editor root element. The color variables follow the [Radix semantic aliasing](https://www.radix-ui.com/colors/docs/overview/aliasing#semantic-aliases)
convention.
The example below swaps the editor gray/blue colors with tomato/mauve. In addition, assigning the `dark-theme` class to the editor also flips it to dark mode (this is a feature of the Radix colors).
@import url('@radix-ui/colors/tomato-dark.css');
@import url('@radix-ui/colors/mauve-dark.css');
.dark-editor {
--accentBase: var(--tomato-1);
--accentBgSubtle: var(--tomato-2);
--accentBg: var(--tomato-3);
--accentBgHover: var(--tomato-4);
--accentBgActive: var(--tomato-5);
--accentLine: var(--tomato-6);
--accentBorder: var(--tomato-7);
--accentBorderHover: var(--tomato-8);
--accentSolid: var(--tomato-9);
--accentSolidHover: var(--tomato-10);
--accentText: var(--tomato-11);
--accentTextContrast: var(--tomato-12);
--baseBase: var(--mauve-1);
--baseBgSubtle: var(--mauve-2);
--baseBg: var(--mauve-3);
--baseBgHover: var(--mauve-4);
--baseBgActive: var(--mauve-5);
--baseLine: var(--mauve-6);
--baseBorder: var(--mauve-7);
--baseBorderHover: var(--mauve-8);
--baseSolid: var(--mauve-9);
--baseSolidHover: var(--mauve-10);
--baseText: var(--mauve-11);
--baseTextContrast: var(--mauve-12);
--admonitionTipBg: var(--cyan4);
--admonitionTipBorder: var(--cyan8);
--admonitionInfoBg: var(--grass4);
--admonitionInfoBorder: var(--grass8);
--admonitionCautionBg: var(--amber4);
--admonitionCautionBorder: var(--amber8);
--admonitionDangerBg: var(--red4);
--admonitionDangerBorder: var(--red8);
--admonitionNoteBg: var(--mauve-4);
--admonitionNoteBorder: var(--mauve-8);
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
color: var(--baseText);
--basePageBg: black;
background: var(--basePageBg);
}
export function CustomTheming() {
return (
}),\
listsPlugin(),\
quotePlugin(),\
headingsPlugin(),\
linkPlugin(),\
linkDialogPlugin(),\
imagePlugin(),\
tablePlugin(),\
thematicBreakPlugin(),\
frontmatterPlugin(),\
codeBlockPlugin({ defaultCodeBlockLanguage: 'txt' }),\
sandpackPlugin({ sandpackConfig: virtuosoSampleSandpackConfig }),\
codeMirrorPlugin({ codeBlockLanguages: { js: 'JavaScript', css: 'CSS', txt: 'text', tsx: 'TypeScript' } }),\
directivesPlugin({ directiveDescriptors: [YoutubeDirectiveDescriptor, AdmonitionDirectiveDescriptor] }),\
diffSourcePlugin({ viewMode: 'rich-text', diffMarkdown: 'boo' }),\
markdownShortcutPlugin()\
]}
/>
)
}
* [Styling the editor elements](#styling-the-editor-elements)
* [Customizing the editor colors](#customizing-the-editor-colors)
---
# Error handling | MDXEditor
Handling Errors
===============
The markdown format can be complex due to its loose nature. You may integrate the editor on top of existing content that you have no full control over. In this article, we will go over the error types that the editor can produce, the actual reasons behind them, and how to handle them.
Errors caused by an invalid markdown format
-------------------------------------------
The editor component uses the [MDAST library](https://github.com/syntax-tree/mdast-util-from-markdown)
to parse the markdown content. Although it's quite forgiving, certain content can cause the parsing to fail, in which case the editor will remain empty. To obtain more information about the error, you can pass a callback to the `onError` prop - the callback will receive a payload that includes the error message and the source markdown that triggered it.
### Parse errors caused by HTML-like formatting (e.g. links surrounded by angle brackets) or JSX expression syntax
To handle common basic HTML formatting (e.g. `u` tags), the default parsing includes the [mdast-util-mdx-jsx extension](https://github.com/syntax-tree/mdast-util-mdx-jsx)
. In some cases, this can cause the parsing to fail. You can disable this extension by setting the `suppressHtmlProcessing` prop to `true`, but you will lose the ability to use HTML-like formatting in your markdown.
Errors due to missing plugins
-----------------------------
Another problem that can occur during markdown parsing is the lack of plugins to handle certain markdown features. For example, the markdown may include table syntax, but the editor may not have the table plugin enabled. Internally, this exception is going to happen at the phase where MDAST nodes are converted into lexical nodes (the UI rendered in the rich text editing surface). Just like in the previous case, you can use the `onError` prop to handle these errors. You can also add a custom "catch-all" plugin that registers an MDAST visitor with a low priority that will handle all unknown nodes. See `./extending-the-editor` for more information.
Enable source mode to allow the user to recover from errors
-----------------------------------------------------------
The diff-source plugin can be used as an "escape hatch" for potentially invalid markdown. Out of the box, the plugin will attach listeners to the markdown conversion, and, if it fails, will display an error message suggesting the user to switch to source mode and fix the problem there. If the user fixes the problem, then switching to rich text mode will work and the content will be displayed correctly.
* [Errors caused by an invalid markdown format](#errors-caused-by-an-invalid-markdown-format)
* [Parse errors caused by HTML-like formatting (e.g. links surrounded by angle brackets) or JSX expression syntax](#parse-errors-caused-by-html-like-formatting-eg-links-surrounded-by-angle-brackets-or-jsx-expression-syntax)
* [Errors due to missing plugins](#errors-due-to-missing-plugins)
* [Enable source mode to allow the user to recover from errors](#enable-source-mode-to-allow-the-user-to-recover-from-errors)
---
# MDXEditorMethods | MDXEditor
Interface: MDXEditorMethods
===========================
The interface for the [MDXEditor](../functions/MDXEditor)
object reference.
Example
-------
const mdxEditorRef = React.useRef(null)
Properties
----------
| Property | Type | Description |
| --- | --- | --- |
| `focus` | (`callbackFn`?: () => `void`, `opts`?: `object`) => `void` | Sets focus on input |
| `getMarkdown` | () => `string` | Gets the current markdown value. |
| `insertMarkdown` | (`value`: `string`) => `void` | Inserts markdown at the current cursor position. Use the focus if necessary. |
| `setMarkdown` | (`value`: `string`) => `void` | Updates the markdown value of the editor. |
---
# Upgrading to v2 | MDXEditor
Upgrading to V2
===============
Version 2 of MDXEditor did not introduce any breaking changes to the built-in plugins or the public API. It upgraded its internal state management model, and bumped its dependencies (including Lexical and the Mdast family) to the latest versions.
Dropped individual exports
--------------------------
The editor still ships its source code as separate files, but it no longer defines the exports for each file. You should import everything from the package name, the tree-shaking should take care of the rest.
mdast-util-from-markdown v2
---------------------------
The markdown AST converter got upgraded [to v2](https://github.com/syntax-tree/mdast-util-from-markdown/releases)
. Few of its extensions moved to a new syntax for their extensions - for example, [the task list item now exports functions](https://github.com/syntax-tree/mdast-util-gfm-task-list-item/releases/tag/2.0.0)
.
Changes to the state management model
-------------------------------------
The main difference is that the internal state management is now extracted into a separate package called Gurx. As a result, plugin authoring is easier. In fact, you should be able to achieve most of the customizations and extensions without packaging them as a plugin.
V1 used the concept of systems (with dependencies between them) as means of encapsulating reactive nodes. In v2, the reactive nodes are module level exports, and no system/dependency definitions are necessary - if you need to access a reactive node, you can import it directly from the module.
The easiest way to understand the necessary changes in your plugin is to check the [diff](https://github.com/mdx-editor/editor/commit/4b646a7240755be670543f604a3573618f74b15c#diff-b4e56d4d61a1410ccfc01148b5290d6e772a98b2bce1ea539184ab7381cdfa35)
between the v1 and v2 versions of the built-in plugins.
* [Dropped individual exports](#dropped-individual-exports)
* [mdast-util-from-markdown v2](#mdast-util-from-markdown-v2)
* [Changes to the state management model](#changes-to-the-state-management-model)
---
# 404: This page could not be found.
404
===
This page could not be found.
-----------------------------
---
# i18n | MDXEditor
i18n
====
The component is localized entirely in English by default, but you can override these localizations via the `translation` prop - a function that has a signature compatible with the `t` function of i18next. You only need to localize parts of the UI that you'll actually be using, there is no need to localize the entirety of the editor unless you need to. If you're using i18next, you can use browse the [`locales` directory in GitHub](https://github.com/mdx-editor/editor)
for a default set of translations or use a tool like [i18next Parser](https://github.com/i18next/i18next-parser)
to extract them from the source code. If you're using another i18n library, you can use the `translation` prop to pass in your own translations
function LocalizedEditor() {
return { return i18n.t(key, defaultValue, interpolations) }} />
}
---
# MDXEditorProps | MDXEditor
Interface: MDXEditorProps
=========================
The props for the [MDXEditor](../functions/MDXEditor)
React component.
Properties
----------
| Property | Type | Description |
| --- | --- | --- |
| `autoFocus?` | `boolean` \| `object` | pass if you would like to have the editor automatically focused when mounted. |
| `className?` | `string` | The class name to apply to the root component element, including the toolbar and the popups. For styling the content editable area, Use `contentEditableClassName` property. |
| `contentEditableClassName?` | `string` | the CSS class to apply to the content editable element of the editor. Use this to style the various content elements like lists and blockquotes. |
| `iconComponentFor?` | (`name`: [`IconKey`](../type-aliases/IconKey)
) => `Element` | Use this prop to customize the icons used across the editor. Pass a function that returns an icon (JSX) for a given icon key. |
| `lexicalTheme?` | `EditorThemeClasses` | A custom lexical theme to use for the editor. |
| `markdown` | `string` | The markdown to edit. Notice that this is read only when the component is mounted. To change the component content dynamically, use the `MDXEditorMethods.setMarkdown` method. |
| `onBlur?` | (`e`: `FocusEvent`) => `void` | Triggered when focus leaves the editor |
| `onChange?` | (`markdown`: `string`, `initialMarkdownNormalize`: `boolean`) => `void` | Triggered when the editor value changes. The callback is not throttled, you can use any throttling mechanism if you intend to do auto-saving. |
| `onError?` | (`payload`: `object`) => `void` | Triggered when the markdown parser encounters an error. The payload includes the invalid source and the error message. |
| `placeholder?` | `ReactNode` | The placeholder contents, displayed when the editor is empty. |
| `plugins?` | [`RealmPlugin`](/editor/api/RealmPlugin)
\[\] | The plugins to use in the editor. |
| `readOnly?` | `boolean` | pass if you would like to have the editor in read-only mode. Note: Don't use this mode to render content for consumption - render the markdown using a library of your choice instead. |
| `spellCheck?` | `boolean` | Controls the spellCheck value for the content editable element of the editor. Defaults to true, use false to disable spell checking. |
| `suppressHtmlProcessing?` | `boolean` | Set to true if you want to suppress the processing of HTML tags. |
| `toMarkdownOptions?` | `Options` | The markdown options used to generate the resulting markdown. See [the mdast-util-to-markdown docs](/editor/api/https://github.com/syntax-tree/mdast-util-to-markdown#options)
for the full list of options. |
| `translation?` | [`Translation`](../type-aliases/Translation) | Pass your own translation function if you want to localize the editor. |
| `trim?` | `boolean` | Whether to apply trim() to the initial markdown input (default: true) |
---
# MDXEditor | MDXEditor
Function: MDXEditor()
=====================
> **MDXEditor**(`props`): `ReactNode`
The MDXEditor React component.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | [`MDXEditorProps`](../interfaces/MDXEditorProps)
& `RefAttributes`<[`MDXEditorMethods`](../interfaces/MDXEditorMethods)
\> |
Returns
-------
`ReactNode`
---
# ALL_HEADING_LEVELS | MDXEditor
Variable: ALL\_HEADING\_LEVELS
==============================
> `const` **ALL\_HEADING\_LEVELS**: readonly \[`1`, `2`, `3`, `4`, `5`, `6`\]
---
# HEADING_LEVEL | MDXEditor
Type alias: HEADING\_LEVEL
==========================
> **HEADING\_LEVEL**: `1` | `2` | `3` | `4` | `5` | `6`
---
# allowedHeadingLevels%24 | MDXEditor
Variable: allowedHeadingLevels$
===============================
> `const` **allowedHeadingLevels$**: `NodeRef` \[\]>
Holds the allowed heading levels.
---
# 404: This page could not be found.
404
===
This page could not be found.
-----------------------------
---
# 404: This page could not be found.
404
===
This page could not be found.
-----------------------------
---
# headingsPlugin | MDXEditor
Function: headingsPlugin()
==========================
> **headingsPlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for markdown headings.
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `params`? | `object` | \- |
| `params.allowedHeadingLevels`? | readonly [`HEADING_LEVEL`](../type-aliases/HEADING_LEVEL)
\[\] | Allows you to limit the headings used in the editor. Affects the block type dropdown and the keyboard shortcuts.**Default**\[1, 2, 3, 4, 5, 6\] |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# quotePlugin | MDXEditor
Function: quotePlugin()
=======================
> **quotePlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for block quotes to the editor.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `params`? | `unknown` |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# disableAutoLink%24 | MDXEditor
Variable: disableAutoLink$
==========================
> `const` **disableAutoLink$**: `NodeRef`<`boolean`\>
Holds whether the auto-linking of URLs and email addresses is disabled.
---
# linkPlugin | MDXEditor
Function: linkPlugin()
======================
> **linkPlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for links in the editor.
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `params`? | `object` | \- |
| `params.disableAutoLink`? | `boolean` | Whether to disable the auto-linking of URLs and email addresses.**Default**false |
| `params.validateUrl`? | (`url`) => `boolean` | An optional function to validate the URL of a link. By default, no validation is performed. |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# EditLinkDialog | MDXEditor
Interface: EditLinkDialog
=========================
The state of the link dialog when it is in edit mode.
Properties
----------
| Property | Type |
| --- | --- |
| `initialTitle?` | `string` |
| `initialUrl` | `string` |
| `linkNodeKey` | `string` |
| `rectangle` | [`RectData`](../type-aliases/RectData) |
| `title` | `string` |
| `type` | `"edit"` |
| `url` | `string` |
---
# InactiveLinkDialog | MDXEditor
Interface: InactiveLinkDialog
=============================
The state of the link dialog when it is inactive.
Properties
----------
| Property | Type |
| --- | --- |
| `linkNodeKey?` | `undefined` |
| `rectangle?` | `undefined` |
| `type` | `"inactive"` |
---
# RectData | MDXEditor
Type alias: RectData
====================
> **RectData**: `Pick`<`DOMRect`, `"height"` | `"width"` | `"top"` | `"left"`\>
Describes the boundaries of the current selection so that the link dialog can position itself accordingly.
---
# PreviewLinkDialog | MDXEditor
Interface: PreviewLinkDialog
============================
The state of the link dialog when it is in preview mode.
Properties
----------
| Property | Type |
| --- | --- |
| `linkNodeKey` | `string` |
| `rectangle` | [`RectData`](../type-aliases/RectData) |
| `title` | `string` |
| `type` | `"preview"` |
| `url` | `string` |
---
# applyLinkChanges%24 | MDXEditor
Variable: applyLinkChanges$
===========================
> `const` **applyLinkChanges$**: `NodeRef`<`void`\>
A signal that confirms the updated values of the current link.
---
# linkDialogState%24 | MDXEditor
Variable: linkDialogState$
==========================
> `const` **linkDialogState$**: `NodeRef`<[`InactiveLinkDialog`](../interfaces/InactiveLinkDialog)
> | [`PreviewLinkDialog`](../interfaces/PreviewLinkDialog)
> | [`EditLinkDialog`](../interfaces/EditLinkDialog)
> \>
The current state of the link dialog.
---
# openLinkEditDialog%24 | MDXEditor
Variable: openLinkEditDialog$
=============================
> `const` **openLinkEditDialog$**: `NodeRef`<`void`\>
An action that opens the link dialog.
---
# removeLink%24 | MDXEditor
Variable: removeLink$
=====================
> `const` **removeLink$**: `NodeRef`<`void`\>
A signal that removes the current link.
---
# cancelLinkEdit%24 | MDXEditor
Variable: cancelLinkEdit$
=========================
> `const` **cancelLinkEdit$**: `NodeRef`<`void`\>
An action that cancel the edit of the current link.
---
# linkDialogPlugin | MDXEditor
Function: linkDialogPlugin()
============================
> **linkDialogPlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `params`? | `object` | \- |
| `params.LinkDialog`? | () => `Element` | If passed, the link dialog will be rendered using this component instead of the default one. |
| `params.linkAutocompleteSuggestions`? | `string`\[\] | If passed, the link input field will autocomplete using the published suggestions. |
| `params.onClickLinkCallback`? | [`ClickLinkCallback`](../type-aliases/ClickLinkCallback) | If set, clicking on the link in the preview popup will call this callback instead of opening the link. |
| `params.onReadOnlyClickLinkCallback`? | [`ReadOnlyClickLinkCallback`](../type-aliases/ReadOnlyClickLinkCallback) | Invoked when a link is clicked in read-only mode |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# updateLink%24 | MDXEditor
Variable: updateLink$
=====================
> `const` **updateLink$**: `NodeRef`<`object`\>
A signal that updates the current link with the published payload.
Type declaration
----------------
### title
> **title**: `undefined` | `string`
### url
> **url**: `undefined` | `string`
---
# switchFromPreviewToLinkEdit%24 | MDXEditor
Variable: switchFromPreviewToLinkEdit$
======================================
> `const` **switchFromPreviewToLinkEdit$**: `NodeRef`<`void`\>
An action that switches the link dialog from preview mode to edit mode.
---
# applyListType%24 | MDXEditor
Variable: applyListType$
========================
> `const` **applyListType$**: `NodeRef`<`""` | `ListType`\>
Converts the current selection to the specified list type.
---
# currentListType%24 | MDXEditor
Variable: currentListType$
==========================
> `const` **currentListType$**: `NodeRef`<`""` | `ListType`\>
The current list type in the editor.
---
# ImageNode | MDXEditor
Class: ImageNode
================
A lexical node that represents an image. Use ["$createImageNode"](../functions/$createImageNode)
to construct one.
Extends
-------
* `DecoratorNode`<`JSX.Element`\>
Constructors
------------
### new ImageNode()
> **new ImageNode**(`src`, `altText`, `title`, `width`?, `height`?, `rest`?, `key`?): [`ImageNode`](/editor/api/ImageNode)
Constructs a new [ImageNode](/editor/api/ImageNode)
with the specified image parameters. Use [$createImageNode](../functions/$createImageNode)
to construct one.
#### Parameters
| Parameter | Type |
| --- | --- |
| `src` | `string` |
| `altText` | `string` |
| `title` | `undefined` \| `string` |
| `width`? | `number` \| `"inherit"` |
| `height`? | `number` \| `"inherit"` |
| `rest`? | (`MdxJsxAttribute` \| `MdxJsxExpressionAttribute`)\[\] |
| `key`? | `string` |
#### Returns
[`ImageNode`](/editor/api/ImageNode)
#### Overrides
`DecoratorNode.constructor`
Methods
-------
### getAltText()
> **getAltText**(): `string`
#### Returns
`string`
* * *
### getHeight()
> **getHeight**(): `number` | `"inherit"`
#### Returns
`number` | `"inherit"`
* * *
### getRest()
> **getRest**(): (`MdxJsxAttribute` | `MdxJsxExpressionAttribute`)\[\]
#### Returns
(`MdxJsxAttribute` | `MdxJsxExpressionAttribute`)\[\]
* * *
### getSrc()
> **getSrc**(): `string`
#### Returns
`string`
* * *
### getTitle()
> **getTitle**(): `undefined` | `string`
#### Returns
`undefined` | `string`
* * *
### getWidth()
> **getWidth**(): `number` | `"inherit"`
#### Returns
`number` | `"inherit"`
* * *
### setAltText()
> **setAltText**(`altText`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `altText` | `undefined` \| `string` |
#### Returns
`void`
* * *
### setSrc()
> **setSrc**(`src`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `src` | `string` |
#### Returns
`void`
* * *
### setTitle()
> **setTitle**(`title`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `title` | `undefined` \| `string` |
#### Returns
`void`
* * *
### setWidthAndHeight()
> **setWidthAndHeight**(`width`, `height`): `void`
Sets the image dimensions
#### Parameters
| Parameter | Type |
| --- | --- |
| `width` | `number` \| `"inherit"` |
| `height` | `number` \| `"inherit"` |
#### Returns
`void`
---
# CreateImageNodeParameters | MDXEditor
Interface: CreateImageNodeParameters
====================================
The parameters used to create an [ImageNode](../classes/ImageNode)
through [$createImageNode](../functions/$createImageNode)
.
Properties
----------
| Property | Type |
| --- | --- |
| `altText` | `string` |
| `height?` | `number` |
| `key?` | `string` |
| `rest?` | (`MdxJsxAttribute` \| `MdxJsxExpressionAttribute`)\[\] |
| `src` | `string` |
| `title?` | `string` |
| `width?` | `number` |
---
# listsPlugin | MDXEditor
Function: listsPlugin()
=======================
> **listsPlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for markdown lists.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `params`? | `unknown` |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# EditingImageDialogState | MDXEditor
Interface: EditingImageDialogState
==================================
The state of the image dialog when it is in editing an existing node.
Properties
----------
| Property | Type |
| --- | --- |
| `initialValues` | `Omit`<[`SaveImageParameters`](/editor/api/SaveImageParameters)
, `"file"`\> |
| `nodeKey` | `string` |
| `type` | `"editing"` |
---
# FileImageParameters | MDXEditor
Interface: FileImageParameters
==============================
Extends
-------
* `BaseImageParameters`
Properties
----------
| Property | Type | Inherited from |
| --- | --- | --- |
| `altText?` | `string` | `BaseImageParameters.altText` |
| `file` | `File` | \- |
| `title?` | `string` | `BaseImageParameters.title` |
---
# NewImageDialogState | MDXEditor
Interface: NewImageDialogState
==============================
The state of the image dialog when it is in new mode.
Properties
----------
| Property | Type |
| --- | --- |
| `type` | `"new"` |
---
# InactiveImageDialogState | MDXEditor
Interface: InactiveImageDialogState
===================================
The state of the image dialog when it is inactive.
Properties
----------
| Property | Type |
| --- | --- |
| `type` | `"inactive"` |
---
# SrcImageParameters | MDXEditor
Interface: SrcImageParameters
=============================
Extends
-------
* `BaseImageParameters`
Properties
----------
| Property | Type | Inherited from |
| --- | --- | --- |
| `altText?` | `string` | `BaseImageParameters.altText` |
| `src` | `string` | \- |
| `title?` | `string` | `BaseImageParameters.title` |
---
# SaveImageParameters | MDXEditor
Interface: SaveImageParameters
==============================
Extends
-------
* `BaseImageParameters`
Properties
----------
| Property | Type | Inherited from |
| --- | --- | --- |
| `altText?` | `string` | `BaseImageParameters.altText` |
| `file` | `FileList` | \- |
| `src?` | `string` | \- |
| `title?` | `string` | `BaseImageParameters.title` |
---
# ImagePreviewHandler | MDXEditor
Type alias: ImagePreviewHandler
===============================
> **ImagePreviewHandler**: (`imageSource`) => `Promise`<`string`\> | `null`
---
# ImageUploadHandler | MDXEditor
Type alias: ImageUploadHandler
==============================
> **ImageUploadHandler**: (`image`) => `Promise`<`string`\> | `null`
---
# InsertImageParameters | MDXEditor
Type alias: InsertImageParameters
=================================
> **InsertImageParameters**: [`FileImageParameters`](../interfaces/FileImageParameters)
> | [`SrcImageParameters`](../interfaces/SrcImageParameters)
---
# SerializedImageNode | MDXEditor
Type alias: SerializedImageNode
===============================
> **SerializedImageNode**: `Spread`<`object`, `SerializedLexicalNode`\>
A serialized representation of an [ImageNode](../classes/ImageNode)
.
Type declaration
----------------
### altText
> **altText**: `string`
### height?
> `optional` **height**: `number`
### rest
> **rest**: (`MdxJsxAttribute` | `MdxJsxExpressionAttribute`)\[\]
### src
> **src**: `string`
### title?
> `optional` **title**: `string`
### type
> **type**: `"image"`
### version
> **version**: `1`
### width?
> `optional` **width**: `number`
---
# closeImageDialog%24 | MDXEditor
Variable: closeImageDialog$
===========================
> `const` **closeImageDialog$**: `NodeRef`<`void`\>
Close the image dialog.
---
# disableImageResize%24 | MDXEditor
Variable: disableImageResize$
=============================
> `const` **disableImageResize$**: `NodeRef`<`boolean`\>
Holds the disable image resize configuration flag.
---
# imageAutocompleteSuggestions%24 | MDXEditor
Variable: imageAutocompleteSuggestions$
=======================================
> `const` **imageAutocompleteSuggestions$**: `NodeRef`<`string`\[\]>
Holds the autocomplete suggestions for image sources.
---
# imageDialogState%24 | MDXEditor
Variable: imageDialogState$
===========================
> `const` **imageDialogState$**: `NodeRef`<[`InactiveImageDialogState`](../interfaces/InactiveImageDialogState)
> | [`NewImageDialogState`](../interfaces/NewImageDialogState)
> | [`EditingImageDialogState`](../interfaces/EditingImageDialogState)
> \>
Holds the current state of the image dialog.
---
# imagePreviewHandler%24 | MDXEditor
Variable: imagePreviewHandler$
==============================
> `const` **imagePreviewHandler$**: `NodeRef`<[`ImagePreviewHandler`](../type-aliases/ImagePreviewHandler)
> \>
Holds the image preview handler callback.
---
# imageUploadHandler%24 | MDXEditor
Variable: imageUploadHandler$
=============================
> `const` **imageUploadHandler$**: `NodeRef`<[`ImageUploadHandler`](../type-aliases/ImageUploadHandler)
> \>
Holds the image upload handler callback.
---
# openEditImageDialog%24 | MDXEditor
Variable: openEditImageDialog$
==============================
> `const` **openEditImageDialog$**: `NodeRef`<`Omit`<[`EditingImageDialogState`](../interfaces/EditingImageDialogState)
> , `"type"`\>>
Opens the edit image dialog with the published parameters.
---
# openNewImageDialog%24 | MDXEditor
Variable: openNewImageDialog$
=============================
> `const` **openNewImageDialog$**: `NodeRef`<`void`\>
Opens the new image dialog.
---
# insertImage%24 | MDXEditor
Variable: insertImage$
======================
> `const` **insertImage$**: `NodeRef`<[`InsertImageParameters`](../type-aliases/InsertImageParameters)
> \>
A signal that inserts a new image node with the published payload.
---
# saveImage%24 | MDXEditor
Variable: saveImage$
====================
> `const` **saveImage$**: `NodeRef`<[`SaveImageParameters`](../interfaces/SaveImageParameters)
> \>
Saves the data from the image dialog
---
# %24createImageNode | MDXEditor
Function: $createImageNode()
============================
> **$createImageNode**(`params`): [`ImageNode`](../classes/ImageNode)
Creates an [ImageNode](../classes/ImageNode)
.
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `params` | [`CreateImageNodeParameters`](../interfaces/CreateImageNodeParameters) | The image attributes. |
Returns
-------
[`ImageNode`](../classes/ImageNode)
---
# %24isImageNode | MDXEditor
Function: $isImageNode()
========================
> **$isImageNode**(`node`): `node is ImageNode`
Retruns true if the node is an [ImageNode](../classes/ImageNode)
.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `node` | `undefined` \| `null` \| `LexicalNode` |
Returns
-------
`node is ImageNode`
---
# imagePlugin | MDXEditor
Function: imagePlugin()
=======================
> **imagePlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for images.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `params`? | `object` |
| `params.ImageDialog`? | `FC`<`object`\> \| () => `Element` |
| `params.disableImageResize`? | `boolean` |
| `params.disableImageSettingsButton`? | `boolean` |
| `params.imageAutocompleteSuggestions`? | `string`\[\] |
| `params.imagePreviewHandler`? | [`ImagePreviewHandler`](../type-aliases/ImagePreviewHandler) |
| `params.imageUploadHandler`? | [`ImageUploadHandler`](../type-aliases/ImageUploadHandler) |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# TableNode | MDXEditor
Class: TableNode
================
A Lexical node that represents a markdown table. Use ["$createTableNode"](../functions/$createTableNode)
to construct one.
Extends
-------
* `DecoratorNode`<`JSX.Element`\>
Constructors
------------
### new TableNode()
> **new TableNode**(`mdastNode`?, `key`?): [`TableNode`](/editor/api/TableNode)
Constructs a new [TableNode](/editor/api/TableNode)
with the specified MDAST table node as the object to edit. See [micromark/micromark-extension-gfm-table](/editor/api/https://github.com/micromark/micromark-extension-gfm-table)
for more information on the MDAST table node.
#### Parameters
| Parameter | Type |
| --- | --- |
| `mdastNode`? | `Table` |
| `key`? | `string` |
#### Returns
[`TableNode`](/editor/api/TableNode)
#### Overrides
`DecoratorNode.constructor`
Methods
-------
### addColumnToRight()
> **addColumnToRight**(): `void`
#### Returns
`void`
* * *
### addRowToBottom()
> **addRowToBottom**(): `void`
#### Returns
`void`
* * *
### deleteColumnAt()
> **deleteColumnAt**(`colIndex`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `colIndex` | `number` |
#### Returns
`void`
* * *
### deleteRowAt()
> **deleteRowAt**(`rowIndex`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `rowIndex` | `number` |
#### Returns
`void`
* * *
### getColCount()
> **getColCount**(): `number`
Returns the number of columns in the table.
#### Returns
`number`
* * *
### getMdastNode()
> **getMdastNode**(): `Table`
Returns the mdast node that this node is constructed from.
#### Returns
`Table`
* * *
### getRowCount()
> **getRowCount**(): `number`
Returns the number of rows in the table.
#### Returns
`number`
* * *
### insertColumnAt()
> **insertColumnAt**(`colIndex`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `colIndex` | `number` |
#### Returns
`void`
* * *
### insertRowAt()
> **insertRowAt**(`y`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `y` | `number` |
#### Returns
`void`
* * *
### select()
> **select**(`coords`?): `void`
Focuses the table cell at the specified coordinates. Pass `undefined` to remove the focus.
#### Parameters
| Parameter | Type |
| --- | --- |
| `coords`? | \[`number`, `number`\] |
#### Returns
`void`
* * *
### setColumnAlign()
> **setColumnAlign**(`colIndex`, `align`): `void`
#### Parameters
| Parameter | Type |
| --- | --- |
| `colIndex` | `number` |
| `align` | `AlignType` |
#### Returns
`void`
---
# SerializedTableNode | MDXEditor
Type alias: SerializedTableNode
===============================
> **SerializedTableNode**: `Spread`<`object`, `SerializedLexicalNode`\>
A serialized representation of a [TableNode](../classes/TableNode)
.
Type declaration
----------------
### mdastNode
> **mdastNode**: `Mdast.Table`
---
# insertTable%24 | MDXEditor
Variable: insertTable$
======================
> `const` **insertTable$**: `NodeRef`<`object`\>
A signal that will insert a table with the published amount of rows and columns into the active editor.
Example
-------
const insertTable = usePublisher(insertTable$)
// ...
insertTable({ rows: 3, columns: 4 })
Type declaration
----------------
### columns?
> `optional` **columns**: `number`
The nunber of columns of the table.
### rows?
> `optional` **rows**: `number`
The nunber of rows of the table.
---
# %24createTableNode | MDXEditor
Function: $createTableNode()
============================
> **$createTableNode**(`mdastNode`): [`TableNode`](../classes/TableNode)
Creates a [TableNode](../classes/TableNode)
. Use this instead of the constructor to follow the Lexical conventions.
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `mdastNode` | `Table` | The mdast node to create the [TableNode](../classes/TableNode)
from. |
Returns
-------
[`TableNode`](../classes/TableNode)
---
# %24isTableNode | MDXEditor
Function: $isTableNode()
========================
> **$isTableNode**(`node`): `node is TableNode`
Retruns true if the given node is a [TableNode](../classes/TableNode)
.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `node` | `undefined` \| `null` \| `LexicalNode` |
Returns
-------
`node is TableNode`
---
# tablePlugin | MDXEditor
Function: tablePlugin()
=======================
> **tablePlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for tables to the editor.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `params`? | `Options` |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# insertThematicBreak%24 | MDXEditor
Variable: insertThematicBreak$
==============================
> `const` **insertThematicBreak$**: `NodeRef`<`void`\>
Inserts a thematic break at the current selection.
---
# thematicBreakPlugin | MDXEditor
Function: thematicBreakPlugin()
===============================
> **thematicBreakPlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds support for thematic breaks.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `params`? | `unknown` |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# toolbarContents%24 | MDXEditor
Variable: toolbarContents$
==========================
> `const` **toolbarContents$**: `NodeRef`<() => `ReactNode`\>
The factory function that returns the contents of the toolbar.
---
# BlockTypeSelect | MDXEditor
Function: BlockTypeSelect()
===========================
> **BlockTypeSelect**(): `null` | `Element`
A toolbar component that allows the user to change the block type of the current selection. Supports paragraphs, headings and block quotes.
Returns
-------
`null` | `Element`
---
# toolbarPlugin | MDXEditor
Function: toolbarPlugin()
=========================
> **toolbarPlugin**(`params`?): [`RealmPlugin`](../interfaces/RealmPlugin)
A plugin that adds a toolbar to the editor.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `params`? | `object` |
| `params.toolbarClassName`? | `string` |
| `params.toolbarContents`? | () => `ReactNode` |
Returns
-------
[`RealmPlugin`](../interfaces/RealmPlugin)
---
# BoldItalicUnderlineToggles | MDXEditor
Function: BoldItalicUnderlineToggles()
======================================
> **BoldItalicUnderlineToggles**(`props`, `context`?): `ReactNode`
A toolbar component that lets the user toggle bold, italic and underline formatting.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | [`BoldItalicUnderlineTogglesProps`](../interfaces/BoldItalicUnderlineTogglesProps) |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# ChangeAdmonitionType | MDXEditor
Function: ChangeAdmonitionType()
================================
> **ChangeAdmonitionType**(): `Element`
A component that allows the user to change the admonition type of the current selection. For this component to work, you must pass the [AdmonitionDirectiveDescriptor](../variables/AdmonitionDirectiveDescriptor)
to the `directivesPlugin` `directiveDescriptors` parameter.
Returns
-------
`Element`
---
# ChangeCodeMirrorLanguage | MDXEditor
Function: ChangeCodeMirrorLanguage()
====================================
> **ChangeCodeMirrorLanguage**(): `Element`
A component that allows the user to change the code block language of the current selection. For this component to work, you must enable the `codeMirrorPlugin` for the editor. See [ConditionalContents](/editor/api/ConditionalContents)
for an example on how to display the dropdown only when a code block is in focus.
Returns
-------
`Element`
---
# CodeToggle | MDXEditor
Function: CodeToggle()
======================
> **CodeToggle**(`props`, `context`?): `ReactNode`
A toolbar component that lets the user toggle code formatting. Use for inline `code` elements (like variables, methods, etc).
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# CreateLink | MDXEditor
Function: CreateLink()
======================
> **CreateLink**(): `Element`
A toolbar component that opens the link edit dialog. For this component to work, you must include the `linkDialogPlugin`.
Returns
-------
`Element`
---
# DiffSourceToggleWrapper | MDXEditor
Function: DiffSourceToggleWrapper()
===================================
> **DiffSourceToggleWrapper**(`props`, `context`?): `ReactNode`
A wrapper element for the toolbar contents that lets the user toggle between rich text, diff and source mode. Put the rich text toolbar contents as children of this component. For this component to work, you must include the `diffSourcePlugin`.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `props.SourceToolbar`? | `ReactNode` |
| `props.children`? | `ReactNode` |
| `props.options`? | [`ViewMode`](../type-aliases/ViewMode)
\[\] |
| `context`? | `any` |
Returns
-------
`ReactNode`
Example
-------
( <> >)\
}), diffSourcePlugin()]}
/>
---
# InsertAdmonition | MDXEditor
Function: InsertAdmonition()
============================
> **InsertAdmonition**(): `Element`
A toolbar dropdown button that allows the user to insert admonitions. For this to work, you need to have the `directives` plugin enabled with the [AdmonitionDirectiveDescriptor](../variables/AdmonitionDirectiveDescriptor)
configured.
Returns
-------
`Element`
---
# InsertCodeBlock | MDXEditor
Function: InsertCodeBlock()
===========================
> **InsertCodeBlock**(`props`, `context`?): `ReactNode`
A toolbar button that allows the user to insert a fenced code block. Once the code block is focused, you can construct a special code block toolbar for it, using the [ConditionalContents](/editor/api/ConditionalContents)
primitive. See the [ConditionalContents](/editor/api/ConditionalContents)
documentation for an example.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# InsertFrontmatter | MDXEditor
Function: InsertFrontmatter()
=============================
> **InsertFrontmatter**(`props`, `context`?): `ReactNode`
A toolbar button that allows the user to insert a [front-matter](/editor/api/https://jekyllrb.com/docs/front-matter/)
editor (if one is not already present). For this to work, you need to have the `frontmatterPlugin` plugin enabled.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# InsertImage | MDXEditor
Function: InsertImage()
=======================
> **InsertImage**(`props`): `ReactNode`
A toolbar button that allows the user to insert an image from an URL. For the button to work, you need to have the `imagePlugin` plugin enabled.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `Omit`<`Record`<`string`, `never`\>, `"ref"`\> & `RefAttributes`<`HTMLButtonElement`\> |
Returns
-------
`ReactNode`
---
# InsertSandpack | MDXEditor
Function: InsertSandpack()
==========================
> **InsertSandpack**(): `Element`
A dropdown button that allows the user to insert a live code block into the editor. The dropdown offers a list of presets that are defined in the sandpack plugin config. For this to work, you need to have the `sandpackPlugin` installed.
Returns
-------
`Element`
---
# InsertTable | MDXEditor
Function: InsertTable()
=======================
> **InsertTable**(`props`, `context`?): `ReactNode`
A toolbar button that allows the user to insert a table. For this button to work, you need to have the `tablePlugin` plugin enabled.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# InsertThematicBreak | MDXEditor
Function: InsertThematicBreak()
===============================
> **InsertThematicBreak**(`props`, `context`?): `ReactNode`
A toolbar button that allows the user to insert a thematic break (rendered as an HR HTML element). For this button to work, you need to have the `thematicBreakPlugin` plugin enabled.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# KitchenSinkToolbar | MDXEditor
Function: KitchenSinkToolbar()
==============================
> **KitchenSinkToolbar**(`props`, `context`?): `ReactNode`
A toolbar component that includes all toolbar components. Notice that some of the buttons will work only if you have the corresponding plugin enabled, so you should use it only for testing purposes. You'll probably want to create your own toolbar component that includes only the buttons that you need.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# ListsToggle | MDXEditor
Function: ListsToggle()
=======================
> **ListsToggle**(`props`, `context`?): `ReactNode`
A toolbar toggle that allows the user to toggle between bulleted, numbered, and check lists. Pressing the selected button will convert the current list to the other type. Pressing it again will remove the list. For this button to work, you need to have the `listsPlugin` plugin enabled.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `props.options`? | (`"number"` \| `"bullet"` \| `"check"`)\[\] |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# ShowSandpackInfo | MDXEditor
Function: ShowSandpackInfo()
============================
> **ShowSandpackInfo**(): `Element`
A component that displays the focused live code block's name. For this component to work, you must enable the `sandpackPlugin` for the editor. See [ConditionalContents](/editor/api/ConditionalContents)
for an example on how to display the dropdown only when a sandpack editor is in focus.
Returns
-------
`Element`
---
# StrikeThroughSupSubToggles | MDXEditor
Function: StrikeThroughSupSubToggles()
======================================
> **StrikeThroughSupSubToggles**(`props`, `context`?): `ReactNode`
A toolbar component that lets the user toggle strikeThrough, superscript and subscript formatting.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | [`StrikeThroughSupSubTogglesProps`](../interfaces/StrikeThroughSupSubTogglesProps) |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# UndoRedo | MDXEditor
Function: UndoRedo()
====================
> **UndoRedo**(`props`, `context`?): `ReactNode`
A toolbar component that lets the user undo and redo changes in the editor.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# ConditionalContentsOption | MDXEditor
Interface: ConditionalContentsOption
====================================
An object that describes a possible option to be displayed in the [ConditionalContents](../functions/ConditionalContents)
component.
Properties
----------
| Property | Type | Description |
| --- | --- | --- |
| `contents` | () => `ReactNode` | The contents to display if the `when` function returns `true`. |
| `when` | (`rootNode`: `null` \| [`EditorInFocus`](/editor/api/EditorInFocus)
) => `boolean` | A function that returns `true` if the option should be displayed for the current editor in focus. |
---
# FallbackOption | MDXEditor
Interface: FallbackOption
=========================
A default option to be displayed in the [ConditionalContents](../functions/ConditionalContents)
component if none of the other options match.
Properties
----------
| Property | Type | Description |
| --- | --- | --- |
| `fallback` | () => `ReactNode` | The contents to display |
---
# Button | MDXEditor
Function: Button()
==================
> **Button**(`props`): `ReactNode`
A toolbar button primitive.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `Omit`<`ToolbarButtonProps` & `RefAttributes`<`HTMLButtonElement`\>, `"ref"`\> & `RefAttributes`<`object`\> |
Returns
-------
`ReactNode`
---
# ButtonOrDropdownButton | MDXEditor
Function: ButtonOrDropdownButton()
==================================
> **ButtonOrDropdownButton**<`T`\>(`props`): `Element`
Use this primitive to create a toolbar button that can be either a button or a dropdown, depending on the number of items passed.
Type parameters
---------------
| Type parameter |
| --- |
| `T` _extends_ `string` |
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `props` | `object` | \- |
| `props.children` | `ReactNode` | The contents of the button - usually an icon. |
| `props.items` | `object`\[\] | The items to show in the dropdown. |
| `props.onChoose` | (`value`) => `void` | The function to execute when the button is clicked or an item is chosen from the dropdown. If there is only one item in the dropdown, the value will be an empty string. |
| `props.title` | `string` | The title used for the tooltip. |
Returns
-------
`Element`
---
# ButtonWithTooltip | MDXEditor
Function: ButtonWithTooltip()
=============================
> **ButtonWithTooltip**(`__namedParameters`): `Element`
A toolbar button with tooltip primitive.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `__namedParameters` | `Omit`<`ToolbarButtonProps` & `RefAttributes`<`HTMLButtonElement`\>, `"ref"`\> & `RefAttributes`<`object`\> & `object` |
Returns
-------
`Element`
---
# MultipleChoiceToggleGroup | MDXEditor
Function: MultipleChoiceToggleGroup()
=====================================
> **MultipleChoiceToggleGroup**(`props`, `context`?): `ReactNode`
A toolbar primitive that allows you to build an UI with multiple non-exclusive toggle groups, like the bold/italic/underline toggle.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` |
| `props.items` | `object`\[\] |
| `context`? | `any` |
Returns
-------
`ReactNode`
---
# ConditionalContents | MDXEditor
Function: ConditionalContents()
===============================
> **ConditionalContents**(`props`, `context`?): `ReactNode`
A toolbar primitive that allows you to show different contents based on the editor that is in focus. Useful for code editors that have different features and don't support rich text formatting.
Parameters
----------
| Parameter | Type | Description |
| --- | --- | --- |
| `props` | `object` | \- |
| `props.options` | ([`ConditionalContentsOption`](../interfaces/ConditionalContentsOption)
\| [`FallbackOption`](../interfaces/FallbackOption)
)\[\] | A set of options that define the contents to show based on the editor that is in focus. Can be either a [ConditionalContentsOption](../interfaces/ConditionalContentsOption)
or a [FallbackOption](../interfaces/FallbackOption)
. See the [ConditionalContents](/editor/api/ConditionalContents)
documentation for an example. |
| `context`? | `any` | \- |
Returns
-------
`ReactNode`
Example
-------
editor?.editorType === 'codeblock', contents: () => },\
{ when: (editor) => editor?.editorType === 'sandpack', contents: () => },\
{\
fallback: () => (\
<>\
\
\
\
>\
)\
}\
]}
/>
---
# DialogButton | MDXEditor
Function: DialogButton()
========================
> **DialogButton**(`props`): `ReactNode`
Use this primitive to create a toolbar button that opens a dialog with a text input, autocomplete suggestions, and a submit button.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `object` & `RefAttributes`<`HTMLButtonElement`\> |
Returns
-------
`ReactNode`
---
# Separator | MDXEditor
Function: Separator()
=====================
> **Separator**(`props`): `ReactNode`
A toolbar primitive that allows you to show a separator between toolbar items. By default, the separator is styled as vertical line.
Parameters
----------
| Parameter | Type |
| --- | --- |
| `props` | `ToolbarSeparatorProps` & `RefAttributes`<`HTMLDivElement`\> |
Returns
-------
`ReactNode`
---
# SingleChoiceToggleGroup | MDXEditor
Function: SingleChoiceToggleGroup()
===================================
> **SingleChoiceToggleGroup**<`T`\>(`__namedParameters`): `Element`
A toolbar primitive that allows you to build an UI with multiple exclusive toggle groups, like the list type toggle.
Type parameters
---------------
| Type parameter |
| --- |
| `T` _extends_ `string` |
Parameters
----------
| Parameter | Type |
| --- | --- |
| `__namedParameters` | `object` |
| `__namedParameters.className`? | `string` |
| `__namedParameters.items` | `object`\[\] |
| `__namedParameters.onChange` | (`value`) => `void` |
| `__namedParameters.value` | `""` \| `T` |
Returns
-------
`Element`
---