UNPKG

@yuntijs/ui

Version:

☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps

14 lines 786 B
import { AutoLinkPlugin, createLinkMatcherWithRegExp } from '@lexical/react/LexicalAutoLinkPlugin'; import { jsx as _jsx } from "react/jsx-runtime"; var URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[\w#%+.:=@~-]{1,256}\.[\d()A-Za-z]{1,6}\b([\w#%&()+./:=?@~-]*)(?<![%()+.:-])/; var EMAIL_REGEX = /(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))/; var MATCHERS = [createLinkMatcherWithRegExp(URL_REGEX, function (text) { return text.startsWith('http') ? text : "https://".concat(text); }), createLinkMatcherWithRegExp(EMAIL_REGEX, function (text) { return "mailto:".concat(text); })]; export default function LexicalAutoLinkPlugin() { return /*#__PURE__*/_jsx(AutoLinkPlugin, { matchers: MATCHERS }); }