obsidian-semantic

Log | Files | Refs | README

SemanticsSettings.ts (1080B)


      1 import { App, PluginSettingTab, Setting } from 'obsidian';
      2 import SemanticIntegration from 'main';
      3 
      4 export class SemanticsSettings extends PluginSettingTab {
      5 	plugin: SemanticIntegration;
      6 
      7 	constructor(app: App, plugin: SemanticIntegration) {
      8 		super(app, plugin);
      9 		this.plugin = plugin;
     10 	}
     11 
     12 	display() {
     13 		const { containerEl } = this;
     14 
     15 		containerEl.empty();
     16 
     17 		new Setting(containerEl)
     18 			.setName("Papers directory")
     19 			.setDesc("Where to store notes for papers")
     20 			.addText(text => text
     21 				.setPlaceholder("papers")
     22 				.setValue(this.plugin.settings.papersPath)
     23 				.onChange(async (value) => {
     24 					this.plugin.settings.papersPath = value;
     25 					await this.plugin.saveSettings();
     26 				}));
     27 
     28 		new Setting(containerEl)
     29 			.setName("API Key")
     30 			.setDesc("API Key to use")
     31 			.addText(text => text
     32 				.setPlaceholder("api key")
     33 				.setValue(this.plugin.settings.apiKey == undefined ? "" : this.plugin.settings.apiKey)
     34 				.onChange(async (value) => {
     35 					this.plugin.settings.apiKey = value == "" ? undefined : value;
     36 					await this.plugin.saveSettings();
     37 				}));
     38 	}
     39 }