The Post Editor’s Data Edit

Namespace: core/editor.

Selectors Selectors

# canInsertBlockType

Related

  • canInsertBlockType in core/block-editor store.

# canUserUseUnfilteredHTML

Returns whether or not the user has the unfiltered_html capability.

Parameters

  • state Object: Editor state.

Returns

  • boolean: Whether the user can or can’t post unfiltered HTML.

# didPostSaveRequestFail

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post save failed.

# didPostSaveRequestSucceed

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post was saved successfully.

# getActivePostLock

Returns the active post lock.

Parameters

  • state Object: Global application state.

Returns

  • Object: The lock object.

# getAdjacentBlockClientId

Related

  • getAdjacentBlockClientId in core/block-editor store.

# getAutosave

Deprecated since 5.6. Callers should use the getAutosave( postType, postId, userId ) selector from the ‘@wordpress/core-data’ package.

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 Object: Editor state.

Returns

  • ?Object: Current autosave, if exists.

# getAutosaveAttribute

Deprecated since 5.6. Callers should use the getAutosave( postType, postId, userId ) selector from the ‘@wordpress/core-data’ package and access properties on the returned autosave object using getPostRawValue.

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

Parameters

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

Returns

  • *: Autosave attribute value.

# getBlock

Related

  • getBlock in core/block-editor store.

# getBlockAttributes

Related

  • getBlockAttributes in core/block-editor store.

# getBlockCount

Related

  • getBlockCount in core/block-editor store.

# getBlockDependantsCacheBust

Related

  • getBlockDependantsCacheBust in core/block-editor store.

# getBlockHierarchyRootClientId

Related

  • getBlockHierarchyRootClientId in core/block-editor store.

# getBlockIndex

Related

  • getBlockIndex in core/block-editor store.

# getBlockInsertionPoint

Related

  • getBlockInsertionPoint in core/block-editor store.

# getBlockListSettings

Related

  • getBlockListSettings in core/block-editor store.

# getBlockMode

Related

  • getBlockMode in core/block-editor store.

# getBlockName

Related

  • getBlockName in core/block-editor store.

# getBlockOrder

Related

  • getBlockOrder in core/block-editor store.

# getBlockRootClientId

Related

  • getBlockRootClientId in core/block-editor store.

# getBlocks

Related

  • getBlocks in core/block-editor store.

# getBlocksByClientId

Related

  • getBlocksByClientId in core/block-editor store.

# getBlockSelectionEnd

Related

  • getBlockSelectionEnd in core/block-editor store.

# getBlockSelectionStart

Related

  • getBlockSelectionStart in core/block-editor store.

# getBlocksForSerialization

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

Parameters

  • state Object: Editor state.

Returns

  • Array<WPBlock>: Filtered set of blocks for save.

# getClientIdsOfDescendants

Related

  • getClientIdsOfDescendants in core/block-editor store.

# getClientIdsWithDescendants

Related

  • getClientIdsWithDescendants in core/block-editor store.

# 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 Object: Global application state.

Returns

  • Object: Post object.

# getCurrentPostAttribute

Returns an attribute value of the saved post.

Parameters

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

Returns

  • *: Post attribute value.

# getCurrentPostId

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

Parameters

  • state Object: Global application state.

Returns

  • ?number: ID of current post.

# getCurrentPostLastRevisionId

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

Parameters

  • state Object: Global application state.

Returns

  • ?number: ID of the last revision.

# getCurrentPostRevisionsCount

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

Parameters

  • state Object: Global application state.

Returns

  • number: Number of revisions.

# getCurrentPostType

Returns the post type of the post currently being edited.

Parameters

  • state Object: Global application state.

Returns

  • string: Post type.

# 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 Object: Global application state.
  • attributeName string: Post attribute name.

Returns

  • *: Post attribute value.

# getEditedPostContent

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

Parameters

  • state Object: Global application state.

Returns

  • string: Post content.

# getEditedPostPreviewLink

Returns the post preview link

Parameters

  • state Object: Global application state.

Returns

  • ?string: Preview Link.

# 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 Object: Global application state.

Returns

  • string: Post visibility.

# getEditorBlocks

Return the current block list.

Parameters

  • state Object:

Returns

  • Array: Block list.

# getEditorSettings

Returns the post editor settings.

Parameters

  • state Object: Editor state.

Returns

  • Object: The editor settings object.

# getFirstMultiSelectedBlockClientId

Related

  • getFirstMultiSelectedBlockClientId in core/block-editor store.

# getGlobalBlockCount

Related

  • getGlobalBlockCount in core/block-editor store.

# getInserterItems

Related

  • getInserterItems in core/block-editor store.

# getLastMultiSelectedBlockClientId

Related

  • getLastMultiSelectedBlockClientId in core/block-editor store.

# getMultiSelectedBlockClientIds

Related

  • getMultiSelectedBlockClientIds in core/block-editor store.

# getMultiSelectedBlocks

Related

  • getMultiSelectedBlocks in core/block-editor store.

# getMultiSelectedBlocksEndClientId

Related

  • getMultiSelectedBlocksEndClientId in core/block-editor store.

# getMultiSelectedBlocksStartClientId

Related

  • getMultiSelectedBlocksStartClientId in core/block-editor store.

# getNextBlockClientId

Related

  • getNextBlockClientId in core/block-editor store.

# getPermalink

Returns the permalink for the post.

Parameters

  • state Object: Editor state.

Returns

  • ?string: The permalink, or null if the post is not viewable.

# getPermalinkParts

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

Parameters

  • state Object: Editor state.

Returns

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

# getPostEdits

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

Parameters

  • state Object: Global application state.

Returns

  • Object: Object of key value pairs comprising unsaved edits.

# getPostLockUser

Returns details about the post lock user.

Parameters

  • state Object: Global application state.

Returns

  • Object: A user object.

# getPreviousBlockClientId

Related

  • getPreviousBlockClientId in core/block-editor store.

# 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.

Usage

const hasEditOccurred = (
   getReferenceByDistinctEdits( beforeState ) !==
   getReferenceByDistinctEdits( afterState )
);

Parameters

  • state Object: Editor state.

Returns

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

# getSelectedBlock

Related

  • getSelectedBlock in core/block-editor store.

# getSelectedBlockClientId

Related

  • getSelectedBlockClientId in core/block-editor store.

# getSelectedBlockCount

Related

  • getSelectedBlockCount in core/block-editor store.

# getSelectedBlocksInitialCaretPosition

Related

  • getSelectedBlocksInitialCaretPosition in core/block-editor store.

# 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 Object: Current global application state.
  • transactionId Object: Optimist transaction ID.

Returns

  • Object: Global application state prior to transaction.

# 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 Object: Global application state.

Returns

  • ?string: Suggested post format.

# getTemplate

Related

  • getTemplate in core/block-editor store.

# getTemplateLock

Related

  • getTemplateLock in core/block-editor store.

# hasAutosave

Deprecated since 5.6. Callers should use the getAutosave( postType, postId, userId ) selector from the ‘@wordpress/core-data’ package and check for a truthy value.

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether there is an existing autosave.

# hasChangedContent

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

Parameters

  • state Object: Editor state.

Returns

  • boolean: Whether content includes unsaved changes.

# hasEditorRedo

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether redo history exists.

# hasEditorUndo

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether undo history exists.

# hasInserterItems

Related

  • hasInserterItems in core/block-editor store.

# hasMultiSelection

Related

  • hasMultiSelection in core/block-editor store.

# hasSelectedBlock

Related

  • hasSelectedBlock in core/block-editor store.

# hasSelectedInnerBlock

Related

  • hasSelectedInnerBlock in core/block-editor store.

# inSomeHistory

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

Parameters

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

Returns

  • boolean: Whether predicate matches for some history.

# isAncestorMultiSelected

Related

  • isAncestorMultiSelected in core/block-editor store.

# isAutosavingPost

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post is autosaving.

# isBlockInsertionPointVisible

Related

  • isBlockInsertionPointVisible in core/block-editor store.

# isBlockMultiSelected

Related

  • isBlockMultiSelected in core/block-editor store.

# isBlockSelected

Related

  • isBlockSelected in core/block-editor store.

# isBlockValid

Related

  • isBlockValid in core/block-editor store.

# isBlockWithinSelection

Related

  • isBlockWithinSelection in core/block-editor store.

# isCaretWithinFormattedText

Related

  • isCaretWithinFormattedText in core/block-editor store.

# 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 Object: Global application state.

Returns

  • boolean: Whether new post and unsaved values exist.

# isCurrentPostPending

Returns true if post is pending review.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether current post is pending review.

# isCurrentPostPublished

Return true if the current post has already been published.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post has been published.

# isCurrentPostScheduled

Returns true if post is already scheduled.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether current post is scheduled to be posted.

# isEditedPostAutosaveable

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

Parameters

  • state Object: Global application state.
  • autosave Object: A raw autosave object from the REST API.

Returns

  • boolean: Whether the post can be autosaved.

# isEditedPostBeingScheduled

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post has been published.

# 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 Object: Editor state.

Returns

  • boolean: Whether the edited post has a floating date value.

# 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 Object: Global application state.

Returns

  • boolean: Whether unsaved values exist.

# 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 Object: Global application state.

Returns

  • boolean: Whether post has content.

# isEditedPostNew

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post is new.

# isEditedPostPublishable

Return true if the post being edited can be published.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post can been published.

# 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 Object: Global application state.

Returns

  • boolean: Whether the post can be saved.

# isFirstMultiSelectedBlock

Related

  • isFirstMultiSelectedBlock in core/block-editor store.

# isMultiSelecting

Related

  • isMultiSelecting in core/block-editor store.

# isPermalinkEditable

Returns whether the permalink is editable or not.

Parameters

  • state Object: Editor state.

Returns

  • boolean: Whether or not the permalink is editable.

# isPostLocked

Returns whether the post is locked.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Is locked.

# isPostLockTakeover

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Is post lock takeover.

# isPostSavingLocked

Returns whether post saving is locked.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Is locked.

# isPreviewingPost

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the post is being previewed.

# isPublishingPost

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether post is being published.

# isPublishSidebarEnabled

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

Parameters

  • state Object: Global application state.

Returns

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

# isSavingPost

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

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether post is being saved.

# isSelectionEnabled

Related

  • isSelectionEnabled in core/block-editor store.

# isTyping

Related

  • isTyping in core/block-editor store.

# isValidTemplate

Related

  • isValidTemplate in core/block-editor store.

Top ↑

Actions Actions

# autosave

Action generator used in signalling that the post should autosave.

Parameters

  • options ?Object: Extra flags to identify the autosave.

# clearSelectedBlock

Related

  • clearSelectedBlock in core/block-editor store.

# createUndoLevel

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

Returns

  • Object: Action object.

# disablePublishSidebar

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

Returns

  • Object: Action object

# editPost

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

Parameters

  • edits Object: Post attributes to edit.

Returns

  • Object: Action object.

# enablePublishSidebar

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

Returns

  • Object: Action object

# enterFormattedText

Related

  • enterFormattedText in core/block-editor store.

# exitFormattedText

Related

  • exitFormattedText in core/block-editor store.

# hideInsertionPoint

Related

  • hideInsertionPoint in core/block-editor store.

# insertBlock

Related

  • insertBlock in core/block-editor store.

# insertBlocks

Related

  • insertBlocks in core/block-editor store.

# insertDefaultBlock

Related

  • insertDefaultBlock in core/block-editor store.

# lockPostSaving

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

Parameters

  • lockName string: The lock name.

Returns

  • Object: Action object

# mergeBlocks

Related

  • mergeBlocks in core/block-editor store.

# moveBlocksDown

Related

  • moveBlocksDown in core/block-editor store.

# moveBlocksUp

Related

  • moveBlocksUp in core/block-editor store.

# moveBlockToPosition

Related

  • moveBlockToPosition in core/block-editor store.

# multiSelect

Related

  • multiSelect in core/block-editor store.

# receiveBlocks

Related

  • receiveBlocks in core/block-editor store.

# redo

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

Returns

  • Object: Action object.

# refreshPost

Action generator for handling refreshing the current post.

# removeBlock

Related

  • removeBlock in core/block-editor store.

# removeBlocks

Related

  • removeBlocks in core/block-editor store.

# replaceBlock

Related

  • replaceBlock in core/block-editor store.

# replaceBlocks

Related

  • replaceBlocks in core/block-editor store.

# resetAutosave

Deprecated since 5.6. Callers should use the receiveAutosaves( postId, autosave ) selector from the ‘@wordpress/core-data’ package.

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

Parameters

  • newAutosave Object: Autosave post object.

Returns

  • Object: Action object.

# resetBlocks

Related

  • resetBlocks in core/block-editor store.

# resetEditorBlocks

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

Parameters

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

Returns

  • Object: Action object

# 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 Object: Post object.

Returns

  • Object: Action object.

# savePost

Action generator for saving the current post in the editor.

Parameters

  • options Object:

# selectBlock

Related

  • selectBlock in core/block-editor store.

# setTemplateValidity

Related

  • setTemplateValidity in core/block-editor store.

# setupEditor

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

Parameters

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

# setupEditorState

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

Parameters

  • post Object: Post object.

Returns

  • Object: Action object.

# showInsertionPoint

Related

  • showInsertionPoint in core/block-editor store.

# startMultiSelect

Related

  • startMultiSelect in core/block-editor store.

# startTyping

Related

  • startTyping in core/block-editor store.

# stopMultiSelect

Related

  • stopMultiSelect in core/block-editor store.

# stopTyping

Related

  • stopTyping in core/block-editor store.

# synchronizeTemplate

Related

  • synchronizeTemplate in core/block-editor store.

# toggleBlockMode

Related

  • toggleBlockMode in core/block-editor store.

# toggleSelection

Related

  • toggleSelection in core/block-editor store.

# trashPost

Action generator for trashing the current post in the editor.

# undo

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

Returns

  • Object: Action object.

# unlockPostSaving

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

Parameters

  • lockName string: The lock name.

Returns

  • Object: Action object

# updateBlock

Related

  • updateBlock in core/block-editor store.

# updateBlockAttributes

Related

  • updateBlockAttributes in core/block-editor store.

# updateBlockListSettings

Related

  • updateBlockListSettings in core/block-editor store.

# updateEditorSettings

Undocumented declaration.

# 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 Object: Updated post fields.

Returns

  • Object: Action object.

# updatePostLock

Returns an action object used to lock the editor.

Parameters

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

Returns

  • Object: Action object.