From f91c2c8e0cd4a34ffdef116bde71e312d4519484 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Mon, 28 Mar 2022 01:06:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B5=8C=E5=85=A5=E8=A7=86?= =?UTF-8?q?=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 ++ src/Common.css | 2 +- src/Common.js | 32 +++++++++++++++++++++++--------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index e1ac30a..4ef5024 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,8 @@ + + diff --git a/src/Common.css b/src/Common.css index 521bfea..ce10dd9 100644 --- a/src/Common.css +++ b/src/Common.css @@ -59,7 +59,7 @@ margin-left: .15rem; } -.ext-img { +.ext-img, .ext-video { max-width: 100%; max-height: 2000px; display: block; diff --git a/src/Common.js b/src/Common.js index 828407a..2730707 100644 --- a/src/Common.js +++ b/src/Common.js @@ -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,15 +159,20 @@ export class HighlightedMarkdown extends Component { /## ) : rule === 'url' ? ( - - {p} - - + <> + + {p} + + + {is_video(p) && ( +