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.
dispatchQueuePromisedQueueQueue that serializes the dispatching of incoming URI actions.
handlersMap<string, ObsidianProtocolHandler>Registered handlers keyed by action name.
sourcesRecord<string, string>Display names of the plugins that registered each action, keyed by action name.
trustedActionsRecord<string, boolean>Actions the user has chosen to always trust, keyed by action name. Persisted in local storage.
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.
getSource(name)null | stringGet the display name of the plugin that registered an action.
getTrustedActions()string[]Get the names of all trusted actions.
handleXCallback(params, file)booleanHandle the x-success / x-error callbacks of an x-callback-url action.
init()voidInstall the global URI action hook (window.OBS_ACT) and, on mobile, the Capacitor app-url listener.
off(name, callback)voidRemove an event listener.
(Inherited from Events)
offref(ref)voidRemove an event listener by reference.
(Inherited from Events)
on('change', callback, ctx?)EventRefTriggered when the set of trusted actions changes.
on(name, callback, ctx?)EventRefAdd 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?)voidRegister a handler for an action.
registerDefaultHandlers()voidRegister the built-in handlers (open, search, new, etc.).
removeTrustedAction(name)voidRemove 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?)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: