mirror of https://github.com/logseq/logseq
Fix url? detection for raw paste case - fix #7297
parent
2c987d0c6a
commit
1c3ef2ccb5
|
@ -83,8 +83,7 @@
|
||||||
[s]
|
[s]
|
||||||
(and (string? s)
|
(and (string? s)
|
||||||
(try
|
(try
|
||||||
(js/URL. s)
|
(not (contains? #{nil "null"} (.-origin (js/URL. s))))
|
||||||
true
|
|
||||||
(catch :default _e
|
(catch :default _e
|
||||||
false))))
|
false))))
|
||||||
|
|
||||||
|
|
|
@ -28,3 +28,10 @@
|
||||||
"/root/Documents/audio" nil
|
"/root/Documents/audio" nil
|
||||||
"/root/Documents/audio." nil
|
"/root/Documents/audio." nil
|
||||||
"special/characters/aäääöüß.7z" "7z"))
|
"special/characters/aäääöüß.7z" "7z"))
|
||||||
|
|
||||||
|
(deftest url?
|
||||||
|
(are [x y]
|
||||||
|
(= (gp-util/url? x) y)
|
||||||
|
"http://logseq.com" true
|
||||||
|
"prop:: value" false
|
||||||
|
"a:" false))
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
[frontend.util :as util]
|
[frontend.util :as util]
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[frontend.extensions.html-parser :as html-parser]
|
[frontend.extensions.html-parser :as html-parser]
|
||||||
|
[frontend.handler.editor :as editor-handler]
|
||||||
[frontend.handler.paste :as paste-handler]))
|
[frontend.handler.paste :as paste-handler]))
|
||||||
|
|
||||||
(deftest try-parse-as-json-result-parse-test
|
(deftest try-parse-as-json-result-parse-test
|
||||||
|
@ -110,3 +111,20 @@
|
||||||
#js {:clipboardData #js {:getData (constantly clipboard)}})]
|
#js {:clipboardData #js {:getData (constantly clipboard)}})]
|
||||||
(is (= expected-paste result))
|
(is (= expected-paste result))
|
||||||
(reset))))))
|
(reset))))))
|
||||||
|
|
||||||
|
(deftest-async editor-on-paste-raw-with-selection
|
||||||
|
(let [clipboard "after"
|
||||||
|
expected-paste "after"
|
||||||
|
selected-text "before"
|
||||||
|
block-content "test:: before"]
|
||||||
|
(test-helper/with-reset
|
||||||
|
reset
|
||||||
|
[utils/getClipText (fn [cb] (cb clipboard))
|
||||||
|
state/get-input (constantly #js {:value block-content})
|
||||||
|
editor-handler/get-selection-and-format (constantly {:value block-content})
|
||||||
|
commands/delete-selection! (constantly nil)
|
||||||
|
commands/simple-insert! (fn [_input text] (p/resolved text))
|
||||||
|
util/get-selected-text (constantly selected-text)]
|
||||||
|
(p/let [result ((paste-handler/editor-on-paste! nil true))]
|
||||||
|
(is (= expected-paste result))
|
||||||
|
(reset)))))
|
||||||
|
|
Loading…
Reference in New Issue