forked from almariah/embed-code-file
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.ts
87 lines (74 loc) · 2.6 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
84
85
86
87
import EmbedCodeFile from './main';
import { PluginSettingTab, Setting, App } from 'obsidian';
export interface EmbedCodeFileSettings {
includedLanguages: string;
titleBackgroundColor: string;
titleFontColor: string;
displayIpynbAsPython: boolean;
showIpynbCellNumbers: boolean;
}
export const DEFAULT_SETTINGS: EmbedCodeFileSettings = {
includedLanguages: 'c,cs,cpp,java,python,go,ruby,javascript,js,typescript,ts,shell,sh,bash,ipynb',
titleBackgroundColor: "#00000020",
titleFontColor: "",
displayIpynbAsPython: true,
showIpynbCellNumbers: true,
}
export class EmbedCodeFileSettingTab extends PluginSettingTab {
plugin: EmbedCodeFile;
constructor(app: App, plugin: EmbedCodeFile) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const {containerEl} = this;
containerEl.empty();
containerEl.createEl('h2', {text: 'Embed Code File Settings'});
new Setting(containerEl)
.setName('Included Languages')
.setDesc('Comma separated list of included languages.')
.addText(text => text
.setPlaceholder('Comma separated list')
.setValue(this.plugin.settings.includedLanguages)
.onChange(async (value) => {
this.plugin.settings.includedLanguages = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName("Font color of title")
.addText(text => text
.setPlaceholder('Enter a color')
.setValue(this.plugin.settings.titleFontColor)
.onChange(async (value) => {
this.plugin.settings.titleFontColor = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Background color of title')
.addText(text => text
.setPlaceholder('#00000020')
.setValue(this.plugin.settings.titleBackgroundColor)
.onChange(async (value) => {
this.plugin.settings.titleBackgroundColor = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Display Jupyter Notebooks as python')
.setDesc('Parse .ipynb files to extract and display their python source code.')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.displayIpynbAsPython)
.onChange(async (value) => {
this.plugin.settings.displayIpynbAsPython = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Jupyter Notebook Cell Numbers')
.setDesc('Show Jupyter Notebook cell numbers in the embedded python code.')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.showIpynbCellNumbers)
.onChange(async (value) => {
this.plugin.settings.showIpynbCellNumbers = value;
await this.plugin.saveSettings();
}));
}
}