Skip to content

CustomCSS

Extends

Properties

_children

_children: Component[]

Child Components attached to current component, will be unloaded on unloading parent component

Inherited from

Component._children


_events

_events: EventRef[]

Events that are attached to the current component, will be detached on unloading parent component

Inherited from

Component._events


_loaded

_loaded: boolean

Whether the component and its children are loaded

Inherited from

Component._loaded


app

app: App

Reference to App


enabledSnippets

enabledSnippets: Set<string>

Set of enabled snippet, given by filenames


oldThemes

oldThemes: string[]

List of theme names not fully updated to post v1.0.0 theme guidelines


snippets

snippets: string[]

List of snippets detected by Obsidian, given by their filenames


theme

theme: string

Currently active theme, given by its name


themes

themes: CustomCSSThemesRecord

Mapping of theme names to their manifest

Methods

addChild()

addChild<T>(component): T

Adds a child component, loading it if this component is loaded

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

Component.addChild


checkForUpdate()

checkForUpdate(themeName): void

Check whether a specific theme can be updated

Parameters

themeName: string

Name of the theme to check

Returns

void


checkForUpdates()

checkForUpdates(): void

Check all themes for updates

Returns

void


disableTranslucency()

disableTranslucency(): void

Disable translucency of application background

Returns

void


downloadLegacyTheme()

downloadLegacyTheme(arg): Promise<string>

Fetch legacy theme CSS using the pre-v1.0.0 theme download pipeline

Parameters

arg

arg.repo: string

Returns

Promise<string>

String obsidian.css contents


enableTranslucency()

enableTranslucency(): void

Enable translucency of application background

Returns

void


getManifest()

getManifest(repoUrl): Promise<ThemeManifest>

Fetch a theme’s manifest using repository URL

Parameters

repoUrl: string

Returns

Promise<ThemeManifest>


getSnippetPath()

getSnippetPath(snippetName): string

Convert snippet name to its corresponding filepath (relative to vault root)

Parameters

snippetName: string

Returns

string

String .obsidian/snippets/${snippetName}.css


getSnippetsFolder()

getSnippetsFolder(): string

Returns the folder path where snippets are stored (relative to vault root)

Returns

string


getThemeFolder()

getThemeFolder(): string

Returns the folder path where themes are stored (relative to vault root)

Returns

string


getThemePath()

getThemePath(themeName): string

Convert theme name to its corresponding filepath (relative to vault root)

Parameters

themeName: string

Returns

string

String .obsidian/themes/${themeName}/theme.css


hasUpdates()

hasUpdates(): boolean

Returns whether there are themes that can be updated

Returns

boolean


installLegacyTheme()

installLegacyTheme(arg): Promise<void>

Install a legacy theme using the pre-v1.0.0 theme download pipeline
Will create a corresponding dummy manifest for the theme

Parameters

arg

arg.author: string

arg.name: string

arg.repo: string

Returns

Promise<void>


installTheme()

installTheme(arg, version): Promise<void>

Install a theme using the regular theme download pipeline

Parameters

arg

arg.author: string

arg.name: string

arg.repo: string

version: string

Returns

Promise<void>


isThemeInstalled()

isThemeInstalled(themeName): boolean

Check whether a specific theme is installed by theme name

Parameters

themeName: string

Returns

boolean


load()

load(): void

Load this component and its children

Returns

void

Inherited from

Component.load


loadCss()

loadCss(arg1): Promise<unknown>

Parameters

arg1: unknown

Returns

Promise<unknown>


loadData()

loadData(): unknown

Returns

unknown


loadSnippets()

loadSnippets(): unknown

Returns

unknown


loadTheme()

loadTheme(arg1): unknown

Parameters

arg1: unknown

Returns

unknown


onunload()

onunload(): void

Override this to unload your component

Returns

void

Inherited from

Component.onunload


register()

register(cb): void

Registers a callback to be called when unloading

Parameters

cb

Returns

void

Inherited from

Component.register


registerDomEvent()

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof WindowEventMap

Parameters

el: Window

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof DocumentEventMap

Parameters

el: Document

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof HTMLElementEventMap

Parameters

el: HTMLElement

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Registers an event to be detached when unloading

Parameters

eventRef: EventRef

Returns

void

Inherited from

Component.registerEvent


registerInterval()

registerInterval(id): number

Registers an interval (from setInterval) to be cancelled when unloading Use setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API

Parameters

id: number

Returns

number

Inherited from

Component.registerInterval


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Parameters

keymapEventHandler: KeymapEventHandler

Returns

void

Inherited from

Component.registerScopeEvent


removeChild()

removeChild<T>(component): T

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

Component.removeChild


removeTheme()

removeTheme(themeName): Promise<void>

Remove a theme by theme name

Parameters

themeName: string

Returns

Promise<void>


setCssEnabledStatus()

setCssEnabledStatus(snippetName, enabled): void

Set the activation status of a snippet by snippet name

Parameters

snippetName: string

enabled: boolean

Returns

void


setTheme()

setTheme(themeName): void

Set the active theme by theme name

Parameters

themeName: string

Returns

void


setTranslucency()

setTranslucency(translucency): void

Set the translucency of application background

Parameters

translucency: boolean

Returns

void


unload()

unload(): void

Unload this component and its children

Returns

void

Inherited from

Component.unload