Explorar o código

:art: fix https://github.com/siyuan-note/siyuan/issues/12615

Vanessa hai 10 meses
pai
achega
4734bb81dc
Modificáronse 2 ficheiros con 15 adicións e 3 borrados
  1. 14 2
      app/src/block/popover.ts
  2. 1 1
      app/src/layout/dock/Files.ts

+ 14 - 2
app/src/block/popover.ts

@@ -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);

+ 1 - 1
app/src/layout/dock/Files.ts

@@ -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>