diff --git a/manifest-beta.json b/manifest-beta.json index 4c0b9d5a..9bbf96cb 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -2,7 +2,7 @@ "id": "pdf-plus", "name": "PDF++", "version": "0.40.6", - "minAppVersion": "1.4.16", + "minAppVersion": "1.5.8", "description": "The most Obsidian-native PDF annotation tool ever.", "author": "Ryota Ushio", "authorUrl": "https://github.com/RyotaUshio", diff --git a/manifest.json b/manifest.json index 4c0b9d5a..9bbf96cb 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "pdf-plus", "name": "PDF++", "version": "0.40.6", - "minAppVersion": "1.4.16", + "minAppVersion": "1.5.8", "description": "The most Obsidian-native PDF annotation tool ever.", "author": "Ryota Ushio", "authorUrl": "https://github.com/RyotaUshio", diff --git a/src/main.ts b/src/main.ts index c9df490c..e7525495 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,11 +8,12 @@ import { ColorPalette } from 'color-palette'; import { DomManager } from 'dom-manager'; import { PDFCroppedEmbed } from 'pdf-cropped-embed'; import { DEFAULT_SETTINGS, PDFPlusSettings, PDFPlusSettingTab } from 'settings'; -import { subpathToParams, OverloadParameters, focusObsidian, isTargetHTMLElement } from 'utils'; +import { subpathToParams, OverloadParameters, focusObsidian, isTargetHTMLElement, getInstallerVersion, isVersionOlderThan } from 'utils'; import { DestArray, ObsidianViewer, PDFEmbed, PDFView, PDFViewerChild, PDFViewerComponent, Rect } from 'typings'; import { ExternalPDFModal } from 'modals'; import { PDFExternalLinkPostProcessor, PDFInternalLinkPostProcessor, PDFOutlineItemPostProcessor, PDFThumbnailItemPostProcessor } from 'post-process'; import { BibliographyManager } from 'bib'; +import { InstallerVersionModal } from 'modals/installer-version-modal'; export default class PDFPlus extends Plugin { @@ -134,6 +135,11 @@ export default class PDFPlus extends Plugin { if (requireApiVersion(untestedVersion)) { console.warn(`${this.manifest.name}: This plugin has not been tested on Obsidian ${untestedVersion} or above. Please report any issue you encounter on GitHub (https://github.com/RyotaUshio/obsidian-pdf-plus/issues/new/choose).`); } + + const installerVersion = getInstallerVersion(); + if (installerVersion && isVersionOlderThan(installerVersion, '1.5.8')) { + new InstallerVersionModal(this).open(); + } } private addIcons() { diff --git a/src/modals/installer-version-modal.ts b/src/modals/installer-version-modal.ts new file mode 100644 index 00000000..eae8898f --- /dev/null +++ b/src/modals/installer-version-modal.ts @@ -0,0 +1,29 @@ +import { ButtonComponent } from 'obsidian'; +import { PDFPlusModal } from './base-modal'; + + +export class InstallerVersionModal extends PDFPlusModal { + onOpen() { + super.onOpen(); + + const name = this.plugin.manifest.name; + this.setTitle(`${name}: Outdated Obsidian installer`); + this.contentEl.appendText( + `Your Obsidian installer is outdated and likely to be incompatible with the latest ${name}. Please download the latest installer from Obsidian's website and re-install the Obsidian app.` + ); + + this.contentEl.createDiv('modal-button-container', (el) => { + new ButtonComponent(el) + .setButtonText('Get installer from https://obsidian.md') + .setCta() + .onClick(() => { + window.open('https://obsidian.md/download', '_blank'); + }); + new ButtonComponent(el) + .setButtonText('What is "installer version"?') + .onClick(() => { + window.open('https://help.obsidian.md/Getting+started/Update+Obsidian#Installer%20updates', '_blank'); + }); + }); + } +} diff --git a/src/utils/index.ts b/src/utils/index.ts index b996bf45..15cd6709 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -173,6 +173,17 @@ export function isVersionNewerThan(a: string, b: string) { return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }) === 1; } +export function isVersionOlderThan(a: string, b: string) { + return isVersionNewerThan(b, a); +} + +export function getInstallerVersion(): string | null { + return Platform.isDesktopApp ? + // @ts-ignore + window.electron.remote.app.getVersion() : + null; +} + export function findReferenceCache(cache: CachedMetadata, start: number, end: number): ReferenceCache | undefined { return cache.links?.find((link) => start <= link.position.start.offset && link.position.end.offset <= end) ?? cache.embeds?.find((embed) => start <= embed.position.start.offset && embed.position.end.offset <= end);