WorkspaceProtocolHandler
Unofficial
Dispatches Obsidian URI (obsidian://) actions to registered protocol handlers.
Import:
import type { WorkspaceProtocolHandler } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface WorkspaceProtocolHandler extends EventsExtends: Events
Constructor
new WorkspaceProtocolHandler(app: App, workspace: Workspace)Constructor.
To get the constructor instance, use getWorkspaceProtocolHandlerConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| _ | Record<string, EventsEntry[]> | Internal storage of registered event handlers by event name. (Inherited from Events) | |
| app | App | Reference to the app. | |
| handlers | Map<string, ObsidianProtocolHandler> | Registered handlers keyed by action name. | |
| workspace | Workspace | Reference to the workspace. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| dispatch(params) | void | Dispatch a parsed URI action to its registered handler. | |
| execCapacitorUrl(url) | void | Parse and dispatch a Capacitor (mobile) deep-link URL. Reloads the app into the target vault if the URL points at a different vault. | |
| handleXCallback(params, file) | boolean | Handle the x-success / x-error callbacks of an x-callback-url action. Does nothing unless URI callbacks are enabled, see WorkspaceProtocolHandler.isCallbacksEnabled. | |
| init() | void | Install the global URI action hook (window.OBS_ACT) and, on mobile, the Capacitor app-url listener. | |
| isCallbacksEnabled() | boolean | Check whether URI callbacks are enabled. They gate x-success / x-error handling and the hook-get-address action. The setting is stored per device, in the uri-callbacks local storage key, and is off by default. | |
| off(name, callback) | void | Remove an event listener. (Inherited from Events) | |
| offref(ref) | void | Remove an event listener by reference. (Inherited from Events) | |
| on(name, callback, ctx?) | EventRef | Add an event listener. (Inherited from Events) | |
| register(name, handler) | void | Register a handler for an action. | |
| registerDefaultHandlers() | void | Register the built-in handlers (open, search, new, etc.). | |
| setCallbacksEnabled(enabled) | void | Enable or disable URI callbacks on this device. | |
| 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) | |
| unregister(name, handler?) | void | Unregister a handler for an action. |
Links to this page: