mirror of
https://github.com/scotttomaszewski/obsidian-disciples-journal.git
synced 2026-07-22 05:42:13 +00:00
Comamnd to open the bible now does so in a new tab
This commit is contained in:
parent
3bfd78d90c
commit
dadcef7bc1
3 changed files with 14 additions and 5 deletions
|
|
@ -6,6 +6,11 @@ header text is **exactly** the release tag (no leading `v`).
|
|||
|
||||
## Unreleased
|
||||
|
||||
- The "Open Bible" command (and ribbon icon) now opens the chosen chapter in a new tab
|
||||
instead of replacing the note you were reading
|
||||
|
||||
## 1.14.0
|
||||
|
||||
- Adds verse selection: tap verses in a rendered passage to select them (shift-click or
|
||||
long-press-drag for a range), then copy or insert them as an inline reference, a `bible`
|
||||
code block, or a blockquote of the verse text. A floating action bar (docked at the
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export class OpenBibleModal extends SuggestModal<BibleTarget> {
|
|||
if (chapterCount === 1) {
|
||||
// Single-chapter book, open directly
|
||||
const loadingNotice = new Notice("Loading chapter...", 0);
|
||||
await this.bibleFiles.openChapterNote(new BibleReference(item.book, 1));
|
||||
await this.bibleFiles.openChapterNote(new BibleReference(item.book, 1), true);
|
||||
loadingNotice.hide();
|
||||
} else {
|
||||
// Reopen for chapter selection
|
||||
|
|
@ -77,7 +77,7 @@ export class OpenBibleModal extends SuggestModal<BibleTarget> {
|
|||
}
|
||||
} else {
|
||||
const loadingNotice = new Notice("Loading chapter...", 0);
|
||||
await this.bibleFiles.openChapterNote(new BibleReference(item.book, item.chapter));
|
||||
await this.bibleFiles.openChapterNote(new BibleReference(item.book, item.chapter), true);
|
||||
loadingNotice.hide();
|
||||
}
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ class OpenBibleChapterModal extends SuggestModal<BibleTarget> {
|
|||
|
||||
private async openChapter(item: BibleTarget): Promise<void> {
|
||||
const loadingNotice = new Notice("Loading chapter...", 0);
|
||||
await this.bibleFiles.openChapterNote(new BibleReference(item.book, item.chapter));
|
||||
await this.bibleFiles.openChapterNote(new BibleReference(item.book, item.chapter), true);
|
||||
loadingNotice.hide();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,8 +67,12 @@ export class BibleFiles {
|
|||
* Open a chapter note for the given reference, creating it from the API first
|
||||
* if it isn't on disk yet. If the reference includes a verse, the note is
|
||||
* scrolled to that verse once it renders.
|
||||
*
|
||||
* Pass `openInNewTab` to open the chapter in a fresh tab instead of reusing
|
||||
* the active leaf (used by the "Open Bible" command so it never replaces the
|
||||
* note the user is reading).
|
||||
*/
|
||||
public async openChapterNote(reference: BibleReference): Promise<void> {
|
||||
public async openChapterNote(reference: BibleReference, openInNewTab = false): Promise<void> {
|
||||
try {
|
||||
const chapterPath = BibleFiles.pathForPassage(reference, this.plugin);
|
||||
if (!BibleFiles.fileExistsForPassage(reference, this.plugin)) {
|
||||
|
|
@ -89,7 +93,7 @@ export class BibleFiles {
|
|||
|
||||
const passageNoteFile = BibleFiles.getFileForPassage(reference, this.plugin);
|
||||
if (passageNoteFile instanceof TFile) {
|
||||
const leaf = this.plugin.app.workspace.getLeaf(false);
|
||||
const leaf = this.plugin.app.workspace.getLeaf(openInNewTab ? 'tab' : false);
|
||||
await leaf.openFile(passageNoteFile);
|
||||
|
||||
// If there's a specific verse, scroll to it once it has rendered
|
||||
|
|
|
|||
Loading…
Reference in a new issue