0

I'm having a problem implementing the auto link plugin (copied from LexicalPlayground repo) in my Lexical Editor.

When I enter the link in my editor instance it properly identifies the autolink, but when I hit space I cannot enter a new word. The cursor remains on the link.

Here is my AutoLink plugin code with image attached below showing the TreeView with corresponding nodes.

It appears the offset isn't updating according to the TreeView It just remains at offset: 1, as many times as hit the spacebar.

import {
  AutoLinkPlugin as LexicalAutoLinkPlugin,
  createLinkMatcherWithRegExp,
} from '@lexical/react/LexicalAutoLinkPlugin'

const URL_REGEX =
  /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/

export const MATCHERS = [
  createLinkMatcherWithRegExp(URL_REGEX, (text) => {
    return text.startsWith('http') ? text : `https://${text}`
  }),
]

export function AutoLinkPlugin(): JSX.Element {
  return <LexicalAutoLinkPlugin matchers={MATCHERS} />
}

Any ideas why?enter image description here

Aaron Z
  • 73
  • 1
  • 5

0 Answers0