diff --git a/AnkiDroid/src/main/assets/scripts/ankidroid.js b/AnkiDroid/src/main/assets/scripts/ankidroid.js new file mode 100644 index 000000000000..5cf49c6085ae --- /dev/null +++ b/AnkiDroid/src/main/assets/scripts/ankidroid.js @@ -0,0 +1,13 @@ +"use strict"; +globalThis.ankidroid = globalThis.ankidroid || {}; + +globalThis.ankidroid.userAction = function (number) { + try { + let userJs = globalThis[`userJs${number}`]; + if (userJs != null) { + userJs(); + } + } catch (e) { + alert(e); + } +}; diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerHelpers.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerHelpers.kt index 62e38ad0bc23..1275355d22f9 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerHelpers.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerHelpers.kt @@ -36,7 +36,7 @@ class NoteEditorDestination(val cardId: Long) { /** * Not exactly equal to anki's stdHtml. Some differences: - * * `ankidroid.css` is added + * * `ankidroid.css` and `ankidroid.js` are added * * `bridgeCommand()` is ignored * * Aimed to be used only for reviewing/previewing cards @@ -77,7 +77,6 @@ fun stdHtml( ":root[class*=night-mode] { --canvas: $canvasColor; --fg: $fgColor; }" } - @Suppress("UnnecessaryVariable") // necessary for the HTML notation @Language("HTML") val html = """ @@ -98,6 +97,7 @@ fun stdHtml(
+