0

I'm using @lexical/react to make a markdown editor. If you type a link, like [Google](https://google.com) and then press backspace to change the link, the entire link block is removed, when you erase just ).

How can I prevent this?

Instead of the entire block being removed, if you remove just ')', I'd like it to show [Google](https://google.com

The code:

const Editor = (props) => {
  const editorNodes = [
    AutoLinkNode,
    CodeNode,
    HeadingNode,
    LinkNode,
    ListNode,
    ListItemNode,
    QuoteNode,
  ];

  const initialConfig = {
    namespace: "MyEditor",
    nodes: editorNodes,
    theme: {
      root: styles.editorRoot,
    },
    onError: (error) => {
      console.log(error);
    },
  };

  return (
    <div className={styles.editor}>
      <LexicalComposer initialConfig={initialConfig}>
        <RichTextPlugin
          contentEditable={<ContentEditable />}
          placeholder={<Placeholder />}
          ErrorBoundary={LexicalErrorBoundary}
        ></RichTextPlugin>
        <MarkdownShortcutPlugin transformers={TRANSFORMERS} />
      </LexicalComposer>
    </div>
  );
};
U. Watt
  • 533
  • 1
  • 5
  • 27

0 Answers0