Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/5708

Vanessafb2cb8edbf67
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index bcff951672..6a5003555d 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -72,7 +72,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
element.textContent = Lute.EscapeHTMLStr(inputElement.value);
} else {
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
- element.textContent = Lute.EscapeHTMLStr(response.data);
+ element.innerHTML = response.data;
});
}
});
@@ -141,7 +141,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
click() {
element.setAttribute("data-subtype", "d");
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
- element.innerHTML = Lute.EscapeHTMLStr(response.data);
+ element.innerHTML = response.data;
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
});
@@ -162,7 +162,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
submenu = submenu.concat([{
label: window.siyuan.languages.text,
click() {
- element.outerHTML = `${element.textContent}<wbr>`;
+ element.outerHTML = `${element.innerHTML}<wbr>`;
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
focusByWbr(nodeElement, protyle.toolbar.range);
@@ -179,7 +179,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}, {
label: window.siyuan.languages.text + " *",
click() {
- element.insertAdjacentText("beforebegin", element.textContent + " ");
+ element.insertAdjacentHTML("beforebegin", element.innerHTML + " ");
element.setAttribute("data-subtype", "s");
element.textContent = "*";
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
@@ -190,7 +190,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
label: window.siyuan.languages.link,
icon: "iconLink",
click() {
- element.outerHTML = `<span data-type="a" data-href="siyuan://blocks/${element.getAttribute("data-id")}">${element.textContent}</span><wbr>`;
+ element.outerHTML = `<span data-type="a" data-href="siyuan://blocks/${element.getAttribute("data-id")}">${element.innerHTML}</span><wbr>`;
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
focusByWbr(nodeElement, protyle.toolbar.range);
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 6a13a91bd4..e16be5742c 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -321,7 +321,7 @@ export class Gutter {
options.protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
if (item.textContent === "") {
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
- item.textContent = response.data;
+ item.innerHTML = response.data;
});
}
});
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 8e6a711588..ee9a2a8e92 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -255,7 +255,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
if (item.textContent === "") {
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
- item.textContent = response.data;
+ item.innerHTML = response.data;
});
}
});
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index 697fc54f52..0bb1eb7856 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -75,7 +75,7 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
if (refElement && refElement.getAttribute("data-subtype") === "d") {
const response = await fetchSyncPost("/api/block/getRefText", {id: refElement.getAttribute("data-id")});
- if (response.data !== refElement.textContent) {
+ if (response.data !== refElement.innerHTML) {
refElement.setAttribute("data-subtype", "s");
}
}
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 934d3d03af..aa1c58c8d7 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -659,7 +659,7 @@ const updateRef = (protyle: IProtyle, id: string, index = 0) => {
protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${id}"]`).forEach(item => {
if (item.getAttribute("data-subtype") === "d") {
fetchPost("/api/block/getRefText", {id: id}, (response) => {
- item.textContent = response.data;
+ item.innerHTML = response.data;
const blockElement = hasClosestBlock(item);
if (blockElement) {
updateRef(protyle, blockElement.getAttribute("data-node-id"), index + 1);