This commit is contained in:
Vanessa 2023-08-29 10:43:15 +08:00 committed by Daniel
parent 5d6c71e35a
commit 9532a3eab6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1,7 +1,7 @@
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "./hasClosest";
import * as dayjs from "dayjs";
import {transaction, updateTransaction} from "../wysiwyg/transaction";
import {getContenteditableElement} from "../wysiwyg/getBlock";
import {getContenteditableElement, hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
import {fixTableRange, focusBlock, focusByWbr, getEditorRange} from "./selection";
import {mathRender} from "../render/mathRender";
import {Constants} from "../../constants";
@ -150,6 +150,15 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
editableElement.innerHTML = replaceInnerHTML;
}
}
const editWbrElement = editableElement.querySelector("wbr")
if (editWbrElement && editableElement && !trimStartText.endsWith("\n")) {
// 数学公式后无换行,后期渲染后添加导致 rang 错误,中文输入错误 https://github.com/siyuan-note/siyuan/issues/9054
const previousElement = hasPreviousSibling(editWbrElement) as HTMLElement
if (previousElement && previousElement.nodeType !== 3 && previousElement.dataset.type.indexOf("inline-math") > -1 &&
!hasNextSibling(editWbrElement)) {
editWbrElement.insertAdjacentText("afterend", "\n");
}
}
mathRender(blockElement);
updateTransaction(protyle, id, blockElement.outerHTML, oldHTML);
focusByWbr(protyle.wysiwyg.element, range);