This commit is contained in:
Vanessa 2022-07-20 19:58:31 +08:00
parent a6ae63ddf7
commit 19b36b46f0
2 changed files with 7 additions and 5 deletions

View file

@ -1,9 +1,9 @@
import {Constants} from "../../constants";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByMatchTag} from "../util/hasClosest";
import {
focusBlock,
focusByRange,
focusByWbr,
focusSideBlock,
getEditorRange,
getSelectionOffset,
getSelectionPosition
@ -599,7 +599,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
window.siyuan.menus.menu.element.querySelector('[data-id="assetSubMenu"]').classList.add("b3-menu__item--show");
window.siyuan.menus.menu.element.querySelectorAll("input")[0].focus();
} else if (value === "---") {
focusSideBlock(nodeElement);
focusBlock(nodeElement);
} else {
focusByWbr(nodeElement, range);
}

View file

@ -5,7 +5,7 @@ import * as dayjs from "dayjs";
import {transaction, updateTransaction} from "./transaction";
import {mathRender} from "../markdown/mathRender";
import {highlightRender} from "../markdown/highlightRender";
import {getContenteditableElement, getNextBlock} from "./getBlock";
import {getContenteditableElement, getNextBlock, isNotEditBlock} from "./getBlock";
import {genEmptyBlock} from "../../block/util";
import {blockRender} from "../markdown/blockRender";
import {hideElements} from "../ui/hideElements";
@ -80,10 +80,12 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
let html = blockElement.outerHTML;
let todoOldHTML = "";
if (editElement.textContent === "---" && !blockElement.classList.contains("code-block")) {
html = `<div data-node-id="${id}" data-type="NodeThematicBreak" class="hr"><div></div></div>`;
html = `<div data-node-id="${id}" data-type="NodeThematicBreak" class="hr"><div><wbr></div></div>`;
const nextBlockElement = getNextBlock(editElement);
if (nextBlockElement) {
focusBlock(nextBlockElement);
if (!isNotEditBlock(nextBlockElement)) {
focusBlock(nextBlockElement);
}
} else {
html += genEmptyBlock(false, true);
}