Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anki v24.06+ back card side automatic swap fix #651

Merged
merged 3 commits into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/media/experimental_assets/_ug-interactive_map_init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Interactive map initialization logic declaration.
* Note that due to Anki Desktop web view being persistent
* for card reviews IIFE is used to separate the namespaces
*/
(function () {
const mapConfig = getMapConfig();
const commonConfig = mapConfig.commonConfig;
Expand Down Expand Up @@ -165,10 +170,20 @@
if (typeof AnkiDroidJS !== "undefined") {
showAnswer();
} else {
commonElements.hiddenTextarea.dispatchEvent(new KeyboardEvent("keypress", {code: "Enter"}));
dispatchEnterEvent()
}
}

/**
* Trigger "Enter" key press event. Note that Anki < 24.06
* uses `code` property and Anki >= 24.06 - `key` property
* to query pressed key, so both properties must be present
*/
function dispatchEnterEvent() {
let artificialEvent = new KeyboardEvent("keypress", {code: "Enter", key: "Enter"});
commonElements.hiddenTextarea.dispatchEvent(artificialEvent);
}

/**
* Retrieve region highlighting color for answer card side
* depending on the configuration and whether the selected
Expand Down
Loading