支持嵌入音频
This commit is contained in:
@@ -58,7 +58,8 @@
|
||||
}
|
||||
|
||||
.ext-img,
|
||||
.ext-video {
|
||||
.ext-video,
|
||||
.ext-audio {
|
||||
max-width: 100%;
|
||||
max-height: 2000px;
|
||||
display: block;
|
||||
|
||||
@@ -35,6 +35,18 @@ function is_video(s) {
|
||||
}
|
||||
}
|
||||
|
||||
function is_audio(s) {
|
||||
try {
|
||||
let url = new URL(s);
|
||||
return (
|
||||
url.pathname.endsWith('.mp3') ||
|
||||
(url.searchParams.get('filetype') || '').startsWith('audio/')
|
||||
);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function build_highlight_re(
|
||||
txt,
|
||||
split = ' ',
|
||||
@@ -185,7 +197,10 @@ export class HighlightedMarkdown extends Component {
|
||||
<span className="icon icon-new-tab" />
|
||||
</a>
|
||||
{is_video(p) && (
|
||||
<video className="ext-video" src={p} controls loop />
|
||||
<video className="ext-video" src={p} controls />
|
||||
)}
|
||||
{is_audio(p) && (
|
||||
<audio className="ext-audio" src={p} controls />
|
||||
)}
|
||||
</>
|
||||
) : rule === 'pid' ? (
|
||||
|
||||
Reference in New Issue
Block a user