JonyEpsilon / gorilla-repl

A rich REPL for Clojure in the notebook style.
http://gorilla-repl.org
MIT License
887 stars 104 forks source link

hrefs don't navigate #244

Open sashton opened 8 years ago

sashton commented 8 years ago

I've tried adding an href to HtmlView output. The link renders, but on clicking it, the browser doesn't navigate. Is there some global click handler which is preventing it?

Example:

#gorilla_repl.html.HtmlView{:content ("<a href=\"http://www.google.com\">www.google.com</a>")}
sashton commented 8 years ago

On investigation, it looks like my suspicion is confirmed: https://github.com/JonyEpsilon/gorilla-repl/blob/develop/resources/gorilla-repl-client/js/renderer.js#L20

The event listener there is returning false. Maybe a solution would be to return false if alt is pressed, but true if otherwise, to allow normal href behavior to occur.

As a workaround, I added an ugly javascript onclick handler to get the navigation to happen:

#gorilla_repl.html.HtmlView{:content ("<a href=\"http://www.google.com\" onclick=\"window.open('http://www.google.com');\">google</a>")}
JonyEpsilon commented 8 years ago

This was done to stop the case where you click on a link and then lose your unsaved work in Gorilla, which is very annoying!

Having a modifier that allows you to follow the link (a bit like in MS Word) is a nice idea.

sashton commented 8 years ago

Keeping unsaved work is definitely a good idea. In my snippet above I solved that by opening the link in a new browser window.