mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-02-13 14:40:49 +00:00
Merge pull request #1479 from hedgedoc/work-around-slide-example-link
Don't open anchor links in new tabs
This commit is contained in:
commit
6ea3321074
1 changed files with 8 additions and 0 deletions
|
@ -575,6 +575,14 @@ export function postProcess (code) {
|
||||||
// also add noopener to prevent clickjacking
|
// also add noopener to prevent clickjacking
|
||||||
// See details: https://mathiasbynens.github.io/rel-noopener/
|
// See details: https://mathiasbynens.github.io/rel-noopener/
|
||||||
result.find('a:not([href^="#"]):not([target])').attr('target', '_blank').attr('rel', 'noopener')
|
result.find('a:not([href^="#"]):not([target])').attr('target', '_blank').attr('rel', 'noopener')
|
||||||
|
|
||||||
|
// If it's hashtag link then make it base uri independent
|
||||||
|
result.find('a[href^="#"]').each((index, linkTag) => {
|
||||||
|
const currentLocation = new URL(window.location)
|
||||||
|
currentLocation.hash = linkTag.hash
|
||||||
|
linkTag.href = currentLocation.toString()
|
||||||
|
})
|
||||||
|
|
||||||
// update continue line numbers
|
// update continue line numbers
|
||||||
const linenumberdivs = result.find('.gutter.linenumber').toArray()
|
const linenumberdivs = result.find('.gutter.linenumber').toArray()
|
||||||
for (let i = 0; i < linenumberdivs.length; i++) {
|
for (let i = 0; i < linenumberdivs.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue