diff --git a/main.js b/main.js index 8bd5853..d5f57e0 100644 --- a/main.js +++ b/main.js @@ -940,6 +940,7 @@ function clickeditor() { var link = linkatpos(); var tag = tagatpos(); + var word = wordatpos(); if (link) { loadnote(link); @@ -950,6 +951,10 @@ function clickeditor() searchinlist(tags[tag.toLowerCase()]) .then(loadnote); } + else if (word.startsWith("https://")) + { + window.open(word, '_blank'); + } } } @@ -1677,6 +1682,19 @@ function selectlines() md.selectionEnd = range.end; } +function wordatpos() +{ + var words = md.value.split(/\s/); + var i = 0; + var word = ""; + while (i < md.selectionStart) + { + word = words.shift(); + i += word.length + 1; + } + return word; +} + function ontopbarclick() { if (title.hidden)