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

Type parameter
LN extends LexicalNode
UN extends Mdast.Nodes

Methods

join()?

optional 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

Type parameter
T extends RootContent

Parameters

ParameterType
prevNodeT
currentNodeT

Returns

T


shouldJoin()?

optional 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

ParameterType
prevNodeRootContent
currentNodeUN

Returns

boolean


testLexicalNode()?

optional 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

ParameterType
lexicalNodeLexicalNode

Returns

lexicalNode is LN


visitLexicalNode()?

optional visitLexicalNode(params): void

Process the given node and manipulate the mdast tree accordingly.

Parameters

ParameterTypeDescription
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-
params.actions.appendToParent-
params.actions.registerReferredComponent-
params.actions.visitChildren-
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

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