@wordpress/editor


目录

This module utilizes components from the @wordpress/block-editor package. Having an awareness of the concept of a WordPress post, it associates the loading and saving mechanism of the value representing blocks to a post and its content. It also provides various components relevant for working with a post object in the context of an editor (e.g., a post title input component). This package can support editing posts of any post type and does not assume that rendering happens in any particular WordPress screen or layout arrangement.

Installation

Install the module

npm install @wordpress/editor --save

This package assumes that your code will run in an ES2015+ environment. If you’re using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @wordpress/babel-preset-default in your code.

How it works

The logic flow concerning the editor includes: inferring a block representation of the post content (parsing); describing the state of a post (representation); rendering of the post to the DOM (rendering); attaching controls to manipulate the content a.k.a blocks (UI).

Diagram

The goal of the editor element is to let the user manipulate the content of their posts in a deterministic way—organized through the presence of blocks of content. Usually, in a declarative flow, the pieces that compose a post would be represented in a certain order and the machine would be able to generate an output view from it with the necessary UI controls. However, we don’t begin in WordPress with a representation of the state of the post that is conductive to this expression nor one that even has any knowledge of blocks because content is stored in a serialized way in a single field.

Such a crucial step is handled by the grammar parsing which takes the serialized content of the post and infers an ordered block list using, preferably, syntax hints present in HTML comments. The editor is initialized with a state representation of the block nodes generated by the parsing of the raw content of a post element: wp.blocks.parse( post.content.raw ).

The visual editor is thus a component that contains and renders the list of block nodes from the internal state into the page. This removes any trace of imperative handling when it comes to finding a block and manipulating a block. As a matter of fact, the visual editor or the text editor are just two different—equally valid—views of the same representation of state. The internal representation of the post content is updated as blocks are updated and it is serialized back to be saved in post_content.

Individual blocks are handled by the VisualBlock component, which attaches event handlers and renders the edit function of a block definition to the document with the corresponding attributes and local state. The edit function is the markup shape of a component while in editing mode.

Components

Because many blocks share the same complex behaviors, reusable components are made available to simplify implementations of your block’s edit function.

BlockControls

When returned by your block’s edit implementation, renders a toolbar of icon buttons. This is useful for block-level modifications to be made available when a block is selected. For example, if your block supports alignment, you may want to display alignment options in the selected block’s toolbar.

Example:

( function ( editor, React ) {
    var el = React.createElement,
        BlockControls = editor.BlockControls,
        AlignmentToolbar = editor.AlignmentToolbar;

    function edit( props ) {
        return [
            // Controls: (only visible when block is selected)
            el(
                BlockControls,
                { key: 'controls' },
                el( AlignmentToolbar, {
                    value: props.align,
                    onChange: function ( nextAlign ) {
                        props.setAttributes( { align: nextAlign } );
                    },
                } )
            ),

            // Block content: (with alignment as attribute)
            el(
                'p',
                { key: 'text', style: { textAlign: props.align } },
                'Hello World!'
            ),
        ];
    }
} )( window.wp.editor, window.React );

Note in this example that we render AlignmentToolbar as a child of the BlockControls element. This is another pre-configured component you can use to simplify block text alignment.

Alternatively, you can create your own toolbar controls by passing an array of controls as a prop to the BlockControls component. Each control should be an object with the following properties:

To create divisions between sets of controls within the same BlockControls element, passing controls instead as a nested array (array of arrays of objects). A divider will be shown between each set of controls.

RichText

Render a rich contenteditable input, providing users the option to add emphasis to content or links to content. It behaves similarly to a controlled component, except that onChange is triggered less frequently than would be expected from a traditional input field, usually when the user exits the field.

The following properties (non-exhaustive list) are made available:

Example:

( function ( editor, React ) {
    var el = React.createElement,
        RichText = editor.RichText;

    function edit( props ) {
        function onChange( value ) {
            props.setAttributes( { text: value } );
        }

        return el( RichText, {
            value: props.attributes.text,
            onChange: onChange,
        } );
    }

    // blocks.registerBlockType( ..., { edit: edit, ... } );
} )( window.wp.editor, window.React );

API

AlignmentToolbar

Deprecated since 5.3, use wp.blockEditor.AlignmentToolbar instead.

Autocomplete

Deprecated since 5.3, use wp.blockEditor.Autocomplete instead.

AutosaveMonitor

Monitors the changes made to the edited post and triggers autosave if necessary.

The post is autosaved every interval seconds while there is something new to save. A failed autosave to the server is retried every interval seconds.

Usage

<AutosaveMonitor interval={ 30 } />

Parameters

BlockAlignmentToolbar

Deprecated since 5.3, use wp.blockEditor.BlockAlignmentToolbar instead.

BlockControls

Deprecated since 5.3, use wp.blockEditor.BlockControls instead.

BlockEdit

Deprecated since 5.3, use wp.blockEditor.BlockEdit instead.

BlockEditorKeyboardShortcuts

Deprecated since 5.3, use wp.blockEditor.BlockEditorKeyboardShortcuts instead.

BlockFormatControls

Deprecated since 5.3, use wp.blockEditor.BlockFormatControls instead.

BlockIcon

Deprecated since 5.3, use wp.blockEditor.BlockIcon instead.

BlockInspector

Deprecated since 5.3, use wp.blockEditor.BlockInspector instead.

BlockList

Deprecated since 5.3, use wp.blockEditor.BlockList instead.

BlockMover

Deprecated since 5.3, use wp.blockEditor.BlockMover instead.

BlockNavigationDropdown

Deprecated since 5.3, use wp.blockEditor.BlockNavigationDropdown instead.

BlockSelectionClearer

Deprecated since 5.3, use wp.blockEditor.BlockSelectionClearer instead.

BlockSettingsMenu

Deprecated since 5.3, use wp.blockEditor.BlockSettingsMenu instead.

BlockTitle

Deprecated since 5.3, use wp.blockEditor.BlockTitle instead.

BlockToolbar

Deprecated since 5.3, use wp.blockEditor.BlockToolbar instead.

CharacterCount

Renders the character count of the post content.

Returns

cleanForSlug

Performs some basic cleanup of a string for use as a post slug

This replicates some of what sanitize_title() does in WordPress core, but is only designed to approximate what the slug will be.

Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters. Removes combining diacritical marks. Converts whitespace, periods, and forward slashes to hyphens. Removes any remaining non-word characters except hyphens and underscores. Converts remaining string to lowercase. It does not account for octets, HTML entities, or other encoded characters.

Parameters

Returns

ColorPalette

Deprecated since 5.3, use wp.blockEditor.ColorPalette instead.

ContrastChecker

Deprecated since 5.3, use wp.blockEditor.ContrastChecker instead.

CopyHandler

Deprecated since 5.3, use wp.blockEditor.CopyHandler instead.

createCustomColorsHOC

Deprecated since 5.3, use wp.blockEditor.createCustomColorsHOC instead.

DefaultBlockAppender

Deprecated since 5.3, use wp.blockEditor.DefaultBlockAppender instead.

DocumentBar

This component renders a navigation bar at the top of the editor. It displays the title of the current document, a back button (if applicable), and a command center button. It also handles different states of the document, such as “not found” or “unsynced”.

Usage

<DocumentBar />

Parameters

Returns

DocumentOutline

Renders a document outline component.

Parameters

Returns

DocumentOutlineCheck

Component check if there are any headings (core/heading blocks) present in the document.

Parameters

Returns

EditorHistoryRedo

Renders the redo button for the editor history.

Parameters

Returns

EditorHistoryUndo

Renders the undo button for the editor history.

Parameters

Returns

EditorKeyboardShortcuts

Handles the keyboard shortcuts for the editor.

It provides functionality for various keyboard shortcuts such as toggling editor mode, toggling distraction-free mode, undo/redo, saving the post, toggling list view, and toggling the sidebar.

EditorKeyboardShortcutsRegister

Component for registering editor keyboard shortcuts.

Returns

EditorNotices

Deprecated since 7.0, use wp.notices.InlineNotices instead.

EditorProvider

This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).

It supports a large number of post types, including post, page, templates, custom post types, patterns, template parts.

All modification and changes are performed to the @wordpress/core-data store.

Usage

<EditorProvider
    post={ post }
    settings={ settings }
    __unstableTemplate={ template }
>
    { children }
</EditorProvider>

Parameters

Returns

EditorSnackbars

Deprecated since 7.0, use wp.notices.SnackbarNotices instead.

EntitiesSavedStates

Undocumented declaration.

ErrorBoundary

ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.

It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.

getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.

FontSizePicker

Deprecated since 5.3, use wp.blockEditor.FontSizePicker instead.

getColorClassName

Deprecated since 5.3, use wp.blockEditor.getColorClassName instead.

getColorObjectByAttributeValues

Deprecated since 5.3, use wp.blockEditor.getColorObjectByAttributeValues instead.

getColorObjectByColorValue

Deprecated since 5.3, use wp.blockEditor.getColorObjectByColorValue instead.

getFontSize

Deprecated since 5.3, use wp.blockEditor.getFontSize instead.

getFontSizeClass

Deprecated since 5.3, use wp.blockEditor.getFontSizeClass instead.

InnerBlocks

Deprecated since 5.3, use wp.blockEditor.InnerBlocks instead.

Inserter

Deprecated since 5.3, use wp.blockEditor.Inserter instead.

InspectorAdvancedControls

Deprecated since 5.3, use wp.blockEditor.InspectorAdvancedControls instead.

InspectorControls

Deprecated since 5.3, use wp.blockEditor.InspectorControls instead.

linkAutocompleter

Type

LocalAutosaveMonitor

Monitors local autosaves of a post in the editor. It uses several hooks and functions to manage autosave behavior:

The module also checks for sessionStorage support and conditionally exports the LocalAutosaveMonitor component based on that.

MediaPlaceholder

Deprecated since 5.3, use wp.blockEditor.MediaPlaceholder instead.

MediaUpload

Deprecated since 5.3, use wp.blockEditor.MediaUpload instead.

mediaUpload

Upload a media file when the file upload button is activated. Wrapper around uploadMedia() that injects the current post ID.

Parameters

MediaUploadCheck

Deprecated since 5.3, use wp.blockEditor.MediaUploadCheck instead.

MultiSelectScrollIntoView

Deprecated since 5.3, use wp.blockEditor.MultiSelectScrollIntoView instead.

NavigableToolbar

Deprecated since 5.3, use wp.blockEditor.NavigableToolbar instead.

ObserveTyping

Deprecated since 5.3, use wp.blockEditor.ObserveTyping instead.

PageAttributesCheck

Wrapper component that renders its children only if the post type supports page attributes.

Parameters

Returns

PageAttributesOrder

Renders the Page Attributes Order component. A number input in an editor interface for setting the order of a given page. The component is now not used in core but was kept for backward compatibility.

Returns

PageAttributesPanel

Renders the Page Attributes Panel component.

Returns

PageAttributesParent

Renders the Page Attributes Parent component. A dropdown menu in an editor interface for selecting the parent page of a given page.

Returns

PageTemplate

Provides a dropdown menu for selecting and managing post templates.

The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.

Returns

PanelColorSettings

Deprecated since 5.3, use wp.blockEditor.PanelColorSettings instead.

PlainText

Deprecated since 5.3, use wp.blockEditor.PlainText instead.

PluginBlockSettingsMenuItem

Renders a new item in the block settings menu.

Usage

// Using ES5 syntax
var __ = wp.i18n.__;
var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;

function doOnClick() {
    // To be called when the user clicks the menu item.
}

function MyPluginBlockSettingsMenuItem() {
    return React.createElement( PluginBlockSettingsMenuItem, {
        allowedBlocks: [ 'core/paragraph' ],
        icon: 'dashicon-name',
        label: __( 'Menu item text' ),
        onClick: doOnClick,
    } );
}
// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PluginBlockSettingsMenuItem } from '@wordpress/editor';

const doOnClick = () => {
    // To be called when the user clicks the menu item.
};

const MyPluginBlockSettingsMenuItem = () => (
    <PluginBlockSettingsMenuItem
        allowedBlocks={ [ 'core/paragraph' ] }
        icon="dashicon-name"
        label={ __( 'Menu item text' ) }
        onClick={ doOnClick }
    />
);

Parameters

Returns

PluginDocumentSettingPanel

Renders items below the Status & Availability panel in the Document Sidebar.

Usage

// Using ES5 syntax
var el = React.createElement;
var __ = wp.i18n.__;
var registerPlugin = wp.plugins.registerPlugin;
var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;

function MyDocumentSettingPlugin() {
    return el(
        PluginDocumentSettingPanel,
        {
            className: 'my-document-setting-plugin',
            title: 'My Panel',
            name: 'my-panel',
        },
        __( 'My Document Setting Panel' )
    );
}

registerPlugin( 'my-document-setting-plugin', {
    render: MyDocumentSettingPlugin,
} );
// Using ESNext syntax
import { registerPlugin } from '@wordpress/plugins';
import { PluginDocumentSettingPanel } from '@wordpress/editor';

const MyDocumentSettingTest = () => (
    <PluginDocumentSettingPanel
        className="my-document-setting-plugin"
        title="My Panel"
        name="my-panel"
    >
        <p>My Document Setting Panel</p>
    </PluginDocumentSettingPanel>
);

registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );

Parameters

Returns

PluginMoreMenuItem

Renders a menu item in Plugins group in More Menu drop down, and can be used to as a button or link depending on the props provided. The text within the component appears as the menu item label.

Usage

// Using ES5 syntax
var __ = wp.i18n.__;
var PluginMoreMenuItem = wp.editor.PluginMoreMenuItem;
var moreIcon = wp.element.createElement( 'svg' ); //... svg element.

function onButtonClick() {
    alert( 'Button clicked.' );
}

function MyButtonMoreMenuItem() {
    return wp.element.createElement(
        PluginMoreMenuItem,
        {
            icon: moreIcon,
            onClick: onButtonClick,
        },
        __( 'My button title' )
    );
}
// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PluginMoreMenuItem } from '@wordpress/editor';
import { more } from '@wordpress/icons';

function onButtonClick() {
    alert( 'Button clicked.' );
}

const MyButtonMoreMenuItem = () => (
    <PluginMoreMenuItem icon={ more } onClick={ onButtonClick }>
        { __( 'My button title' ) }
    </PluginMoreMenuItem>
);

Parameters

Returns

PluginPostPublishPanel

Renders provided content to the post-publish panel in the publish flow (side panel that opens after a user publishes the post).

Usage

// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PluginPostPublishPanel } from '@wordpress/editor';

const MyPluginPostPublishPanel = () => (
    <PluginPostPublishPanel
        className="my-plugin-post-publish-panel"
        title={ __( 'My panel title' ) }
        initialOpen={ true }
    >
        { __( 'My panel content' ) }
    </PluginPostPublishPanel>
);

Parameters

Returns

PluginPostStatusInfo

Renders a row in the Summary panel of the Document sidebar. It should be noted that this is named and implemented around the function it serves and not its location, which may change in future iterations.

Usage

// Using ES5 syntax
var __ = wp.i18n.__;
var PluginPostStatusInfo = wp.editor.PluginPostStatusInfo;

function MyPluginPostStatusInfo() {
    return React.createElement(
        PluginPostStatusInfo,
        {
            className: 'my-plugin-post-status-info',
        },
        __( 'My post status info' )
    );
}
// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PluginPostStatusInfo } from '@wordpress/editor';

const MyPluginPostStatusInfo = () => (
    <PluginPostStatusInfo className="my-plugin-post-status-info">
        { __( 'My post status info' ) }
    </PluginPostStatusInfo>
);

Parameters

Returns

PluginPrePublishPanel

Renders provided content to the pre-publish side panel in the publish flow (side panel that opens when a user first pushes “Publish” from the main editor).

Usage

// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PluginPrePublishPanel } from '@wordpress/editor';

const MyPluginPrePublishPanel = () => (
    <PluginPrePublishPanel
        className="my-plugin-pre-publish-panel"
        title={ __( 'My panel title' ) }
        initialOpen={ true }
    >
        { __( 'My panel content' ) }
    </PluginPrePublishPanel>
);

Parameters

Returns

PluginPreviewMenuItem

Renders a menu item in the Preview dropdown, which can be used as a button or link depending on the props provided. The text within the component appears as the menu item label.

Usage

import { __ } from '@wordpress/i18n';
import { PluginPreviewMenuItem } from '@wordpress/editor';
import { external } from '@wordpress/icons';

function onPreviewClick() {
    // Handle preview action
}

const ExternalPreviewMenuItem = () => (
    <PluginPreviewMenuItem icon={ external } onClick={ onPreviewClick }>
        { __( 'Preview in new tab' ) }
    </PluginPreviewMenuItem>
);
registerPlugin( 'external-preview-menu-item', {
    render: ExternalPreviewMenuItem,
} );

Parameters

Returns

PluginSidebar

Renders a sidebar when activated. The contents within the PluginSidebar will appear as content within the sidebar. It also automatically renders a corresponding PluginSidebarMenuItem component when isPinnable flag is set to true. If you wish to display the sidebar, you can with use the PluginSidebarMoreMenuItem component or the wp.data.dispatch API:

wp.data
    .dispatch( 'core/edit-post' )
    .openGeneralSidebar( 'plugin-name/sidebar-name' );

Usage

// Using ES5 syntax
var __ = wp.i18n.__;
var el = React.createElement;
var PanelBody = wp.components.PanelBody;
var PluginSidebar = wp.editor.PluginSidebar;
var moreIcon = React.createElement( 'svg' ); //... svg element.

function MyPluginSidebar() {
    return el(
        PluginSidebar,
        {
            name: 'my-sidebar',
            title: 'My sidebar title',
            icon: moreIcon,
        },
        el( PanelBody, {}, __( 'My sidebar content' ) )
    );
}
// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PanelBody } from '@wordpress/components';
import { PluginSidebar } from '@wordpress/editor';
import { more } from '@wordpress/icons';

const MyPluginSidebar = () => (
    <PluginSidebar name="my-sidebar" title="My sidebar title" icon={ more }>
        <PanelBody>{ __( 'My sidebar content' ) }</PanelBody>
    </PluginSidebar>
);

Parameters

PluginSidebarMoreMenuItem

Renders a menu item in Plugins group in More Menu drop down, and can be used to activate the corresponding PluginSidebar component. The text within the component appears as the menu item label.

Usage

// Using ES5 syntax
var __ = wp.i18n.__;
var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
var moreIcon = React.createElement( 'svg' ); //... svg element.

function MySidebarMoreMenuItem() {
    return React.createElement(
        PluginSidebarMoreMenuItem,
        {
            target: 'my-sidebar',
            icon: moreIcon,
        },
        __( 'My sidebar title' )
    );
}
// Using ESNext syntax
import { __ } from '@wordpress/i18n';
import { PluginSidebarMoreMenuItem } from '@wordpress/editor';
import { more } from '@wordpress/icons';

const MySidebarMoreMenuItem = () => (
    <PluginSidebarMoreMenuItem target="my-sidebar" icon={ more }>
        { __( 'My sidebar title' ) }
    </PluginSidebarMoreMenuItem>
);

Parameters

Returns

PostAuthor

Renders the control for selecting the post author.

Returns

PostAuthorCheck

Wrapper component that renders its children only if the post type supports the author.

Parameters

Returns

PostAuthorPanel

Renders the Post Author Panel component.

Returns

PostComments

A form for managing comment status.

Returns

PostDiscussionPanel

This component allows to update comment and pingback settings for the current post. Internally there are checks whether the current post has support for the above and if the discussion-panel panel is enabled.

Returns

PostExcerpt

Renders an editable textarea for the post excerpt. Templates, template parts and patterns use the excerpt field as a description semantically. Additionally templates and template parts override the excerpt field as description in REST API. So this component handles proper labeling and updating the edited entity.

Parameters

PostExcerptCheck

Component for checking if the post type supports the excerpt field.

Parameters

Returns

PostExcerptPanel

Is rendered if the post type supports excerpts and allows editing the excerpt.

Returns

PostFeaturedImage

Renders the component for managing the featured image of a post.

Parameters

Returns

PostFeaturedImageCheck

Wrapper component that renders its children only if the post type supports a featured image and the theme supports post thumbnails.

Parameters

Returns

PostFeaturedImagePanel

Renders the panel for the post featured image.

Parameters

Returns

PostFormat

PostFormat a component that allows changing the post format while also providing a suggestion for the current post.

Usage

<PostFormat />

Returns

PostFormatCheck

Component check if there are any post formats.

Parameters

Returns

PostLastRevision

Renders the component for displaying the last revision of a post.

Returns

PostLastRevisionCheck

Wrapper component that renders its children if the post has more than one revision.

Parameters

Returns

PostLastRevisionPanel

Renders the panel for displaying the last revision of a post.

Returns

PostLockedModal

A modal component that is displayed when a post is locked for editing by another user. The modal provides information about the lock status and options to take over or exit the editor.

Returns

PostPendingStatus

A component for displaying and toggling the pending status of a post.

Returns

PostPendingStatusCheck

This component checks the publishing status of the current post. If the post is already published or the user doesn’t have the capability to publish, it returns null.

Parameters

Returns

PostPingbacks

Renders a control for enabling or disabling pingbacks and trackbacks in a WordPress post.

PostPreviewButton

Renders a button that opens a new window or tab for the preview, writes the interstitial message to this window, and then navigates to the actual preview link. The button is not rendered if the post is not viewable and disabled if the post is not saveable.

Parameters

Returns

PostPublishButton

Renders the publish button.

PostPublishButtonLabel

Renders the label for the publish button.

Returns

PostPublishPanel

Renders a panel for publishing a post.

Parameters

Returns

PostSavedState

Component showing whether the post is saved or not and providing save buttons.

Parameters

Returns

PostSchedule

Renders the PostSchedule component. It allows the user to schedule a post.

Parameters

Returns

PostScheduleCheck

Wrapper component that renders its children only if post has a publish action.

Parameters

Returns

PostScheduleLabel

Renders the PostScheduleLabel component.

Parameters

Returns

PostSchedulePanel

Renders the Post Schedule Panel component.

Returns

PostSticky

Renders the PostSticky component. It provides a checkbox control for the sticky post feature.

Returns

PostStickyCheck

Wrapper component that renders its children only if post has a sticky action.

Parameters

Returns

PostSwitchToDraftButton

Renders a button component that allows the user to switch a post to draft status.

Returns

PostSyncStatus

Renders the sync status of a post.

Returns

PostTaxonomies

Renders the taxonomies associated with a post.

Parameters

Returns

PostTaxonomiesCheck

Renders the children components only if the current post type has taxonomies.

Parameters

Returns

PostTaxonomiesFlatTermSelector

Renders a flat term selector component.

Parameters

Returns

PostTaxonomiesHierarchicalTermSelector

Hierarchical term selector.

Parameters

Returns

PostTaxonomiesPanel

Component that renders the post taxonomies panel.

Returns

PostTemplatePanel

Displays the template controls based on the current editor settings and user permissions.

Returns

PostTextEditor

Displays the Post Text Editor along with content in Visual and Text mode.

Returns

PostTitle

Renders the PostTitle component.

Parameters

Returns

PostTitleRaw

Undocumented declaration.

PostTrash

Displays the Post Trash Button and Confirm Dialog in the Editor.

Parameters

Returns

PostTrashCheck

Wrapper component that renders its children only if the post can be trashed.

Parameters

Returns

PostTypeSupportCheck

A component which renders its own children only if the current editor post type supports one of the given supportKeys prop.

Parameters

Returns

PostURL

Renders the PostURL component.

Usage

<PostURL />

Parameters

Returns

PostURLCheck

Check if the post URL is valid and visible.

Parameters

Returns

PostURLLabel

Represents a label component for a post URL.

Returns

PostURLPanel

Renders the PostURLPanel component.

Returns

PostVisibility

Allows users to set the visibility of a post.

Parameters

Returns

PostVisibilityCheck

Determines if the current post can be edited (published) and passes this information to the provided render function.

Parameters

Returns

PostVisibilityLabel

Returns the label for the current post visibility setting.

Returns

privateApis

Undocumented declaration.

registerEntityAction

Deprecated since Gutenberg 24.3. Register the action in PHP on the wp_entity_actions_api_init action instead, with a script module for its JavaScript parts.

Has no effect: every action of an entity is registered on the server.

Register the action in PHP on the wp_entity_actions_api_init action instead, with a script module for the parts PHP cannot serialize (callback, RenderModal, isEligible…).

Parameters

registerEntityField

Deprecated since Gutenberg 24.3. Register the field in PHP with wp_register_entity_fields() instead.

Has no effect: the fields of an entity are registered on the server.

Register the field in PHP, with wp_register_entity_fields() on the wp_entity_fields_api_init action, and with a script module for the parts PHP cannot serialize (render, Edit, getElements…).

Parameters

RichText

Deprecated since 5.3, use wp.blockEditor.RichText instead.

RichTextShortcut

Deprecated since 5.3, use wp.blockEditor.RichTextShortcut instead.

RichTextToolbarButton

Deprecated since 5.3, use wp.blockEditor.RichTextToolbarButton instead.

ServerSideRender

Undocumented declaration.

SkipToSelectedBlock

Deprecated since 5.3, use wp.blockEditor.SkipToSelectedBlock instead.

store

Store definition for the editor namespace.

storeConfig

Post editor data store configuration.

TableOfContents

Renders a table of contents component.

Parameters

Returns

TextEditorGlobalKeyboardShortcuts

Handles the keyboard shortcuts for the editor.

It provides functionality for various keyboard shortcuts such as toggling editor mode, toggling distraction-free mode, undo/redo, saving the post, toggling list view, and toggling the sidebar.

ThemeSupportCheck

Checks if the current theme supports specific features and renders the children if supported.

Parameters

Returns

TimeToRead

Component for showing Time To Read in Content.

Returns

transformStyles

Undocumented declaration.

unregisterEntityAction

Deprecated since Gutenberg 24.3. Unregister the action in PHP on the wp_entity_actions_api_init action instead.

Has no effect: every action of an entity is registered on the server.

Unregister the action in PHP on the wp_entity_actions_api_init action instead.

Parameters

unregisterEntityField

Deprecated since Gutenberg 24.3. Unregister the field in PHP with wp_unregister_entity_fields() instead.

Has no effect: the fields of an entity are registered on the server.

Unregister the field in PHP, with wp_unregister_entity_fields() on the wp_entity_fields_api_init action.

Parameters

UnsavedChangesWarning

Warns the user if there are unsaved changes before leaving the editor. Compatible with Post Editor and Site Editor.

Returns

URLInput

Deprecated since 5.3, use wp.blockEditor.URLInput instead.

URLInputButton

Deprecated since 5.3, use wp.blockEditor.URLInputButton instead.

URLPopover

Deprecated since 5.3, use wp.blockEditor.URLPopover instead.

useEntitiesSavedStatesIsDirty

Undocumented declaration.

usePostScheduleLabel

Custom hook to get the label for post schedule.

Parameters

Returns

usePostURLLabel

Custom hook to get the label for the post URL.

Returns

usePostVisibilityLabel

Get the label for the current post visibility setting.

Returns

userAutocompleter

A user mentions completer.

Type

VisualEditorGlobalKeyboardShortcuts

Handles the keyboard shortcuts for the editor.

It provides functionality for various keyboard shortcuts such as toggling editor mode, toggling distraction-free mode, undo/redo, saving the post, toggling list view, and toggling the sidebar.

Warning

Deprecated since 5.3, use wp.blockEditor.Warning instead.

withColorContext

Deprecated since 5.3, use wp.blockEditor.createCustomColorsHOC instead.

withColors

Deprecated since 5.3, use wp.blockEditor.withColors instead.

withFontSizes

Deprecated since 5.3, use wp.blockEditor.withFontSizes instead.

WordCount

Renders the word count of the post content.

Returns

WritingFlow

Deprecated since 5.3, use wp.blockEditor.WritingFlow instead.

Contributing to this package

This is an individual package that’s part of the Gutenberg project. The project is organized as a monorepo. It’s made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project’s main contributor guide.


版本号 #2
由 壳壳虫 创建于 2026-10-31 18:18:53 UTC
由 壳壳虫 更新于 2026-10-31 18:18:57 UTC