commands: add vimeo video embed block command

pull/1436/head
Collin Lefeber 2021-03-07 10:40:44 -05:00 committed by Tienson Qin
parent 55265f1657
commit dfb0ff6bd3
2 changed files with 21 additions and 0 deletions

View File

@ -138,6 +138,10 @@
["Embed Youtube Video" [[:editor/input "{{youtube }}" {:last-pattern slash
:backward-pos 2}]]]
["Embed Vimeo Video" [[:editor/input "{{vimeo }}" {:last-pattern slash
:backward-pos 2}]]]
["Html Inline " (->inline "html")]
;; TODO:

View File

@ -800,6 +800,23 @@
:height height
:width width}])))))
(= name "vimeo")
(let [url (first arguments)]
(let [Vimeo-regex #"^((?:https?:)?//)?((?:www).)?((?:player.vimeo.com|vimeo.com)?)((?:/video/)?)([\w-]+)(\S+)?$"]
(when-let [vimeo-id (nth (re-find Vimeo-regex url) 5)]
(when-not (string/blank? vimeo-id)
(let [width (min (- (util/get-width) 96)
560)
height (int (* width (/ 315 560)))]
[:iframe
{:allow-full-screen "allowfullscreen"
:allow
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
:frame-border "0"
:src (str "https://player.vimeo.com/video/" vimeo-id)
:height height
:width width}])))))
;; TODO: support fullscreen mode, maybe we need a fullscreen dialog?
(= name "bilibili")
(let [url (first arguments)