Plugins in data/plugins are loaded at startup and can add a tab with a read-only node board, and the demo plugin shows every asset as a node (#113)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2a390e52ff
commit
57a97ba94f
22 files changed
+1153
-57
No files matched your search
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 });
|
||||
}
|
||||
Reference in new issue
Block a user