PR-17 - Fixed a minor bug where the full text for multi-chapter references wasn't being displayed in the passage preview and updated a few just stylistic things.

This commit is contained in:
Caleb Campbell
2026-02-10 09:01:50 +11:00
parent 30b9a60baf
commit 7f2c2589f3
9 changed files with 53 additions and 86 deletions

View File

@@ -40,9 +40,9 @@ export default class LocalBibleRefPlugin extends Plugin {
defaultVersionShorthand: '', defaultVersionShorthand: '',
defaultPassageFormat: PassageFormat.Callout, defaultPassageFormat: PassageFormat.Callout,
bibleFormat: BibleFormat.LocalBibleRef, bibleFormat: BibleFormat.LocalBibleRef,
fullPreview: false,
quote: quoteSettings, quote: quoteSettings,
callout: calloutSettings, callout: calloutSettings,
fullSuggestion: true
}; };
if (!this.settings.quote) this.settings.quote = quoteSettings; if (!this.settings.quote) this.settings.quote = quoteSettings;

View File

@@ -1,6 +1,6 @@
{ {
"name": "local-bible-ref", "name": "local-bible-ref",
"version": "1.3.2", "version": "1.2.2",
"description": "Quickly and easily reference Bible passages stored locally in your Obsidian vault.", "description": "Quickly and easily reference Bible passages stored locally in your Obsidian vault.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@@ -39,6 +39,11 @@ export const SETTINGS_LABELS: SettingsLabels = {
description: description:
'Der Formatierungsstil, den Sie für Ihre Vault-Bibeln verwenden. Local Bible Ref benötigt diesen, um Textpassagen korrekt zu analysieren.', 'Der Formatierungsstil, den Sie für Ihre Vault-Bibeln verwenden. Local Bible Ref benötigt diesen, um Textpassagen korrekt zu analysieren.',
}, },
fullPreview: {
name: 'Vollständige Passage-Vorschau',
description:
'Ob in der Vorschau der vollständige Text oder nur ein Ausschnitt angezeigt werden soll.',
},
}, },
}, },
@@ -89,18 +94,6 @@ export const SETTINGS_LABELS: SettingsLabels = {
}, },
}, },
suggestionFormat: {
name: 'Einstellungen für das Vorschlagsformat',
description: 'Einstellungen für das Format des Hinweistextes.',
controls: {
full: {
name: 'Vollständiger Vorschlag',
description:
'Ob der für die Passage vorgeschlagene Hinweis vollständig ist.',
},
},
},
issues: { issues: {
before: before:
'Falls Sie Probleme mit Local Bible Ref feststellen oder Verbesserungsvorschläge haben, ', 'Falls Sie Probleme mit Local Bible Ref feststellen oder Verbesserungsvorschläge haben, ',

View File

@@ -38,6 +38,11 @@ export const SETTINGS_LABELS: SettingsLabels = {
description: description:
'The formatting style you use for your vault bibles. Local Bible Ref relies on this to parse passages correctly.', 'The formatting style you use for your vault bibles. Local Bible Ref relies on this to parse passages correctly.',
}, },
fullPreview: {
name: 'Full Passage Preview',
description:
'Whether to display the full passage in the preview rather than just a snippet.',
},
}, },
}, },
@@ -87,19 +92,6 @@ export const SETTINGS_LABELS: SettingsLabels = {
}, },
}, },
suggestionFormat: {
name: 'Suggestion Format Settings',
description: 'Settings for the callout suggestion passage format.',
controls: {
full: {
name: 'Full Suggestion',
description:
'Whether the callout suggestion to use for the passage is full.',
},
},
},
issues: { issues: {
before: before:
'If you find any issues with Local Bible Ref or have suggestions for improvements, please ', 'If you find any issues with Local Bible Ref or have suggestions for improvements, please ',

View File

@@ -38,6 +38,10 @@ export const SETTINGS_LABELS: SettingsLabels = {
description: description:
'보관된 성경에 사용하는 서식 스타일입니다. Local Bible Ref는 이 스타일을 기반으로 구절을 정확하게 분석합니다.', '보관된 성경에 사용하는 서식 스타일입니다. Local Bible Ref는 이 스타일을 기반으로 구절을 정확하게 분석합니다.',
}, },
fullPreview: {
name: '전체 구절 미리보기',
description: '미리보기에서 전체 내용을 표시할지, 아니면 일부만 표시할지 여부.',
},
}, },
}, },
@@ -84,18 +88,6 @@ export const SETTINGS_LABELS: SettingsLabels = {
}, },
}, },
suggestionFormat: {
name: '제안 형식 설정',
description: '콜아웃 제안 문구 형식에 대한 설정입니다.',
controls: {
full: {
name: '전체 제안',
description:
'본문에 사용할 콜아웃 제안이 완전한지 여부.',
},
},
},
issues: { issues: {
before: before:
'Local Bible Ref에 문제가 있거나 개선 사항에 대한 제안이 있는 경우, ', 'Local Bible Ref에 문제가 있거나 개선 사항에 대한 제안이 있는 경우, ',

View File

@@ -33,6 +33,7 @@ export interface SettingsLabels {
}; };
}; };
bibleFormat: Control; bibleFormat: Control;
fullPreview: Control;
}; };
}; };
@@ -61,14 +62,6 @@ export interface SettingsLabels {
}; };
}; };
suggestionFormat: {
name: string;
description: string;
controls: {
full: Control;
};
};
issues: { issues: {
before: string; before: string;
link: string; link: string;

View File

@@ -45,7 +45,7 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
display(): void { display(): void {
const { containerEl } = this; const { containerEl } = this;
const { required, optional, quoteFormat, calloutFormat, suggestionFormat, issues } = const { required, optional, quoteFormat, calloutFormat, issues } =
this.settingsLabels; this.settingsLabels;
containerEl.empty(); containerEl.empty();
@@ -87,6 +87,8 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
new PathSuggest(this.app, text.inputEl); new PathSuggest(this.app, text.inputEl);
}); });
// optional settings ---
new Setting(containerEl).setName(optional.name).setHeading(); new Setting(containerEl).setName(optional.name).setHeading();
let defaultVersionTimeout: number; let defaultVersionTimeout: number;
@@ -150,6 +152,20 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
}) })
); );
new Setting(containerEl)
.setName(optional.controls.fullPreview.name)
.setDesc(optional.controls.fullPreview.description)
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.fullPreview)
.onChange(async (value) => {
this.plugin.settings.fullPreview = value;
await this.plugin.saveSettings();
})
);
// quote format settings ---
new Setting(containerEl) new Setting(containerEl)
.setName(quoteFormat.name) .setName(quoteFormat.name)
.setDesc(quoteFormat.description) .setDesc(quoteFormat.description)
@@ -210,7 +226,8 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
quoteRefLinkSetting.settingEl.addClass(this.hiddenClass); quoteRefLinkSetting.settingEl.addClass(this.hiddenClass);
} }
// callout format
// callout format settings ---
new Setting(containerEl) new Setting(containerEl)
.setName(calloutFormat.name) .setName(calloutFormat.name)
.setDesc(calloutFormat.description) .setDesc(calloutFormat.description)
@@ -267,24 +284,6 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
}) })
); );
//suggestion format
new Setting(containerEl)
.setName(suggestionFormat.name)
.setDesc(suggestionFormat.description)
.setHeading();
new Setting(containerEl)
.setName(suggestionFormat.controls.full.name)
.setDesc(suggestionFormat.controls.full.description)
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.fullSuggestion)
.onChange(async (value) => {
this.plugin.settings.fullSuggestion = value;
await this.plugin.saveSettings();
})
);
const issuesLink = document.createElement('a'); const issuesLink = document.createElement('a');
issuesLink.href = 'https://github.com/camelChief/local-bible-ref/issues'; issuesLink.href = 'https://github.com/camelChief/local-bible-ref/issues';
issuesLink.textContent = issues.link; issuesLink.textContent = issues.link;

View File

@@ -117,7 +117,8 @@ export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
}); });
// suggest // suggest
const excerpt = this.generateExcerpt(texts[0]); const fullText = texts.join('\n\n');
const excerpt = this.generateExcerpt(fullText);
const text = this.formatTexts(texts, passageRef, context); const text = this.formatTexts(texts, passageRef, context);
return [{ excerpt, text }]; return [{ excerpt, text }];
} }
@@ -295,26 +296,24 @@ export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
/** Generates an excerpt for the suggestion. */ /** Generates an excerpt for the suggestion. */
private generateExcerpt(text: string): string { private generateExcerpt(text: string): string {
if(this.settings.fullSuggestion){ const fullPreview = this.settings.fullPreview;
text = text.replace(/(?:<sup>)/g, ""); if (fullPreview) {
text = text.replace(/(?:<\/sup>)/g, ""); text = text.replace(/<sup>/g, '');
} text = text.replace(/<\/sup>/g, '');
else{ } else {
text = text.split(/<\/sup>/, 2)[1]; text = text.split(/<\/sup>/, 2)[1];
text = text.replace(/<sup>\d+<\/sup>/g, ""); text = text.replace(/<sup>\d+<\/sup>/g, '');
text = text.replace(/^(?:> |- )/gm, ""); text = text.replace(/^(?:> |- )/gm, '');
} }
text = text.replace( text = text.replace(
/<span(?:\s+\w+=['"][^'"]+['"])*>([^<]+)<\/span>/g, /<span(?:\s+\w+=['"][^'"]+['"])*>([^<]+)<\/span>/g,
"$1" '$1'
); );
if(!this.settings.fullSuggestion) if (!fullPreview) text = text.replace(/\n/g, ' ');
text = text.replace(/\n/g, ' '); text = text.replace(/ {2,}/g, ' ');
text = text.replace(/ {2,}/g, " "); if (fullPreview) return text;
if (this.settings.fullSuggestion) return text.slice(0, 45) + '...';
return text;
return text.slice(0, 45) + "...";
} }
/** Formats the final text for suggestion. */ /** Formats the final text for suggestion. */
@@ -362,15 +361,14 @@ export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
break; break;
} }
case PassageFormat.Callout: { case PassageFormat.Callout: {
const { type, linkToPassage } = this.settings.callout; const { type, linkToPassage, collapsible } = this.settings.callout;
let stringRef = ''; let stringRef = '';
if (linkToPassage) if (linkToPassage)
stringRef = this.generatePassageLink(passageRef, context); stringRef = this.generatePassageLink(passageRef, context);
else stringRef = passageRef.stringify(); else stringRef = passageRef.stringify();
formatted = `> [!quote]${this.settings.callout.collapsible? '+' : ''} ${stringRef}\n`;
formatted = `> [!${type}]${this.settings.callout.collapsible? '+' : ''} ${stringRef}\n`; formatted = `> [!${type}]${collapsible ? '+' : ''} ${stringRef}\n`;
formatted += texts.join('\n\n').trim(); formatted += texts.join('\n\n').trim();
formatted = formatted.replace(/\n/gm, '\n> '); formatted = formatted.replace(/\n/gm, '\n> ');
formatted += '\n\n'; formatted += '\n\n';

View File

@@ -6,6 +6,7 @@ export default interface LocalBibleRefSettings {
defaultVersionShorthand: string; defaultVersionShorthand: string;
defaultPassageFormat: PassageFormat; defaultPassageFormat: PassageFormat;
bibleFormat: BibleFormat; bibleFormat: BibleFormat;
fullPreview: boolean;
quote: { quote: {
includeReference: boolean; includeReference: boolean;
referencePosition: QuoteReferencePosition; referencePosition: QuoteReferencePosition;
@@ -16,7 +17,6 @@ export default interface LocalBibleRefSettings {
linkToPassage: boolean; linkToPassage: boolean;
collapsible: boolean; collapsible: boolean;
}; };
fullSuggestion: boolean;
} }
export enum QuoteReferencePosition { export enum QuoteReferencePosition {