Skip to main content

Module: @lexical/markdown

Type Aliases

ElementTransformer

Ƭ ElementTransformer: Object

Type declaration

NameTypeDescription
dependenciesKlass<LexicalNode>[]-
export(node: LexicalNode, traverseChildren: (node: ElementNode) => string) => string | null-
regExpRegExp-
replace(parentNode: ElementNode, children: LexicalNode[], match: string[], isImport: boolean) => boolean | void-
type"element"-

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:47


MultilineElementTransformer

Ƭ MultilineElementTransformer: Object

Type declaration

NameTypeDescription
dependenciesKlass<LexicalNode>[]-
export?(node: LexicalNode, traverseChildren: (node: ElementNode) => string) => string | null-
handleImportAfterStartMatch?(args: { lines: string[] ; rootNode: ElementNode ; startLineIndex: number ; startMatch: RegExpMatchArray ; transformer: MultilineElementTransformer }) => [boolean, number] | null | undefined-
regExpEnd?RegExp | { optional?: true ; regExp: RegExp }This regex determines when to stop matching. Anything in between regExpStart and regExpEnd will be matched
regExpStartRegExpThis regex determines when to start matching
replace(rootNode: ElementNode, children: LexicalNode[] | null, startMatch: string[], endMatch: string[] | null, linesInBetween: string[] | null, isImport: boolean) => boolean | void-
type"multiline-element"-

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:77


TextFormatTransformer

Ƭ TextFormatTransformer: Readonly<{ format: ReadonlyArray<TextFormatType> ; intraword?: boolean ; tag: string ; type: "text-format" }>

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:146


TextMatchTransformer

Ƭ TextMatchTransformer: Readonly<{ dependencies: Klass<LexicalNode>[] ; export?: (node: LexicalNode, exportChildren: (node: ElementNode) => string, exportFormat: (node: TextNode, textContent: string) => string) => string | null ; importRegExp?: RegExp ; regExp: RegExp ; replace?: (node: TextNode, match: RegExpMatchArray) => void ; trigger?: string ; type: "text-match" }>

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:153


Transformer

Ƭ Transformer: ElementTransformer | MultilineElementTransformer | TextFormatTransformer | TextMatchTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:41

Variables

BOLD_ITALIC_STAR

Const BOLD_ITALIC_STAR: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:480


BOLD_ITALIC_UNDERSCORE

Const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:486


BOLD_STAR

Const BOLD_STAR: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:493


BOLD_UNDERSCORE

Const BOLD_UNDERSCORE: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:499


CHECK_LIST

Const CHECK_LIST: ElementTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:448


CODE

Const CODE: MultilineElementTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:355


ELEMENT_TRANSFORMERS

Const ELEMENT_TRANSFORMERS: ElementTransformer[]

Defined in

packages/lexical-markdown/src/index.ts:41


HEADING

Const HEADING: ElementTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:301


HIGHLIGHT

Const HIGHLIGHT: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:474


INLINE_CODE

Const INLINE_CODE: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:468


ITALIC_STAR

Const ITALIC_STAR: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:512


ITALIC_UNDERSCORE

Const ITALIC_UNDERSCORE: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:518


Const LINK: TextMatchTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:529


MULTILINE_ELEMENT_TRANSFORMERS

Const MULTILINE_ELEMENT_TRANSFORMERS: MultilineElementTransformer[]

Defined in

packages/lexical-markdown/src/index.ts:48


ORDERED_LIST

Const ORDERED_LIST: ElementTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:458


QUOTE

Const QUOTE: ElementTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:318


STRIKETHROUGH

Const STRIKETHROUGH: TextFormatTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:506


TEXT_FORMAT_TRANSFORMERS

Const TEXT_FORMAT_TRANSFORMERS: TextFormatTransformer[]

Defined in

packages/lexical-markdown/src/index.ts:56


TEXT_MATCH_TRANSFORMERS

Const TEXT_MATCH_TRANSFORMERS: TextMatchTransformer[]

Defined in

packages/lexical-markdown/src/index.ts:68


TRANSFORMERS

Const TRANSFORMERS: Transformer[]

Defined in

packages/lexical-markdown/src/index.ts:70


UNORDERED_LIST

Const UNORDERED_LIST: ElementTransformer

Defined in

packages/lexical-markdown/src/MarkdownTransformers.ts:438

Functions

$convertFromMarkdownString

$convertFromMarkdownString(markdown, transformers?, node?, shouldPreserveNewLines?, shouldMergeAdjacentLines?): void

Renders markdown from a string. The selection is moved to the start after the operation.

Parameters

NameTypeDefault valueDescription
markdownstringundefined-
transformersTransformer[]TRANSFORMERS-
node?ElementNodeundefined-
shouldPreserveNewLines?booleanfalseBy setting this to true, new lines will be preserved between conversions
shouldMergeAdjacentLines?booleanfalseBy setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.

Returns

void

Defined in

packages/lexical-markdown/src/index.ts:83


$convertToMarkdownString

$convertToMarkdownString(transformers?, node?, shouldPreserveNewLines?): string

Renders string from markdown. The selection is moved to the start after the operation.

Parameters

NameTypeDefault value
transformersTransformer[]TRANSFORMERS
node?ElementNodeundefined
shouldPreserveNewLinesbooleanfalse

Returns

string

Defined in

packages/lexical-markdown/src/index.ts:103


registerMarkdownShortcuts

registerMarkdownShortcuts(editor, transformers?): () => void

Parameters

NameTypeDefault value
editorLexicalEditorundefined
transformersTransformer[]TRANSFORMERS

Returns

fn

▸ (): void

Returns

void

Defined in

packages/lexical-markdown/src/MarkdownShortcuts.ts:390