Skip to main content

Editor.Model.AssetContext.Item

Class

Represents a single selected asset entry, pairing an asset reference with its file path.

Index

Properties

Example

// Register a context action that accesses AssetContext.Item properties.
const registry = this.pluginSystem.findInterface(
Editor.IContextActionRegistry.interfaceId
) as Editor.IContextActionRegistry;
if (Editor.isNull(registry)) {
console.log('IContextActionRegistry not available');
return;
}

const guard = registry.registerAction((ctx: Editor.IContext) => {
const assetCtx = ctx as Editor.Model.AssetContext;
for (const item of assetCtx.selection) {
// Each Item has readonly asset and path properties
const asset: Editor.Assets.Asset = item.asset;
const path: Editor.Path = item.path;
console.log('Asset name:', asset.name);
console.log('Asset path:', path.toString());
}
return undefined as unknown as Editor;
});
this.guards.push(guard);
console.log('Asset context item action registered');

Properties

asset

readonly asset: Asset

The asset associated with this context item.


path

readonly path: Path

The path of the asset within the context.