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
* The number returned includes nested blocks.
[11500] Fix | Delete
*
[11501] Fix | Delete
* @param {Object} state Global application state.
[11502] Fix | Delete
* @param {?string} blockName Optional block name, if specified only blocks of that type will be counted.
[11503] Fix | Delete
*
[11504] Fix | Delete
* @return {number} Number of blocks in the post, or number of blocks with name equal to blockName.
[11505] Fix | Delete
*/
[11506] Fix | Delete
const getGlobalBlockCount = (0,external_wp_data_namespaceObject.createSelector)((state, blockName) => {
[11507] Fix | Delete
const clientIds = getClientIdsWithDescendants(state);
[11508] Fix | Delete
if (!blockName) {
[11509] Fix | Delete
return clientIds.length;
[11510] Fix | Delete
}
[11511] Fix | Delete
let count = 0;
[11512] Fix | Delete
for (const clientId of clientIds) {
[11513] Fix | Delete
const block = state.blocks.byClientId.get(clientId);
[11514] Fix | Delete
if (block.name === blockName) {
[11515] Fix | Delete
count++;
[11516] Fix | Delete
}
[11517] Fix | Delete
}
[11518] Fix | Delete
return count;
[11519] Fix | Delete
}, state => [state.blocks.order, state.blocks.byClientId]);
[11520] Fix | Delete
[11521] Fix | Delete
/**
[11522] Fix | Delete
* Returns all blocks that match a blockName. Results include nested blocks.
[11523] Fix | Delete
*
[11524] Fix | Delete
* @param {Object} state Global application state.
[11525] Fix | Delete
* @param {?string} blockName Optional block name, if not specified, returns an empty array.
[11526] Fix | Delete
*
[11527] Fix | Delete
* @return {Array} Array of clientIds of blocks with name equal to blockName.
[11528] Fix | Delete
*/
[11529] Fix | Delete
const getBlocksByName = (0,external_wp_data_namespaceObject.createSelector)((state, blockName) => {
[11530] Fix | Delete
if (!blockName) {
[11531] Fix | Delete
return selectors_EMPTY_ARRAY;
[11532] Fix | Delete
}
[11533] Fix | Delete
const blockNames = Array.isArray(blockName) ? blockName : [blockName];
[11534] Fix | Delete
const clientIds = getClientIdsWithDescendants(state);
[11535] Fix | Delete
const foundBlocks = clientIds.filter(clientId => {
[11536] Fix | Delete
const block = state.blocks.byClientId.get(clientId);
[11537] Fix | Delete
return blockNames.includes(block.name);
[11538] Fix | Delete
});
[11539] Fix | Delete
return foundBlocks.length > 0 ? foundBlocks : selectors_EMPTY_ARRAY;
[11540] Fix | Delete
}, state => [state.blocks.order, state.blocks.byClientId]);
[11541] Fix | Delete
[11542] Fix | Delete
/**
[11543] Fix | Delete
* Returns all global blocks that match a blockName. Results include nested blocks.
[11544] Fix | Delete
*
[11545] Fix | Delete
* @deprecated
[11546] Fix | Delete
*
[11547] Fix | Delete
* @param {Object} state Global application state.
[11548] Fix | Delete
* @param {?string} blockName Optional block name, if not specified, returns an empty array.
[11549] Fix | Delete
*
[11550] Fix | Delete
* @return {Array} Array of clientIds of blocks with name equal to blockName.
[11551] Fix | Delete
*/
[11552] Fix | Delete
function __experimentalGetGlobalBlocksByName(state, blockName) {
[11553] Fix | Delete
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__experimentalGetGlobalBlocksByName", {
[11554] Fix | Delete
since: '6.5',
[11555] Fix | Delete
alternative: `wp.data.select( 'core/block-editor' ).getBlocksByName`
[11556] Fix | Delete
});
[11557] Fix | Delete
return getBlocksByName(state, blockName);
[11558] Fix | Delete
}
[11559] Fix | Delete
[11560] Fix | Delete
/**
[11561] Fix | Delete
* Given an array of block client IDs, returns the corresponding array of block
[11562] Fix | Delete
* objects.
[11563] Fix | Delete
*
[11564] Fix | Delete
* @param {Object} state Editor state.
[11565] Fix | Delete
* @param {string[]} clientIds Client IDs for which blocks are to be returned.
[11566] Fix | Delete
*
[11567] Fix | Delete
* @return {WPBlock[]} Block objects.
[11568] Fix | Delete
*/
[11569] Fix | Delete
const getBlocksByClientId = (0,external_wp_data_namespaceObject.createSelector)((state, clientIds) => (Array.isArray(clientIds) ? clientIds : [clientIds]).map(clientId => getBlock(state, clientId)), (state, clientIds) => (Array.isArray(clientIds) ? clientIds : [clientIds]).map(clientId => state.blocks.tree.get(clientId)));
[11570] Fix | Delete
[11571] Fix | Delete
/**
[11572] Fix | Delete
* Given an array of block client IDs, returns the corresponding array of block
[11573] Fix | Delete
* names.
[11574] Fix | Delete
*
[11575] Fix | Delete
* @param {Object} state Editor state.
[11576] Fix | Delete
* @param {string[]} clientIds Client IDs for which block names are to be returned.
[11577] Fix | Delete
*
[11578] Fix | Delete
* @return {string[]} Block names.
[11579] Fix | Delete
*/
[11580] Fix | Delete
const getBlockNamesByClientId = (0,external_wp_data_namespaceObject.createSelector)((state, clientIds) => getBlocksByClientId(state, clientIds).filter(Boolean).map(block => block.name), (state, clientIds) => getBlocksByClientId(state, clientIds));
[11581] Fix | Delete
[11582] Fix | Delete
/**
[11583] Fix | Delete
* Returns the number of blocks currently present in the post.
[11584] Fix | Delete
*
[11585] Fix | Delete
* @param {Object} state Editor state.
[11586] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list.
[11587] Fix | Delete
*
[11588] Fix | Delete
* @return {number} Number of blocks in the post.
[11589] Fix | Delete
*/
[11590] Fix | Delete
function getBlockCount(state, rootClientId) {
[11591] Fix | Delete
return getBlockOrder(state, rootClientId).length;
[11592] Fix | Delete
}
[11593] Fix | Delete
[11594] Fix | Delete
/**
[11595] Fix | Delete
* Returns the current selection start block client ID, attribute key and text
[11596] Fix | Delete
* offset.
[11597] Fix | Delete
*
[11598] Fix | Delete
* @param {Object} state Block editor state.
[11599] Fix | Delete
*
[11600] Fix | Delete
* @return {WPBlockSelection} Selection start information.
[11601] Fix | Delete
*/
[11602] Fix | Delete
function getSelectionStart(state) {
[11603] Fix | Delete
return state.selection.selectionStart;
[11604] Fix | Delete
}
[11605] Fix | Delete
[11606] Fix | Delete
/**
[11607] Fix | Delete
* Returns the current selection end block client ID, attribute key and text
[11608] Fix | Delete
* offset.
[11609] Fix | Delete
*
[11610] Fix | Delete
* @param {Object} state Block editor state.
[11611] Fix | Delete
*
[11612] Fix | Delete
* @return {WPBlockSelection} Selection end information.
[11613] Fix | Delete
*/
[11614] Fix | Delete
function getSelectionEnd(state) {
[11615] Fix | Delete
return state.selection.selectionEnd;
[11616] Fix | Delete
}
[11617] Fix | Delete
[11618] Fix | Delete
/**
[11619] Fix | Delete
* Returns the current block selection start. This value may be null, and it
[11620] Fix | Delete
* may represent either a singular block selection or multi-selection start.
[11621] Fix | Delete
* A selection is singular if its start and end match.
[11622] Fix | Delete
*
[11623] Fix | Delete
* @param {Object} state Global application state.
[11624] Fix | Delete
*
[11625] Fix | Delete
* @return {?string} Client ID of block selection start.
[11626] Fix | Delete
*/
[11627] Fix | Delete
function getBlockSelectionStart(state) {
[11628] Fix | Delete
return state.selection.selectionStart.clientId;
[11629] Fix | Delete
}
[11630] Fix | Delete
[11631] Fix | Delete
/**
[11632] Fix | Delete
* Returns the current block selection end. This value may be null, and it
[11633] Fix | Delete
* may represent either a singular block selection or multi-selection end.
[11634] Fix | Delete
* A selection is singular if its start and end match.
[11635] Fix | Delete
*
[11636] Fix | Delete
* @param {Object} state Global application state.
[11637] Fix | Delete
*
[11638] Fix | Delete
* @return {?string} Client ID of block selection end.
[11639] Fix | Delete
*/
[11640] Fix | Delete
function getBlockSelectionEnd(state) {
[11641] Fix | Delete
return state.selection.selectionEnd.clientId;
[11642] Fix | Delete
}
[11643] Fix | Delete
[11644] Fix | Delete
/**
[11645] Fix | Delete
* Returns the number of blocks currently selected in the post.
[11646] Fix | Delete
*
[11647] Fix | Delete
* @param {Object} state Global application state.
[11648] Fix | Delete
*
[11649] Fix | Delete
* @return {number} Number of blocks selected in the post.
[11650] Fix | Delete
*/
[11651] Fix | Delete
function getSelectedBlockCount(state) {
[11652] Fix | Delete
const multiSelectedBlockCount = getMultiSelectedBlockClientIds(state).length;
[11653] Fix | Delete
if (multiSelectedBlockCount) {
[11654] Fix | Delete
return multiSelectedBlockCount;
[11655] Fix | Delete
}
[11656] Fix | Delete
return state.selection.selectionStart.clientId ? 1 : 0;
[11657] Fix | Delete
}
[11658] Fix | Delete
[11659] Fix | Delete
/**
[11660] Fix | Delete
* Returns true if there is a single selected block, or false otherwise.
[11661] Fix | Delete
*
[11662] Fix | Delete
* @param {Object} state Editor state.
[11663] Fix | Delete
*
[11664] Fix | Delete
* @return {boolean} Whether a single block is selected.
[11665] Fix | Delete
*/
[11666] Fix | Delete
function hasSelectedBlock(state) {
[11667] Fix | Delete
const {
[11668] Fix | Delete
selectionStart,
[11669] Fix | Delete
selectionEnd
[11670] Fix | Delete
} = state.selection;
[11671] Fix | Delete
return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId;
[11672] Fix | Delete
}
[11673] Fix | Delete
[11674] Fix | Delete
/**
[11675] Fix | Delete
* Returns the currently selected block client ID, or null if there is no
[11676] Fix | Delete
* selected block.
[11677] Fix | Delete
*
[11678] Fix | Delete
* @param {Object} state Editor state.
[11679] Fix | Delete
*
[11680] Fix | Delete
* @return {?string} Selected block client ID.
[11681] Fix | Delete
*/
[11682] Fix | Delete
function getSelectedBlockClientId(state) {
[11683] Fix | Delete
const {
[11684] Fix | Delete
selectionStart,
[11685] Fix | Delete
selectionEnd
[11686] Fix | Delete
} = state.selection;
[11687] Fix | Delete
const {
[11688] Fix | Delete
clientId
[11689] Fix | Delete
} = selectionStart;
[11690] Fix | Delete
if (!clientId || clientId !== selectionEnd.clientId) {
[11691] Fix | Delete
return null;
[11692] Fix | Delete
}
[11693] Fix | Delete
return clientId;
[11694] Fix | Delete
}
[11695] Fix | Delete
[11696] Fix | Delete
/**
[11697] Fix | Delete
* Returns the currently selected block, or null if there is no selected block.
[11698] Fix | Delete
*
[11699] Fix | Delete
* @param {Object} state Global application state.
[11700] Fix | Delete
*
[11701] Fix | Delete
* @return {?Object} Selected block.
[11702] Fix | Delete
*/
[11703] Fix | Delete
function getSelectedBlock(state) {
[11704] Fix | Delete
const clientId = getSelectedBlockClientId(state);
[11705] Fix | Delete
return clientId ? getBlock(state, clientId) : null;
[11706] Fix | Delete
}
[11707] Fix | Delete
[11708] Fix | Delete
/**
[11709] Fix | Delete
* Given a block client ID, returns the root block from which the block is
[11710] Fix | Delete
* nested, an empty string for top-level blocks, or null if the block does not
[11711] Fix | Delete
* exist.
[11712] Fix | Delete
*
[11713] Fix | Delete
* @param {Object} state Editor state.
[11714] Fix | Delete
* @param {string} clientId Block from which to find root client ID.
[11715] Fix | Delete
*
[11716] Fix | Delete
* @return {?string} Root client ID, if exists
[11717] Fix | Delete
*/
[11718] Fix | Delete
function getBlockRootClientId(state, clientId) {
[11719] Fix | Delete
var _state$blocks$parents;
[11720] Fix | Delete
return (_state$blocks$parents = state.blocks.parents.get(clientId)) !== null && _state$blocks$parents !== void 0 ? _state$blocks$parents : null;
[11721] Fix | Delete
}
[11722] Fix | Delete
[11723] Fix | Delete
/**
[11724] Fix | Delete
* Given a block client ID, returns the list of all its parents from top to bottom.
[11725] Fix | Delete
*
[11726] Fix | Delete
* @param {Object} state Editor state.
[11727] Fix | Delete
* @param {string} clientId Block from which to find root client ID.
[11728] Fix | Delete
* @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
[11729] Fix | Delete
*
[11730] Fix | Delete
* @return {Array} ClientIDs of the parent blocks.
[11731] Fix | Delete
*/
[11732] Fix | Delete
const getBlockParents = (0,external_wp_data_namespaceObject.createSelector)((state, clientId, ascending = false) => {
[11733] Fix | Delete
const parents = [];
[11734] Fix | Delete
let current = clientId;
[11735] Fix | Delete
while (current = state.blocks.parents.get(current)) {
[11736] Fix | Delete
parents.push(current);
[11737] Fix | Delete
}
[11738] Fix | Delete
if (!parents.length) {
[11739] Fix | Delete
return selectors_EMPTY_ARRAY;
[11740] Fix | Delete
}
[11741] Fix | Delete
return ascending ? parents : parents.reverse();
[11742] Fix | Delete
}, state => [state.blocks.parents]);
[11743] Fix | Delete
[11744] Fix | Delete
/**
[11745] Fix | Delete
* Given a block client ID and a block name, returns the list of all its parents
[11746] Fix | Delete
* from top to bottom, filtered by the given name(s). For example, if passed
[11747] Fix | Delete
* 'core/group' as the blockName, it will only return parents which are group
[11748] Fix | Delete
* blocks. If passed `[ 'core/group', 'core/cover']`, as the blockName, it will
[11749] Fix | Delete
* return parents which are group blocks and parents which are cover blocks.
[11750] Fix | Delete
*
[11751] Fix | Delete
* @param {Object} state Editor state.
[11752] Fix | Delete
* @param {string} clientId Block from which to find root client ID.
[11753] Fix | Delete
* @param {string|string[]} blockName Block name(s) to filter.
[11754] Fix | Delete
* @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
[11755] Fix | Delete
*
[11756] Fix | Delete
* @return {Array} ClientIDs of the parent blocks.
[11757] Fix | Delete
*/
[11758] Fix | Delete
const getBlockParentsByBlockName = (0,external_wp_data_namespaceObject.createSelector)((state, clientId, blockName, ascending = false) => {
[11759] Fix | Delete
const parents = getBlockParents(state, clientId, ascending);
[11760] Fix | Delete
const hasName = Array.isArray(blockName) ? name => blockName.includes(name) : name => blockName === name;
[11761] Fix | Delete
return parents.filter(id => hasName(getBlockName(state, id)));
[11762] Fix | Delete
}, state => [state.blocks.parents]);
[11763] Fix | Delete
/**
[11764] Fix | Delete
* Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks.
[11765] Fix | Delete
*
[11766] Fix | Delete
* @param {Object} state Editor state.
[11767] Fix | Delete
* @param {string} clientId Block from which to find root client ID.
[11768] Fix | Delete
*
[11769] Fix | Delete
* @return {string} Root client ID
[11770] Fix | Delete
*/
[11771] Fix | Delete
function getBlockHierarchyRootClientId(state, clientId) {
[11772] Fix | Delete
let current = clientId;
[11773] Fix | Delete
let parent;
[11774] Fix | Delete
do {
[11775] Fix | Delete
parent = current;
[11776] Fix | Delete
current = state.blocks.parents.get(current);
[11777] Fix | Delete
} while (current);
[11778] Fix | Delete
return parent;
[11779] Fix | Delete
}
[11780] Fix | Delete
[11781] Fix | Delete
/**
[11782] Fix | Delete
* Given a block client ID, returns the lowest common ancestor with selected client ID.
[11783] Fix | Delete
*
[11784] Fix | Delete
* @param {Object} state Editor state.
[11785] Fix | Delete
* @param {string} clientId Block from which to find common ancestor client ID.
[11786] Fix | Delete
*
[11787] Fix | Delete
* @return {string} Common ancestor client ID or undefined
[11788] Fix | Delete
*/
[11789] Fix | Delete
function getLowestCommonAncestorWithSelectedBlock(state, clientId) {
[11790] Fix | Delete
const selectedId = getSelectedBlockClientId(state);
[11791] Fix | Delete
const clientParents = [...getBlockParents(state, clientId), clientId];
[11792] Fix | Delete
const selectedParents = [...getBlockParents(state, selectedId), selectedId];
[11793] Fix | Delete
let lowestCommonAncestor;
[11794] Fix | Delete
const maxDepth = Math.min(clientParents.length, selectedParents.length);
[11795] Fix | Delete
for (let index = 0; index < maxDepth; index++) {
[11796] Fix | Delete
if (clientParents[index] === selectedParents[index]) {
[11797] Fix | Delete
lowestCommonAncestor = clientParents[index];
[11798] Fix | Delete
} else {
[11799] Fix | Delete
break;
[11800] Fix | Delete
}
[11801] Fix | Delete
}
[11802] Fix | Delete
return lowestCommonAncestor;
[11803] Fix | Delete
}
[11804] Fix | Delete
[11805] Fix | Delete
/**
[11806] Fix | Delete
* Returns the client ID of the block adjacent one at the given reference
[11807] Fix | Delete
* startClientId and modifier directionality. Defaults start startClientId to
[11808] Fix | Delete
* the selected block, and direction as next block. Returns null if there is no
[11809] Fix | Delete
* adjacent block.
[11810] Fix | Delete
*
[11811] Fix | Delete
* @param {Object} state Editor state.
[11812] Fix | Delete
* @param {?string} startClientId Optional client ID of block from which to
[11813] Fix | Delete
* search.
[11814] Fix | Delete
* @param {?number} modifier Directionality multiplier (1 next, -1
[11815] Fix | Delete
* previous).
[11816] Fix | Delete
*
[11817] Fix | Delete
* @return {?string} Return the client ID of the block, or null if none exists.
[11818] Fix | Delete
*/
[11819] Fix | Delete
function getAdjacentBlockClientId(state, startClientId, modifier = 1) {
[11820] Fix | Delete
// Default to selected block.
[11821] Fix | Delete
if (startClientId === undefined) {
[11822] Fix | Delete
startClientId = getSelectedBlockClientId(state);
[11823] Fix | Delete
}
[11824] Fix | Delete
[11825] Fix | Delete
// Try multi-selection starting at extent based on modifier.
[11826] Fix | Delete
if (startClientId === undefined) {
[11827] Fix | Delete
if (modifier < 0) {
[11828] Fix | Delete
startClientId = getFirstMultiSelectedBlockClientId(state);
[11829] Fix | Delete
} else {
[11830] Fix | Delete
startClientId = getLastMultiSelectedBlockClientId(state);
[11831] Fix | Delete
}
[11832] Fix | Delete
}
[11833] Fix | Delete
[11834] Fix | Delete
// Validate working start client ID.
[11835] Fix | Delete
if (!startClientId) {
[11836] Fix | Delete
return null;
[11837] Fix | Delete
}
[11838] Fix | Delete
[11839] Fix | Delete
// Retrieve start block root client ID, being careful to allow the falsey
[11840] Fix | Delete
// empty string top-level root by explicitly testing against null.
[11841] Fix | Delete
const rootClientId = getBlockRootClientId(state, startClientId);
[11842] Fix | Delete
if (rootClientId === null) {
[11843] Fix | Delete
return null;
[11844] Fix | Delete
}
[11845] Fix | Delete
const {
[11846] Fix | Delete
order
[11847] Fix | Delete
} = state.blocks;
[11848] Fix | Delete
const orderSet = order.get(rootClientId);
[11849] Fix | Delete
const index = orderSet.indexOf(startClientId);
[11850] Fix | Delete
const nextIndex = index + 1 * modifier;
[11851] Fix | Delete
[11852] Fix | Delete
// Block was first in set and we're attempting to get previous.
[11853] Fix | Delete
if (nextIndex < 0) {
[11854] Fix | Delete
return null;
[11855] Fix | Delete
}
[11856] Fix | Delete
[11857] Fix | Delete
// Block was last in set and we're attempting to get next.
[11858] Fix | Delete
if (nextIndex === orderSet.length) {
[11859] Fix | Delete
return null;
[11860] Fix | Delete
}
[11861] Fix | Delete
[11862] Fix | Delete
// Assume incremented index is within the set.
[11863] Fix | Delete
return orderSet[nextIndex];
[11864] Fix | Delete
}
[11865] Fix | Delete
[11866] Fix | Delete
/**
[11867] Fix | Delete
* Returns the previous block's client ID from the given reference start ID.
[11868] Fix | Delete
* Defaults start to the selected block. Returns null if there is no previous
[11869] Fix | Delete
* block.
[11870] Fix | Delete
*
[11871] Fix | Delete
* @param {Object} state Editor state.
[11872] Fix | Delete
* @param {?string} startClientId Optional client ID of block from which to
[11873] Fix | Delete
* search.
[11874] Fix | Delete
*
[11875] Fix | Delete
* @return {?string} Adjacent block's client ID, or null if none exists.
[11876] Fix | Delete
*/
[11877] Fix | Delete
function getPreviousBlockClientId(state, startClientId) {
[11878] Fix | Delete
return getAdjacentBlockClientId(state, startClientId, -1);
[11879] Fix | Delete
}
[11880] Fix | Delete
[11881] Fix | Delete
/**
[11882] Fix | Delete
* Returns the next block's client ID from the given reference start ID.
[11883] Fix | Delete
* Defaults start to the selected block. Returns null if there is no next
[11884] Fix | Delete
* block.
[11885] Fix | Delete
*
[11886] Fix | Delete
* @param {Object} state Editor state.
[11887] Fix | Delete
* @param {?string} startClientId Optional client ID of block from which to
[11888] Fix | Delete
* search.
[11889] Fix | Delete
*
[11890] Fix | Delete
* @return {?string} Adjacent block's client ID, or null if none exists.
[11891] Fix | Delete
*/
[11892] Fix | Delete
function getNextBlockClientId(state, startClientId) {
[11893] Fix | Delete
return getAdjacentBlockClientId(state, startClientId, 1);
[11894] Fix | Delete
}
[11895] Fix | Delete
[11896] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[11897] Fix | Delete
/**
[11898] Fix | Delete
* Returns the initial caret position for the selected block.
[11899] Fix | Delete
* This position is to used to position the caret properly when the selected block changes.
[11900] Fix | Delete
* If the current block is not a RichText, having initial position set to 0 means "focus block"
[11901] Fix | Delete
*
[11902] Fix | Delete
* @param {Object} state Global application state.
[11903] Fix | Delete
*
[11904] Fix | Delete
* @return {0|-1|null} Initial position.
[11905] Fix | Delete
*/
[11906] Fix | Delete
function getSelectedBlocksInitialCaretPosition(state) {
[11907] Fix | Delete
/* eslint-enable jsdoc/valid-types */
[11908] Fix | Delete
return state.initialPosition;
[11909] Fix | Delete
}
[11910] Fix | Delete
[11911] Fix | Delete
/**
[11912] Fix | Delete
* Returns the current selection set of block client IDs (multiselection or single selection).
[11913] Fix | Delete
*
[11914] Fix | Delete
* @param {Object} state Editor state.
[11915] Fix | Delete
*
[11916] Fix | Delete
* @return {Array} Multi-selected block client IDs.
[11917] Fix | Delete
*/
[11918] Fix | Delete
const getSelectedBlockClientIds = (0,external_wp_data_namespaceObject.createSelector)(state => {
[11919] Fix | Delete
const {
[11920] Fix | Delete
selectionStart,
[11921] Fix | Delete
selectionEnd
[11922] Fix | Delete
} = state.selection;
[11923] Fix | Delete
if (!selectionStart.clientId || !selectionEnd.clientId) {
[11924] Fix | Delete
return selectors_EMPTY_ARRAY;
[11925] Fix | Delete
}
[11926] Fix | Delete
if (selectionStart.clientId === selectionEnd.clientId) {
[11927] Fix | Delete
return [selectionStart.clientId];
[11928] Fix | Delete
}
[11929] Fix | Delete
[11930] Fix | Delete
// Retrieve root client ID to aid in retrieving relevant nested block
[11931] Fix | Delete
// order, being careful to allow the falsey empty string top-level root
[11932] Fix | Delete
// by explicitly testing against null.
[11933] Fix | Delete
const rootClientId = getBlockRootClientId(state, selectionStart.clientId);
[11934] Fix | Delete
if (rootClientId === null) {
[11935] Fix | Delete
return selectors_EMPTY_ARRAY;
[11936] Fix | Delete
}
[11937] Fix | Delete
const blockOrder = getBlockOrder(state, rootClientId);
[11938] Fix | Delete
const startIndex = blockOrder.indexOf(selectionStart.clientId);
[11939] Fix | Delete
const endIndex = blockOrder.indexOf(selectionEnd.clientId);
[11940] Fix | Delete
if (startIndex > endIndex) {
[11941] Fix | Delete
return blockOrder.slice(endIndex, startIndex + 1);
[11942] Fix | Delete
}
[11943] Fix | Delete
return blockOrder.slice(startIndex, endIndex + 1);
[11944] Fix | Delete
}, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
[11945] Fix | Delete
[11946] Fix | Delete
/**
[11947] Fix | Delete
* Returns the current multi-selection set of block client IDs, or an empty
[11948] Fix | Delete
* array if there is no multi-selection.
[11949] Fix | Delete
*
[11950] Fix | Delete
* @param {Object} state Editor state.
[11951] Fix | Delete
*
[11952] Fix | Delete
* @return {Array} Multi-selected block client IDs.
[11953] Fix | Delete
*/
[11954] Fix | Delete
function getMultiSelectedBlockClientIds(state) {
[11955] Fix | Delete
const {
[11956] Fix | Delete
selectionStart,
[11957] Fix | Delete
selectionEnd
[11958] Fix | Delete
} = state.selection;
[11959] Fix | Delete
if (selectionStart.clientId === selectionEnd.clientId) {
[11960] Fix | Delete
return selectors_EMPTY_ARRAY;
[11961] Fix | Delete
}
[11962] Fix | Delete
return getSelectedBlockClientIds(state);
[11963] Fix | Delete
}
[11964] Fix | Delete
[11965] Fix | Delete
/**
[11966] Fix | Delete
* Returns the current multi-selection set of blocks, or an empty array if
[11967] Fix | Delete
* there is no multi-selection.
[11968] Fix | Delete
*
[11969] Fix | Delete
* @param {Object} state Editor state.
[11970] Fix | Delete
*
[11971] Fix | Delete
* @return {Array} Multi-selected block objects.
[11972] Fix | Delete
*/
[11973] Fix | Delete
const getMultiSelectedBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
[11974] Fix | Delete
const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state);
[11975] Fix | Delete
if (!multiSelectedBlockClientIds.length) {
[11976] Fix | Delete
return selectors_EMPTY_ARRAY;
[11977] Fix | Delete
}
[11978] Fix | Delete
return multiSelectedBlockClientIds.map(clientId => getBlock(state, clientId));
[11979] Fix | Delete
}, state => [...getSelectedBlockClientIds.getDependants(state), state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
[11980] Fix | Delete
[11981] Fix | Delete
/**
[11982] Fix | Delete
* Returns the client ID of the first block in the multi-selection set, or null
[11983] Fix | Delete
* if there is no multi-selection.
[11984] Fix | Delete
*
[11985] Fix | Delete
* @param {Object} state Editor state.
[11986] Fix | Delete
*
[11987] Fix | Delete
* @return {?string} First block client ID in the multi-selection set.
[11988] Fix | Delete
*/
[11989] Fix | Delete
function getFirstMultiSelectedBlockClientId(state) {
[11990] Fix | Delete
return getMultiSelectedBlockClientIds(state)[0] || null;
[11991] Fix | Delete
}
[11992] Fix | Delete
[11993] Fix | Delete
/**
[11994] Fix | Delete
* Returns the client ID of the last block in the multi-selection set, or null
[11995] Fix | Delete
* if there is no multi-selection.
[11996] Fix | Delete
*
[11997] Fix | Delete
* @param {Object} state Editor state.
[11998] Fix | Delete
*
[11999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function