feat(config): reorganize settings window and move annotation colors to subtitleStyle

- Reorganize Configuration window into Appearance, Behavior, Anki, Input, and Integration sections
- Add AnkiConnect-backed deck, note-type, and field pickers in the Anki section
- Add click-to-learn keybinding controls
- Move known-word and N+1 highlight colors to subtitleStyle.knownWordColor / subtitleStyle.nPlusOneColor; legacy ankiConnect.knownWords.color and ankiConnect.nPlusOne.nPlusOne keys still accepted with deprecation warnings
- Add deckNames, modelNames, modelFieldNames, and fieldNamesForDeck methods to AnkiConnectClient
- Mark discordPresence.presenceStyle as an enum in the config registry
This commit is contained in:
2026-05-17 02:10:16 -07:00
parent a54f03f0cd
commit 309ce6ef8f
44 changed files with 2152 additions and 321 deletions
+42
View File
@@ -156,6 +156,48 @@ export class AnkiConnectClient {
return (result as number[]) || [];
}
async deckNames(): Promise<string[]> {
const result = await this.invoke('deckNames');
return Array.isArray(result)
? result.filter((value): value is string => typeof value === 'string').sort()
: [];
}
async modelNames(): Promise<string[]> {
const result = await this.invoke('modelNames');
return Array.isArray(result)
? result.filter((value): value is string => typeof value === 'string').sort()
: [];
}
async modelFieldNames(modelName: string): Promise<string[]> {
const result = await this.invoke('modelFieldNames', { modelName });
return Array.isArray(result)
? result.filter((value): value is string => typeof value === 'string').sort()
: [];
}
async fieldNamesForDeck(deckName: string, sampleSize = 100): Promise<string[]> {
const escapedDeckName = deckName.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
const noteIds = await this.findNotes(`deck:"${escapedDeckName}"`, { maxRetries: 0 });
if (noteIds.length === 0) {
return [];
}
const noteInfos = await this.notesInfo(noteIds.slice(0, sampleSize));
const fields = new Set<string>();
for (const noteInfo of noteInfos) {
const noteFields = noteInfo.fields;
if (!noteFields || typeof noteFields !== 'object' || Array.isArray(noteFields)) {
continue;
}
for (const fieldName of Object.keys(noteFields)) {
fields.add(fieldName);
}
}
return [...fields].sort();
}
async notesInfo(noteIds: number[]): Promise<Record<string, unknown>[]> {
const result = await this.invoke('notesInfo', { notes: noteIds });
return (result as Record<string, unknown>[]) || [];