comparison src/main.ts @ 58:4f6cbc0b339c

Remove checks for legacy editor.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 21 Nov 2023 17:15:18 -0800
parents 388eb78ef4b7
children
comparison
equal deleted inserted replaced
57:666e93f1bd3e 58:4f6cbc0b339c
150 } 150 }
151 }); 151 });
152 this._globalUninstallers.push(uninstall); 152 this._globalUninstallers.push(uninstall);
153 153
154 this.addSettingTab(new RememberFileStatePluginSettingTab(this.app, this)); 154 this.addSettingTab(new RememberFileStatePluginSettingTab(this.app, this));
155
156 if ((this.app.vault as any).getConfig('legacyEditor') !== false) {
157 new WarningModal(
158 this.app,
159 "Legacy Editor Not Supported",
160 "The 'Remember File State' plugin works only with the new editor. Please turn off 'Legacy Editor' in the options."
161 ).open();
162 }
163 } 155 }
164 156
165 onunload() { 157 onunload() {
166 console.log("RememberFileState: unloading plugin"); 158 console.log("RememberFileState: unloading plugin");
167 159
362 // Save scrolling position (Obsidian API only gives vertical position). 354 // Save scrolling position (Obsidian API only gives vertical position).
363 const scrollInfo = {top: view.currentMode.getScroll(), left: 0}; 355 const scrollInfo = {top: view.currentMode.getScroll(), left: 0};
364 356
365 // Save current selection. CodeMirror returns a JSON object (not a 357 // Save current selection. CodeMirror returns a JSON object (not a
366 // JSON string!) when we call toJSON. 358 // JSON string!) when we call toJSON.
367 // If state selection is undefined, we have a legacy editor. Just ignore that part.
368 const cm6editor = view.editor as EditorWithCM6; 359 const cm6editor = view.editor as EditorWithCM6;
369 const stateSelection: EditorSelection = cm6editor.cm.state.selection; 360 const stateSelection: EditorSelection = cm6editor.cm.state.selection;
370 const stateSelectionJSON = (stateSelection !== undefined) ? stateSelection.toJSON() : undefined; 361 const stateSelectionJSON = stateSelection.toJSON();
371 362
372 const stateData = {'scrollInfo': scrollInfo, 'selection': stateSelectionJSON}; 363 const stateData = {'scrollInfo': scrollInfo, 'selection': stateSelectionJSON};
373 364
374 return stateData; 365 return stateData;
375 } 366 }