Skip to content

Commit

Permalink
fix: git patch bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Sep 23, 2023
1 parent 7b520ba commit 58f887b
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions frontend/src/svg_utils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,12 @@ window.typstProcessSvg = function (docRoot) {
}

docRoot.addEventListener('click', event => {
const origin = event.target.closest(`a`);

if (origin && origin.getAttribute('onclick') !== undefined) {
// stop the browser automatically opening a new tab
event.preventDefault();

// console.log(origin, origin.href);

// do whatever you want with the url
if (typeof SVGAnimatedString !== 'undefined' && origin.href instanceof SVGAnimatedString) {
window.location = origin.href.baseVal;
} else {
window.location = origin.href;
}
return;
}

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

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

0 comments on commit 58f887b

Please sign in to comment.