From bf4c4e6a4f35f746ccb21766ed265322bd904625 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 6 Oct 2023 22:46:26 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9358 --- app/src/protyle/util/insertHTML.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts index bf70a7e29..de7367fa7 100644 --- a/app/src/protyle/util/insertHTML.ts +++ b/app/src/protyle/util/insertHTML.ts @@ -18,8 +18,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false, } const range = useProtyleRange ? protyle.toolbar.range : getEditorRange(protyle.wysiwyg.element); fixTableRange(range); + let tableInlineHTML; if (hasClosestByAttribute(range.startContainer, "data-type", "NodeTable") && !isBlock) { - html = protyle.lute.BlockDOM2InlineBlockDOM(html); + tableInlineHTML = protyle.lute.BlockDOM2InlineBlockDOM(html); } let blockElement = hasClosestBlock(range.startContainer) as Element; if (!blockElement) { @@ -102,7 +103,8 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false, } const tempElement = document.createElement("template"); // 需要再 spin 一次 https://github.com/siyuan-note/siyuan/issues/7118 - tempElement.innerHTML = protyle.lute.SpinBlockDOM(html) || + tempElement.innerHTML = tableInlineHTML // 在 table 中插入需要使用转换好的行内元素 https://github.com/siyuan-note/siyuan/issues/9358 + || protyle.lute.SpinBlockDOM(html) || html; // 空格会被 Spin 不再,需要使用原文 const editableElement = getContenteditableElement(blockElement); // 使用 lute 方法会添加 p 元素,只有一个 p 元素或者只有一个字符串或者为 b 时的时候只拷贝内部