Vanessa 2025-04-30 11:14:46 +08:00
parent f66685fda3
commit 7dd7a07018
2 changed files with 7 additions and 5 deletions

View file

@ -1,5 +1,5 @@
import {focusByWbr, getEditorRange} from "../protyle/util/selection";
import {hasClosestBlock} from "../protyle/util/hasClosest";
import {hasClosestBlock, hasClosestByClassName} from "../protyle/util/hasClosest";
import {getContenteditableElement, getTopAloneElement} from "../protyle/wysiwyg/getBlock";
import {genListItemElement, updateListOrder} from "../protyle/wysiwyg/list";
import {transaction, turnsIntoOneTransaction, updateTransaction} from "../protyle/wysiwyg/transaction";
@ -131,6 +131,12 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id
} else {
blockElement = hasClosestBlock(range.startContainer) as HTMLElement;
blockElement = getTopAloneElement(blockElement);
// https://github.com/siyuan-note/siyuan/issues/14720#issuecomment-2840665326
if (blockElement.classList.contains("list")) {
blockElement = hasClosestByClassName(range.startContainer, "li") as HTMLElement;
} else if (blockElement.classList.contains("bq")) {
blockElement = hasClosestBlock(range.startContainer) as HTMLElement;
}
}
}
if (!blockElement) {

View file

@ -35,10 +35,6 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
if (disableElement ||
// https://github.com/siyuan-note/siyuan/issues/10633
blockElement.classList.contains("table")) {
if (blockElement.classList.contains("hr")) {
insertEmptyBlock(protyle, "afterend");
return;
}
if (blockElement.classList.contains("protyle-wysiwyg--select") && blockElement.classList.contains("render-node")) {
protyle.toolbar.showRender(protyle, blockElement);
} else {