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