mirror of
https://github.com/logseq/logseq.git
synced 2026-05-02 01:46:35 +00:00
use mod+shift+v to wrap video marco if clipboard is a url
Pasting a video url as {{video url}} is removed
This commit is contained in:
@@ -2878,6 +2878,18 @@
|
||||
(recur (remove (set (map :block/uuid result)) (rest ids)) result))
|
||||
result)))
|
||||
|
||||
(defn wrap-macro-url
|
||||
[url]
|
||||
(cond
|
||||
(boolean (text/get-matched-video url))
|
||||
(util/format "{{video %s}}" url)
|
||||
|
||||
(string/includes? url "twitter.com")
|
||||
(util/format "{{twitter %s}}" url)
|
||||
|
||||
:else
|
||||
(notification/show! (util/format "No macro is available for %s" url) :warning)))
|
||||
|
||||
(defn- paste-copied-blocks-or-text
|
||||
[text e]
|
||||
(let [copied-blocks (state/get-copied-blocks)
|
||||
@@ -2906,15 +2918,6 @@
|
||||
(not (string/blank? (util/get-selected-text))))
|
||||
(html-link-format! text)
|
||||
|
||||
(and (gp-util/url? text)
|
||||
(boolean (text/get-matched-video text)))
|
||||
(commands/simple-insert! (state/get-edit-input-id) (util/format "{{video %s}}" text) nil)
|
||||
|
||||
(and (gp-util/url? text)
|
||||
(string/includes? text "twitter.com")
|
||||
(mobile-util/is-native-platform?))
|
||||
(commands/simple-insert! (state/get-edit-input-id) (util/format "{{twitter %s}}" text) nil)
|
||||
|
||||
(and (text/block-ref? text)
|
||||
(wrapped-by? input "((" "))"))
|
||||
(commands/simple-insert! (state/get-edit-input-id) (text/get-block-ref text) nil)
|
||||
@@ -2951,7 +2954,10 @@
|
||||
(utils/getClipText
|
||||
(fn [clipboard-data]
|
||||
(when-let [_ (state/get-input)]
|
||||
(state/append-current-edit-content! clipboard-data)))
|
||||
(let [data (if (gp-util/url? clipboard-data)
|
||||
(wrap-macro-url clipboard-data)
|
||||
clipboard-data)]
|
||||
(state/append-current-edit-content! data))))
|
||||
(fn [error]
|
||||
(js/console.error error))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user