From 71b3a33623018c9e6a4040747acccf28ecaa81f0 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 13 Jan 2022 12:44:21 +0500 Subject: [PATCH] added support to play inline youtube video content in app builtin player --- .../postHtmlRenderer/linkDataParser.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/postHtmlRenderer/linkDataParser.ts b/src/components/postHtmlRenderer/linkDataParser.ts index c63d7613a..ee1dda016 100644 --- a/src/components/postHtmlRenderer/linkDataParser.ts +++ b/src/components/postHtmlRenderer/linkDataParser.ts @@ -19,10 +19,24 @@ export const parseLinkData = (tnode:TNode):LinkData => { } if(tnode.classes.includes('markdown-external-link')){ + + //inline external links can contain video links, for such tags and video id or url is contained as + //attribute if that is the case, use in app video modal to play content + //for now, only youtube id is supported + const youtubeId = tnode.attributes['data-youtube'] + if(youtubeId){ return { - type:'markdown-external-link', - href: tnode.attributes['data-href'] + type:'markdown-video-link-youtube', + youtubeId:youtubeId.length > 11 && youtubeId[12] === '?' ? youtubeId.substring(0,11):youtubeId //this is a workaround to avoid feeding query parameters to youtube player } + } + //TOOD: support other video link later + + //use default markdown-external-link with url; + return { + type:'markdown-external-link', + href: tnode.attributes['data-href'] + } }