Utsob Roy 71835a5ee5
Tooltip Enhancements (#59)
* tooltip scroll to section

* reference highlight on focus and navigation

* removed irrelevant code

* added double-click to copy link styling

* Correctly place styling, and add new file to plugin-info

---------

Co-authored-by: Ole Eskild Steensen <oleeskild@users.noreply.github.com>
2023-02-04 13:52:16 +01:00

26 lines
928 B
Plaintext

<script>
if (window.location.hash) {
document.getElementById(window.location.hash.slice(1)).classList.add('referred');
}
window.addEventListener('hashchange', (evt) => {
const oldParts = evt.oldURL.split("#");
if (oldParts[1]) {
document.getElementById(oldParts[1]).classList.remove('referred');
}
const newParts = evt.newURL.split("#");
if (newParts[1]) {
document.getElementById(newParts[1]).classList.add('referred');
}
}, false);
const url_parts = window.location.href.split("#")
const url = url_parts[0];
const referrence = url_parts[1];
document.querySelectorAll(".cm-s-obsidian > *[id]").forEach(function (el) {
el.ondblclick = function(evt) {
const ref_url = url + '#' + evt.target.id
navigator.clipboard.writeText(ref_url);
}
});
</script>