mirror of https://github.com/logseq/logseq
feat: add `embed youtube video` command
parent
570cdebd7d
commit
8b3bde40a1
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue