Syncfusion React Blockeditor

syncfusion/react-ui-components-skills/skills/syncfusion-react-blockeditor

作者 syncfusion6fb1c883a8412b611b95f839e0cb06e1fc8170a8無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Implement the Syncfusion React BlockEditor component for block-based content editing. 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, accessibility, real-time collaborative editing with Yjs integration, user presence and remote cursors, document version history and snapshot management in React.

AI 產生的概覽

指導在 React 應用程式中實作 Syncfusion React BlockEditor 元件,用於區塊式內容編輯。

功能
此技能提供整合 Syncfusion React BlockEditorComponent(區塊式富文字編輯器)的參考文件。內容涵蓋安裝、區塊類型、選單、拖放、提及與標籤、方法與 API、樣式、無障礙,以及以 Yjs 為基礎的即時協作編輯與版本歷程。它產出的是指引與程式碼範例,而非可直接執行的成品。
適用情境
適用於建置需要區塊式內容編輯的 React 介面,例如 CMS 編輯器、筆記應用程式、部落格編輯器或知識庫。也適合在設定編輯器選單、區塊行為、無障礙或即時協作功能時使用。
執行需求
需要一個 React 專案,並安裝 @syncfusion/ej2-react-blockeditor npm 套件及其主題 CSS。協作編輯另需 Yjs 提供者與文件設定。此技能不含指令碼,僅為說明與參考文件。

Syncfusion React Block Editor in React

Component Overview

The Syncfusion React BlockEditorComponent is a powerful block-based rich text editor that allows users to create, edit, and format content using a modern block architecture. Each piece of content (paragraphs, headings, lists, tables, code snippets) is a discrete, manageable block.

Key Capabilities

The BlockEditorComponent provides:

  • Block-based architecture - Content structured as discrete, reorderable blocks
  • Built-in block types - Paragraphs, headings, lists, tables, code, callouts, quotes, collapsible sections
  • Intuitive menus - Slash commands, context menus, inline toolbars
  • Drag-and-drop - Reorder blocks easily with visual handles
  • Content export - Export as JSON, HTML, or plain text
  • Accessibility - WCAG 2.1 compliant with keyboard navigation and screen reader support
  • Customization - Custom styling, themes, RTL support, globalization
  • Collaborative Editing - Real-time multi-user editing powered by Yjs, with user presence and remote cursors, document version history and snapshot management

Documentation Navigation Guide

Getting Started

📄 Read: references/getting-started.md [blocked]

  • Installation and npm package setup
  • Basic component implementation
  • CSS imports and theme configuration
  • Creating your first block editor
  • Setting initial content with blocks

Built-in Block Types

📄 Read: references/built-in-blocks.md [blocked]

  • Block type reference (Paragraph, Heading, List, Table, Code, Quote, Callout)
  • Nested block types (CollapsibleHeading, CollapsibleParagraph)
  • Block indentation and CSS class styling
  • Content configuration and properties

Menus and Commands

📄 Read: references/block-editor-menus.md [blocked]

  • Slash command menu customization
  • Context menu configuration with Table and Link options
  • Inline toolbar setup with Transform, code, link, and color support
  • Block action menu customization and tooltips
  • Menu events and filtering

Drag-Drop and Content Management

📄 Read: references/drag-drop-and-content.md [blocked]

  • Drag-and-drop block reordering (enableDragAndDrop)
  • Content insertion and nesting
  • Drag events (blockDragStart, blockDragging, blockDropped)
  • Programmatic block movement

Mentions and Labels

📄 Read: references/mentions-and-labels.md [blocked]

  • users prop and UserModel interface for @mention feature
  • labelSettings prop and LabelItemModel interface for label feature
  • ContentType.Mention / ContentType.Label inline content
  • IMentionContentSettings / ILabelContentSettings

Methods and API

📄 Read: references/methods-and-api.md [blocked]

  • Block management methods (add, remove, update, move)
  • Selection and cursor control
  • Data export/import (JSON, HTML)
  • Content formatting and rendering

Styling and Appearance

📄 Read: references/styling-and-appearance.md [blocked]

  • CSS theming and imports
  • Block styling with custom CSS classes
  • Typography and formatting options
  • Dark mode and responsive design

Advanced Features

📄 Read: references/advanced-features.md [blocked]

  • Paste cleanup and content sanitization
  • Undo/redo functionality
  • Keyboard shortcut customization
  • Read-only mode configuration
  • XSS protection and HTML sanitization
  • RTL support and internationalization

Collaborative Editing

📄 Read: references/collaborative-editing.md [blocked]

  • 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

Accessibility

📄 Read: references/accessibility.md [blocked]

  • WCAG 2.1 compliance
  • Keyboard navigation patterns
  • Screen reader support and ARIA attributes
  • Focus management
  • Color contrast and visual indicators

Quick Start Example

tsx
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;

Common Patterns

1. Add a Block Programmatically

tsx
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);};

2. Handle Menu Item Selection

tsx
const commandMenuSettings = {  itemSelect: (args) => {    console.log('Selected command:', args.command.label, args.command.id);    // Handle custom actions based on selected command  }};

3. Export Content as JSON

tsx
const exportContent = () => {  const jsonContent = editorRef.current?.getDataAsJson();  console.log('Exported content:', jsonContent);};

4. Enable Read-Only Mode

tsx
<BlockEditorComponent  id="block-editor"  blocks={blocksData}  readOnly={true}/>

Key Props

⚠️ Props toolbarSettings, containerCssClass, and showBlockHandle do not exist in the BlockEditor API and must not be used.

PropTypeDescription
idstringUnique identifier for the component
blocksBlockModel[]Array of block objects defining content
readOnlybooleanEnable read-only mode (default: false)
widthstring | numberWidth of the editor container (default: '100%')
heightstring | numberHeight of the editor container
commandMenuSettingsCommandMenuSettingsModelCustomize slash command (/) menu
contextMenuSettingsContextMenuSettingsModelConfigure right-click context menu
inlineToolbarSettingsInlineToolbarSettingsModelConfigure inline text selection toolbar
blockActionMenuSettingsBlockActionMenuSettingsModelConfigure block action (⋮) menu
transformSettingsTransformSettingsModelConfigure block type transform menu
imageBlockSettingsImageBlockSettingsModelConfigure image upload and rendering
codeBlockSettingsCodeBlockSettingsModelConfigure code block languages
pasteCleanupSettingsPasteCleanupSettingsModelControl paste sanitization behavior
usersUserModel[]User list for @mention feature and collaboration presence with avatar colors
labelSettingsLabelSettingsModelLabel items and trigger char for label feature
enableDragAndDropbooleanEnable/disable drag-and-drop reordering (default: true)
undoRedoStacknumberMax number of undo/redo history steps
keyConfig{ [key: string]: string }Custom keyboard shortcut mappings
localestringLocalization language code (default: 'en-US')
blockChangedEmitType<BlockChangedEventArgs>Fires when block content changes
collaborationSettingsCollaborationSettingsModelConfigure real-time collaboration with Yjs provider, awareness, and version history
currentUserIdstringUnique identifier of the current user for collaboration and cursor identification

Common Use Cases

Content Management System - Build a CMS with block-based editing, custom block types, and content export

Document Editor - Create a collaborative document editor with formatting, templates, and version control

Note-Taking App - Implement a personal notes app with nesting, tagging, and search capabilities

Blog Editor - Enable blog authors to write with rich formatting, media embeds, and preview

Knowledge Base - Build internal documentation with organized blocks, search, and linked references

Survey/Form Builder - Create dynamic surveys with conditional blocks and response capture


來源與署名

來源:syncfusion/react-ui-components-skills位於skills/syncfusion-react-blockeditor提交6fb1c88

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架