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
* @return {?string} Last block client ID in the multi-selection set.
[12000] Fix | Delete
*/
[12001] Fix | Delete
function getLastMultiSelectedBlockClientId(state) {
[12002] Fix | Delete
const selectedClientIds = getMultiSelectedBlockClientIds(state);
[12003] Fix | Delete
return selectedClientIds[selectedClientIds.length - 1] || null;
[12004] Fix | Delete
}
[12005] Fix | Delete
[12006] Fix | Delete
/**
[12007] Fix | Delete
* Returns true if a multi-selection exists, and the block corresponding to the
[12008] Fix | Delete
* specified client ID is the first block of the multi-selection set, or false
[12009] Fix | Delete
* otherwise.
[12010] Fix | Delete
*
[12011] Fix | Delete
* @param {Object} state Editor state.
[12012] Fix | Delete
* @param {string} clientId Block client ID.
[12013] Fix | Delete
*
[12014] Fix | Delete
* @return {boolean} Whether block is first in multi-selection.
[12015] Fix | Delete
*/
[12016] Fix | Delete
function isFirstMultiSelectedBlock(state, clientId) {
[12017] Fix | Delete
return getFirstMultiSelectedBlockClientId(state) === clientId;
[12018] Fix | Delete
}
[12019] Fix | Delete
[12020] Fix | Delete
/**
[12021] Fix | Delete
* Returns true if the client ID occurs within the block multi-selection, or
[12022] Fix | Delete
* false otherwise.
[12023] Fix | Delete
*
[12024] Fix | Delete
* @param {Object} state Editor state.
[12025] Fix | Delete
* @param {string} clientId Block client ID.
[12026] Fix | Delete
*
[12027] Fix | Delete
* @return {boolean} Whether block is in multi-selection set.
[12028] Fix | Delete
*/
[12029] Fix | Delete
function isBlockMultiSelected(state, clientId) {
[12030] Fix | Delete
return getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1;
[12031] Fix | Delete
}
[12032] Fix | Delete
[12033] Fix | Delete
/**
[12034] Fix | Delete
* Returns true if an ancestor of the block is multi-selected, or false
[12035] Fix | Delete
* otherwise.
[12036] Fix | Delete
*
[12037] Fix | Delete
* @param {Object} state Editor state.
[12038] Fix | Delete
* @param {string} clientId Block client ID.
[12039] Fix | Delete
*
[12040] Fix | Delete
* @return {boolean} Whether an ancestor of the block is in multi-selection
[12041] Fix | Delete
* set.
[12042] Fix | Delete
*/
[12043] Fix | Delete
const isAncestorMultiSelected = (0,external_wp_data_namespaceObject.createSelector)((state, clientId) => {
[12044] Fix | Delete
let ancestorClientId = clientId;
[12045] Fix | Delete
let isMultiSelected = false;
[12046] Fix | Delete
while (ancestorClientId && !isMultiSelected) {
[12047] Fix | Delete
ancestorClientId = getBlockRootClientId(state, ancestorClientId);
[12048] Fix | Delete
isMultiSelected = isBlockMultiSelected(state, ancestorClientId);
[12049] Fix | Delete
}
[12050] Fix | Delete
return isMultiSelected;
[12051] Fix | Delete
}, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
[12052] Fix | Delete
[12053] Fix | Delete
/**
[12054] Fix | Delete
* Returns the client ID of the block which begins the multi-selection set, or
[12055] Fix | Delete
* null if there is no multi-selection.
[12056] Fix | Delete
*
[12057] Fix | Delete
* This is not necessarily the first client ID in the selection.
[12058] Fix | Delete
*
[12059] Fix | Delete
* @see getFirstMultiSelectedBlockClientId
[12060] Fix | Delete
*
[12061] Fix | Delete
* @param {Object} state Editor state.
[12062] Fix | Delete
*
[12063] Fix | Delete
* @return {?string} Client ID of block beginning multi-selection.
[12064] Fix | Delete
*/
[12065] Fix | Delete
function getMultiSelectedBlocksStartClientId(state) {
[12066] Fix | Delete
const {
[12067] Fix | Delete
selectionStart,
[12068] Fix | Delete
selectionEnd
[12069] Fix | Delete
} = state.selection;
[12070] Fix | Delete
if (selectionStart.clientId === selectionEnd.clientId) {
[12071] Fix | Delete
return null;
[12072] Fix | Delete
}
[12073] Fix | Delete
return selectionStart.clientId || null;
[12074] Fix | Delete
}
[12075] Fix | Delete
[12076] Fix | Delete
/**
[12077] Fix | Delete
* Returns the client ID of the block which ends the multi-selection set, or
[12078] Fix | Delete
* null if there is no multi-selection.
[12079] Fix | Delete
*
[12080] Fix | Delete
* This is not necessarily the last client ID in the selection.
[12081] Fix | Delete
*
[12082] Fix | Delete
* @see getLastMultiSelectedBlockClientId
[12083] Fix | Delete
*
[12084] Fix | Delete
* @param {Object} state Editor state.
[12085] Fix | Delete
*
[12086] Fix | Delete
* @return {?string} Client ID of block ending multi-selection.
[12087] Fix | Delete
*/
[12088] Fix | Delete
function getMultiSelectedBlocksEndClientId(state) {
[12089] Fix | Delete
const {
[12090] Fix | Delete
selectionStart,
[12091] Fix | Delete
selectionEnd
[12092] Fix | Delete
} = state.selection;
[12093] Fix | Delete
if (selectionStart.clientId === selectionEnd.clientId) {
[12094] Fix | Delete
return null;
[12095] Fix | Delete
}
[12096] Fix | Delete
return selectionEnd.clientId || null;
[12097] Fix | Delete
}
[12098] Fix | Delete
[12099] Fix | Delete
/**
[12100] Fix | Delete
* Returns true if the selection is not partial.
[12101] Fix | Delete
*
[12102] Fix | Delete
* @param {Object} state Editor state.
[12103] Fix | Delete
*
[12104] Fix | Delete
* @return {boolean} Whether the selection is mergeable.
[12105] Fix | Delete
*/
[12106] Fix | Delete
function __unstableIsFullySelected(state) {
[12107] Fix | Delete
const selectionAnchor = getSelectionStart(state);
[12108] Fix | Delete
const selectionFocus = getSelectionEnd(state);
[12109] Fix | Delete
return !selectionAnchor.attributeKey && !selectionFocus.attributeKey && typeof selectionAnchor.offset === 'undefined' && typeof selectionFocus.offset === 'undefined';
[12110] Fix | Delete
}
[12111] Fix | Delete
[12112] Fix | Delete
/**
[12113] Fix | Delete
* Returns true if the selection is collapsed.
[12114] Fix | Delete
*
[12115] Fix | Delete
* @param {Object} state Editor state.
[12116] Fix | Delete
*
[12117] Fix | Delete
* @return {boolean} Whether the selection is collapsed.
[12118] Fix | Delete
*/
[12119] Fix | Delete
function __unstableIsSelectionCollapsed(state) {
[12120] Fix | Delete
const selectionAnchor = getSelectionStart(state);
[12121] Fix | Delete
const selectionFocus = getSelectionEnd(state);
[12122] Fix | Delete
return !!selectionAnchor && !!selectionFocus && selectionAnchor.clientId === selectionFocus.clientId && selectionAnchor.attributeKey === selectionFocus.attributeKey && selectionAnchor.offset === selectionFocus.offset;
[12123] Fix | Delete
}
[12124] Fix | Delete
function __unstableSelectionHasUnmergeableBlock(state) {
[12125] Fix | Delete
return getSelectedBlockClientIds(state).some(clientId => {
[12126] Fix | Delete
const blockName = getBlockName(state, clientId);
[12127] Fix | Delete
const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
[12128] Fix | Delete
return !blockType.merge;
[12129] Fix | Delete
});
[12130] Fix | Delete
}
[12131] Fix | Delete
[12132] Fix | Delete
/**
[12133] Fix | Delete
* Check whether the selection is mergeable.
[12134] Fix | Delete
*
[12135] Fix | Delete
* @param {Object} state Editor state.
[12136] Fix | Delete
* @param {boolean} isForward Whether to merge forwards.
[12137] Fix | Delete
*
[12138] Fix | Delete
* @return {boolean} Whether the selection is mergeable.
[12139] Fix | Delete
*/
[12140] Fix | Delete
function __unstableIsSelectionMergeable(state, isForward) {
[12141] Fix | Delete
const selectionAnchor = getSelectionStart(state);
[12142] Fix | Delete
const selectionFocus = getSelectionEnd(state);
[12143] Fix | Delete
[12144] Fix | Delete
// It's not mergeable if the start and end are within the same block.
[12145] Fix | Delete
if (selectionAnchor.clientId === selectionFocus.clientId) {
[12146] Fix | Delete
return false;
[12147] Fix | Delete
}
[12148] Fix | Delete
[12149] Fix | Delete
// It's not mergeable if there's no rich text selection.
[12150] Fix | Delete
if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
[12151] Fix | Delete
return false;
[12152] Fix | Delete
}
[12153] Fix | Delete
const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
[12154] Fix | Delete
const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId);
[12155] Fix | Delete
[12156] Fix | Delete
// It's not mergeable if the selection doesn't start and end in the same
[12157] Fix | Delete
// block list. Maybe in the future it should be allowed.
[12158] Fix | Delete
if (anchorRootClientId !== focusRootClientId) {
[12159] Fix | Delete
return false;
[12160] Fix | Delete
}
[12161] Fix | Delete
const blockOrder = getBlockOrder(state, anchorRootClientId);
[12162] Fix | Delete
const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
[12163] Fix | Delete
const focusIndex = blockOrder.indexOf(selectionFocus.clientId);
[12164] Fix | Delete
[12165] Fix | Delete
// Reassign selection start and end based on order.
[12166] Fix | Delete
let selectionStart, selectionEnd;
[12167] Fix | Delete
if (anchorIndex > focusIndex) {
[12168] Fix | Delete
selectionStart = selectionFocus;
[12169] Fix | Delete
selectionEnd = selectionAnchor;
[12170] Fix | Delete
} else {
[12171] Fix | Delete
selectionStart = selectionAnchor;
[12172] Fix | Delete
selectionEnd = selectionFocus;
[12173] Fix | Delete
}
[12174] Fix | Delete
const targetBlockClientId = isForward ? selectionEnd.clientId : selectionStart.clientId;
[12175] Fix | Delete
const blockToMergeClientId = isForward ? selectionStart.clientId : selectionEnd.clientId;
[12176] Fix | Delete
const targetBlockName = getBlockName(state, targetBlockClientId);
[12177] Fix | Delete
const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlockName);
[12178] Fix | Delete
if (!targetBlockType.merge) {
[12179] Fix | Delete
return false;
[12180] Fix | Delete
}
[12181] Fix | Delete
const blockToMerge = getBlock(state, blockToMergeClientId);
[12182] Fix | Delete
[12183] Fix | Delete
// It's mergeable if the blocks are of the same type.
[12184] Fix | Delete
if (blockToMerge.name === targetBlockName) {
[12185] Fix | Delete
return true;
[12186] Fix | Delete
}
[12187] Fix | Delete
[12188] Fix | Delete
// If the blocks are of a different type, try to transform the block being
[12189] Fix | Delete
// merged into the same type of block.
[12190] Fix | Delete
const blocksToMerge = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blockToMerge, targetBlockName);
[12191] Fix | Delete
return blocksToMerge && blocksToMerge.length;
[12192] Fix | Delete
}
[12193] Fix | Delete
[12194] Fix | Delete
/**
[12195] Fix | Delete
* Get partial selected blocks with their content updated
[12196] Fix | Delete
* based on the selection.
[12197] Fix | Delete
*
[12198] Fix | Delete
* @param {Object} state Editor state.
[12199] Fix | Delete
*
[12200] Fix | Delete
* @return {Object[]} Updated partial selected blocks.
[12201] Fix | Delete
*/
[12202] Fix | Delete
const __unstableGetSelectedBlocksWithPartialSelection = state => {
[12203] Fix | Delete
const selectionAnchor = getSelectionStart(state);
[12204] Fix | Delete
const selectionFocus = getSelectionEnd(state);
[12205] Fix | Delete
if (selectionAnchor.clientId === selectionFocus.clientId) {
[12206] Fix | Delete
return selectors_EMPTY_ARRAY;
[12207] Fix | Delete
}
[12208] Fix | Delete
[12209] Fix | Delete
// Can't split if the selection is not set.
[12210] Fix | Delete
if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
[12211] Fix | Delete
return selectors_EMPTY_ARRAY;
[12212] Fix | Delete
}
[12213] Fix | Delete
const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
[12214] Fix | Delete
const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId);
[12215] Fix | Delete
[12216] Fix | Delete
// It's not splittable if the selection doesn't start and end in the same
[12217] Fix | Delete
// block list. Maybe in the future it should be allowed.
[12218] Fix | Delete
if (anchorRootClientId !== focusRootClientId) {
[12219] Fix | Delete
return selectors_EMPTY_ARRAY;
[12220] Fix | Delete
}
[12221] Fix | Delete
const blockOrder = getBlockOrder(state, anchorRootClientId);
[12222] Fix | Delete
const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
[12223] Fix | Delete
const focusIndex = blockOrder.indexOf(selectionFocus.clientId);
[12224] Fix | Delete
[12225] Fix | Delete
// Reassign selection start and end based on order.
[12226] Fix | Delete
const [selectionStart, selectionEnd] = anchorIndex > focusIndex ? [selectionFocus, selectionAnchor] : [selectionAnchor, selectionFocus];
[12227] Fix | Delete
const blockA = getBlock(state, selectionStart.clientId);
[12228] Fix | Delete
const blockB = getBlock(state, selectionEnd.clientId);
[12229] Fix | Delete
const htmlA = blockA.attributes[selectionStart.attributeKey];
[12230] Fix | Delete
const htmlB = blockB.attributes[selectionEnd.attributeKey];
[12231] Fix | Delete
let valueA = (0,external_wp_richText_namespaceObject.create)({
[12232] Fix | Delete
html: htmlA
[12233] Fix | Delete
});
[12234] Fix | Delete
let valueB = (0,external_wp_richText_namespaceObject.create)({
[12235] Fix | Delete
html: htmlB
[12236] Fix | Delete
});
[12237] Fix | Delete
valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, 0, selectionStart.offset);
[12238] Fix | Delete
valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, selectionEnd.offset, valueB.text.length);
[12239] Fix | Delete
return [{
[12240] Fix | Delete
...blockA,
[12241] Fix | Delete
attributes: {
[12242] Fix | Delete
...blockA.attributes,
[12243] Fix | Delete
[selectionStart.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
[12244] Fix | Delete
value: valueA
[12245] Fix | Delete
})
[12246] Fix | Delete
}
[12247] Fix | Delete
}, {
[12248] Fix | Delete
...blockB,
[12249] Fix | Delete
attributes: {
[12250] Fix | Delete
...blockB.attributes,
[12251] Fix | Delete
[selectionEnd.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
[12252] Fix | Delete
value: valueB
[12253] Fix | Delete
})
[12254] Fix | Delete
}
[12255] Fix | Delete
}];
[12256] Fix | Delete
};
[12257] Fix | Delete
[12258] Fix | Delete
/**
[12259] Fix | Delete
* Returns an array containing all block client IDs in the editor in the order
[12260] Fix | Delete
* they appear. Optionally accepts a root client ID of the block list for which
[12261] Fix | Delete
* the order should be returned, defaulting to the top-level block order.
[12262] Fix | Delete
*
[12263] Fix | Delete
* @param {Object} state Editor state.
[12264] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list.
[12265] Fix | Delete
*
[12266] Fix | Delete
* @return {Array} Ordered client IDs of editor blocks.
[12267] Fix | Delete
*/
[12268] Fix | Delete
function getBlockOrder(state, rootClientId) {
[12269] Fix | Delete
return state.blocks.order.get(rootClientId || '') || selectors_EMPTY_ARRAY;
[12270] Fix | Delete
}
[12271] Fix | Delete
[12272] Fix | Delete
/**
[12273] Fix | Delete
* Returns the index at which the block corresponding to the specified client
[12274] Fix | Delete
* ID occurs within the block order, or `-1` if the block does not exist.
[12275] Fix | Delete
*
[12276] Fix | Delete
* @param {Object} state Editor state.
[12277] Fix | Delete
* @param {string} clientId Block client ID.
[12278] Fix | Delete
*
[12279] Fix | Delete
* @return {number} Index at which block exists in order.
[12280] Fix | Delete
*/
[12281] Fix | Delete
function getBlockIndex(state, clientId) {
[12282] Fix | Delete
const rootClientId = getBlockRootClientId(state, clientId);
[12283] Fix | Delete
return getBlockOrder(state, rootClientId).indexOf(clientId);
[12284] Fix | Delete
}
[12285] Fix | Delete
[12286] Fix | Delete
/**
[12287] Fix | Delete
* Returns true if the block corresponding to the specified client ID is
[12288] Fix | Delete
* currently selected and no multi-selection exists, or false otherwise.
[12289] Fix | Delete
*
[12290] Fix | Delete
* @param {Object} state Editor state.
[12291] Fix | Delete
* @param {string} clientId Block client ID.
[12292] Fix | Delete
*
[12293] Fix | Delete
* @return {boolean} Whether block is selected and multi-selection exists.
[12294] Fix | Delete
*/
[12295] Fix | Delete
function isBlockSelected(state, clientId) {
[12296] Fix | Delete
const {
[12297] Fix | Delete
selectionStart,
[12298] Fix | Delete
selectionEnd
[12299] Fix | Delete
} = state.selection;
[12300] Fix | Delete
if (selectionStart.clientId !== selectionEnd.clientId) {
[12301] Fix | Delete
return false;
[12302] Fix | Delete
}
[12303] Fix | Delete
return selectionStart.clientId === clientId;
[12304] Fix | Delete
}
[12305] Fix | Delete
[12306] Fix | Delete
/**
[12307] Fix | Delete
* Returns true if one of the block's inner blocks is selected.
[12308] Fix | Delete
*
[12309] Fix | Delete
* @param {Object} state Editor state.
[12310] Fix | Delete
* @param {string} clientId Block client ID.
[12311] Fix | Delete
* @param {boolean} deep Perform a deep check.
[12312] Fix | Delete
*
[12313] Fix | Delete
* @return {boolean} Whether the block has an inner block selected
[12314] Fix | Delete
*/
[12315] Fix | Delete
function hasSelectedInnerBlock(state, clientId, deep = false) {
[12316] Fix | Delete
const selectedBlockClientIds = getSelectedBlockClientIds(state);
[12317] Fix | Delete
if (!selectedBlockClientIds.length) {
[12318] Fix | Delete
return false;
[12319] Fix | Delete
}
[12320] Fix | Delete
if (deep) {
[12321] Fix | Delete
return selectedBlockClientIds.some(id =>
[12322] Fix | Delete
// Pass true because we don't care about order and it's more
[12323] Fix | Delete
// performant.
[12324] Fix | Delete
getBlockParents(state, id, true).includes(clientId));
[12325] Fix | Delete
}
[12326] Fix | Delete
return selectedBlockClientIds.some(id => getBlockRootClientId(state, id) === clientId);
[12327] Fix | Delete
}
[12328] Fix | Delete
[12329] Fix | Delete
/**
[12330] Fix | Delete
* Returns true if one of the block's inner blocks is dragged.
[12331] Fix | Delete
*
[12332] Fix | Delete
* @param {Object} state Editor state.
[12333] Fix | Delete
* @param {string} clientId Block client ID.
[12334] Fix | Delete
* @param {boolean} deep Perform a deep check.
[12335] Fix | Delete
*
[12336] Fix | Delete
* @return {boolean} Whether the block has an inner block dragged
[12337] Fix | Delete
*/
[12338] Fix | Delete
function hasDraggedInnerBlock(state, clientId, deep = false) {
[12339] Fix | Delete
return getBlockOrder(state, clientId).some(innerClientId => isBlockBeingDragged(state, innerClientId) || deep && hasDraggedInnerBlock(state, innerClientId, deep));
[12340] Fix | Delete
}
[12341] Fix | Delete
[12342] Fix | Delete
/**
[12343] Fix | Delete
* Returns true if the block corresponding to the specified client ID is
[12344] Fix | Delete
* currently selected but isn't the last of the selected blocks. Here "last"
[12345] Fix | Delete
* refers to the block sequence in the document, _not_ the sequence of
[12346] Fix | Delete
* multi-selection, which is why `state.selectionEnd` isn't used.
[12347] Fix | Delete
*
[12348] Fix | Delete
* @param {Object} state Editor state.
[12349] Fix | Delete
* @param {string} clientId Block client ID.
[12350] Fix | Delete
*
[12351] Fix | Delete
* @return {boolean} Whether block is selected and not the last in the
[12352] Fix | Delete
* selection.
[12353] Fix | Delete
*/
[12354] Fix | Delete
function isBlockWithinSelection(state, clientId) {
[12355] Fix | Delete
if (!clientId) {
[12356] Fix | Delete
return false;
[12357] Fix | Delete
}
[12358] Fix | Delete
const clientIds = getMultiSelectedBlockClientIds(state);
[12359] Fix | Delete
const index = clientIds.indexOf(clientId);
[12360] Fix | Delete
return index > -1 && index < clientIds.length - 1;
[12361] Fix | Delete
}
[12362] Fix | Delete
[12363] Fix | Delete
/**
[12364] Fix | Delete
* Returns true if a multi-selection has been made, or false otherwise.
[12365] Fix | Delete
*
[12366] Fix | Delete
* @param {Object} state Editor state.
[12367] Fix | Delete
*
[12368] Fix | Delete
* @return {boolean} Whether multi-selection has been made.
[12369] Fix | Delete
*/
[12370] Fix | Delete
function hasMultiSelection(state) {
[12371] Fix | Delete
const {
[12372] Fix | Delete
selectionStart,
[12373] Fix | Delete
selectionEnd
[12374] Fix | Delete
} = state.selection;
[12375] Fix | Delete
return selectionStart.clientId !== selectionEnd.clientId;
[12376] Fix | Delete
}
[12377] Fix | Delete
[12378] Fix | Delete
/**
[12379] Fix | Delete
* Whether in the process of multi-selecting or not. This flag is only true
[12380] Fix | Delete
* while the multi-selection is being selected (by mouse move), and is false
[12381] Fix | Delete
* once the multi-selection has been settled.
[12382] Fix | Delete
*
[12383] Fix | Delete
* @see hasMultiSelection
[12384] Fix | Delete
*
[12385] Fix | Delete
* @param {Object} state Global application state.
[12386] Fix | Delete
*
[12387] Fix | Delete
* @return {boolean} True if multi-selecting, false if not.
[12388] Fix | Delete
*/
[12389] Fix | Delete
function selectors_isMultiSelecting(state) {
[12390] Fix | Delete
return state.isMultiSelecting;
[12391] Fix | Delete
}
[12392] Fix | Delete
[12393] Fix | Delete
/**
[12394] Fix | Delete
* Selector that returns if multi-selection is enabled or not.
[12395] Fix | Delete
*
[12396] Fix | Delete
* @param {Object} state Global application state.
[12397] Fix | Delete
*
[12398] Fix | Delete
* @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled.
[12399] Fix | Delete
*/
[12400] Fix | Delete
function selectors_isSelectionEnabled(state) {
[12401] Fix | Delete
return state.isSelectionEnabled;
[12402] Fix | Delete
}
[12403] Fix | Delete
[12404] Fix | Delete
/**
[12405] Fix | Delete
* Returns the block's editing mode, defaulting to "visual" if not explicitly
[12406] Fix | Delete
* assigned.
[12407] Fix | Delete
*
[12408] Fix | Delete
* @param {Object} state Editor state.
[12409] Fix | Delete
* @param {string} clientId Block client ID.
[12410] Fix | Delete
*
[12411] Fix | Delete
* @return {Object} Block editing mode.
[12412] Fix | Delete
*/
[12413] Fix | Delete
function getBlockMode(state, clientId) {
[12414] Fix | Delete
return state.blocksMode[clientId] || 'visual';
[12415] Fix | Delete
}
[12416] Fix | Delete
[12417] Fix | Delete
/**
[12418] Fix | Delete
* Returns true if the user is typing, or false otherwise.
[12419] Fix | Delete
*
[12420] Fix | Delete
* @param {Object} state Global application state.
[12421] Fix | Delete
*
[12422] Fix | Delete
* @return {boolean} Whether user is typing.
[12423] Fix | Delete
*/
[12424] Fix | Delete
function selectors_isTyping(state) {
[12425] Fix | Delete
return state.isTyping;
[12426] Fix | Delete
}
[12427] Fix | Delete
[12428] Fix | Delete
/**
[12429] Fix | Delete
* Returns true if the user is dragging blocks, or false otherwise.
[12430] Fix | Delete
*
[12431] Fix | Delete
* @param {Object} state Global application state.
[12432] Fix | Delete
*
[12433] Fix | Delete
* @return {boolean} Whether user is dragging blocks.
[12434] Fix | Delete
*/
[12435] Fix | Delete
function isDraggingBlocks(state) {
[12436] Fix | Delete
return !!state.draggedBlocks.length;
[12437] Fix | Delete
}
[12438] Fix | Delete
[12439] Fix | Delete
/**
[12440] Fix | Delete
* Returns the client ids of any blocks being directly dragged.
[12441] Fix | Delete
*
[12442] Fix | Delete
* This does not include children of a parent being dragged.
[12443] Fix | Delete
*
[12444] Fix | Delete
* @param {Object} state Global application state.
[12445] Fix | Delete
*
[12446] Fix | Delete
* @return {string[]} Array of dragged block client ids.
[12447] Fix | Delete
*/
[12448] Fix | Delete
function getDraggedBlockClientIds(state) {
[12449] Fix | Delete
return state.draggedBlocks;
[12450] Fix | Delete
}
[12451] Fix | Delete
[12452] Fix | Delete
/**
[12453] Fix | Delete
* Returns whether the block is being dragged.
[12454] Fix | Delete
*
[12455] Fix | Delete
* Only returns true if the block is being directly dragged,
[12456] Fix | Delete
* not if the block is a child of a parent being dragged.
[12457] Fix | Delete
* See `isAncestorBeingDragged` for child blocks.
[12458] Fix | Delete
*
[12459] Fix | Delete
* @param {Object} state Global application state.
[12460] Fix | Delete
* @param {string} clientId Client id for block to check.
[12461] Fix | Delete
*
[12462] Fix | Delete
* @return {boolean} Whether the block is being dragged.
[12463] Fix | Delete
*/
[12464] Fix | Delete
function isBlockBeingDragged(state, clientId) {
[12465] Fix | Delete
return state.draggedBlocks.includes(clientId);
[12466] Fix | Delete
}
[12467] Fix | Delete
[12468] Fix | Delete
/**
[12469] Fix | Delete
* Returns whether a parent/ancestor of the block is being dragged.
[12470] Fix | Delete
*
[12471] Fix | Delete
* @param {Object} state Global application state.
[12472] Fix | Delete
* @param {string} clientId Client id for block to check.
[12473] Fix | Delete
*
[12474] Fix | Delete
* @return {boolean} Whether the block's ancestor is being dragged.
[12475] Fix | Delete
*/
[12476] Fix | Delete
function isAncestorBeingDragged(state, clientId) {
[12477] Fix | Delete
// Return early if no blocks are being dragged rather than
[12478] Fix | Delete
// the more expensive check for parents.
[12479] Fix | Delete
if (!isDraggingBlocks(state)) {
[12480] Fix | Delete
return false;
[12481] Fix | Delete
}
[12482] Fix | Delete
const parents = getBlockParents(state, clientId);
[12483] Fix | Delete
return parents.some(parentClientId => isBlockBeingDragged(state, parentClientId));
[12484] Fix | Delete
}
[12485] Fix | Delete
[12486] Fix | Delete
/**
[12487] Fix | Delete
* Returns true if the caret is within formatted text, or false otherwise.
[12488] Fix | Delete
*
[12489] Fix | Delete
* @deprecated
[12490] Fix | Delete
*
[12491] Fix | Delete
* @return {boolean} Whether the caret is within formatted text.
[12492] Fix | Delete
*/
[12493] Fix | Delete
function isCaretWithinFormattedText() {
[12494] Fix | Delete
external_wp_deprecated_default()('wp.data.select( "core/block-editor" ).isCaretWithinFormattedText', {
[12495] Fix | Delete
since: '6.1',
[12496] Fix | Delete
version: '6.3'
[12497] Fix | Delete
});
[12498] Fix | Delete
return false;
[12499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function