Selaa lähdekoodia

feat: Web <video> and <audio> element support src attribute (#19988)

tags/1.4.1
ruanjiefeng 5 kuukautta sitten
vanhempi
commit
9ebc58b1a2
No account linked to committer's email address
1 muutettua tiedostoa jossa 10 lisäystä ja 2 poistoa
  1. 10
    2
      web/app/components/base/markdown.tsx

+ 10
- 2
web/app/components/base/markdown.tsx Näytä tiedosto



const VideoBlock: any = memo(({ node }: any) => { const VideoBlock: any = memo(({ node }: any) => {
const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src) const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src)
if (srcs.length === 0)
if (srcs.length === 0) {
const src = node.properties?.src
if (src)
return <VideoGallery key={src} srcs={[src]} />
return null return null
}
return <VideoGallery key={srcs.join()} srcs={srcs} /> return <VideoGallery key={srcs.join()} srcs={srcs} />
}) })
VideoBlock.displayName = 'VideoBlock' VideoBlock.displayName = 'VideoBlock'


const AudioBlock: any = memo(({ node }: any) => { const AudioBlock: any = memo(({ node }: any) => {
const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src) const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src)
if (srcs.length === 0)
if (srcs.length === 0) {
const src = node.properties?.src
if (src)
return <AudioGallery key={src} srcs={[src]} />
return null return null
}
return <AudioGallery key={srcs.join()} srcs={srcs} /> return <AudioGallery key={srcs.join()} srcs={srcs} />
}) })
AudioBlock.displayName = 'AudioBlock' AudioBlock.displayName = 'AudioBlock'

Loading…
Peruuta
Tallenna