@wordpress/block-editor
The@wordpress/block-editor package provides generic, WordPress-agnostic components and hooks for creating block editors. This is the foundational layer of the Gutenberg editor architecture.
Installation
Current Version: 15.13.1This package assumes an ES2015+ environment. Include the polyfill from @wordpress/babel-preset-default if needed.
Architecture
The@wordpress/block-editor is the first layer in Gutenberg’s three-layer architecture:
1
Block Editor (Generic Layer)
@wordpress/block-editor - WordPress-agnostic block editing2
Editor (WordPress Layer)
@wordpress/editor - WordPress post-type aware3
Implementation Layer
@wordpress/edit-post, @wordpress/edit-site - Full editor screensQuick Start
Create a standalone block editor:Don’t forget to load the required stylesheets:
Core Components
BlockEditorProvider
The root component that provides block editor context.Array
required
Current array of blocks
Function
Called when blocks change (non-persistent changes like typing)
Function
Called when blocks change (persistent changes like adding blocks)
Object
Editor settings object. See SETTINGS_DEFAULTS
BlockCanvas
Renders the block list in an iframe for content isolation.string
Canvas height (defaults to 300px)
Array
Content styles to inject into the iframe
Element
Content to render (defaults to BlockList component)
BlockList
Renders the list of blocks.BlockEditorProvider context.
BlockInspector
Displays block settings in a sidebar.BlockTools
Renders toolbars and insertion points for blocks.Object
required
The block content and style container
Object
Ref holding the content scroll container
BlockToolbar
Renders the block toolbar with controls.boolean
Show or hide the drag handle
string
Style variant (‘toolbar-block’ or ‘toolbar’)
Block Controls
BlockControls
Renders controls in the block toolbar.InspectorControls
Renders controls in the block inspector sidebar.InspectorAdvancedControls
Renders advanced controls in the block inspector.Alignment Controls
AlignmentControl
Text alignment control.BlockAlignmentControl
Block-level alignment control.BlockVerticalAlignmentControl
Vertical alignment control for blocks.Rich Text
RichText
Multi-line rich text input for content editing.string
required
HTML tag to use (e.g., ‘p’, ‘h2’, ‘div’)
string
required
Rich text HTML value
Function
required
Called when content changes
string
Placeholder text when empty
PlainText
Plain text input without formatting.Colors and Styles
ColorPalette
Color picker with palette.PanelColorSettings
Color settings panel for the inspector.withColors
Higher-order component for color management.Typography
FontSizePicker
Font size picker control.LineHeightControl
Line height control.Media
MediaPlaceholder
Placeholder for media upload.MediaUpload
Media upload button.MediaReplaceFlow
Media replacement control.Inner Blocks
InnerBlocks
Nested blocks support.Array
Array of block names that can be inserted
Array
Initial block template as array of [blockName, attributes, innerBlocks]
string | false
all: Prevents all operationsinsert: Prevents inserting/removing blocksfalse: No restrictions
Hooks
useBlockProps
Essential hook for marking block elements.Required for all blocks using API version 2 or higher.
useInnerBlocksProps
CombinesuseBlockProps with inner blocks.
useBlockEditContext
Access current block context.string
Block type name
string
Unique block client ID
boolean
Whether the block is selected
useSettings
Retrieve editor settings.useBlockDisplayInformation
Get block display information.useBlockEditingMode
Control block editing mode.BlockEditingMode
'disabled': Block cannot be selected'contentOnly': Hide non-content UI'default': Normal editing
Utility Functions
getColorClassName
Returns a color class name.getFontSizeClass
Returns a font size class name.getTypographyClassesAndStyles
Get typography CSS classes and styles from attributes.SETTINGS_DEFAULTS
Default editor settings object:Available Settings
Available Settings
boolean
Enable/disable wide/full alignments
boolean
Enable/disable layout support
Array
Available color palette
Array
Available font sizes
Array
Available image sizes
number
Max content width
boolean | Array
Allowed block types (true for all, array for specific)
boolean
Whether toolbar is fixed at top
boolean
Enable focus mode
Array
Editor styles
string
Placeholder for empty content
Store
The block-editor package includes a data store:TypeScript
Type definitions are included:Dependencies
Key dependencies:@wordpress/blocks- Block API@wordpress/components- UI components@wordpress/data- State management@wordpress/element- React abstraction@wordpress/i18n- Internationalization@wordpress/compose- Higher-order components- And 20+ other packages
Resources
Block Editor Handbook
Complete block editor documentation
Custom Block Editor
How to create a custom block editor
GitHub Repository
Source code and issue tracker
Component READMEs
Detailed component documentation