a0135cdc59
* make text editor reusable * use dropdown component for block type * remove ring when clicking on block type * allow excluding items in toolbar * refactor code * make AddVariableDropdown reusable * fixed missed translations * fixes variable translation issue * change missed translation variables * make AddVariablesDropdown reusable * reorder block types in dropdown * remove not needed prop * code clean up Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
37 lines
965 B
TypeScript
37 lines
965 B
TypeScript
import { AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin";
|
|
|
|
const URL_MATCHER =
|
|
/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
|
|
const EMAIL_MATCHER =
|
|
/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
|
|
const MATCHERS = [
|
|
(text: any) => {
|
|
const match = URL_MATCHER.exec(text);
|
|
return (
|
|
match && {
|
|
index: match.index,
|
|
length: match[0].length,
|
|
text: match[0],
|
|
url: match[0],
|
|
}
|
|
);
|
|
},
|
|
(text: any) => {
|
|
const match = EMAIL_MATCHER.exec(text);
|
|
return (
|
|
match && {
|
|
index: match.index,
|
|
length: match[0].length,
|
|
text: match[0],
|
|
url: `mailto:${match[0]}`,
|
|
}
|
|
);
|
|
},
|
|
];
|
|
|
|
export default function PlaygroundAutoLinkPlugin() {
|
|
return <AutoLinkPlugin matchers={MATCHERS} />;
|
|
}
|