mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-20 00:59:34 +00:00
Update markdown_controller.js
Don't handle links as external by default. Instead distiguish internal (relative) and external (absolute) links.
This commit is contained in:
parent
b8d5b83eee
commit
e5a7ddb833
1 changed files with 11 additions and 7 deletions
|
|
@ -56,12 +56,16 @@ export default class MarkdownController extends Controller {
|
||||||
this.element.innerHTML = DOMPurify.sanitize(MarkdownController._marked.parse(this.unescapeHTML(raw)));
|
this.element.innerHTML = DOMPurify.sanitize(MarkdownController._marked.parse(this.unescapeHTML(raw)));
|
||||||
|
|
||||||
for(let a of this.element.querySelectorAll('a')) {
|
for(let a of this.element.querySelectorAll('a')) {
|
||||||
//Mark all links as external
|
// test if link is absolute
|
||||||
a.classList.add('link-external');
|
var r = new RegExp('^(?:[a-z+]+:)?//', 'i');
|
||||||
//Open links in new tag
|
if (r.test(a.getAttribute('href'))) {
|
||||||
a.setAttribute('target', '_blank');
|
//Mark all links as external
|
||||||
//Dont track
|
a.classList.add('link-external');
|
||||||
a.setAttribute('rel', 'noopener');
|
//Open links in new tag
|
||||||
|
a.setAttribute('target', '_blank');
|
||||||
|
//Dont track
|
||||||
|
a.setAttribute('rel', 'noopener');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply bootstrap styles to tables
|
//Apply bootstrap styles to tables
|
||||||
|
|
@ -108,4 +112,4 @@ export default class MarkdownController extends Controller {
|
||||||
gfm: true,
|
gfm: true,
|
||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue