generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdjacencyMatrixMakerSettingTab.ts
143 lines (130 loc) · 4.8 KB
/
AdjacencyMatrixMakerSettingTab.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import {
App, Notice, PluginSettingTab,
Setting
} from "obsidian";
import {
hslToHex,
hexToHSL
} from "./utility";
import AdjacencyMatrixMakerPlugin from "./main";
// !SECTION Matrix Modal
// SECTION SettingsTab
export class AdjacencyMatrixMakerSettingTab extends PluginSettingTab {
plugin: AdjacencyMatrixMakerPlugin;
constructor(app: App, plugin: AdjacencyMatrixMakerPlugin) {
super(app, plugin);
// this.plugin = plugin;
}
display(): void {
let { containerEl } = this;
containerEl.empty();
containerEl.createEl("h2", {
text: "Settings for Adjacency Matrix Maker",
});
// SECTION Custom settings
const coloursDiv = containerEl.createDiv();
// Main colour picker
const mainColourDiv = coloursDiv.createDiv();
mainColourDiv.createEl("h4", {
text: "Main colour",
});
const mainColourPicker = mainColourDiv.createEl("input", { type: "color" });
mainColourPicker.value = hslToHex(
...this.plugin.settings.mainColourComponents
);
mainColourPicker.addEventListener("change", async () => {
this.plugin.settings.mainColourComponents = hexToHSL(
mainColourPicker.value
);
await this.plugin.saveSettings();
});
// Background colour picker
const backgroundColourDiv = coloursDiv.createDiv();
backgroundColourDiv.createEl("h4", {
text: "Background colour",
});
const backgroundColourPicker = backgroundColourDiv.createEl("input", {
type: "color",
});
backgroundColourPicker.value = this.plugin.settings.backgroundColour;
backgroundColourPicker.addEventListener("change", async () => {
this.plugin.settings.backgroundColour = backgroundColourPicker.value;
await this.plugin.saveSettings();
});
// // Folder squares colour picker
// const folderSquaresColourDiv = coloursDiv.createDiv();
// folderSquaresColourDiv.createEl("h4", {
// text: "Folder squares colour",
// });
// const folderSquaresColourPicker = folderSquaresColourDiv.createEl("input", {
// type: "color",
// });
// folderSquaresColourPicker.value = this.plugin.settings.folderSquaresColour;
// folderSquaresColourPicker.addEventListener("change", async () => {
// this.plugin.settings.folderSquaresColour =
// folderSquaresColourPicker.value;
// await this.plugin.saveSettings();
// });
// !SECTION Custom settings
// SECTION Obsidian Settings
new Setting(containerEl)
.setName("Show folders")
.setDesc("Add squares to the image showing which folder a note is in")
.addToggle((toggle) => toggle
.setValue(this.plugin.settings.showFolders)
.onChange(async (value) => {
this.plugin.settings.showFolders = value;
await this.plugin.saveSettings();
})
);
const initialScale = this.plugin.settings.userScale === 0
? ""
: this.plugin.settings.userScale;
new Setting(containerEl)
.setName("Image Scale")
.setDesc(
"The side length in pixels of each cell in the matrix. A larger scale will make for longer loading times, but a crisper image. The default value is determined by the number of files in your vault (More files = higher scale value). Leave blank to use the default."
)
.addText((text) => text
.setPlaceholder("Scale")
.setValue(initialScale.toString())
.onChange(async (newValue) => {
const newScale = Number(newValue);
if (!(Number.isInteger(newScale) && newScale >= 0)) {
new Notice("Scale must be an integer greater than or equal to 1");
return;
}
this.plugin.settings.userScale = newScale;
await this.plugin.saveSettings();
// console.log(this.plugin.settings.userScale)
})
);
new Setting(containerEl)
.setName("Image name")
.setDesc(
"The value used to name a saved image. The name will have the datetime appended automatically"
)
.addText((text) => text
.setPlaceholder("Default name")
.setValue(this.plugin.settings.imgName)
.onChange(async (value) => {
this.plugin.settings.imgName = value;
await this.plugin.saveSettings();
})
);
new Setting(containerEl)
.setName("Folder path")
.setDesc(
'The folder to save the image in. The default is the root of your vault \'/\'. If you do change it, leave out the first slash in front. e.g. To save the image in "Attachments", type in "Attachments" (no quotes)'
)
.addText((text) => text
.setPlaceholder("/")
.setValue(this.plugin.settings.folderPath)
.onChange(async (value) => {
this.plugin.settings.folderPath = value;
await this.plugin.saveSettings();
})
);
// !SECTION Obsidian Settings
}
}