This commit is contained in:
HappyDay 2025-12-31 04:09:34 +08:00 committed by GitHub
commit d54c88e68d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,7 +26,7 @@ import {
$createHorizontalRuleNode,
$isHorizontalRuleNode,
} from '@lexical/react/LexicalHorizontalRuleNode'
import { $isParagraphNode, $isTextNode, LexicalNode } from 'lexical'
import { $isParagraphNode, $isTextNode, LexicalNode, $createTextNode } from 'lexical'
import {
$createRemoteImageNode,
$isRemoteImageNode,
@ -74,6 +74,42 @@ const IMAGE: TextMatchTransformer = {
type: 'text-match',
}
export const ARROW_DOUBLE: TextMatchTransformer = {
dependencies: [],
export: () => null,
importRegExp: /<-> /,
regExp: /<-> $/,
replace: (textNode) => {
textNode.replace($createTextNode('↔ '))
},
trigger: ' ',
type: 'text-match',
}
export const ARROW_RIGHT: TextMatchTransformer = {
dependencies: [],
export: () => null,
importRegExp: /-> /,
regExp: /-> $/,
replace: (textNode) => {
textNode.replace($createTextNode('→ '))
},
trigger: ' ',
type: 'text-match',
}
export const ARROW_LEFT: TextMatchTransformer = {
dependencies: [],
export: () => null,
importRegExp: /<- /,
regExp: /<- $/,
replace: (textNode) => {
textNode.replace($createTextNode('← '))
},
trigger: ' ',
type: 'text-match',
}
const INLINE_FILE: TextMatchTransformer = {
dependencies: [InlineFileNode],
export: (node) => {
@ -247,6 +283,9 @@ export const MarkdownTransformers = [
CHECK_LIST,
IMAGE,
INLINE_FILE,
ARROW_DOUBLE,
ARROW_RIGHT,
ARROW_LEFT,
...ELEMENT_TRANSFORMERS,
...MULTILINE_ELEMENT_TRANSFORMERS,
...TEXT_FORMAT_TRANSFORMERS,