enhance(mobile): paste Youtube/Twitter URL as macro

This commit is contained in:
leizhe
2022-01-04 13:06:12 +08:00
committed by Andelf
parent 7a8aa9329c
commit ab3e6a78b0

View File

@@ -3079,28 +3079,33 @@
(let [copied-blocks (state/get-copied-blocks)
copied-block-tree (:copy/block-tree copied-blocks)
input (state/get-input)]
(util/stop e)
(cond
(and
(:copy/content copied-blocks)
(not (string/blank? text))
(= (string/replace (string/trim text) "\r" "")
(string/replace (string/trim (:copy/content copied-blocks)) "\r" "")))
(do
;; copy from logseq internally
(paste-block-vec-tree-at-target copied-block-tree [] nil)
(util/stop e))
(paste-block-vec-tree-at-target copied-block-tree [] nil)
(and (util/url? text)
(not (string/blank? (util/get-selected-text))))
(do
(util/stop e)
(html-link-format! text))
(html-link-format! text)
(and (util/url? text)
(or (string/includes? text "youtube.com")
(string/includes? text "youtu.be"))
(mobile/is-native-platform?))
(commands/simple-insert! (state/get-edit-input-id) (util/format "{{youtube %s}}" text) nil)
(and (util/url? text)
(string/includes? text "twitter.com")
(mobile/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 "((" "))"))
(do
(util/stop e)
(commands/simple-insert! (state/get-edit-input-id) (text/get-block-ref text) nil))
(commands/simple-insert! (state/get-edit-input-id) (text/get-block-ref text) nil)
:else
;; from external
@@ -3109,30 +3114,22 @@
(nil? (util/safe-re-find #"(?m)^\s*(?:[-+*]|#+)\s+" text))
(nil? (util/safe-re-find #"(?m)^\s*\*+\s+" text))
(nil? (util/safe-re-find #"(?:\r?\n){2,}" text))]
[:markdown false _ _]
(do
(paste-text-parseable format text)
(util/stop e))
[:markdown false _ _]
(paste-text-parseable format text)
[:org _ false _]
(do
(paste-text-parseable format text)
(util/stop e))
[:org _ false _]
(paste-text-parseable format text)
[:markdown true _ false]
(do
(paste-segmented-text format text)
(util/stop e))
[:markdown true _ false]
(paste-segmented-text format text)
[:markdown true _ true]
nil
[:markdown true _ true]
nil
[:org _ true false]
(do
(paste-segmented-text format text)
(util/stop e))
[:org _ true true]
nil)))))
[:org _ true false]
(paste-segmented-text format text)
[:org _ true true]
nil)))))
(defn paste-text-in-one-block-at-point
[]