diff --git a/src/data/CollapsibleVerses.ts b/src/data/CollapsibleVerses.ts
new file mode 100644
index 0000000..66d3e59
--- /dev/null
+++ b/src/data/CollapsibleVerses.ts
@@ -0,0 +1,20 @@
+export enum CollapsibleVerses {
+ Plus = '+',
+ Minus = '-',
+ None = 'None'
+}
+
+export const CollapsibleVersesCollection = [
+ {
+ name: CollapsibleVerses.Plus,
+ description: 'Plus',
+ },
+ {
+ name: CollapsibleVerses.Minus,
+ description: 'Minus',
+ },
+ {
+ name: CollapsibleVerses.None,
+ description: 'None',
+ },
+]
diff --git a/src/data/constants.ts b/src/data/constants.ts
index a85641a..2be071a 100644
--- a/src/data/constants.ts
+++ b/src/data/constants.ts
@@ -2,6 +2,7 @@ import { DEFAULT_BIBLE_VERSION } from './BibleVersionCollection'
import { BibleVerseReferenceLinkPosition } from './BibleVerseReferenceLinkPosition'
import { BibleVerseFormat } from './BibleVerseFormat'
import { BibleVerseNumberFormat } from './BibleVerseNumberFormat'
+import { CollapsibleVerses } from './CollapsibleVerses'
export const APP_NAMING = {
appName: 'Bible Reference',
@@ -28,7 +29,7 @@ export interface BibleReferencePluginSettings {
referenceLinkPosition?: BibleVerseReferenceLinkPosition
verseFormatting?: BibleVerseFormat
verseNumberFormatting?: BibleVerseNumberFormat
- collapsibleVerses?: boolean // this is binging to displayBibleIconPrefixAtHeader option
+ collapsibleVerses?: CollapsibleVerses // this is binging to displayBibleIconPrefixAtHeader option
enableHyperlinking?: boolean
showVerseTranslation?: boolean
bookTagging?: boolean
@@ -51,7 +52,7 @@ export const DEFAULT_SETTINGS: BibleReferencePluginSettings = {
referenceLinkPosition: BibleVerseReferenceLinkPosition.Header,
verseFormatting: BibleVerseFormat.SingleLine,
verseNumberFormatting: BibleVerseNumberFormat.Period,
- collapsibleVerses: false,
+ collapsibleVerses: CollapsibleVerses.Plus,
enableHyperlinking: true,
showVerseTranslation: true,
bookTagging: false,
@@ -61,7 +62,7 @@ export const DEFAULT_SETTINGS: BibleReferencePluginSettings = {
bookBacklinking: OutgoingLinkPositionEnum.None,
chapterBacklinking: OutgoingLinkPositionEnum.None,
bibleVersionStatusIndicator: BibleVersionNameLengthEnum.Short,
- displayBibleIconPrefixAtHeader: true,
+ displayBibleIconPrefixAtHeader: true
}
export const API_WAITING_LABEL = 'Loading...'
diff --git a/src/main.ts b/src/main.ts
index 657eb6e..16d2401 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -60,6 +60,9 @@ export default class BibleReferencePlugin extends Plugin {
this.addVerseOfDayInsertCommand()
this.addVerseOfDayNoticeCommand()
+ // toggle bible icon prefix
+ this.toggleBibleIconPrefix()
+
this.initStatusBarIndicator()
EventStats.logRecord(this.settings.optOutToEvents)
}
@@ -154,6 +157,17 @@ export default class BibleReferencePlugin extends Plugin {
})
}
+ private toggleBibleIconPrefix() {
+ this.addCommand({
+ id: 'toggle-bible-icon-prefix',
+ name: 'Toggle Bible Icon Prefix',
+ callback: () => {
+ this.settings.displayBibleIconPrefixAtHeader = !this.settings.displayBibleIconPrefixAtHeader
+ this.saveSettings()
+ },
+ })
+ }
+
private addRibbonButton(): void {
// https://lucide.dev/icons/?search=book
// Obsidian use Lucide Icons
diff --git a/src/ui/BibleReferenceSettingTab.ts b/src/ui/BibleReferenceSettingTab.ts
index 5bf95b3..20f7788 100644
--- a/src/ui/BibleReferenceSettingTab.ts
+++ b/src/ui/BibleReferenceSettingTab.ts
@@ -23,6 +23,10 @@ import {
BibleVerseNumberFormat,
BibleVerseNumberFormatCollection,
} from '../data/BibleVerseNumberFormat'
+import {
+ CollapsibleVerses,
+ CollapsibleVersesCollection,
+} from '../data/CollapsibleVerses'
import { BibleAPISourceCollection } from '../data/BibleApiSourceCollection'
import { EventStats } from '../provider/EventStats'
import {
@@ -61,7 +65,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
this.setUpVerseFormatOptions()
this.setUpVerseNumberFormatOptions()
this.setUpBibleIconPrefixToggle()
- this.setUpCollapsibleToggle()
+ this.setUpCollapsibleOptions()
this.setUpStatusIndicationOptions()
this.containerEl.createEl('h2', { text: 'Others' })
this.setUpExpertSettings()
@@ -422,28 +426,27 @@ Obsidian Bible Reference is proudly powered by
})
}
- private setUpCollapsibleToggle(): void {
- const setting = new Setting(this.containerEl)
+ private setUpCollapsibleOptions(): void {
+ 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)'
- )
- setting.setTooltip(
- "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) {
- toggle.setDisabled(true)
- toggle.setTooltip('')
- }
- toggle
- .setValue(!!this.plugin.settings?.collapsibleVerses)
+ .setDesc('Set how the rendered verses collapse, (This option will be disabled if Bible Icon Prefix option above is disabled)')
+ .setTooltip("'+' will make the callout be expanded on default. '-' will make the callout be collapsed by default. 'None' removes that options entirely")
+ .addDropdown((dropdown: DropdownComponent) => {
+ CollapsibleVersesCollection.forEach(({ name, description }) => {
+ dropdown.addOption(name, description)
+ })
+ dropdown
+ .setValue(
+ this.plugin.settings.collapsibleVerses ?? CollapsibleVerses.Plus
+ )
.onChange(async (value) => {
- this.plugin.settings.collapsibleVerses = value
+ this.plugin.settings.collapsibleVerses = value as CollapsibleVerses
+ console.debug('Bible Verse Collapsible To: ' + value)
await this.plugin.saveSettings()
+ new Notice('Bible Verse Collapsible Settings Updated')
EventStats.logSettingChange(
'changeVerseFormatting',
- { key: `collapsible-${value}`, value: 1 },
+ { key: `collapsible-verses-${value}`, value: 1 },
this.plugin.settings.optOutToEvents
)
})
@@ -463,7 +466,7 @@ Obsidian Bible Reference is proudly powered by
this.plugin.settings.displayBibleIconPrefixAtHeader = value
await this.plugin.saveSettings()
if (!value) {
- this.plugin.settings.collapsibleVerses = false
+ this.plugin.settings.collapsibleVerses = CollapsibleVerses.None
await this.plugin.saveSettings()
}
pluginEvent.trigger('bible-reference:settings:re-render', [])
diff --git a/src/verse/BaseVerseFormatter.ts b/src/verse/BaseVerseFormatter.ts
index a5809be..8c632c3 100644
--- a/src/verse/BaseVerseFormatter.ts
+++ b/src/verse/BaseVerseFormatter.ts
@@ -4,6 +4,7 @@ import { BibleVerseNumberFormat } from '../data/BibleVerseNumberFormat'
import { VerseReference } from '../utils/splitBibleReference'
import { BibleVerseFormat } from '../data/BibleVerseFormat'
import { IVerse } from '../interfaces/IVerse'
+import { CollapsibleVerses } from 'src/data/CollapsibleVerses'
export abstract class BaseVerseFormatter {
protected settings: BibleReferencePluginSettings
@@ -53,17 +54,19 @@ export abstract class BaseVerseFormatter {
} else {
text = ''
}
- this.verses.forEach((verse) => {
+ this.verses.forEach((verse, index) => {
+ let singleVerseText = verse.text.trim()
+ if (
+ index === this.verses!.length - 1 &&
+ singleVerseText.endsWith('
') // Remove the last
tag that appears in LSB verses.
+ ) {
+ singleVerseText = singleVerseText.slice(0, -5)
+ }
const verseNumberFormatted = this.formatVerseNumber(verse.verse)
if (this.settings?.verseFormatting === BibleVerseFormat.Paragraph) {
- text +=
- ' ' + verseNumberFormatted + verse.text.trim().replaceAll('\n', ' ')
+ text += ' ' + verseNumberFormatted + singleVerseText.replaceAll('\n', ' ')
} else {
- text +=
- '> ' +
- verseNumberFormatted +
- verse.text.trim().replace(/\r\n|\n|\r/g, ' ') +
- '\n' // Remove extraneous line breaks in KJV verses.
+ text += '> ' + verseNumberFormatted + singleVerseText.replace(/\r\n|\n|\r/g, ' ') + '\n' // Remove extraneous line breaks in KJV verses.
}
})
console.debug('text', text)
@@ -76,8 +79,16 @@ export abstract class BaseVerseFormatter {
if (this.settings.displayBibleIconPrefixAtHeader) {
head += '[!bible]'
- if (this.settings?.collapsibleVerses) {
- head += '+'
+ switch (this.settings?.collapsibleVerses) {
+ case CollapsibleVerses.Plus:
+ head += '+'
+ break
+ case CollapsibleVerses.Minus:
+ head += '-'
+ break
+ case CollapsibleVerses.None:
+ head += ''
+ break
}
}