From 9ccb1f173e13d29e44d4b8e4e551d4bea623d760 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 12 Sep 2024 22:07:32 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/12073 --- app/src/protyle/gutter/index.ts | 16 ++++++ app/src/protyle/wysiwyg/keydown.ts | 79 +++++++++++++++++------------- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 9656aca82..c43026a18 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -989,6 +989,14 @@ export class Gutter { selectsElement: [nodeElement], type: "Blocks2Ps", })); + turnIntoSubmenu.push(this.turnsIntoOne({ + icon: "iconQuote", + accelerator: window.siyuan.config.keymap.editor.insert.quote.custom, + label: window.siyuan.languages.quote, + protyle, + selectsElement: [nodeElement], + type: "Blocks2Blockquote" + })); if (subType !== "h1") { turnIntoSubmenu.push(this.turnsInto({ icon: "iconH1", @@ -1065,6 +1073,14 @@ export class Gutter { id, type: "CancelList" })); + turnIntoSubmenu.push(this.turnsIntoOne({ + icon: "iconQuote", + accelerator: window.siyuan.config.keymap.editor.insert.quote.custom, + label: window.siyuan.languages.quote, + protyle, + selectsElement: [nodeElement], + type: "Blocks2Blockquote" + })); if (nodeElement.getAttribute("data-subtype") === "o") { turnIntoSubmenu.push(this.turnsOneInto({ icon: "iconList", diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 300db6126..ba646b6b4 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1387,45 +1387,58 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (isMatchList || isMatchOList || isMatchCheck || isMatchQuote) { const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")); if (selectsElement.length === 0) { - protyle.hint.splitChar = "/"; - protyle.hint.lastIndex = -1; - if (isMatchQuote) { - protyle.hint.fill(">" + Lute.Caret, protyle); - } else { - protyle.hint.fill((isMatchCheck ? "* [ ] " : (isMatchList ? "* " : "1. ")) + Lute.Caret, protyle); - } - } else if (selectsElement.length === 1) { + selectsElement.push(nodeElement); + } + if (selectsElement.length === 1) { const subType = selectsElement[0].dataset.subtype; const type = selectsElement[0].dataset.type; - if (type === "NodeParagraph") { - turnsIntoOneTransaction({ - protyle, - selectsElement, - type: isMatchQuote ? "Blocks2Blockquote" : (isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs")) - }); - } else if (type === "NodeList") { - const id = selectsElement[0].dataset.nodeId; - if (subType === "o" && (isMatchList || isMatchCheck)) { - turnsOneInto({ + if (isMatchQuote) { + if (["NodeHeading", "NodeParagraph", "NodeList"].includes(type)) { + turnsIntoOneTransaction({ protyle, - nodeElement: selectsElement[0], - id, - type: isMatchCheck ? "UL2TL" : "OL2UL", + selectsElement, + type: "Blocks2Blockquote" }); - } else if (subType === "t" && (isMatchList || isMatchOList)) { - turnsOneInto({ + } else { + protyle.hint.splitChar = "/"; + protyle.hint.lastIndex = -1; + protyle.hint.fill(">" + Lute.Caret, protyle); + } + } else { + if (type === "NodeParagraph") { + turnsIntoOneTransaction({ protyle, - nodeElement: selectsElement[0], - id, - type: isMatchList ? "TL2UL" : "TL2OL", - }); - } else if (isMatchCheck || isMatchOList) { - turnsOneInto({ - protyle, - nodeElement: selectsElement[0], - id, - type: isMatchCheck ? "OL2TL" : "UL2OL", + selectsElement, + type: isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs") }); + } else if (type === "NodeList") { + const id = selectsElement[0].dataset.nodeId; + if (subType === "o" && (isMatchList || isMatchCheck)) { + turnsOneInto({ + protyle, + nodeElement: selectsElement[0], + id, + type: isMatchCheck ? "UL2TL" : "OL2UL", + }); + } else if (subType === "t" && (isMatchList || isMatchOList)) { + turnsOneInto({ + protyle, + nodeElement: selectsElement[0], + id, + type: isMatchList ? "TL2UL" : "TL2OL", + }); + } else if (isMatchCheck || isMatchOList) { + turnsOneInto({ + protyle, + nodeElement: selectsElement[0], + id, + type: isMatchCheck ? "OL2TL" : "UL2OL", + }); + } + } else { + protyle.hint.splitChar = "/"; + protyle.hint.lastIndex = -1; + protyle.hint.fill((isMatchCheck ? "* [ ] " : (isMatchList ? "* " : "1. ")) + Lute.Caret, protyle); } } } else {