mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Merge remote-tracking branch 'upstream/HEAD' into apkg
This commit is contained in:
commit
f0cc027db6
7 changed files with 16 additions and 7 deletions
|
@ -853,6 +853,12 @@ class Collection(DeprecatedNamesMixin):
|
||||||
return CollectionStats(self)
|
return CollectionStats(self)
|
||||||
|
|
||||||
def card_stats_data(self, card_id: CardId) -> stats_pb2.CardStatsResponse:
|
def card_stats_data(self, card_id: CardId) -> stats_pb2.CardStatsResponse:
|
||||||
|
"""Returns the data required to show card stats.
|
||||||
|
|
||||||
|
If you wish to display the stats in a HTML table like Anki does,
|
||||||
|
you can use the .js file directly - see this add-on for an example:
|
||||||
|
https://ankiweb.net/shared/info/2179254157
|
||||||
|
"""
|
||||||
return self._backend.card_stats(card_id)
|
return self._backend.card_stats(card_id)
|
||||||
|
|
||||||
def studied_today(self) -> str:
|
def studied_today(self) -> str:
|
||||||
|
|
|
@ -39,7 +39,7 @@ def _legacy_card_stats(
|
||||||
if ({1 if _legacy_nightmode else 0}) {{
|
if ({1 if _legacy_nightmode else 0}) {{
|
||||||
document.documentElement.className = "night-mode";
|
document.documentElement.className = "night-mode";
|
||||||
}}
|
}}
|
||||||
const {varName} = anki.cardInfo(document.getElementById('{random_id}'));
|
const {varName} = anki.setupCardInfo(document.getElementById('{random_id}'));
|
||||||
{varName}.then((c) => c.$set({{ cardId: {card_id}, includeRevlog: {str(include_revlog).lower()} }}));
|
{varName}.then((c) => c.$set({{ cardId: {card_id}, includeRevlog: {str(include_revlog).lower()} }}));
|
||||||
</script>
|
</script>
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -353,6 +353,7 @@ class Browser(QMainWindow):
|
||||||
|
|
||||||
self._lastSearchTxt = search
|
self._lastSearchTxt = search
|
||||||
prompt = search if prompt == None else prompt
|
prompt = search if prompt == None else prompt
|
||||||
|
self.form.searchEdit.setCurrentIndex(-1)
|
||||||
self.form.searchEdit.lineEdit().setText(prompt)
|
self.form.searchEdit.lineEdit().setText(prompt)
|
||||||
self.search()
|
self.search()
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ class CardInfoDialog(QDialog):
|
||||||
layout.addWidget(buttons)
|
layout.addWidget(buttons)
|
||||||
qconnect(buttons.rejected, self.reject)
|
qconnect(buttons.rejected, self.reject)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
self.web.eval("anki.cardInfoPromise = anki.setupCardInfo(document.body);")
|
||||||
self.update_card(card_id)
|
self.update_card(card_id)
|
||||||
|
|
||||||
def update_card(self, card_id: CardId | None) -> None:
|
def update_card(self, card_id: CardId | None) -> None:
|
||||||
|
|
|
@ -1343,7 +1343,7 @@ class EditorWebView(AnkiWebView):
|
||||||
return
|
return
|
||||||
html = mime.html()
|
html = mime.html()
|
||||||
mime.setHtml(f"<!--anki-->{html}")
|
mime.setHtml(f"<!--anki-->{html}")
|
||||||
clip.setMimeData(mime)
|
aqt.mw.progress.timer(10, lambda: clip.setMimeData(mime), False, parent=self)
|
||||||
|
|
||||||
def contextMenuEvent(self, evt: QContextMenuEvent) -> None:
|
def contextMenuEvent(self, evt: QContextMenuEvent) -> None:
|
||||||
m = QMenu(self)
|
m = QMenu(self)
|
||||||
|
|
|
@ -41,6 +41,7 @@ impl Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schedule_as_review(&mut self, interval: u32, due: i32, ease_factor: u16) {
|
fn schedule_as_review(&mut self, interval: u32, due: i32, ease_factor: u16) {
|
||||||
|
self.original_position = self.last_position();
|
||||||
self.remove_from_filtered_deck_before_reschedule();
|
self.remove_from_filtered_deck_before_reschedule();
|
||||||
self.interval = interval.max(1);
|
self.interval = interval.max(1);
|
||||||
self.due = due;
|
self.due = due;
|
||||||
|
|
|
@ -11,17 +11,17 @@ const i18n = setupI18n({
|
||||||
modules: [ModuleName.CARD_STATS, ModuleName.SCHEDULING, ModuleName.STATISTICS],
|
modules: [ModuleName.CARD_STATS, ModuleName.SCHEDULING, ModuleName.STATISTICS],
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function setupCardInfo(): Promise<CardInfo> {
|
export async function setupCardInfo(target: HTMLElement): Promise<CardInfo> {
|
||||||
checkNightMode();
|
checkNightMode();
|
||||||
await i18n;
|
await i18n;
|
||||||
|
|
||||||
return new CardInfo({ target: document.body, props: { includeRevlog: true } });
|
return new CardInfo({ target, props: {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cardInfoPromise = setupCardInfo();
|
|
||||||
|
|
||||||
if (window.location.hash.startsWith("#test")) {
|
if (window.location.hash.startsWith("#test")) {
|
||||||
// use #testXXXX where XXXX is card ID to test
|
// use #testXXXX where XXXX is card ID to test
|
||||||
const cardId = parseInt(window.location.hash.substr("#test".length), 10);
|
const cardId = parseInt(window.location.hash.substr("#test".length), 10);
|
||||||
cardInfoPromise.then((cardInfo: CardInfo): void => cardInfo.$set({ cardId }));
|
setupCardInfo(document.body).then((cardInfo: CardInfo): void =>
|
||||||
|
cardInfo.$set({ cardId }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue