import { App , Notice , PluginSettingTab , Setting } from 'obsidian' ; import { APP_NAMING } from '../data/constants' ; import BibleReferencePlugin from '../../main' ; import { BibleVersionCollection , IBibleVersion } from '../data/BibleVersionCollection' ; export class BibleReferenceSettingTab extends PluginSettingTab { plugin : BibleReferencePlugin ; constructor ( app , plugin ) { super ( app , plugin ) ; this . plugin = plugin ; } getAllBibleVersionsWithLanguageNameAlphabetically = ( ) : IBibleVersion [ ] => { return this . getAllBibleVersionsWithLanguageName ( ) . sort ( ( a , b ) => { const languageCompare = a . language . localeCompare ( b . language ) ; if ( languageCompare === 0 ) { return a . versionName . localeCompare ( b . versionName ) ; } else { return languageCompare ; } } ) ; } ; getAllBibleVersionsWithLanguageName = ( ) : IBibleVersion [ ] => { return BibleVersionCollection ; } ; SetUpVersionSettingsAndVersionOptions = ( containerEl ) : void => { new Setting ( containerEl ) . setName ( 'Bible Version' ) . setDesc ( 'Choose the Bible Version You Prefer' ) . addDropdown ( ( dropdown ) => { const allVersionOptions = this . getAllBibleVersionsWithLanguageNameAlphabetically ( ) ; allVersionOptions . forEach ( ( version ) => { dropdown . addOption ( version . key , `${ version . language } - ${ version . versionName }` ) ; } ) ; dropdown . setValue ( this . plugin . settings . bibleVersion ) . onChange ( async ( value ) => { this . plugin . settings . bibleVersion = value ; console . log ( 'Bible Version: ' + value ) ; await this . plugin . saveSettings ( ) ; new Notice ( 'Bible Reference Settings Updated ' ) ; } ) ; } ) ; } ; display ( ) { let { containerEl } = this ; containerEl . empty ( ) ; containerEl . createEl ( 'h2' , { text : 'Settings for ' + APP_NAMING . appName } ) ; this . SetUpVersionSettingsAndVersionOptions ( containerEl ) ; } }