Block plugins
Plugins let UI components — data tables, graphs, sequence alignments — own their persistent state. The component author packages state management into a plugin; the block developer registers an instance. The plugin handles its own initialization, persistence, and migrations.
Registering a plugin
Use .plugin() on the BlockModelV3 builder:
import { BlockModelV3, DataModelBuilder } from '@platforma-sdk/model';
// Assume `tablePlugin` is provided by a component libraryimport { tablePlugin } from '@platforma-sdk/ui-vue';
type BlockData = { inputRef?: PlRef; species: string;};
const dataModel = new DataModelBuilder() .from<BlockData>('v1') .init(() => ({ species: 'human' }));
export const platforma = BlockModelV3.create(dataModel) .args((data) => ({ inputRef: data.inputRef, species: data.species })) .argsIssues(({ args }) => args.inputRef === undefined ? [{ severity: 'error', message: 'Input is required' }] : [], ) .plugin('mainTable', tablePlugin.create({ joinType: 'inner' }), { columns: (ctx) => ctx.outputs?.resolve('data')?.getPColumns(), }) .done();.plugin() takes three arguments:
- Instance ID — a unique string identifying this plugin within the block (e.g.,
'mainTable') - Configured plugin — from
factory.create(config), provided by the component library - Params mapping — an object of lambdas that derive plugin inputs from the block’s render context
The params mapping is re-evaluated whenever block data changes, so the plugin always receives current inputs. Multiple plugins can be registered on the same block — each with a distinct instance ID.