Skip to main content

@lexical/mdast

Interfaces

CompiledMdast

Defined in: packages/lexical-mdast/src/types.ts:187

Experimental

The compiled registry produced from MdastConfig at editor build time and consumed by the importer, exporter, and shortcut scanner.

Properties

exportHandlers

exportHandlers: Map<string, MdastExportHandler<LexicalNode>>

Defined in: packages/lexical-mdast/src/types.ts:189

Experimental

importHandlers

importHandlers: Map<string, MdastImportHandler<MdastNode>>

Defined in: packages/lexical-mdast/src/types.ts:188

Experimental

inlineShortcutTriggers

inlineShortcutTriggers: Set<string>

Defined in: packages/lexical-mdast/src/types.ts:196

Experimental

Characters that can close an inline construct and trigger a re-scan.

inlineShortcutTypes

inlineShortcutTypes: Set<string>

Defined in: packages/lexical-mdast/src/types.ts:194

Experimental

mdast inline types eligible for streaming shortcut materialization.

mdastExtensions

mdastExtensions: Extension[]

Defined in: packages/lexical-mdast/src/types.ts:191

Experimental

micromarkExtensions

micromarkExtensions: Extension[]

Defined in: packages/lexical-mdast/src/types.ts:190

Experimental

toMarkdownExtensions

toMarkdownExtensions: Options[]

Defined in: packages/lexical-mdast/src/types.ts:192

Experimental


MdastConfig

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:100

Experimental

Configuration for the core MdastImportExtension registry. Feature extensions contribute to these arrays via configExtension(MdastImportExtension, …); you rarely need to set them by hand. The shape mirrors @lexical/html's DOMImportExtension config: raw contribution arrays that mergeConfig concatenates and build compiles.

Properties

exportRules

readonly exportRules: readonly MdastExportRule[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:104

Experimental

Lexical getType() -> mdast mapping rules used while exporting.

importRules

readonly importRules: readonly MdastImportRule[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:102

Experimental

mdast type -> Lexical mapping rules used while importing.

inlineShortcutTriggers

readonly inlineShortcutTriggers: readonly string[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:123

Experimental

Characters that can close an inline construct; typing one triggers an inline re-scan. Extensions add their construct's closing character here (e.g. '=' for ==highlight==).

inlineShortcutTypes

readonly inlineShortcutTypes: readonly string[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:117

Experimental

mdast inline types that the streaming shortcuts may materialize when their closing delimiter is typed. Extensions that contribute a new inline construct add its type here (with a matching import rule) so shortcuts stay in lock-step with the parser.

mdastExtensions

readonly mdastExtensions: readonly Extension[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:108

Experimental

mdast-util-from-markdown extensions (tokens -> mdast).

micromarkExtensions

readonly micromarkExtensions: readonly Extension[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:106

Experimental

micromark syntax extensions (the tokenizer layer).

toMarkdownExtensions

readonly toMarkdownExtensions: readonly Options[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:110

Experimental

mdast-util-to-markdown extensions (mdast -> Markdown string).


MdastExportContext

Defined in: packages/lexical-mdast/src/types.ts:119

Experimental

The context passed to MdastExportHandlers while a Lexical tree is converted back into an mdast tree.

Methods

exportBlocks()

exportBlocks(node): BlockContent[]

Defined in: packages/lexical-mdast/src/types.ts:136

Experimental

Convert the inline children of node into one or more mdast block nodes (paragraphs), splitting on hard line breaks. Used by containers such as block quotes and list items whose Lexical children are inline but whose mdast children must be block-level.

Parameters
node

ElementNode

Returns

BlockContent[]

exportChildren()

exportChildren(node): MdastNode[]

Defined in: packages/lexical-mdast/src/types.ts:124

Experimental

Convert the children of node into mdast nodes by dispatching each child through the registered export handlers.

Parameters
node

ElementNode

Returns

MdastNode[]

exportInline()

exportInline(node): PhrasingContent[]

Defined in: packages/lexical-mdast/src/types.ts:129

Experimental

Convert the inline children of node into mdast phrasing content, grouping bare line breaks as mdast break nodes.

Parameters
node

ElementNode

Returns

PhrasingContent[]

isIncluded()

isIncluded(node): boolean

Defined in: packages/lexical-mdast/src/types.ts:145

Experimental

Whether node belongs in the current export: always true for a whole-document export; during a selection export, true when the node or any descendant is selected. The exportChildren/exportInline/ exportBlocks walks apply this automatically — handlers only need it when they iterate children manually (e.g. list items, table rows) to skip structural children the selection does not reach.

Parameters
node

LexicalNode

Returns

boolean


MdastExportExtensionOutput

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:24

Experimental

The runtime API exposed by MdastExportExtension. Obtain it inside a read/update with $getExtensionOutput(MdastExportExtension), or use the $convertToMarkdownString shorthand.

Methods

$convertSelectionToMarkdownString()

$convertSelectionToMarkdownString(selection?): string

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:47

Experimental

Serializes only the selected content (defaulting to the current selection) to a Markdown string: leaves outside the selection are skipped, partially selected text nodes are sliced to the selected range, and elements are kept when they or any descendant are selected. Returns '' for a null or collapsed selection. Must be called inside an editor.read() or editor.update().

Parameters
selection?

BaseSelection | null

Returns

string

$convertToMarkdownString()

$convertToMarkdownString(node?): string

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:29

Experimental

Serializes the editor root (or node) to a Markdown string. Must be called inside an editor.read() or editor.update().

Parameters
node?

ElementNode

Returns

string

$convertToMdast()

$convertToMdast(node?): Root

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:38

Experimental

Exports the editor root (or node) to an mdast Root tree without serializing it, for interop with the unified/remark ecosystem (remark plugins, remark-rehype, tree diffing, ...). Must be called inside an editor.read() or editor.update(). Syntax preserved from import rides along as data fields on the nodes, mdast's sanctioned extension point.

Parameters
node?

ElementNode

Returns

Root


MdastExportRule

Defined in: packages/lexical-mdast/src/types.ts:175

Experimental

A single export mapping: which Lexical node getType() it handles and how.

Properties

$export

$export: MdastExportHandler<any>

Defined in: packages/lexical-mdast/src/types.ts:179

Experimental

type

type: string

Defined in: packages/lexical-mdast/src/types.ts:177

Experimental

The Lexical node getType() this rule handles (e.g. 'heading').


MdastImportContext

Defined in: packages/lexical-mdast/src/types.ts:66

Experimental

The context passed to MdastImportHandlers while an mdast tree is being walked and converted into Lexical nodes.

Properties

format

readonly format: number

Defined in: packages/lexical-mdast/src/types.ts:73

Experimental

The accumulated text-format bitmask for the current inline position (e.g. inside strong > emphasis this carries the bold + italic bits). Block handlers can ignore this; inline handlers should pass it along to createText and the recursion helpers.

source

readonly source: string

Defined in: packages/lexical-mdast/src/types.ts:80

Experimental

The original Markdown source being imported, or '' when importing a pre-parsed mdast tree. Handlers slice this by node.position to recover the literal syntax (list marker, code fence, hard-break style) for round-trip preservation.

Methods

createText()

createText(value, format?): LexicalNode[]

Defined in: packages/lexical-mdast/src/types.ts:94

Experimental

Create text nodes for value with the current (or supplied) format bitmask; \n becomes a LineBreakNode and \t a TabNode.

Parameters
value

string

format?

number

Returns

LexicalNode[]

getDefinition()

getDefinition(identifier): { title?: string | null; url: string; } | undefined

Defined in: packages/lexical-mdast/src/types.ts:99

Experimental

Resolves a link/image reference identifier (already normalized by mdast) against the document's definitions ([id]: url "title").

Parameters
identifier

string

Returns

{ title?: string | null; url: string; } | undefined

importChildren()

importChildren(parent, format?): LexicalNode[]

Defined in: packages/lexical-mdast/src/types.ts:85

Experimental

Convert every child of parent into Lexical nodes, optionally layering an additional text-format bitmask on top of the current format.

Parameters
parent

MdastParent

format?

number

Returns

LexicalNode[]

importNode()

importNode(node, format?): LexicalNode[]

Defined in: packages/lexical-mdast/src/types.ts:89

Experimental

Convert a single mdast node (and its descendants) into Lexical nodes.

Parameters
node

MdastNode

format?

number

Returns

LexicalNode[]


MdastImportExtensionOutput

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:134

Experimental

The runtime API exposed by MdastImportExtension. Obtain it inside a read/update with $getExtensionOutput(MdastImportExtension), or use the $convertFromMarkdownString shorthand. Serialization lives in MdastExportExtension so import-only editors don't bundle the serializer (mdast-util-to-markdown).

Methods

$convertFromMarkdownString()

$convertFromMarkdownString(markdown, node?): void

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:139

Experimental

Parses markdown with micromark/mdast and replaces the contents of the editor root (or node). Must be called inside an editor.update().

Parameters
markdown

string

node?

ElementNode

Returns

void

$convertFromMdast()

$convertFromMdast(tree, node?): void

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:147

Experimental

Imports an already-parsed mdast Root tree (e.g. produced or transformed by unified/remark tooling) and replaces the contents of the editor root (or node). Must be called inside an editor.update(). Source-based syntax preservation does not apply (there is no source text to recover literal markers from).

Parameters
tree

Root

node?

ElementNode

Returns

void

$generateNodesFromMarkdownString()

$generateNodesFromMarkdownString(markdown): LexicalNode[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:154

Experimental

Parses markdown and returns the resulting block-level nodes as a detached array, without modifying the document or the selection — e.g. for insertion at an arbitrary position via selection.insertNodes(). Must be called inside an editor.update().

Parameters
markdown

string

Returns

LexicalNode[]

$generateNodesFromMdast()

$generateNodesFromMdast(tree): LexicalNode[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:162

Experimental

Walks an already-parsed mdast Root tree and returns the resulting block-level nodes as a detached array, without modifying the document or the selection. Must be called inside an editor.update(). As with MdastImportExtensionOutput.$convertFromMdast, source-based syntax preservation does not apply.

Parameters
tree

Root

Returns

LexicalNode[]


MdastImportRule

Defined in: packages/lexical-mdast/src/types.ts:164

Experimental

A single import mapping: which mdast node type it handles and how. The unit an extension contributes (alongside the micromark/mdast extensions that tokenize the construct) to MdastImportExtension's importRules config.

Properties

$import

$import: MdastImportHandler<any>

Defined in: packages/lexical-mdast/src/types.ts:168

Experimental

type

type: string

Defined in: packages/lexical-mdast/src/types.ts:166

Experimental

The mdast node type this rule handles (e.g. 'heading').


MdastParent

Defined in: node_modules/.pnpm/@types+mdast@4.0.4/node_modules/@types/mdast/index.d.ts:502

Abstract mdast node that contains other mdast nodes (children).

This interface is supposed to be extended if you make custom mdast nodes.

For a union of all registered mdast parents, see Parents.

Extends

  • Node

Properties

children

children: RootContent[]

Defined in: node_modules/.pnpm/@types+mdast@4.0.4/node_modules/@types/mdast/index.d.ts:506

List of children.

data?

optional data?: Data

Defined in: node_modules/.pnpm/@types+mdast@4.0.4/node_modules/@types/mdast/index.d.ts:492

Info from the ecosystem.

Inherited from

Node.data

position?

optional position?: Position

Defined in: node_modules/.pnpm/@types+unist@3.0.3/node_modules/@types/unist/index.d.ts:103

Position of a node in a source document.

Nodes that are generated (not in the original source document) must not have a position.

Inherited from

Node.position

type

type: string

Defined in: node_modules/.pnpm/@types+unist@3.0.3/node_modules/@types/unist/index.d.ts:90

Node type.

Inherited from

Node.type


MdastShortcutsConfig

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:542

Properties

disabled

disabled: boolean

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:544

Disable the streaming shortcuts without removing the extension.

Type Aliases

MdastExportHandler

MdastExportHandler<T> = (node, context) => MdastNode | MdastNode[] | null

Defined in: packages/lexical-mdast/src/types.ts:153

Experimental

Converts a Lexical node into one or more mdast nodes. Returning null defers to the next registered handler.

Type Parameters

T

T extends LexicalNode = LexicalNode

Parameters

node

T

context

MdastExportContext

Returns

MdastNode | MdastNode[] | null


MdastImportHandler

MdastImportHandler<T> = (node, context) => LexicalNode | LexicalNode[] | null

Defined in: packages/lexical-mdast/src/types.ts:109

Experimental

Converts an mdast node of a particular type into one or more Lexical nodes. Returning null defers to the next registered handler.

Type Parameters

T

T extends MdastNode = MdastNode

Parameters

node

T

context

MdastImportContext

Returns

LexicalNode | LexicalNode[] | null


MdastNode

MdastNode = Root | RootContent

Defined in: node_modules/.pnpm/@types+mdast@4.0.4/node_modules/@types/mdast/index.d.ts:439

Union of registered mdast nodes.

To register custom mdast nodes, add them to RootContentMap and other places where relevant. They will be automatically added here.

Variables

MdastAutolinkLiteralExtension

const MdastAutolinkLiteralExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/AutolinkLiteral", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:422

Experimental

Opt-in: GFM literal autolinks — bare https://… / www.… URLs and email addresses in prose become links, the way GitHub renders them. This is a GFM extension rather than CommonMark, so it is not part of MdastCommonMarkExtension; add it alongside to opt in:

dependencies: [MdastCommonMarkExtension, MdastAutolinkLiteralExtension]

MdastBlockquoteExtension

const MdastBlockquoteExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Blockquote", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:310

Experimental

Block quotes (> …), shipping QuoteNode. For blockquotes that hold block-level children (nested lists, code, quotes) with full fidelity, add MdastShadowRootQuoteExtension.


MdastCodeExtension

const MdastCodeExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Code", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:376

Experimental

Fenced and indented code blocks, shipping CodeNode.


MdastCommonMarkExtension

const MdastCommonMarkExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/CommonMark", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:531

Experimental

Convenience bundle of every CommonMark construct: headings, block quotes, lists, code blocks, links, and thematic breaks. GFM features (strikethrough, task lists, literal autolinks, tables) are bundled separately as MdastGfmExtension, and MdastExportExtension (or the MdastExtension bundle) adds serialization back to Markdown.


MdastExportExtension

const MdastExportExtension: LexicalExtension<Record<never, never>, "@lexical/mdast/Export", MdastExportExtensionOutput, void>

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:64

Experimental

Markdown serialization for @lexical/mdast. Import (MdastImportExtension and the feature extensions that contribute to it) and export are separate extensions so that editors which only parse Markdown — never serialize back — don't bundle mdast-util-to-markdown.

The export rules themselves are contributed by the same feature extensions that contribute import rules; this extension compiles the shared registry into a serializer:

dependencies: [MdastCommonMarkExtension, MdastExportExtension]

MdastExtension

const MdastExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Mdast", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastExtension.ts:27

Experimental

Convenience bundle of MdastImportExtension and MdastExportExtension: Markdown parsing and serialization.

Depend on this when you want both directions without thinking about it:

dependencies: [MdastCommonMarkExtension, MdastExtension]

Editors that never serialize back to Markdown can skip it (feature extensions already pull in MdastImportExtension) and avoid bundling the serializer (mdast-util-to-markdown).


MdastGfmExtension

const MdastGfmExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Gfm", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastGfmExtension.ts:30

Experimental

Convenience bundle of every GFM extension — strikethrough, task lists, literal autolinks, and tables — mirroring the scope of micromark-extension-gfm. Combine with MdastCommonMarkExtension for GitHub-flavored Markdown:

dependencies: [MdastCommonMarkExtension, MdastGfmExtension]

Each member is also usable individually when you only want some of GFM (e.g. task lists without tables).


MdastHeadingExtension

const MdastHeadingExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Heading", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:293

Experimental

ATX (# …) and setext headings, shipping HeadingNode.


MdastHorizontalRuleExtension

const MdastHorizontalRuleExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/HorizontalRule", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:493

Experimental

Thematic breaks (---, ***, ___), mapped to HorizontalRuleExtension's HorizontalRuleNode. The original marker character is preserved on round-trip.


MdastImportExtension

const MdastImportExtension: LexicalExtension<MdastConfig, "@lexical/mdast/Import", MdastImportExtensionOutput, void>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:216

Experimental

The core Markdown registry for @lexical/mdast, modeled on @lexical/html's DOMImportExtension. It assembles the import/export rules and micromark/mdast extensions contributed by feature extensions into a compiled registry, and exposes Markdown import through its MdastImportExtensionOutput. Markdown export is provided separately by MdastExportExtension, so editors that never serialize back to Markdown don't bundle the serializer.

You normally do not depend on this directly — depend on a feature extension (e.g. MdastCommonMarkExtension) which contributes its rules here and ships the nodes those rules need.

Example

import {$convertFromMarkdownString, MdastCommonMarkExtension}
from '@lexical/mdast';
import {buildEditorFromExtensions} from '@lexical/extension';
import {defineExtension} from 'lexical';

const editor = buildEditorFromExtensions(
defineExtension({dependencies: [MdastCommonMarkExtension], name: '[root]'}),
);
editor.update(() => $convertFromMarkdownString('# Hi'));

MdastLinkExtension

const MdastLinkExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Link", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:395

Experimental

Inline links, CommonMark autolinks (<https://…>), and CommonMark reference links ([text][id] resolved against [id]: url definitions), shipping LinkNode. Reference links are resolved to their target on import and serialize back as inline links. For GFM literal autolinks (bare https://… in prose) add MdastAutolinkLiteralExtension.


MdastListExtension

const MdastListExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/List", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:338

Experimental

Ordered and unordered lists, shipping ListNode and ListItemNode. For GFM task lists (- [x] …) add MdastTaskListExtension.


MdastRichTextExtension

const MdastRichTextExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/RichText", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:327

Experimental

Convenience bundle of MdastHeadingExtension and MdastBlockquoteExtension — the constructs backed by @lexical/rich-text nodes.


MdastShadowRootQuoteExtension

const MdastShadowRootQuoteExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/ShadowRootQuote", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:449

Experimental

Opt-in: import Markdown blockquotes as shadow root QuoteNodes ($createQuoteNode({shadowRoot: true})), which hold block-level children like a table cell. Structured blockquotes — multiple paragraphs, nested lists, code blocks, nested quotes — then round-trip with full fidelity instead of being reassembled from inline content.

Not part of MdastCommonMarkExtension; add it alongside to opt in:

dependencies: [MdastCommonMarkExtension, MdastShadowRootQuoteExtension]

The quote export handler supports both forms per node, so legacy quotes (e.g. created by the > shortcut) and shadow root quotes can coexist.


MdastShortcutsExtension

const MdastShortcutsExtension: LexicalExtension<MdastShortcutsConfig, "@lexical/mdast/Shortcuts", NamedSignalsOutput<MdastShortcutsConfig>, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:557

Experimental

Streaming Markdown shortcuts (block markers convert on space, fenced code on Enter, inline constructs on their closing delimiter). Each keystroke is fed back through micromark, so shortcut recognition uses the same grammar and the same enabled extensions as import: shortcuts exist for exactly the feature extensions in the editor and no others. Combine with MdastCommonMarkExtension (and MdastGfmExtension) — this extension only wires up the behavior, it does not pull in any grammar of its own.


MdastStrikethroughExtension

const MdastStrikethroughExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Strikethrough", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:509

Experimental

GFM ~~strikethrough~~, mapped to the Lexical strikethrough text format. Needs no extra nodes (the core text handlers carry the format bit).


MdastTableExtension

const MdastTableExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/Table", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastTableExtension.ts:132

Experimental

GFM tables, mapped to @lexical/table nodes. Opt-in (not part of MdastCommonMarkExtension) because it pulls in the @lexical/table nodes it ships. The first table row is treated as the header row in both directions.

Example

import {MdastShortcutsExtension, MdastTableExtension} from '@lexical/mdast';
import {buildEditorFromExtensions} from '@lexical/extension';
import {defineExtension} from 'lexical';

const editor = buildEditorFromExtensions(
defineExtension({
dependencies: [MdastShortcutsExtension, MdastTableExtension],
name: '[root]',
}),
);

MdastTaskListExtension

const MdastTaskListExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mdast/TaskList", unknown, unknown>

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:360

Experimental

Opt-in: GFM task lists (- [x] done), layered on MdastListExtension. Contributes the gfmTaskListItem grammar; the list import/export handlers already understand checked, and the typing shortcut ([ ] / [x] in a list item) is enabled by the grammar's presence in the registry.

Functions

$convertFromMarkdownString()

$convertFromMarkdownString(markdown, node?): void

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:583

Experimental

Shorthand for $getExtensionOutput(MdastImportExtension).$convertFromMarkdownString. Must be called inside an editor.update(). Throws if the editor was not built with MdastImportExtension (or an extension that depends on it).

Parameters

markdown

string

node?

ElementNode

Returns

void


$convertFromMdast()

$convertFromMdast(tree, node?): void

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:600

Experimental

Shorthand for $getExtensionOutput(MdastImportExtension).$convertFromMdast. Must be called inside an editor.update(). Throws if the editor was not built with MdastImportExtension (or an extension that depends on it).

Parameters

tree

Root

node?

ElementNode

Returns

void


$convertSelectionToMarkdownString()

$convertSelectionToMarkdownString(selection?): string

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:116

Experimental

Shorthand for $getExtensionOutput(MdastExportExtension).$convertSelectionToMarkdownString. Serializes only the selected content (defaulting to the current selection) to a Markdown string; returns '' for a null or collapsed selection. Must be called inside an editor.read() or editor.update(). Throws if the editor was not built with MdastExportExtension.

Parameters

selection?

BaseSelection | null

Returns

string


$convertToMarkdownString()

$convertToMarkdownString(node?): string

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:91

Experimental

Shorthand for $getExtensionOutput(MdastExportExtension).$convertToMarkdownString. Must be called inside an editor.read() or editor.update(). Throws if the editor was not built with MdastExportExtension.

Parameters

node?

ElementNode

Returns

string


$convertToMdast()

$convertToMdast(node?): Root

Defined in: packages/lexical-mdast/src/MdastExportExtension.ts:103

Experimental

Shorthand for $getExtensionOutput(MdastExportExtension).$convertToMdast. Must be called inside an editor.read() or editor.update(). Throws if the editor was not built with MdastExportExtension.

Parameters

node?

ElementNode

Returns

Root


$generateNodesFromMarkdownString()

$generateNodesFromMarkdownString(markdown): LexicalNode[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:613

Experimental

Shorthand for $getExtensionOutput(MdastImportExtension).$generateNodesFromMarkdownString. Parses markdown and returns the resulting block-level nodes as a detached array, without modifying the document or the selection. Must be called inside an editor.update(). Throws if the editor was not built with MdastImportExtension (or an extension that depends on it).

Parameters

markdown

string

Returns

LexicalNode[]


$generateNodesFromMdast()

$generateNodesFromMdast(tree): LexicalNode[]

Defined in: packages/lexical-mdast/src/MdastImportExtension.ts:631

Experimental

Shorthand for $getExtensionOutput(MdastImportExtension).$generateNodesFromMdast. Walks an already-parsed mdast Root tree and returns the resulting block-level nodes as a detached array, without modifying the document or the selection. Must be called inside an editor.update(). Throws if the editor was not built with MdastImportExtension (or an extension that depends on it).

Parameters

tree

Root

Returns

LexicalNode[]