Overview
The@wordpress/edit-post package provides the complete post editor screen for WordPress. It sits at the top of the three-layer editor architecture, assembling UI components, sidebars, settings panels, and plugin slots into a full editing experience.
This package is designed for WordPress core and may not be fully documented for external use. However, you can use it in your own projects with the understanding that APIs may evolve.
Three-Layer Architecture
The WordPress editor follows a three-layer architecture where each layer builds upon the previous one:Layer Responsibilities
@wordpress/block-editor- Generic, WordPress-agnostic block editing functionality. Provides the canvas, block selection, and manipulation APIs.@wordpress/editor- WordPress-specific features for post types. Adds document settings, post status, and entity management.@wordpress/edit-post- Complete editor screen implementation. Assembles all UI elements, sidebars, toolbars, and plugin extension points.
Installation
Install the package via npm:@wordpress/babel-preset-default.
Initializing the Editor
You initialize the post editor using theinitializeEditor function:
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Unique identifier for the editor instance |
postType | string | Post type of the post to edit (e.g., ‘post’, ‘page’) |
postId | number | ID of the post to edit |
settings | Object | Editor settings object (optional) |
initialEdits | Object | Programmatic edits to apply initially, bypassing unsaved changes prompt |
Initial edits are considered non-user-initiated, so they won’t trigger the “unsaved changes” warning when the user navigates away.
Extending the Editor UI
You extend the post editor UI using theregisterPlugin API from @wordpress/plugins. This allows you to define all your plugin’s UI elements in a single place.
Using Plugin Components
The package exports several components for extending different areas of the editor. These components are available in the global variablewp.editPost when you define wp-edit-post as a script dependency.
Plugin Extension Components
The following components allow you to add custom UI elements to various parts of the editor:PluginSidebar
Adds a custom sidebar to the editor with its own icon in the toolbar.For full documentation, see the PluginSidebar reference in @wordpress/editor.
PluginSidebarMoreMenuItem
Adds a menu item to open your custom sidebar from the “More” menu.PluginDocumentSettingPanel
Adds a custom panel to the Document settings sidebar.PluginBlockSettingsMenuItem
Adds a custom menu item to the block settings dropdown (three-dot menu in the block toolbar).PluginPostPublishPanel
Adds custom content to the post-publish panel that appears after publishing.PluginPrePublishPanel
Adds custom content to the pre-publish panel that appears before publishing.PluginPostStatusInfo
Adds custom information to the post status section of the Document sidebar.PluginMoreMenuItem
Adds a custom menu item to the editor’s “More” menu (three-dot menu in the top toolbar).Most of these components are re-exported from
@wordpress/editor. You can use them from either package, but importing from @wordpress/editor is recommended for better compatibility.Complete Plugin Example
Here’s a comprehensive example showing multiple extension points:Data Store
The package provides a Redux-style data store for managing editor UI state:- Active editor mode (visual or code)
- Sidebar visibility
- Panel open/closed states
- Feature flags and preferences
WordPress Script Dependency
When loading via WordPress’s script system, you can access the package through the globalwp.editPost object:
Migration Notes
Deprecated APIs
reinitializeEditor()- This function is now a deprecated no-op. You don’t need to reinitialize the editor after errors.
Related Packages
@wordpress/block-editor- Generic block editing functionality@wordpress/editor- WordPress post-type-aware editor features@wordpress/plugins- Plugin registration and management API@wordpress/data- Redux-style data stores