From 8178231bdc8f242e0313aa8b317ec32dfe3d41f9 Mon Sep 17 00:00:00 2001 From: Hananoshika Yomaru Date: Wed, 8 Nov 2023 14:44:26 -0800 Subject: [PATCH] release: 1.0.16 --- manifest.json | 2 +- package.json | 2 +- src/main.ts | 16 +++++++++++----- versions.json | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index d4f4070..9c74545 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "frontmatter-generator", "name": "Frontmatter generator", - "version": "1.0.15", + "version": "1.0.16", "minAppVersion": "0.15.0", "description": "Generate frontmatter for your notes from json and javascript", "author": "Hananoshika Yomaru", diff --git a/package.json b/package.json index 367fc3b..7193e49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-frontmatter-generator", - "version": "1.0.15", + "version": "1.0.16", "description": "A plugin for Obsidian that generates frontmatter for notes.", "main": "main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index be3736b..615ddbc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import { App, Editor, EventRef, + MarkdownPreviewView, MarkdownView, Notice, Plugin, @@ -331,12 +332,17 @@ export default class FrontmatterGeneratorPlugin extends Plugin { if (!this.settings.runOnModify) return; if (file instanceof TFile && isMarkdownFile(file)) { const activeFile = this.app.workspace.getActiveFile(); - const editor = - this.app.workspace.getActiveViewOfType( - MarkdownView - )?.editor; + const view = + this.app.workspace.getActiveViewOfType(MarkdownView); + + // check if the view.currentMode is MarkdownPreviewView + + const isPreview = + view?.currentMode instanceof MarkdownPreviewView; + + const editor = view?.editor; if (activeFile === file && editor) { - this.runFileSync(file, editor); + if (isPreview) this.runFileSync(file, editor); } else { await this.runFile(file); } diff --git a/versions.json b/versions.json index 8d89ded..0ac0217 100644 --- a/versions.json +++ b/versions.json @@ -13,5 +13,6 @@ "1.0.12": "0.15.0", "1.0.13": "0.15.0", "1.0.14": "0.15.0", - "1.0.15": "0.15.0" + "1.0.15": "0.15.0", + "1.0.16": "0.15.0" } \ No newline at end of file