Merge pull request #212 from nextjournal/fix-html5-history-contenteditable

Fix handling links inside contenteditable
This commit is contained in:
Juho Teperi 2019-02-08 13:49:55 +02:00 committed by GitHub
commit f5eb1d17f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,8 @@
(:require [reitit.core :as reitit] (:require [reitit.core :as reitit]
[reitit.core :as r] [reitit.core :as r]
[reitit.frontend :as rf] [reitit.frontend :as rf]
[goog.events :as gevents]) [goog.events :as gevents]
[goog.dom :as gdom])
(:import goog.Uri)) (:import goog.Uri))
(defprotocol History (defprotocol History
@ -77,7 +78,8 @@
(not (contains? #{"_blank" "self"} (.getAttribute el "target"))) (not (contains? #{"_blank" "self"} (.getAttribute el "target")))
;; Left button ;; Left button
(= 0 (.-button e)) (= 0 (.-button e))
(reitit/match-by-path router (.getPath uri))) (reitit/match-by-path router (.getPath uri))
(not (gdom/getAncestor el (fn [node] (.isContentEditable node)))))
(.preventDefault e) (.preventDefault e)
(let [path (str (.getPath uri) (let [path (str (.getPath uri)
(if (seq (.getQuery uri)) (if (seq (.getQuery uri))