Skip to content

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 Events

Extends: Events

Constructor

new WorkspaceProtocolHandler(app: App, workspace: Workspace)

Constructor.

To get the constructor instance, use getWorkspaceProtocolHandlerConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
_Record<string, EventsEntry[]>Internal storage of registered event handlers by event name.
(Inherited from Events)
appAppReference to the app.
handlersMap<string, ObsidianProtocolHandler>Registered handlers keyed by action name.
workspaceWorkspaceReference to the workspace.

Methods

MethodReturnsDescription
dispatch(params)voidDispatch a parsed URI action to its registered handler.
execCapacitorUrl(url)voidParse 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)booleanHandle the x-success / x-error callbacks of an x-callback-url action. Does nothing unless URI callbacks are enabled, see WorkspaceProtocolHandler.isCallbacksEnabled.
init()voidInstall the global URI action hook (window.OBS_ACT) and, on mobile, the Capacitor app-url listener.
isCallbacksEnabled()booleanCheck 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)voidRemove an event listener.
(Inherited from Events)
offref(ref)voidRemove an event listener by reference.
(Inherited from Events)
on(name, callback, ctx?)EventRefAdd an event listener.
(Inherited from Events)
register(name, handler)voidRegister a handler for an action.
registerDefaultHandlers()voidRegister the built-in handlers (open, search, new, etc.).
setCallbacksEnabled(enabled)voidEnable or disable URI callbacks on this device.
trigger(name, data?)voidTrigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)
tryTrigger(evt, args)voidTry to trigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)
unregister(name, handler?)voidUnregister a handler for an action.

Links to this page: