2025-06-11 00:19:57 +00:00
|
|
|
import PinDailyNotePlugin from "./main";
|
|
|
|
|
import { App, PluginSettingTab, Setting } from "obsidian";
|
2025-06-10 23:50:13 +00:00
|
|
|
|
|
|
|
|
export enum PinOptions {
|
|
|
|
|
EDITOR = 'editor',
|
|
|
|
|
LEFT_SIDE_BAR = 'leftSideBar',
|
|
|
|
|
RIGHT_SIDE_BAR = 'rightSideBar',
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-11 00:44:59 +00:00
|
|
|
export enum PluginOptions {
|
|
|
|
|
DAILY_NOTES = 'daily-notes',
|
|
|
|
|
PERIODIC_NOTES = 'periodic-notes',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PinDailyNotePluginSetting {
|
|
|
|
|
whereToPin: PinOptions
|
|
|
|
|
plugin: PluginOptions
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-10 23:50:13 +00:00
|
|
|
export const DEFAULT_SETTING: Partial<PinDailyNotePluginSetting> = {
|
2025-06-11 00:19:57 +00:00
|
|
|
whereToPin: PinOptions.EDITOR,
|
2025-06-11 00:44:59 +00:00
|
|
|
plugin: PluginOptions.DAILY_NOTES,
|
2025-06-11 00:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const whereToPinDropdownOptions: Record<PinOptions, string> = {
|
|
|
|
|
[PinOptions.EDITOR]: 'Editor',
|
|
|
|
|
[PinOptions.LEFT_SIDE_BAR]: 'Left Sidebar',
|
|
|
|
|
[PinOptions.RIGHT_SIDE_BAR]: 'Right Sidebar',
|
2025-06-10 23:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-11 00:44:59 +00:00
|
|
|
const pluginDropdownOptions: Record<PluginOptions, string> = {
|
|
|
|
|
[PluginOptions.DAILY_NOTES]: 'Daily Notes (Core Plugin)',
|
|
|
|
|
[PluginOptions.PERIODIC_NOTES]: 'Periodic Notes (Community Plugin)',
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-10 23:50:13 +00:00
|
|
|
export class PinDailyNotePluginSettingTab extends PluginSettingTab {
|
|
|
|
|
plugin: PinDailyNotePlugin
|
|
|
|
|
|
|
|
|
|
constructor(app: App, plugin: PinDailyNotePlugin) {
|
2025-06-11 00:19:57 +00:00
|
|
|
super(app, plugin);
|
2025-06-10 23:50:13 +00:00
|
|
|
this.plugin = plugin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
display(): void {
|
|
|
|
|
const { containerEl } = this;
|
2025-06-11 00:19:57 +00:00
|
|
|
containerEl.empty();
|
2025-06-10 23:50:13 +00:00
|
|
|
|
|
|
|
|
new Setting(containerEl)
|
2025-06-11 00:19:57 +00:00
|
|
|
.setName('Pin Location')
|
|
|
|
|
.setDesc('Default place to pin new daily note')
|
2025-06-10 23:50:13 +00:00
|
|
|
.addDropdown((dropdown) => {
|
|
|
|
|
dropdown.addOptions(whereToPinDropdownOptions)
|
2025-06-11 00:22:30 +00:00
|
|
|
dropdown.setValue(
|
|
|
|
|
this.plugin.settings.whereToPin ||
|
|
|
|
|
DEFAULT_SETTING.whereToPin
|
|
|
|
|
)
|
2025-06-10 23:50:13 +00:00
|
|
|
dropdown.onChange(async (value) => {
|
2025-06-11 00:10:45 +00:00
|
|
|
this.plugin.settings.whereToPin = value as PinOptions;
|
2025-06-11 00:44:59 +00:00
|
|
|
await this.plugin.saveSettings();
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
new Setting(containerEl)
|
|
|
|
|
.setName('Plugin')
|
|
|
|
|
.setDesc('Plugin to use for creating daily notes')
|
|
|
|
|
.addDropdown((dropdown) => {
|
|
|
|
|
dropdown.addOptions(pluginDropdownOptions)
|
|
|
|
|
dropdown.setValue(
|
|
|
|
|
this.plugin.settings.plugin ||
|
|
|
|
|
DEFAULT_SETTING.plugin
|
|
|
|
|
)
|
|
|
|
|
dropdown.onChange(async (value) => {
|
|
|
|
|
this.plugin.settings.plugin = value as PluginOptions;
|
|
|
|
|
await this.plugin.saveSettings();
|
2025-06-10 23:50:13 +00:00
|
|
|
})
|
2025-06-11 00:19:57 +00:00
|
|
|
});
|
2025-06-10 23:50:13 +00:00
|
|
|
}
|
|
|
|
|
}
|