From 343fa4794ddcbecf8fcfaa9eb4ad601a37da7829 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Mon, 4 Apr 2022 10:05:58 +0200 Subject: [PATCH] Fixing an issue where the plugin would fail to load on mobile(closes #24) --- manifest.json | 2 +- package.json | 2 +- src/const.ts | 8 +++++++- versions.json | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 68204fb..4092252 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-plantuml", "name": "PlantUML", - "version": "1.5.2", + "version": "1.5.3", "minAppVersion": "0.13.0", "description": "Render PlantUML Diagrams", "author": "Johannes Theiner", diff --git a/package.json b/package.json index 677ede4..878f739 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-plantuml", - "version": "1.5.2", + "version": "1.5.3", "description": "PlantUML rendering for Obsidian.md", "main": "main.js", "scripts": { diff --git a/src/const.ts b/src/const.ts index 9f9b7e6..9994f5f 100644 --- a/src/const.ts +++ b/src/const.ts @@ -34,7 +34,13 @@ export function isUsingLivePreviewEnabledEditor() : boolean { if(config.legacyEditor) return false; //requireApiVersion() has been added with 0.13.23, so we need a different method to be sure - const version = navigator.userAgent.match(/obsidian([^ ]+)/).first().split("/")[1]; + const userAgent = navigator.userAgent.match(/obsidian([^ ]+)/); + + //we are on mobile, there is no legacy editor on mobile. + if (userAgent === null) { + return true; + } + const version = userAgent.first().split("/")[1]; //live preview was added with 0.13, so there is no way that prior versions would support it. return compareVersions.compare(version, "0.13.0", ">="); } diff --git a/versions.json b/versions.json index a296c59..b6836d3 100644 --- a/versions.json +++ b/versions.json @@ -16,5 +16,6 @@ "1.4.0": "0.12.0", "1.5.0": "0.13.0", "1.5.1": "0.13.0", - "1.5.2": "0.13.0" + "1.5.2": "0.13.0", + "1.5.3": "0.13.0" }