Skip to content

UnlockActiveNoteCommandHandler

A command handler that unlocks the active note. It cancels the operation that took the lock and releases the lock covering the note — whether the note is locked directly or by a subtree-locked ancestor folder. Only available while the active note is locked.

Import:

import { UnlockActiveNoteCommandHandler } from 'obsidian-dev-utils/obsidian/command-handlers/unlock-active-note-command-handler';

Signature:

export class UnlockActiveNoteCommandHandler extends GlobalCommandHandler

Extends: GlobalCommandHandler

Constructor

new UnlockActiveNoteCommandHandler(params: UnlockActiveNoteCommandHandlerConstructorParams)

Constructs a new instance.

Properties

PropertyTypeDescription
appAppThe Obsidian app instance.
iconIconNameThe icon for the command.
(Inherited from GlobalCommandHandler)
idstringThe ID of the command.
(Inherited from GlobalCommandHandler)
namestringThe display name of the command.
(Inherited from GlobalCommandHandler)
resourceLockComponentResourceLockComponentThe resource-lock component whose lock covering the active note the command releases.

Methods

MethodReturnsDescription
buildCommand()CommandBuilds a plain Obsidian Command object with a checkCallback.
(Inherited from GlobalCommandHandler)
canExecute()booleanChecks whether the command can currently execute: only when there is an active note covered by a lock (directly or by a subtree-locked ancestor folder).
execute()voidExecutes the command, unlocking the active note.
onRegistered(context)Promise<void>Called after the command has been registered with Obsidian. Subclasses use the provided context to register menu event handlers.

Throws when the same instance is registered twice. A handler stores per-registration state — the plugin name here, the active-file provider and the submenu override in AbstractFileCommandHandler, plus whatever a subclass records — and the menu closures registered here read that state lazily, at menu-render time. So a second registration silently rewrites what the first registration's closures will see. CommandHandlerComponent registers a handler set once per menu surface, which is why CommandHandlerFactory must build FRESH instances on every call; this guard turns a factory that hands out shared instances into a loud failure instead of a wrong context menu.
(Inherited from GlobalCommandHandler)

Links to this page: