/** * Demo plugin (#113): a tab "Assets" that shows every asset of the project as a node, laid out in * a grid in the order of the asset list. It follows the project: adding, renaming or deleting an * asset redraws the board. * * A plugin imports nothing – everything it needs comes in through `api`. */ export const meta = { id: 'demo', name: 'Demo plugin', version: '1.0.0', api: 1 }; const COLUMNS = 4; const CELL_W = 220; const CELL_H = 64; export function activate(api) { const board = new api.ui.NodeBoard(); const show = () => board.setNodes( api.project.assets().map((asset, i) => ({ id: asset.id, title: asset.name, x: (i % COLUMNS) * CELL_W, y: Math.floor(i / COLUMNS) * CELL_H, })), ); show(); api.project.on('change', show); api.tabs.add({ id: 'assets', label: 'Assets', create: () => board }); }