Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Vanessa190fa7f8c4c6
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index 0b16002f9f..5cf2ac8bc1 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/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,
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 0da7e85ea8..1a977f58e0 100644
--- a/app/src/protyle/hint/index.ts
+++ b/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>`;
}
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 705c0771cf..a1f7270a5f 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/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 += "* ";