Vanessa 2022-12-22 14:52:43 +08:00
parent 26e9c3a4c6
commit bcfbe9b897
3 changed files with 57 additions and 2 deletions

View file

@ -1,3 +1,44 @@
import {Dialog} from "../dialog";
import {fetchPost} from "../util/fetch";
import {isMobile} from "../util/functions";
export const openCard = () => {
let decksHTML = '<option value="">All</option>';
fetchPost("/api/riff/getRiffDecks", {}, (response) => {
response.data.forEach((deck:{id:string, name:string}) => {
decksHTML += `<option value="${deck.id}">${deck.name}</option>`;
})
fetchPost("/api/riff/getRiffDueCards", {deckID:""}, (cardsResponse) => {
const dialog = new Dialog({
title: window.siyuan.languages.riffCard,
content:`<div class="fn__flex-column">
<div class="fn__flex">
<select class="b3-select">${decksHTML}</select>
<span class="fn__space"></span>
<div>${cardsResponse.data}</div>
</div>
<div class="fn__flex-1" data-type="render"></div>
<div class="fn__flex">
<button class="b3-button">Again Rating</button>
<span class="fn__flex-1"></span>
<button class="b3-button">Hard</button>
<span class="fn__flex-1"></span>
<button class="b3-button">Good</button>
<span class="fn__flex-1"></span>
<button class="b3-button">Easy</button>
</div>
</div>`,
width: isMobile() ? "80vw" : "50vw",
height: "70vh",
})
dialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.riffCard.custom)
dialog.element.querySelector("select").addEventListener("change", (event) => {
})
})
})
}
export const matchCardKey = (event: KeyboardEvent) => {
}

View file

@ -43,7 +43,7 @@ import {editor} from "../config/editor";
import {hintMoveBlock} from "../protyle/hint/extend";
import {Backlink} from "../layout/dock/Backlink";
import {openHistory} from "../history/history";
import {openCard} from "../card/openCard";
import {matchCardKey, openCard} from "../card/openCard";
const getRightBlock = (element: HTMLElement, x: number, y: number) => {
let index = 1;
@ -343,6 +343,19 @@ export const globalShortcut = () => {
return;
}
if (!event.ctrlKey && !event.metaKey && !event.shiftKey && !event.altKey && event.key === "s") {
const openCardDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.riffCard.custom) {
return true;
}
});
if (openCardDialog) {
event.preventDefault();
matchCardKey(event);
return;
}
}
// 仅处理以下快捷键操作
if (!event.ctrlKey && !isCtrl(event) && event.key !== "Escape" && !event.shiftKey && !event.altKey &&
!/^F\d{1,2}$/.test(event.key) && event.key.indexOf("Arrow") === -1 && event.key !== "Enter" && event.key !== "Backspace" && event.key !== "Delete") {
@ -460,6 +473,7 @@ export const globalShortcut = () => {
return;
}
}
if (matchHotKey(window.siyuan.config.keymap.general.recentDocs.custom, event)) {
const openRecentDocsDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {

View file

@ -179,7 +179,7 @@ const initBar = () => {
<div id="barDailyNote" data-menu="true" aria-label="${window.siyuan.languages.dailyNote} ${updateHotkeyTip(window.siyuan.config.keymap.general.dailyNote.custom)}" class="toolbar__item b3-tooltips b3-tooltips__se${window.siyuan.config.readonly ? " fn__none" : ""}">
<svg><use xlink:href="#iconCalendar"></use></svg>
</div>
<div id="barRiffCard" data-menu="true" aria-label="${window.siyuan.languages.iconRiffCard} ${updateHotkeyTip(window.siyuan.config.keymap.general.iconRiffCard.custom)}" class="toolbar__item b3-tooltips b3-tooltips__se${window.siyuan.config.readonly ? " fn__none" : ""}">
<div id="barRiffCard" data-menu="true" aria-label="${window.siyuan.languages.riffCard} ${updateHotkeyTip(window.siyuan.config.keymap.general.riffCard.custom)}" class="toolbar__item b3-tooltips b3-tooltips__se${window.siyuan.config.readonly ? " fn__none" : ""}">
<svg><use xlink:href="#iconRiffCard"></use></svg>
</div>
<button id="barBack" data-menu="true" class="toolbar__item toolbar__item--disabled b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.languages.goBack} ${updateHotkeyTip(window.siyuan.config.keymap.general.goBack.custom)}">