mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-26 08:54:07 +01:00
This commit is contained in:
parent
327c3aaabb
commit
f8d1d1958b
4 changed files with 46 additions and 8 deletions
|
|
@ -9,7 +9,7 @@ import {lineNumberRender} from "../render/highlightRender";
|
|||
import {hideMessage, showMessage} from "../../dialog/message";
|
||||
import {genUUID} from "../../util/genID";
|
||||
import {getContenteditableElement, getLastBlock} from "../wysiwyg/getBlock";
|
||||
import {genEmptyElement} from "../../block/util";
|
||||
import {genEmptyElement, genHeadingElement} from "../../block/util";
|
||||
import {transaction} from "../wysiwyg/transaction";
|
||||
import {focusByRange} from "../util/selection";
|
||||
/// #if !MOBILE
|
||||
|
|
@ -137,16 +137,22 @@ export const initUI = (protyle: IProtyle) => {
|
|||
return;
|
||||
}
|
||||
}
|
||||
const lastRect = protyle.wysiwyg.element.lastElementChild.getBoundingClientRect();
|
||||
const lastElement = protyle.wysiwyg.element.lastElementChild;
|
||||
const lastRect = lastElement.getBoundingClientRect();
|
||||
const range = document.createRange();
|
||||
if (event.y > lastRect.bottom) {
|
||||
const lastEditElement = getContenteditableElement(getLastBlock(protyle.wysiwyg.element.lastElementChild));
|
||||
const lastEditElement = getContenteditableElement(getLastBlock(lastElement));
|
||||
if (!protyle.options.click.preventInsetEmptyBlock && (
|
||||
!lastEditElement ||
|
||||
(protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") !== "NodeParagraph" && protyle.wysiwyg.element.getAttribute("data-doc-type") !== "NodeListItem") ||
|
||||
(protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") === "NodeParagraph" && getContenteditableElement(lastEditElement).innerHTML !== ""))
|
||||
(lastElement.getAttribute("data-type") !== "NodeParagraph" && protyle.wysiwyg.element.getAttribute("data-doc-type") !== "NodeListItem") ||
|
||||
(lastElement.getAttribute("data-type") === "NodeParagraph" && getContenteditableElement(lastEditElement).innerHTML !== ""))
|
||||
) {
|
||||
const emptyElement = genEmptyElement(false, false);
|
||||
let emptyElement:Element;
|
||||
if (lastElement.getAttribute("data-type") === "NodeHeading" && lastElement.getAttribute("fold") === "1") {
|
||||
emptyElement = genHeadingElement(lastElement) as Element;
|
||||
} else {
|
||||
emptyElement = genEmptyElement(false, false);
|
||||
}
|
||||
protyle.wysiwyg.element.insertAdjacentElement("beforeend", emptyElement);
|
||||
transaction(protyle, [{
|
||||
action: "insert",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue