Namespace: core/editor
.
Related
- canInsertBlockType in core/block-editor store.
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.
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.
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.
Returns the active post lock.
Parameters
- state
Object
: Global application state.
Returns
Object
: The lock object.
Related
- getAdjacentBlockClientId in core/block-editor store.
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.
Related
- getBlock in core/block-editor store.
Related
- getBlockAttributes in core/block-editor store.
Related
- getBlockCount in core/block-editor store.
Related
- getBlockHierarchyRootClientId in core/block-editor store.
Related
- getBlockIndex in core/block-editor store.
Related
- getBlockInsertionPoint in core/block-editor store.
Related
- getBlockListSettings in core/block-editor store.
Related
- getBlockMode in core/block-editor store.
Related
- getBlockName in core/block-editor store.
Related
- getBlockOrder in core/block-editor store.
Related
- getBlockRootClientId in core/block-editor store.
Related
- getBlocks in core/block-editor store.
Related
- getBlocksByClientId in core/block-editor store.
Related
- getBlockSelectionEnd in core/block-editor store.
Related
- getBlockSelectionStart in core/block-editor store.
Related
- getClientIdsOfDescendants in core/block-editor store.
Related
- getClientIdsWithDescendants in core/block-editor store.
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.
Returns an attribute value of the saved post.
Parameters
- state
Object
: Global application state. - attributeName
string
: Post attribute name.
Returns
*
: Post attribute value.
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.
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.
Returns the number of revisions of the post currently being edited.
Parameters
- state
Object
: Global application state.
Returns
number
: Number of revisions.
Returns the post type of the post currently being edited.
Parameters
- state
Object
: Global application state.
Returns
string
: Post type.
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.
Returns the content of the post being edited.
Parameters
- state
Object
: Global application state.
Returns
string
: Post content.
Returns the post preview link
Parameters
- state
Object
: Global application state.
Returns
string?
: Preview Link.
Returns the slug for the post being edited, preferring a manually edited value if one exists, then a sanitized version of the current post title, and finally the post ID.
Parameters
- state
Object
: Editor state.
Returns
string
: The current slug to be displayed in the editor
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.
Return the current block list.
Parameters
- state
Object
:
Returns
Array
: Block list.
Returns the current selection.
Parameters
- state
Object
:
Returns
WPBlockSelection
: The selection end.
Deprecated since Gutenberg 10.0.0.
Returns the current selection end.
Parameters
- state
Object
:
Returns
WPBlockSelection
: The selection end.
Deprecated since Gutenberg 10.0.0.
Returns the current selection start.
Parameters
- state
Object
:
Returns
WPBlockSelection
: The selection start.
Returns the post editor settings.
Parameters
- state
Object
: Editor state.
Returns
Object
: The editor settings object.
Related
- getFirstMultiSelectedBlockClientId in core/block-editor store.
Related
- getGlobalBlockCount in core/block-editor store.
Related
- getInserterItems in core/block-editor store.
Related
- getLastMultiSelectedBlockClientId in core/block-editor store.
Related
- getMultiSelectedBlockClientIds in core/block-editor store.
Related
- getMultiSelectedBlocks in core/block-editor store.
Related
- getMultiSelectedBlocksEndClientId in core/block-editor store.
Related
- getMultiSelectedBlocksStartClientId in core/block-editor store.
Related
- getNextBlockClientId in core/block-editor store.
Returns the permalink for the post.
Parameters
- state
Object
: Editor state.
Returns
?string
: The permalink, or null if the post is not viewable.
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.
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.
Returns details about the post lock user.
Parameters
- state
Object
: Global application state.
Returns
Object
: A user object.
Returns a post type label depending on the current post.
Parameters
- state
Object
: Global application state.
Returns
string|undefined
: The post type label if available, otherwise undefined.
Related
- getPreviousBlockClientId in core/block-editor store.
Related
- getSelectedBlock in core/block-editor store.
Related
- getSelectedBlockClientId in core/block-editor store.
Related
- getSelectedBlockCount in core/block-editor store.
Related
- getSelectedBlocksInitialCaretPosition in core/block-editor store.
Deprecated since Gutenberg 9.7.0.
Returns state object prior to a specified optimist transaction ID, or null
if the transaction corresponding to the given ID cannot be found.
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.
Related
- getTemplate in core/block-editor store.
Related
- getTemplateLock in core/block-editor store.
Returns true if content includes unsaved changes, or false otherwise.
Parameters
- state
Object
: Editor state.
Returns
boolean
: Whether content includes unsaved changes.
Returns true if any future editor history snapshots exist, or false otherwise.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether redo history exists.
Returns true if any past editor history snapshots exist, or false otherwise.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether undo history exists.
Related
- hasInserterItems in core/block-editor store.
Related
- hasMultiSelection in core/block-editor store.
Returns true if there are unsaved edits for entities other than the editor's post, and false otherwise.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether there are edits or not.
Related
- hasSelectedBlock in core/block-editor store.
Related
- hasSelectedInnerBlock in core/block-editor store.
Deprecated since Gutenberg 9.7.0.
Returns true if an optimistic transaction is pending commit, for which the before state satisfies the given predicate function.
Related
- isAncestorMultiSelected in core/block-editor store.
Returns true if the post is autosaving, or false otherwise.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether the post is autosaving.
Related
- isBlockInsertionPointVisible in core/block-editor store.
Related
- isBlockMultiSelected in core/block-editor store.
Related
- isBlockSelected in core/block-editor store.
Related
- isBlockValid in core/block-editor store.
Related
- isBlockWithinSelection in core/block-editor store.
Related
- isCaretWithinFormattedText in core/block-editor store.
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.
Returns true if post is pending review.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether current post is pending review.
Return true if the current post has already been published.
Parameters
- state
Object
: Global application state. - currentPost
Object?
: Explicit current post for bypassing registry selector.
Returns
boolean
: Whether the post has been published.
Returns true if post is already scheduled.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether current post is scheduled to be posted.
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.
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.
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.
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.
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.
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.
Return true if the post being edited can be published.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether the post can been published.
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.
Related
- isFirstMultiSelectedBlock in core/block-editor store.
Related
- isMultiSelecting in core/block-editor store.
Returns whether the permalink is editable or not.
Parameters
- state
Object
: Editor state.
Returns
boolean
: Whether or not the permalink is editable.
Returns whether post autosaving is locked.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Is locked.
Returns whether the post is locked.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Is locked.
Returns whether the edition of the post has been taken over.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Is post lock takeover.
Returns whether post saving is locked.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Is locked.
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.
Returns true if the post is being published, or false otherwise.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether post is being published.
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.
Returns true if non-post entities are currently being saved, or false otherwise.
Parameters
- state
Object
: Global application state.
Returns
boolean
: Whether non-post entities are being saved.
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.
Related
- isSelectionEnabled in core/block-editor store.
Related
- isTyping in core/block-editor store.
Related
- isValidTemplate in core/block-editor store.
Action generator used in signalling that the post should autosave. This includes server-side autosaving (default) and client-side (a.k.a. local) autosaving (e.g. on the Web, the post might be committed to Session Storage).
Parameters
- options
Object?
: Extra flags to identify the autosave.
Related
- clearSelectedBlock in core/block-editor store.
Returns an action object used in signalling that the user has disabled the publish sidebar.
Returns
Object
: Action object
Returns an action object used in signalling that attributes of the post have been edited.
Parameters
- edits
Object
: Post attributes to edit. - options
Object
: Options for the edit.
Returns an action object used in signalling that the user has enabled the publish sidebar.
Returns
Object
: Action object
Related
- enterFormattedText in core/block-editor store.
Related
- exitFormattedText in core/block-editor store.
Related
- hideInsertionPoint in core/block-editor store.
Related
- insertBlock in core/block-editor store.
Related
- insertBlocks in core/block-editor store.
Related
- insertDefaultBlock in core/block-editor store.
Returns an action object used to signal that post autosaving is locked.
Usage
// Lock post autosaving with the lock key `mylock`:
wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
Parameters
- lockName
string
: The lock name.
Returns
Object
: Action object
Returns an action object used to signal that post saving is locked.
Usage
const { subscribe } = wp.data;
const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
// Only allow publishing posts that are set to a future date.
if ( 'publish' !== initialPostStatus ) {
// Track locking.
let locked = false;
// Watch for the publish event.
let unssubscribe = subscribe( () => {
const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
if ( 'publish' !== currentPostStatus ) {
// Compare the post date to the current date, lock the post if the date isn't in the future.
const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
const currentDate = new Date();
if ( postDate.getTime() <= currentDate.getTime() ) {
if ( ! locked ) {
locked = true;
wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
}
} else {
if ( locked ) {
locked = false;
wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
}
}
}
} );
}
Parameters
- lockName
string
: The lock name.
Returns
Object
: Action object
Related
- mergeBlocks in core/block-editor store.
Related
- moveBlocksDown in core/block-editor store.
Related
- moveBlocksUp in core/block-editor store.
Related
- moveBlockToPosition in core/block-editor store.
Related
- multiSelect in core/block-editor store.
Related
- receiveBlocks in core/block-editor store.
Returns an action object used in signalling that undo history should restore last popped state.
Related
- removeBlock in core/block-editor store.
Related
- removeBlocks in core/block-editor store.
Related
- replaceBlock in core/block-editor store.
Related
- replaceBlocks in core/block-editor store.
Related
- resetBlocks in core/block-editor store.
Returns an action object used to signal that the blocks have been updated.
Parameters
- blocks
Array
: Block Array. - options
?Object
: Optional options.
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.
Action generator for saving the current post in the editor.
Parameters
- options
Object
:
Related
- selectBlock in core/block-editor store.
Related
- setTemplateValidity in core/block-editor store.
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.
Returns an action object used to setup the editor state when first opening an editor.
Parameters
- post
Object
: Post object.
Returns
Object
: Action object.
Related
- showInsertionPoint in core/block-editor store.
Related
- startMultiSelect in core/block-editor store.
Related
- startTyping in core/block-editor store.
Related
- stopMultiSelect in core/block-editor store.
Related
- stopTyping in core/block-editor store.
Related
- synchronizeTemplate in core/block-editor store.
Related
- toggleBlockMode in core/block-editor store.
Related
- toggleSelection in core/block-editor store.
Action generator for trashing the current post in the editor.
Returns an action object used in signalling that undo history should pop.
Returns an action object used to signal that post autosaving is unlocked.
Usage
// Unlock post saving with the lock key `mylock`:
wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
Parameters
- lockName
string
: The lock name.
Returns
Object
: Action object
Returns an action object used to signal that post saving is unlocked.
Usage
// Unlock post saving with the lock key `mylock`:
wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
Parameters
- lockName
string
: The lock name.
Returns
Object
: Action object
Related
- updateBlock in core/block-editor store.
Related
- updateBlockAttributes in core/block-editor store.
Related
- updateBlockListSettings in core/block-editor store.
Undocumented declaration.
Deprecated since Gutenberg 9.7.0.
Returns an action object used in signalling that a patch of updates for the latest version of the post have been received.
Returns
Object
: Action object.
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.