From 184949dd6958ac938f2abbfb4459ac9ffed746da Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 5 Mar 2023 14:18:23 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7574 --- app/src/block/util.ts | 10 +++++++++- app/src/protyle/util/editorCommonEvent.ts | 11 +++++++++++ app/src/protyle/wysiwyg/transaction.ts | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/src/block/util.ts b/app/src/block/util.ts index 67e750df1..52511dab0 100644 --- a/app/src/block/util.ts +++ b/app/src/block/util.ts @@ -6,6 +6,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction"; import {scrollCenter} from "../util/highlightById"; import {Constants} from "../constants"; import {hideElements} from "../protyle/ui/hideElements"; +import {blockRender} from "../protyle/markdown/blockRender"; export const cancelSB = (protyle: IProtyle, nodeElement: Element) => { const doOperations: IOperation[] = []; @@ -48,7 +49,14 @@ export const cancelSB = (protyle: IProtyle, nodeElement: Element) => { }); previousId = item.getAttribute("data-node-id"); }); - + // 超级块内嵌入块无面包屑,需重新渲染 https://github.com/siyuan-note/siyuan/issues/7574 + doOperations.forEach(item => { + const element = protyle.wysiwyg.element.querySelector(`[data-node-id="${item.id}"]`); + if (element && element.getAttribute("data-type") === "NodeBlockQueryEmbed") { + element.removeAttribute("data-render") + blockRender(protyle, element) + } + }) return { doOperations, undoOperations, previousId }; diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 1a6f4b072..b6f625732 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -822,6 +822,17 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { dragSame(protyle, sourceElements, targetElement, targetClass.includes("dragover__bottom"), event.ctrlKey); } } + // 超级块内嵌入块无面包屑,需重新渲染 https://github.com/siyuan-note/siyuan/issues/7574 + sourceElements.forEach(item => { + if (item.getAttribute("data-type") === "NodeBlockQueryEmbed") { + item.removeAttribute("data-render") + blockRender(protyle, item) + } + }) + if (targetElement.getAttribute("data-type") === "NodeBlockQueryEmbed") { + targetElement.removeAttribute("data-render") + blockRender(protyle, targetElement) + } } } else if (event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE)?.split("-").length > 1 && targetElement && !protyle.options.backlinkData) { diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 208fec0c3..63b373876 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -728,6 +728,11 @@ export const turnsIntoOneTransaction = (options: { id, }); } + // 超级块内嵌入块无面包屑,需重新渲染 https://github.com/siyuan-note/siyuan/issues/7574 + if (item.getAttribute("data-type") === "NodeBlockQueryEmbed") { + item.removeAttribute("data-render") + blockRender(options.protyle, item) + } }); transaction(options.protyle, doOperations, undoOperations); focusBlock(options.protyle.wysiwyg.element.querySelector(`[data-node-id="${options.selectsElement[0].getAttribute("data-node-id")}"]`));