code-docs/plugins/blocks/basic.md
HTML primitive blocks for Lowdefy. Provides basic building blocks without framework dependencies.
This package contains simple HTML-based blocks that:
| Block | HTML Element | Purpose |
|---|---|---|
Box | <div> | Generic container |
Span | <span> | Inline container |
Html | <div> | Renders HTML string (sanitized) |
DangerousHtml | <div> | Renders raw HTML (unsanitized) |
Img | `` | Image element |
Icon | SVG | Icon from icon library |
Anchor | <a> | HTML anchor/link |
List | <ul>/<ol> | HTML list |
The most commonly used container:
- id: container
type: Box
style:
padding: 20px
backgroundColor: '#f0f0f0'
areas:
content:
blocks:
- id: child
type: Title
Renders sanitized HTML:
- id: content
type: Html
properties:
html: '<p>This is <strong>safe</strong> HTML</p>'
Sanitization removes:
<script> tagsRenders raw HTML without sanitization:
- id: widget
type: DangerousHtml
properties:
html:
_request: getEmbedCode
Warning: Only use with trusted content. Vulnerable to XSS if content is user-provided.
Renders icons from icon libraries:
- id: icon
type: Icon
properties:
name: AiOutlineUser # Ant Design icon
size: 24
color: '#1890ff'
Supported icon libraries:
AiOutline*, AiFilled*)Simple image element:
- id: logo
type: Img
properties:
src: /images/logo.png
alt: Company Logo
width: 200
HTML list rendering:
- id: features
type: List
properties:
ordered: false # ul vs ol
items:
- First item
- Second item
- Third item
Use basic blocks when:
The List block has an e2e helper for testing list rendering:
// src/blocks/List/e2e.js
import { createBlockHelper } from '@lowdefy/e2e-utils';
import { expect } from '@playwright/test';
const locator = (page, blockId) => page.locator(`#bl-${blockId}`);
export default createBlockHelper({
locator,
expect: {
itemCount: async (page, blockId, count) => {
const items = locator(page, blockId).locator('[id^="bl-"][id$=".$"]');
await expect(items).toHaveCount(count);
},
},
});
Usage in tests:
await ldf.block('items_list').expect.itemCount(5);
{
"exports": {
"./e2e/List": "./dist/blocks/List/e2e.js"
}
}