Loading...
Loading...
Compare original and translation side by side
enableDragAndDropblockDragStartblockDraggingblockDroppedenableDragAndDropblockDragStartblockDraggingblockDroppedusersUserModel@mentionlabelSettingsLabelItemModelContentType.MentionContentType.LabelIMentionContentSettingsILabelContentSettings@mentionusersUserModellabelSettingsLabelItemModelContentType.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;import { 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 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 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);
};const exportContent = () => {
const jsonContent = editorRef.current?.getDataAsJson();
console.log('Exported content:', jsonContent);
};<BlockEditorComponent
id="block-editor"
blocks={blocksData}
readOnly={true}
/><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 |
⚠️ 属性、toolbarSettings和containerCssClass不存在于BlockEditor API中,请勿使用。showBlockHandle
| 属性 | 类型 | 描述 |
|---|---|---|
| | 组件的唯一标识符 |
| | 定义内容的区块对象数组 |
| | 启用只读模式(默认值: |
| | 编辑器容器的宽度(默认值: |
| | 编辑器容器的高度 |
| | 自定义斜杠命令(/)菜单 |
| | 配置右键上下文菜单 |
| | 配置内联文本选择工具栏 |
| | 配置区块操作(⋮)菜单 |
| | 配置区块类型转换菜单 |
| | 配置图片上传与渲染 |
| | 配置代码块语言 |
| | 控制粘贴内容的净化行为 |
| | 用于 |
| | 标签项与触发字符的配置 |
| | 启用/禁用拖拽重新排序(默认值: |
| | 撤销/重做历史记录的最大步数 |
| | 自定义键盘快捷键映射 |
| | 本地化语言代码(默认值: |
| | 区块内容变更时触发 |