Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: block-editor.js
*
[11000] Fix | Delete
* @param {Object} state Global application state.
[11001] Fix | Delete
*
[11002] Fix | Delete
* @return {Array} An array of style ID to style override pairs.
[11003] Fix | Delete
*/
[11004] Fix | Delete
const getStyleOverrides = (0,external_wp_data_namespaceObject.createSelector)(state => {
[11005] Fix | Delete
const clientIds = getClientIdsWithDescendants(state);
[11006] Fix | Delete
const clientIdMap = clientIds.reduce((acc, clientId, index) => {
[11007] Fix | Delete
acc[clientId] = index;
[11008] Fix | Delete
return acc;
[11009] Fix | Delete
}, {});
[11010] Fix | Delete
return [...state.styleOverrides].sort((overrideA, overrideB) => {
[11011] Fix | Delete
var _clientIdMap$clientId, _clientIdMap$clientId2;
[11012] Fix | Delete
// Once the overrides Map is spread to an array, the first element
[11013] Fix | Delete
// is the key, while the second is the override itself including
[11014] Fix | Delete
// the clientId to sort by.
[11015] Fix | Delete
const [, {
[11016] Fix | Delete
clientId: clientIdA
[11017] Fix | Delete
}] = overrideA;
[11018] Fix | Delete
const [, {
[11019] Fix | Delete
clientId: clientIdB
[11020] Fix | Delete
}] = overrideB;
[11021] Fix | Delete
const aIndex = (_clientIdMap$clientId = clientIdMap[clientIdA]) !== null && _clientIdMap$clientId !== void 0 ? _clientIdMap$clientId : -1;
[11022] Fix | Delete
const bIndex = (_clientIdMap$clientId2 = clientIdMap[clientIdB]) !== null && _clientIdMap$clientId2 !== void 0 ? _clientIdMap$clientId2 : -1;
[11023] Fix | Delete
return aIndex - bIndex;
[11024] Fix | Delete
});
[11025] Fix | Delete
}, state => [state.blocks.order, state.styleOverrides]);
[11026] Fix | Delete
[11027] Fix | Delete
/** @typedef {import('./actions').InserterMediaCategory} InserterMediaCategory */
[11028] Fix | Delete
/**
[11029] Fix | Delete
* Returns the registered inserter media categories through the public API.
[11030] Fix | Delete
*
[11031] Fix | Delete
* @param {Object} state Editor state.
[11032] Fix | Delete
*
[11033] Fix | Delete
* @return {InserterMediaCategory[]} Inserter media categories.
[11034] Fix | Delete
*/
[11035] Fix | Delete
function getRegisteredInserterMediaCategories(state) {
[11036] Fix | Delete
return state.registeredInserterMediaCategories;
[11037] Fix | Delete
}
[11038] Fix | Delete
[11039] Fix | Delete
/**
[11040] Fix | Delete
* Returns an array containing the allowed inserter media categories.
[11041] Fix | Delete
* It merges the registered media categories from extenders with the
[11042] Fix | Delete
* core ones. It also takes into account the allowed `mime_types`, which
[11043] Fix | Delete
* can be altered by `upload_mimes` filter and restrict some of them.
[11044] Fix | Delete
*
[11045] Fix | Delete
* @param {Object} state Global application state.
[11046] Fix | Delete
*
[11047] Fix | Delete
* @return {InserterMediaCategory[]} Client IDs of descendants.
[11048] Fix | Delete
*/
[11049] Fix | Delete
const getInserterMediaCategories = (0,external_wp_data_namespaceObject.createSelector)(state => {
[11050] Fix | Delete
const {
[11051] Fix | Delete
settings: {
[11052] Fix | Delete
inserterMediaCategories,
[11053] Fix | Delete
allowedMimeTypes,
[11054] Fix | Delete
enableOpenverseMediaCategory
[11055] Fix | Delete
},
[11056] Fix | Delete
registeredInserterMediaCategories
[11057] Fix | Delete
} = state;
[11058] Fix | Delete
// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict
[11059] Fix | Delete
// some of them. In this case we shouldn't add the category to the available media
[11060] Fix | Delete
// categories list in the inserter.
[11061] Fix | Delete
if (!inserterMediaCategories && !registeredInserterMediaCategories.length || !allowedMimeTypes) {
[11062] Fix | Delete
return;
[11063] Fix | Delete
}
[11064] Fix | Delete
const coreInserterMediaCategoriesNames = inserterMediaCategories?.map(({
[11065] Fix | Delete
name
[11066] Fix | Delete
}) => name) || [];
[11067] Fix | Delete
const mergedCategories = [...(inserterMediaCategories || []), ...(registeredInserterMediaCategories || []).filter(({
[11068] Fix | Delete
name
[11069] Fix | Delete
}) => !coreInserterMediaCategoriesNames.includes(name))];
[11070] Fix | Delete
return mergedCategories.filter(category => {
[11071] Fix | Delete
// Check if Openverse category is enabled.
[11072] Fix | Delete
if (!enableOpenverseMediaCategory && category.name === 'openverse') {
[11073] Fix | Delete
return false;
[11074] Fix | Delete
}
[11075] Fix | Delete
return Object.values(allowedMimeTypes).some(mimeType => mimeType.startsWith(`${category.mediaType}/`));
[11076] Fix | Delete
});
[11077] Fix | Delete
}, state => [state.settings.inserterMediaCategories, state.settings.allowedMimeTypes, state.settings.enableOpenverseMediaCategory, state.registeredInserterMediaCategories]);
[11078] Fix | Delete
[11079] Fix | Delete
/**
[11080] Fix | Delete
* Returns whether there is at least one allowed pattern for inner blocks children.
[11081] Fix | Delete
* This is useful for deferring the parsing of all patterns until needed.
[11082] Fix | Delete
*
[11083] Fix | Delete
* @param {Object} state Editor state.
[11084] Fix | Delete
* @param {string} [rootClientId=null] Target root client ID.
[11085] Fix | Delete
*
[11086] Fix | Delete
* @return {boolean} If there is at least one allowed pattern.
[11087] Fix | Delete
*/
[11088] Fix | Delete
const hasAllowedPatterns = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, rootClientId = null) => {
[11089] Fix | Delete
const {
[11090] Fix | Delete
getAllPatterns
[11091] Fix | Delete
} = unlock(select(STORE_NAME));
[11092] Fix | Delete
const patterns = getAllPatterns();
[11093] Fix | Delete
const {
[11094] Fix | Delete
allowedBlockTypes
[11095] Fix | Delete
} = getSettings(state);
[11096] Fix | Delete
return patterns.some(pattern => {
[11097] Fix | Delete
const {
[11098] Fix | Delete
inserter = true
[11099] Fix | Delete
} = pattern;
[11100] Fix | Delete
if (!inserter) {
[11101] Fix | Delete
return false;
[11102] Fix | Delete
}
[11103] Fix | Delete
const {
[11104] Fix | Delete
blocks
[11105] Fix | Delete
} = getParsedPattern(pattern);
[11106] Fix | Delete
return checkAllowListRecursive(blocks, allowedBlockTypes) && blocks.every(({
[11107] Fix | Delete
name: blockName
[11108] Fix | Delete
}) => canInsertBlockType(state, blockName, rootClientId));
[11109] Fix | Delete
});
[11110] Fix | Delete
}, (state, rootClientId) => [...getAllPatternsDependants(select)(state), ...getInsertBlockTypeDependants(state, rootClientId)]));
[11111] Fix | Delete
function mapUserPattern(userPattern, __experimentalUserPatternCategories = []) {
[11112] Fix | Delete
return {
[11113] Fix | Delete
name: `core/block/${userPattern.id}`,
[11114] Fix | Delete
id: userPattern.id,
[11115] Fix | Delete
type: INSERTER_PATTERN_TYPES.user,
[11116] Fix | Delete
title: userPattern.title.raw,
[11117] Fix | Delete
categories: userPattern.wp_pattern_category.map(catId => {
[11118] Fix | Delete
const category = __experimentalUserPatternCategories.find(({
[11119] Fix | Delete
id
[11120] Fix | Delete
}) => id === catId);
[11121] Fix | Delete
return category ? category.slug : catId;
[11122] Fix | Delete
}),
[11123] Fix | Delete
content: userPattern.content.raw,
[11124] Fix | Delete
syncStatus: userPattern.wp_pattern_sync_status
[11125] Fix | Delete
};
[11126] Fix | Delete
}
[11127] Fix | Delete
const getPatternBySlug = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, patternName) => {
[11128] Fix | Delete
var _state$settings$__exp, _state$settings$selec;
[11129] Fix | Delete
// Only fetch reusable blocks if we know we need them. To do: maybe
[11130] Fix | Delete
// use the entity record API to retrieve the block by slug.
[11131] Fix | Delete
if (patternName?.startsWith('core/block/')) {
[11132] Fix | Delete
const _id = parseInt(patternName.slice('core/block/'.length), 10);
[11133] Fix | Delete
const block = unlock(select(STORE_NAME)).getReusableBlocks().find(({
[11134] Fix | Delete
id
[11135] Fix | Delete
}) => id === _id);
[11136] Fix | Delete
if (!block) {
[11137] Fix | Delete
return null;
[11138] Fix | Delete
}
[11139] Fix | Delete
return mapUserPattern(block, state.settings.__experimentalUserPatternCategories);
[11140] Fix | Delete
}
[11141] Fix | Delete
return [
[11142] Fix | Delete
// This setting is left for back compat.
[11143] Fix | Delete
...((_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(({
[11144] Fix | Delete
name
[11145] Fix | Delete
}) => name === patternName);
[11146] Fix | Delete
}, (state, patternName) => patternName?.startsWith('core/block/') ? [unlock(select(STORE_NAME)).getReusableBlocks(), state.settings.__experimentalReusableBlocks] : [state.settings.__experimentalBlockPatterns, state.settings[selectBlockPatternsKey]?.(select)]));
[11147] Fix | Delete
const getAllPatterns = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
[11148] Fix | Delete
var _state$settings$__exp2, _state$settings$selec2;
[11149] Fix | Delete
return [...unlock(select(STORE_NAME)).getReusableBlocks().map(userPattern => mapUserPattern(userPattern, state.settings.__experimentalUserPatternCategories)),
[11150] Fix | Delete
// This setting is left for back compat.
[11151] Fix | Delete
...((_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));
[11152] Fix | Delete
}, getAllPatternsDependants(select)));
[11153] Fix | Delete
const isResolvingPatterns = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
[11154] Fix | Delete
const blockPatternsSelect = state.settings[selectBlockPatternsKey];
[11155] Fix | Delete
const reusableBlocksSelect = state.settings[reusableBlocksSelectKey];
[11156] Fix | Delete
return (blockPatternsSelect ? blockPatternsSelect(select) === undefined : false) || (reusableBlocksSelect ? reusableBlocksSelect(select) === undefined : false);
[11157] Fix | Delete
}, getAllPatternsDependants(select)));
[11158] Fix | Delete
const EMPTY_ARRAY = [];
[11159] Fix | Delete
const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[11160] Fix | Delete
var _state$settings$__exp3;
[11161] Fix | Delete
const reusableBlocksSelect = state.settings[reusableBlocksSelectKey];
[11162] Fix | Delete
return reusableBlocksSelect ? reusableBlocksSelect(select) : (_state$settings$__exp3 = state.settings.__experimentalReusableBlocks) !== null && _state$settings$__exp3 !== void 0 ? _state$settings$__exp3 : EMPTY_ARRAY;
[11163] Fix | Delete
});
[11164] Fix | Delete
[11165] Fix | Delete
/**
[11166] Fix | Delete
* Returns the element of the last element that had focus when focus left the editor canvas.
[11167] Fix | Delete
*
[11168] Fix | Delete
* @param {Object} state Block editor state.
[11169] Fix | Delete
*
[11170] Fix | Delete
* @return {Object} Element.
[11171] Fix | Delete
*/
[11172] Fix | Delete
function getLastFocus(state) {
[11173] Fix | Delete
return state.lastFocus;
[11174] Fix | Delete
}
[11175] Fix | Delete
[11176] Fix | Delete
/**
[11177] Fix | Delete
* Returns true if the user is dragging anything, or false otherwise. It is possible for a
[11178] Fix | Delete
* user to be dragging data from outside of the editor, so this selector is separate from
[11179] Fix | Delete
* the `isDraggingBlocks` selector which only returns true if the user is dragging blocks.
[11180] Fix | Delete
*
[11181] Fix | Delete
* @param {Object} state Global application state.
[11182] Fix | Delete
*
[11183] Fix | Delete
* @return {boolean} Whether user is dragging.
[11184] Fix | Delete
*/
[11185] Fix | Delete
function private_selectors_isDragging(state) {
[11186] Fix | Delete
return state.isDragging;
[11187] Fix | Delete
}
[11188] Fix | Delete
[11189] Fix | Delete
/**
[11190] Fix | Delete
* Retrieves the expanded block from the state.
[11191] Fix | Delete
*
[11192] Fix | Delete
* @param {Object} state Block editor state.
[11193] Fix | Delete
*
[11194] Fix | Delete
* @return {string|null} The client ID of the expanded block, if set.
[11195] Fix | Delete
*/
[11196] Fix | Delete
function getExpandedBlock(state) {
[11197] Fix | Delete
return state.expandedBlock;
[11198] Fix | Delete
}
[11199] Fix | Delete
[11200] Fix | Delete
/**
[11201] Fix | Delete
* Retrieves the client ID of the ancestor block that is content locking the block
[11202] Fix | Delete
* with the provided client ID.
[11203] Fix | Delete
*
[11204] Fix | Delete
* @param {Object} state Global application state.
[11205] Fix | Delete
* @param {Object} clientId Client Id of the block.
[11206] Fix | Delete
*
[11207] Fix | Delete
* @return {?string} Client ID of the ancestor block that is content locking the block.
[11208] Fix | Delete
*/
[11209] Fix | Delete
const getContentLockingParent = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
[11210] Fix | Delete
let current = clientId;
[11211] Fix | Delete
let result;
[11212] Fix | Delete
while (current = state.blocks.parents.get(current)) {
[11213] Fix | Delete
if (getBlockName(state, current) === 'core/block' || getTemplateLock(state, current) === 'contentOnly') {
[11214] Fix | Delete
result = current;
[11215] Fix | Delete
}
[11216] Fix | Delete
}
[11217] Fix | Delete
return result;
[11218] Fix | Delete
}, state => [state.blocks.parents, state.blockListSettings]);
[11219] Fix | Delete
[11220] Fix | Delete
/**
[11221] Fix | Delete
* Retrieves the client ID of the block that is content locked but is
[11222] Fix | Delete
* currently being temporarily edited as a non-locked block.
[11223] Fix | Delete
*
[11224] Fix | Delete
* @param {Object} state Global application state.
[11225] Fix | Delete
*
[11226] Fix | Delete
* @return {?string} The client ID of the block being temporarily edited as a non-locked block.
[11227] Fix | Delete
*/
[11228] Fix | Delete
function getTemporarilyEditingAsBlocks(state) {
[11229] Fix | Delete
return state.temporarilyEditingAsBlocks;
[11230] Fix | Delete
}
[11231] Fix | Delete
[11232] Fix | Delete
/**
[11233] Fix | Delete
* Returns the focus mode that should be reapplied when the user stops editing
[11234] Fix | Delete
* a content locked blocks as a block without locking.
[11235] Fix | Delete
*
[11236] Fix | Delete
* @param {Object} state Global application state.
[11237] Fix | Delete
*
[11238] Fix | Delete
* @return {?string} The focus mode that should be re-set when temporarily editing as blocks stops.
[11239] Fix | Delete
*/
[11240] Fix | Delete
function getTemporarilyEditingFocusModeToRevert(state) {
[11241] Fix | Delete
return state.temporarilyEditingFocusModeRevert;
[11242] Fix | Delete
}
[11243] Fix | Delete
[11244] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
[11245] Fix | Delete
/**
[11246] Fix | Delete
* WordPress dependencies
[11247] Fix | Delete
*/
[11248] Fix | Delete
[11249] Fix | Delete
[11250] Fix | Delete
[11251] Fix | Delete
[11252] Fix | Delete
[11253] Fix | Delete
[11254] Fix | Delete
[11255] Fix | Delete
[11256] Fix | Delete
/**
[11257] Fix | Delete
* Internal dependencies
[11258] Fix | Delete
*/
[11259] Fix | Delete
[11260] Fix | Delete
[11261] Fix | Delete
[11262] Fix | Delete
[11263] Fix | Delete
[11264] Fix | Delete
[11265] Fix | Delete
/**
[11266] Fix | Delete
* A block selection object.
[11267] Fix | Delete
*
[11268] Fix | Delete
* @typedef {Object} WPBlockSelection
[11269] Fix | Delete
*
[11270] Fix | Delete
* @property {string} clientId A block client ID.
[11271] Fix | Delete
* @property {string} attributeKey A block attribute key.
[11272] Fix | Delete
* @property {number} offset An attribute value offset, based on the rich
[11273] Fix | Delete
* text value. See `wp.richText.create`.
[11274] Fix | Delete
*/
[11275] Fix | Delete
[11276] Fix | Delete
// Module constants.
[11277] Fix | Delete
const MILLISECONDS_PER_HOUR = 3600 * 1000;
[11278] Fix | Delete
const MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
[11279] Fix | Delete
const MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000;
[11280] Fix | Delete
[11281] Fix | Delete
/**
[11282] Fix | Delete
* Shared reference to an empty array for cases where it is important to avoid
[11283] Fix | Delete
* returning a new array reference on every invocation, as in a connected or
[11284] Fix | Delete
* other pure component which performs `shouldComponentUpdate` check on props.
[11285] Fix | Delete
* This should be used as a last resort, since the normalized data should be
[11286] Fix | Delete
* maintained by the reducer result in state.
[11287] Fix | Delete
*
[11288] Fix | Delete
* @type {Array}
[11289] Fix | Delete
*/
[11290] Fix | Delete
const selectors_EMPTY_ARRAY = [];
[11291] Fix | Delete
[11292] Fix | Delete
/**
[11293] Fix | Delete
* Shared reference to an empty Set for cases where it is important to avoid
[11294] Fix | Delete
* returning a new Set reference on every invocation, as in a connected or
[11295] Fix | Delete
* other pure component which performs `shouldComponentUpdate` check on props.
[11296] Fix | Delete
* This should be used as a last resort, since the normalized data should be
[11297] Fix | Delete
* maintained by the reducer result in state.
[11298] Fix | Delete
*
[11299] Fix | Delete
* @type {Set}
[11300] Fix | Delete
*/
[11301] Fix | Delete
const EMPTY_SET = new Set();
[11302] Fix | Delete
const EMPTY_OBJECT = {};
[11303] Fix | Delete
[11304] Fix | Delete
/**
[11305] Fix | Delete
* Returns a block's name given its client ID, or null if no block exists with
[11306] Fix | Delete
* the client ID.
[11307] Fix | Delete
*
[11308] Fix | Delete
* @param {Object} state Editor state.
[11309] Fix | Delete
* @param {string} clientId Block client ID.
[11310] Fix | Delete
*
[11311] Fix | Delete
* @return {string} Block name.
[11312] Fix | Delete
*/
[11313] Fix | Delete
function getBlockName(state, clientId) {
[11314] Fix | Delete
const block = state.blocks.byClientId.get(clientId);
[11315] Fix | Delete
const socialLinkName = 'core/social-link';
[11316] Fix | Delete
if (external_wp_element_namespaceObject.Platform.OS !== 'web' && block?.name === socialLinkName) {
[11317] Fix | Delete
const attributes = state.blocks.attributes.get(clientId);
[11318] Fix | Delete
const {
[11319] Fix | Delete
service
[11320] Fix | Delete
} = attributes !== null && attributes !== void 0 ? attributes : {};
[11321] Fix | Delete
return service ? `${socialLinkName}-${service}` : socialLinkName;
[11322] Fix | Delete
}
[11323] Fix | Delete
return block ? block.name : null;
[11324] Fix | Delete
}
[11325] Fix | Delete
[11326] Fix | Delete
/**
[11327] Fix | Delete
* Returns whether a block is valid or not.
[11328] Fix | Delete
*
[11329] Fix | Delete
* @param {Object} state Editor state.
[11330] Fix | Delete
* @param {string} clientId Block client ID.
[11331] Fix | Delete
*
[11332] Fix | Delete
* @return {boolean} Is Valid.
[11333] Fix | Delete
*/
[11334] Fix | Delete
function isBlockValid(state, clientId) {
[11335] Fix | Delete
const block = state.blocks.byClientId.get(clientId);
[11336] Fix | Delete
return !!block && block.isValid;
[11337] Fix | Delete
}
[11338] Fix | Delete
[11339] Fix | Delete
/**
[11340] Fix | Delete
* Returns a block's attributes given its client ID, or null if no block exists with
[11341] Fix | Delete
* the client ID.
[11342] Fix | Delete
*
[11343] Fix | Delete
* @param {Object} state Editor state.
[11344] Fix | Delete
* @param {string} clientId Block client ID.
[11345] Fix | Delete
*
[11346] Fix | Delete
* @return {Object?} Block attributes.
[11347] Fix | Delete
*/
[11348] Fix | Delete
function getBlockAttributes(state, clientId) {
[11349] Fix | Delete
const block = state.blocks.byClientId.get(clientId);
[11350] Fix | Delete
if (!block) {
[11351] Fix | Delete
return null;
[11352] Fix | Delete
}
[11353] Fix | Delete
return state.blocks.attributes.get(clientId);
[11354] Fix | Delete
}
[11355] Fix | Delete
[11356] Fix | Delete
/**
[11357] Fix | Delete
* Returns a block given its client ID. This is a parsed copy of the block,
[11358] Fix | Delete
* containing its `blockName`, `clientId`, and current `attributes` state. This
[11359] Fix | Delete
* is not the block's registration settings, which must be retrieved from the
[11360] Fix | Delete
* blocks module registration store.
[11361] Fix | Delete
*
[11362] Fix | Delete
* getBlock recurses through its inner blocks until all its children blocks have
[11363] Fix | Delete
* been retrieved. Note that getBlock will not return the child inner blocks of
[11364] Fix | Delete
* an inner block controller. This is because an inner block controller syncs
[11365] Fix | Delete
* itself with its own entity, and should therefore not be included with the
[11366] Fix | Delete
* blocks of a different entity. For example, say you call `getBlocks( TP )` to
[11367] Fix | Delete
* get the blocks of a template part. If another template part is a child of TP,
[11368] Fix | Delete
* then the nested template part's child blocks will not be returned. This way,
[11369] Fix | Delete
* the template block itself is considered part of the parent, but the children
[11370] Fix | Delete
* are not.
[11371] Fix | Delete
*
[11372] Fix | Delete
* @param {Object} state Editor state.
[11373] Fix | Delete
* @param {string} clientId Block client ID.
[11374] Fix | Delete
*
[11375] Fix | Delete
* @return {Object} Parsed block object.
[11376] Fix | Delete
*/
[11377] Fix | Delete
function getBlock(state, clientId) {
[11378] Fix | Delete
if (!state.blocks.byClientId.has(clientId)) {
[11379] Fix | Delete
return null;
[11380] Fix | Delete
}
[11381] Fix | Delete
return state.blocks.tree.get(clientId);
[11382] Fix | Delete
}
[11383] Fix | Delete
const __unstableGetBlockWithoutInnerBlocks = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
[11384] Fix | Delete
const block = state.blocks.byClientId.get(clientId);
[11385] Fix | Delete
if (!block) {
[11386] Fix | Delete
return null;
[11387] Fix | Delete
}
[11388] Fix | Delete
return {
[11389] Fix | Delete
...block,
[11390] Fix | Delete
attributes: getBlockAttributes(state, clientId)
[11391] Fix | Delete
};
[11392] Fix | Delete
}, (state, clientId) => [state.blocks.byClientId.get(clientId), state.blocks.attributes.get(clientId)]);
[11393] Fix | Delete
[11394] Fix | Delete
/**
[11395] Fix | Delete
* Returns all block objects for the current post being edited as an array in
[11396] Fix | Delete
* the order they appear in the post. Note that this will exclude child blocks
[11397] Fix | Delete
* of nested inner block controllers.
[11398] Fix | Delete
*
[11399] Fix | Delete
* @param {Object} state Editor state.
[11400] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list.
[11401] Fix | Delete
*
[11402] Fix | Delete
* @return {Object[]} Post blocks.
[11403] Fix | Delete
*/
[11404] Fix | Delete
function getBlocks(state, rootClientId) {
[11405] Fix | Delete
const treeKey = !rootClientId || !areInnerBlocksControlled(state, rootClientId) ? rootClientId || '' : 'controlled||' + rootClientId;
[11406] Fix | Delete
return state.blocks.tree.get(treeKey)?.innerBlocks || selectors_EMPTY_ARRAY;
[11407] Fix | Delete
}
[11408] Fix | Delete
[11409] Fix | Delete
/**
[11410] Fix | Delete
* Returns a stripped down block object containing only its client ID,
[11411] Fix | Delete
* and its inner blocks' client IDs.
[11412] Fix | Delete
*
[11413] Fix | Delete
* @deprecated
[11414] Fix | Delete
*
[11415] Fix | Delete
* @param {Object} state Editor state.
[11416] Fix | Delete
* @param {string} clientId Client ID of the block to get.
[11417] Fix | Delete
*
[11418] Fix | Delete
* @return {Object} Client IDs of the post blocks.
[11419] Fix | Delete
*/
[11420] Fix | Delete
const __unstableGetClientIdWithClientIdsTree = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
[11421] Fix | Delete
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetClientIdWithClientIdsTree", {
[11422] Fix | Delete
since: '6.3',
[11423] Fix | Delete
version: '6.5'
[11424] Fix | Delete
});
[11425] Fix | Delete
return {
[11426] Fix | Delete
clientId,
[11427] Fix | Delete
innerBlocks: __unstableGetClientIdsTree(state, clientId)
[11428] Fix | Delete
};
[11429] Fix | Delete
}, state => [state.blocks.order]);
[11430] Fix | Delete
[11431] Fix | Delete
/**
[11432] Fix | Delete
* Returns the block tree represented in the block-editor store from the
[11433] Fix | Delete
* given root, consisting of stripped down block objects containing only
[11434] Fix | Delete
* their client IDs, and their inner blocks' client IDs.
[11435] Fix | Delete
*
[11436] Fix | Delete
* @deprecated
[11437] Fix | Delete
*
[11438] Fix | Delete
* @param {Object} state Editor state.
[11439] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list.
[11440] Fix | Delete
*
[11441] Fix | Delete
* @return {Object[]} Client IDs of the post blocks.
[11442] Fix | Delete
*/
[11443] Fix | Delete
const __unstableGetClientIdsTree = (0,external_wp_data_namespaceObject.createSelector)((state, rootClientId = '') => {
[11444] Fix | Delete
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetClientIdsTree", {
[11445] Fix | Delete
since: '6.3',
[11446] Fix | Delete
version: '6.5'
[11447] Fix | Delete
});
[11448] Fix | Delete
return getBlockOrder(state, rootClientId).map(clientId => __unstableGetClientIdWithClientIdsTree(state, clientId));
[11449] Fix | Delete
}, state => [state.blocks.order]);
[11450] Fix | Delete
[11451] Fix | Delete
/**
[11452] Fix | Delete
* Returns an array containing the clientIds of all descendants of the blocks
[11453] Fix | Delete
* given. Returned ids are ordered first by the order of the ids given, then
[11454] Fix | Delete
* by the order that they appear in the editor.
[11455] Fix | Delete
*
[11456] Fix | Delete
* @param {Object} state Global application state.
[11457] Fix | Delete
* @param {string|string[]} rootIds Client ID(s) for which descendant blocks are to be returned.
[11458] Fix | Delete
*
[11459] Fix | Delete
* @return {Array} Client IDs of descendants.
[11460] Fix | Delete
*/
[11461] Fix | Delete
const getClientIdsOfDescendants = (0,external_wp_data_namespaceObject.createSelector)((state, rootIds) => {
[11462] Fix | Delete
rootIds = Array.isArray(rootIds) ? [...rootIds] : [rootIds];
[11463] Fix | Delete
const ids = [];
[11464] Fix | Delete
[11465] Fix | Delete
// Add the descendants of the root blocks first.
[11466] Fix | Delete
for (const rootId of rootIds) {
[11467] Fix | Delete
const order = state.blocks.order.get(rootId);
[11468] Fix | Delete
if (order) {
[11469] Fix | Delete
ids.push(...order);
[11470] Fix | Delete
}
[11471] Fix | Delete
}
[11472] Fix | Delete
let index = 0;
[11473] Fix | Delete
[11474] Fix | Delete
// Add the descendants of the descendants, recursively.
[11475] Fix | Delete
while (index < ids.length) {
[11476] Fix | Delete
const id = ids[index];
[11477] Fix | Delete
const order = state.blocks.order.get(id);
[11478] Fix | Delete
if (order) {
[11479] Fix | Delete
ids.splice(index + 1, 0, ...order);
[11480] Fix | Delete
}
[11481] Fix | Delete
index++;
[11482] Fix | Delete
}
[11483] Fix | Delete
return ids;
[11484] Fix | Delete
}, state => [state.blocks.order]);
[11485] Fix | Delete
[11486] Fix | Delete
/**
[11487] Fix | Delete
* Returns an array containing the clientIds of the top-level blocks and
[11488] Fix | Delete
* their descendants of any depth (for nested blocks). Ids are returned
[11489] Fix | Delete
* in the same order that they appear in the editor.
[11490] Fix | Delete
*
[11491] Fix | Delete
* @param {Object} state Global application state.
[11492] Fix | Delete
*
[11493] Fix | Delete
* @return {Array} ids of top-level and descendant blocks.
[11494] Fix | Delete
*/
[11495] Fix | Delete
const getClientIdsWithDescendants = state => getClientIdsOfDescendants(state, '');
[11496] Fix | Delete
[11497] Fix | Delete
/**
[11498] Fix | Delete
* Returns the total number of blocks, or the total number of blocks with a specific name in a post.
[11499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function