diff --git a/src/data/BibleVersionCollection.ts b/src/data/BibleVersionCollection.ts index 00f86f5..90ce643 100644 --- a/src/data/BibleVersionCollection.ts +++ b/src/data/BibleVersionCollection.ts @@ -18,180 +18,201 @@ export const BibleVersionCollection: IBibleVersion[] = [ { key: 'clementine', versionName: 'Clementine Latin Vulgate', - language: 'Latin', code: 'la', + language: 'Latin', + code: 'la', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'kjv', versionName: 'King James Version', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'bbe', versionName: 'Bible in Basic English', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'oeb-us', versionName: 'Open English Bible, US Edition', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'almeida', versionName: 'João Ferreira de Almeida', - language: 'Portuguese', code: 'pt', + language: 'Portuguese', + code: 'pt', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'rccv', versionName: 'Romanian Corrected Cornilescu Version', - language: 'Romanian', code: 'ro', + language: 'Romanian', + code: 'ro', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'cherokee', versionName: 'Cherokee New Testament', - language: 'Cherokee', code: 'cu', + language: 'Cherokee', + code: 'cu', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'oeb-cw', versionName: 'Open English Bible, Commonwealth Edition', - language: 'English (UK)', code: 'en', + language: 'English (UK)', + code: 'en', apiSource: BibleAPISourceCollection.bibleApi, }, { key: 'webbe', versionName: 'World English Bible, British Edition', - language: 'English (UK)', code: 'en', + language: 'English (UK)', + code: 'en', apiSource: BibleAPISourceCollection.bibleApi, }, // bolls life { key: 'nkjv', versionName: 'New King James Version', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bollsLife, infoUrl: 'https://wikipedia.org/wiki/New_King_James_Version', }, { key: 'niv', versionName: 'New International Version, 1984', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'nrsvce', versionName: 'New Revised Standard Version Catholic Edition (NRSVCE)', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'esv', versionName: 'English Standard Version', - language: 'English', code: 'en', + language: 'English', + code: 'en', apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "nasb", - versionName: "New American Standard Bible (1995)", - language: "English", + key: 'nasb', + versionName: 'New American Standard Bible (1995)', + language: 'English', code: 'en', - apiSource: BibleAPISourceCollection.bollsLife + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "elb", - versionName: "Elberfelder Bibel (1871)", - language: "German Deutsch", + key: 'elb', + versionName: 'Elberfelder Bibel (1871)', + language: 'German Deutsch', code: 'de', - apiSource: BibleAPISourceCollection.bollsLife + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "lut", - versionName: "Luther (1912)", - language: "German Deutsch", + key: 'lut', + versionName: 'Luther (1912)', + language: 'German Deutsch', code: 'de', - apiSource: BibleAPISourceCollection.bollsLife + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "ntgt", - versionName: "Greek NT: Tischendorf 8th Ed.", - language: "Greek Ελληνικά", - apiSource: BibleAPISourceCollection.bollsLife + key: 'ntgt', + versionName: 'Greek NT: Tischendorf 8th Ed.', + language: 'Greek Ελληνικά', + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "tr", - versionName: "Elzevir Textus Receptus (1624)", - language: "Greek Ελληνικά", - apiSource: BibleAPISourceCollection.bollsLife + key: 'tr', + versionName: 'Elzevir Textus Receptus (1624)', + language: 'Greek Ελληνικά', + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "lxx", - versionName: "Septuagint", - language: "Greek Ελληνικά", - apiSource: BibleAPISourceCollection.bollsLife + key: 'lxx', + versionName: 'Septuagint', + language: 'Greek Ελληνικά', + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "wlc", - versionName: "Westminster Leningrad Codex (with Vowels)", - language: "Hebrew עברית", - apiSource: BibleAPISourceCollection.bollsLife + key: 'wlc', + versionName: 'Westminster Leningrad Codex (with Vowels)', + language: 'Hebrew עברית', + apiSource: BibleAPISourceCollection.bollsLife, }, { - key: "dhnt", + key: 'dhnt', versionName: "Delitzsch's Hebrew New Testament 1877, 1998 (with Vowels)", - language: "Hebrew עברית", - apiSource: BibleAPISourceCollection.bollsLife + language: 'Hebrew עברית', + apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'cuv', versionName: 'Chinese Union Version (Traditional)', - language: 'Chinese', code: 'cn', + language: 'Chinese', + code: 'cn', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'nr06', versionName: 'Nuova Riveduta, 2006', - language: 'Latin / Italian', code: 'it', + language: 'Latin / Italian', + code: 'it', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'svd', versionName: 'Smith and Van Dyke', - language: 'Arabic العربية', code: 'ar', + language: 'Arabic العربية', + code: 'ar', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'btx3', versionName: 'La Biblia Textual 3ra Edicion', - language: 'Spanish', code: 'sp', + language: 'Spanish', + code: 'sp', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'rv1960', versionName: 'Reina Valera 1960', - language: 'Spanish', code: 'sp', + language: 'Spanish', + code: 'sp', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'rv2004', versionName: 'Reina Valera Gomez 2004', - language: 'Spanish', code: 'sp', + language: 'Spanish', + code: 'sp', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'pdt', versionName: 'Palabra de Dios para Todos', - language: 'Spanish', code: 'sp', + language: 'Spanish', + code: 'sp', apiSource: BibleAPISourceCollection.bollsLife, }, { key: 'nvi', versionName: 'Nueva Version Internacional', - language: 'Spanish', code: 'sp', + language: 'Spanish', + code: 'sp', apiSource: BibleAPISourceCollection.bollsLife, }, { @@ -243,17 +264,20 @@ export const BibleVersionCollection: IBibleVersion[] = [ export const DEFAULT_BIBLE_VERSION = BibleVersionCollection[11] - export const getBibleVersion = (key: string): IBibleVersion => { - return BibleVersionCollection.find(bibleVersion => bibleVersion.key === key) ?? DEFAULT_BIBLE_VERSION + return ( + BibleVersionCollection.find((bibleVersion) => bibleVersion.key === key) ?? + DEFAULT_BIBLE_VERSION + ) } -export const allBibleVersionsWithLanguageNameAlphabetically: IBibleVersion[] = BibleVersionCollection.sort((a, b) => { - // sort by language and versionName alphabetically - const languageCompare = a.language.localeCompare(b.language) - if (languageCompare === 0) { - return a.versionName.localeCompare(b.versionName) - } else { - return languageCompare - } -}) +export const allBibleVersionsWithLanguageNameAlphabetically: IBibleVersion[] = + BibleVersionCollection.sort((a, b) => { + // sort by language and versionName alphabetically + const languageCompare = a.language.localeCompare(b.language) + if (languageCompare === 0) { + return a.versionName.localeCompare(b.versionName) + } else { + return languageCompare + } + }) diff --git a/src/data/constants.ts b/src/data/constants.ts index 709899e..f8109ec 100644 --- a/src/data/constants.ts +++ b/src/data/constants.ts @@ -31,7 +31,7 @@ export interface BibleReferencePluginSettings { enableBibleVerseLookupRibbon?: boolean optOutToEvents?: boolean - advancedSettings?: boolean; + advancedSettings?: boolean } export const DEFAULT_SETTINGS: BibleReferencePluginSettings = { diff --git a/src/main.ts b/src/main.ts index 8fc0ca2..458146a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,8 +14,8 @@ import { splitBibleReference } from './utils/splitBibleReference' import { VerseOfDaySuggesting } from './verse/VerseOfDaySuggesting' import { FlagService } from './provider/FeatureFlag' import { EventStats } from './provider/EventStats' -import { getBibleVersion } from './data/BibleVersionCollection'; -import { pluginEvent } from './obsidian/PluginEvent'; +import { getBibleVersion } from './data/BibleVersionCollection' +import { pluginEvent } from './obsidian/PluginEvent' export default class BibleReferencePlugin extends Plugin { settings: BibleReferencePluginSettings @@ -67,7 +67,7 @@ export default class BibleReferencePlugin extends Plugin { console.debug('unloading plugin', APP_NAMING.appName) this.removeRibbonButton() this.removeStatusBarIndicator() - pluginEvent.offAll(); // so that we don't have to worry about off ref in multiple places + pluginEvent.offAll() // so that we don't have to worry about off ref in multiple places } async loadSettings() { @@ -80,8 +80,8 @@ export default class BibleReferencePlugin extends Plugin { } private async getAndCachedVerseOfDay(): Promise { - const {ttl, timestamp, verseOfDaySuggesting} = - this?.cachedVerseOfDaySuggesting || {} + const { ttl, timestamp, verseOfDaySuggesting } = + this?.cachedVerseOfDaySuggesting || {} if (!verseOfDaySuggesting || timestamp + ttl > Date.now()) { const vodResp = await getVod() const reference = splitBibleReference(vodResp.verse.details.reference) @@ -107,7 +107,7 @@ export default class BibleReferencePlugin extends Plugin { callback: () => { EventStats.logUIOpen( 'lookupModalOpen', - {key: `command-lookup`, value: 1}, + { key: `command-lookup`, value: 1 }, this.settings.optOutToEvents ) this.verseLookUpModal.open() @@ -124,7 +124,7 @@ export default class BibleReferencePlugin extends Plugin { const verse = await this.getAndCachedVerseOfDay() EventStats.logUIOpen( 'vodEditorOpen', - {key: `command-vod`, value: 1}, + { key: `command-vod`, value: 1 }, this.settings.optOutToEvents ) new Notice( @@ -145,7 +145,7 @@ export default class BibleReferencePlugin extends Plugin { const vodSuggesting = await this.getAndCachedVerseOfDay() EventStats.logUIOpen( 'vodEditorOpen', - {key: `command-vod-insert`, value: 1}, + { key: `command-vod-insert`, value: 1 }, this.settings.optOutToEvents ) editor.replaceSelection(vodSuggesting.allFormattedContent) @@ -162,7 +162,7 @@ export default class BibleReferencePlugin extends Plugin { (_evt) => { EventStats.logUIOpen( 'lookupModalOpen', - {key: `ribbon-click`, value: 1}, + { key: `ribbon-click`, value: 1 }, this.settings.optOutToEvents ) this.verseLookUpModal.open() @@ -174,7 +174,7 @@ export default class BibleReferencePlugin extends Plugin { if (this.ribbonButton) { EventStats.logUIOpen( 'lookupModalOpen', - {key: `ribbon-remove`, value: 1}, + { key: `ribbon-remove`, value: 1 }, this.settings.optOutToEvents ) this.ribbonButton.parentNode?.removeChild(this.ribbonButton) @@ -187,14 +187,14 @@ export default class BibleReferencePlugin extends Plugin { */ private initStatusBarInidactor(): void { // This adds a status bar item to the bottom of the app. Does not work on mobile apps. - this.removeStatusBarIndicator(); + this.removeStatusBarIndicator() const bibleVersion = getBibleVersion(this.settings.bibleVersion) this.statusBarIndicator = this.addStatusBarItem() // todo add an icon this.statusBarIndicator.createEl('span', { text: `${bibleVersion.versionName}(${bibleVersion.language})`, - cls: 'bible-version-indicator' - }); + cls: 'bible-version-indicator', + }) // create event listener for the update pluginEvent.on('bible-reference:settings:version', () => { this.updateStatusBarIndicator() @@ -202,18 +202,21 @@ export default class BibleReferencePlugin extends Plugin { // this.registerEvent(versionChangeEventRef) // somehow this is not necessary } - private removeStatusBarIndicator(): void { if (this.statusBarIndicator) { this.statusBarIndicator.parentNode?.removeChild(this.statusBarIndicator) } } - private updateStatusBarIndicator(): void { const bibleVersion = getBibleVersion(this.settings.bibleVersion) - if (this.statusBarIndicator && 'getElementsByClassName' in this.statusBarIndicator) { - const el = this.statusBarIndicator.getElementsByClassName('bible-version-indicator')[0] + if ( + this.statusBarIndicator && + 'getElementsByClassName' in this.statusBarIndicator + ) { + const el = this.statusBarIndicator.getElementsByClassName( + 'bible-version-indicator' + )[0] el.innerHTML = `${bibleVersion.versionName}(${bibleVersion.language})` } } diff --git a/src/obsidian/PluginEvent.ts b/src/obsidian/PluginEvent.ts index e2f5348..1853d7d 100644 --- a/src/obsidian/PluginEvent.ts +++ b/src/obsidian/PluginEvent.ts @@ -1,33 +1,32 @@ -import { Events, EventRef } from 'obsidian'; +import { Events, EventRef } from 'obsidian' // ref this article https://shbgm.ca/blog/obsidian/plugin-development/custom-events export class PluginEvent extends Events { - private static instance: PluginEvent; - protected refs: EventRef[] = []; + private static instance: PluginEvent + protected refs: EventRef[] = [] constructor() { - super(); + super() } public static getInstance(): PluginEvent { if (!PluginEvent.instance) { - PluginEvent.instance = new PluginEvent(); + PluginEvent.instance = new PluginEvent() } - return PluginEvent.instance; + return PluginEvent.instance } on(name: string, callback: (...data: any) => any, ctx?: any): EventRef { - const ref = super.on(name, callback, ctx); - this.refs.push(ref); - return ref; + const ref = super.on(name, callback, ctx) + this.refs.push(ref) + return ref } public offAll() { this.refs.forEach((ref) => { this.offref(ref) - }); + }) } } - -export const pluginEvent = PluginEvent.getInstance(); +export const pluginEvent = PluginEvent.getInstance() diff --git a/src/provider/BaseBibleAPIProvider.ts b/src/provider/BaseBibleAPIProvider.ts index ae5c0bc..4dfe401 100644 --- a/src/provider/BaseBibleAPIProvider.ts +++ b/src/provider/BaseBibleAPIProvider.ts @@ -1,7 +1,7 @@ import { IVerse } from '../interfaces/IVerse' import { Notice } from 'obsidian' import { EventStats } from './EventStats' -import { IBibleVersion } from '../interfaces/IBibleVersion'; +import { IBibleVersion } from '../interfaces/IBibleVersion' export abstract class BaseBibleAPIProvider { protected _versionKey: string // the version selected, for example kjv @@ -17,7 +17,7 @@ export abstract class BaseBibleAPIProvider { this._apiUrl = bibleVersion.apiSource.apiUrl } - protected get LanguageShortCode(): string|undefined { + protected get LanguageShortCode(): string | undefined { return this._bibleVersiopn.code } diff --git a/src/provider/BollyLifeProvider.ts b/src/provider/BollyLifeProvider.ts index 5d8a49c..7254d78 100644 --- a/src/provider/BollyLifeProvider.ts +++ b/src/provider/BollyLifeProvider.ts @@ -1,7 +1,7 @@ import { IVerse } from '../interfaces/IVerse' import { IBibleVersion } from '../interfaces/IBibleVersion' import { BaseBibleAPIProvider } from './BaseBibleAPIProvider' -import { getBookIdFromBookName } from '../utils/bookNameReference'; +import { getBookIdFromBookName } from '../utils/bookNameReference' export class BollyLifeProvider extends BaseBibleAPIProvider { //private _verseApiUrl: string; // we do not support get verse api yet, but the api supported it diff --git a/src/ui/BibleReferenceSettingTab.ts b/src/ui/BibleReferenceSettingTab.ts index 523dae4..c39815c 100644 --- a/src/ui/BibleReferenceSettingTab.ts +++ b/src/ui/BibleReferenceSettingTab.ts @@ -27,11 +27,11 @@ import { FlagService } from '../provider/FeatureFlag' import { BibleAPISourceCollection } from '../data/BibleApiSourceCollection' import { EventStats } from '../provider/EventStats' import { APP_NAMING, OutgoingLinkPositionEnum } from '../data/constants' -import { pluginEvent } from '../obsidian/PluginEvent'; +import { pluginEvent } from '../obsidian/PluginEvent' export class BibleReferenceSettingTab extends PluginSettingTab { private plugin: BibleReferencePlugin - private expertSettingContainer?: HTMLElement; + private expertSettingContainer?: HTMLElement constructor(app: App, plugin: BibleReferencePlugin) { super(app, plugin) @@ -46,16 +46,16 @@ export class BibleReferenceSettingTab extends PluginSettingTab {