Mercurial > obsidian-remember-file-state
view src/settings.ts @ 37:8be02002ed66
Use Obsidian's view APIs for scrolling state
Obsidian does some asynchronous formatting upon opening a file which can
affect the vertical positioning of things, especially when there are
tables for instance. Setting the scrolling position via the CM6 APIs
gets invalidated by this, so we're using the Obsidian view API instead
even if it only allows getting/setting vertical scrolling (not
horizontal).
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 14 Aug 2023 10:44:55 -0700 |
parents | 815b93d13e0f |
children | 7e981d54a055 |
line wrap: on
line source
import { App, PluginSettingTab, Setting } from 'obsidian'; import RememberFileStatePlugin from './main'; export interface RememberFileStatePluginSettings { rememberMaxFiles: number; } export const DEFAULT_SETTINGS: RememberFileStatePluginSettings = { // Matches the number of files Obsidian remembers the undo/redo // history for by default (at least as of 0.13.17). rememberMaxFiles: 20 } export class RememberFileStatePluginSettingTab extends PluginSettingTab { plugin: RememberFileStatePlugin; constructor(app: App, plugin: RememberFileStatePlugin) { super(app, plugin); this.plugin = plugin; } display(): void { const {containerEl} = this; containerEl.empty(); new Setting(containerEl) .setName('Remember files') .setDesc('How many files to remember at most') .addText(text => text .setValue(this.plugin.settings.rememberMaxFiles?.toString()) .onChange(async (value: string) => { const intValue = parseInt(value); if (!isNaN(intValue)) { this.plugin.settings.rememberMaxFiles = intValue; await this.plugin.saveSettings(); } })); } }