diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 7170b20af..16b66579f 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -1035,6 +1035,7 @@ export class Gutter { turnIntoSubmenu.push(this.turnsOneInto({ icon: "iconParagraph", label: window.siyuan.languages.paragraph, + accelerator: window.siyuan.config.keymap.editor.heading.paragraph.custom, protyle, nodeElement, id, @@ -1102,6 +1103,7 @@ export class Gutter { turnIntoSubmenu.push(this.turnsOneInto({ icon: "iconParagraph", label: window.siyuan.languages.paragraph, + accelerator: window.siyuan.config.keymap.editor.heading.paragraph.custom, protyle, nodeElement, id, diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 0d19d50af..f7fec9375 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1182,11 +1182,40 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { // h1 - h6 hotkey if (matchHotKey(window.siyuan.config.keymap.editor.heading.paragraph.custom, event)) { - turnsIntoTransaction({ - protyle, - nodeElement, - type: "Blocks2Ps", - }); + const selectsElement = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")) + if (selectsElement.length === 0) { + selectsElement.push(nodeElement); + } + if (selectsElement.length > 1) { + turnsIntoTransaction({ + protyle, + nodeElement: selectsElement[0], + type: "Blocks2Ps", + }); + } else { + const type = selectsElement[0].getAttribute("data-type"); + if (type === "NodeHeading") { + turnsIntoTransaction({ + protyle, + nodeElement: selectsElement[0], + type: "Blocks2Ps", + }); + } else if (type === "NodeList") { + turnsOneInto({ + protyle, + nodeElement: selectsElement[0], + id: selectsElement[0].getAttribute("data-node-id"), + type: "CancelList", + }); + } else if (type === "NodeBlockquote") { + turnsOneInto({ + protyle, + nodeElement: selectsElement[0], + id: selectsElement[0].getAttribute("data-node-id"), + type: "CancelBlockquote", + }); + } + } event.preventDefault(); event.stopPropagation(); return true;