WordPress.org

The Post Editor’s Data Edit

Selectors Selectors

hasEditorUndo hasEditorUndo

Returns true if any past editor history snapshots exist, or false otherwise.

Parameters

  • state: Global application state.

Top ↑

hasEditorRedo hasEditorRedo

Returns true if any future editor history snapshots exist, or false
otherwise.

Parameters

  • state: Global application state.

Returns

Whether redo history exists.

Top ↑

isEditedPostNew isEditedPostNew

Returns true if the currently edited post is yet to be saved, or false if
the post has been saved.

Parameters

  • state: Global application state.

Returns

Whether the post is new.

Top ↑

hasChangedContent hasChangedContent

Returns true if content includes unsaved changes, or false otherwise.

Parameters

  • state: Editor state.

Returns

Whether content includes unsaved changes.

Top ↑

isEditedPostDirty isEditedPostDirty

Returns true if there are unsaved values for the current edit session, or
false if the editing state matches the saved or new post.

Parameters

  • state: Global application state.

Returns

Whether unsaved values exist.

Top ↑

isCleanNewPost isCleanNewPost

Returns true if there are no unsaved values for the current edit session and
if the currently edited post is new (has never been saved before).

Parameters

  • state: Global application state.

Returns

Whether new post and unsaved values exist.

Top ↑

getCurrentPost getCurrentPost

Returns the post currently being edited in its last known saved state, not
including unsaved edits. Returns an object containing relevant default post
values if the post has not yet been saved.

Parameters

  • state: Global application state.

Returns

Post object.

Top ↑

getCurrentPostType getCurrentPostType

Returns the post type of the post currently being edited.

Parameters

  • state: Global application state.

Returns

Post type.

Top ↑

getCurrentPostId getCurrentPostId

Returns the ID of the post currently being edited, or null if the post has
not yet been saved.

Parameters

  • state: Global application state.

Returns

ID of current post.

Top ↑

getCurrentPostRevisionsCount getCurrentPostRevisionsCount

Returns the number of revisions of the post currently being edited.

Parameters

  • state: Global application state.

Returns

Number of revisions.

Top ↑

getCurrentPostLastRevisionId getCurrentPostLastRevisionId

Returns the last revision ID of the post currently being edited,
or null if the post has no revisions.

Parameters

  • state: Global application state.

Returns

ID of the last revision.

Top ↑

getPostEdits getPostEdits

Returns any post values which have been changed in the editor but not yet
been saved.

Parameters

  • state: Global application state.

Returns

Object of key value pairs comprising unsaved edits.

Top ↑

getReferenceByDistinctEdits getReferenceByDistinctEdits

Returns a new reference when edited values have changed. This is useful in
inferring where an edit has been made between states by comparison of the
return values using strict equality.

Parameters

  • state: Editor state.

Returns

A value whose reference will change only when an edit occurs.

Top ↑

getCurrentPostAttribute getCurrentPostAttribute

Returns an attribute value of the saved post.

Parameters

  • state: Global application state.
  • attributeName: Post attribute name.

Returns

Post attribute value.

Top ↑

getEditedPostAttribute getEditedPostAttribute

Returns a single attribute of the post being edited, preferring the unsaved
edit if one exists, but falling back to the attribute for the last known
saved state of the post.

Parameters

  • state: Global application state.
  • attributeName: Post attribute name.

Returns

Post attribute value.

Top ↑

getAutosaveAttribute getAutosaveAttribute

Returns an attribute value of the current autosave revision for a post, or
null if there is no autosave for the post.

Parameters

  • state: Global application state.
  • attributeName: Autosave attribute name.

Returns

Autosave attribute value.

Top ↑

getEditedPostVisibility getEditedPostVisibility

Returns the current visibility of the post being edited, preferring the
unsaved value if different than the saved post. The return value is one of
“private”, “password”, or “public”.

Parameters

  • state: Global application state.

Returns

Post visibility.

Top ↑

isCurrentPostPending isCurrentPostPending

Returns true if post is pending review.

Parameters

  • state: Global application state.

Returns

Whether current post is pending review.

Top ↑

isCurrentPostPublished isCurrentPostPublished

Return true if the current post has already been published.

Parameters

  • state: Global application state.

Returns

Whether the post has been published.

Top ↑

isCurrentPostScheduled isCurrentPostScheduled

Returns true if post is already scheduled.

Parameters

  • state: Global application state.

Returns

Whether current post is scheduled to be posted.

Top ↑

isEditedPostPublishable isEditedPostPublishable

Return true if the post being edited can be published.

Parameters

  • state: Global application state.

Returns

Whether the post can been published.

Top ↑

isEditedPostSaveable isEditedPostSaveable

Returns true if the post can be saved, or false otherwise. A post must
contain a title, an excerpt, or non-empty content to be valid for save.

Parameters

  • state: Global application state.

Returns

Whether the post can be saved.

Top ↑

isEditedPostEmpty isEditedPostEmpty

Returns true if the edited post has content. A post has content if it has at
least one saveable block or otherwise has a non-empty content property
assigned.

Parameters

  • state: Global application state.

Returns

Whether post has content.

Top ↑

isEditedPostAutosaveable isEditedPostAutosaveable

Returns true if the post can be autosaved, or false otherwise.

Parameters

  • state: Global application state.

Returns

Whether the post can be autosaved.

Top ↑

getAutosave getAutosave

Returns the current autosave, or null if one is not set (i.e. if the post
has yet to be autosaved, or has been saved or published since the last
autosave).

Parameters

  • state: Editor state.

Returns

Current autosave, if exists.

Top ↑

hasAutosave hasAutosave

Returns the true if there is an existing autosave, otherwise false.

Parameters

  • state: Global application state.

Returns

Whether there is an existing autosave.

Top ↑

isEditedPostBeingScheduled isEditedPostBeingScheduled

Return true if the post being edited is being scheduled. Preferring the
unsaved status values.

Parameters

  • state: Global application state.

Returns

Whether the post has been published.

Top ↑

isEditedPostDateFloating isEditedPostDateFloating

Returns whether the current post should be considered to have a “floating”
date (i.e. that it would publish “Immediately” rather than at a set time).

Unlike in the PHP backend, the REST API returns a full date string for posts
where the 0000-00-00T00:00:00 placeholder is present in the database. To
infer that a post is set to publish “Immediately” we check whether the date
and modified date are the same.

Parameters

  • state: Editor state.

Returns

Whether the edited post has a floating date value.

Top ↑

isSavingPost isSavingPost

Returns true if the post is currently being saved, or false otherwise.

Parameters

  • state: Global application state.

Returns

Whether post is being saved.

Top ↑

didPostSaveRequestSucceed didPostSaveRequestSucceed

Returns true if a previous post save was attempted successfully, or false
otherwise.

Parameters

  • state: Global application state.

Returns

Whether the post was saved successfully.

Top ↑

didPostSaveRequestFail didPostSaveRequestFail

Returns true if a previous post save was attempted but failed, or false
otherwise.

Parameters

  • state: Global application state.

Returns

Whether the post save failed.

Top ↑

isAutosavingPost isAutosavingPost

Returns true if the post is autosaving, or false otherwise.

Parameters

  • state: Global application state.

Returns

Whether the post is autosaving.

Top ↑

isPreviewingPost isPreviewingPost

Returns true if the post is being previewed, or false otherwise.

Parameters

  • state: Global application state.

Returns

Whether the post is being previewed.

Top ↑

Returns the post preview link

Parameters

  • state: Global application state.

Returns

Preview Link.

Top ↑

getSuggestedPostFormat getSuggestedPostFormat

Returns a suggested post format for the current post, inferred only if there
is a single block within the post and it is of a type known to match a
default post format. Returns null if the format cannot be determined.

Parameters

  • state: Global application state.

Returns

Suggested post format.

Top ↑

getBlocksForSerialization getBlocksForSerialization

Returns a set of blocks which are to be used in consideration of the post’s
generated save content.

Parameters

  • state: Editor state.

Returns

Filtered set of blocks for save.

Top ↑

getEditedPostContent getEditedPostContent

Returns the content of the post being edited, preferring raw string edit
before falling back to serialization of block state.

Parameters

  • state: Global application state.

Returns

Post content.

Top ↑

__experimentalGetReusableBlock __experimentalGetReusableBlock

Returns the reusable block with the given ID.

Parameters

  • state: Global application state.
  • ref: The reusable block’s ID.

Returns

The reusable block, or null if none exists.

Top ↑

__experimentalIsSavingReusableBlock __experimentalIsSavingReusableBlock

Returns whether or not the reusable block with the given ID is being saved.

Parameters

  • state: Global application state.
  • ref: The reusable block’s ID.

Returns

Whether or not the reusable block is being saved.

Top ↑

__experimentalIsFetchingReusableBlock __experimentalIsFetchingReusableBlock

Returns true if the reusable block with the given ID is being fetched, or
false otherwise.

Parameters

  • state: Global application state.
  • ref: The reusable block’s ID.

Returns

Whether the reusable block is being fetched.

Top ↑

__experimentalGetReusableBlocks __experimentalGetReusableBlocks

Returns an array of all reusable blocks.

Parameters

  • state: Global application state.

Returns

An array of all reusable blocks.

Top ↑

getStateBeforeOptimisticTransaction getStateBeforeOptimisticTransaction

Returns state object prior to a specified optimist transaction ID, or null
if the transaction corresponding to the given ID cannot be found.

Parameters

  • state: Current global application state.
  • transactionId: Optimist transaction ID.

Returns

Global application state prior to transaction.

Top ↑

isPublishingPost isPublishingPost

Returns true if the post is being published, or false otherwise.

Parameters

  • state: Global application state.

Returns

Whether post is being published.

Top ↑

isPermalinkEditable isPermalinkEditable

Returns whether the permalink is editable or not.

Parameters

  • state: Editor state.

Returns

Whether or not the permalink is editable.

Top ↑

Returns the permalink for the post.

Parameters

  • state: Editor state.

Returns

The permalink, or null if the post is not viewable.

Top ↑

getPermalinkParts getPermalinkParts

Returns the permalink for a post, split into it’s three parts: the prefix,
the postName, and the suffix.

Parameters

  • state: Editor state.

Returns

An object containing the prefix, postName, and suffix for
the permalink, or null if the post is not viewable.

Top ↑

inSomeHistory inSomeHistory

Returns true if an optimistic transaction is pending commit, for which the
before state satisfies the given predicate function.

Parameters

  • state: Editor state.
  • predicate: Function given state, returning true if match.

Returns

Whether predicate matches for some history.

Top ↑

isPostLocked isPostLocked

Returns whether the post is locked.

Parameters

  • state: Global application state.

Returns

Is locked.

Top ↑

isPostSavingLocked isPostSavingLocked

Returns whether post saving is locked.

Parameters

  • state: Global application state.

Returns

Is locked.

Top ↑

isPostLockTakeover isPostLockTakeover

Returns whether the edition of the post has been taken over.

Parameters

  • state: Global application state.

Returns

Is post lock takeover.

Top ↑

getPostLockUser getPostLockUser

Returns details about the post lock user.

Parameters

  • state: Global application state.

Returns

A user object.

Top ↑

getActivePostLock getActivePostLock

Returns the active post lock.

Parameters

  • state: Global application state.

Returns

The lock object.

Top ↑

canUserUseUnfilteredHTML canUserUseUnfilteredHTML

Returns whether or not the user has the unfiltered_html capability.

Parameters

  • state: Editor state.

Returns

Whether the user can or can’t post unfiltered HTML.

Top ↑

isPublishSidebarEnabled isPublishSidebarEnabled

Returns whether the pre-publish panel should be shown
or skipped when the user clicks the “publish” button.

Parameters

  • state: Global application state.

Returns

Whether the pre-publish panel should be shown or not.

Top ↑

getEditorBlocks getEditorBlocks

Return the current block list.

Parameters

  • state: null

Returns

Block list.

Top ↑

__unstableIsEditorReady __unstableIsEditorReady

Is the editor ready

Parameters

  • state: null

Returns

is Ready.

Top ↑

getEditorSettings getEditorSettings

Returns the post editor settings.

Parameters

  • state: Editor state.

Returns

The editor settings object.

Top ↑

Actions Actions

Top ↑

setupEditor setupEditor

Returns an action object used in signalling that editor has initialized with
the specified post object and editor settings.

Parameters

  • post: Post object.
  • edits: Initial edited attributes object.
  • template: Block Template.

Top ↑

resetPost resetPost

Returns an action object used in signalling that the latest version of the
post has been received, either by initialization or save.

Parameters

  • post: Post object.

Top ↑

resetAutosave resetAutosave

Returns an action object used in signalling that the latest autosave of the
post has been received, by initialization or autosave.

Parameters

  • post: Autosave post object.

Top ↑

__experimentalRequestPostUpdateStart __experimentalRequestPostUpdateStart

Optimistic action for dispatching that a post update request has started.

Parameters

  • options: null

Top ↑

__experimentalRequestPostUpdateSuccess __experimentalRequestPostUpdateSuccess

Optimistic action for indicating that the request post update has completed
successfully.

Parameters

  • data: The data for the action.
  • data.previousPost: The previous post prior to update.
  • data.post: The new post after update
  • data.isRevision: Whether the post is a revision or not.
  • data.options: Options passed through from the original
    action dispatch.
  • data.postType: The post type object.

Top ↑

__experimentalRequestPostUpdateFailure __experimentalRequestPostUpdateFailure

Optimistic action for indicating that the request post update has completed
with a failure.

Parameters

  • data: The data for the action
  • data.post: The post that failed updating.
  • data.edits: The fields that were being updated.
  • data.error: The error from the failed call.
  • data.options: Options passed through from the original
    action dispatch.

Top ↑

updatePost updatePost

Returns an action object used in signalling that a patch of updates for the
latest version of the post have been received.

Parameters

  • edits: Updated post fields.

Top ↑

setupEditorState setupEditorState

Returns an action object used to setup the editor state when first opening
an editor.

Parameters

  • post: Post object.

Top ↑

editPost editPost

Returns an action object used in signalling that attributes of the post have
been edited.

Parameters

  • edits: Post attributes to edit.

Top ↑

__experimentalOptimisticUpdatePost __experimentalOptimisticUpdatePost

Returns action object produced by the updatePost creator augmented by
an optimist option that signals optimistically applying updates.

Parameters

  • edits: Updated post fields.

Top ↑

savePost savePost

Action generator for saving the current post in the editor.

Parameters

  • options: null

Top ↑

refreshPost refreshPost

Action generator for handling refreshing the current post.

Top ↑

trashPost trashPost

Action generator for trashing the current post in the editor.

Top ↑

autosave autosave

Action generator used in signalling that the post should autosave.

Parameters

  • options: Extra flags to identify the autosave.

Top ↑

redo redo

Returns an action object used in signalling that undo history should
restore last popped state.

Top ↑

undo undo

Returns an action object used in signalling that undo history should pop.

Top ↑

createUndoLevel createUndoLevel

Returns an action object used in signalling that undo history record should
be created.

Top ↑

updatePostLock updatePostLock

Returns an action object used to lock the editor.

Parameters

  • lock: Details about the post lock status, user, and nonce.

Top ↑

__experimentalFetchReusableBlocks __experimentalFetchReusableBlocks

Returns an action object used to fetch a single reusable block or all
reusable blocks from the REST API into the store.

Parameters

  • id: If given, only a single reusable block with this ID will
    be fetched.

Top ↑

__experimentalReceiveReusableBlocks __experimentalReceiveReusableBlocks

Returns an action object used in signalling that reusable blocks have been
received. results is an array of objects containing:
reusableBlock – Details about how the reusable block is persisted.
parsedBlock – The original block.

Parameters

  • results: Reusable blocks received.

Top ↑

__experimentalSaveReusableBlock __experimentalSaveReusableBlock

Returns an action object used to save a reusable block that’s in the store to
the REST API.

Parameters

  • id: The ID of the reusable block to save.

Top ↑

__experimentalDeleteReusableBlock __experimentalDeleteReusableBlock

Returns an action object used to delete a reusable block via the REST API.

Parameters

  • id: The ID of the reusable block to delete.

Top ↑

__experimentalUpdateReusableBlockTitle __experimentalUpdateReusableBlockTitle

Returns an action object used in signalling that a reusable block’s title is
to be updated.

Parameters

  • id: The ID of the reusable block to update.
  • title: The new title.

Top ↑

__experimentalConvertBlockToStatic __experimentalConvertBlockToStatic

Returns an action object used to convert a reusable block into a static
block.

Parameters

  • clientId: The client ID of the block to attach.

Top ↑

__experimentalConvertBlockToReusable __experimentalConvertBlockToReusable

Returns an action object used to convert a static block into a reusable
block.

Parameters

  • clientIds: The client IDs of the block to detach.

Top ↑

enablePublishSidebar enablePublishSidebar

Returns an action object used in signalling that the user has enabled the
publish sidebar.

Top ↑

disablePublishSidebar disablePublishSidebar

Returns an action object used in signalling that the user has disabled the
publish sidebar.

Top ↑

lockPostSaving lockPostSaving

Returns an action object used to signal that post saving is locked.

Parameters

  • lockName: The lock name.

Top ↑

unlockPostSaving unlockPostSaving

Returns an action object used to signal that post saving is unlocked.

Parameters

  • lockName: The lock name.

Top ↑

resetEditorBlocks resetEditorBlocks

Returns an action object used to signal that the blocks have been updated.

Parameters

  • blocks: Block Array.
  • options: Optional options.

Top ↑

updateEditorSettings updateEditorSettings

Returns an action object used in signalling that the post editor settings have been updated.

Parameters

  • settings: Updated settings
Skip to toolbar