# HG changeset patch # User Ludovic Chabant # Date 1652545999 25200 # Node ID 3d0ac176118f60798c7119c325f095339ec14df4 # Parent 8ff5e5d9ed1097d703fd440a8a08c8491b9e7863 Show warning message if using the plugin with the legacy editor diff -r 8ff5e5d9ed10 -r 3d0ac176118f src/main.ts --- 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() {