This commit is contained in:
parent
f6f358f1eb
commit
a5417ec301
1 changed files with 20 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
focusBlock,
|
||||
focusByRange,
|
||||
focusByRange, focusByWbr,
|
||||
getEditorRange,
|
||||
} from "../util/selection";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
|
@ -26,6 +26,8 @@ import {getNoContainerElement} from "../wysiwyg/getBlock";
|
|||
import {commonHotkey} from "../wysiwyg/commonHotkey";
|
||||
import {code160to32} from "../util/code160to32";
|
||||
import {deleteFile} from "../../editor/deleteFile";
|
||||
import {genEmptyElement} from "../../block/util";
|
||||
import {transaction} from "../wysiwyg/transaction";
|
||||
|
||||
export class Title {
|
||||
public element: HTMLElement;
|
||||
|
@ -80,7 +82,7 @@ export class Title {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (event.key === "ArrowDown" || event.key === "Enter") {
|
||||
if (event.key === "ArrowDown") {
|
||||
const noContainerElement = getNoContainerElement(protyle.wysiwyg.element.firstElementChild);
|
||||
// https://github.com/siyuan-note/siyuan/issues/4923
|
||||
if (noContainerElement) {
|
||||
|
@ -88,6 +90,22 @@ export class Title {
|
|||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
} else if (event.key === "Enter") {
|
||||
const newId = Lute.NewNodeID()
|
||||
const newElement = genEmptyElement(false, true, newId)
|
||||
protyle.wysiwyg.element.insertAdjacentElement("afterbegin", newElement);
|
||||
focusByWbr(newElement, protyle.toolbar.range || getEditorRange(newElement));
|
||||
transaction(protyle, [{
|
||||
action: "insert",
|
||||
data: newElement.outerHTML,
|
||||
id: newId,
|
||||
parentID: protyle.block.parentID
|
||||
}], [{
|
||||
action: "delete",
|
||||
id: newId,
|
||||
}]);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.attr.custom, event)) {
|
||||
fetchPost("/api/block/getDocInfo", {
|
||||
id: protyle.block.rootID
|
||||
|
|
Loading…
Add table
Reference in a new issue