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: https://github.com/siyuan-note/siyuan/issues/14823
Vanessa0a40694b0b58
diff --git a/app/src/block/popover.ts b/app/src/block/popover.tsindex 1cc0608b55..21263a5be2 100644--- a/app/src/block/popover.ts+++ b/app/src/block/popover.ts@@ -7,10 +7,12 @@ import {App} from "../index";import {Constants} from "../constants";import {getCellText} from "../protyle/render/av/cell";import {isTouchDevice} from "../util/functions";-import {escapeAriaLabel, escapeHtml} from "../util/escape";+import {escapeAriaLabel, escapeHtml, escapeLessThans} from "../util/escape";+import {getInstanceById} from "../layout/util";+import {Editor} from "../editor";+import {Tab} from "../layout/Tab";let popoverTargetElement: HTMLElement;-let notebookItemElement: HTMLElement | false;// 异步获取信息后再显示 tooltip,鼠标已移走时需中断请求 https://github.com/siyuan-note/siyuan/issues/14823let tooltipAbortController: AbortController | null = null;export const initBlockPopover = (app: App) => {@@ -137,20 +139,54 @@ export const initBlockPopover = (app: App) => {}}- notebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");+ const tabElement = hasClosestByAttribute(event.target, "data-type", "tab-header");+ if (tabElement) {+ const tab = getInstanceById(tabElement.getAttribute("data-id"));+ if (tab instanceof Tab) {+ let id = "";+ if (tab.model instanceof Editor && tab.model.editor?.protyle?.block?.rootID) {+ id = (tab.model as Editor).editor.protyle.block.rootID;+ } else if (!tab.model) {+ const initData = JSON.parse(tab.headElement.getAttribute("data-initdata") || "{}");+ if (initData && initData.instance === "Editor") {+ id = initData.blockId;+ }+ }+ if (id) {+ tooltipAbortController = new AbortController();+ const signal = tooltipAbortController.signal;+ const capturedController = tooltipAbortController;+ fetchPost("/api/filetree/getFullHPathByID", {+ id+ }, (response) => {+ if (signal.aborted) {+ return;+ }+ showTooltip(escapeLessThans(response.data), tab.headElement);+ tab.headElement.setAttribute("aria-label", escapeLessThans(response.data));+ if (tooltipAbortController === capturedController) {+ tooltipAbortController = null;+ }+ }, undefined, undefined, signal);+ } else {+ tab.headElement.setAttribute("aria-label", escapeLessThans(tab.title));+ }+ }+ }++ const notebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");if (notebookItemElement && notebookItemElement.parentElement.getAttribute("data-type") === "navigation-root") {- const scopedNotebookItemElement = notebookItemElement;tooltipAbortController = new AbortController();const signal = tooltipAbortController.signal;const capturedController = tooltipAbortController;- fetchPost("/api/notebook/getNotebookInfo", {notebook: scopedNotebookItemElement.parentElement.parentElement.getAttribute("data-url")}, (response) => {+ fetchPost("/api/notebook/getNotebookInfo", {notebook: notebookItemElement.parentElement.parentElement.getAttribute("data-url")}, (response) => {if (signal.aborted) {return;}const boxData = response.data.boxInfo;const tip = `${boxData.name} <small class='ft__on-surface'>${boxData.hSize}</small>${boxData.docCount !== 0 ? window.siyuan.languages.includeSubFile.replace("x", boxData.docCount) : ""}<br>${window.siyuan.languages.modifiedAt} ${boxData.hMtime}<br>${window.siyuan.languages.createdAt} ${boxData.hCtime}`;- showTooltip(tip, scopedNotebookItemElement);- scopedNotebookItemElement.setAttribute("aria-label", tip);+ showTooltip(tip, notebookItemElement as Element);+ (notebookItemElement as HTMLElement).setAttribute("aria-label", tip);if (tooltipAbortController === capturedController) {tooltipAbortController = null;}diff --git a/app/src/layout/Tab.ts b/app/src/layout/Tab.tsindex 69f97cd0f7..c778ca01c2 100644--- a/app/src/layout/Tab.ts+++ b/app/src/layout/Tab.ts@@ -1,13 +1,11 @@import {Wnd} from "./Wnd";import {genUUID} from "../util/genID";import type {Model} from "./Model";-import {Editor} from "../editor";import {hasClosestByTag} from "../protyle/util/hasClosest";import {Constants} from "../constants";-import {escapeHtml, escapeLessThans} from "../util/escape";+import {escapeHtml} from "../util/escape";import {unicode2Emoji} from "../emoji";-import {fetchPost} from "../util/fetch";-import {hideTooltip, showTooltip} from "../dialog/tooltip";+import {hideTooltip} from "../dialog/tooltip";/// #if !BROWSERimport {openNewWindow} from "../window/openNewWindow";import {ipcRenderer} from "electron";@@ -25,8 +23,6 @@ export class Tab {public title: string;public icon: string;public docIcon: string;- // 鼠标已移走时中断尚未完成的完整路径请求 https://github.com/siyuan-note/siyuan/issues/14823- public hPathAbortController: AbortController | null = null;constructor(options: ITab) {this.id = genUUID();@@ -48,59 +44,6 @@ export class Tab {}this.headElement.innerHTML = `${iconHTML}<span class="item__text">${escapeHtml(options.title)}</span><span class="item__close"><svg><use xlink:href="#iconClose"></use></svg></span>`;- this.headElement.addEventListener("mouseenter", (event) => {- event.stopPropagation();- event.preventDefault();- const dragElement = Array.from(this.headElement.parentElement.childNodes).find((item: HTMLElement) => {- if (item.style?.opacity === "0.38") {- return true;- }- });- if (dragElement) {- hideTooltip();- return;- }-- let id = "";- if (this.model instanceof Editor && this.model.editor?.protyle?.block?.rootID) {- id = (this.model as Editor).editor.protyle.block.rootID;- } else if (!this.model) {- const initData = JSON.parse(this.headElement.getAttribute("data-initdata") || "{}");- if (initData && initData.instance === "Editor") {- id = initData.blockId;- }- }- if (id) {- if (this.hPathAbortController) {- this.hPathAbortController.abort();- }- this.hPathAbortController = new AbortController();- const signal = this.hPathAbortController.signal;- const capturedController = this.hPathAbortController;- fetchPost("/api/filetree/getFullHPathByID", {- id- }, (response) => {- if (signal.aborted) {- return;- }- if (!this.headElement.getAttribute("aria-label")) {- showTooltip(escapeLessThans(response.data), this.headElement);- }- this.headElement.setAttribute("aria-label", escapeLessThans(response.data));- if (this.hPathAbortController === capturedController) {- this.hPathAbortController = null;- }- }, undefined, undefined, signal);- } else {- this.headElement.setAttribute("aria-label", escapeLessThans(this.title));- }- });- this.headElement.addEventListener("mouseleave", () => {- if (this.hPathAbortController) {- this.hPathAbortController.abort();- this.hPathAbortController = null;- }- });this.headElement.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {window.getSelection().removeAllRanges();hideTooltip();