mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-29 12:58:48 +01:00
This commit is contained in:
parent
78014ecd75
commit
2274b0b8df
2 changed files with 36 additions and 5 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue