Vanessa 2024-09-04 17:35:50 +08:00
parent 2d8152a137
commit c2dc8fd83c
4 changed files with 14 additions and 6 deletions

View file

@ -432,6 +432,7 @@ export abstract class Constants {
list: {default: "", custom: ""}, list: {default: "", custom: ""},
table: {default: "⌘O", custom: "⌘O"}, table: {default: "⌘O", custom: "⌘O"},
code: {default: "⇧⌘K", custom: "⇧⌘K"}, code: {default: "⇧⌘K", custom: "⇧⌘K"},
quote: {default: "", custom: ""},
clearInline: {default: "⌘\\", custom: "⌘\\"}, clearInline: {default: "⌘\\", custom: "⌘\\"},
}, },
heading: { heading: {

View file

@ -571,6 +571,7 @@ export class Gutter {
turnIntoSubmenu.push(this.turnsIntoOne({ turnIntoSubmenu.push(this.turnsIntoOne({
icon: "iconQuote", icon: "iconQuote",
label: window.siyuan.languages.quote, label: window.siyuan.languages.quote,
accelerator: window.siyuan.config.keymap.editor.insert.quote.custom,
protyle, protyle,
selectsElement, selectsElement,
type: "Blocks2Blockquote" type: "Blocks2Blockquote"
@ -917,6 +918,7 @@ export class Gutter {
})); }));
turnIntoSubmenu.push(this.turnsIntoOne({ turnIntoSubmenu.push(this.turnsIntoOne({
icon: "iconQuote", icon: "iconQuote",
accelerator: window.siyuan.config.keymap.editor.insert.quote.custom,
label: window.siyuan.languages.quote, label: window.siyuan.languages.quote,
protyle, protyle,
selectsElement: [nodeElement], selectsElement: [nodeElement],

View file

@ -51,7 +51,7 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
value: '<div data-type="NodeAttributeView" data-av-type="table"></div>', value: '<div data-type="NodeAttributeView" data-av-type="table"></div>',
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.database}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.database}</span></div>`,
}, { }, {
filter: ["新建文档并引用", "xinjianwendangbingyinyong","xjwdbyy", "new doc"], filter: ["新建文档并引用", "xinjianwendangbingyinyong", "xjwdbyy", "new doc"],
value: Constants.ZWSP + 4, value: Constants.ZWSP + 4,
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newFileRef}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newFileRef}</span></div>`,
}, { }, {
@ -100,7 +100,7 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
}, { }, {
filter: ["引述", "yinshu", "ys", "bq", "blockquote"], filter: ["引述", "yinshu", "ys", "bq", "blockquote"],
value: "> " + Lute.Caret, value: "> " + Lute.Caret,
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconQuote"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.quote}</span><span class="b3-list-item__meta">&gt;</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconQuote"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.quote}</span>${window.siyuan.config.keymap.editor.insert.quote.custom ? `<span class="b3-menu__accelerator">${updateHotkeyTip((window.siyuan.config.keymap.editor.insert.quote.custom))}</span>` : '<span class="b3-list-item__meta">&gt;</span>'}</div>`,
}, { }, {
filter: ["代码块", "daimakuai", "dmk", "code block"], filter: ["代码块", "daimakuai", "dmk", "code block"],
value: "```", value: "```",

View file

@ -1383,12 +1383,17 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const isMatchList = matchHotKey(window.siyuan.config.keymap.editor.insert.list.custom, event); const isMatchList = matchHotKey(window.siyuan.config.keymap.editor.insert.list.custom, event);
const isMatchCheck = matchHotKey(window.siyuan.config.keymap.editor.insert.check.custom, event); const isMatchCheck = matchHotKey(window.siyuan.config.keymap.editor.insert.check.custom, event);
const isMatchOList = matchHotKey(window.siyuan.config.keymap.editor.insert["ordered-list"].custom, event); const isMatchOList = matchHotKey(window.siyuan.config.keymap.editor.insert["ordered-list"].custom, event);
if (isMatchList || isMatchOList || isMatchCheck) { const isMatchQuote = matchHotKey(window.siyuan.config.keymap.editor.insert.quote.custom, event);
if (isMatchList || isMatchOList || isMatchCheck || isMatchQuote) {
const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")); const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
if (selectsElement.length === 0) { if (selectsElement.length === 0) {
protyle.hint.splitChar = "/"; protyle.hint.splitChar = "/";
protyle.hint.lastIndex = -1; protyle.hint.lastIndex = -1;
if (isMatchQuote) {
protyle.hint.fill(">" + Lute.Caret, protyle);
} else {
protyle.hint.fill((isMatchCheck ? "* [ ] " : (isMatchList ? "* " : "1. ")) + Lute.Caret, protyle); protyle.hint.fill((isMatchCheck ? "* [ ] " : (isMatchList ? "* " : "1. ")) + Lute.Caret, protyle);
}
} else if (selectsElement.length === 1) { } else if (selectsElement.length === 1) {
const subType = selectsElement[0].dataset.subtype; const subType = selectsElement[0].dataset.subtype;
const type = selectsElement[0].dataset.type; const type = selectsElement[0].dataset.type;
@ -1396,7 +1401,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
turnsIntoOneTransaction({ turnsIntoOneTransaction({
protyle, protyle,
selectsElement, selectsElement,
type: isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs") type: isMatchQuote ? "Blocks2Blockquote" : (isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs"))
}); });
} else if (type === "NodeList") { } else if (type === "NodeList") {
const id = selectsElement[0].dataset.nodeId; const id = selectsElement[0].dataset.nodeId;
@ -1443,7 +1448,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
turnsIntoOneTransaction({ turnsIntoOneTransaction({
protyle, protyle,
selectsElement, selectsElement,
type: isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs") type: isMatchQuote ? "Blocks2Blockquote" : (isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs"))
}); });
} }
} }