Explorar o código

use mod+shift+v to wrap video marco if clipboard is a url

Pasting a video url as {{video url}} is removed
llcc %!s(int64=3) %!d(string=hai) anos
pai
achega
e3fa589396
Modificáronse 1 ficheiros con 16 adicións e 10 borrados
  1. 16 10
      src/main/frontend/handler/editor.cljs

+ 16 - 10
src/main/frontend/handler/editor.cljs

@@ -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))))