diff --git a/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts b/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts index b94d3c9f3..865368da2 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts +++ b/packages/web/src/javascripts/Components/SuperEditor/MarkdownTransformers.ts @@ -25,7 +25,7 @@ import { $createHorizontalRuleNode, $isHorizontalRuleNode, } from '@lexical/react/LexicalHorizontalRuleNode' -import { $isParagraphNode, $isTextNode, LexicalNode } from 'lexical' +import { $isParagraphNode, $isTextNode, LexicalNode, $createTextNode } from 'lexical' import { $createRemoteImageNode, $isRemoteImageNode, @@ -73,6 +73,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) => { @@ -246,6 +282,9 @@ export const MarkdownTransformers = [ CHECK_LIST, IMAGE, INLINE_FILE, + ARROW_DOUBLE, + ARROW_RIGHT, + ARROW_LEFT, ...ELEMENT_TRANSFORMERS, ...TEXT_FORMAT_TRANSFORMERS, ...TEXT_MATCH_TRANSFORMERS,