🐛 windows 下回车新建块输入abc,选中 bc ctrl+m 后光标错误

This commit is contained in:
Vanessa 2023-08-29 23:02:10 +08:00 committed by Daniel
parent 6f42ac392e
commit 00d58cb4dc
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -21,7 +21,8 @@ import {isLocalPath, pathPosix} from "../../util/pathName";
import {genEmptyElement} from "../../block/util";
import {previewImage} from "../preview/image";
import {
contentMenu, enterBack,
contentMenu,
enterBack,
fileAnnotationRefMenu,
imgMenu,
linkMenu,
@ -1527,7 +1528,8 @@ export class WYSIWYG {
(!event.isComposing || (event.isComposing && range.toString() !== "")) // https://github.com/siyuan-note/siyuan/issues/4341
) {
// 搜狗输入法不走 keydown需重新记录历史状态
if (nodeElement && typeof protyle.wysiwyg.lastHTMLs[nodeElement.getAttribute("data-node-id")] === "undefined") {
if (range.toString() === "" && // windows 下回车新建块输入abc选中 bc ctrl+m 后光标错误
nodeElement && typeof protyle.wysiwyg.lastHTMLs[nodeElement.getAttribute("data-node-id")] === "undefined") {
range.insertNode(document.createElement("wbr"));
protyle.wysiwyg.lastHTMLs[nodeElement.getAttribute("data-node-id")] = nodeElement.outerHTML;
nodeElement.querySelector("wbr").remove();