Merge pull request #14779 from GewoonJaap/feature/audio-html-component

Add Audio HTML token support
This commit is contained in:
Tim Jaeryang Baek 2025-06-08 18:39:50 +04:00 committed by GitHub
commit 0b1c81791e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,6 +38,20 @@
{:else}
{token.text}
{/if}
{:else if html && html.includes('<audio')}
{@const audio = html.match(/<audio[^>]*>([\s\S]*?)<\/audio>/)}
{@const audioSrc = audio && audio[1]}
{#if audioSrc}
<!-- svelte-ignore a11y-media-has-caption -->
<audio
class="w-full my-2"
src={audioSrc.replaceAll('&amp;', '&')}
title="Audio player"
controls
></audio>
{:else}
{token.text}
{/if}
{:else if token.text && token.text.match(/<iframe\s+[^>]*src="https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]{11})(?:\?[^"]*)?"[^>]*><\/iframe>/)}
{@const match = token.text.match(
/<iframe\s+[^>]*src="https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]{11})(?:\?[^"]*)?"[^>]*><\/iframe>/