This commit is contained in:
Vanessa 2022-09-25 09:53:53 +08:00
parent 56dd997b6d
commit c2e9e7ed6f
2 changed files with 10 additions and 5 deletions

View file

@ -303,15 +303,19 @@ export const setFirstNodeRange = (editElement: Element, range: Range) => {
if (!editElement) {
return range;
}
let firstChild = editElement.firstChild;
while (firstChild && firstChild.nodeType !== 3) {
firstChild = firstChild.firstChild;
let firstChild = editElement.firstChild as HTMLElement;
while (firstChild && firstChild.nodeType !== 3 && !firstChild.classList.contains("render-node")) {
firstChild = firstChild.firstChild as HTMLElement;
}
if (!firstChild) {
range.selectNodeContents(editElement);
return range;
}
range.setStart(firstChild, 0);
if (firstChild.classList.contains("render-node")) {
range.setStartBefore(firstChild);
} else {
range.setStart(firstChild, 0);
}
return range;
};

View file

@ -300,7 +300,8 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
}
// bq
if (editableElement.textContent === "" && blockElement.nextElementSibling && blockElement.nextElementSibling.classList.contains("protyle-attr") && blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote") {
if (editableElement.textContent.replace(Constants.ZWSP, "").replace("\n", "") === "" &&
blockElement.nextElementSibling && blockElement.nextElementSibling.classList.contains("protyle-attr") && blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote") {
range.insertNode(document.createElement("wbr"));
const topElement = getTopEmptyElement(blockElement);
const blockId = blockElement.getAttribute("data-node-id");