mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
0298a066ad
- 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
45 lines
2.0 KiB
TypeScript
45 lines
2.0 KiB
TypeScript
import { contextBridge, ipcRenderer } from 'electron';
|
|
import type {
|
|
ConfigSettingsAnkiListResult,
|
|
ConfigSettingsAPI,
|
|
ConfigSettingsPatch,
|
|
ConfigSettingsSaveResult,
|
|
ConfigSettingsSnapshot,
|
|
} from './types/settings';
|
|
|
|
const SETTINGS_IPC_CHANNELS = {
|
|
getSnapshot: 'config:get-settings-snapshot',
|
|
savePatch: 'config:save-settings-patch',
|
|
openFile: 'config:open-settings-file',
|
|
openWindow: 'config:open-settings-window',
|
|
getAnkiDeckNames: 'config-settings:anki-deck-names',
|
|
getAnkiDeckFieldNames: 'config-settings:anki-deck-field-names',
|
|
getAnkiModelNames: 'config-settings:anki-model-names',
|
|
getAnkiModelFieldNames: 'config-settings:anki-model-field-names',
|
|
} as const;
|
|
|
|
const configSettingsAPI: ConfigSettingsAPI = {
|
|
getSnapshot: (): Promise<ConfigSettingsSnapshot> =>
|
|
ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.getSnapshot),
|
|
savePatch: (patch: ConfigSettingsPatch): Promise<ConfigSettingsSaveResult> =>
|
|
ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.savePatch, patch),
|
|
openSettingsFile: (): Promise<boolean> => ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.openFile),
|
|
openSettingsWindow: (): Promise<boolean> => ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.openWindow),
|
|
getAnkiDeckNames: (draftUrl?: string): Promise<ConfigSettingsAnkiListResult> =>
|
|
ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.getAnkiDeckNames, draftUrl),
|
|
getAnkiDeckFieldNames: (
|
|
deckName: string,
|
|
draftUrl?: string,
|
|
): Promise<ConfigSettingsAnkiListResult> =>
|
|
ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.getAnkiDeckFieldNames, deckName, draftUrl),
|
|
getAnkiModelNames: (draftUrl?: string): Promise<ConfigSettingsAnkiListResult> =>
|
|
ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.getAnkiModelNames, draftUrl),
|
|
getAnkiModelFieldNames: (
|
|
modelName: string,
|
|
draftUrl?: string,
|
|
): Promise<ConfigSettingsAnkiListResult> =>
|
|
ipcRenderer.invoke(SETTINGS_IPC_CHANNELS.getAnkiModelFieldNames, modelName, draftUrl),
|
|
};
|
|
|
|
contextBridge.exposeInMainWorld('configSettingsAPI', configSettingsAPI);
|