CustomCSS
Unofficial
Manager for custom CSS themes and snippets.
Import:
import type { CustomCSS } from '@obsidian-typings/obsidian-catalyst-latest';Signature:
export interface CustomCSS extends ComponentExtends: Component
Constructor
new CustomCSS(app: App)Constructor.
To get the constructor instance, use getCustomCSSConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| _children | Component[] | Child Components attached to current component, will be unloaded on unloading parent component. (Inherited from Component) | |
| _events | EventRef[] | Events that are attached to the current component, will be detached on unloading parent component. (Inherited from Component) | |
| _loaded | boolean | Whether the component and its children are loaded. (Inherited from Component) | |
| app | App | Reference to the obsidian#App. | |
| csscache | Map<string, string> | Cache of CSS snippet filepath (relative to vault root) to CSS snippet contents. | |
| enabledSnippets | Set<string> | Set of enabled snippet, given by filenames. | |
| extraStyleEls | HTMLStyleElement[] | Contains references to Style elements containing custom CSS snippets. | |
| oldThemes | string[] | List of theme names not fully updated to post v1.0.0 theme guidelines. | |
| queue | PromisedQueue | Queue for sequential CSS processing operations. | |
| requestLoadSnippets | Debouncer<[], void> | Debounced function to reload CSS snippets. | |
| requestLoadTheme | Debouncer<[], void> | Debounced function to reload the active theme. | |
| requestReadThemes | Debouncer<[], void> | Debounced function to re-read available themes from disk. | |
| snippets | string[] | List of snippets detected by Obsidian, given by their filenames. | |
| styleEl | HTMLStyleElement | Main style element for the active theme. | |
| theme | '' | string | Currently active theme, given by its name. | |
| themes | CustomCSSThemesRecord | Mapping of theme names to their manifest. | |
| updates | CustomCSSUpdatesRecord | Record of available theme updates. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addChild(component) | T | Adds a child component, loading it if this component is loaded. (Inherited from Component) | |
| boundRaw(themeName) | void | Bound callback for handling raw file change events for a theme. | |
| checkForUpdate(themeName) | void | Check whether a specific theme can be updated. | |
| checkForUpdates() | void | Check all themes for updates. | |
| disableTranslucency() | void | Disable translucency of application background. | |
| downloadLegacyTheme(options) | Promise<string> | Fetch legacy theme CSS using the pre-v1.0.0 theme download pipeline. | |
| enableTranslucency() | void | Enable translucency of application background. | |
| getManifest(repoUrl) | Promise<ThemeManifest> | Fetch a theme's manifest using repository URL. | |
| getSnippetPath(snippetName) | string | Convert snippet name to its corresponding filepath (relative to vault root). | |
| getSnippetsFolder() | string | Returns the folder path where snippets are stored (relative to vault root). | |
| getThemeFolder() | string | Returns the folder path where themes are stored (relative to vault root). | |
| getThemePath(themeName) | string | Convert theme name to its corresponding filepath (relative to vault root). | |
| hasUpdates() | boolean | Returns whether there are themes that can be updated. | |
| installLegacyTheme(options) | Promise<void> | Install a legacy theme using the pre-v1.0.0 theme download pipeline<br> Will create a corresponding. dummy manifest for the theme. | |
| installTheme(options, version) | Promise<void> | Install a theme using the regular theme download pipeline. | |
| isDarkMode() | boolean | Check whether the current theme is dark mode. | |
| isThemeInstalled(themeName) | boolean | Check whether a specific theme is installed by theme name. | |
| load() | void | Load this component and its children. (Inherited from Component) | |
| loadCss(arg1) | Promise<unknown> | Load and apply CSS from the given source. | |
| loadData() | unknown | Load stored CustomCSS configuration data. | |
| loadSnippets() | unknown | Load and apply all enabled CSS snippets. | |
| loadTheme(arg1) | unknown | Load and apply a specific theme. | |
| onload() | void | Lifecycle hook called when the component is loaded. | |
| onRaw(themeName) | void | Handle raw file system change events for a theme. | |
| onunload() | void | Override this to unload your component (Inherited from Component) | |
| readSnippets(reload?) | void | Read available CSS snippets from the snippets folder. | |
| readThemes(reload?) | void | Read available themes from the themes folder. | |
| register(cb) | void | Registers a callback to be called when unloading. (Inherited from Component) | |
| registerDomEvent(el, type, callback, options?) | void | Registers a DOM event to be detached when unloading. (Inherited from Component) | |
| registerDomEvent(el, type, callback, options?) | void | Registers a DOM event to be detached when unloading (Inherited from Component) | |
| registerDomEvent(el, type, callback, options?) | void | Registers a DOM event to be detached when unloading (Inherited from Component) | |
| registerEvent(eventRef) | void | Registers an event to be detached when unloading. (Inherited from Component) | |
| registerInterval(id) | number | Registers an interval (from setInterval) to be cancelled when unloading. Use window.setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API(Inherited from Component) | |
| registerScopeEvent(keymapEventHandler) | void | Register a scope keymap event handler to be removed on unload. (Inherited from Component) | |
| reloadTheme() | void | Reload the active theme CSS. | |
| removeChild(component) | T | Removes a child component, unloading it. (Inherited from Component) | |
| removeTheme(themeName) | Promise<void> | Remove a theme by theme name. | |
| setCssEnabledStatus(snippetName, enabled) | void | Set the activation status of a snippet by snippet name. | |
| setTheme(themeName) | void | Set the active theme by theme name. | |
| setTranslucency(translucency) | void | Set the translucency of application background. | |
| unload() | void | Override this to unload your component. (Inherited from Component) |
Links to this page: