Render open-location syntax as link
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
This commit is contained in:
18
script.js
18
script.js
@@ -119,9 +119,23 @@
|
||||
return path;
|
||||
}
|
||||
|
||||
function findOpenElement(target) {
|
||||
var el = target;
|
||||
while (el && el !== document) {
|
||||
if (el.classList && el.classList.contains('luxtools-open')) return el;
|
||||
el = el.parentNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function onClick(event) {
|
||||
var el = event.target;
|
||||
if (!el || !el.classList || !el.classList.contains('luxtools-open')) return;
|
||||
var el = findOpenElement(event.target);
|
||||
if (!el) return;
|
||||
|
||||
// {{open>...}} renders as a link; avoid jumping to '#'.
|
||||
if (el.tagName && el.tagName.toLowerCase() === 'a') {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
var raw = el.getAttribute('data-path') || '';
|
||||
if (!raw) return;
|
||||
|
||||
Reference in New Issue
Block a user