diff --git a/src/main/frontend/commands.cljs b/src/main/frontend/commands.cljs index 5829ab251..888eb62fe 100644 --- a/src/main/frontend/commands.cljs +++ b/src/main/frontend/commands.cljs @@ -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: diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 2be9eaf9f..16a06cf8b 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -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)