-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimage-search-settings-tab.ts
50 lines (41 loc) · 1.2 KB
/
image-search-settings-tab.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { App, PluginSettingTab, Setting } from 'obsidian';
import ImageSearchPlugin from './main'
export interface ImageSearchPluginSettings {
apiKey: string;
searchEngineId: string;
}
export const DEFAULT_SETTINGS: ImageSearchPluginSettings = {
apiKey: '',
searchEngineId: ''
}
export class ImageSearchSettingTab extends PluginSettingTab {
plugin: ImageSearchPlugin;
constructor(app: App, plugin: ImageSearchPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
new Setting(containerEl)
.setName('API key')
.setDesc('Google Programmable Search Engine API key')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.apiKey)
.onChange(async (value) => {
this.plugin.settings.apiKey = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Search engine ID')
.setDesc('Google Programmable Search Engine ID')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.searchEngineId)
.onChange(async (value) => {
this.plugin.settings.searchEngineId = value;
await this.plugin.saveSettings();
}));
}
}