Syncfusion Blazor Block Editor
Component Overview
The Syncfusion Blazor Block Editor is a powerful, modular content creation component that enables users to build rich, structured documents using customizable blocks. Each block represents a specific content type—headings, paragraphs, lists, tables, images, code blocks, and more—providing a clean, organized editing experience.
Key Features
- Block-Based Architecture: Create structured content using distinct block types (heading, paragraph, list, table, image, code, quote, callout, divider, toggle)
- Intuitive Menus: Slash command menu (
/), context menu (right-click), block action menu (hover), and inline toolbar (text selection)
- Drag-and-Drop Reordering: Rearrange blocks intuitively by dragging
- Undo/Redo Support: Full history management with configurable stack depth
- Keyboard Shortcuts: Comprehensive shortcuts for formatting, block creation, and editor operations
- Paste Cleanup: Advanced HTML sanitization, style filtering, and tag removal for safe content pasting
- Event System: Created, BlockChanged, SelectionChanged, Focus, Blur, and paste lifecycle events
- Responsive Design: Adaptive to different screen sizes and viewports
- Read-Only Mode: Display-only content without editing capabilities
- Custom Styling: CSS class customization and theme integration
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installation via NuGet (Visual Studio, VS Code, .NET CLI)
- Blazor Web App project setup
- Service registration and configuration
- Import namespaces and add theme resources
- Render modes (Server, WebAssembly, Auto)
- Basic component initialization
- Block configuration and data binding
Appearance and Styling
📄 Read: references/appearance-and-styling.md
- Set component width and height
- Read-only mode configuration
- Custom CSS class application
- Responsive design patterns
- Theme customization and styling approaches
- Style examples and best practices
Editor Menus
📄 Read: references/editor-menus.md
- Slash command menu (built-in items, customization, events)
- Context menu (right-click actions, customization, events)
- Block action menu (drag handle actions, customization, events)
- Inline toolbar (text formatting options, customization, events, optional items - transform, inline code, link)
- Menu event handling and filtering
- Custom command and menu item creation
Built-In Blocks
📄 Read: references/built-in-blocks.md
- Heading blocks (levels 1-4)
- Paragraph blocks
- List types (bullet, numbered, checklist)
- Table blocks
- Code blocks
- Image/media blocks (imageSettings properties, resizing config, image upliads )
- Quote and callout blocks
- Toggle (collapsible) blocks
- Divider blocks
- Block nesting and hierarchy
Drag-Drop and Undo-Redo
📄 Read: references/drag-drop-and-undo.md
- Enable/disable drag-and-drop
- Single and multiple block dragging
- Undo/redo keyboard shortcuts
- Configure undo/redo stack depth
- History management and state tracking
- Drag operation visual feedback
Events and Interactions
📄 Read: references/events-and-interactions.md
- Created event (initialization)
- BlockChanged event (structural changes)
- SelectionChanged event (text selection)
- Focus and Blur events (editor state)
- Keyboard shortcuts (content editing, block creation, block management, general operations)
- Custom keyboard shortcut configuration (KeyConfig)
- Event handler patterns and examples
Content Handling
📄 Read: references/content-handling.md
- Getting and setting block content
- Content model structure (BlockModel, ContentModel)
- Paste cleanup configuration (DeniedTags, KeepFormat, PlainText)
- PasteCleanupStarting and PasteCleanupCompleted events
- Security best practices (XSS prevention)
- Content validation patterns
Labels and Mentions
📄 Read: references/labels-and-mentions.md
- UserModel for mentioning users (@mentions)
- LabelItemModel for tagging content (#labels)
- BlockEditorLabel component configuration
- MentionContentSettings and LabelContentSettings
- Implementing collaborative mentions and labels
- Practical workflow examples and patterns
Advanced Methods
📄 Read: references/advanced-methods.md
- GetSelectedBlocksAsync() - Retrieve selected blocks
- SelectAllBlocksAsync() - Select all blocks programmatically
- FocusInAsync() / FocusOutAsync() - Manage editor focus
- PrintAsync() - Print editor content
- EnableToolbarItemsAsync() / DisableToolbarItemsAsync() - Control toolbar availability
- Advanced workflow patterns and use cases
Advanced Features
📄 Read: references/advanced-features.md
- WebAssembly integration and considerations
- Performance optimization strategies
- Custom block type implementation
- Accessibility features (WCAG compliance)
- Auto-save and state persistence patterns
- Common troubleshooting scenarios
Quick Start Example
@using Syncfusion.Blazor.BlockEditor
@rendermode InteractiveAuto
<div id="container" style="height: 500px; width: 100%;">
<SfBlockEditor @bind-Blocks="blockData" EnableDragAndDrop="true">
<BlockEditorCommandMenu></BlockEditorCommandMenu>
<BlockEditorContextMenu Enable="true"></BlockEditorContextMenu>
<BlockEditorActionMenu Enable="true"></BlockEditorActionMenu>
<BlockEditorInlineToolbar Enable="true"></BlockEditorInlineToolbar>
<BlockEditorPasteCleanup DeniedTags="@(new string[] { "script", "iframe" })">
</BlockEditorPasteCleanup>
</SfBlockEditor>
</div>
@code {
private List<BlockModel> blockData = new List<BlockModel>
{
new BlockModel
{
BlockType = BlockType.Heading,
Properties = new HeadingBlockSettings { Level = 1 },
Content = new List<ContentModel>
{
new ContentModel { ContentType = ContentType.Text, Content = "Welcome to Block Editor" }
}
},
new BlockModel
{
BlockType = BlockType.Paragraph,
Content = new List<ContentModel>
{
new ContentModel { ContentType = ContentType.Text, Content = "Start typing or use / to add new blocks..." }
}
}
};
}
Common Patterns
Pattern 1: Event-Driven Content Tracking
Monitor document changes in real-time for auto-save or logging:
<SfBlockEditor BlockChanged="@OnBlockChanged"
SelectionChanged="@OnSelectionChanged">
</SfBlockEditor>
@code {
private void OnBlockChanged(BlockChangedEventArgs args)
{
// Auto-save, track changes, update UI
}
private void OnSelectionChanged(SelectionChangedEventArgs args)
{
// Update toolbar state based on selection
}
}
Pattern 2: Read-Only Preview Mode
Display finalized content without editing:
<SfBlockEditor @bind-Blocks="blockData" ReadOnly="true">
</SfBlockEditor>
Pattern 3: Custom Keyboard Shortcuts
Override default shortcuts for application-specific commands:
<SfBlockEditor KeyConfig="@customShortcuts">
</SfBlockEditor>
@code {
private Dictionary<string, string> customShortcuts = new()
{
{ "Bold", "alt+b" },
{ "Italic", "alt+i" }
};
}
Pattern 4: Secure Paste with Content Filtering
Control paste behavior for safety and consistency:
<BlockEditorPasteCleanup
DeniedTags="@deniedTags"
PlainText="false">
</BlockEditorPasteCleanup>
@code {
private string[] deniedTags = { "script", "iframe", "object" };
}
Key Properties
| Property |
Type |
Default |
Purpose |
Blocks |
List<BlockModel> |
Empty |
The content blocks bound to the editor |
Width |
string |
"100%" |
Editor container width |
Height |
string |
"auto" |
Editor container height |
ReadOnly |
bool |
false |
Enable/disable read-only mode |
EnableDragAndDrop |
bool |
true |
Enable/disable block dragging |
UndoRedoStack |
int |
30 |
Maximum undo/redo history depth |
CssClass |
string |
"" |
Custom CSS classes for styling |
KeyConfig |
Dictionary<string, string> |
Default shortcuts |
Custom keyboard shortcuts |
Common Use Cases
- Blog Platform: Create a rich blog editor with headings, images, and formatting
- Document Management: Build document creators for articles and reports
- Knowledge Base: Implement structured content editors for documentation
- Content Preview: Display finalized documents in read-only mode
- Form Builder: Use blocks to create dynamic form templates
- Email Templates: Create email templates with customizable blocks
- Proposal Builder: Generate professional proposals with block-based structure
1---
2name: syncfusion-blazor-blockeditor
3description: Implement Syncfusion Blazor Block Editor for modular, block-based rich content creation. ALWAYS use when building structured document editors with customizable blocks like headings, paragraphs, lists, and media. Immediately configure menus, drag-drop, undo/redo, paste cleanup, and events.
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7---
8
9# Syncfusion Blazor Block Editor
10
11## Component Overview
12
13The Syncfusion Blazor Block Editor is a powerful, modular content creation component that enables users to build rich, structured documents using customizable blocks. Each block represents a specific content type—headings, paragraphs, lists, tables, images, code blocks, and more—providing a clean, organized editing experience.
14
15### Key Features
16
17- **Block-Based Architecture**: Create structured content using distinct block types (heading, paragraph, list, table, image, code, quote, callout, divider, toggle)
18- **Intuitive Menus**: Slash command menu (`/`), context menu (right-click), block action menu (hover), and inline toolbar (text selection)
19- **Drag-and-Drop Reordering**: Rearrange blocks intuitively by dragging
20- **Undo/Redo Support**: Full history management with configurable stack depth
21- **Keyboard Shortcuts**: Comprehensive shortcuts for formatting, block creation, and editor operations
22- **Paste Cleanup**: Advanced HTML sanitization, style filtering, and tag removal for safe content pasting
23- **Event System**: Created, BlockChanged, SelectionChanged, Focus, Blur, and paste lifecycle events
24- **Responsive Design**: Adaptive to different screen sizes and viewports
25- **Read-Only Mode**: Display-only content without editing capabilities
26- **Custom Styling**: CSS class customization and theme integration
27
28## Documentation and Navigation Guide
29
30### Getting Started
31📄 **Read:** [references/getting-started.md](references/getting-started.md)
32- Installation via NuGet (Visual Studio, VS Code, .NET CLI)
33- Blazor Web App project setup
34- Service registration and configuration
35- Import namespaces and add theme resources
36- Render modes (Server, WebAssembly, Auto)
37- Basic component initialization
38- Block configuration and data binding
39
40### Appearance and Styling
41📄 **Read:** [references/appearance-and-styling.md](references/appearance-and-styling.md)
42- Set component width and height
43- Read-only mode configuration
44- Custom CSS class application
45- Responsive design patterns
46- Theme customization and styling approaches
47- Style examples and best practices
48
49### Editor Menus
50📄 **Read:** [references/editor-menus.md](references/editor-menus.md)
51- Slash command menu (built-in items, customization, events)
52- Context menu (right-click actions, customization, events)
53- Block action menu (drag handle actions, customization, events)
54- Inline toolbar (text formatting options, customization, events, optional items - transform, inline code, link)
55- Menu event handling and filtering
56- Custom command and menu item creation
57
58### Built-In Blocks
59📄 **Read:** [references/built-in-blocks.md](references/built-in-blocks.md)
60- Heading blocks (levels 1-4)
61- Paragraph blocks
62- List types (bullet, numbered, checklist)
63- Table blocks
64- Code blocks
65- Image/media blocks (imageSettings properties, resizing config, image upliads )
66- Quote and callout blocks
67- Toggle (collapsible) blocks
68- Divider blocks
69- Block nesting and hierarchy
70
71### Drag-Drop and Undo-Redo
72📄 **Read:** [references/drag-drop-and-undo.md](references/drag-drop-and-undo.md)
73- Enable/disable drag-and-drop
74- Single and multiple block dragging
75- Undo/redo keyboard shortcuts
76- Configure undo/redo stack depth
77- History management and state tracking
78- Drag operation visual feedback
79
80### Events and Interactions
81📄 **Read:** [references/events-and-interactions.md](references/events-and-interactions.md)
82- Created event (initialization)
83- BlockChanged event (structural changes)
84- SelectionChanged event (text selection)
85- Focus and Blur events (editor state)
86- Keyboard shortcuts (content editing, block creation, block management, general operations)
87- Custom keyboard shortcut configuration (KeyConfig)
88- Event handler patterns and examples
89
90### Content Handling
91📄 **Read:** [references/content-handling.md](references/content-handling.md)
92- Getting and setting block content
93- Content model structure (BlockModel, ContentModel)
94- Paste cleanup configuration (DeniedTags, KeepFormat, PlainText)
95- PasteCleanupStarting and PasteCleanupCompleted events
96- Security best practices (XSS prevention)
97- Content validation patterns
98
99### Labels and Mentions
100📄 **Read:** [references/labels-and-mentions.md](references/labels-and-mentions.md)
101- UserModel for mentioning users (@mentions)
102- LabelItemModel for tagging content (#labels)
103- BlockEditorLabel component configuration
104- MentionContentSettings and LabelContentSettings
105- Implementing collaborative mentions and labels
106- Practical workflow examples and patterns
107
108### Advanced Methods
109📄 **Read:** [references/advanced-methods.md](references/advanced-methods.md)
110- GetSelectedBlocksAsync() - Retrieve selected blocks
111- SelectAllBlocksAsync() - Select all blocks programmatically
112- FocusInAsync() / FocusOutAsync() - Manage editor focus
113- PrintAsync() - Print editor content
114- EnableToolbarItemsAsync() / DisableToolbarItemsAsync() - Control toolbar availability
115- Advanced workflow patterns and use cases
116
117### Advanced Features
118📄 **Read:** [references/advanced-features.md](references/advanced-features.md)
119- WebAssembly integration and considerations
120- Performance optimization strategies
121- Custom block type implementation
122- Accessibility features (WCAG compliance)
123- Auto-save and state persistence patterns
124- Common troubleshooting scenarios
125
126## Quick Start Example
127
128```razor
129@using Syncfusion.Blazor.BlockEditor
130
131@rendermode InteractiveAuto
132
133<div id="container" style="height: 500px; width: 100%;">
134 <SfBlockEditor @bind-Blocks="blockData" EnableDragAndDrop="true">
135 <BlockEditorCommandMenu></BlockEditorCommandMenu>
136 <BlockEditorContextMenu Enable="true"></BlockEditorContextMenu>
137 <BlockEditorActionMenu Enable="true"></BlockEditorActionMenu>
138 <BlockEditorInlineToolbar Enable="true"></BlockEditorInlineToolbar>
139 <BlockEditorPasteCleanup DeniedTags="@(new string[] { "script", "iframe" })">
140 </BlockEditorPasteCleanup>
141 </SfBlockEditor>
142</div>
143
144@code {
145 private List<BlockModel> blockData = new List<BlockModel>
146 {
147 new BlockModel
148 {
149 BlockType = BlockType.Heading,
150 Properties = new HeadingBlockSettings { Level = 1 },
151 Content = new List<ContentModel>
152 {
153 new ContentModel { ContentType = ContentType.Text, Content = "Welcome to Block Editor" }
154 }
155 },
156 new BlockModel
157 {
158 BlockType = BlockType.Paragraph,
159 Content = new List<ContentModel>
160 {
161 new ContentModel { ContentType = ContentType.Text, Content = "Start typing or use / to add new blocks..." }
162 }
163 }
164 };
165}
166```
167
168## Common Patterns
169
170### Pattern 1: Event-Driven Content Tracking
171Monitor document changes in real-time for auto-save or logging:
172
173```razor
174<SfBlockEditor BlockChanged="@OnBlockChanged"
175 SelectionChanged="@OnSelectionChanged">
176</SfBlockEditor>
177
178@code {
179 private void OnBlockChanged(BlockChangedEventArgs args)
180 {
181 // Auto-save, track changes, update UI
182 }
183
184 private void OnSelectionChanged(SelectionChangedEventArgs args)
185 {
186 // Update toolbar state based on selection
187 }
188}
189```
190
191### Pattern 2: Read-Only Preview Mode
192Display finalized content without editing:
193
194```razor
195<SfBlockEditor @bind-Blocks="blockData" ReadOnly="true">
196</SfBlockEditor>
197```
198
199### Pattern 3: Custom Keyboard Shortcuts
200Override default shortcuts for application-specific commands:
201
202```razor
203<SfBlockEditor KeyConfig="@customShortcuts">
204</SfBlockEditor>
205
206@code {
207 private Dictionary<string, string> customShortcuts = new()
208 {
209 { "Bold", "alt+b" },
210 { "Italic", "alt+i" }
211 };
212}
213```
214
215### Pattern 4: Secure Paste with Content Filtering
216Control paste behavior for safety and consistency:
217
218```razor
219<BlockEditorPasteCleanup
220 DeniedTags="@deniedTags"
221 PlainText="false">
222</BlockEditorPasteCleanup>
223
224@code {
225 private string[] deniedTags = { "script", "iframe", "object" };
226}
227```
228
229## Key Properties
230
231| Property | Type | Default | Purpose |
232|----------|------|---------|---------|
233| `Blocks` | `List<BlockModel>` | Empty | The content blocks bound to the editor |
234| `Width` | `string` | "100%" | Editor container width |
235| `Height` | `string` | "auto" | Editor container height |
236| `ReadOnly` | `bool` | false | Enable/disable read-only mode |
237| `EnableDragAndDrop` | `bool` | true | Enable/disable block dragging |
238| `UndoRedoStack` | `int` | 30 | Maximum undo/redo history depth |
239| `CssClass` | `string` | "" | Custom CSS classes for styling |
240| `KeyConfig` | `Dictionary<string, string>` | Default shortcuts | Custom keyboard shortcuts |
241
242## Common Use Cases
243
2441. **Blog Platform**: Create a rich blog editor with headings, images, and formatting
2452. **Document Management**: Build document creators for articles and reports
2463. **Knowledge Base**: Implement structured content editors for documentation
2475. **Content Preview**: Display finalized documents in read-only mode
2486. **Form Builder**: Use blocks to create dynamic form templates
2497. **Email Templates**: Create email templates with customizable blocks
2508. **Proposal Builder**: Generate professional proposals with block-based structure