From fc83211e907215dd32352d2a591ee6f0874890dd Mon Sep 17 00:00:00 2001 From: si458 Date: Tue, 5 Nov 2024 15:58:51 +0000 Subject: [PATCH] open note urls in new tab #4091 Signed-off-by: si458 --- views/default.handlebars | 13 +++++++++++++ views/default3.handlebars | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/views/default.handlebars b/views/default.handlebars index f01d626d..2913ee45 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1708,6 +1708,19 @@ mainUpdate(512); }, 200); + // open notes markdown links in new tab + if (DOMPurify) { + DOMPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + node.setAttribute('target', '_blank'); + node.setAttribute('rel', 'noopener noreferrer'); + } + if (!node.hasAttribute('target') && (node.hasAttribute('xlink:href') || node.hasAttribute('href'))) { + node.setAttribute('xlink:show', 'new'); + } + }); + } + // Connect to the mesh server meshserver = MeshServerCreateControl(domainUrl); meshserver.onStateChanged = onStateChanged; diff --git a/views/default3.handlebars b/views/default3.handlebars index 90f201a3..887f936e 100644 --- a/views/default3.handlebars +++ b/views/default3.handlebars @@ -2369,6 +2369,19 @@ mainUpdate(512); }, 200); + // open notes markdown links in new tab + if (DOMPurify) { + DOMPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + node.setAttribute('target', '_blank'); + node.setAttribute('rel', 'noopener noreferrer'); + } + if (!node.hasAttribute('target') && (node.hasAttribute('xlink:href') || node.hasAttribute('href'))) { + node.setAttribute('xlink:show', 'new'); + } + }); + } + // Connect to the mesh server meshserver = MeshServerCreateControl(domainUrl); meshserver.onStateChanged = onStateChanged;