Skip to content

lockResourceForPath

Locks the note at the given path, making it read-only in every current and future MarkdownView until the lock is released, and showing a lock indicator in the tab header, view action bar, and (while active) the status bar. The indicators’ tooltip lists the plugins that currently hold a lock on the note.

The lock is reference-counted per calling plugin: each call must be balanced by exactly one release (either disposing the returned Disposable — ideally via a using declaration — or a matching unlockResourceForPath call).

Import:

import { lockResourceForPath } from 'obsidian-dev-utils/obsidian/resource-lock';

Signature:

function lockResourceForPath(params: LockResourceForPathParams): Disposable

Parameters:

ParameterTypeDescription
paramsLockResourceForPathParamsThe parameters for locking the note.

Returns: Disposable — A Disposable that releases this lock when disposed. Disposing more than once is a no-op.


Links to this page: