1
0
silverbullet/plugs/index/asset/toc.js
2023-11-25 13:40:56 +01:00

27 lines
788 B
JavaScript

function processClick(e) {
const dataEl = e.target.closest("[data-ref]");
syscall(
"system.invokeFunction",
"index.navigateToMention",
dataEl.getAttribute("data-ref"),
).catch(console.error);
}
document.getElementById("link-ul").addEventListener("click", processClick);
document.getElementById("hide-button").addEventListener("click", () => {
syscall("system.invokeFunction", "index.toggleTOC").catch(console.error);
});
document.body.addEventListener("mouseenter", () => {
console.log("Refreshing on focus");
syscall("system.invokeFunction", "index.renderTOC").catch(
console.error,
);
});
document.getElementById("reload-button").addEventListener("click", () => {
syscall("system.invokeFunction", "index.renderTOC").catch(
console.error,
);
});