Select the button block to edit its fields: label, link and colour.
A plugin is a plain BlockPlugin object: a block type with an editor view, a site
preview, fields and optionally a markdown form. The bundled plugins are written the same way, with only what the
core exports. Props are untrusted user input: the preview checks links and colours (safeColor)
and never renders them with {@html}.
Three files: the plugin object, its editor view and its preview.
import { MousePointerClick } from '@lucide/svelte';
import { mdText, type BlockPlugin } from '@atom-forge/brickee';
import ButtonView, { type ButtonProps } from './ButtonView.svelte';
import ButtonPreview from './ButtonPreview.svelte';
export const button: BlockPlugin<ButtonProps> = {
type: 'button', // stored in documents: never rename it
label: 'Button',
hint: 'A link as a button',
keys: 'button link cta',
icon: MousePointerClick,
props: () => ({ label: '', url: '', color: '#2563eb' }),
fields: [
{ key: 'label', label: 'Label', kind: 'text' },
{ key: 'url', label: 'Link', kind: 'text', placeholder: 'https://…' },
{ key: 'color', label: 'Colour', kind: 'color' }
],
tag: () => 'button',
content: 'none',
markdown: (p) => (p.url ? `[${mdText(p.label)}](${p.url})` : ''),
view: ButtonView,
preview: ButtonPreview
};
Select the button block to edit its fields: label, link and colour.