added: ctrl+click to open extrenal links

This commit is contained in:
quenousimporte 2023-10-03 12:11:37 +02:00
parent b174f7b727
commit 3afea22f9d
1 changed files with 18 additions and 0 deletions

18
main.js
View File

@ -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)