mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-30 05:18:49 +01:00
This commit is contained in:
parent
56dd997b6d
commit
c2e9e7ed6f
2 changed files with 10 additions and 5 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue