Browse Source

fix(ios): no handling of uri pasting

Fix #9433
Andelf 2 years ago
parent
commit
8ec5ea7a50
1 changed files with 11 additions and 3 deletions
  1. 11 3
      src/main/frontend/handler/paste.cljs

+ 11 - 3
src/main/frontend/handler/paste.cljs

@@ -233,12 +233,20 @@
     (state/set-state! :editor/on-paste? true)
     (state/set-state! :editor/on-paste? true)
     (let [clipboard-data (gobj/get e "clipboardData")
     (let [clipboard-data (gobj/get e "clipboardData")
           html (.getData clipboard-data "text/html")
           html (.getData clipboard-data "text/html")
-          text (.getData clipboard-data "text")]
+          text (.getData clipboard-data "text")
+          has-files? (seq (.-files clipboard-data))]
       (cond
       (cond
         (and (string/blank? text) (string/blank? html))
         (and (string/blank? text) (string/blank? html))
+        ;; When both text and html are blank, paste file if exists.
+        ;; NOTE: util/stop is not called here if no file is provided, 
+        ;; so the default paste behavior of the native platform will be used.
+        (when has-files?
+          (paste-file-if-exists id e))
+
+        ;; both file attachment and text/html exist
+        (and has-files? (state/preferred-pasting-file?))
         (paste-file-if-exists id e)
         (paste-file-if-exists id e)
-        (and (seq (.-files clipboard-data)) (state/preferred-pasting-file?))
-        (paste-file-if-exists id e)
+
         :else
         :else
         (let [text' (or (when (gp-util/url? text)
         (let [text' (or (when (gp-util/url? text)
                           (wrap-macro-url text))
                           (wrap-macro-url text))