diff --git a/README.md b/README.md index eaa3369..4db8bb8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ > On iOS devices, there is a known issue about conflict between `Smart Punctuation` and double hyphens `--`. > -> To make it work, +> To make it work, +> > - you can use `++` instead of `--` in the beginning of the verse reference => `++John1:1` (recommended) > - or you can turn Smart Punctuation off => [How to use](https://github.com/tim-hub/obsidian-bible-reference/wiki/How-to-use#how-to-use-on-ios-iphone--ipad) @@ -89,11 +90,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d > Special thanks for the sponsors [![support button of obsidian bible reference](https://img.shields.io/static/v1?label=SupportMe&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/tim-hub) - - - ## Related Projects -- [Bible Vector Search](https://bible-search.antioch.tech/) To search Bible verses in meaning not in keywords. -This is another open source project I built recently to implement AI Embedding and Vector Search for Bible verses (in BBE transaltion). + +- [Bible Vector Search](https://bible-search.antioch.tech/) To search Bible verses in meaning not in keywords. + This is another open source project I built recently to implement AI Embedding and Vector Search for Bible verses (in BBE transaltion). diff --git a/src/api/PluginAPI.ts b/src/api/PluginAPI.ts index 1020523..7945c48 100644 --- a/src/api/PluginAPI.ts +++ b/src/api/PluginAPI.ts @@ -14,7 +14,7 @@ import { App } from 'obsidian' export class BibleReferenceAPI { public constructor( public app: App, - public settings: BibleReferencePluginSettings, + public settings: BibleReferencePluginSettings ) { this.app = app this.settings = settings @@ -28,12 +28,19 @@ export class BibleReferenceAPI { * @param {String} query - the query string (e.g. 'Luke 1:1') * @param {BibleReferencePluginSettings?} [opts=undefined] - optional overrides for any settings */ - async queryVerses(query: string, opts?: BibleReferencePluginSettings): Promise { + async queryVerses( + query: string, + opts?: BibleReferencePluginSettings + ): Promise { if (!verseMatch(query)) return null - return getSuggestionsFromQuery(`${query}`, this.mergeSettings(opts)).then(verseArray => verseArray[0] || null) + return getSuggestionsFromQuery(`${query}`, this.mergeSettings(opts)).then( + (verseArray) => verseArray[0] || null + ) } - private mergeSettings(opts?: BibleReferencePluginSettings): BibleReferencePluginSettings { + private mergeSettings( + opts?: BibleReferencePluginSettings + ): BibleReferencePluginSettings { return opts ? Object.assign(Object.assign({}, this.settings), opts) : Object.assign({}, this.settings) diff --git a/src/data/BibleVersionCollection.ts b/src/data/BibleVersionCollection.ts index 0845342..f231423 100644 --- a/src/data/BibleVersionCollection.ts +++ b/src/data/BibleVersionCollection.ts @@ -1,7 +1,6 @@ import { IBibleVersion } from '../interfaces/IBibleVersion' import { BibleAPISourceCollection } from './BibleApiSourceCollection' - export const BibleVersionCollectionEnglish = [ { key: 'amp', @@ -31,7 +30,8 @@ export const BibleVersionCollectionEnglish = [ language: 'English', code: 'en', apiSource: BibleAPISourceCollection.bollsLife, - infoURL: 'https://en.wikipedia.org/wiki/Messianic_Bible_translations#Complete_Jewish_Bible_(CJB)', + infoURL: + 'https://en.wikipedia.org/wiki/Messianic_Bible_translations#Complete_Jewish_Bible_(CJB)', }, { key: 'drb', @@ -198,7 +198,7 @@ export const BibleVersionCollectionEnglish = [ }, { key: 'ylt', - versionName: 'Young\'s Literal Translation', + versionName: "Young's Literal Translation", language: 'English', code: 'en', apiSource: BibleAPISourceCollection.bollsLife, @@ -312,14 +312,12 @@ export const BibleVersionCollectionGreek = [ language: 'Greek Ελληνικά', apiSource: BibleAPISourceCollection.bollsLife, }, - ] export const BibleVersionCollectionHebrew = [ - { key: 'dhnt', - versionName: 'Delitzsch\'s Hebrew New Testament 1877, 1998 (with Vowels)', + versionName: "Delitzsch's Hebrew New Testament 1877, 1998 (with Vowels)", language: 'Hebrew עברית', apiSource: BibleAPISourceCollection.bollsLife, }, @@ -427,7 +425,6 @@ export const BibleVersionCollectionSpanish = [ }, ] - export const BibleVersionCollectionPolish = [ { key: 'bg', @@ -488,34 +485,32 @@ export const BibleVersionCollectionTamil = [ }, ] - /** * Please note to support the abbreviation of the translation * "code" need to be added * And the Abbreviation source need to be updated too See this repo. https://github.com/AntiochTechnology/bible-reference-toolkit/tree/master/packages/bible-book-names-intl */ -export const BibleVersionCollection: IBibleVersion[] = - [ - ...BibleVersionCollectionArabic, - ...BibleVersionCollectionCherokee, - ...BibleVersionCollectionChinese, - ...BibleVersionCollectionEnglish, - ...BibleVersionCollectionEnglishUK, - ...BibleVersionCollectionFrench, - ...BibleVersionCollectionGerman, - ...BibleVersionCollectionGreek, - ...BibleVersionCollectionHebrew, - ...BibleVersionCollectionIndonesian, - ...BibleVersionCollectionItalian, - ...BibleVersionCollectionLatin, - ...BibleVersionCollectionPolish, - ...BibleVersionCollectionPortuguese, - ...BibleVersionCollectionRomanian, - ...BibleVersionCollectionRussian, - ...BibleVersionCollectionSpanish, - ...BibleVersionCollectionTamil, - ...BibleVersionCollectionUkrainian, - ] +export const BibleVersionCollection: IBibleVersion[] = [ + ...BibleVersionCollectionArabic, + ...BibleVersionCollectionCherokee, + ...BibleVersionCollectionChinese, + ...BibleVersionCollectionEnglish, + ...BibleVersionCollectionEnglishUK, + ...BibleVersionCollectionFrench, + ...BibleVersionCollectionGerman, + ...BibleVersionCollectionGreek, + ...BibleVersionCollectionHebrew, + ...BibleVersionCollectionIndonesian, + ...BibleVersionCollectionItalian, + ...BibleVersionCollectionLatin, + ...BibleVersionCollectionPolish, + ...BibleVersionCollectionPortuguese, + ...BibleVersionCollectionRomanian, + ...BibleVersionCollectionRussian, + ...BibleVersionCollectionSpanish, + ...BibleVersionCollectionTamil, + ...BibleVersionCollectionUkrainian, +] export const DEFAULT_BIBLE_VERSION = BibleVersionCollection[11] diff --git a/src/main.ts b/src/main.ts index 2c1204d..657eb6e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -43,17 +43,18 @@ export default class BibleReferencePlugin extends Plugin { this.addVerseLookupCommand() this.addRibbonButton() - this.api = new BibleReferenceAPI(this.app, this.settings); + this.api = new BibleReferenceAPI(this.app, this.settings) // Register the api globally // @ts-ignore - (window['BibleReferenceAPI'] = this.api) && this.register(() => { - // @ts-ignore - delete window['BibleReferenceAPI'] - }) + ;(window['BibleReferenceAPI'] = this.api) && + this.register(() => { + // @ts-ignore + delete window['BibleReferenceAPI'] + }) // enable vod this.registerEditorSuggest( - new VerseOfDayEditorSuggester(this, this.settings), + new VerseOfDayEditorSuggester(this, this.settings) ) this.verseOfDayModal = new VerseOfDayModal(this, this.settings) this.addVerseOfDayInsertCommand() @@ -81,7 +82,7 @@ export default class BibleReferencePlugin extends Plugin { private async getAndCachedVerseOfDay(): Promise { const { ttl, timestamp, verseOfDaySuggesting } = - this?.cachedVerseOfDaySuggesting || {} + this?.cachedVerseOfDaySuggesting || {} if (!verseOfDaySuggesting || timestamp + ttl > Date.now()) { const vodResp = await getVod() const reference = splitBibleReference(vodResp.verse.details.reference) @@ -89,7 +90,7 @@ export default class BibleReferencePlugin extends Plugin { const vodSuggesting = new VerseOfDaySuggesting( this.settings, reference, - verseTexts, + verseTexts ) this.cachedVerseOfDaySuggesting = { verseOfDaySuggesting: vodSuggesting, @@ -108,7 +109,7 @@ export default class BibleReferencePlugin extends Plugin { EventStats.logUIOpen( 'lookupModalOpen', { key: `command-lookup`, value: 1 }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) this.verseLookUpModal.open() }, @@ -125,13 +126,13 @@ export default class BibleReferencePlugin extends Plugin { EventStats.logUIOpen( 'vodEditorOpen', { key: `command-vod`, value: 1 }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) new Notice( `${verse.verseTexts?.join('')} -- ${verse.verseReference.bookName} ${ verse.verseReference.chapterNumber }:${verse.verseReference.verseNumber}`, - 1000 * 10, + 1000 * 10 ) }, }) @@ -146,7 +147,7 @@ export default class BibleReferencePlugin extends Plugin { EventStats.logUIOpen( 'vodEditorOpen', { key: `command-vod-insert`, value: 1 }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) editor.replaceSelection(vodSuggesting.allFormattedContent) }, @@ -163,10 +164,10 @@ export default class BibleReferencePlugin extends Plugin { EventStats.logUIOpen( 'lookupModalOpen', { key: `ribbon-click`, value: 1 }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) this.verseLookUpModal.open() - }, + } ) } @@ -175,7 +176,7 @@ export default class BibleReferencePlugin extends Plugin { EventStats.logUIOpen( 'lookupModalOpen', { key: `ribbon-remove`, value: 1 }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) this.ribbonButton.parentNode?.removeChild(this.ribbonButton) } @@ -230,7 +231,7 @@ export default class BibleReferencePlugin extends Plugin { 'getElementsByClassName' in this.statusBarIndicator ) { const el = this.statusBarIndicator.getElementsByClassName( - 'bible-version-indicator', + 'bible-version-indicator' )[0] el.innerHTML = this.getStatusBatLabel() } diff --git a/src/provider/BaseBibleAPIProvider.ts b/src/provider/BaseBibleAPIProvider.ts index 498e7da..37da143 100644 --- a/src/provider/BaseBibleAPIProvider.ts +++ b/src/provider/BaseBibleAPIProvider.ts @@ -13,7 +13,7 @@ export abstract class BaseBibleAPIProvider { constructor(bibleVersion: IBibleVersion) { this._bibleVersion = bibleVersion - const {key} = bibleVersion + const { key } = bibleVersion this._versionKey = key this._apiUrl = bibleVersion.apiSource.apiUrl } @@ -37,7 +37,7 @@ export abstract class BaseBibleAPIProvider { return this._currentQueryUrl } - protected abstract prepareVerseLinkUrl():string + protected abstract prepareVerseLinkUrl(): string /** * Get the Callout Link URL for the verse query @@ -65,8 +65,14 @@ export abstract class BaseBibleAPIProvider { * @param verses * @protected */ - protected buildBibleGatewayUrl(bookName: string, chapter: number, verses: number[]): string { - return `https://www.biblegateway.com/passage/?search=${bookName}+${chapter}:${this.convertVersesToQueryString(verses)}&version=${this._versionKey}` + protected buildBibleGatewayUrl( + bookName: string, + chapter: number, + verses: number[] + ): string { + return `https://www.biblegateway.com/passage/?search=${bookName}+${chapter}:${this.convertVersesToQueryString( + verses + )}&version=${this._versionKey}` } /** @@ -130,7 +136,7 @@ export abstract class BaseBibleAPIProvider { } catch (e) { console.error('error while querying', e) new Notice(`Error while querying ${url}`) - EventStats.logError('errors', {key: url, value: 1}) + EventStats.logError('errors', { key: url, value: 1 }) return await Promise.reject(e) } } diff --git a/src/provider/BibleAPIDotComProvider.ts b/src/provider/BibleAPIDotComProvider.ts index 7c00191..ff43b46 100644 --- a/src/provider/BibleAPIDotComProvider.ts +++ b/src/provider/BibleAPIDotComProvider.ts @@ -26,25 +26,33 @@ export class BibleAPIDotComProvider extends BaseBibleAPIProvider { versionName ? versionName : this?.BibleVersionKey - ? this.BibleVersionKey - : '' + ? this.BibleVersionKey + : '' }` // setup the bible gateway url - this.bibleGatewayUrl = this.buildBibleGatewayUrl(bookName, chapter, verses).replace(/ /g, "+") // Remove spaces in Book names for URL. + this.bibleGatewayUrl = this.buildBibleGatewayUrl( + bookName, + chapter, + verses + ).replace(/ /g, '+') // Remove spaces in Book names for URL. return this._currentQueryUrl } protected prepareVerseLinkUrl(): string { - if (this._versionKey in [ - 'bbe', - 'clementine', - 'oeb-us', - 'oeb-cw', - 'almeida', - 'rccv', - 'cherokee', - ] && !this.bibleGatewayUrl) { + if ( + this._versionKey in + [ + 'bbe', + 'clementine', + 'oeb-us', + 'oeb-cw', + 'almeida', + 'rccv', + 'cherokee', + ] && + !this.bibleGatewayUrl + ) { return this._currentQueryUrl } if (this._versionKey === 'webbe') { diff --git a/src/suggesetor/VerseEditorSuggester.ts b/src/suggesetor/VerseEditorSuggester.ts index 3e3e239..d6d8b20 100644 --- a/src/suggesetor/VerseEditorSuggester.ts +++ b/src/suggesetor/VerseEditorSuggester.ts @@ -22,7 +22,7 @@ export class VerseEditorSuggester extends EditorSuggest { constructor( plugin: BibleReferencePlugin, - settings: BibleReferencePluginSettings, + settings: BibleReferencePluginSettings ) { super(plugin.app) this.plugin = plugin @@ -38,7 +38,7 @@ export class VerseEditorSuggester extends EditorSuggest { onTrigger( cursor: EditorPosition, editor: Editor, - _: TFile, + _: TFile ): EditorSuggestTriggerInfo | null { const currentContent = editor.getLine(cursor.line).substring(0, cursor.ch) @@ -58,7 +58,7 @@ export class VerseEditorSuggester extends EditorSuggest { EventStats.logUIOpen( 'lookupEditorOpen', { key: `${this.settings.bibleVersion}`, value: 1 }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) return { end: cursor, @@ -77,11 +77,11 @@ export class VerseEditorSuggester extends EditorSuggest { * @param context */ async getSuggestions( - context: EditorSuggestContext, + context: EditorSuggestContext ): Promise { const suggestions = await getSuggestionsFromQuery( context.query, - this.settings, + this.settings ) EventStats.logLookup( 'verseLookUp', @@ -89,7 +89,7 @@ export class VerseEditorSuggester extends EditorSuggest { key: `${this.settings.bibleVersion}-${context.query.toLowerCase()}`, value: 1, }, - this.settings.optOutToEvents, + this.settings.optOutToEvents ) return suggestions } diff --git a/src/ui/BibleReferenceSettingTab.ts b/src/ui/BibleReferenceSettingTab.ts index 10db950..f16ab19 100644 --- a/src/ui/BibleReferenceSettingTab.ts +++ b/src/ui/BibleReferenceSettingTab.ts @@ -1,16 +1,35 @@ -import { App, DropdownComponent, Notice, PluginSettingTab, Setting } from 'obsidian' +import { + App, + DropdownComponent, + Notice, + PluginSettingTab, + Setting, +} from 'obsidian' import BibleReferencePlugin from './../main' -import { allBibleVersionsWithLanguageNameAlphabetically, DEFAULT_BIBLE_VERSION } from '../data/BibleVersionCollection' +import { + allBibleVersionsWithLanguageNameAlphabetically, + DEFAULT_BIBLE_VERSION, +} from '../data/BibleVersionCollection' import { IBibleVersion } from '../interfaces/IBibleVersion' import { BibleVerseReferenceLinkPosition, BibleVerseReferenceLinkPositionCollection, } from '../data/BibleVerseReferenceLinkPosition' -import { BibleVerseFormat, BibleVerseFormatCollection } from '../data/BibleVerseFormat' -import { BibleVerseNumberFormat, BibleVerseNumberFormatCollection } from '../data/BibleVerseNumberFormat' +import { + BibleVerseFormat, + BibleVerseFormatCollection, +} from '../data/BibleVerseFormat' +import { + BibleVerseNumberFormat, + BibleVerseNumberFormatCollection, +} from '../data/BibleVerseNumberFormat' import { BibleAPISourceCollection } from '../data/BibleApiSourceCollection' import { EventStats } from '../provider/EventStats' -import { APP_NAMING, BibleVersionNameLengthEnum, OutgoingLinkPositionEnum } from '../data/constants' +import { + APP_NAMING, + BibleVersionNameLengthEnum, + OutgoingLinkPositionEnum, +} from '../data/constants' import { pluginEvent } from '../obsidian/PluginEvent' export class BibleReferenceSettingTab extends PluginSettingTab { @@ -75,7 +94,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logUIOpen( 'settingsOpen', { key: 'open', value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) } @@ -112,9 +131,9 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `book-tagging-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) - }), + }) ) new Setting(this.expertSettingContainer) .setName('Add a Chapter Tag') @@ -128,13 +147,13 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `chapter-tagging-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) - }), + }) ) const getOutgoingLinkPosition = ( - linkingPostion: string | OutgoingLinkPositionEnum | undefined, + linkingPostion: string | OutgoingLinkPositionEnum | undefined ) => { let value = linkingPostion if (!value) { @@ -154,7 +173,7 @@ Obsidian Bible Reference is proudly powered by dropdown.addOption(name, name) }) const value = getOutgoingLinkPosition( - this.plugin.settings?.bookBacklinking, + this.plugin.settings?.bookBacklinking ) dropdown.setValue(value) dropdown.onChange(async (value) => { @@ -167,14 +186,14 @@ Obsidian Bible Reference is proudly powered by new Setting(this.expertSettingContainer) .setName('Add a Chapter Outgoing Links') .setDesc( - 'Makes an outgoing link for the chapter, for example [[John1]] ', + 'Makes an outgoing link for the chapter, for example [[John1]] ' ) .addDropdown((dropdown) => { Object.keys(OutgoingLinkPositionEnum).forEach((name) => { dropdown.addOption(name, name) }) const value = getOutgoingLinkPosition( - this.plugin.settings?.chapterBacklinking, + this.plugin.settings?.chapterBacklinking ) dropdown.setValue(value) dropdown.onChange(async (value) => { @@ -200,7 +219,7 @@ Obsidian Bible Reference is proudly powered by if ( disableBibleAPI && !allAvailableVersionOptions.find( - (v) => v.key === this.plugin.settings.bibleVersion, + (v) => v.key === this.plugin.settings.bibleVersion ) ) { this.plugin.settings.bibleVersion = DEFAULT_BIBLE_VERSION.key @@ -213,7 +232,7 @@ Obsidian Bible Reference is proudly powered by allAvailableVersionOptions.forEach((version: IBibleVersion) => { dropdown.addOption( version.key, - `${version.language} - ${version.versionName} @${version.apiSource.name}`, + `${version.language} - ${version.versionName} @${version.apiSource.name}` ) }) dropdown @@ -227,7 +246,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVersion', { key: value, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -240,20 +259,20 @@ Obsidian Bible Reference is proudly powered by .addDropdown((dropdown: DropdownComponent) => { dropdown.addOption( BibleVersionNameLengthEnum.Full, - BibleVersionNameLengthEnum.Full, + BibleVersionNameLengthEnum.Full ) dropdown.addOption( BibleVersionNameLengthEnum.Short, - BibleVersionNameLengthEnum.Short, + BibleVersionNameLengthEnum.Short ) dropdown.addOption( BibleVersionNameLengthEnum.Hide, - BibleVersionNameLengthEnum.Hide, + BibleVersionNameLengthEnum.Hide ) dropdown .setValue( this.plugin.settings.bibleVersionStatusIndicator ?? - BibleVersionNameLengthEnum.Short, + BibleVersionNameLengthEnum.Short ) .onChange(async (value) => { this.plugin.settings.bibleVersionStatusIndicator = @@ -266,7 +285,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'others', { key: `version-status-indicator-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -280,12 +299,12 @@ Obsidian Bible Reference is proudly powered by BibleVerseReferenceLinkPositionCollection.forEach( ({ name, description }) => { dropdown.addOption(name, description) - }, + } ) dropdown .setValue( this.plugin.settings.referenceLinkPosition ?? - BibleVerseReferenceLinkPosition.None, + BibleVerseReferenceLinkPosition.None ) .onChange(async (value) => { this.plugin.settings.referenceLinkPosition = @@ -296,7 +315,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `link-position-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -306,7 +325,7 @@ Obsidian Bible Reference is proudly powered by new Setting(this.containerEl) .setName('Verse Formatting Options') .setDesc( - 'Sets how to format the verses in Obsidian, either line by line or in 1 paragraph', + 'Sets how to format the verses in Obsidian, either line by line or in 1 paragraph' ) .addDropdown((dropdown: DropdownComponent) => { BibleVerseFormatCollection.forEach(({ name, description }) => { @@ -314,7 +333,7 @@ Obsidian Bible Reference is proudly powered by }) dropdown .setValue( - this.plugin.settings.verseFormatting ?? BibleVerseFormat.SingleLine, + this.plugin.settings.verseFormatting ?? BibleVerseFormat.SingleLine ) .onChange(async (value) => { this.plugin.settings.verseFormatting = value as BibleVerseFormat @@ -324,7 +343,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `verse-format-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -335,7 +354,7 @@ Obsidian Bible Reference is proudly powered by .setName('Show Verse Translation') .setDesc('Show or hide the verse translation in verses reference') setting.setTooltip( - 'This will show the verse translation verse text after the verse number', + 'This will show the verse translation verse text after the verse number' ) setting.addToggle((toggle) => { toggle @@ -346,7 +365,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `show-translation-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -357,7 +376,7 @@ Obsidian Bible Reference is proudly powered by .setName('Enable Hyperlinking') .setDesc('Enable or disable hyperlinking in verses reference') setting.setTooltip( - 'This will make the verse number clickable and will open the verse in the Bible app', + 'This will make the verse number clickable and will open the verse in the Bible app' ) setting.addToggle((toggle) => { toggle @@ -368,7 +387,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `hyperlinking-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -385,7 +404,7 @@ Obsidian Bible Reference is proudly powered by dropdown .setValue( this.plugin.settings.verseNumberFormatting ?? - BibleVerseNumberFormat.Period, + BibleVerseNumberFormat.Period ) .onChange(async (value) => { this.plugin.settings.verseNumberFormatting = @@ -396,7 +415,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `verse-number-format-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -406,10 +425,10 @@ Obsidian Bible Reference is proudly powered by const setting = new Setting(this.containerEl) .setName('Make Verses Collapsible *') .setDesc( - 'Make the rendered verses collapsible, (This option will be disabled if Bible Icon Prefix option above is disabled)', + 'Make the rendered verses collapsible, (This option will be disabled if Bible Icon Prefix option above is disabled)' ) setting.setTooltip( - 'This will make the rendered verses collapsible, so that you can hide them when you don\'t need them', + "This will make the rendered verses collapsible, so that you can hide them when you don't need them" ) setting.addToggle((toggle) => { if (!this.plugin.settings?.displayBibleIconPrefixAtHeader) { @@ -424,7 +443,7 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'changeVerseFormatting', { key: `collapsible-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) }) }) @@ -434,7 +453,7 @@ Obsidian Bible Reference is proudly powered by new Setting(this.containerEl) .setName('Show Bible Icon Prefix "[!Bible]" *') .setDesc( - 'When this is true, it will render a Bible icon in Obsidian, disable this if you want to hide it or use standard Markdown. (This will disable the Collapsible option below)', + 'When this is true, it will render a Bible icon in Obsidian, disable this if you want to hide it or use standard Markdown. (This will disable the Collapsible option below)' ) .addToggle((toggle) => toggle @@ -450,9 +469,9 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'others', { key: `displayBibleIconPrefix-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) - }), + }) ) } @@ -460,7 +479,7 @@ Obsidian Bible Reference is proudly powered by new Setting(this.containerEl) .setName('Expert Settings') .setDesc( - 'Display or Hide Expert Settings, such as Tagging, Linking, Events Logging settings', + 'Display or Hide Expert Settings, such as Tagging, Linking, Events Logging settings' ) .addToggle((toggle) => toggle @@ -470,57 +489,57 @@ Obsidian Bible Reference is proudly powered by await this.plugin.saveSettings() pluginEvent.trigger('bible-reference:settings:advanced', [value]) // todo add event log stats fire - }), + }) ) } private setUpBookTagging(): void { this.expertSettingContainer && - new Setting(this.expertSettingContainer) - .setName('Add a Book Tag') - .setDesc('Add a hidden book tag at bottom, for example #John') - .addToggle((toggle) => - toggle - .setValue(!!this.plugin.settings?.bookTagging) - .onChange(async (value) => { - this.plugin.settings.bookTagging = value - await this.plugin.saveSettings() - EventStats.logSettingChange( - 'changeVerseFormatting', - { key: `book-tagging-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, - ) - }), - ) + new Setting(this.expertSettingContainer) + .setName('Add a Book Tag') + .setDesc('Add a hidden book tag at bottom, for example #John') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.bookTagging) + .onChange(async (value) => { + this.plugin.settings.bookTagging = value + await this.plugin.saveSettings() + EventStats.logSettingChange( + 'changeVerseFormatting', + { key: `book-tagging-${value}`, value: 1 }, + this.plugin.settings.optOutToEvents + ) + }) + ) } private setUpChapterTagging(): void { this.expertSettingContainer && - new Setting(this.expertSettingContainer) - .setName('Add a Chapter Tag') - .setDesc('Add a hidden chapter tag at bottom, for example #John1') - .addToggle((toggle) => - toggle - .setValue(!!this.plugin.settings?.chapterTagging) - .onChange(async (value) => { - this.plugin.settings.chapterTagging = value - await this.plugin.saveSettings() - EventStats.logSettingChange( - 'changeVerseFormatting', - { key: `chapter-tagging-${value}`, value: 1 }, - this.plugin.settings.optOutToEvents, - ) - }), - ) + new Setting(this.expertSettingContainer) + .setName('Add a Chapter Tag') + .setDesc('Add a hidden chapter tag at bottom, for example #John1') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.chapterTagging) + .onChange(async (value) => { + this.plugin.settings.chapterTagging = value + await this.plugin.saveSettings() + EventStats.logSettingChange( + 'changeVerseFormatting', + { key: `chapter-tagging-${value}`, value: 1 }, + this.plugin.settings.optOutToEvents + ) + }) + ) } private setUpOptOutEventsOptions( - container: HTMLElement = this.containerEl, + container: HTMLElement = this.containerEl ): void { new Setting(container) .setName('Opt Out of Events Logging') .setDesc( - 'We used events logging to improve the plugin, this is very helpful for us, but if you want to opt out, you can do it here. (Excluding Errors Logs))', + 'We used events logging to improve the plugin, this is very helpful for us, but if you want to opt out, you can do it here. (Excluding Errors Logs))' ) .addToggle((toggle) => toggle @@ -529,20 +548,20 @@ Obsidian Bible Reference is proudly powered by EventStats.logSettingChange( 'others', { key: `opt-${value ? 'out' : 'in'}`, value: 1 }, - this.plugin.settings.optOutToEvents, + this.plugin.settings.optOutToEvents ) this.plugin.settings.optOutToEvents = value await this.plugin.saveSettings() if (value) { new Notice( - 'You have opted out of events logging, we will not log any events from now on', + 'You have opted out of events logging, we will not log any events from now on' ) } else { new Notice( - 'Thanks for opting in to events logging, this is really valuable for us to improve the plugin', + 'Thanks for opting in to events logging, this is really valuable for us to improve the plugin' ) } - }), + }) ) } } diff --git a/src/utils/getSuggestionsFromQuery.ts b/src/utils/getSuggestionsFromQuery.ts index abb9469..e3e4580 100644 --- a/src/utils/getSuggestionsFromQuery.ts +++ b/src/utils/getSuggestionsFromQuery.ts @@ -16,14 +16,18 @@ export const getSuggestionsFromQuery = async ( console.debug('get suggestion for query ', queryWithoutPrefix.toLowerCase()) const bookNameMatchingResults = queryWithoutPrefix.match(BOOK_REG) - const rawBookName = bookNameMatchingResults?.length ? bookNameMatchingResults[0] : undefined + const rawBookName = bookNameMatchingResults?.length + ? bookNameMatchingResults[0] + : undefined if (!rawBookName) { console.error(`could not find through query`, queryWithoutPrefix) return [] } - const numbersPartsOfQueryString = queryWithoutPrefix.substring(rawBookName.length) + const numbersPartsOfQueryString = queryWithoutPrefix.substring( + rawBookName.length + ) const numbers = numbersPartsOfQueryString.split(/[-:]+/) const chapterNumber = parseInt(numbers[0].trim()) diff --git a/src/utils/regs.ts b/src/utils/regs.ts index de5043d..be1f2e5 100644 --- a/src/utils/regs.ts +++ b/src/utils/regs.ts @@ -4,11 +4,11 @@ * John1:1 * 1John1:1 */ -export const MODAL_REG = /([123])*\s*[A-Z\[\\\]^_`a-z]{2,}\s*\d{1,3}:\d{1,3}(-\d{1,3})*/ +export const MODAL_REG = + /([123])*\s*[A-Z\[\\\]^_`a-z]{2,}\s*\d{1,3}:\d{1,3}(-\d{1,3})*/ export const BOOK_REG = /[123]*\s*[A-Z\[\\\]^_`a-z]{2,}/ - /** * prefix of the trigger * -- diff --git a/src/utils/verseMatch.test.ts b/src/utils/verseMatch.test.ts index d380b54..5a6ccb8 100644 --- a/src/utils/verseMatch.test.ts +++ b/src/utils/verseMatch.test.ts @@ -15,7 +15,6 @@ test('test verse not match', () => { expect(result).toBe('John3:16') }) - test('test trigger prefix', () => { const result = matchTriggerPrefix('--') expect(result).toBe(true) @@ -26,7 +25,6 @@ test('test trigger prefix ++', () => { expect(result).toBe(true) }) - test('test trigger prefix **', () => { const result = matchTriggerPrefix('**') expect(result).toBe(false) diff --git a/src/utils/verseMatch.ts b/src/utils/verseMatch.ts index 9a6b61a..6639113 100644 --- a/src/utils/verseMatch.ts +++ b/src/utils/verseMatch.ts @@ -1,6 +1,5 @@ import { MODAL_REG, DEFAULT_TRIGGER_PREFIX_REG } from './regs' - /** * check if the given string contains a verseNumber, and return the verseNumber if it does * @param verseTrigger without the prefix trigger -- @@ -15,7 +14,6 @@ export const verseMatch = (verseTrigger: string): string => { } } - export const matchTriggerPrefix = (verseTrigger: string): boolean => { return DEFAULT_TRIGGER_PREFIX_REG.test(verseTrigger) } diff --git a/src/verse/BaseVerseFormatter.ts b/src/verse/BaseVerseFormatter.ts index fa9aa77..a5809be 100644 --- a/src/verse/BaseVerseFormatter.ts +++ b/src/verse/BaseVerseFormatter.ts @@ -59,7 +59,11 @@ export abstract class BaseVerseFormatter { text += ' ' + verseNumberFormatted + verse.text.trim().replaceAll('\n', ' ') } else { - text += '> ' + verseNumberFormatted + verse.text.trim().replace(/\r\n|\n|\r/g, " ") + "\n" // Remove extraneous line breaks in KJV verses. + text += + '> ' + + verseNumberFormatted + + verse.text.trim().replace(/\r\n|\n|\r/g, ' ') + + '\n' // Remove extraneous line breaks in KJV verses. } }) console.debug('text', text) @@ -130,7 +134,7 @@ export abstract class BaseVerseFormatter { return verseNumberFormatted case BibleVerseNumberFormat.Bold: verseNumberFormatted += '**' + verseNumber + '** ' - return verseNumberFormatted + return verseNumberFormatted case BibleVerseNumberFormat.None: verseNumberFormatted = ' ' return verseNumberFormatted diff --git a/src/verse/VerseSuggesting.ts b/src/verse/VerseSuggesting.ts index 731f6b8..d739320 100644 --- a/src/verse/VerseSuggesting.ts +++ b/src/verse/VerseSuggesting.ts @@ -56,11 +56,12 @@ export class VerseSuggesting if (this.settings?.bookTagging || this.settings?.chapterTagging) { bottom += ' %%' bottom += this.settings?.bookTagging - ? ` #${this.verseReference.bookName.replace(/ /g, "")}` // Remove spaces from book names in tags + ? ` #${this.verseReference.bookName.replace(/ /g, '')}` // Remove spaces from book names in tags : '' bottom += this.settings?.chapterTagging ? ` #${ - this.verseReference.bookName.replace(/ /g, "") + this.verseReference.chapterNumber // Remove spaces from book names in tags + this.verseReference.bookName.replace(/ /g, '') + + this.verseReference.chapterNumber // Remove spaces from book names in tags }` : '' bottom += ' %%' @@ -123,14 +124,29 @@ export class VerseSuggesting protected getVerseReferenceLink(): string { let verseLink = '' - if (this.settings?.showVerseTranslation && this.settings?.enableHyperlinking) { - verseLink = ` [${this.bibleProvider.BibleReferenceHead} - ${this.bibleVersion.toUpperCase()}](${this.bibleProvider.VerseLinkURL})` - } else if (this.settings?.showVerseTranslation && !this.settings?.enableHyperlinking) { - verseLink = ` ${this.bibleProvider.BibleReferenceHead} - ${this.bibleVersion.toUpperCase()}` - } else if (!this.settings?.showVerseTranslation && this.settings?.enableHyperlinking) { + if ( + this.settings?.showVerseTranslation && + this.settings?.enableHyperlinking + ) { + verseLink = ` [${ + this.bibleProvider.BibleReferenceHead + } - ${this.bibleVersion.toUpperCase()}](${ + this.bibleProvider.VerseLinkURL + })` + } else if ( + this.settings?.showVerseTranslation && + !this.settings?.enableHyperlinking + ) { + verseLink = ` ${ + this.bibleProvider.BibleReferenceHead + } - ${this.bibleVersion.toUpperCase()}` + } else if ( + !this.settings?.showVerseTranslation && + this.settings?.enableHyperlinking + ) { verseLink = ` [${this.bibleProvider.BibleReferenceHead}](${this.bibleProvider.VerseLinkURL})` } else { - verseLink = ` ${this.bibleProvider.BibleReferenceHead}` + verseLink = ` ${this.bibleProvider.BibleReferenceHead}` } return verseLink } diff --git a/styles.css b/styles.css index dbefb7c..d08a157 100644 --- a/styles.css +++ b/styles.css @@ -9,12 +9,10 @@ padding: 1em; } - .sponsor-button { - margin-right: 2em + margin-right: 2em; } - .logo { - height:16px + height: 16px; }