WorkspaceProtocolHandler
Unofficial
Dispatches Obsidian URI (obsidian://) actions to registered protocol handlers.
Import:
import type { WorkspaceProtocolHandler } from '@obsidian-typings/obsidian-catalyst-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. | |
| dispatchQueue | PromisedQueue | Queue that serializes the dispatching of incoming URI actions. | |
| handlers | Map<string, ObsidianProtocolHandler> | Registered handlers keyed by action name. | |
| sources | Record<string, string> | Display names of the plugins that registered each action, keyed by action name. | |
| trustedActions | Record<string, boolean> | Actions the user has chosen to always trust, keyed by action name. Persisted in local storage. | |
| 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. | |
| getSource(name) | null | string | Get the display name of the plugin that registered an action. | |
| getTrustedActions() | string[] | Get the names of all trusted actions. | |
| handleXCallback(params, file) | boolean | Handle the x-success / x-error callbacks of an x-callback-url action. | |
| init() | void | Install the global URI action hook (window.OBS_ACT) and, on mobile, the Capacitor app-url listener. | |
| off(name, callback) | void | Remove an event listener. (Inherited from Events) | |
| offref(ref) | void | Remove an event listener by reference. (Inherited from Events) | |
| on('change', callback, ctx?) | EventRef | Triggered when the set of trusted actions changes. | |
| on(name, callback, ctx?) | EventRef | Add an event listener. (Inherited from Events) | |
| promptConfirmation(fragmentEl, action) | Promise<'once' | 'trust' | false> | Open a confirmation dialog and resolve with the user's choice. | |
| register(name, handler, source?) | void | Register a handler for an action. | |
| registerDefaultHandlers() | void | Register the built-in handlers (open, search, new, etc.). | |
| removeTrustedAction(name) | void | Remove an action from the trusted list. | |
| showConfirmModal(params) | Promise<boolean> | Show the confirmation modal for an untrusted action and resolve whether to proceed. | |
| 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: