支持嵌入音频
This commit is contained in:
@@ -58,7 +58,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ext-img,
|
.ext-img,
|
||||||
.ext-video {
|
.ext-video,
|
||||||
|
.ext-audio {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 2000px;
|
max-height: 2000px;
|
||||||
display: block;
|
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(
|
export function build_highlight_re(
|
||||||
txt,
|
txt,
|
||||||
split = ' ',
|
split = ' ',
|
||||||
@@ -185,7 +197,10 @@ export class HighlightedMarkdown extends Component {
|
|||||||
<span className="icon icon-new-tab" />
|
<span className="icon icon-new-tab" />
|
||||||
</a>
|
</a>
|
||||||
{is_video(p) && (
|
{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' ? (
|
) : rule === 'pid' ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user