Vanessa 2024-09-28 17:14:54 +08:00
parent 2e39cb75c5
commit 4734bb81dc
2 changed files with 15 additions and 3 deletions

View file

@ -9,6 +9,7 @@ import {getCellText} from "../protyle/render/av/cell";
import {isTouchDevice} from "../util/functions";
let popoverTargetElement: HTMLElement;
let notebookItemElement: HTMLElement | false;
export const initBlockPopover = (app: App) => {
let timeout: number;
let timeoutHide: number;
@ -87,11 +88,22 @@ export const initBlockPopover = (app: App) => {
hideTooltip();
}
} else if (!aElement) {
const notebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");
notebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");
if (notebookItemElement && notebookItemElement.parentElement.getAttribute("data-type") === "navigation-root") {
showTooltip(notebookItemElement.getAttribute("aria-label") || "", notebookItemElement);
fetchPost("/api/notebook/getNotebookInfo", {notebook: notebookItemElement.parentElement.parentElement.getAttribute("data-url")}, (response) => {
const boxData = response.data.boxInfo;
showTooltip(`${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}`,notebookItemElement)
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}`
const newNotebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");
if (notebookItemElement && newNotebookItemElement && notebookItemElement.isSameNode(newNotebookItemElement)) {
showTooltip(tip, notebookItemElement);
}
if (newNotebookItemElement &&
newNotebookItemElement.parentElement.getAttribute("data-type") === "navigation-root" &&
newNotebookItemElement.parentElement.parentElement.getAttribute("data-url") === boxData.id) {
newNotebookItemElement.setAttribute("aria-label", tip);
}
})
} else {
const tipElement = hasClosestByAttribute(event.target, "id", "tooltip", true);

View file

@ -724,7 +724,7 @@ export class Files extends Model {
<svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
${emojiHTML}
<span class="b3-list-item__text">${escapeHtml(item.name)}</span>
<span class="b3-list-item__text" data-position="parentE">${escapeHtml(item.name)}</span>
<span data-type="more-root" class="b3-list-item__action b3-tooltips b3-tooltips__w${(window.siyuan.config.readonly) ? " fn__none" : ""}" aria-label="${window.siyuan.languages.more}">
<svg><use xlink:href="#iconMore"></use></svg>
</span>