: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param {Object} state Global application state.
* @return {Array} An array of style ID to style override pairs.
const getStyleOverrides = (0,external_wp_data_namespaceObject.createSelector)(state => {
const clientIds = getClientIdsWithDescendants(state);
const clientIdMap = clientIds.reduce((acc, clientId, index) => {
return [...state.styleOverrides].sort((overrideA, overrideB) => {
var _clientIdMap$clientId, _clientIdMap$clientId2;
// Once the overrides Map is spread to an array, the first element
// is the key, while the second is the override itself including
// the clientId to sort by.
const aIndex = (_clientIdMap$clientId = clientIdMap[clientIdA]) !== null && _clientIdMap$clientId !== void 0 ? _clientIdMap$clientId : -1;
const bIndex = (_clientIdMap$clientId2 = clientIdMap[clientIdB]) !== null && _clientIdMap$clientId2 !== void 0 ? _clientIdMap$clientId2 : -1;
}, state => [state.blocks.order, state.styleOverrides]);
/** @typedef {import('./actions').InserterMediaCategory} InserterMediaCategory */
* Returns the registered inserter media categories through the public API.
* @param {Object} state Editor state.
* @return {InserterMediaCategory[]} Inserter media categories.
function getRegisteredInserterMediaCategories(state) {
return state.registeredInserterMediaCategories;
* Returns an array containing the allowed inserter media categories.
* It merges the registered media categories from extenders with the
* core ones. It also takes into account the allowed `mime_types`, which
* can be altered by `upload_mimes` filter and restrict some of them.
* @param {Object} state Global application state.
* @return {InserterMediaCategory[]} Client IDs of descendants.
const getInserterMediaCategories = (0,external_wp_data_namespaceObject.createSelector)(state => {
enableOpenverseMediaCategory
registeredInserterMediaCategories
// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict
// some of them. In this case we shouldn't add the category to the available media
// categories list in the inserter.
if (!inserterMediaCategories && !registeredInserterMediaCategories.length || !allowedMimeTypes) {
const coreInserterMediaCategoriesNames = inserterMediaCategories?.map(({
const mergedCategories = [...(inserterMediaCategories || []), ...(registeredInserterMediaCategories || []).filter(({
}) => !coreInserterMediaCategoriesNames.includes(name))];
return mergedCategories.filter(category => {
// Check if Openverse category is enabled.
if (!enableOpenverseMediaCategory && category.name === 'openverse') {
return Object.values(allowedMimeTypes).some(mimeType => mimeType.startsWith(`${category.mediaType}/`));
}, state => [state.settings.inserterMediaCategories, state.settings.allowedMimeTypes, state.settings.enableOpenverseMediaCategory, state.registeredInserterMediaCategories]);
* Returns whether there is at least one allowed pattern for inner blocks children.
* This is useful for deferring the parsing of all patterns until needed.
* @param {Object} state Editor state.
* @param {string} [rootClientId=null] Target root client ID.
* @return {boolean} If there is at least one allowed pattern.
const hasAllowedPatterns = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, rootClientId = null) => {
} = unlock(select(STORE_NAME));
const patterns = getAllPatterns();
return patterns.some(pattern => {
} = getParsedPattern(pattern);
return checkAllowListRecursive(blocks, allowedBlockTypes) && blocks.every(({
}) => canInsertBlockType(state, blockName, rootClientId));
}, (state, rootClientId) => [...getAllPatternsDependants(select)(state), ...getInsertBlockTypeDependants(state, rootClientId)]));
function mapUserPattern(userPattern, __experimentalUserPatternCategories = []) {
name: `core/block/${userPattern.id}`,
type: INSERTER_PATTERN_TYPES.user,
title: userPattern.title.raw,
categories: userPattern.wp_pattern_category.map(catId => {
const category = __experimentalUserPatternCategories.find(({
return category ? category.slug : catId;
content: userPattern.content.raw,
syncStatus: userPattern.wp_pattern_sync_status
const getPatternBySlug = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, patternName) => {
var _state$settings$__exp, _state$settings$selec;
// Only fetch reusable blocks if we know we need them. To do: maybe
// use the entity record API to retrieve the block by slug.
if (patternName?.startsWith('core/block/')) {
const _id = parseInt(patternName.slice('core/block/'.length), 10);
const block = unlock(select(STORE_NAME)).getReusableBlocks().find(({
return mapUserPattern(block, state.settings.__experimentalUserPatternCategories);
// This setting is left for back compat.
...((_state$settings$__exp = state.settings.__experimentalBlockPatterns) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : []), ...((_state$settings$selec = state.settings[selectBlockPatternsKey]?.(select)) !== null && _state$settings$selec !== void 0 ? _state$settings$selec : [])].find(({
}) => name === patternName);
}, (state, patternName) => patternName?.startsWith('core/block/') ? [unlock(select(STORE_NAME)).getReusableBlocks(), state.settings.__experimentalReusableBlocks] : [state.settings.__experimentalBlockPatterns, state.settings[selectBlockPatternsKey]?.(select)]));
const getAllPatterns = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
var _state$settings$__exp2, _state$settings$selec2;
return [...unlock(select(STORE_NAME)).getReusableBlocks().map(userPattern => mapUserPattern(userPattern, state.settings.__experimentalUserPatternCategories)),
// This setting is left for back compat.
...((_state$settings$__exp2 = state.settings.__experimentalBlockPatterns) !== null && _state$settings$__exp2 !== void 0 ? _state$settings$__exp2 : []), ...((_state$settings$selec2 = state.settings[selectBlockPatternsKey]?.(select)) !== null && _state$settings$selec2 !== void 0 ? _state$settings$selec2 : [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name));
}, getAllPatternsDependants(select)));
const isResolvingPatterns = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
const blockPatternsSelect = state.settings[selectBlockPatternsKey];
const reusableBlocksSelect = state.settings[reusableBlocksSelectKey];
return (blockPatternsSelect ? blockPatternsSelect(select) === undefined : false) || (reusableBlocksSelect ? reusableBlocksSelect(select) === undefined : false);
}, getAllPatternsDependants(select)));
const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
var _state$settings$__exp3;
const reusableBlocksSelect = state.settings[reusableBlocksSelectKey];
return reusableBlocksSelect ? reusableBlocksSelect(select) : (_state$settings$__exp3 = state.settings.__experimentalReusableBlocks) !== null && _state$settings$__exp3 !== void 0 ? _state$settings$__exp3 : EMPTY_ARRAY;
* Returns the element of the last element that had focus when focus left the editor canvas.
* @param {Object} state Block editor state.
* @return {Object} Element.
function getLastFocus(state) {
* Returns true if the user is dragging anything, or false otherwise. It is possible for a
* user to be dragging data from outside of the editor, so this selector is separate from
* the `isDraggingBlocks` selector which only returns true if the user is dragging blocks.
* @param {Object} state Global application state.
* @return {boolean} Whether user is dragging.
function private_selectors_isDragging(state) {
* Retrieves the expanded block from the state.
* @param {Object} state Block editor state.
* @return {string|null} The client ID of the expanded block, if set.
function getExpandedBlock(state) {
return state.expandedBlock;
* Retrieves the client ID of the ancestor block that is content locking the block
* with the provided client ID.
* @param {Object} state Global application state.
* @param {Object} clientId Client Id of the block.
* @return {?string} Client ID of the ancestor block that is content locking the block.
const getContentLockingParent = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
while (current = state.blocks.parents.get(current)) {
if (getBlockName(state, current) === 'core/block' || getTemplateLock(state, current) === 'contentOnly') {
}, state => [state.blocks.parents, state.blockListSettings]);
* Retrieves the client ID of the block that is content locked but is
* currently being temporarily edited as a non-locked block.
* @param {Object} state Global application state.
* @return {?string} The client ID of the block being temporarily edited as a non-locked block.
function getTemporarilyEditingAsBlocks(state) {
return state.temporarilyEditingAsBlocks;
* Returns the focus mode that should be reapplied when the user stops editing
* a content locked blocks as a block without locking.
* @param {Object} state Global application state.
* @return {?string} The focus mode that should be re-set when temporarily editing as blocks stops.
function getTemporarilyEditingFocusModeToRevert(state) {
return state.temporarilyEditingFocusModeRevert;
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
* A block selection object.
* @typedef {Object} WPBlockSelection
* @property {string} clientId A block client ID.
* @property {string} attributeKey A block attribute key.
* @property {number} offset An attribute value offset, based on the rich
* text value. See `wp.richText.create`.
const MILLISECONDS_PER_HOUR = 3600 * 1000;
const MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
const MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000;
* Shared reference to an empty array for cases where it is important to avoid
* returning a new array reference on every invocation, as in a connected or
* other pure component which performs `shouldComponentUpdate` check on props.
* This should be used as a last resort, since the normalized data should be
* maintained by the reducer result in state.
const selectors_EMPTY_ARRAY = [];
* Shared reference to an empty Set for cases where it is important to avoid
* returning a new Set reference on every invocation, as in a connected or
* other pure component which performs `shouldComponentUpdate` check on props.
* This should be used as a last resort, since the normalized data should be
* maintained by the reducer result in state.
const EMPTY_SET = new Set();
* Returns a block's name given its client ID, or null if no block exists with
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
* @return {string} Block name.
function getBlockName(state, clientId) {
const block = state.blocks.byClientId.get(clientId);
const socialLinkName = 'core/social-link';
if (external_wp_element_namespaceObject.Platform.OS !== 'web' && block?.name === socialLinkName) {
const attributes = state.blocks.attributes.get(clientId);
} = attributes !== null && attributes !== void 0 ? attributes : {};
return service ? `${socialLinkName}-${service}` : socialLinkName;
return block ? block.name : null;
* Returns whether a block is valid or not.
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
* @return {boolean} Is Valid.
function isBlockValid(state, clientId) {
const block = state.blocks.byClientId.get(clientId);
return !!block && block.isValid;
* Returns a block's attributes given its client ID, or null if no block exists with
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
* @return {Object?} Block attributes.
function getBlockAttributes(state, clientId) {
const block = state.blocks.byClientId.get(clientId);
return state.blocks.attributes.get(clientId);
* Returns a block given its client ID. This is a parsed copy of the block,
* containing its `blockName`, `clientId`, and current `attributes` state. This
* is not the block's registration settings, which must be retrieved from the
* blocks module registration store.
* getBlock recurses through its inner blocks until all its children blocks have
* been retrieved. Note that getBlock will not return the child inner blocks of
* an inner block controller. This is because an inner block controller syncs
* itself with its own entity, and should therefore not be included with the
* blocks of a different entity. For example, say you call `getBlocks( TP )` to
* get the blocks of a template part. If another template part is a child of TP,
* then the nested template part's child blocks will not be returned. This way,
* the template block itself is considered part of the parent, but the children
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
* @return {Object} Parsed block object.
function getBlock(state, clientId) {
if (!state.blocks.byClientId.has(clientId)) {
return state.blocks.tree.get(clientId);
const __unstableGetBlockWithoutInnerBlocks = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
const block = state.blocks.byClientId.get(clientId);
attributes: getBlockAttributes(state, clientId)
}, (state, clientId) => [state.blocks.byClientId.get(clientId), state.blocks.attributes.get(clientId)]);
* Returns all block objects for the current post being edited as an array in
* the order they appear in the post. Note that this will exclude child blocks
* of nested inner block controllers.
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
* @return {Object[]} Post blocks.
function getBlocks(state, rootClientId) {
const treeKey = !rootClientId || !areInnerBlocksControlled(state, rootClientId) ? rootClientId || '' : 'controlled||' + rootClientId;
return state.blocks.tree.get(treeKey)?.innerBlocks || selectors_EMPTY_ARRAY;
* Returns a stripped down block object containing only its client ID,
* and its inner blocks' client IDs.
* @param {Object} state Editor state.
* @param {string} clientId Client ID of the block to get.
* @return {Object} Client IDs of the post blocks.
const __unstableGetClientIdWithClientIdsTree = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetClientIdWithClientIdsTree", {
innerBlocks: __unstableGetClientIdsTree(state, clientId)
}, state => [state.blocks.order]);
* Returns the block tree represented in the block-editor store from the
* given root, consisting of stripped down block objects containing only
* their client IDs, and their inner blocks' client IDs.
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
* @return {Object[]} Client IDs of the post blocks.
const __unstableGetClientIdsTree = (0,external_wp_data_namespaceObject.createSelector)((state, rootClientId = '') => {
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetClientIdsTree", {
return getBlockOrder(state, rootClientId).map(clientId => __unstableGetClientIdWithClientIdsTree(state, clientId));
}, state => [state.blocks.order]);
* Returns an array containing the clientIds of all descendants of the blocks
* given. Returned ids are ordered first by the order of the ids given, then
* by the order that they appear in the editor.
* @param {Object} state Global application state.
* @param {string|string[]} rootIds Client ID(s) for which descendant blocks are to be returned.
* @return {Array} Client IDs of descendants.
const getClientIdsOfDescendants = (0,external_wp_data_namespaceObject.createSelector)((state, rootIds) => {
rootIds = Array.isArray(rootIds) ? [...rootIds] : [rootIds];
// Add the descendants of the root blocks first.
for (const rootId of rootIds) {
const order = state.blocks.order.get(rootId);
// Add the descendants of the descendants, recursively.
while (index < ids.length) {
const order = state.blocks.order.get(id);
ids.splice(index + 1, 0, ...order);
}, state => [state.blocks.order]);
* Returns an array containing the clientIds of the top-level blocks and
* their descendants of any depth (for nested blocks). Ids are returned
* in the same order that they appear in the editor.
* @param {Object} state Global application state.
* @return {Array} ids of top-level and descendant blocks.
const getClientIdsWithDescendants = state => getClientIdsOfDescendants(state, '');
* Returns the total number of blocks, or the total number of blocks with a specific name in a post.