This commit is contained in:
JunaidPinjari 2025-04-01 10:43:42 +07:00 committed by GitHub
commit df0e67fbfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,8 @@
{@html html}
{:else if token.text.includes(`<iframe src="${WEBUI_BASE_URL}/api/v1/files/`)}
{@html `${token.text}`}
{:else if token.text.includes(`<iframe ytEmbed`)}
{@html `${token.text.replace(`<iframe ytEmbed`, `<iframe`)}`}
{:else if token.text.includes(`<source_id`)}
<Source {id} {token} onClick={onSourceClick} />
{:else}

View File

@ -274,6 +274,8 @@
{@html `${token.text}`}
{:else if token.text.includes(`<source_id`)}
<Source {id} {token} onClick={onSourceClick} />
{:else if token.text.includes(`<iframe ytEmbed`)}
{@html `${token.text.replace(`<iframe ytEmbed`, `<iframe`)}`}
{:else}
{token.text}
{/if}

View File

@ -29,6 +29,14 @@ export const replaceTokens = (content, sourceIds, char, user) => {
const tokens = [
{ regex: /{{char}}/gi, replacement: char },
{ regex: /{{user}}/gi, replacement: user },
{
regex: /{{(VIDEO_YOUTUBE_ID_[^\s{}]+)}}/gi,
replacement: (_, fullMatch) => {
const ytId = fullMatch.replace("VIDEO_YOUTUBE_ID_", ""); // Extract only the ID
const videoUrl = `https://www.youtube.com/embed/${ytId}`;
return `<iframe ytEmbed src="${videoUrl}" width="100%" height="500" frameborder="0" allowfullscreen></iframe>`;
}
},
{
regex: /{{VIDEO_FILE_ID_([a-f0-9-]+)}}/gi,
replacement: (_, fileId) =>