-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mcq): single choice question auto flipping
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'anki-templates': minor | ||
--- | ||
|
||
feat(mcq): single choice question auto flipping (单选题自动翻转) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
declare const pycmd: (cmd: string) => void | undefined; | ||
declare const study: { drawAnswer: () => void } | undefined; | ||
declare const AnkiDroidJS: any; | ||
declare const showAnswer: () => void | undefined; | ||
|
||
declare global { | ||
interface Window { | ||
sendMessage2?: (type: string, pos: string) => void; | ||
anki: any; | ||
} | ||
} | ||
|
||
export function flipToBack() { | ||
if (typeof pycmd !== 'undefined') { | ||
pycmd('ans'); | ||
} else if (typeof study !== 'undefined') { | ||
study.drawAnswer(); | ||
} else if (typeof AnkiDroidJS !== 'undefined') { | ||
showAnswer(); | ||
} else if (window.anki && window.sendMessage2) { | ||
window.sendMessage2('ankitap', 'midCenter'); | ||
} else if (process.env.NODE_ENV === 'development') { | ||
window.setBack?.(true); | ||
} | ||
} |