diff --git a/lib/src/Components/TipTap/utils/preprocessMarkdown.ts b/lib/src/Components/TipTap/utils/preprocessMarkdown.ts index e790ae2e..2a87bee2 100644 --- a/lib/src/Components/TipTap/utils/preprocessMarkdown.ts +++ b/lib/src/Components/TipTap/utils/preprocessMarkdown.ts @@ -61,10 +61,23 @@ export function preprocessMarkdown(text: string): string { /** * Converts YouTube and Rumble markdown links to video-embed HTML tags. + * Handles both standard markdown links [Text](url) and autolinks */ export function preprocessVideoLinks(text: string): string { let result = text + // YouTube autolinks: + result = result.replace( + /&]+)[^>]*>/g, + '', + ) + + // YouTube short autolinks: + result = result.replace( + /?]+)[^>]*>/g, + '', + ) + // YouTube: [Text](https://www.youtube.com/watch?v=VIDEO_ID) result = result.replace( /\[([^\]]*)\]\(https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^)&]+)[^)]*\)/g, @@ -77,6 +90,12 @@ export function preprocessVideoLinks(text: string): string { '', ) + // Rumble autolinks: + result = result.replace( + /]+)>/g, + '', + ) + // Rumble embed URLs: [Text](https://rumble.com/embed/VIDEO_ID) result = result.replace( /\[([^\]]*)\]\(https?:\/\/rumble\.com\/embed\/([^)]+)\)/g,