mirror of
https://github.com/binaris00/Theme-Controller.git
synced 2026-07-22 05:32:18 +00:00
Small fixes and added obsidian typing
This commit is contained in:
parent
b4f851961f
commit
ded80a85a5
8 changed files with 980 additions and 33 deletions
941
package-lock.json
generated
941
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -12,13 +12,14 @@
|
|||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@popperjs/core": "^2.11.7",
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"@popperjs/core": "^2.11.7",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.17.3",
|
||||
"obsidian": "latest",
|
||||
"obsidian-typings": "^2.5.0",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ export class ColorStatusBar {
|
|||
private app: App;
|
||||
private plugin: Plugin;
|
||||
private settings: IThControlSettings;
|
||||
public DARK_MODE_THEME_KEY: string = "obsidian";
|
||||
public LIGHT_MODE_THEME_KEY: string = "moonstone";
|
||||
public DARK_MODE_THEME_KEY = "obsidian";
|
||||
public LIGHT_MODE_THEME_KEY = "moonstone";
|
||||
currentColorStatus: string;
|
||||
|
||||
constructor(plugin: ThControl) {
|
||||
|
|
|
|||
10
src/main.ts
10
src/main.ts
|
|
@ -23,11 +23,15 @@ export default class ThControl extends Plugin {
|
|||
this.registerEvent(
|
||||
this.app.workspace.on("file-open", async (file) => {
|
||||
if (file === null) return;
|
||||
|
||||
let path = this.pathController.onFileOpen(file);
|
||||
let tag = this.tagController.onFileOpen(file);
|
||||
|
||||
if(!this.pathController.onFileOpen(file) && !this.tagController.onFileOpen(file))
|
||||
if(!path && !tag)
|
||||
this.defaultThemeCheck();
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
defaultThemeCheck(){
|
||||
|
|
@ -38,8 +42,8 @@ export default class ThControl extends Plugin {
|
|||
//@ts-ignore
|
||||
this.app.changeTheme(
|
||||
this.settings.defaultColor
|
||||
? this.colorStatusBar.DARK_MODE_THEME_KEY
|
||||
: this.colorStatusBar.LIGHT_MODE_THEME_KEY
|
||||
? "obsidian"
|
||||
: "moonstone"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ export class PathController {
|
|||
//@ts-ignore
|
||||
this.app.changeTheme(
|
||||
bestMatch.color
|
||||
? this.plugin.colorStatusBar.DARK_MODE_THEME_KEY
|
||||
: this.plugin.colorStatusBar.LIGHT_MODE_THEME_KEY
|
||||
? "obsidian"
|
||||
: "moonstone"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,45 +69,49 @@ export class ThControlSettingTab extends PluginSettingTab {
|
|||
|
||||
statusBarIcon(container: HTMLElement): void{
|
||||
new Setting(container)
|
||||
.setName('Enable Color Status Bar Icon')
|
||||
.setName('Enable color switcher')
|
||||
.setDesc('Enable/Disable an icon in your status bar to switch light/dark mode! Need to reload Obsidian or the plugin' )
|
||||
.addToggle((toggle) => {
|
||||
toggle.setValue(this.plugin.settings.enableColorStatusBarIcon)
|
||||
toggle.onChange(async (value) => {
|
||||
this.plugin.settings.enableColorStatusBarIcon = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
new Setting(container)
|
||||
.setName('Dark Mode String Status')
|
||||
.setName('Dark mode string status')
|
||||
.setDesc('Set any text-emoji to display the dark status! Need to enable Color Status Bar Icon')
|
||||
.addText(text => text
|
||||
.setPlaceholder('🌕')
|
||||
.setValue(this.plugin.settings.darkModeStringStatus)
|
||||
.onChange(async (value) => {
|
||||
.addText((text) => {
|
||||
if(!this.plugin.settings.enableColorStatusBarIcon) text.setDisabled(true);
|
||||
text.setPlaceholder('🌕')
|
||||
text.setValue(this.plugin.settings.darkModeStringStatus)
|
||||
text.onChange(async (value) => {
|
||||
this.plugin.settings.darkModeStringStatus = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
new Setting(container)
|
||||
.setName('Light Mode String Status')
|
||||
.setName('Light mode string status')
|
||||
.setDesc('Set any text-emoji to display the light status! Need to enable Color Status Bar Icon')
|
||||
.addText(text => text
|
||||
.setPlaceholder('🔆')
|
||||
.setValue(this.plugin.settings.lightModeStringStatus)
|
||||
.addText((text) => {
|
||||
if(!this.plugin.settings.enableColorStatusBarIcon) text.setDisabled(true);
|
||||
text.setPlaceholder('🔆')
|
||||
text.setValue(this.plugin.settings.lightModeStringStatus)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.lightModeStringStatus = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
this.plugin.settings.lightModeStringStatus = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
pathControl(container: HTMLElement): void{
|
||||
new Setting(container).setHeading().setName("Theme by Path").setDesc("This option has lower priority than the Tag Controller");
|
||||
new Setting(container).setHeading().setName("Path-Specific themes").setDesc("This option has lower priority than the Tag Controller");
|
||||
|
||||
let themes: string[] = getThemes();
|
||||
|
||||
|
|
@ -224,11 +228,11 @@ export class ThControlSettingTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
private tagControl(container: HTMLElement): void {
|
||||
new Setting(container).setHeading().setName("Theme by Tag").setDesc("This option has more priority than the Path Controller")
|
||||
new Setting(container).setHeading().setName("Tag-Specific themes").setDesc("This option has more priority than the Path Controller")
|
||||
|
||||
let themes: string[] = getThemes();
|
||||
|
||||
let settingAdd = new Setting(container).setName('Add a new tag').setDesc('set the tag, theme and color scheme, after that, select the add button');
|
||||
let settingAdd = new Setting(container).setName('Add a new tag').setDesc('set the tag, theme and color scheme, after that, select the add button. No need to write `#` before the tag');
|
||||
settingAdd.addText((text) => {
|
||||
text.setPlaceholder('ExampleTag')
|
||||
text.onChange(async (value) => {
|
||||
|
|
@ -337,7 +341,7 @@ export class ThControlSettingTab extends PluginSettingTab {
|
|||
|
||||
private defaultTheme(container: HTMLElement): void {
|
||||
|
||||
let setting = new Setting(container).setHeading().setName("Default Theme").setDesc("Set a default theme when you don't have any saved theme config in path or tag");
|
||||
let setting = new Setting(container).setHeading().setName("Default theme").setDesc("Set a default theme when you don't have any saved theme config in path or tag");
|
||||
let themes: string[] = getThemes();
|
||||
|
||||
setting.addToggle((toggle) => {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ export class TagController {
|
|||
//@ts-ignore
|
||||
this.app.changeTheme(
|
||||
bestMatch.color
|
||||
? this.plugin.colorStatusBar.DARK_MODE_THEME_KEY
|
||||
: this.plugin.colorStatusBar.LIGHT_MODE_THEME_KEY
|
||||
? "obsidian"
|
||||
: "moonstone"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@
|
|||
"ES5",
|
||||
"ES6",
|
||||
"ES7"
|
||||
]
|
||||
],
|
||||
"types": [
|
||||
"obsidian-typings"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
|
|
|
|||
Loading…
Reference in a new issue