Skip to content

Commit

Permalink
Merge pull request #651 from helitopia/interactive-map
Browse files Browse the repository at this point in the history
Anki v24.06+ back card side automatic swap fix
  • Loading branch information
axelboc authored Aug 24, 2024
2 parents 3086a10 + e0b0f47 commit d33eb54
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit d33eb54

Please sign in to comment.