/** * @file * * Mock of Obsidian's `ImageValue`, the Bases value wrapping a path to an image in the vault. */ import type { ImageValue as ImageValueOriginal } from 'obsidian'; import type { RenderContext } from './RenderContext.mjs'; import { StringValue } from './StringValue.mjs'; /** * Mock of Obsidian's `ImageValue`: a string value holding an image path. */ export declare class ImageValue extends StringValue { /** * The value type's identifier, `'Image'` - Obsidian's own name for this class of value. */ static type: string; /** * The lucide icon name standing for this value's type. */ icon: string; /** * Creates an image value. * * @param value - The path of the image resource. */ constructor(value?: string); /** * Mock-only factory: creates an image value, spyable via `vi.spyOn(ImageValue, 'create2__')`. The subclass * variant of {@link StringValue.create__}. * * @param value - The path of the image resource. * @returns The new image value. */ static create2__(value?: string): ImageValue; /** * Mock-only: views a value typed as Obsidian's `ImageValue` as this mock. * * @param value - The value typed as the original `ImageValue`. * @returns The same object, typed as the mock. */ static fromOriginalType5__(value: ImageValueOriginal): ImageValue; /** * Mock-only: views this mock as Obsidian's `ImageValue` type. * * @returns The same object, typed as the original `ImageValue`. */ asOriginalType5__(): ImageValueOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(ImageValue.prototype, 'constructor5__')`. * * @param _value - The image path the value was created with. */ constructor5__(_value: string): void; /** * Renders the image into an element, as Obsidian does: an `img` whose `src` is the vault resource path for * an in-vault image, and the value itself for anything else. * * The two branches are not symmetric, and the asymmetry is Obsidian's. An INTERNAL path is resolved through * `MetadataCache.getFirstLinkpathDest` and rendered only when it resolves to a file whose extension is an * image one - so a path that resolves to nothing, or to a note, renders NO element at all. An external * source always gets its `img`, with a desktop `file:///` source re-prefixed with * `Platform.resourcePathPrefix` first. * * The mock's `Vault.getResourcePath` answers an empty string, so an in-vault image renders an `img` with an * empty `src`. Its presence and its class are the observable part; spy on `getResourcePath` for a test that * needs a real path. * * @param el - The element to render into. * @param context - The rendering context, whose app resolves an in-vault path. */ renderTo(el: HTMLElement, context: RenderContext): void; }