From fb2cb8edbf67b55fcca2674acc66229617f9892e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 31 Aug 2022 18:17:43 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5708 --- app/src/menus/protyle.ts | 10 +++++----- app/src/protyle/gutter/index.ts | 2 +- app/src/protyle/util/paste.ts | 2 +- app/src/protyle/wysiwyg/input.ts | 2 +- app/src/protyle/wysiwyg/transaction.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index bcff95167..6a5003555 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}`; + element.outerHTML = `${element.innerHTML}`; 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 = `${element.textContent}`; + element.outerHTML = `${element.innerHTML}`; 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 6a13a91bd..e16be5742 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 8e6a71158..ee9a2a8e9 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 697fc54f5..0bb1eb785 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 934d3d03a..aa1c58c8d 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);