浏览代码

:art: https://github.com/siyuan-note/siyuan/issues/10049

Vanessa 7 月之前
父节点
当前提交
190fa7f8c4
共有 3 个文件被更改,包括 15 次插入7 次删除
  1. 6 0
      app/src/protyle/hint/extend.ts
  2. 5 1
      app/src/protyle/hint/index.ts
  3. 4 6
      app/src/protyle/render/av/action.ts

+ 6 - 0
app/src/protyle/hint/extend.ts

@@ -440,6 +440,12 @@ export const hintRef = (key: string, protyle: IProtyle, source: THintSource): IH
             let value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="d">${item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")}</span>`;
             if (source === "search") {
                 value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${key}${Constants.ZWSP}${item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")}</span>`;
+            } else if (source === "av") {
+                let refText = item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")
+                if (nodeElement) {
+                    refText = item.ial['custom-sy-av-s-text-' + nodeElement.getAttribute("data-av-id")] || refText;
+                }
+                value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${refText}</span>`;
             }
             dataList.push({
                 value,

+ 5 - 1
app/src/protyle/hint/index.ts

@@ -339,7 +339,11 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
                 let blockRefHTML;
                 if (source === "av") {
                     // av 搜索时需要获取值 https://github.com/siyuan-note/siyuan/issues/12020
-                    blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")}</span>`;
+                    let refText = item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")
+                    if (nodeElement) {
+                        refText = item.ial['custom-sy-av-s-text-' + nodeElement.getAttribute("data-av-id")] || refText;
+                    }
+                    blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${refText}</span>`;
                 } else {
                     blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${oldValue}</span>`;
                 }

+ 4 - 6
app/src/protyle/render/av/action.ts

@@ -329,7 +329,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
             id: "copyBlockRef",
             iconHTML: "",
             label: window.siyuan.languages.copyBlockRef,
-            click: async () => {
+            click: () => {
                 let text = "";
                 for (let i = 0; i < ids.length; i++) {
                     const id = ids[i];
@@ -338,8 +338,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
                     if (cellElement.getAttribute("data-detached") === "true") {
                         content = cellElement.querySelector(".av__celltext").textContent;
                     } else {
-                        const response = await fetchSyncPost("/api/block/getRefText", {id});
-                        content = `((${id} '${response.data}'))`;
+                        content = `((${id} '${cellElement.querySelector(".av__celltext").textContent}'))`;
                     }
                     if (ids.length > 1) {
                         text += "* ";
@@ -399,7 +398,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
             id: "copyProtocolInMd",
             iconHTML: "",
             label: window.siyuan.languages.copyProtocolInMd,
-            click: async () => {
+            click: () => {
                 let text = "";
                 for (let i = 0; i < ids.length; i++) {
                     const id = ids[i];
@@ -408,8 +407,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
                     if (cellElement.getAttribute("data-detached") === "true") {
                         content = cellElement.querySelector(".av__celltext").textContent;
                     } else {
-                        const response = await fetchSyncPost("/api/block/getRefText", {id});
-                        content = `[${response.data}](siyuan://blocks/${id})`;
+                        content = `[${cellElement.querySelector(".av__celltext").textContent}](siyuan://blocks/${id})`;
                     }
                     if (ids.length > 1) {
                         text += "* ";