From 3afea22f9dff265b472a8d5fcc33a48404263846 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Tue, 3 Oct 2023 12:11:37 +0200 Subject: [PATCH] added: ctrl+click to open extrenal links --- main.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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)