Skip to main content

@wordpress/editor

The @wordpress/editor package provides a WordPress post-aware editor implementation. It extends @wordpress/block-editor with WordPress-specific functionality, integrating with the REST API and Core Data.

Installation

Current Version: 14.40.1This package assumes an ES2015+ environment. Include the polyfill from @wordpress/babel-preset-default if needed.

Architecture Position

The @wordpress/editor is the second layer in Gutenberg’s architecture:
1

Block Editor

Generic, WordPress-agnostic (@wordpress/block-editor)
2

Editor (Current Layer)

WordPress post-type aware (@wordpress/editor)
3

Implementations

Full editor screens (@wordpress/edit-post, @wordpress/edit-site)
This package:
  • Knows about WordPress posts and post types
  • Integrates with @wordpress/core-data
  • Handles post loading and saving
  • Provides post-specific UI components

How It Works

The editor flow:
  1. Parse: Convert post content HTML to block representation
  2. Render: Display blocks in the editor with UI controls
  3. Update: Modify block state as user edits
  4. Serialize: Convert blocks back to HTML
  5. Save: Persist to WordPress via REST API

Quick Start

EditorProvider

The root component for post editing:
Object
required
The post object to edit:
  • id: Post ID
  • type: Post type
  • content: Post content
  • title: Post title
  • Other post fields
Object
Optional template object wrapping the post (for posts/pages with templates)
Object
Editor settings. Extends @wordpress/block-editor settings with post-specific options
React.ReactNode
Child components to render within the editor context

Post Components

PostTitle

Editable post title input.

PostTextEditor

Text mode editor (HTML view).

DocumentBar

Navigation bar showing document title and back button.
string
Document title (defaults to post/template title)
IconType
Icon to display

Post Metadata Components

PostExcerpt

Post excerpt editor.
boolean
Whether to visually hide the label
boolean
Whether to update on blur instead of on change

PostFeaturedImage

Featured image selector.

PostAuthor

Post author selector.

PostSchedule

Post scheduling controls.

PostVisibility

Post visibility controls (public, private, password-protected).

PostFormat

Post format selector.

PostSticky

Sticky post toggle.

Taxonomy Components

PostTaxonomies

Renders all taxonomies for the post.

PostTaxonomiesHierarchicalTermSelector

Hierarchical taxonomy selector (like categories).
string
required
Taxonomy slug (e.g., ‘category’)

PostTaxonomiesFlatTermSelector

Flat taxonomy selector (like tags).
string
required
Taxonomy slug (e.g., ‘post_tag’)

Publishing Components

PostPublishButton

Publish/update button.

PostPublishPanel

Pre-publish checklist panel.

PostSavedState

Shows save status and save button.
boolean
Force the post to be marked as dirty

PostPreviewButton

Preview button.

PostSwitchToDraftButton

Switch to draft button (for published posts).

PostTrash

Move to trash button.

Panel Components

PostExcerptPanel

Excerpt panel for sidebar.

PostFeaturedImagePanel

Featured image panel for sidebar.

PostTaxonomiesPanel

Taxonomies panel for sidebar.

PostDiscussionPanel

Comments and pingbacks panel.

PostLastRevisionPanel

Post revisions panel.

PageAttributesPanel

Page attributes (parent, order, template).

Plugin Extension Points

PluginDocumentSettingPanel

Add custom panels to document settings.
string
required
Unique panel identifier
string
Panel title
string
Additional CSS class
WPBlockTypeIconRender
Panel icon

PluginPostStatusInfo

Add items to post status panel.

PluginPrePublishPanel

Add panel to pre-publish checklist.

PluginPostPublishPanel

Add panel to post-publish flow.

PluginSidebar

Add custom sidebar.
string
required
Unique sidebar identifier
string
required
Sidebar title
WPBlockTypeIconRender
Sidebar icon
boolean
Whether sidebar can be pinned (automatically renders menu item)

PluginBlockSettingsMenuItem

Add item to block settings menu.
Array
Block names to show this item for
WPBlockTypeIconRender
Menu item icon
string
required
Menu item text
Function
required
Click handler

PluginMoreMenuItem

Add item to More Menu (three dots).

Monitoring Components

AutosaveMonitor

Monitors changes and triggers autosave.
number
Autosave interval in milliseconds (e.g., 30000 for 30 seconds)
The logic checks for changes every interval seconds. If changes are detected and the post is autosaveable, it calls the autosave action.

LocalAutosaveMonitor

Manages browser-based local autosaves.
Automatically handles:
  • Creating local autosaves in sessionStorage
  • Prompting to restore local autosaves
  • Clearing local autosaves after successful save

PostLockedModal

Displays when another user is editing the post.
Shows lock information and options to take over or exit.

UnsavedChangesWarning

Warns before leaving with unsaved changes.

Keyboard Shortcuts

EditorKeyboardShortcuts

Registers editor keyboard shortcuts.
Provides shortcuts for:
  • Toggle editor mode (Ctrl+Shift+Alt+M)
  • Save post (Ctrl+S)
  • Undo/Redo (Ctrl+Z / Ctrl+Shift+Z)
  • Toggle distraction-free mode
  • Toggle list view
  • Toggle sidebar

History Controls

EditorHistoryUndo

Undo button.

EditorHistoryRedo

Redo button.

Document Utilities

DocumentOutline

Displays document heading structure.

TableOfContents

Table of contents dropdown.

CharacterCount

Returns character count of post content.

TimeToRead

Estimated reading time.

Utility Functions

cleanForSlug

Cleans a string for use as a post slug.
string
required
Title or slug to process
string
Processed slug string
This approximates what WordPress sanitize_title() does but is client-side only.

mediaUpload

Upload media files with current post ID.

Check Components

Conditional rendering components:

PostTypeSupportCheck

PostAuthorCheck

PostFeaturedImageCheck

ThemeSupportCheck

Saved States

EntitiesSavedStates

Manages saving multiple entities (post + template).
Function
required
Function to close the dialog
boolean
Whether to render as a modal dialog
string
'inline' renders action buttons at the end instead of start

Error Boundary

ErrorBoundary

Catches JavaScript errors in child components.

DataViews Integration

registerEntityField

Register custom DataViews fields (experimental).

registerEntityAction

Register custom DataViews actions (experimental).

Store

The editor package includes a data store:

TypeScript

Type definitions are included:

Dependencies

Key dependencies:
  • @wordpress/block-editor - Generic block editor
  • @wordpress/blocks - Block API
  • @wordpress/core-data - WordPress data entities
  • @wordpress/data - State management
  • @wordpress/components - UI components
  • @wordpress/element - React abstraction
  • And 30+ other packages
See package.json for the complete list.

Resources

Editor Handbook

Complete editor documentation

Plugin Extension Points

Extending the editor with plugins

GitHub Repository

Source code and issue tracker

Core Data Package

Learn about WordPress data management