```
3. **Use template literals carefully:**
```typescript
// Ensure all ${} expressions return strings
return `
${defaults.title || ''}
`;
```
---
## Performance Considerations
### Block Count Impact
**Threshold:** 50+ blocks in library
**Symptoms:**
- Slow editor initialization (~1s+)
- Left panel laggy on scroll
**Mitigations:**
1. **Category filtering:**
- Only fetch blocks for specific category
- Lazy-load categories on expand
2. **Pagination:**
- Load first 20 blocks, fetch more on scroll
- Not implemented in current version
3. **Caching:**
- Store blocks in localStorage
- Refresh only when version changes
### Schema Complexity
**Issue:** Deeply nested array schemas (3+ levels) slow GrapesJS rendering
**Example:**
```json
{
"sections": {
"type": "array",
"items": {
"features": {
"type": "array",
"items": {
"details": {
"type": "array"
}
}
}
}
}
}
```
**Alternative:** Flatten structure or use CODE mode
---
## Security Considerations
### Admin-Only Access
**Protection:** All `/api/page-blocks` endpoints require admin role
```typescript
router.use(authenticate);
router.use(requireRole(UserRole.SUPER_ADMIN, UserRole.INFLUENCE_ADMIN, UserRole.MAP_ADMIN));
```
**Risk:** Malicious admin creates XSS block with ``
---
## Related Documentation
### Frontend Components
- **[GrapesJSEditor](/v2/frontend/components/GrapesJSEditor)** — Block registration logic
- **[LandingPageEditor](/v2/frontend/pages/LandingPageEditor)** — Fetches blocks for editor
### Backend Modules
- **[blocks.routes](/v2/backend/modules/pages/blocks.routes)** — CRUD endpoints
- **[blocks.service](/v2/backend/modules/pages/blocks.service)** — Business logic
- **[pages.schemas](/v2/backend/modules/pages/pages.schemas)** — Zod schemas
### Database
- **[PageBlock Model](/v2/database/models/pages)** — Schema + indexes
### Features
- **[Page Builder](page-builder.md)** — Landing page system
- **[GrapesJS Editor](grapes-editor.md)** — Editor integration
### Seed Data
- **[api/prisma/seed.ts](https://github.com/changemaker-lite/changemaker.lite/blob/v2/api/prisma/seed.ts)** — Default blocks definition