支持嵌入视频
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
<link rel="icon" href="%PUBLIC_URL%/static/favicon/512.png">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
|
||||
<meta name="referrer" content="no-referrer">
|
||||
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/static/favicon/512.png">
|
||||
<link rel="manifest" href="./static/manifest.json">
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
margin-left: .15rem;
|
||||
}
|
||||
|
||||
.ext-img {
|
||||
.ext-img, .ext-video {
|
||||
max-width: 100%;
|
||||
max-height: 2000px;
|
||||
display: block;
|
||||
|
||||
@@ -24,6 +24,15 @@ function escape_regex(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
function is_video(s) {
|
||||
try {
|
||||
let url = new URL(s);
|
||||
return url.pathname.endsWith('.mp4') || url.pathname.endsWith('.mov');
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function build_highlight_re(
|
||||
txt,
|
||||
split = ' ',
|
||||
@@ -150,6 +159,7 @@ export class HighlightedMarkdown extends Component {
|
||||
/##
|
||||
</span>
|
||||
) : rule === 'url' ? (
|
||||
<>
|
||||
<a
|
||||
href={normalize_url(p)}
|
||||
className="ext-link"
|
||||
@@ -159,6 +169,10 @@ export class HighlightedMarkdown extends Component {
|
||||
{p}
|
||||
<span className="icon icon-new-tab" />
|
||||
</a>
|
||||
{is_video(p) && (
|
||||
<video className="ext-video" src={p} controls loop/>
|
||||
)}
|
||||
</>
|
||||
) : rule === 'pid' ? (
|
||||
<a
|
||||
href={'#' + p}
|
||||
|
||||
Reference in New Issue
Block a user