Closed nokola closed 6 years ago
I noticed that clicking on link (not the icon) is actually in the click addon - would be nice to have similar option for a click() handler there as well (or maybe refactor part of click addon into fold addon or vice versa?)
Yes. the click handler will be introduced in next version (TypeScript ver). Click add-on only works when user clicks on text, not image. If you want to handle events on images, try adding a capturing (not bubbling) event listener.
Custom Click Handler is now avaliable in v0.3.0
A simple demo can be found here http://laobubu.net/HyperMD/?directOpen#./docs/index.md
...or just put this into your js...
cm.setOption("hmdClick", clickHandler)
function clickHandler(info, cm) {
if (info.type === "link" || info.type === "url") {
var url = info.url
if ((info.ctrlKey || info.altKey) && /hotdog/i.test(url)) {
alert("You can't access urls containing HotDog")
return false
}
}
}
In fold.js supports Ctrl+click to open links, and "break mark" for images.
With small extension in fold.js, it will make it possible to support thumbnail scenarios. For example I'm looking to support this:
To have universal solution, perhaps we add the option to have click handled in options like this?
click() handler will return true if it handles the event, and no further processing is needed click() handler returns false to show codemirror test (the "breakMark(...)" code will execute)
Example click handler: