Mercurial > obsidian-remember-file-state
comparison src/main.ts @ 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 | ba74a7d3709c |
children | fbaf7c7126be |
comparison
equal
deleted
inserted
replaced
26:8ff5e5d9ed10 | 27:3d0ac176118f |
---|---|
1 import { | 1 import { |
2 App, | 2 App, |
3 Editor, | 3 Editor, |
4 MarkdownView, | 4 MarkdownView, |
5 Modal, | |
5 OpenViewState, | 6 OpenViewState, |
6 Plugin, | 7 Plugin, |
7 TAbstractFile, | 8 TAbstractFile, |
8 TFile, | 9 TFile, |
9 View, | 10 View, |
64 } | 65 } |
65 | 66 |
66 // Default empty list of remembered file states. | 67 // Default empty list of remembered file states. |
67 const DEFAULT_DATA: RememberFileStatePluginData = { | 68 const DEFAULT_DATA: RememberFileStatePluginData = { |
68 rememberedFiles: {} | 69 rememberedFiles: {} |
70 }; | |
71 | |
72 // Simple warning message. | |
73 class WarningModal extends Modal { | |
74 constructor(app: App, title: string, message: string) { | |
75 super(app) | |
76 this.title = title; | |
77 this.message = message; | |
78 } | |
79 onOpen() { | |
80 this.contentEl.createEl('h2', {text: this.title}); | |
81 this.contentEl.createEl('p', {text: this.message}); | |
82 } | |
69 }; | 83 }; |
70 | 84 |
71 export default class RememberFileStatePlugin extends Plugin { | 85 export default class RememberFileStatePlugin extends Plugin { |
72 settings: RememberFileStatePluginSettings; | 86 settings: RememberFileStatePluginSettings; |
73 data: RememberFileStatePluginData; | 87 data: RememberFileStatePluginData; |
113 } | 127 } |
114 }); | 128 }); |
115 this._globalUninstallers.push(uninstall); | 129 this._globalUninstallers.push(uninstall); |
116 | 130 |
117 this.addSettingTab(new RememberFileStatePluginSettingTab(this.app, this)); | 131 this.addSettingTab(new RememberFileStatePluginSettingTab(this.app, this)); |
132 | |
133 if (this.app.vault.getConfig('legacyEditor') !== false) { | |
134 new WarningModal( | |
135 this.app, | |
136 "Legacy Editor Not Supported", | |
137 "The 'Remember File State' plugin works only with the new editor. Please turn off 'Legacy Editor' in the options." | |
138 ).open(); | |
139 } | |
118 } | 140 } |
119 | 141 |
120 onunload() { | 142 onunload() { |
121 // Run view uninstallers on all current views. | 143 // Run view uninstallers on all current views. |
122 var numViews: number = 0; | 144 var numViews: number = 0; |