Skip to content

registerVirtualFile

Registers immutable text as a file without writing to the adapter.

The parent folder must exist. Markdown views are read-only; vault and adapter mutations of the path or its ancestors throw. Raw filesystem access and third-party views are outside this contract. Resource URLs use UTF-8 blobs. Disposing closes views of this file and revokes its URL. No create or delete events are emitted, so indexers and synchronization never treat it as a persisted file.

Import:

import { registerVirtualFile } from '@mnaoumov/obsidian-lib/virtual-file';

Signature:

function registerVirtualFile(params: RegisterVirtualFileParams): Promise<VirtualFile>

Parameters:

Parameter Type Description
params RegisterVirtualFileParams The app, path and immutable text.

Returns: Promise<VirtualFile> — The registered file, synchronous content and idempotent disposal callback.


Links to this page: