Skip to content

Commit

Permalink
feat(theme): override target="_blank" behavior (#28)
Browse files Browse the repository at this point in the history
* feat(theme): override target="_blank" behavior

* feat(theme): more clever impl
  • Loading branch information
Myriad-Dreamin authored Sep 23, 2023
1 parent f16594a commit 7b520ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/src/svg_utils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ window.typstProcessSvg = function (docRoot) {
}

let elem = event.target;
const origin = elem.closest(`a`);

if (origin && origin.getAttribute('onclick') === null) {
let target = origin.getAttribute('target');
if (target === '_blank') {
// remove the target attribute
origin.removeAttribute('target');
}
return;
}

while (elem) {
const span = elem.getAttribute('data-span');
if (span) {
Expand Down

0 comments on commit 7b520ba

Please sign in to comment.