generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
settings.ts
83 lines (65 loc) · 2.4 KB
/
settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { App, PluginSettingTab, Setting } from "obsidian";
import ObsidianLinkArchivePlugin from "./main";
import { defaultArchiveText } from "./constants";
export const enum ArchiveOptions {
Wayback,
Archiveis,
Both
}
// ReSharper disable once InconsistentNaming
export interface LinkArchivePluginSettings {
archiveOption: ArchiveOptions;
archiveText: string;
}
export const defaultSettings: LinkArchivePluginSettings = {
archiveOption: ArchiveOptions.Archiveis,
archiveText: defaultArchiveText
}
export class LinkArchiveSettingTab extends PluginSettingTab {
plugin: ObsidianLinkArchivePlugin;
constructor(app: App, plugin: ObsidianLinkArchivePlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const plugin: ObsidianLinkArchivePlugin = (this as any).plugin;
const { containerEl } = this;
containerEl.empty();
// add archive link text customization option
containerEl.createEl("h2", {text: "Archive Settings"});
new Setting(containerEl)
.setName("Link text")
.setDesc("The text of the archive links")
.addText(text =>
text
.setValue(plugin.settings.archiveText)
.onChange(async value => {
console.log(`Link text: ${value}`);
plugin.settings.archiveText = value;
await plugin.saveSettings();
}));
// new Setting(containerEl)
// .setName('Archive Provider')
// .setDesc('Choose a provider for the link archive')
// .addDropdown((dropdown) => {
// const options: Record<ArchiveOptions, string> = {
// 0: "Internet Archive",
// 1: "archive.is",
// 2: "Both"
// };
// dropdown
// .addOptions(options)
// .setValue(plugin.settings.archiveOption.toString())
// .onChange(async (value) => {
// console.log('Archive option: ' + value);
// plugin.settings.archiveOption = +value;
// await plugin.saveSettings();
// this.display();
// })
// });
containerEl.createEl("h2", {text: "About Link Archive"});
containerEl.createEl("p", {text: "This plugin archives links in your note so they're available to you even if the original site goes down or gets removed."});
containerEl.createEl("a", {text: "Open GitHub repository", href: "https://github.com/tomzorz/obsidian-link-archive"});
// TODO github support and ko-fi
}
}