diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cb49db..d7033ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/components/OpenBibleModal.ts b/src/components/OpenBibleModal.ts index b7766de..3a85224 100644 --- a/src/components/OpenBibleModal.ts +++ b/src/components/OpenBibleModal.ts @@ -68,7 +68,7 @@ export class OpenBibleModal extends SuggestModal { 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 { } } 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 { private async openChapter(item: BibleTarget): Promise { 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(); } } diff --git a/src/services/BibleFiles.ts b/src/services/BibleFiles.ts index 48b7cd4..654ec20 100644 --- a/src/services/BibleFiles.ts +++ b/src/services/BibleFiles.ts @@ -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 { + public async openChapterNote(reference: BibleReference, openInNewTab = false): Promise { 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