Syncfusion JavaScript BlockEditor
Overview
The Syncfusion JavaScript BlockEditor is a modern, block-based text editor that enables users to create, format, and organize content using various block types. It provides an intuitive editing experience with features like drag-and-drop reordering, slash commands, inline toolbars, and extensive customization options. The BlockEditor control is built on a block-based architecture where content is organized into discrete blocks. Each block has a specific type (paragraph, heading, list, image, etc.) and can contain formatted content. Key characteristics:
- Block Types: 14 built-in block types including typography, lists, tables, images, code, and collapsible sections
- Content Model: Structured content with BlockModel and ContentModel for programmatic manipulation
- Intuitive UX: Slash commands (/), drag handles, inline toolbars, and context menus
- Collaborative Editing: Real-time multi-user editing powered by Yjs, with presence, remote cursors, and version history
- Extensibility: Custom blocks, commands, menu items, and templates
- Data Formats: Import/export as HTML or JSON for flexible storage and interchange
- Accessibility: Keyboard navigation, ARIA attributes, and screen reader support
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installation and package setup (
@syncfusion/ej2-blockeditor)
- CSS imports and theme configuration (Tailwind3, Material, Bootstrap, etc.)
- Basic BlockEditor initialization and first render
- Webpack configuration for development environment
- Minimal working example with sample blocks
Blocks and Content Models
📄 Read: references/blocks-and-content-models.md
- Complete BlockModel interface (id, blockType, content, properties, cssClass, indent, parentId, template)
- BlockType enum (Paragraph, Heading, BulletList, NumberedList, Checklist, Table, Image, Code, Quote, Callout, Divider, CollapsibleParagraph, CollapsibleHeading, Template)
- ContentModel interface (id, contentType, content, properties)
- ContentType enum (Text, Link, Mention, Label)
- Block-specific properties (HeadingProps, ImageProps, CodeProps, ChecklistProps, CollapsibleProps, etc.)
- Content-specific properties (LinkContentProps, MentionContentProps, StyleModel)
- UserModel for mentions and collaboration
- BlockFactory class with helper methods for creating blocks
Built-in Block Types
📄 Read: references/built-in-block-types.md
- Typography blocks: Paragraph, Heading (1-4), Quote, Callout
- Text formatting: bold, italic, underline, strikethrough, uppercase, lowercase, subscript, superscript, inline code
- Font color and background color (text highlighting)
- List blocks: BulletList, NumberedList, Checklist (with isChecked)
- Table blocks with configuration
- Media blocks: Image with upload, resize, and constraints (imageBlockSettings)
- Code blocks with syntax highlighting and language selection (codeBlockSettings)
- Advanced blocks: CollapsibleParagraph, CollapsibleHeading, Divider, Template
- Nested block structures with parent-child relationships
Editor Menus and Toolbars
📄 Read: references/editor-menus-and-toolbars.md
- Slash Command Menu (/) - commandMenuSettings with CommandItemModel
- Block Action Menu (⋮ handle) - blockActionMenuSettings with BlockActionItemModel
- Context Menu (right-click) - contextMenuSettings with ContextMenuItemModel
- Inline Formatting Toolbar - inlineToolbarSettings with ToolbarItemModel and BuiltInToolbar enum
- Transform Menu - transformSettings for block type conversion
- Custom commands and menu items
- Menu events: filtering, itemSelect, beforeOpen, beforeClose
- Complete customization examples
Methods Reference
📄 Read: references/methods-reference.md
- Block management: addBlock, removeBlock, moveBlock, updateBlock
- Block queries: getBlock, getBlockCount, getSelectedBlocks
- Selection: selectBlock, selectAllBlocks, selectRange, setSelection, getRange, setCursorPosition
- Data operations: getDataAsHtml, getDataAsJson, parseHtmlToBlocks, renderBlocksFromJson
- Toolbar control: enableToolbarItems, disableToolbarItems, executeToolbarAction
- Focus management: focusIn, focusOut
- Utility: print, refresh, dataBind
- Lifecycle: appendTo, destroy, addEventListener, removeEventListener
Events Reference
📄 Read: references/events-reference.md
- Lifecycle: created
- Content: blockChanged (with BlockChangedEventArgs), selectionChanged
- Focus: focus (FocusEventArgs), blur (BlurEventArgs)
- Drag-drop: blockDragStart, blockDragging, blockDropped (with BlockDragEventArgs, BlockDropEventArgs)
- Paste: beforePasteCleanup, afterPasteCleanup (with PasteCleanupEventArgs)
- File upload: beforeFileUpload, fileUploading, fileUploadSuccess, fileUploadFailed
- Complete event arguments interfaces
- ActionType enum for undo/redo tracking
Drag-Drop and Selection
📄 Read: references/drag-drop-and-selection.md
- Drag-and-drop configuration (enableDragAndDrop property)
- Single and multiple block dragging
- Drag events and visual indicators
- Selection management methods
- Programmatic selection control
- NodeSelection class
- Cursor positioning
Paste, Undo/Redo, and Keyboard
📄 Read: references/paste-undo-redo-keyboard.md
- Paste cleanup configuration (pasteCleanupSettings with keepFormat, plainText, deniedTags)
- Paste events for interception and modification
- Undo/redo stack configuration (undoRedoStack property)
- Keyboard shortcuts (keyConfig property for custom shortcuts)
- Default keyboard commands
- Mentions (@user) with users property and UserModel
- Labels/tags ($label) with labelSettings property and LabelItemModel
Customization and Appearance
📄 Read: references/customization-and-appearance.md
- Dimensions: width, height properties
- Custom styling: cssClass property
- Font color customization: fontColorSettings (FontColorSettingsModel with palette/picker modes)
- Background color customization: backgroundColorSettings (BackgroundColorSettingsModel)
- ColorModeType enum (Palette, Picker)
- Read-only mode: readOnly property
- RTL support: enableRtl property
- Localization: locale property
- Custom block templates
- Theme integration
Security and Sanitization
📄 Read: references/security-and-sanitization.md
- HTML sanitization
- HTML encoding (enableHtmlEncode property)
- XSS prevention strategies
- Read-only mode for view-only content
- Paste security with deniedTags
- Safe content handling best practices
- Compliance considerations
Collaborative Editing
📄 Read: references/collaborative-editing.md
- Real-time collaborative editing powered by Yjs (CRDT-based sync and conflict resolution)
- Injecting the
Collaboration and VersionHistory modules
collaborationSettings property (provider, adapter, enableAwareness, versionHistory)
- Choosing a Yjs provider (y-websocket, y-webrtc, y-indexeddb, Hocuspocus, Liveblocks, PartyKit)
- Setting up a Yjs document,
YjsAdapter, and provider
- User presence, remote cursors, and text selection overlays (enableAwareness)
- Configuring the current user via
users and currentUserId
- Version history: creating, listing, renaming, restoring, comparing, exporting, and importing snapshots
- Custom snapshot storage via the
IVersionStorage interface
- Version history events:
snapshotCreated, snapshotRestored
- Best practices and troubleshooting for collaboration setups
Quick Start Example
import { BlockEditor, BlockType, ContentType } from '@syncfusion/ej2-blockeditor';
// Initialize BlockEditor with sample content
const editor = new BlockEditor({
width: '100%',
height: '600px',
blocks: [
{
id: 'heading-1',
blockType: BlockType.Heading,
properties: { level: 1 },
content: [
{
contentType: ContentType.Text,
content: 'Welcome to BlockEditor'
}
]
},
{
id: 'intro-para',
blockType: BlockType.Paragraph,
content: [
{
contentType: ContentType.Text,
content: 'Start typing or press "/" to open the command menu.'
}
]
},
{
id: 'bullet-list',
blockType: BlockType.BulletList,
content: [
{
contentType: ContentType.Text,
content: 'Drag blocks to reorder'
}
]
}
],
enableDragAndDrop: true,
enableHtmlSanitizer: true
});
// Render the editor
editor.appendTo('#blockeditor');
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.syncfusion.com/ej2/32.1.19/tailwind.css" rel="stylesheet" />
</head>
<body>
<div id="blockeditor"></div>
</body>
</html>
Common Patterns
Adding Blocks Programmatically
// Add a new paragraph block after a target block
const newBlock = {
id: 'new-para',
blockType: BlockType.Paragraph,
content: [
{
contentType: ContentType.Text,
content: 'This is a new paragraph.'
}
]
};
editor.addBlock(newBlock, 'target-block-id', true); // true = after
Getting Content as HTML/JSON
// Get all content as HTML
const htmlContent = editor.getDataAsHtml();
// Get all content as JSON
const jsonContent = editor.getDataAsJson();
// Get specific block content
const blockHtml = editor.getDataAsHtml('block-id');
const blockJson = editor.getDataAsJson('block-id');
Handling Block Changes
const editor = new BlockEditor({
blockChanged: (args) => {
console.log('Blocks changed:', args.changes);
// Auto-save functionality
saveContent(editor.getDataAsJson());
}
});
Custom Slash Commands
const editor = new BlockEditor({
commandMenuSettings: {
popupWidth: '350px',
commands: [
{
id: 'custom-quote',
type: BlockType.Quote,
label: 'Quote Block',
iconCss: 'e-icons e-quote',
groupBy: 'Basic'
},
{
id: 'timestamp',
label: 'Insert Timestamp',
iconCss: 'e-icons e-schedule',
groupBy: 'Actions'
}
],
itemSelect: (args) => {
if (args.command.id === 'timestamp') {
// Custom action: insert current timestamp
const timestamp = new Date().toLocaleString();
// Insert logic here
}
}
}
});
Enabling Real-Time Collaborative Editing
import { BlockEditor, Collaboration, YjsAdapter } from '@syncfusion/ej2-blockeditor';
import * as Y from 'yjs';
import { WebsocketProvider } from 'y-websocket';
BlockEditor.Inject(Collaboration);
const yDoc = new Y.Doc();
const yFragment = yDoc.getXmlFragment('blockeditor');
const adapter: YjsAdapter = { yRuntime: Y, yXmlFragment: yFragment };
const provider = new WebsocketProvider('wss://your-server-url', 'document-room-id', yDoc);
const editor = new BlockEditor({
users: [{ id: 'user-1', user: 'John Doe', avatarBgColor: '#e74c3c' }],
currentUserId: 'user-1',
collaborationSettings: {
provider: provider,
adapter: adapter,
enableAwareness: true,
}
});
editor.appendTo('#blockeditor');
Image Upload Configuration
const editor = new BlockEditor({
imageBlockSettings: {
saveUrl: 'https://your-server.com/api/upload',
path: '/images/',
allowedTypes: ['.jpg', '.jpeg', '.png', '.gif'],
maxFileSize: 5000000, // 5MB
maxWidth: 1200,
maxHeight: 800,
enableResize: true,
saveFormat: 'Blob' // or 'Base64'
},
fileUploadSuccess: (args) => {
console.log('File uploaded:', args.fileUrl);
}
});
Key Configuration Options
Essential Properties
- blocks:
BlockModel[] - Initial content blocks
- width:
string | number - Editor width (default: '100%')
- height:
string | number - Editor height (default: 'auto')
- readOnly:
boolean - Read-only mode (default: false)
- enableDragAndDrop:
boolean - Drag-drop blocks (default: true)
- enableHtmlSanitizer:
boolean - Sanitize HTML (default: true)
- undoRedoStack:
number - Max undo/redo operations (default: 30)
- cssClass:
string - Custom CSS class for styling
Menu and Toolbar Settings
- commandMenuSettings:
CommandMenuSettingsModel - Slash command menu (/)
- blockActionMenuSettings:
BlockActionMenuSettingsModel - Block action menu (⋮)
- contextMenuSettings:
ContextMenuSettingsModel - Right-click context menu
- inlineToolbarSettings:
InlineToolbarSettingsModel - Text formatting toolbar
- transformSettings:
TransformSettingsModel - Block transformation menu
Feature Settings
- imageBlockSettings:
ImageBlockSettingsModel - Image upload and configuration
- codeBlockSettings:
CodeBlockSettingsModel - Code syntax highlighting
- pasteCleanupSettings:
PasteCleanupSettingsModel - Paste formatting control
- labelSettings:
LabelSettingsModel - Labels/tags configuration ($label)
- users:
UserModel[] - Users for mentions (@user)
- keyConfig:
{ [key: string]: string } - Custom keyboard shortcuts
Color Settings
- fontColorSettings:
FontColorSettingsModel - Text color palette
- backgroundColorSettings:
BackgroundColorSettingsModel - Background/highlight color palette
Collaboration Settings
- collaborationSettings:
CollaborationSettingsModel - Real-time collaboration configuration (provider, adapter, enableAwareness, versionHistory)
- users:
UserModel[] - Connected users, also used for mentions and presence
- currentUserId:
string - Identifies the local user for presence and cursor highlighting
- Requires injecting the Collaboration module (and VersionHistory for snapshot support) via
BlockEditor.Inject(...)
Localization and RTL
- locale:
string - Localization code (default: 'en-US')
- enableRtl:
boolean - Right-to-left support (default: false)
- enablePersistence:
boolean - Persist state across reloads (default: false)
1---2name: syncfusion-javascript-block-editor3description: Implement the Syncfusion JavaScript BlockEditor control - a modern block-based text editor with drag-and-drop, slash commands, extensive formatting capabilities, and real-time collaborative editing. Use this skill IMMEDIATELY for: BlockEditor implementation, block-based editors, content editing with blocks, document editors with block structure, text editing with modern UI, slash command menus, drag-and-drop content reordering, inline toolbars, collaborative editing features, real-time multi-user editing, Yjs integration, user presence and remote cursors, document version history, structured content creation, @mentions and labels, code blocks with syntax highlighting, tables and lists, collapsible sections, or any Syncfusion EJ2 BlockEditor control usage in JavaScript applications.4---56# Syncfusion JavaScript BlockEditor78## Overview910The Syncfusion JavaScript BlockEditor is a modern, block-based text editor that enables users to create, format, and organize content using various block types. It provides an intuitive editing experience with features like drag-and-drop reordering, slash commands, inline toolbars, and extensive customization options. The BlockEditor control is built on a block-based architecture where content is organized into discrete blocks. Each block has a specific type (paragraph, heading, list, image, etc.) and can contain formatted content. Key characteristics:1112- **Block Types**: 14 built-in block types including typography, lists, tables, images, code, and collapsible sections13- **Content Model**: Structured content with BlockModel and ContentModel for programmatic manipulation14- **Intuitive UX**: Slash commands (/), drag handles, inline toolbars, and context menus15- **Collaborative Editing**: Real-time multi-user editing powered by Yjs, with presence, remote cursors, and version history16- **Extensibility**: Custom blocks, commands, menu items, and templates17- **Data Formats**: Import/export as HTML or JSON for flexible storage and interchange18- **Accessibility**: Keyboard navigation, ARIA attributes, and screen reader support1920## Documentation and Navigation Guide2122### Getting Started23📄 **Read:** [references/getting-started.md](references/getting-started.md)24- Installation and package setup (`@syncfusion/ej2-blockeditor`)25- CSS imports and theme configuration (Tailwind3, Material, Bootstrap, etc.)26- Basic BlockEditor initialization and first render27- Webpack configuration for development environment28- Minimal working example with sample blocks2930### Blocks and Content Models31📄 **Read:** [references/blocks-and-content-models.md](references/blocks-and-content-models.md)32- Complete BlockModel interface (id, blockType, content, properties, cssClass, indent, parentId, template)33- BlockType enum (Paragraph, Heading, BulletList, NumberedList, Checklist, Table, Image, Code, Quote, Callout, Divider, CollapsibleParagraph, CollapsibleHeading, Template)34- ContentModel interface (id, contentType, content, properties)35- ContentType enum (Text, Link, Mention, Label)36- Block-specific properties (HeadingProps, ImageProps, CodeProps, ChecklistProps, CollapsibleProps, etc.)37- Content-specific properties (LinkContentProps, MentionContentProps, StyleModel)38- UserModel for mentions and collaboration39- BlockFactory class with helper methods for creating blocks4041### Built-in Block Types42📄 **Read:** [references/built-in-block-types.md](references/built-in-block-types.md)43- Typography blocks: Paragraph, Heading (1-4), Quote, Callout44- Text formatting: bold, italic, underline, strikethrough, uppercase, lowercase, subscript, superscript, inline code45- Font color and background color (text highlighting)46- List blocks: BulletList, NumberedList, Checklist (with isChecked)47- Table blocks with configuration48- Media blocks: Image with upload, resize, and constraints (imageBlockSettings)49- Code blocks with syntax highlighting and language selection (codeBlockSettings)50- Advanced blocks: CollapsibleParagraph, CollapsibleHeading, Divider, Template51- Nested block structures with parent-child relationships5253### Editor Menus and Toolbars54📄 **Read:** [references/editor-menus-and-toolbars.md](references/editor-menus-and-toolbars.md)55- Slash Command Menu (/) - commandMenuSettings with CommandItemModel56- Block Action Menu (⋮ handle) - blockActionMenuSettings with BlockActionItemModel57- Context Menu (right-click) - contextMenuSettings with ContextMenuItemModel58- Inline Formatting Toolbar - inlineToolbarSettings with ToolbarItemModel and BuiltInToolbar enum59- Transform Menu - transformSettings for block type conversion60- Custom commands and menu items61- Menu events: filtering, itemSelect, beforeOpen, beforeClose62- Complete customization examples6364### Methods Reference65📄 **Read:** [references/methods-reference.md](references/methods-reference.md)66- Block management: addBlock, removeBlock, moveBlock, updateBlock67- Block queries: getBlock, getBlockCount, getSelectedBlocks68- Selection: selectBlock, selectAllBlocks, selectRange, setSelection, getRange, setCursorPosition69- Data operations: getDataAsHtml, getDataAsJson, parseHtmlToBlocks, renderBlocksFromJson70- Toolbar control: enableToolbarItems, disableToolbarItems, executeToolbarAction71- Focus management: focusIn, focusOut72- Utility: print, refresh, dataBind73- Lifecycle: appendTo, destroy, addEventListener, removeEventListener7475### Events Reference76📄 **Read:** [references/events-reference.md](references/events-reference.md)77- Lifecycle: created78- Content: blockChanged (with BlockChangedEventArgs), selectionChanged79- Focus: focus (FocusEventArgs), blur (BlurEventArgs)80- Drag-drop: blockDragStart, blockDragging, blockDropped (with BlockDragEventArgs, BlockDropEventArgs)81- Paste: beforePasteCleanup, afterPasteCleanup (with PasteCleanupEventArgs)82- File upload: beforeFileUpload, fileUploading, fileUploadSuccess, fileUploadFailed83- Complete event arguments interfaces84- ActionType enum for undo/redo tracking8586### Drag-Drop and Selection87📄 **Read:** [references/drag-drop-and-selection.md](references/drag-drop-and-selection.md)88- Drag-and-drop configuration (enableDragAndDrop property)89- Single and multiple block dragging90- Drag events and visual indicators91- Selection management methods92- Programmatic selection control93- NodeSelection class94- Cursor positioning9596### Paste, Undo/Redo, and Keyboard97📄 **Read:** [references/paste-undo-redo-keyboard.md](references/paste-undo-redo-keyboard.md)98- Paste cleanup configuration (pasteCleanupSettings with keepFormat, plainText, deniedTags)99- Paste events for interception and modification100- Undo/redo stack configuration (undoRedoStack property)101- Keyboard shortcuts (keyConfig property for custom shortcuts)102- Default keyboard commands103- Mentions (@user) with users property and UserModel104- Labels/tags ($label) with labelSettings property and LabelItemModel105106### Customization and Appearance107📄 **Read:** [references/customization-and-appearance.md](references/customization-and-appearance.md)108- Dimensions: width, height properties109- Custom styling: cssClass property110- Font color customization: fontColorSettings (FontColorSettingsModel with palette/picker modes)111- Background color customization: backgroundColorSettings (BackgroundColorSettingsModel)112- ColorModeType enum (Palette, Picker)113- Read-only mode: readOnly property114- RTL support: enableRtl property115- Localization: locale property116- Custom block templates117- Theme integration118119### Security and Sanitization120📄 **Read:** [references/security-and-sanitization.md](references/security-and-sanitization.md)121- HTML sanitization122- HTML encoding (enableHtmlEncode property)123- XSS prevention strategies124- Read-only mode for view-only content125- Paste security with deniedTags126- Safe content handling best practices127- Compliance considerations128129### Collaborative Editing130📄 **Read:** [references/collaborative-editing.md](references/collaborative-editing.md)131- Real-time collaborative editing powered by Yjs (CRDT-based sync and conflict resolution)132- Injecting the `Collaboration` and `VersionHistory` modules133- `collaborationSettings` property (provider, adapter, enableAwareness, versionHistory)134- Choosing a Yjs provider (y-websocket, y-webrtc, y-indexeddb, Hocuspocus, Liveblocks, PartyKit)135- Setting up a Yjs document, `YjsAdapter`, and provider136- User presence, remote cursors, and text selection overlays (enableAwareness)137- Configuring the current user via `users` and `currentUserId`138- Version history: creating, listing, renaming, restoring, comparing, exporting, and importing snapshots139- Custom snapshot storage via the `IVersionStorage` interface140- Version history events: `snapshotCreated`, `snapshotRestored`141- Best practices and troubleshooting for collaboration setups142143## Quick Start Example144145```typescript146import { BlockEditor, BlockType, ContentType } from '@syncfusion/ej2-blockeditor';147148// Initialize BlockEditor with sample content149const editor = new BlockEditor({150 width: '100%',151 height: '600px',152 blocks: [153 {154 id: 'heading-1',155 blockType: BlockType.Heading,156 properties: { level: 1 },157 content: [158 {159 contentType: ContentType.Text,160 content: 'Welcome to BlockEditor'161 }162 ]163 },164 {165 id: 'intro-para',166 blockType: BlockType.Paragraph,167 content: [168 {169 contentType: ContentType.Text,170 content: 'Start typing or press "/" to open the command menu.'171 }172 ]173 },174 {175 id: 'bullet-list',176 blockType: BlockType.BulletList,177 content: [178 {179 contentType: ContentType.Text,180 content: 'Drag blocks to reorder'181 }182 ]183 }184 ],185 enableDragAndDrop: true,186 enableHtmlSanitizer: true187});188189// Render the editor190editor.appendTo('#blockeditor');191```192193```html194<!DOCTYPE html>195<html>196<head>197 <link href="https://cdn.syncfusion.com/ej2/32.1.19/tailwind.css" rel="stylesheet" />198</head>199<body>200 <div id="blockeditor"></div>201</body>202</html>203```204205## Common Patterns206207### Adding Blocks Programmatically208209```typescript210// Add a new paragraph block after a target block211const newBlock = {212 id: 'new-para',213 blockType: BlockType.Paragraph,214 content: [215 {216 contentType: ContentType.Text,217 content: 'This is a new paragraph.'218 }219 ]220};221222editor.addBlock(newBlock, 'target-block-id', true); // true = after223```224225### Getting Content as HTML/JSON226227```typescript228// Get all content as HTML229const htmlContent = editor.getDataAsHtml();230231// Get all content as JSON232const jsonContent = editor.getDataAsJson();233234// Get specific block content235const blockHtml = editor.getDataAsHtml('block-id');236const blockJson = editor.getDataAsJson('block-id');237```238239### Handling Block Changes240241```typescript242const editor = new BlockEditor({243 blockChanged: (args) => {244 console.log('Blocks changed:', args.changes);245 // Auto-save functionality246 saveContent(editor.getDataAsJson());247 }248});249```250251### Custom Slash Commands252253```typescript254const editor = new BlockEditor({255 commandMenuSettings: {256 popupWidth: '350px',257 commands: [258 {259 id: 'custom-quote',260 type: BlockType.Quote,261 label: 'Quote Block',262 iconCss: 'e-icons e-quote',263 groupBy: 'Basic'264 },265 {266 id: 'timestamp',267 label: 'Insert Timestamp',268 iconCss: 'e-icons e-schedule',269 groupBy: 'Actions'270 }271 ],272 itemSelect: (args) => {273 if (args.command.id === 'timestamp') {274 // Custom action: insert current timestamp275 const timestamp = new Date().toLocaleString();276 // Insert logic here277 }278 }279 }280});281```282283### Enabling Real-Time Collaborative Editing284285```typescript286import { BlockEditor, Collaboration, YjsAdapter } from '@syncfusion/ej2-blockeditor';287import * as Y from 'yjs';288import { WebsocketProvider } from 'y-websocket';289290BlockEditor.Inject(Collaboration);291292const yDoc = new Y.Doc();293const yFragment = yDoc.getXmlFragment('blockeditor');294const adapter: YjsAdapter = { yRuntime: Y, yXmlFragment: yFragment };295const provider = new WebsocketProvider('wss://your-server-url', 'document-room-id', yDoc);296297const editor = new BlockEditor({298 users: [{ id: 'user-1', user: 'John Doe', avatarBgColor: '#e74c3c' }],299 currentUserId: 'user-1',300 collaborationSettings: {301 provider: provider,302 adapter: adapter,303 enableAwareness: true,304 }305});306307editor.appendTo('#blockeditor');308```309310### Image Upload Configuration311312```typescript313const editor = new BlockEditor({314 imageBlockSettings: {315 saveUrl: 'https://your-server.com/api/upload',316 path: '/images/',317 allowedTypes: ['.jpg', '.jpeg', '.png', '.gif'],318 maxFileSize: 5000000, // 5MB319 maxWidth: 1200,320 maxHeight: 800,321 enableResize: true,322 saveFormat: 'Blob' // or 'Base64'323 },324 fileUploadSuccess: (args) => {325 console.log('File uploaded:', args.fileUrl);326 }327});328```329330## Key Configuration Options331332### Essential Properties333334- **blocks**: `BlockModel[]` - Initial content blocks335- **width**: `string | number` - Editor width (default: '100%')336- **height**: `string | number` - Editor height (default: 'auto')337- **readOnly**: `boolean` - Read-only mode (default: false)338- **enableDragAndDrop**: `boolean` - Drag-drop blocks (default: true)339- **enableHtmlSanitizer**: `boolean` - Sanitize HTML (default: true)340- **undoRedoStack**: `number` - Max undo/redo operations (default: 30)341- **cssClass**: `string` - Custom CSS class for styling342343### Menu and Toolbar Settings344345- **commandMenuSettings**: `CommandMenuSettingsModel` - Slash command menu (/)346- **blockActionMenuSettings**: `BlockActionMenuSettingsModel` - Block action menu (⋮)347- **contextMenuSettings**: `ContextMenuSettingsModel` - Right-click context menu348- **inlineToolbarSettings**: `InlineToolbarSettingsModel` - Text formatting toolbar349- **transformSettings**: `TransformSettingsModel` - Block transformation menu350351### Feature Settings352353- **imageBlockSettings**: `ImageBlockSettingsModel` - Image upload and configuration354- **codeBlockSettings**: `CodeBlockSettingsModel` - Code syntax highlighting355- **pasteCleanupSettings**: `PasteCleanupSettingsModel` - Paste formatting control356- **labelSettings**: `LabelSettingsModel` - Labels/tags configuration ($label)357- **users**: `UserModel[]` - Users for mentions (@user)358- **keyConfig**: `{ [key: string]: string }` - Custom keyboard shortcuts359360### Color Settings361362- **fontColorSettings**: `FontColorSettingsModel` - Text color palette363- **backgroundColorSettings**: `BackgroundColorSettingsModel` - Background/highlight color palette364365### Collaboration Settings366367- **collaborationSettings**: `CollaborationSettingsModel` - Real-time collaboration configuration (provider, adapter, enableAwareness, versionHistory)368- **users**: `UserModel[]` - Connected users, also used for mentions and presence369- **currentUserId**: `string` - Identifies the local user for presence and cursor highlighting370- Requires injecting the **Collaboration** module (and **VersionHistory** for snapshot support) via `BlockEditor.Inject(...)`371372### Localization and RTL373374- **locale**: `string` - Localization code (default: 'en-US')375- **enableRtl**: `boolean` - Right-to-left support (default: false)376- **enablePersistence**: `boolean` - Persist state across reloads (default: false)