mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-04 10:30:00 -06:00
* revert to last working version * add updated ui components * update formbricks-com components * apply prettier formatting * update apps/web files
39 lines
1013 B
TypeScript
39 lines
1013 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 const PlaygroundAutoLinkPlugin: React.FC = () => {
|
|
return <AutoLinkPlugin matchers={MATCHERS} />;
|
|
};
|
|
|
|
export default PlaygroundAutoLinkPlugin;
|