diff --git a/README.md b/README.md index 9477ce6..aae8194 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This plugin takes heavy inspiration from the [Bible Reference](https://github.co ### Getting Started -To start with, you will need to format a Bible for your own vault. Some instructions on this can be found [below](#bible-markdown-format) (this plugin uses a different markdown format to *Bible Linker*). I've also already formatted the Public Domain World English Bible so you can [download](https://github.com/camelChief/markdown-webp) that and just get started. Once you've done that, open up the *Local Bible Ref* settings and fill in at least the *Bibles Path* field. Then, to use the plugin, simply open a new note and use the `--` reference prefix to grab a passage of scripture. There are also additional options (similar to terminal command options) you can provide to the reference to indicate which version to use and what markdown format to display the passage in. More information can be found [below](#usage). +To start with, you will need to format a Bible for your own vault. Some instructions on this can be found [below](#bible-markdown-format) (this plugin uses a different markdown format to *Bible Linker*). I've also already formatted the Public Domain World English Bible so you can [download](https://github.com/camelChief/markdown-webp) that and just get started. Once you've done that, open up the *Local Bible Ref* settings and fill in at least the *Bibles path* field. Then, to use the plugin, simply open a new note and use the `--` reference prefix to grab a passage of scripture. There are also additional options (similar to terminal command options) you can provide to the reference to indicate which version to use and what markdown format to display the passage in. More information can be found [below](#usage). ![localBibleRef1](https://github.com/user-attachments/assets/b8b5440b-8f47-4462-987e-a52791d758be) diff --git a/manifest.json b/manifest.json index 52ccc7d..cc79f0b 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,5 @@ "description": "Quickly and easily reference Bible passages stored locally in your vault.", "author": "Caleb Campbell", "authorUrl": "https://mastodon.social/@calebcampbell", - "fundingUrl": "", - "isDesktopOnly": true + "isDesktopOnly": false } diff --git a/package-lock.json b/package-lock.json index f684282..f355504 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@typescript-eslint/parser": "5.29.0", "builtin-modules": "3.3.0", "esbuild": "0.17.3", - "obsidian": "latest", + "obsidian": "^1.8.7", "tslib": "2.4.0", "typescript": "4.7.4" } @@ -1809,10 +1809,11 @@ "peer": true }, "node_modules/obsidian": { - "version": "1.5.7-1", - "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.5.7-1.tgz", - "integrity": "sha512-T5ZRuQ1FnfXqEoakTTHVDYvzUEEoT8zSPnQCW31PVgYwG4D4tZCQfKHN2hTz1ifnCe8upvwa6mBTAP2WUA5Vng==", + "version": "1.8.7", + "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.8.7.tgz", + "integrity": "sha512-h4bWwNFAGRXlMlMAzdEiIM2ppTGlrh7uGOJS6w4gClrsjc+ei/3YAtU2VdFUlCiPuTHpY4aBpFJJW75S1Tl/JA==", "dev": true, + "license": "MIT", "dependencies": { "@types/codemirror": "5.60.8", "moment": "2.29.4" diff --git a/src/local-bible-ref-setting-tab.ts b/src/local-bible-ref-setting-tab.ts index 919b935..c259287 100644 --- a/src/local-bible-ref-setting-tab.ts +++ b/src/local-bible-ref-setting-tab.ts @@ -15,9 +15,9 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab { const { containerEl } = this; containerEl.empty(); - let biblesPathTimeout: NodeJS.Timeout; + let biblesPathTimeout: number; new Setting(containerEl) - .setName('Bibles Path') + .setName('Bibles path') .setDesc('The path to the folder containing your bibles.') .addText(text => { text.setPlaceholder('e.g. Data/Bibles') @@ -27,7 +27,7 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); clearTimeout(biblesPathTimeout); - biblesPathTimeout = setTimeout(async () => { + biblesPathTimeout = window.setTimeout(async () => { const exists = await this.app.vault.adapter.exists(value); if (!exists) new Notice(`Bibles folder doesn't exist at path: ${value}.`); }, 1000); @@ -36,9 +36,9 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab { new PathSuggest(this.app, text.inputEl); }); - let defaultVersionTimeout: NodeJS.Timeout; + let defaultVersionTimeout: number; new Setting(containerEl) - .setName('Default Version Shorthand') + .setName('Default version shorthand') .setDesc('The version to use by default - shorthand.') .addText(text => text .setPlaceholder('e.g. NIV') @@ -48,7 +48,7 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); clearTimeout(defaultVersionTimeout); - defaultVersionTimeout = setTimeout(async () => { + defaultVersionTimeout = window.setTimeout(async () => { const path = `${this.plugin.settings.biblesPath}/${value}`; const exists = await this.app.vault.adapter.exists(path); if (!exists) new Notice(`Version folder doesn't exist at path: ${path}.`); @@ -56,7 +56,7 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab { })); new Setting(containerEl) - .setName('Default Passage Format') + .setName('Default passage format') .setDesc('The markdown format to use for passages by default.') .addDropdown(dropdown => dropdown .addOptions({ diff --git a/src/passage-suggest.ts b/src/passage-suggest.ts index efc9cc0..6c0f975 100644 --- a/src/passage-suggest.ts +++ b/src/passage-suggest.ts @@ -32,7 +32,7 @@ export class PassageSuggest extends EditorSuggest { // if no settings, alert user if (!this.settings.biblesPath) { - if (!this.noSettingsNotice?.noticeEl.isShown()) { + if (!this.noSettingsNotice?.messageEl.isShown()) { const noticeText = "Local Bible Ref settings are not " + "configured. Please set the bibles path before " + "attempting to reference passages."; @@ -283,9 +283,8 @@ export class PassageSuggest extends EditorSuggest { formatted += "\n\n"; break; case PassageFormat.Callout: { - const passageReference = passageRef.stringify(); - const passageLink = this.generatePassageLink(passageRef, context); - formatted = `> [!quote] [${passageReference}](${passageLink})\n`; + const passageLink = this.generatePassageLink(passageRef, context); + formatted = `> [!quote] ${passageLink}\n`; formatted += texts.join("\n\n").trim(); formatted = formatted.replace(/\n/gm, "\n> "); formatted += "\n\n"; @@ -301,17 +300,17 @@ export class PassageSuggest extends EditorSuggest { ref: PassageReference, context: EditorSuggestContext ): string { - let link = ""; - let folder: TFolder | null = context.file.parent; - while (folder?.parent) { - link += "../"; - folder = folder.parent; - } - const { version, book, startChapter } = ref; - link += `${this.settings.biblesPath}/${version}/` + - `${book.name}/${book.name} ${startChapter}.md`; - return link.replace(/ /g, "%20"); + const filePath = `${this.settings.biblesPath}/${version}/${book.name}/${book.name} ${startChapter}.md`; + const file = this.app.vault.getFileByPath(filePath); + if (!file) return ref.stringify(); + + return this.app.fileManager.generateMarkdownLink( + file, + context.file.path, + undefined, + ref.stringify(), + ); } }