import treeService from "./tree.js"; import linkService from "./link.js"; import froca from "./froca.js"; import utils from "./utils.js"; import attributeRenderer from "./attribute_renderer.js"; import contentRenderer from "./content_renderer.js"; import appContext from "../components/app_context.js"; function setupGlobalTooltip() { $(document).on("mouseenter", "a", mouseEnterHandler); $(document).on("mouseleave", "a", mouseLeaveHandler); // close any note tooltip after click, this fixes the problem that sometimes tooltips remained on the screen $(document).on("click", () => $('.note-tooltip').remove()); } function setupElementTooltip($el) { $el.on('mouseenter', mouseEnterHandler); $el.on('mouseleave', mouseLeaveHandler); } async function mouseEnterHandler() { const $link = $(this); if ($link.hasClass("no-tooltip-preview") || $link.hasClass("disabled")) { return; } // this is to avoid showing tooltip from inside the CKEditor link editor dialog if ($link.closest(".ck-link-actions").length) { return; } const url = $link.attr("href") || $link.attr("data-href"); const { notePath, noteId, viewScope } = linkService.parseNavigationStateFromUrl(url); if (!notePath || viewScope.viewMode !== 'default') { return; } const note = await froca.getNote(noteId); const content = await renderTooltip(note); if (utils.isHtmlEmpty(content)) { return; } const html = `