From fc8b976ca8bd6dcdec58753e6e6d716582326f47 Mon Sep 17 00:00:00 2001 From: BlueGreenMagick Date: Mon, 9 May 2022 18:55:35 +0900 Subject: [PATCH 01/12] fix typo. Shortcut uses on:action not on:click (#1846) --- ts/deck-options/SaveButton.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/deck-options/SaveButton.svelte b/ts/deck-options/SaveButton.svelte index 6aa2ecea7..71cbb1da9 100644 --- a/ts/deck-options/SaveButton.svelte +++ b/ts/deck-options/SaveButton.svelte @@ -66,7 +66,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html tooltip={getPlatformString(saveKeyCombination)} --border-left-radius="5px">{tr.deckConfigSaveButton()} - save(false)} /> + save(false)} /> Date: Mon, 9 May 2022 12:00:20 +0200 Subject: [PATCH 02/12] Fix undisruptive formatting issues (#1848) * Skip unparsable pylib files with black This was causing black to return a non-zero code, preventing the subsequent isort from running. * Organise imports on save --- .vscode/settings.json | 3 +++ pylib/tests/run_format.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index cf1f836b8..5c8bfa763 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,8 @@ { "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, "files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, diff --git a/pylib/tests/run_format.py b/pylib/tests/run_format.py index ceaa67bc5..f6a676d68 100644 --- a/pylib/tests/run_format.py +++ b/pylib/tests/run_format.py @@ -39,7 +39,7 @@ if __name__ == "__main__": "anki", "tests", "tools", - "--exclude=_pb2|buildinfo|_gen", + "--exclude=_pb2|buildinfo|_gen|_backend/generated|fluent", ] + args, check=False, From 9d98c62d502d62983836051fd341d1b14bad83eb Mon Sep 17 00:00:00 2001 From: BlueGreenMagick Date: Tue, 10 May 2022 10:36:54 +0900 Subject: [PATCH 03/12] Fix when tooltip changes before tooltipObject is created (#1845) It can happen in TagWithTooltip.svelte when a tag is normalized beause of leading/trailing delimiter --- ts/components/WithTooltip.svelte | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ts/components/WithTooltip.svelte b/ts/components/WithTooltip.svelte index 8bafa1b76..6adbb7c11 100644 --- a/ts/components/WithTooltip.svelte +++ b/ts/components/WithTooltip.svelte @@ -43,9 +43,11 @@ let previousTooltip: string = tooltip; $: if (tooltip !== previousTooltip) { previousTooltip = tooltip; - const element: HTMLElement = tooltipObject["_element"]; - tooltipObject.dispose(); - createTooltip(element); + if (tooltipObject !== undefined) { + const element: HTMLElement = tooltipObject["_element"]; + tooltipObject.dispose(); + createTooltip(element); + } } From 1b48d3e3d1ffb03b700b11fb1348edd2895f641a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 10 May 2022 11:39:15 +1000 Subject: [PATCH 04/12] Mention eslint --fix in docs https://github.com/ankitects/anki/pull/1847#issuecomment-1120954217 --- docs/development.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/development.md b/docs/development.md index 96eec4b94..f5e7a2394 100644 --- a/docs/development.md +++ b/docs/development.md @@ -141,6 +141,13 @@ that's causing the problem, and then run bazel run //ts:format ``` +If you get complaints from eslint about unordered imports, run the following +line first, then run ts:format: + +``` +bazel run eslint -- --fix +``` + For other packages, change to the folder and run ``` From 68482d37a1d7b8bcf17581a9cca01536ef13f51a Mon Sep 17 00:00:00 2001 From: BlueGreenMagick Date: Tue, 10 May 2022 10:39:54 +0900 Subject: [PATCH 05/12] select all tags with Ctrl+A (#1847) --- ts/editor/tag-editor/TagEditor.svelte | 2 ++ ts/editor/tag-editor/TagInput.svelte | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ts/editor/tag-editor/TagEditor.svelte b/ts/editor/tag-editor/TagEditor.svelte index 527688f3d..8f41b753d 100644 --- a/ts/editor/tag-editor/TagEditor.svelte +++ b/ts/editor/tag-editor/TagEditor.svelte @@ -112,6 +112,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html function appendEmptyTag(): void { // used by tag badge and tag spacer + deselect(); const lastTag = tagTypes[tagTypes.length - 1]; if (!lastTag || lastTag.name.length > 0) { @@ -448,6 +449,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html splitTag(index, detail.start, detail.end)} on:tagadd={() => insertTagKeepFocus(index)} on:tagdelete={() => deleteTagAt(index)} + on:tagselectall={selectAllTags} on:tagjoinprevious={() => joinWithPreviousTag(index)} on:tagjoinnext={() => joinWithNextTag(index)} on:tagmoveprevious={() => moveToPreviousTag(index)} diff --git a/ts/editor/tag-editor/TagInput.svelte b/ts/editor/tag-editor/TagInput.svelte index a9f0f40d4..b9f7c1f32 100644 --- a/ts/editor/tag-editor/TagInput.svelte +++ b/ts/editor/tag-editor/TagInput.svelte @@ -5,6 +5,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html Date: Tue, 10 May 2022 04:44:44 +0300 Subject: [PATCH 06/12] Store rendered side in TemplateRenderContext (#1852) * Store rendered side in TemplateRenderContext * Move _question_side up with the other simple properties (dae) --- pylib/anki/template.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pylib/anki/template.py b/pylib/anki/template.py index ed63516b4..3c0267949 100644 --- a/pylib/anki/template.py +++ b/pylib/anki/template.py @@ -158,6 +158,7 @@ class TemplateRenderContext: self._fill_empty = fill_empty self._fields: dict | None = None self._latex_svg = False + self._question_side: bool = True if not notetype: self._note_type = note.note_type() else: @@ -167,6 +168,10 @@ class TemplateRenderContext: # hooks, you can insert it into this dictionary self.extra_state: dict[str, Any] = {} + @property + def question_side(self) -> bool: + return self._question_side + def col(self) -> anki.collection.Collection: return self._col @@ -226,9 +231,11 @@ class TemplateRenderContext: answer_av_tags=[], ) + self._question_side = True qtext = apply_custom_filters(partial.qnodes, self, front_side=None) qout = self.col()._backend.extract_av_tags(text=qtext, question_side=True) + self._question_side = False atext = apply_custom_filters(partial.anodes, self, front_side=qout.text) aout = self.col()._backend.extract_av_tags(text=atext, question_side=False) From 96d9539b9ddc8da97f5cc798264c5c506995e234 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 10 May 2022 03:45:41 +0200 Subject: [PATCH 07/12] Fix activeName updating wrongly when selecting previous tag from invalid tag (#1851) --- ts/editor/tag-editor/TagEditor.svelte | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ts/editor/tag-editor/TagEditor.svelte b/ts/editor/tag-editor/TagEditor.svelte index 8f41b753d..2fabe8bb1 100644 --- a/ts/editor/tag-editor/TagEditor.svelte +++ b/ts/editor/tag-editor/TagEditor.svelte @@ -220,6 +220,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html activeAfterBlur = index - 1; active = null; + activeInput.blur(); } async function moveToNextTag(index: number): Promise { @@ -233,6 +234,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html activeAfterBlur = index + 1; active = null; + activeInput.blur(); await tick(); activeInput.setSelectionRange(0, 0); From 6043d2f5a29eabcdfc8258d9bafc1ca21b1b5399 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 10 May 2022 03:48:11 +0200 Subject: [PATCH 08/12] Set editor size to 1.6 on Windows as well (#1853) --- ts/editor/NoteEditor.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ts/editor/NoteEditor.svelte b/ts/editor/NoteEditor.svelte index 9f5cce9c2..754628b29 100644 --- a/ts/editor/NoteEditor.svelte +++ b/ts/editor/NoteEditor.svelte @@ -40,7 +40,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import Absolute from "../components/Absolute.svelte"; import Badge from "../components/Badge.svelte"; import { bridgeCommand } from "../lib/bridgecommand"; - import { isApplePlatform } from "../lib/platform"; import { ChangeTimer } from "./change-timer"; import DecoratedElements from "./DecoratedElements.svelte"; import { clearableArray } from "./destroyable"; @@ -70,7 +69,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html return fontFamily; } - const size = isApplePlatform() ? 1.6 : 1.8; + const size = 1.6; const wrap = true; const fieldStores: Writable[] = []; From 89530c5f24a8177de53123805dd2664e1ceae443 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 10 May 2022 03:54:06 +0200 Subject: [PATCH 09/12] Change sequence of Mathjax escaping (#1854) --- ts/editable/mathjax.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/editable/mathjax.ts b/ts/editable/mathjax.ts index 1c340d138..bbc4b8006 100644 --- a/ts/editable/mathjax.ts +++ b/ts/editable/mathjax.ts @@ -70,7 +70,7 @@ export function convertMathjax( * Escape characters which are technically legal in Mathjax, but confuse HTML. */ export function escapeSomeEntities(value: string): string { - return value.replace(//g, ">").replace(/&/g, "&"); + return value.replace(/&/g, "&").replace(//g, ">"); } export function unescapeSomeEntities(value: string): string { From 6c807c1b2ed1aa92420c08402659159f0ad58272 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Tue, 10 May 2022 04:11:35 +0200 Subject: [PATCH 10/12] Fix review queue if limit is reached (#1855) --- rslib/src/decks/limits.rs | 4 +++- rslib/src/scheduler/queue/builder/mod.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/rslib/src/decks/limits.rs b/rslib/src/decks/limits.rs index d62ad9519..5120e0d1b 100644 --- a/rslib/src/decks/limits.rs +++ b/rslib/src/decks/limits.rs @@ -122,7 +122,9 @@ impl LimitTreeMap { .unwrap(); let mut map = HashMap::new(); - map.insert(root_deck.id, root_id.clone()); + if root_limits.limits.review > 0 { + map.insert(root_deck.id, root_id.clone()); + } let mut limits = Self { tree, map }; let mut remaining_decks = child_decks.into_iter().peekable(); diff --git a/rslib/src/scheduler/queue/builder/mod.rs b/rslib/src/scheduler/queue/builder/mod.rs index 8da5b11a9..dd0045ba4 100644 --- a/rslib/src/scheduler/queue/builder/mod.rs +++ b/rslib/src/scheduler/queue/builder/mod.rs @@ -287,6 +287,13 @@ mod test { self.add_or_update_deck(deck).unwrap(); } + fn set_deck_review_limit(&mut self, deck: DeckId, limit: u32) { + let dcid = self.get_deck(deck).unwrap().unwrap().config_id().unwrap(); + let mut conf = self.get_deck_config(dcid, false).unwrap().unwrap(); + conf.inner.reviews_per_day = limit; + self.add_or_update_deck_config(&mut conf).unwrap(); + } + fn queue_as_deck_and_template(&mut self, deck_id: DeckId) -> Vec<(DeckId, u16)> { self.build_queues(deck_id) .unwrap() @@ -318,6 +325,18 @@ mod test { } } + #[test] + fn should_build_empty_queue_if_limit_is_reached() { + let mut col = open_test_collection(); + col.set_config_bool(BoolKey::Sched2021, true, false) + .unwrap(); + let note_id = col.add_new_note("Basic").id; + let cids = col.storage.card_ids_of_notes(&[note_id]).unwrap(); + col.set_due_date(&cids, "0", None).unwrap(); + col.set_deck_review_limit(DeckId(1), 0); + assert_eq!(col.queue_as_deck_and_template(DeckId(1)), vec![]); + } + #[test] fn new_queue_building() -> Result<()> { let mut col = open_test_collection(); From ab1c23953e830c73436e12f6d8301a662450d2ee Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 10 May 2022 13:18:07 +1000 Subject: [PATCH 11/12] Update translations --- repos.bzl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/repos.bzl b/repos.bzl index c06153208..922078db5 100644 --- a/repos.bzl +++ b/repos.bzl @@ -115,12 +115,12 @@ def register_repos(): ################ core_i18n_repo = "anki-core-i18n" - core_i18n_commit = "0d97543af78a11c7cc4f2af34f4eaef18e86cae9" - core_i18n_zip_csum = "ca722979b1c6ff4098d5fc3b91a723e51ac760e1a723ac46983c05248e4e79e2" + core_i18n_commit = "f404191d521051946b824d7974b14aff35932016" + core_i18n_zip_csum = "da823e153ff55ca1bb46d8e1eb5b74ca723f596abf85fb530f2457d17d0ffa05" qtftl_i18n_repo = "anki-desktop-ftl" - qtftl_i18n_commit = "9eda7432ff61768e867376bf7e4cf9a450056c9b" - qtftl_i18n_zip_csum = "6544d7d02cf605559f8d1ac1103d9375b2a2ecad499734dff748cf2675d59deb" + qtftl_i18n_commit = "51724fbb327815358d6f896a4f79cf9cb2303562" + qtftl_i18n_zip_csum = "e8f4723eb6d20432754b08c19164fbaafd43ff8222779e2a7cd1fb835f41c7b5" i18n_build_content = """ filegroup( From fb5521eeedffe55a433cec8fb8a5e1389f9eab70 Mon Sep 17 00:00:00 2001 From: BlueGreenMagick Date: Wed, 11 May 2022 09:06:34 +0900 Subject: [PATCH 12/12] remove image.style.height on resize (#1856) --- ts/editor/image-overlay/ImageHandle.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ts/editor/image-overlay/ImageHandle.svelte b/ts/editor/image-overlay/ImageHandle.svelte index 3021e222e..f1f9e819a 100644 --- a/ts/editor/image-overlay/ImageHandle.svelte +++ b/ts/editor/image-overlay/ImageHandle.svelte @@ -152,12 +152,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } /** - * Image resizing add-ons previously used image.style.width to set the - * preferred width of an image. In these cases, if we'd only set - * image.width, there would be no visible effect on the image. - * To avoid confusion with users we'll clear image.style.width (for now). + * Image resizing add-ons previously used image.style.width/height to set the + * preferred dimension of an image. In these cases, if we'd only set + * image.[dimension], there would be no visible effect on the image. + * To avoid confusion with users we'll clear image.style.[dimension] (for now). */ activeImage!.style.removeProperty("width"); + activeImage!.style.removeProperty("height"); if (activeImage!.getAttribute("style")?.length === 0) { activeImage!.removeAttribute("style"); }