Loading...
Loading...
Implement the Syncfusion React BlockEditor component. Use this skill for block-based rich content editing, document creation, CMS interfaces, markdown alternatives, editor setup, block configuration, toolbar or menu customization, drag-and-drop behavior, formatting options, APIs, and accessibility in React.
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-blockeditorenableDragAndDropblockDragStartblockDraggingblockDroppedusersUserModel@mentionlabelSettingsLabelItemModelContentType.MentionContentType.LabelIMentionContentSettingsILabelContentSettingsimport { BlockEditorComponent } from '@syncfusion/ej2-react-blockeditor';
import { BlockModel, ContentType } from '@syncfusion/ej2-react-blockeditor';
import '@syncfusion/ej2-react-blockeditor/styles/material.css';
function App() {
// Define initial blocks
const blocksData: BlockModel[] = [
{
id: 'block-1',
blockType: 'Heading',
properties: { level: 1 },
content: [
{
contentType: ContentType.Text,
content: 'Welcome to Block Editor'
}
]
},
{
id: 'block-2',
blockType: 'Paragraph',
content: [
{
contentType: ContentType.Text,
content: 'This is your first paragraph. Click the "+" button to add more blocks.'
}
]
}
];
return (
<BlockEditorComponent
id="block-editor"
blocks={blocksData}
/>
);
}
export default App;const editorRef = React.useRef<BlockEditorComponent>(null);
const addNewBlock = () => {
const newBlock: BlockModel = {
blockType: 'Paragraph',
content: [
{
contentType: ContentType.Text,
content: 'New paragraph block'
}
]
};
editorRef.current?.addBlock(newBlock);
};const commandMenuSettings = {
itemSelect: (args) => {
console.log('Selected command:', args.command.label, args.command.id);
// Handle custom actions based on selected command
}
};const exportContent = () => {
const jsonContent = editorRef.current?.getDataAsJson();
console.log('Exported content:', jsonContent);
};<BlockEditorComponent
id="block-editor"
blocks={blocksData}
readOnly={true}
/>⚠️ Props,toolbarSettings, andcontainerCssClassdo not exist in the BlockEditor API and must not be used.showBlockHandle
| Prop | Type | Description |
|---|---|---|
| | Unique identifier for the component |
| | Array of block objects defining content |
| | Enable read-only mode (default: |
| | Width of the editor container (default: |
| | Height of the editor container |
| | Customize slash command (/) menu |
| | Configure right-click context menu |
| | Configure inline text selection toolbar |
| | Configure block action (⋮) menu |
| | Configure block type transform menu |
| | Configure image upload and rendering |
| | Configure code block languages |
| | Control paste sanitization behavior |
| | User list for |
| | Label items and trigger char for label feature |
| | Enable/disable drag-and-drop reordering (default: |
| | Max number of undo/redo history steps |
| | Custom keyboard shortcut mappings |
| | Localization language code (default: |
| | Fires when block content changes |