Interface: LexicalExportVisitor<LN, UN>

Implement this interface in order to process mdast node(s) into a lexical tree. This is part of the process that converts the editor contents to markdown.

Type parameters

NameType
LNextends LexicalNode
UNextends Mdast.Nodes

Table of contents

Methods

Properties

Methods

join

join<T>(prevNode, currentNode): T

Join the current node with the previous node, returning the resulting new node For this to be called by the tree walk, shouldJoin must return true.

Type parameters

NameType
Textends RootContent

Parameters

NameType
prevNodeT
currentNodeT

Returns

T


shouldJoin

shouldJoin(prevNode, currentNode): boolean

Return true if the current node should be joined with the previous node. This is necessary due to some inconsistencies between the lexical tree and the mdast tree when it comes to formatting.

Parameters

NameType
prevNodeRootContent
currentNodeUN

Returns

boolean


testLexicalNode

testLexicalNode(lexicalNode): lexicalNode is LN

Return true if the given node is of the type that this visitor can process. You can safely use the node type guard functions (as in $isParagraphNode, $isLinkNode, etc.) here.

Parameters

NameType
lexicalNodeLexicalNode

Returns

lexicalNode is LN


visitLexicalNode

visitLexicalNode(params): void

Process the given node and manipulate the mdast tree accordingly.

Parameters

NameTypeDescription
paramsObject-
params.actionsObjectA set of actions that can be used to manipulate the mdast tree. These are "convenience" utilities that avoid the repetitive boilerplate of creating mdast nodes.
params.actions.addAndStepInto(type: string, props?: Record<string, unknown>, hasChildren?: boolean) => void-
params.actions.appendToParent<T>(parentNode: T, node: T["children"][number]) => Root | T["children"][number]-
params.actions.registerReferredComponent(componentName: string) => void-
params.actions.visitChildren(node: LN, mdastParent: Parent) => void-
params.lexicalNodeLNThe lexical node that is being visited.
params.mdastParentParentThe mdast parent node that the result of the lexical node conversion should be appended to.

Returns

void

Properties

priority

Optional priority: number

Default 0, optional, sets the priority of the visitor. The higher the number, the earlier it will be called.