An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add plugin event bus to tooltip (#18162)
Jeffrey Chen962da8b2ed50
diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.tsindex 9930d07049..3685f678f0 100644--- a/app/src/dialog/tooltip.ts+++ b/app/src/dialog/tooltip.ts@@ -11,6 +11,20 @@ export const showTooltip = (if (isMobile() || !message) {return;}+ const messageElement = document.getElementById("tooltip");+ const showDetail = {+ message,+ target,+ tooltipElement: messageElement,+ };+ window.siyuan.ws.app.plugins.forEach(plugin => {+ plugin.eventBus.emit("before-show-tooltip", showDetail);+ });+ message = showDetail.message;+ if (!message) {+ hideTooltip();+ return;+ }let targetRect = target.getBoundingClientRect();// 跨行元素const clientRects = Array.from(target.getClientRects());@@ -37,7 +51,6 @@ export const showTooltip = (hideTooltip();return;}- const messageElement = document.getElementById("tooltip");messageElement.className = tooltipClass ? `tooltip tooltip--${tooltipClass}` : "tooltip";messageElement.innerHTML = window.DOMPurify.sanitize(message);// 避免原本的 top 和 left 影响计算@@ -134,5 +147,14 @@ export const showTooltip = (};export const hideTooltip = () => {- document.getElementById("tooltip").classList.add("fn__none");+ const messageElement = document.getElementById("tooltip");+ if (messageElement.classList.contains("fn__none")) {+ return;+ }+ window.siyuan.ws.app.plugins.forEach(plugin => {+ plugin.eventBus.emit("before-hide-tooltip", {+ tooltipElement: messageElement,+ });+ });+ messageElement.classList.add("fn__none");};diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 8a34fcb832..8a986bafe4 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -111,7 +111,8 @@ type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" |"lock-screen" |"mobile-keyboard-show" | "mobile-keyboard-hide" |"code-language-update" | "code-language-change" |- "kernel-plugin-state-change"+ "kernel-plugin-state-change" |+ "before-show-tooltip" | "before-hide-tooltip"type TAVView = "table" | "gallery" | "kanban"type TAVAlign = "" | "left" | "center" | "right"type TAVDateFormat = "" | "full" | "month-day-year" | "day-month-year" | "year-month-day"