mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-10 03:13:32 -07:00
feat: add Anki deck dropdown with Yomitan auto-fill in settings (#95)
This commit is contained in:
@@ -520,6 +520,36 @@ test('KnownWordCacheManager uses the current deck fields for immediate append',
|
||||
}
|
||||
});
|
||||
|
||||
test('KnownWordCacheManager uses all configured deck fields for immediate append without a current deck', () => {
|
||||
const config: AnkiConnectConfig = {
|
||||
deck: '',
|
||||
fields: {
|
||||
word: 'Expression',
|
||||
},
|
||||
knownWords: {
|
||||
highlightEnabled: true,
|
||||
decks: {
|
||||
'Kaishi 1.5k': ['Word'],
|
||||
Minecraft: ['Expression', 'Word'],
|
||||
},
|
||||
},
|
||||
};
|
||||
const { manager, cleanup } = createKnownWordCacheHarness(config);
|
||||
|
||||
try {
|
||||
manager.appendFromNoteInfo({
|
||||
noteId: 1,
|
||||
fields: {
|
||||
Expression: { value: '別人' },
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(manager.isKnownWord('別人'), true);
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('KnownWordCacheManager reports immediate append cache clears as mutations', () => {
|
||||
const config: AnkiConnectConfig = {
|
||||
fields: {
|
||||
|
||||
@@ -326,7 +326,18 @@ export class KnownWordCacheManager {
|
||||
: null;
|
||||
|
||||
if (!selectedDeckEntry) {
|
||||
return null;
|
||||
const configuredFields = trimmedDeckEntries.flatMap(([, fields]) =>
|
||||
Array.isArray(fields) ? fields : [],
|
||||
);
|
||||
const normalizedFields = [
|
||||
...new Set(
|
||||
configuredFields
|
||||
.map(String)
|
||||
.map((field) => field.trim())
|
||||
.filter((field) => field.length > 0),
|
||||
),
|
||||
];
|
||||
return normalizedFields.length > 0 ? normalizedFields : this.getDefaultKnownWordFields();
|
||||
}
|
||||
|
||||
const deckFields = selectedDeckEntry[1];
|
||||
|
||||
Reference in New Issue
Block a user