ViewRegistry
Unofficial
Registry that maps view types to their constructors and file extensions to view types.
Import:
import type { ViewRegistry } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface ViewRegistry extends EventsExtends: Events
Constructor
new ViewRegistry()Constructor.
To get the constructor instance, use getViewRegistryConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| _ | Record<string, EventsEntry[]> | Internal storage of registered event handlers by event name. (Inherited from Events) | |
| typeByExtension | ViewRegistryTypeByExtensionRecord | Mapping of file extensions to view type. | |
| viewByType | ViewRegistryViewByTypeRecord | Mapping of view type to view constructor. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| getTypeByExtension(extension) | string | undefined | Get the view type associated with a file extension. | |
| getViewCreatorByType(type) | undefined | ViewCreator | Get the view creator function associated with a view type. | |
| getViewCreatorByType(type) | TypedViewCreator<ViewTypeViewMapping[TViewType]> | undefined | Get the view constructor associated with a view type. | |
| isExtensionRegistered(extension) | boolean | Check whether a view type is registered. | |
| off(name, callback) | void | Remove an event listener. (Inherited from Events) | |
| offref(ref) | void | Remove an event listener by reference. (Inherited from Events) | |
| on('extensions-updated', callback) | EventRef | Called when the file extensions mapping has been updated. | |
| on('view-registered', callback) | EventRef | Called when a view of type has been registered into the registry. | |
| on('view-unregistered', callback) | EventRef | Called when a view of type has been unregistered from the registry. | |
| on(name, callback, ctx?) | EventRef | Add an event listener. (Inherited from Events) | |
| registerExtensions(extensions, viewType) | void | Register a view type for file extensions. | |
| registerView(type, viewCreator) | void | Register a view constructor for a view type. | |
| registerViewWithExtensions(extensions, type, viewCreator) | void | Register a view and its associated file extensions. | |
| trigger(name, data?) | void | Trigger an event, executing all the listeners in order even if some of them throw an error. (Inherited from Events) | |
| tryTrigger(evt, args) | void | Try to trigger an event, executing all the listeners in order even if some of them throw an error. (Inherited from Events) | |
| unregisterExtensions(extensions) | void | Unregister extensions for a view type. | |
| unregisterView(type) | void | Unregister a view type. |
Links to this page: