fix: open error external link with shiftkey on Win #2023

pull/2064/head
charlie 2021-05-29 13:42:03 +08:00 committed by Tienson Qin
parent 907704310b
commit ca693456ea
2 changed files with 11 additions and 1 deletions

View File

@ -307,7 +307,9 @@
:nfs-granted? granted?
:db-restoring? db-restoring?
:system-theme? system-theme?
:on-click editor-handler/unhighlight-blocks!}
:on-click #(do
(editor-handler/unhighlight-blocks!)
(util/fix-open-external-with-shift! %))}
[:div.theme-inner
(sidebar-mobile-sidebar

View File

@ -1374,6 +1374,14 @@
(count val))]
(.setRangeText input "" current (inc idx)))))
#?(:cljs
(defn fix-open-external-with-shift!
[^js/MouseEvent e]
(when (and (.-shiftKey e) util/win32? (util/electron?)
(= (string/lower-case (.. e -target -nodeName)) "a")
(string/starts-with? (.. e -target -href) "file:"))
(.preventDefault e))))
(defn classnames
"Like react classnames utility: