Skip to content

Commit

Permalink
Merge pull request #163 from tim-hub/option-to-disable-icon
Browse files Browse the repository at this point in the history
option to disable icon
  • Loading branch information
tim-hub committed Dec 20, 2023
2 parents 29bd91c + b51649f commit 7cf9499
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 62 deletions.
6 changes: 6 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "semver"
version_provider = "npm"
update_changelog_on_bump = true
4 changes: 3 additions & 1 deletion src/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface BibleReferencePluginSettings {
referenceLinkPosition?: BibleVerseReferenceLinkPosition
verseFormatting?: BibleVerseFormat
verseNumberFormatting?: BibleVerseNumberFormat
collapsibleVerses?: boolean
collapsibleVerses?: boolean // this is binging to displayBibleIconPrefixAtHeader option
bookTagging?: boolean
chapterTagging?: boolean
bookBacklinking?: OutgoingLinkPositionEnum // this is refering to outgoing link
Expand All @@ -39,6 +39,7 @@ export interface BibleReferencePluginSettings {

advancedSettings?: boolean
bibleVersionStatusIndicator?: BibleVersionNameLengthEnum
displayBibleIconPrefixAtHeader?: boolean // this is binding to to header collapsible option
}

export const DEFAULT_SETTINGS: BibleReferencePluginSettings = {
Expand All @@ -54,6 +55,7 @@ export const DEFAULT_SETTINGS: BibleReferencePluginSettings = {
bookBacklinking: OutgoingLinkPositionEnum.None,
chapterBacklinking: OutgoingLinkPositionEnum.None,
bibleVersionStatusIndicator: BibleVersionNameLengthEnum.Short,
displayBibleIconPrefixAtHeader: true,
}

export const API_WAITING_LABEL = 'Loading...'
153 changes: 95 additions & 58 deletions src/ui/BibleReferenceSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
<iframe src="https://github.com/sponsors/tim-hub/button" title="Sponsor Obsidian Bible Reference" width="116" height="32px" style="margin-right: 2em"/>
`

this.containerEl.createEl('h1', { text: APP_NAMING.appName })
this.containerEl.createEl('h1', {text: APP_NAMING.appName})
this.setUpVersionSettingsAndVersionOptions()

this.containerEl.createEl('h2', { text: 'Verses Rendering' })
this.containerEl.createEl('h2', {text: 'Verses Rendering'})
this.setUpReferenceLinkPositionOptions()
this.setUpVerseFormatOptions()
this.setUpVerseNumberFormatOptions()
this.setUpCollapsible()
this.setUpBibleIconPrefixToggle()
this.setUpCollapsibleToggle()
this.setUpStatusIndicationOptions()
this.containerEl.createEl('h2', { text: 'Others' })
this.containerEl.createEl('h2', {text: 'Others'})
this.setUpExpertSettings()

this.containerEl.createSpan({}, (span) => {
Expand All @@ -77,7 +78,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
}
EventStats.logUIOpen(
'settingsOpen',
{ key: 'open', value: 1 },
{key: 'open', value: 1},
this.plugin.settings.optOutToEvents
)
}
Expand All @@ -91,12 +92,17 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
this?.expertSettingContainer && this.expertSettingContainer.empty()
}
})

pluginEvent.on('bible-reference:settings:re-render', (value: boolean) => {
console.log('re-render', value)
this.display()
})
}

private displayExpertSettings(): void {
if (this.expertSettingContainer) {
this.expertSettingContainer.empty()
this.expertSettingContainer.createEl('h2', { text: 'Expert Settings' })
this.expertSettingContainer.createEl('h2', {text: 'Expert Settings'})

new Setting(this.expertSettingContainer)
.setName('Add a Book Tag')
Expand All @@ -109,7 +115,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
await this.plugin.saveSettings()
EventStats.logSettingChange(
'changeVerseFormatting',
{ key: `book-tagging-${value}`, value: 1 },
{key: `book-tagging-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand All @@ -125,7 +131,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
await this.plugin.saveSettings()
EventStats.logSettingChange(
'changeVerseFormatting',
{ key: `chapter-tagging-${value}`, value: 1 },
{key: `chapter-tagging-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand Down Expand Up @@ -225,7 +231,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
new Notice(`Bible Reference - use Version ${value.toUpperCase()}`)
EventStats.logSettingChange(
'changeVersion',
{ key: value, value: 1 },
{key: value, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand All @@ -252,7 +258,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
dropdown
.setValue(
this.plugin.settings.bibleVersionStatusIndicator ??
BibleVersionNameLengthEnum.Short
BibleVersionNameLengthEnum.Short
)
.onChange(async (value) => {
this.plugin.settings.bibleVersionStatusIndicator =
Expand All @@ -264,7 +270,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
])
EventStats.logSettingChange(
'others',
{ key: `version-status-indicator-${value}`, value: 1 },
{key: `version-status-indicator-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand All @@ -277,14 +283,14 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
.setDesc('Where to put the reference link of the Bible')
.addDropdown((dropdown: DropdownComponent) => {
BibleVerseReferenceLinkPositionCollection.forEach(
({ name, description }) => {
({name, description}) => {
dropdown.addOption(name, description)
}
)
dropdown
.setValue(
this.plugin.settings.referenceLinkPosition ??
BibleVerseReferenceLinkPosition.None
BibleVerseReferenceLinkPosition.None
)
.onChange(async (value) => {
this.plugin.settings.referenceLinkPosition =
Expand All @@ -294,7 +300,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
new Notice('Bible Reference Settings Updated ')
EventStats.logSettingChange(
'changeVerseFormatting',
{ key: `link-position-${value}`, value: 1 },
{key: `link-position-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand All @@ -308,7 +314,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
'Sets how to format the verses in Obsidian, either line by line or in 1 paragraph'
)
.addDropdown((dropdown: DropdownComponent) => {
BibleVerseFormatCollection.forEach(({ name, description }) => {
BibleVerseFormatCollection.forEach(({name, description}) => {
dropdown.addOption(name, description)
})
dropdown
Expand All @@ -322,7 +328,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
new Notice('Bible Verse Format Settings Updated')
EventStats.logSettingChange(
'changeVerseFormatting',
{ key: `verse-format-${value}`, value: 1 },
{key: `verse-format-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand All @@ -334,13 +340,13 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
.setName('Verse Number Formatting Options')
.setDesc('Sets how to format the verse numbers in Obsidian')
.addDropdown((dropdown: DropdownComponent) => {
BibleVerseNumberFormatCollection.forEach(({ name, description }) => {
BibleVerseNumberFormatCollection.forEach(({name, description}) => {
dropdown.addOption(name, description)
})
dropdown
.setValue(
this.plugin.settings.verseNumberFormatting ??
BibleVerseNumberFormat.Period
BibleVerseNumberFormat.Period
)
.onChange(async (value) => {
this.plugin.settings.verseNumberFormatting =
Expand All @@ -350,26 +356,57 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
new Notice('Bible Verse Format Number Settings Updated')
EventStats.logSettingChange(
'changeVerseFormatting',
{ key: `verse-number-format-${value}`, value: 1 },
{key: `verse-number-format-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
})
}

private setUpCollapsible(): void {
new Setting(this.containerEl)
.setName('Make Verses Collapsible')
.setDesc('Make the rendered verses collapsible')
.addToggle((toggle) =>
private setUpCollapsibleToggle(): void {
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)')
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)
.onChange(async (value) => {
this.plugin.settings.collapsibleVerses = value
await this.plugin.saveSettings()
EventStats.logSettingChange(
'changeVerseFormatting',
{ key: `collapsible-${value}`, value: 1 },
{key: `collapsible-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
}
)

}

private setUpBibleIconPrefixToggle(): void {
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)')
.addToggle((toggle) =>
toggle
.setValue(!!this.plugin.settings?.displayBibleIconPrefixAtHeader)
.onChange(async (value) => {
this.plugin.settings.displayBibleIconPrefixAtHeader = value
await this.plugin.saveSettings()
if (!value) {
this.plugin.settings.collapsibleVerses = false
await this.plugin.saveSettings()
}
pluginEvent.trigger('bible-reference:settings:re-render', [])
EventStats.logSettingChange(
'others',
{key: `displayBibleIconPrefix-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
Expand All @@ -396,42 +433,42 @@ export class BibleReferenceSettingTab extends PluginSettingTab {

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(
Expand All @@ -448,7 +485,7 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
.onChange(async (value) => {
EventStats.logSettingChange(
'others',
{ key: `opt-${value ? 'out' : 'in'}`, value: 1 },
{key: `opt-${value ? 'out' : 'in'}`, value: 1},
this.plugin.settings.optOutToEvents
)
this.plugin.settings.optOutToEvents = value
Expand Down
12 changes: 9 additions & 3 deletions src/verse/BaseVerseFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ export abstract class BaseVerseFormatter {
}

protected get head(): string {
let head = `> [!bible]`
let head = `> `

if (this.settings.displayBibleIconPrefixAtHeader) {
head += '[!bible]'

if (this.settings?.collapsibleVerses) {
head += '+'
}

if (this.settings?.collapsibleVerses) {
head += '+'
}

if (
this.settings.referenceLinkPosition ===
BibleVerseReferenceLinkPosition.Header ||
Expand Down

0 comments on commit 7cf9499

Please sign in to comment.