feat: add `embed youtube video` command

pull/645/head
Tienson Qin 2020-11-08 12:29:37 +08:00
parent 570cdebd7d
commit 8b3bde40a1
2 changed files with 24 additions and 1 deletions

View File

@ -100,7 +100,7 @@
["Deadline" [[:editor/clear-current-slash]
[:editor/show-date-picker]]]
["Scheduled" [[:editor/clear-current-slash]
[:editor/show-date-picker]]]
[:editor/show-date-picker]]]
["Draw" [[:editor/input "/draw "]
[:editor/show-input [{:command :draw
:id :title
@ -125,6 +125,8 @@
["Image Link" link-steps]
(when (state/logged?)
["Upload an image" [[:editor/click-hidden-file-input :id]]])
["Embed Youtube Video" [[:editor/input "{{{youtube }}}" {:last-pattern slash
:backward-pos 3}]]]
["Html Inline " (->inline "html")]
;; TODO:

View File

@ -578,6 +578,27 @@
[title])
arguments)]
(cond
(= name "youtube")
(let [url (first arguments)]
(when-let [youtube-id (cond
(string/starts-with? url "https://youtu.be/")
(string/replace url "https://youtu.be/" "")
(string? url)
url
:else
nil)]
(when-not (string/blank? youtube-id)
[:iframe
{:allowfullscreen "allowfullscreen"
:allow
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
:frameborder "0"
:src (str "https://www.youtube.com/embed/" youtube-id)
:height "315"
:width "560"}])))
(= name "embed")
(let [a (first arguments)]
(cond