changeset 27:3d0ac176118f

Show warning message if using the plugin with the legacy editor
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 14 May 2022 09:33:19 -0700
parents 8ff5e5d9ed10
children fbaf7c7126be
files src/main.ts
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.ts	Fri Mar 18 19:35:52 2022 -0700
+++ b/src/main.ts	Sat May 14 09:33:19 2022 -0700
@@ -2,6 +2,7 @@
 	App,
 	Editor,
 	MarkdownView,
+	Modal,
 	OpenViewState,
 	Plugin,
 	TAbstractFile,
@@ -68,6 +69,19 @@
 	rememberedFiles: {}
 };
 
+// Simple warning message.
+class WarningModal extends Modal {
+	constructor(app: App, title: string, message: string) {
+		super(app)
+		this.title = title;
+		this.message = message;
+	}
+	onOpen() {
+		this.contentEl.createEl('h2', {text: this.title});
+		this.contentEl.createEl('p', {text: this.message});
+	}
+};
+
 export default class RememberFileStatePlugin extends Plugin {
 	settings: RememberFileStatePluginSettings;
 	data: RememberFileStatePluginData;
@@ -115,6 +129,14 @@
 		this._globalUninstallers.push(uninstall);
 
 		this.addSettingTab(new RememberFileStatePluginSettingTab(this.app, this));
+
+		if (this.app.vault.getConfig('legacyEditor') !== false) {
+			new WarningModal(
+				this.app,
+				"Legacy Editor Not Supported",
+				"The 'Remember File State' plugin works only with the new editor. Please turn off 'Legacy Editor' in the options."
+			).open();
+		}
 	}
 
 	onunload() {