This commit is contained in:
Vanessa 2022-07-20 22:06:06 +08:00
parent c624c9f60c
commit 0317de0f9f
2 changed files with 12 additions and 10 deletions

View file

@ -416,19 +416,23 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
range.selectNodeContents(element.firstElementChild);
setRange = true;
} else if (type === "NodeBlockQueryEmbed") {
if (element.lastElementChild.previousElementSibling) {
range.selectNodeContents(element.lastElementChild.previousElementSibling);
if (element.lastElementChild.previousElementSibling?.firstChild) {
range.selectNodeContents(element.lastElementChild.previousElementSibling.firstChild);
range.collapse(true);
} else {
// https://github.com/siyuan-note/siyuan/issues/5267
range.selectNodeContents(element);
range.collapse(true);
}
setRange = true;
} else if (["NodeMathBlock", "NodeHTMLBlock"].includes(type)) {
if (element.lastElementChild.previousElementSibling?.lastElementChild) {
if (element.lastElementChild.previousElementSibling?.lastElementChild?.firstChild) {
// https://ld246.com/article/1655714737572
range.selectNodeContents(element.lastElementChild.previousElementSibling.lastElementChild);
range.selectNodeContents(element.lastElementChild.previousElementSibling.lastElementChild.firstChild);
range.collapse(true);
} else if (element.lastElementChild.previousElementSibling) {
range.selectNodeContents(element.lastElementChild.previousElementSibling);
range.collapse(true);
}
setRange = true;
} else if (type === "NodeIFrame" || type === "NodeWidget") {
@ -442,6 +446,7 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
setRange = true;
} else if (type === "NodeCodeBlock") {
range.selectNodeContents(element);
range.collapse(true);
setRange = true;
}
if (setRange) {

View file

@ -1,4 +1,4 @@
import {focusBlock, focusSideBlock, focusByWbr, focusByRange} from "../util/selection";
import {focusBlock, focusSideBlock, focusByWbr} from "../util/selection";
import {
getContenteditableElement,
getLastBlock,
@ -14,7 +14,6 @@ import {setFold, zoomOut} from "../../menus/protyle";
import {preventScroll} from "../scroll/preventScroll";
import {hideElements} from "../ui/hideElements";
import {Constants} from "../../constants";
import {countBlockWord} from "../../layout/status";
const removeLi = (protyle: IProtyle, blockElement: Element, range: Range) => {
if (!blockElement.parentElement.previousElementSibling && blockElement.parentElement.nextElementSibling && blockElement.parentElement.nextElementSibling.classList.contains("protyle-attr")) {
@ -412,10 +411,8 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
}
return;
}
previousLastElement.classList.add("protyle-wysiwyg--select");
countBlockWord([previousId]);
if (previousLastElement.getAttribute("data-type") === "NodeBlockQueryEmbed" || editableElement.textContent !== "") {
focusByRange(range);
focusBlock(previousLastElement, undefined, false);
if (editableElement.textContent !== "") {
return;
}
}