This commit is contained in:
Vanessa 2023-06-01 20:50:49 +08:00
parent fd0893d8d8
commit 6806392b41
57 changed files with 271 additions and 360 deletions

View file

@ -147,7 +147,6 @@ export const bindCardEvent = (options: {
data: response,
protyle: editor.protyle,
action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML],
app: options.app
});
});
}
@ -168,7 +167,6 @@ export const bindCardEvent = (options: {
options.blocks = treeCards.data.cards;
if (options.blocks.length > 0) {
nextCard({
app: options.app,
countElement,
editor,
actionElements,
@ -342,7 +340,6 @@ export const bindCardEvent = (options: {
if (index > 0) {
index--;
nextCard({
app: options.app,
countElement,
editor,
actionElements,
@ -386,7 +383,6 @@ export const bindCardEvent = (options: {
}
} else {
nextCard({
app: options.app,
countElement,
editor,
actionElements,
@ -398,7 +394,6 @@ export const bindCardEvent = (options: {
return;
}
nextCard({
app: options.app,
countElement,
editor,
actionElements,
@ -458,8 +453,11 @@ export const openCardByData = (app: App, cardsData: {
};
const nextCard = (options: {
app: App,
countElement: Element, editor: Protyle, actionElements: NodeListOf<Element>, index: number, blocks: ICard[]
countElement: Element,
editor: Protyle,
actionElements: NodeListOf<Element>,
index: number,
blocks: ICard[]
}) => {
options.editor.protyle.element.classList.add("card__block--hide");
if (window.siyuan.config.flashcard.superBlock) {
@ -491,7 +489,6 @@ const nextCard = (options: {
data: response,
protyle: options.editor.protyle,
action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML],
app: options.app
});
});
};

View file

@ -68,7 +68,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
if (window.siyuan.config.editor.readOnly) {
disabledProtyle(edit.protyle);
}
getArticle(app, edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));
getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));
}
const previousElement = dialog.element.querySelector('[data-type="previous"]');
const nextElement = dialog.element.querySelector('[data-type="next"]');
@ -93,7 +93,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
if (currentRect.top < parentRect.top || currentRect.bottom > parentRect.bottom) {
currentElement.scrollIntoView(currentRect.top < parentRect.top);
}
getArticle(app, edit, currentElement.getAttribute("data-id"));
getArticle(edit, currentElement.getAttribute("data-id"));
currentElement.classList.add("b3-list-item--focus");
}
event.stopPropagation();
@ -125,7 +125,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
nextElement.nextElementSibling.nextElementSibling.textContent = `${pageIndex}/${cardsResponse.data.pageCount || 1}`;
listElement.innerHTML = renderViewItem(cardsResponse.data.blocks, title, deckType);
listElement.scrollTop = 0;
getArticle(app, edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));
getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));
});
event.stopPropagation();
event.preventDefault();
@ -145,13 +145,13 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
nextElement.nextElementSibling.nextElementSibling.textContent = `${pageIndex}/${cardsResponse.data.pageCount || 1}`;
listElement.innerHTML = renderViewItem(cardsResponse.data.blocks, title, deckType);
listElement.scrollTop = 0;
getArticle(app, edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));
getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id"));
});
event.stopPropagation();
event.preventDefault();
break;
} else if (type === "card-item") {
getArticle(app, edit, target.getAttribute("data-id"));
getArticle(edit, target.getAttribute("data-id"));
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
target.classList.add("b3-list-item--focus");
event.stopPropagation();
@ -171,10 +171,10 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
}
if (!nextElment) {
getArticle(app, edit, "");
getArticle(edit, "");
listElement.innerHTML = `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`;
} else {
getArticle(app, edit, nextElment.getAttribute("data-id"));
getArticle(edit, nextElment.getAttribute("data-id"));
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
nextElment.classList.add("b3-list-item--focus");
target.parentElement.remove();
@ -240,7 +240,7 @@ ${unicode2Emoji(item.ial.icon, false, "b3-list-item__graphic", true)}
};
const getArticle = (app: App, edit: Protyle, id: string) => {
const getArticle = (edit: Protyle, id: string) => {
if (!id) {
edit.protyle.element.classList.add("fn__none");
edit.protyle.element.nextElementSibling.classList.remove("fn__none");
@ -256,7 +256,7 @@ const getArticle = (app: App, edit: Protyle, id: string) => {
size: Constants.SIZE_GET_MAX,
}, getResponse => {
onGet({
data: getResponse, protyle: edit.protyle, action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML], app
data: getResponse, protyle: edit.protyle, action: [Constants.CB_GET_ALL, Constants.CB_GET_HTML]
});
});
};