-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support MDX flow expressions (#396)
* Add handlers for mdxFlowExpressions * chore: adjust isInline I'm not certain on its purpose right now, but I think lexical calls it at some point. --------- Co-authored-by: Stanislav Kubik <[email protected]> Co-authored-by: Petyo Ivanov <[email protected]>
- Loading branch information
1 parent
87adbef
commit b6e2a19
Showing
9 changed files
with
72 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { MdxFlowExpression, MdxTextExpression } from 'mdast-util-mdx' | ||
import { LexicalExportVisitor } from '../../exportMarkdownFromLexical' | ||
import { $isLexicalMdxExpressionNode, LexicalMdxExpressionNode } from './LexicalMdxExpressionNode' | ||
|
||
export const LexicalMdxExpressionVisitor: LexicalExportVisitor<LexicalMdxExpressionNode, MdxTextExpression> = { | ||
testLexicalNode: $isLexicalMdxExpressionNode, | ||
visitLexicalNode({ actions, mdastParent, lexicalNode }) { | ||
const mdastNode = { | ||
type: lexicalNode.getMdastType(), | ||
value: lexicalNode.getValue() | ||
} as const satisfies MdxTextExpression | MdxFlowExpression | ||
|
||
actions.appendToParent(mdastParent, mdastNode) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ElementNode } from 'lexical' | ||
import { MdxFlowExpression, MdxTextExpression } from 'mdast-util-mdx' | ||
import { MdastImportVisitor } from '../../importMarkdownToLexical' | ||
import { $createLexicalMdxExpressionNode } from './LexicalMdxExpressionNode' | ||
|
||
export const MdastMdxExpressionVisitor: MdastImportVisitor<MdxTextExpression | MdxFlowExpression> = { | ||
testNode: (node) => node.type === 'mdxTextExpression' || node.type === 'mdxFlowExpression', | ||
visitNode({ lexicalParent, mdastNode }) { | ||
;(lexicalParent as ElementNode).append($createLexicalMdxExpressionNode(mdastNode.value, mdastNode.type)) | ||
}, | ||
priority: -200 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters