diff --git a/package-lock.json b/package-lock.json index 4ba89c5d..6f630d0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "imwald", - "version": "22.5.3", + "version": "22.5.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "imwald", - "version": "22.5.3", + "version": "22.5.4", "license": "MIT", "dependencies": { "@asciidoctor/core": "^3.0.4", diff --git a/package.json b/package.json index 724121e6..68ce4250 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "imwald", - "version": "22.5.3", + "version": "22.5.4", "description": "Imwald — a user-friendly Nostr client focused on relay feed browsing, publications, and relay discovery", "private": true, "type": "module", diff --git a/src/components/Note/MarkdownArticle/MarkdownArticle.tsx b/src/components/Note/MarkdownArticle/MarkdownArticle.tsx index e0d8edac..58f58854 100644 --- a/src/components/Note/MarkdownArticle/MarkdownArticle.tsx +++ b/src/components/Note/MarkdownArticle/MarkdownArticle.tsx @@ -3305,8 +3305,8 @@ function parseMarkdownContentMarked( } const renderParagraph = (token: any, key: string): React.ReactNode => { - const paragraphText = String(token.text ?? '').trim() - const rawParagraphText = String(token.text ?? '') + const rawParagraphText = String(token.text ?? token.raw ?? '') + const paragraphText = rawParagraphText.trim() const standaloneMath = parseDelimitedMath(rawParagraphText.trim()) if (standaloneMath) { return ( @@ -3645,7 +3645,7 @@ function parseMarkdownContentMarked( } } - const paragraphTokens = lexInlineProtected(String(token.text ?? token.raw ?? '')) + const paragraphTokens = lexInlineProtected(rawParagraphText) const parseNostrHref = (href: string): string | null => { if (!href.toLowerCase().startsWith('nostr:')) return null const raw = href.slice(6).trim() @@ -3760,6 +3760,56 @@ function parseMarkdownContentMarked( return
with a plain anchor instead of an embed. + const hasInlineYouTubeLink = paragraphTokens.some((t: any) => { + if (t?.type !== 'link') return false + const cleaned = cleanUrl(String(t.href ?? '')) + return !!cleaned && isYouTubeUrl(cleaned) + }) + if (hasInlineYouTubeLink) { + const nodes: React.ReactNode[] = [] + let inlineSegment: any[] = [] + const flushInlineSegment = (segmentIdx: number) => { + if (inlineSegment.length === 0) return + nodes.push( +
+ {renderInlineTokens(inlineSegment, `${key}-yt-inline-segment-${segmentIdx}`)} +
+ ) + inlineSegment = [] + } + + let segmentIdx = 0 + paragraphTokens.forEach((t: any, idx: number) => { + if (t?.type !== 'link') { + inlineSegment.push(t) + return + } + const cleaned = cleanUrl(String(t.href ?? '')) + if (!cleaned || !isYouTubeUrl(cleaned)) { + inlineSegment.push(t) + return + } + + flushInlineSegment(segmentIdx++) + nodes.push( +