2022-12-22 14:52:43 +08:00
|
|
|
|
import {Dialog} from "../dialog";
|
|
|
|
|
|
import {fetchPost} from "../util/fetch";
|
|
|
|
|
|
import {isMobile} from "../util/functions";
|
2022-12-22 15:37:21 +08:00
|
|
|
|
import {Protyle} from "../protyle";
|
|
|
|
|
|
import {Constants} from "../constants";
|
2023-09-12 10:22:04 +08:00
|
|
|
|
import {onGet} from "../protyle/util/onGet";
|
2023-04-03 19:50:25 +08:00
|
|
|
|
import {hasClosestByAttribute, hasClosestByClassName} from "../protyle/util/hasClosest";
|
2023-02-19 09:55:34 +08:00
|
|
|
|
import {hideElements} from "../protyle/ui/hideElements";
|
2024-01-01 23:07:40 +08:00
|
|
|
|
import {isPaidUser, needSubscribe} from "../util/needSubscribe";
|
2023-04-03 19:50:25 +08:00
|
|
|
|
import {fullscreen} from "../protyle/breadcrumb/action";
|
2023-04-14 12:03:11 +08:00
|
|
|
|
import {MenuItem} from "../menus/Menu";
|
|
|
|
|
|
import {escapeHtml} from "../util/escape";
|
2023-04-28 16:01:02 +08:00
|
|
|
|
/// #if !MOBILE
|
2023-04-28 22:08:57 +08:00
|
|
|
|
import {openFile} from "../editor/util";
|
2023-04-28 16:01:02 +08:00
|
|
|
|
/// #endif
|
2024-03-27 18:35:19 +08:00
|
|
|
|
/// #if !BROWSER
|
|
|
|
|
|
import {ipcRenderer} from "electron";
|
|
|
|
|
|
/// #endif
|
2024-03-15 09:31:18 +08:00
|
|
|
|
import * as dayjs from "dayjs";
|
2023-04-28 16:01:02 +08:00
|
|
|
|
import {getDisplayName, movePathTo} from "../util/pathName";
|
2023-05-18 19:27:21 +08:00
|
|
|
|
import {App} from "../index";
|
2023-09-14 09:56:13 +08:00
|
|
|
|
import {resize} from "../protyle/util/resize";
|
2023-10-23 11:35:44 +08:00
|
|
|
|
import {setStorageVal} from "../protyle/util/compatibility";
|
2024-01-06 14:56:30 +08:00
|
|
|
|
import {focusByRange} from "../protyle/util/selection";
|
2024-02-27 21:04:56 +08:00
|
|
|
|
import {updateCardHV} from "./util";
|
2024-03-14 22:01:09 +08:00
|
|
|
|
import {showMessage} from "../dialog/message";
|
|
|
|
|
|
import {Menu} from "../plugin/Menu";
|
|
|
|
|
|
import {transaction} from "../protyle/wysiwyg/transaction";
|
2022-12-22 14:52:43 +08:00
|
|
|
|
|
2024-03-14 22:01:09 +08:00
|
|
|
|
const genCardCount = (cardsData: ICardData, allIndex = 0) => {
|
|
|
|
|
|
let newIndex = 0;
|
|
|
|
|
|
let oldIndex = 0;
|
|
|
|
|
|
cardsData.cards.forEach((item, index) => {
|
|
|
|
|
|
if (index > allIndex) {
|
2024-03-15 20:46:39 +08:00
|
|
|
|
return;
|
2024-03-14 22:01:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (item.state === 0) {
|
|
|
|
|
|
newIndex++;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
oldIndex++;
|
|
|
|
|
|
}
|
2024-03-15 20:46:39 +08:00
|
|
|
|
});
|
2024-03-14 22:01:09 +08:00
|
|
|
|
return `<span class="ariaLabel" aria-label="${window.siyuan.languages.flashcardNewCard}">
|
|
|
|
|
|
<span class="ft__error">${newIndex}</span> /
|
|
|
|
|
|
<span class="ariaLabel ft__primary" aria-label="${window.siyuan.languages.flashcardNewCard}">${cardsData.unreviewedNewCardCount}</span>
|
|
|
|
|
|
</span>
|
2023-12-22 10:54:47 +08:00
|
|
|
|
<span class="fn__space"></span>+<span class="fn__space"></span>
|
2024-03-14 22:01:09 +08:00
|
|
|
|
<span class="ariaLabel" aria-label="${window.siyuan.languages.flashcardReviewCard}">
|
|
|
|
|
|
<span class="ft__error">${oldIndex}</span> /
|
|
|
|
|
|
<span class="ft__success">${cardsData.unreviewedOldCardCount}</span>
|
|
|
|
|
|
</span>`;
|
2023-12-25 21:31:32 +08:00
|
|
|
|
};
|
2023-12-22 10:25:55 +08:00
|
|
|
|
|
2023-04-27 20:03:00 +08:00
|
|
|
|
export const genCardHTML = (options: {
|
|
|
|
|
|
id: string,
|
|
|
|
|
|
cardType: TCardType,
|
2024-01-08 22:12:19 +08:00
|
|
|
|
cardsData: ICardData,
|
2023-04-27 20:03:00 +08:00
|
|
|
|
isTab: boolean
|
|
|
|
|
|
}) => {
|
2023-05-10 00:01:47 +08:00
|
|
|
|
let iconsHTML: string;
|
2023-04-28 16:01:02 +08:00
|
|
|
|
/// #if MOBILE
|
2023-05-10 00:01:47 +08:00
|
|
|
|
iconsHTML = `<div class="toolbar toolbar--border">
|
2023-04-28 16:01:02 +08:00
|
|
|
|
<svg class="toolbar__icon"><use xlink:href="#iconRiffCard"></use></svg>
|
|
|
|
|
|
<span class="fn__flex-1 fn__flex-center toolbar__text">${window.siyuan.languages.riffCard}</span>
|
2024-03-14 22:01:09 +08:00
|
|
|
|
<div data-type="count" class="${options.cardsData.cards.length === 0 ? "fn__none" : "fn__flex"}">${genCardCount(options.cardsData)}</span></div>
|
2023-04-28 16:01:02 +08:00
|
|
|
|
<svg class="toolbar__icon" data-id="${options.id || ""}" data-cardtype="${options.cardType}" data-type="filter"><use xlink:href="#iconFilter"></use></svg>
|
2024-03-17 11:16:48 +08:00
|
|
|
|
<svg class="toolbar__icon" data-type="more"><use xlink:href="#iconMore"></use></svg>
|
2023-04-28 16:01:02 +08:00
|
|
|
|
<svg class="toolbar__icon" data-type="close"><use xlink:href="#iconCloseRound"></use></svg>
|
|
|
|
|
|
</div>`;
|
|
|
|
|
|
/// #else
|
2023-05-10 00:01:47 +08:00
|
|
|
|
iconsHTML = `<div class="block__icons">
|
2024-01-11 11:03:34 +08:00
|
|
|
|
${options.isTab ? '<div class="fn__flex-1"></div>' : `<div class="block__logo">
|
2024-01-19 23:59:34 +08:00
|
|
|
|
<svg class="block__logoicon"><use xlink:href="#iconRiffCard"></use></svg>${window.siyuan.languages.riffCard}
|
2024-01-11 11:03:34 +08:00
|
|
|
|
</div>`}
|
|
|
|
|
|
<span class="fn__flex-1 resize__move" style="min-height: 100%"></span>
|
2024-03-14 22:01:09 +08:00
|
|
|
|
<div data-type="count" class="ft__on-surface ft__smaller fn__flex-center${options.cardsData.cards.length === 0 ? " fn__none" : " fn__flex"}">${genCardCount(options.cardsData)}</span></div>
|
2023-04-14 12:03:11 +08:00
|
|
|
|
<div class="fn__space"></div>
|
2024-01-12 20:08:57 +08:00
|
|
|
|
<button data-id="${options.id || ""}" data-cardtype="${options.cardType}" data-type="filter" class="block__icon block__icon--show">
|
2023-04-14 12:03:11 +08:00
|
|
|
|
<svg><use xlink:href="#iconFilter"></use></svg>
|
2024-01-12 20:08:57 +08:00
|
|
|
|
</button>
|
2023-04-08 22:02:47 +08:00
|
|
|
|
<div class="fn__space"></div>
|
2023-04-28 16:01:02 +08:00
|
|
|
|
<div data-type="fullscreen" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show" aria-label="${window.siyuan.languages.fullscreen}">
|
|
|
|
|
|
<svg><use xlink:href="#iconFullscreen"></use></svg>
|
|
|
|
|
|
</div>
|
2025-10-16 16:54:46 +08:00
|
|
|
|
<div class="fn__space${options.cardsData.cards.length === 0 ? " fn__none" : ""}"></div>
|
|
|
|
|
|
<div data-type="more" class="${options.cardsData.cards.length === 0 ? "fn__none " : ""}b3-tooltips b3-tooltips__sw block__icon block__icon--show" aria-label="${window.siyuan.languages.more}">
|
2024-03-14 22:01:09 +08:00
|
|
|
|
<svg><use xlink:href="#iconMore"></use></svg>
|
|
|
|
|
|
</div>
|
2023-04-28 16:01:02 +08:00
|
|
|
|
<div class="fn__space${options.isTab ? " fn__none" : ""}"></div>
|
2024-03-27 18:35:19 +08:00
|
|
|
|
<div data-type="sticktab" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show${options.isTab ? " fn__none" : ""}" aria-label="${window.siyuan.languages.openBy}">
|
|
|
|
|
|
<svg><use xlink:href="#iconOpen"></use></svg>
|
2023-04-28 16:01:02 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>`;
|
|
|
|
|
|
/// #endif
|
|
|
|
|
|
return `<div class="card__main">
|
|
|
|
|
|
${iconsHTML}
|
2024-11-21 12:31:00 +08:00
|
|
|
|
<div class="card__block fn__flex-1 ${options.cardsData.cards.length === 0 ? "fn__none" : ""}" data-type="render"></div>
|
2023-12-26 22:13:44 +08:00
|
|
|
|
<div class="card__empty card__empty--space${options.cardsData.cards.length === 0 ? "" : " fn__none"}" data-type="empty">
|
2023-02-19 00:20:18 +08:00
|
|
|
|
<div>🔮</div>
|
2023-02-19 00:05:38 +08:00
|
|
|
|
${window.siyuan.languages.noDueCard}
|
|
|
|
|
|
</div>
|
2024-11-29 09:16:18 +08:00
|
|
|
|
<div class="fn__flex card__action fn__none">
|
2023-02-26 11:34:30 +08:00
|
|
|
|
<button class="b3-button b3-button--cancel" disabled="disabled" data-type="-2" style="width: 25%;min-width: 86px;display: flex">
|
|
|
|
|
|
<svg><use xlink:href="#iconLeft"></use></svg>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
${!isMobile() ? "(p / q)" : ""}
|
2023-02-26 11:34:30 +08:00
|
|
|
|
</button>
|
|
|
|
|
|
<span class="fn__space"></span>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
<button data-type="-1" class="b3-button fn__flex-1">${window.siyuan.languages.cardShowAnswer}${!isMobile() ? " (" + window.siyuan.languages.space + " / " + window.siyuan.languages.enterKey + ")" : ""}</button>
|
2022-12-29 11:50:06 +08:00
|
|
|
|
</div>
|
2023-02-24 10:01:40 +08:00
|
|
|
|
<div class="fn__flex card__action fn__none">
|
2023-03-19 14:50:08 +08:00
|
|
|
|
<div>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
<button class="b3-button b3-button--cancel" disabled="disabled" style="display: flex;margin-bottom: 8px;height: 28px;padding: 0;" data-type="-2"><svg><use xlink:href="#iconLeft"></use></svg>${!isMobile() ? "(p / q)" : ""}</button>
|
2024-02-07 18:18:09 +08:00
|
|
|
|
<button data-type="-3" aria-label="0 / x" class="b3-button b3-button--cancel b3-tooltips__n b3-tooltips">
|
2024-02-27 21:04:56 +08:00
|
|
|
|
<div class="card__icon">💤</div>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
${window.siyuan.languages.skip}${!isMobile() ? " (0)" : ""}
|
2023-03-19 14:50:08 +08:00
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2022-12-29 15:30:10 +08:00
|
|
|
|
<div>
|
2022-12-29 15:44:57 +08:00
|
|
|
|
<span></span>
|
2024-02-07 18:18:09 +08:00
|
|
|
|
<button data-type="1" aria-label="1 / j / a" class="b3-button b3-button--error b3-tooltips__n b3-tooltips">
|
2024-02-27 21:04:56 +08:00
|
|
|
|
<div class="card__icon">🙈</div>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
${window.siyuan.languages.cardRatingAgain}${!isMobile() ? " (1)" : ""}
|
2023-02-24 09:32:39 +08:00
|
|
|
|
</button>
|
2022-12-29 15:30:10 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2022-12-29 15:44:57 +08:00
|
|
|
|
<span></span>
|
2024-02-07 18:18:09 +08:00
|
|
|
|
<button data-type="2" aria-label="2 / k / s" class="b3-button b3-button--warning b3-tooltips__n b3-tooltips">
|
2024-02-27 21:04:56 +08:00
|
|
|
|
<div class="card__icon">😬</div>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
${window.siyuan.languages.cardRatingHard}${!isMobile() ? " (2)" : ""}
|
2023-02-24 10:33:04 +08:00
|
|
|
|
</button>
|
2022-12-29 15:30:10 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2022-12-29 15:44:57 +08:00
|
|
|
|
<span></span>
|
2024-05-10 00:25:28 +08:00
|
|
|
|
<button data-type="3" aria-label="3 / l / d / ${window.siyuan.languages.space} / ${window.siyuan.languages.enterKey}" class="b3-button b3-button--info b3-tooltips__n b3-tooltips">
|
2024-02-27 21:04:56 +08:00
|
|
|
|
<div class="card__icon">😊</div>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
${window.siyuan.languages.cardRatingGood}${!isMobile() ? " (3)" : ""}
|
2023-02-24 10:33:04 +08:00
|
|
|
|
</button>
|
2022-12-29 15:30:10 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2022-12-29 15:44:57 +08:00
|
|
|
|
<span></span>
|
2024-02-07 18:18:09 +08:00
|
|
|
|
<button data-type="4" aria-label="4 / ; / f" class="b3-button b3-button--success b3-tooltips__n b3-tooltips">
|
2024-02-27 21:04:56 +08:00
|
|
|
|
<div class="card__icon">🌈</div>
|
2024-12-28 21:36:46 +08:00
|
|
|
|
${window.siyuan.languages.cardRatingEasy}${!isMobile() ? " (4)" : ""}
|
2023-02-24 10:33:04 +08:00
|
|
|
|
</button>
|
2022-12-29 15:30:10 +08:00
|
|
|
|
</div>
|
2022-12-22 14:52:43 +08:00
|
|
|
|
</div>
|
2023-04-27 20:03:00 +08:00
|
|
|
|
</div>`;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-11-21 12:31:00 +08:00
|
|
|
|
const getEditor = (id: string, protyle: IProtyle, element: Element, currentCard: ICard) => {
|
|
|
|
|
|
fetchPost("/api/block/getDocInfo", {
|
|
|
|
|
|
id,
|
2025-08-09 10:43:08 +08:00
|
|
|
|
}, (docResponse) => {
|
|
|
|
|
|
protyle.wysiwyg.renderCustom(docResponse.data.ial);
|
2024-11-21 12:31:00 +08:00
|
|
|
|
fetchPost("/api/filetree/getDoc", {
|
|
|
|
|
|
id,
|
|
|
|
|
|
mode: 0,
|
|
|
|
|
|
size: Constants.SIZE_GET_MAX
|
|
|
|
|
|
}, (response) => {
|
|
|
|
|
|
onGet({
|
|
|
|
|
|
updateReadonly: true,
|
|
|
|
|
|
data: response,
|
|
|
|
|
|
protyle,
|
2025-10-02 18:02:13 +08:00
|
|
|
|
action: response.data.rootID === response.data.id ? [] : [Constants.CB_GET_ALL],
|
2024-11-21 12:31:00 +08:00
|
|
|
|
afterCB: () => {
|
2025-10-19 10:18:56 +08:00
|
|
|
|
if (protyle.element.classList.contains("fn__none")) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-11-21 12:31:00 +08:00
|
|
|
|
let hasHide = false;
|
|
|
|
|
|
if (!window.siyuan.config.flashcard.superBlock &&
|
|
|
|
|
|
!window.siyuan.config.flashcard.heading &&
|
|
|
|
|
|
!window.siyuan.config.flashcard.list &&
|
|
|
|
|
|
!window.siyuan.config.flashcard.mark) {
|
|
|
|
|
|
hasHide = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (window.siyuan.config.flashcard.superBlock) {
|
|
|
|
|
|
if (protyle.wysiwyg.element.querySelector(":scope > .sb")) {
|
|
|
|
|
|
hasHide = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (window.siyuan.config.flashcard.heading) {
|
|
|
|
|
|
if (protyle.wysiwyg.element.querySelector(':scope > [data-type="NodeHeading"]')) {
|
|
|
|
|
|
hasHide = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (window.siyuan.config.flashcard.list) {
|
|
|
|
|
|
if (protyle.wysiwyg.element.querySelector(".list, .li")) {
|
|
|
|
|
|
hasHide = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (window.siyuan.config.flashcard.mark) {
|
|
|
|
|
|
if (protyle.wysiwyg.element.querySelector('span[data-type~="mark"]')) {
|
|
|
|
|
|
hasHide = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
const actionElements = element.querySelectorAll(".card__action");
|
|
|
|
|
|
if (!hasHide) {
|
|
|
|
|
|
protyle.element.classList.remove("card__block--hidemark", "card__block--hideli", "card__block--hidesb", "card__block--hideh");
|
|
|
|
|
|
actionElements[0].classList.add("fn__none");
|
|
|
|
|
|
actionElements[1].querySelectorAll("button.b3-button").forEach((element, btnIndex) => {
|
|
|
|
|
|
if (btnIndex < 2) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-08-09 10:43:08 +08:00
|
|
|
|
element.previousElementSibling.textContent = currentCard.nextDues[btnIndex - 1];
|
2024-11-21 12:31:00 +08:00
|
|
|
|
});
|
|
|
|
|
|
actionElements[1].classList.remove("fn__none");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (window.siyuan.config.flashcard.superBlock) {
|
|
|
|
|
|
protyle.element.classList.add("card__block--hidesb");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (window.siyuan.config.flashcard.heading) {
|
|
|
|
|
|
protyle.element.classList.add("card__block--hideh");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (window.siyuan.config.flashcard.list) {
|
|
|
|
|
|
protyle.element.classList.add("card__block--hideli");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (window.siyuan.config.flashcard.mark) {
|
|
|
|
|
|
protyle.element.classList.add("card__block--hidemark");
|
|
|
|
|
|
}
|
|
|
|
|
|
actionElements[0].classList.remove("fn__none");
|
|
|
|
|
|
actionElements[1].classList.add("fn__none");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-11-22 21:15:18 +08:00
|
|
|
|
};
|
2024-11-21 12:31:00 +08:00
|
|
|
|
|
2025-10-14 11:14:23 +08:00
|
|
|
|
export const bindCardEvent = async (options: {
|
2023-05-18 19:27:21 +08:00
|
|
|
|
app: App,
|
2023-04-28 10:30:27 +08:00
|
|
|
|
element: Element,
|
|
|
|
|
|
title?: string,
|
2024-01-08 22:12:19 +08:00
|
|
|
|
cardsData: ICardData
|
2023-04-28 10:30:27 +08:00
|
|
|
|
cardType: TCardType,
|
|
|
|
|
|
id?: string,
|
2023-04-28 12:02:08 +08:00
|
|
|
|
dialog?: Dialog,
|
2025-10-14 18:01:36 +08:00
|
|
|
|
index?: number,
|
2023-04-28 10:30:27 +08:00
|
|
|
|
}) => {
|
2023-10-23 11:35:44 +08:00
|
|
|
|
if (window.siyuan.storage[Constants.LOCAL_FLASHCARD].fullscreen) {
|
|
|
|
|
|
fullscreen(options.element.querySelector(".card__main"),
|
|
|
|
|
|
options.element.querySelector('[data-type="fullscreen"]'));
|
|
|
|
|
|
}
|
2023-04-27 20:03:00 +08:00
|
|
|
|
let index = 0;
|
2023-10-31 20:03:42 +08:00
|
|
|
|
if (typeof options.index === "number") {
|
2023-11-02 11:20:47 +08:00
|
|
|
|
index = options.index;
|
2023-10-31 20:03:42 +08:00
|
|
|
|
}
|
2023-05-18 19:27:21 +08:00
|
|
|
|
const editor = new Protyle(options.app, options.element.querySelector("[data-type='render']") as HTMLElement, {
|
2023-02-19 00:05:38 +08:00
|
|
|
|
blockId: "",
|
|
|
|
|
|
action: [Constants.CB_GET_ALL],
|
|
|
|
|
|
render: {
|
|
|
|
|
|
background: false,
|
|
|
|
|
|
gutter: true,
|
|
|
|
|
|
breadcrumbDocName: true,
|
2025-08-09 10:43:08 +08:00
|
|
|
|
title: true,
|
|
|
|
|
|
hideTitleOnZoom: true,
|
2023-02-19 00:05:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
typewriterMode: false
|
|
|
|
|
|
});
|
2023-04-12 14:46:17 +08:00
|
|
|
|
if (window.siyuan.mobile) {
|
|
|
|
|
|
window.siyuan.mobile.popEditor = editor;
|
|
|
|
|
|
}
|
2023-12-26 22:13:44 +08:00
|
|
|
|
if (options.cardsData.cards.length > 0) {
|
2024-11-21 12:31:00 +08:00
|
|
|
|
getEditor(options.cardsData.cards[index].blockID, editor.protyle, options.element, options.cardsData.cards[index]);
|
2023-02-19 00:05:38 +08:00
|
|
|
|
}
|
2023-12-22 12:30:12 +08:00
|
|
|
|
options.element.setAttribute("data-key", Constants.DIALOG_OPENCARD);
|
2023-04-28 10:30:27 +08:00
|
|
|
|
const actionElements = options.element.querySelectorAll(".card__action");
|
2024-11-16 10:04:13 +08:00
|
|
|
|
if (options.index === 0 || typeof options.index === "undefined") {
|
2023-12-22 11:30:51 +08:00
|
|
|
|
actionElements[0].firstElementChild.setAttribute("disabled", "disabled");
|
2024-11-21 12:31:00 +08:00
|
|
|
|
actionElements[1].querySelector(".b3-button").setAttribute("disabled", "disabled");
|
2023-12-22 11:30:51 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
actionElements[0].firstElementChild.removeAttribute("disabled");
|
2024-11-21 12:31:00 +08:00
|
|
|
|
actionElements[1].querySelector(".b3-button").removeAttribute("disabled");
|
2023-12-22 11:30:51 +08:00
|
|
|
|
}
|
2024-03-14 22:01:09 +08:00
|
|
|
|
const countElement = options.element.querySelector('[data-type="count"]');
|
2023-04-28 10:30:27 +08:00
|
|
|
|
const filterElement = options.element.querySelector('[data-type="filter"]');
|
2023-04-14 12:03:11 +08:00
|
|
|
|
const fetchNewRound = () => {
|
2023-04-14 22:42:21 +08:00
|
|
|
|
const currentCardType = filterElement.getAttribute("data-cardtype");
|
2024-03-17 11:16:48 +08:00
|
|
|
|
const docId = filterElement.getAttribute("data-id");
|
2023-04-14 12:03:11 +08:00
|
|
|
|
fetchPost(currentCardType === "all" ? "/api/riff/getRiffDueCards" :
|
|
|
|
|
|
(currentCardType === "doc" ? "/api/riff/getTreeRiffDueCards" : "/api/riff/getNotebookRiffDueCards"), {
|
2024-03-17 09:28:33 +08:00
|
|
|
|
rootID: docId,
|
|
|
|
|
|
deckID: docId,
|
|
|
|
|
|
notebook: docId,
|
2024-01-08 22:12:19 +08:00
|
|
|
|
}, async (treeCards) => {
|
2023-04-14 12:03:11 +08:00
|
|
|
|
index = 0;
|
2023-12-25 00:34:16 +08:00
|
|
|
|
options.cardsData = treeCards.data;
|
2024-01-08 22:12:19 +08:00
|
|
|
|
for (let i = 0; i < options.app.plugins.length; i++) {
|
|
|
|
|
|
options.cardsData = await options.app.plugins[i].updateCards(options.cardsData);
|
|
|
|
|
|
}
|
2023-12-26 22:13:44 +08:00
|
|
|
|
if (options.cardsData.cards.length > 0) {
|
2023-04-14 12:03:11 +08:00
|
|
|
|
nextCard({
|
|
|
|
|
|
countElement,
|
|
|
|
|
|
editor,
|
|
|
|
|
|
actionElements,
|
|
|
|
|
|
index,
|
2024-02-05 22:03:43 +08:00
|
|
|
|
cardsData: options.cardsData
|
2023-04-14 12:03:11 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
allDone(countElement, editor, actionElements);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-04-14 22:42:21 +08:00
|
|
|
|
};
|
2023-04-14 12:03:11 +08:00
|
|
|
|
|
2024-03-17 11:16:48 +08:00
|
|
|
|
countElement.innerHTML = genCardCount(options.cardsData, index);
|
2025-10-14 18:01:36 +08:00
|
|
|
|
options.element.firstChild.addEventListener("click", (event: MouseEvent) => {
|
2023-04-12 09:26:19 +08:00
|
|
|
|
const target = event.target as HTMLElement;
|
2023-02-19 00:05:38 +08:00
|
|
|
|
let type = "";
|
2024-03-15 20:46:39 +08:00
|
|
|
|
const currentCard = options.cardsData.cards[index];
|
2024-03-17 11:16:48 +08:00
|
|
|
|
const docId = filterElement.getAttribute("data-id");
|
2023-02-19 00:05:38 +08:00
|
|
|
|
if (typeof event.detail === "string") {
|
2024-02-07 18:18:09 +08:00
|
|
|
|
if (["1", "j", "a"].includes(event.detail)) {
|
2023-02-19 00:05:38 +08:00
|
|
|
|
type = "1";
|
2024-02-07 18:18:09 +08:00
|
|
|
|
} else if (["2", "k", "s"].includes(event.detail)) {
|
2023-02-19 00:05:38 +08:00
|
|
|
|
type = "2";
|
2024-02-07 18:18:09 +08:00
|
|
|
|
} else if (["3", "l", "d"].includes(event.detail)) {
|
2023-02-19 00:05:38 +08:00
|
|
|
|
type = "3";
|
2024-02-07 18:18:09 +08:00
|
|
|
|
} else if (["4", ";", "f"].includes(event.detail)) {
|
2023-08-01 18:21:00 +08:00
|
|
|
|
type = "4";
|
2024-02-07 18:18:09 +08:00
|
|
|
|
} else if ([" ", "enter"].includes(event.detail)) {
|
2023-02-19 00:05:38 +08:00
|
|
|
|
type = "-1";
|
2024-02-07 18:18:09 +08:00
|
|
|
|
} else if (["p", "q"].includes(event.detail)) {
|
2023-02-26 11:34:30 +08:00
|
|
|
|
type = "-2";
|
2024-02-07 18:18:09 +08:00
|
|
|
|
} else if (["0", "x"].includes(event.detail)) {
|
2023-03-19 14:50:08 +08:00
|
|
|
|
type = "-3";
|
2023-02-19 00:05:38 +08:00
|
|
|
|
}
|
2023-04-12 09:26:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
const fullscreenElement = hasClosestByAttribute(target, "data-type", "fullscreen");
|
|
|
|
|
|
if (fullscreenElement) {
|
2023-04-28 10:30:27 +08:00
|
|
|
|
fullscreen(options.element.querySelector(".card__main"),
|
|
|
|
|
|
options.element.querySelector('[data-type="fullscreen"]'));
|
2023-09-14 09:56:13 +08:00
|
|
|
|
resize(editor.protyle);
|
2023-10-24 10:42:04 +08:00
|
|
|
|
window.siyuan.storage[Constants.LOCAL_FLASHCARD].fullscreen = !window.siyuan.storage[Constants.LOCAL_FLASHCARD].fullscreen;
|
2023-10-31 20:03:42 +08:00
|
|
|
|
setStorageVal(Constants.LOCAL_FLASHCARD, window.siyuan.storage[Constants.LOCAL_FLASHCARD]);
|
2023-04-12 09:26:19 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-03-14 22:06:20 +08:00
|
|
|
|
const moreElement = hasClosestByAttribute(target, "data-type", "more");
|
2025-10-14 18:13:45 +08:00
|
|
|
|
if (moreElement && currentCard) {
|
2024-03-14 22:06:20 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
2024-03-17 22:30:30 +08:00
|
|
|
|
if (filterElement.getAttribute("data-cardtype") === "all" && filterElement.getAttribute("data-id")) {
|
2024-03-14 22:06:20 +08:00
|
|
|
|
showMessage(window.siyuan.languages.noSupportTip);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const menu = new Menu();
|
|
|
|
|
|
menu.addItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "setDueTime",
|
2024-03-14 22:06:20 +08:00
|
|
|
|
icon: "iconClock",
|
2024-03-17 11:16:48 +08:00
|
|
|
|
label: window.siyuan.languages.setDueTime,
|
2024-03-14 22:06:20 +08:00
|
|
|
|
click() {
|
2024-03-17 11:48:41 +08:00
|
|
|
|
const timedialog = new Dialog({
|
2024-03-17 11:16:48 +08:00
|
|
|
|
title: window.siyuan.languages.setDueTime,
|
|
|
|
|
|
content: `<div class="b3-dialog__content">
|
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.showCardDay}</div>
|
|
|
|
|
|
<div class="fn__hr"></div>
|
|
|
|
|
|
<input class="b3-text-field fn__block" value="1" type="number" step="1" min="1">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="b3-dialog__action">
|
|
|
|
|
|
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
|
|
|
|
|
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
|
|
|
|
|
</div>`,
|
|
|
|
|
|
width: isMobile() ? "92vw" : "520px",
|
|
|
|
|
|
});
|
2024-03-17 11:48:41 +08:00
|
|
|
|
const inputElement = timedialog.element.querySelector("input") as HTMLInputElement;
|
|
|
|
|
|
const btnsElement = timedialog.element.querySelectorAll(".b3-button");
|
|
|
|
|
|
timedialog.bindInput(inputElement, () => {
|
2024-03-17 11:16:48 +08:00
|
|
|
|
(btnsElement[1] as HTMLButtonElement).click();
|
|
|
|
|
|
});
|
|
|
|
|
|
inputElement.focus();
|
|
|
|
|
|
inputElement.select();
|
|
|
|
|
|
btnsElement[0].addEventListener("click", () => {
|
2024-03-17 11:48:41 +08:00
|
|
|
|
timedialog.destroy();
|
2024-03-17 11:16:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
btnsElement[1].addEventListener("click", () => {
|
|
|
|
|
|
fetchPost("/api/riff/batchSetRiffCardsDueTime", {
|
|
|
|
|
|
cardDues: [{
|
2024-03-17 11:48:41 +08:00
|
|
|
|
id: currentCard.cardID,
|
2024-10-12 12:34:59 +08:00
|
|
|
|
due: dayjs().add(parseInt(inputElement.value), "day").format("YYYYMMDDHHmmss")
|
2024-03-17 11:16:48 +08:00
|
|
|
|
}]
|
|
|
|
|
|
}, () => {
|
|
|
|
|
|
actionElements[0].classList.add("fn__none");
|
|
|
|
|
|
actionElements[1].classList.remove("fn__none");
|
|
|
|
|
|
if (currentCard.state === 0) {
|
|
|
|
|
|
options.cardsData.unreviewedNewCardCount--;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
options.cardsData.unreviewedOldCardCount--;
|
|
|
|
|
|
}
|
2025-11-11 10:45:31 +08:00
|
|
|
|
options.element.firstElementChild.dispatchEvent(new CustomEvent("click", {detail: "0"}));
|
2024-03-17 11:16:48 +08:00
|
|
|
|
options.cardsData.cards.splice(index, 1);
|
|
|
|
|
|
index--;
|
2024-03-17 11:48:41 +08:00
|
|
|
|
timedialog.destroy();
|
2024-03-17 11:16:48 +08:00
|
|
|
|
});
|
2024-03-17 09:28:33 +08:00
|
|
|
|
});
|
2024-03-14 22:06:20 +08:00
|
|
|
|
}
|
2024-03-15 20:46:39 +08:00
|
|
|
|
});
|
2024-03-17 11:16:48 +08:00
|
|
|
|
if (currentCard.state !== 0) {
|
|
|
|
|
|
menu.addItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "reset",
|
2024-03-17 11:16:48 +08:00
|
|
|
|
icon: "iconRefresh",
|
|
|
|
|
|
label: window.siyuan.languages.reset,
|
|
|
|
|
|
click() {
|
|
|
|
|
|
fetchPost("/api/riff/resetRiffCards", {
|
|
|
|
|
|
type: filterElement.getAttribute("data-cardtype"),
|
|
|
|
|
|
id: docId,
|
|
|
|
|
|
deckID: Constants.QUICK_DECK_ID,
|
|
|
|
|
|
blockIDs: [currentCard.blockID],
|
|
|
|
|
|
}, () => {
|
2024-03-19 08:26:16 +08:00
|
|
|
|
const minLang = window.siyuan.languages._time["1m"].replace("%s", "");
|
2024-03-17 11:16:48 +08:00
|
|
|
|
currentCard.lapses = 0;
|
|
|
|
|
|
currentCard.lastReview = -62135596800000;
|
|
|
|
|
|
currentCard.reps = 0;
|
|
|
|
|
|
currentCard.state = 0;
|
|
|
|
|
|
currentCard.nextDues = {
|
|
|
|
|
|
1: minLang,
|
|
|
|
|
|
2: minLang.replace("1", "5"),
|
|
|
|
|
|
3: minLang.replace("1", "10"),
|
|
|
|
|
|
4: window.siyuan.languages._time["1d"].replace("%s", "").replace("1", "6")
|
|
|
|
|
|
};
|
2024-11-21 12:31:00 +08:00
|
|
|
|
actionElements[1].querySelectorAll("button.b3-button").forEach((element, btnIndex) => {
|
|
|
|
|
|
if (btnIndex < 2) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-08-09 10:43:08 +08:00
|
|
|
|
element.previousElementSibling.textContent = currentCard.nextDues[btnIndex - 1];
|
2024-03-17 11:16:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
options.cardsData.unreviewedOldCardCount--;
|
|
|
|
|
|
options.cardsData.unreviewedNewCardCount++;
|
|
|
|
|
|
countElement.innerHTML = genCardCount(options.cardsData, index);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-03-14 22:06:20 +08:00
|
|
|
|
menu.addItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "removeRiffCard",
|
2024-03-14 22:06:20 +08:00
|
|
|
|
icon: "iconTrashcan",
|
|
|
|
|
|
label: `${window.siyuan.languages.remove} <b>${window.siyuan.languages.riffCard}</b>`,
|
|
|
|
|
|
click() {
|
|
|
|
|
|
actionElements[0].classList.add("fn__none");
|
|
|
|
|
|
actionElements[1].classList.remove("fn__none");
|
2024-03-15 09:31:18 +08:00
|
|
|
|
if (currentCard.state === 0) {
|
2024-03-14 22:06:20 +08:00
|
|
|
|
options.cardsData.unreviewedNewCardCount--;
|
2024-03-15 09:31:18 +08:00
|
|
|
|
} else {
|
2024-03-14 22:06:20 +08:00
|
|
|
|
options.cardsData.unreviewedOldCardCount--;
|
|
|
|
|
|
}
|
2025-11-11 10:45:31 +08:00
|
|
|
|
options.element.firstElementChild.dispatchEvent(new CustomEvent("click", {detail: "0"}));
|
2024-03-14 22:06:20 +08:00
|
|
|
|
transaction(undefined, [{
|
|
|
|
|
|
action: "removeFlashcards",
|
|
|
|
|
|
deckID: Constants.QUICK_DECK_ID,
|
2024-03-15 09:31:18 +08:00
|
|
|
|
blockIDs: [currentCard.blockID]
|
2024-03-14 22:06:20 +08:00
|
|
|
|
}]);
|
|
|
|
|
|
options.cardsData.cards.splice(index, 1);
|
|
|
|
|
|
index--;
|
|
|
|
|
|
}
|
2024-03-15 20:46:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
menu.addSeparator();
|
2024-03-15 09:31:18 +08:00
|
|
|
|
menu.addItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "forgetCountAndRevisionCountAndCardStatusAndLastReviewTime",
|
2024-03-15 09:31:18 +08:00
|
|
|
|
iconHTML: "",
|
|
|
|
|
|
type: "readonly",
|
|
|
|
|
|
label: `<div class="fn__flex">
|
2024-03-25 17:34:13 +08:00
|
|
|
|
<div class="fn__flex-1 ft__breakword">${window.siyuan.languages.forgetCount}</div>
|
2024-03-15 09:31:18 +08:00
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
|
<div>${currentCard.lapses}</div>
|
2024-03-17 11:16:48 +08:00
|
|
|
|
</div><div class="fn__flex">
|
2024-03-25 17:34:13 +08:00
|
|
|
|
<div class="fn__flex-1 ft__breakword">${window.siyuan.languages.revisionCount}</div>
|
2024-03-15 09:31:18 +08:00
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
|
<div>${currentCard.reps}</div>
|
2024-03-17 11:16:48 +08:00
|
|
|
|
</div><div class="fn__flex">
|
2024-03-25 17:34:13 +08:00
|
|
|
|
<div class="fn__flex-1 ft__breakword">${window.siyuan.languages.cardStatus}</div>
|
2024-03-15 09:31:18 +08:00
|
|
|
|
<div class="fn__space"></div>
|
2024-03-17 11:16:48 +08:00
|
|
|
|
<div class="${currentCard.state === 0 ? "ft__primary" : "ft__success"}">${currentCard.state === 0 ? window.siyuan.languages.flashcardNewCard : window.siyuan.languages.flashcardReviewCard}</div>
|
2024-03-17 23:21:39 +08:00
|
|
|
|
</div><div class="fn__flex${currentCard.lastReview > 0 ? "" : " fn__none"}">
|
2024-03-25 17:34:13 +08:00
|
|
|
|
<div class="fn__flex-1 ft__breakword" style="width: 170px;">${window.siyuan.languages.lastReviewTime}</div>
|
2024-03-17 23:21:39 +08:00
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
|
<div>${dayjs(currentCard.lastReview).format("YYYY-MM-DD")}</div>
|
2024-03-15 09:31:18 +08:00
|
|
|
|
</div>`,
|
2024-03-15 20:46:39 +08:00
|
|
|
|
});
|
2024-03-17 11:16:48 +08:00
|
|
|
|
/// #if MOBILE
|
|
|
|
|
|
menu.fullscreen();
|
|
|
|
|
|
/// #else
|
2024-03-27 18:35:19 +08:00
|
|
|
|
const rect = moreElement.getBoundingClientRect();
|
2024-03-14 22:06:20 +08:00
|
|
|
|
menu.open({
|
|
|
|
|
|
x: rect.left,
|
|
|
|
|
|
y: rect.bottom
|
|
|
|
|
|
});
|
2024-03-17 11:16:48 +08:00
|
|
|
|
/// #endif
|
2024-03-14 22:06:20 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-04-28 16:01:02 +08:00
|
|
|
|
/// #if !MOBILE
|
2023-04-27 20:03:00 +08:00
|
|
|
|
const sticktabElement = hasClosestByAttribute(target, "data-type", "sticktab");
|
|
|
|
|
|
if (sticktabElement) {
|
2024-03-27 18:35:19 +08:00
|
|
|
|
const stickMenu = new Menu();
|
2025-10-14 09:46:23 +08:00
|
|
|
|
stickMenu.addItem({
|
|
|
|
|
|
id: "openInNewTab",
|
|
|
|
|
|
icon: "iconOpen",
|
|
|
|
|
|
label: window.siyuan.languages.openInNewTab,
|
|
|
|
|
|
click() {
|
|
|
|
|
|
openFile({
|
|
|
|
|
|
app: options.app,
|
|
|
|
|
|
custom: {
|
|
|
|
|
|
icon: "iconRiffCard",
|
|
|
|
|
|
title: window.siyuan.languages.spaceRepetition,
|
|
|
|
|
|
data: {
|
|
|
|
|
|
cardsData: options.cardsData,
|
|
|
|
|
|
index,
|
|
|
|
|
|
cardType: filterElement.getAttribute("data-cardtype") as TCardType,
|
|
|
|
|
|
id: docId,
|
|
|
|
|
|
title: options.title
|
|
|
|
|
|
},
|
|
|
|
|
|
id: "siyuan-card"
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
options.dialog.destroy();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2024-03-27 18:35:19 +08:00
|
|
|
|
stickMenu.addItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "insertRight",
|
2024-03-27 18:35:19 +08:00
|
|
|
|
icon: "iconLayoutRight",
|
|
|
|
|
|
label: window.siyuan.languages.insertRight,
|
|
|
|
|
|
click() {
|
|
|
|
|
|
openFile({
|
|
|
|
|
|
app: options.app,
|
|
|
|
|
|
position: "right",
|
|
|
|
|
|
custom: {
|
|
|
|
|
|
icon: "iconRiffCard",
|
|
|
|
|
|
title: window.siyuan.languages.spaceRepetition,
|
|
|
|
|
|
data: {
|
|
|
|
|
|
cardsData: options.cardsData,
|
|
|
|
|
|
index,
|
|
|
|
|
|
cardType: filterElement.getAttribute("data-cardtype") as TCardType,
|
|
|
|
|
|
id: docId,
|
|
|
|
|
|
title: options.title
|
|
|
|
|
|
},
|
|
|
|
|
|
id: "siyuan-card"
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
options.dialog.destroy();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
/// #if !BROWSER
|
|
|
|
|
|
stickMenu.addItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "openByNewWindow",
|
2024-03-27 18:35:19 +08:00
|
|
|
|
icon: "iconOpenWindow",
|
|
|
|
|
|
label: window.siyuan.languages.openByNewWindow,
|
|
|
|
|
|
click() {
|
2024-10-25 20:30:43 +08:00
|
|
|
|
const json = [{
|
2024-03-27 18:35:19 +08:00
|
|
|
|
"title": window.siyuan.languages.spaceRepetition,
|
|
|
|
|
|
"icon": "iconRiffCard",
|
|
|
|
|
|
"instance": "Tab",
|
|
|
|
|
|
"children": {
|
|
|
|
|
|
"instance": "Custom",
|
|
|
|
|
|
"customModelType": "siyuan-card",
|
|
|
|
|
|
"customModelData": {
|
2025-10-14 09:46:23 +08:00
|
|
|
|
"cardsData": options.cardsData,
|
|
|
|
|
|
"index": index,
|
2024-03-27 18:35:19 +08:00
|
|
|
|
"cardType": filterElement.getAttribute("data-cardtype"),
|
|
|
|
|
|
"id": docId,
|
|
|
|
|
|
"title": options.title
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-10-25 20:30:43 +08:00
|
|
|
|
}];
|
2024-03-27 18:35:19 +08:00
|
|
|
|
ipcRenderer.send(Constants.SIYUAN_OPEN_WINDOW, {
|
|
|
|
|
|
// 需要 encode, 否则 https://github.com/siyuan-note/siyuan/issues/9343
|
|
|
|
|
|
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${encodeURIComponent(JSON.stringify(json))}`
|
|
|
|
|
|
});
|
|
|
|
|
|
options.dialog.destroy();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
/// #endif
|
|
|
|
|
|
const rect = sticktabElement.getBoundingClientRect();
|
|
|
|
|
|
stickMenu.open({
|
|
|
|
|
|
x: rect.left,
|
|
|
|
|
|
y: rect.bottom
|
2023-04-27 20:03:00 +08:00
|
|
|
|
});
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-04-28 16:01:02 +08:00
|
|
|
|
/// #endif
|
2023-04-12 09:26:19 +08:00
|
|
|
|
const closeElement = hasClosestByAttribute(target, "data-type", "close");
|
|
|
|
|
|
if (closeElement) {
|
2023-04-28 12:02:08 +08:00
|
|
|
|
if (options.dialog) {
|
|
|
|
|
|
options.dialog.destroy();
|
|
|
|
|
|
}
|
2023-04-12 09:26:19 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-04-14 12:03:11 +08:00
|
|
|
|
const filterTempElement = hasClosestByAttribute(target, "data-type", "filter");
|
|
|
|
|
|
if (filterTempElement) {
|
|
|
|
|
|
fetchPost("/api/riff/getRiffDecks", {}, (response) => {
|
|
|
|
|
|
window.siyuan.menus.menu.remove();
|
|
|
|
|
|
window.siyuan.menus.menu.append(new MenuItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "all",
|
2024-01-26 17:58:02 +08:00
|
|
|
|
iconHTML: "",
|
2023-04-14 12:03:11 +08:00
|
|
|
|
label: window.siyuan.languages.all,
|
|
|
|
|
|
click() {
|
2023-04-14 22:42:21 +08:00
|
|
|
|
filterElement.setAttribute("data-id", "");
|
|
|
|
|
|
filterElement.setAttribute("data-cardtype", "all");
|
|
|
|
|
|
fetchNewRound();
|
2023-04-14 12:03:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
}).element);
|
|
|
|
|
|
window.siyuan.menus.menu.append(new MenuItem({
|
2025-02-25 18:02:35 +08:00
|
|
|
|
id: "fileTree",
|
2024-01-26 17:58:02 +08:00
|
|
|
|
iconHTML: "",
|
2023-04-14 12:03:11 +08:00
|
|
|
|
label: window.siyuan.languages.fileTree,
|
|
|
|
|
|
click() {
|
2025-12-01 18:51:58 +08:00
|
|
|
|
movePathTo({
|
|
|
|
|
|
cb: (toPath, toNotebook) => {
|
|
|
|
|
|
filterElement.setAttribute("data-id", toPath[0] === "/" ? toNotebook[0] : getDisplayName(toPath[0], true, true));
|
|
|
|
|
|
filterElement.setAttribute("data-cardtype", toPath[0] === "/" ? "notebook" : "doc");
|
|
|
|
|
|
fetchNewRound();
|
|
|
|
|
|
},
|
|
|
|
|
|
title: window.siyuan.languages.specifyPath,
|
|
|
|
|
|
flashcard: true
|
|
|
|
|
|
});
|
2023-04-14 12:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).element);
|
2023-04-28 10:30:27 +08:00
|
|
|
|
if (options.title || response.data.length > 0) {
|
2023-04-17 12:48:53 +08:00
|
|
|
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
|
|
|
|
|
}
|
2023-04-28 10:30:27 +08:00
|
|
|
|
if (options.title) {
|
2023-04-14 12:03:11 +08:00
|
|
|
|
window.siyuan.menus.menu.append(new MenuItem({
|
2024-01-26 17:58:02 +08:00
|
|
|
|
iconHTML: "",
|
2023-04-28 10:30:27 +08:00
|
|
|
|
label: escapeHtml(options.title),
|
2023-04-14 12:03:11 +08:00
|
|
|
|
click() {
|
2023-04-28 10:30:27 +08:00
|
|
|
|
filterElement.setAttribute("data-id", options.id);
|
|
|
|
|
|
filterElement.setAttribute("data-cardtype", options.cardType);
|
2023-04-14 22:42:21 +08:00
|
|
|
|
fetchNewRound();
|
2023-04-14 12:03:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
}).element);
|
2024-03-05 21:38:47 +08:00
|
|
|
|
if (response.data.length > 0) {
|
|
|
|
|
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
|
|
|
|
|
}
|
2023-04-14 12:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
response.data.forEach((deck: { id: string, name: string }) => {
|
|
|
|
|
|
window.siyuan.menus.menu.append(new MenuItem({
|
2024-01-26 17:58:02 +08:00
|
|
|
|
iconHTML: "",
|
2023-04-14 12:03:11 +08:00
|
|
|
|
label: escapeHtml(deck.name),
|
|
|
|
|
|
click() {
|
2023-04-14 22:42:21 +08:00
|
|
|
|
filterElement.setAttribute("data-id", deck.id);
|
|
|
|
|
|
filterElement.setAttribute("data-cardtype", "all");
|
|
|
|
|
|
fetchNewRound();
|
2023-04-14 12:03:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
}).element);
|
2023-04-12 09:26:19 +08:00
|
|
|
|
});
|
2023-04-14 22:42:21 +08:00
|
|
|
|
const filterRect = filterTempElement.getBoundingClientRect();
|
2023-04-14 12:03:11 +08:00
|
|
|
|
window.siyuan.menus.menu.popup({x: filterRect.left, y: filterRect.bottom});
|
2023-04-12 14:48:01 +08:00
|
|
|
|
});
|
2023-04-12 09:26:19 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-04-14 12:03:11 +08:00
|
|
|
|
|
|
|
|
|
|
const newroundElement = hasClosestByAttribute(target, "data-type", "newround");
|
|
|
|
|
|
if (newroundElement) {
|
|
|
|
|
|
fetchNewRound();
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-02-19 00:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!type) {
|
2023-04-12 09:26:19 +08:00
|
|
|
|
const buttonElement = hasClosestByClassName(target, "b3-button");
|
2023-02-19 00:05:38 +08:00
|
|
|
|
if (buttonElement) {
|
|
|
|
|
|
type = buttonElement.getAttribute("data-type");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-15 09:31:18 +08:00
|
|
|
|
if (!type || !currentCard) {
|
2023-02-19 00:05:38 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
event.stopPropagation();
|
2023-12-22 11:30:51 +08:00
|
|
|
|
hideElements(["toolbar", "hint", "util", "gutter"], editor.protyle);
|
2023-03-24 20:54:02 +08:00
|
|
|
|
if (type === "-1") { // 显示答案
|
2023-02-26 11:45:50 +08:00
|
|
|
|
if (actionElements[0].classList.contains("fn__none")) {
|
2023-12-17 16:24:11 +08:00
|
|
|
|
type = "3";
|
2023-12-15 09:25:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
editor.protyle.element.classList.remove("card__block--hidemark", "card__block--hideli", "card__block--hidesb", "card__block--hideh");
|
|
|
|
|
|
actionElements[0].classList.add("fn__none");
|
2024-11-21 12:31:00 +08:00
|
|
|
|
actionElements[1].querySelectorAll("button.b3-button").forEach((element, btnIndex) => {
|
|
|
|
|
|
if (btnIndex < 2) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-08-09 10:43:08 +08:00
|
|
|
|
element.previousElementSibling.textContent = currentCard.nextDues[btnIndex - 1];
|
2023-12-15 09:25:52 +08:00
|
|
|
|
});
|
|
|
|
|
|
actionElements[1].classList.remove("fn__none");
|
2024-03-15 09:31:18 +08:00
|
|
|
|
emitEvent(options.app, currentCard, type);
|
2023-02-26 11:45:50 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-12-15 09:25:52 +08:00
|
|
|
|
} else if (type === "-2") { // 上一步
|
2023-02-26 11:34:30 +08:00
|
|
|
|
if (index > 0) {
|
|
|
|
|
|
index--;
|
|
|
|
|
|
nextCard({
|
|
|
|
|
|
countElement,
|
|
|
|
|
|
editor,
|
|
|
|
|
|
actionElements,
|
|
|
|
|
|
index,
|
2024-02-05 22:03:43 +08:00
|
|
|
|
cardsData: options.cardsData
|
2023-02-26 11:45:50 +08:00
|
|
|
|
});
|
2024-02-08 10:58:03 +08:00
|
|
|
|
emitEvent(options.app, options.cardsData.cards[index + 1], type);
|
2023-02-26 11:34:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-07-28 18:52:45 +08:00
|
|
|
|
if (["1", "2", "3", "4", "-3"].includes(type) && actionElements[0].classList.contains("fn__none")) {
|
2023-03-19 14:50:08 +08:00
|
|
|
|
fetchPost(type === "-3" ? "/api/riff/skipReviewRiffCard" : "/api/riff/reviewRiffCard", {
|
2024-03-15 09:31:18 +08:00
|
|
|
|
deckID: currentCard.deckID,
|
|
|
|
|
|
cardID: currentCard.cardID,
|
2023-03-22 14:32:29 +08:00
|
|
|
|
rating: parseInt(type),
|
2023-12-22 10:25:55 +08:00
|
|
|
|
reviewedCards: options.cardsData.cards
|
2023-02-19 00:05:38 +08:00
|
|
|
|
}, () => {
|
2023-03-08 22:39:09 +08:00
|
|
|
|
/// #if MOBILE
|
2023-03-19 14:50:08 +08:00
|
|
|
|
if (type !== "-3" &&
|
2024-01-01 23:07:40 +08:00
|
|
|
|
((0 !== window.siyuan.config.sync.provider && isPaidUser()) ||
|
2023-07-21 17:20:34 +08:00
|
|
|
|
(0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
|
2023-03-08 22:39:09 +08:00
|
|
|
|
window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) {
|
|
|
|
|
|
document.getElementById("toolbarSync").classList.remove("fn__none");
|
|
|
|
|
|
}
|
|
|
|
|
|
/// #endif
|
2023-02-19 00:05:38 +08:00
|
|
|
|
index++;
|
2023-12-26 22:13:44 +08:00
|
|
|
|
if (index > options.cardsData.cards.length - 1) {
|
2023-04-14 22:42:21 +08:00
|
|
|
|
const currentCardType = filterElement.getAttribute("data-cardtype");
|
2023-04-14 12:03:11 +08:00
|
|
|
|
fetchPost(currentCardType === "all" ? "/api/riff/getRiffDueCards" :
|
|
|
|
|
|
(currentCardType === "doc" ? "/api/riff/getTreeRiffDueCards" : "/api/riff/getNotebookRiffDueCards"), {
|
2024-03-17 09:28:33 +08:00
|
|
|
|
rootID: docId,
|
|
|
|
|
|
deckID: docId,
|
|
|
|
|
|
notebook: docId,
|
2023-12-22 10:25:55 +08:00
|
|
|
|
reviewedCards: options.cardsData.cards
|
2024-01-08 22:12:19 +08:00
|
|
|
|
}, async (result) => {
|
2024-02-08 10:58:03 +08:00
|
|
|
|
emitEvent(options.app, options.cardsData.cards[index - 1], type);
|
2023-02-26 11:45:50 +08:00
|
|
|
|
index = 0;
|
2023-12-25 00:34:16 +08:00
|
|
|
|
options.cardsData = result.data;
|
2024-01-08 22:12:19 +08:00
|
|
|
|
for (let i = 0; i < options.app.plugins.length; i++) {
|
|
|
|
|
|
options.cardsData = await options.app.plugins[i].updateCards(options.cardsData);
|
|
|
|
|
|
}
|
2023-12-26 22:13:44 +08:00
|
|
|
|
if (options.cardsData.cards.length === 0) {
|
|
|
|
|
|
if (options.cardsData.unreviewedCount > 0) {
|
2023-04-12 10:01:08 +08:00
|
|
|
|
newRound(countElement, editor, actionElements, result.data.unreviewedCount);
|
2023-04-12 09:26:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
allDone(countElement, editor, actionElements);
|
|
|
|
|
|
}
|
2023-02-24 22:50:33 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
nextCard({
|
|
|
|
|
|
countElement,
|
|
|
|
|
|
editor,
|
|
|
|
|
|
actionElements,
|
|
|
|
|
|
index,
|
2024-02-05 22:03:43 +08:00
|
|
|
|
cardsData: options.cardsData
|
2023-02-26 11:45:50 +08:00
|
|
|
|
});
|
2023-02-24 22:50:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-02-19 00:05:38 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-02-24 22:50:33 +08:00
|
|
|
|
nextCard({
|
|
|
|
|
|
countElement,
|
|
|
|
|
|
editor,
|
|
|
|
|
|
actionElements,
|
|
|
|
|
|
index,
|
2024-02-05 22:03:43 +08:00
|
|
|
|
cardsData: options.cardsData
|
2023-02-26 11:45:50 +08:00
|
|
|
|
});
|
2024-02-08 10:58:03 +08:00
|
|
|
|
emitEvent(options.app, options.cardsData.cards[index - 1], type);
|
2022-12-22 15:37:21 +08:00
|
|
|
|
});
|
2023-02-19 00:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-04-28 10:30:27 +08:00
|
|
|
|
return editor;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-02-08 10:58:03 +08:00
|
|
|
|
const emitEvent = (app: App, card: ICard, type: string) => {
|
2024-02-06 14:03:32 +08:00
|
|
|
|
app.plugins.forEach(item => {
|
|
|
|
|
|
item.eventBus.emit("click-flashcard-action", {
|
|
|
|
|
|
type,
|
2024-02-08 10:58:03 +08:00
|
|
|
|
card
|
2024-02-06 14:03:32 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-05-18 19:27:21 +08:00
|
|
|
|
export const openCard = (app: App) => {
|
2024-07-05 21:00:21 +08:00
|
|
|
|
if (window.siyuan.config.readonly) {
|
2024-07-06 09:57:00 +08:00
|
|
|
|
return;
|
2024-07-05 21:00:21 +08:00
|
|
|
|
}
|
2023-04-28 10:30:27 +08:00
|
|
|
|
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
|
2023-05-18 19:27:21 +08:00
|
|
|
|
openCardByData(app, cardsResponse.data, "all");
|
2023-04-28 10:30:27 +08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-01-08 22:12:19 +08:00
|
|
|
|
export const openCardByData = async (app: App, cardsData: ICardData, cardType: TCardType, id?: string, title?: string) => {
|
2023-04-28 10:30:27 +08:00
|
|
|
|
const exit = window.siyuan.dialogs.find(item => {
|
2023-12-22 12:30:12 +08:00
|
|
|
|
if (item.element.getAttribute("data-key") === Constants.DIALOG_OPENCARD) {
|
2023-04-28 10:30:27 +08:00
|
|
|
|
item.destroy();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if (exit) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-01-19 17:55:02 +08:00
|
|
|
|
let lastRange: Range;
|
|
|
|
|
|
if (getSelection().rangeCount > 0) {
|
2024-01-20 23:05:01 +08:00
|
|
|
|
lastRange = getSelection().getRangeAt(0);
|
2024-01-19 17:55:02 +08:00
|
|
|
|
}
|
2024-02-05 22:31:21 +08:00
|
|
|
|
for (let i = 0; i < app.plugins.length; i++) {
|
|
|
|
|
|
cardsData = await app.plugins[i].updateCards(cardsData);
|
|
|
|
|
|
}
|
2023-04-28 10:30:27 +08:00
|
|
|
|
const dialog = new Dialog({
|
2023-12-22 13:09:44 +08:00
|
|
|
|
positionId: Constants.DIALOG_OPENCARD,
|
2023-12-22 10:25:55 +08:00
|
|
|
|
content: genCardHTML({id, cardType, cardsData, isTab: false}),
|
2023-12-22 13:09:44 +08:00
|
|
|
|
width: isMobile() ? "100vw" : "80vw",
|
|
|
|
|
|
height: isMobile() ? "100vh" : "70vh",
|
2023-04-28 10:30:27 +08:00
|
|
|
|
destroyCallback() {
|
|
|
|
|
|
if (editor) {
|
|
|
|
|
|
editor.destroy();
|
|
|
|
|
|
if (window.siyuan.mobile) {
|
|
|
|
|
|
window.siyuan.mobile.popEditor = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-19 17:55:02 +08:00
|
|
|
|
if (lastRange) {
|
2024-01-20 23:05:01 +08:00
|
|
|
|
focusByRange(lastRange);
|
2024-01-19 17:55:02 +08:00
|
|
|
|
}
|
2024-02-29 10:47:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
resizeCallback(type: string) {
|
|
|
|
|
|
if (type !== "d" && type !== "t" && editor) {
|
|
|
|
|
|
editor.resize();
|
|
|
|
|
|
}
|
2023-04-28 10:30:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-03-10 10:08:16 +08:00
|
|
|
|
(dialog.element.querySelector(".b3-dialog__scrim") as HTMLElement).style.backgroundColor = "var(--b3-theme-surface)";
|
2023-04-28 10:30:27 +08:00
|
|
|
|
(dialog.element.querySelector(".b3-dialog__container") as HTMLElement).style.maxWidth = "1024px";
|
2024-01-08 22:12:19 +08:00
|
|
|
|
const editor = await bindCardEvent({
|
2023-05-18 19:27:21 +08:00
|
|
|
|
app,
|
2023-04-28 10:30:27 +08:00
|
|
|
|
element: dialog.element,
|
2023-12-22 10:25:55 +08:00
|
|
|
|
cardsData,
|
2023-04-28 10:30:27 +08:00
|
|
|
|
title,
|
|
|
|
|
|
id,
|
|
|
|
|
|
cardType,
|
|
|
|
|
|
dialog
|
|
|
|
|
|
});
|
2024-02-29 10:47:49 +08:00
|
|
|
|
editor.resize();
|
2024-02-29 00:33:11 +08:00
|
|
|
|
dialog.editors = {
|
|
|
|
|
|
card: editor
|
|
|
|
|
|
};
|
2024-01-11 11:03:34 +08:00
|
|
|
|
/// #if !MOBILE
|
2024-01-12 20:08:57 +08:00
|
|
|
|
const focusElement = dialog.element.querySelector(".block__icons button.block__icon") as HTMLElement;
|
2024-01-06 14:56:30 +08:00
|
|
|
|
focusElement.focus();
|
2024-01-08 23:23:59 +08:00
|
|
|
|
const range = document.createRange();
|
|
|
|
|
|
range.selectNodeContents(focusElement);
|
2024-01-11 11:18:12 +08:00
|
|
|
|
range.collapse();
|
2024-01-06 14:56:30 +08:00
|
|
|
|
focusByRange(range);
|
2024-01-11 11:03:34 +08:00
|
|
|
|
/// #endif
|
2024-02-27 21:04:56 +08:00
|
|
|
|
updateCardHV();
|
2023-02-19 09:35:07 +08:00
|
|
|
|
};
|
2023-02-24 22:50:33 +08:00
|
|
|
|
|
|
|
|
|
|
const nextCard = (options: {
|
2023-06-01 20:50:49 +08:00
|
|
|
|
countElement: Element,
|
|
|
|
|
|
editor: Protyle,
|
|
|
|
|
|
actionElements: NodeListOf<Element>,
|
|
|
|
|
|
index: number,
|
2024-02-05 22:03:43 +08:00
|
|
|
|
cardsData: ICardData
|
2023-02-24 22:50:33 +08:00
|
|
|
|
}) => {
|
|
|
|
|
|
options.editor.protyle.element.classList.remove("fn__none");
|
|
|
|
|
|
options.editor.protyle.element.nextElementSibling.classList.add("fn__none");
|
2024-03-14 22:01:09 +08:00
|
|
|
|
options.countElement.innerHTML = genCardCount(options.cardsData, options.index);
|
2024-02-05 22:09:47 +08:00
|
|
|
|
options.countElement.classList.remove("fn__none");
|
2023-02-26 11:34:30 +08:00
|
|
|
|
if (options.index === 0) {
|
|
|
|
|
|
options.actionElements[0].firstElementChild.setAttribute("disabled", "disabled");
|
2024-11-21 12:31:00 +08:00
|
|
|
|
options.actionElements[1].querySelector(".b3-button").setAttribute("disabled", "disabled");
|
2023-02-26 11:45:50 +08:00
|
|
|
|
} else {
|
2023-02-26 11:34:30 +08:00
|
|
|
|
options.actionElements[0].firstElementChild.removeAttribute("disabled");
|
2024-11-21 12:31:00 +08:00
|
|
|
|
options.actionElements[1].querySelector(".b3-button").removeAttribute("disabled");
|
2023-02-26 11:34:30 +08:00
|
|
|
|
}
|
2024-11-21 12:31:00 +08:00
|
|
|
|
getEditor(options.cardsData.cards[options.index].blockID, options.editor.protyle,
|
|
|
|
|
|
hasClosestByAttribute(options.countElement, "data-key", Constants.DIALOG_OPENCARD) as HTMLElement,
|
|
|
|
|
|
options.cardsData.cards[options.index]);
|
2023-02-26 11:45:50 +08:00
|
|
|
|
};
|
2023-02-24 22:50:33 +08:00
|
|
|
|
|
|
|
|
|
|
const allDone = (countElement: Element, editor: Protyle, actionElements: NodeListOf<Element>) => {
|
2024-02-05 22:09:47 +08:00
|
|
|
|
countElement.classList.add("fn__none");
|
2023-02-24 22:50:33 +08:00
|
|
|
|
editor.protyle.element.classList.add("fn__none");
|
2023-04-12 14:48:01 +08:00
|
|
|
|
const emptyElement = editor.protyle.element.nextElementSibling;
|
|
|
|
|
|
emptyElement.innerHTML = `<div>🔮</div>${window.siyuan.languages.noDueCard}`;
|
2023-04-12 09:26:19 +08:00
|
|
|
|
emptyElement.classList.remove("fn__none");
|
2023-02-24 22:50:33 +08:00
|
|
|
|
actionElements[0].classList.add("fn__none");
|
|
|
|
|
|
actionElements[1].classList.add("fn__none");
|
2025-10-16 16:54:46 +08:00
|
|
|
|
const moreElement = countElement.parentElement.querySelector('[data-type="more"]');
|
|
|
|
|
|
moreElement.classList.add("fn__none");
|
|
|
|
|
|
moreElement.previousElementSibling.classList.add("fn__none");
|
2023-02-24 22:50:33 +08:00
|
|
|
|
};
|
2023-04-12 09:26:19 +08:00
|
|
|
|
|
2023-04-12 10:01:08 +08:00
|
|
|
|
const newRound = (countElement: Element, editor: Protyle, actionElements: NodeListOf<Element>, unreviewedCount: number) => {
|
2024-02-05 22:09:47 +08:00
|
|
|
|
countElement.classList.add("fn__none");
|
2023-04-12 09:26:19 +08:00
|
|
|
|
editor.protyle.element.classList.add("fn__none");
|
|
|
|
|
|
const emptyElement = editor.protyle.element.nextElementSibling;
|
2023-04-12 14:46:17 +08:00
|
|
|
|
emptyElement.innerHTML = `<div>♻️ </div>
|
|
|
|
|
|
<span>${window.siyuan.languages.continueReview2.replace("${count}", unreviewedCount)}</span>
|
|
|
|
|
|
<div class="fn__hr"></div>
|
2023-04-13 08:56:22 +08:00
|
|
|
|
<button data-type="newround" class="b3-button fn__size200">${window.siyuan.languages.continueReview1}</button>`;
|
2023-04-12 09:26:19 +08:00
|
|
|
|
emptyElement.classList.remove("fn__none");
|
|
|
|
|
|
actionElements[0].classList.add("fn__none");
|
|
|
|
|
|
actionElements[1].classList.add("fn__none");
|
2023-04-12 14:48:01 +08:00
|
|
|
|
};
|