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
type: 'START_MULTI_SELECT'
[14500] Fix | Delete
};
[14501] Fix | Delete
}
[14502] Fix | Delete
[14503] Fix | Delete
/**
[14504] Fix | Delete
* Action that stops block multi-selection.
[14505] Fix | Delete
*
[14506] Fix | Delete
* @return {Object} Action object.
[14507] Fix | Delete
*/
[14508] Fix | Delete
function stopMultiSelect() {
[14509] Fix | Delete
return {
[14510] Fix | Delete
type: 'STOP_MULTI_SELECT'
[14511] Fix | Delete
};
[14512] Fix | Delete
}
[14513] Fix | Delete
[14514] Fix | Delete
/**
[14515] Fix | Delete
* Action that changes block multi-selection.
[14516] Fix | Delete
*
[14517] Fix | Delete
* @param {string} start First block of the multi selection.
[14518] Fix | Delete
* @param {string} end Last block of the multiselection.
[14519] Fix | Delete
* @param {number|null} __experimentalInitialPosition Optional initial position. Pass as null to skip focus within editor canvas.
[14520] Fix | Delete
*/
[14521] Fix | Delete
const multiSelect = (start, end, __experimentalInitialPosition = 0) => ({
[14522] Fix | Delete
select,
[14523] Fix | Delete
dispatch
[14524] Fix | Delete
}) => {
[14525] Fix | Delete
const startBlockRootClientId = select.getBlockRootClientId(start);
[14526] Fix | Delete
const endBlockRootClientId = select.getBlockRootClientId(end);
[14527] Fix | Delete
[14528] Fix | Delete
// Only allow block multi-selections at the same level.
[14529] Fix | Delete
if (startBlockRootClientId !== endBlockRootClientId) {
[14530] Fix | Delete
return;
[14531] Fix | Delete
}
[14532] Fix | Delete
dispatch({
[14533] Fix | Delete
type: 'MULTI_SELECT',
[14534] Fix | Delete
start,
[14535] Fix | Delete
end,
[14536] Fix | Delete
initialPosition: __experimentalInitialPosition
[14537] Fix | Delete
});
[14538] Fix | Delete
const blockCount = select.getSelectedBlockCount();
[14539] Fix | Delete
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of selected blocks */
[14540] Fix | Delete
(0,external_wp_i18n_namespaceObject._n)('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
[14541] Fix | Delete
};
[14542] Fix | Delete
[14543] Fix | Delete
/**
[14544] Fix | Delete
* Action that clears the block selection.
[14545] Fix | Delete
*
[14546] Fix | Delete
* @return {Object} Action object.
[14547] Fix | Delete
*/
[14548] Fix | Delete
function clearSelectedBlock() {
[14549] Fix | Delete
return {
[14550] Fix | Delete
type: 'CLEAR_SELECTED_BLOCK'
[14551] Fix | Delete
};
[14552] Fix | Delete
}
[14553] Fix | Delete
[14554] Fix | Delete
/**
[14555] Fix | Delete
* Action that enables or disables block selection.
[14556] Fix | Delete
*
[14557] Fix | Delete
* @param {boolean} [isSelectionEnabled=true] Whether block selection should
[14558] Fix | Delete
* be enabled.
[14559] Fix | Delete
*
[14560] Fix | Delete
* @return {Object} Action object.
[14561] Fix | Delete
*/
[14562] Fix | Delete
function toggleSelection(isSelectionEnabled = true) {
[14563] Fix | Delete
return {
[14564] Fix | Delete
type: 'TOGGLE_SELECTION',
[14565] Fix | Delete
isSelectionEnabled
[14566] Fix | Delete
};
[14567] Fix | Delete
}
[14568] Fix | Delete
[14569] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[14570] Fix | Delete
/**
[14571] Fix | Delete
* Action that replaces given blocks with one or more replacement blocks.
[14572] Fix | Delete
*
[14573] Fix | Delete
* @param {(string|string[])} clientIds Block client ID(s) to replace.
[14574] Fix | Delete
* @param {(Object|Object[])} blocks Replacement block(s).
[14575] Fix | Delete
* @param {number} indexToSelect Index of replacement block to select.
[14576] Fix | Delete
* @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
[14577] Fix | Delete
* @param {?Object} meta Optional Meta values to be passed to the action object.
[14578] Fix | Delete
*
[14579] Fix | Delete
* @return {Object} Action object.
[14580] Fix | Delete
*/
[14581] Fix | Delete
const replaceBlocks = (clientIds, blocks, indexToSelect, initialPosition = 0, meta) => ({
[14582] Fix | Delete
select,
[14583] Fix | Delete
dispatch,
[14584] Fix | Delete
registry
[14585] Fix | Delete
}) => {
[14586] Fix | Delete
/* eslint-enable jsdoc/valid-types */
[14587] Fix | Delete
clientIds = actions_castArray(clientIds);
[14588] Fix | Delete
blocks = actions_castArray(blocks);
[14589] Fix | Delete
const rootClientId = select.getBlockRootClientId(clientIds[0]);
[14590] Fix | Delete
// Replace is valid if the new blocks can be inserted in the root block.
[14591] Fix | Delete
for (let index = 0; index < blocks.length; index++) {
[14592] Fix | Delete
const block = blocks[index];
[14593] Fix | Delete
const canInsertBlock = select.canInsertBlockType(block.name, rootClientId);
[14594] Fix | Delete
if (!canInsertBlock) {
[14595] Fix | Delete
return;
[14596] Fix | Delete
}
[14597] Fix | Delete
}
[14598] Fix | Delete
// We're batching these two actions because an extra `undo/redo` step can
[14599] Fix | Delete
// be created, based on whether we insert a default block or not.
[14600] Fix | Delete
registry.batch(() => {
[14601] Fix | Delete
dispatch({
[14602] Fix | Delete
type: 'REPLACE_BLOCKS',
[14603] Fix | Delete
clientIds,
[14604] Fix | Delete
blocks,
[14605] Fix | Delete
time: Date.now(),
[14606] Fix | Delete
indexToSelect,
[14607] Fix | Delete
initialPosition,
[14608] Fix | Delete
meta
[14609] Fix | Delete
});
[14610] Fix | Delete
// To avoid a focus loss when removing the last block, assure there is
[14611] Fix | Delete
// always a default block if the last of the blocks have been removed.
[14612] Fix | Delete
dispatch.ensureDefaultBlock();
[14613] Fix | Delete
});
[14614] Fix | Delete
};
[14615] Fix | Delete
[14616] Fix | Delete
/**
[14617] Fix | Delete
* Action that replaces a single block with one or more replacement blocks.
[14618] Fix | Delete
*
[14619] Fix | Delete
* @param {(string|string[])} clientId Block client ID to replace.
[14620] Fix | Delete
* @param {(Object|Object[])} block Replacement block(s).
[14621] Fix | Delete
*
[14622] Fix | Delete
* @return {Object} Action object.
[14623] Fix | Delete
*/
[14624] Fix | Delete
function replaceBlock(clientId, block) {
[14625] Fix | Delete
return replaceBlocks(clientId, block);
[14626] Fix | Delete
}
[14627] Fix | Delete
[14628] Fix | Delete
/**
[14629] Fix | Delete
* Higher-order action creator which, given the action type to dispatch creates
[14630] Fix | Delete
* an action creator for managing block movement.
[14631] Fix | Delete
*
[14632] Fix | Delete
* @param {string} type Action type to dispatch.
[14633] Fix | Delete
*
[14634] Fix | Delete
* @return {Function} Action creator.
[14635] Fix | Delete
*/
[14636] Fix | Delete
const createOnMove = type => (clientIds, rootClientId) => ({
[14637] Fix | Delete
select,
[14638] Fix | Delete
dispatch
[14639] Fix | Delete
}) => {
[14640] Fix | Delete
// If one of the blocks is locked or the parent is locked, we cannot move any block.
[14641] Fix | Delete
const canMoveBlocks = select.canMoveBlocks(clientIds);
[14642] Fix | Delete
if (!canMoveBlocks) {
[14643] Fix | Delete
return;
[14644] Fix | Delete
}
[14645] Fix | Delete
dispatch({
[14646] Fix | Delete
type,
[14647] Fix | Delete
clientIds: actions_castArray(clientIds),
[14648] Fix | Delete
rootClientId
[14649] Fix | Delete
});
[14650] Fix | Delete
};
[14651] Fix | Delete
const moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
[14652] Fix | Delete
const moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
[14653] Fix | Delete
[14654] Fix | Delete
/**
[14655] Fix | Delete
* Action that moves given blocks to a new position.
[14656] Fix | Delete
*
[14657] Fix | Delete
* @param {?string} clientIds The client IDs of the blocks.
[14658] Fix | Delete
* @param {?string} fromRootClientId Root client ID source.
[14659] Fix | Delete
* @param {?string} toRootClientId Root client ID destination.
[14660] Fix | Delete
* @param {number} index The index to move the blocks to.
[14661] Fix | Delete
*/
[14662] Fix | Delete
const moveBlocksToPosition = (clientIds, fromRootClientId = '', toRootClientId = '', index) => ({
[14663] Fix | Delete
select,
[14664] Fix | Delete
dispatch
[14665] Fix | Delete
}) => {
[14666] Fix | Delete
const canMoveBlocks = select.canMoveBlocks(clientIds);
[14667] Fix | Delete
[14668] Fix | Delete
// If one of the blocks is locked or the parent is locked, we cannot move any block.
[14669] Fix | Delete
if (!canMoveBlocks) {
[14670] Fix | Delete
return;
[14671] Fix | Delete
}
[14672] Fix | Delete
[14673] Fix | Delete
// If moving inside the same root block the move is always possible.
[14674] Fix | Delete
if (fromRootClientId !== toRootClientId) {
[14675] Fix | Delete
const canRemoveBlocks = select.canRemoveBlocks(clientIds);
[14676] Fix | Delete
[14677] Fix | Delete
// If we're moving to another block, it means we're deleting blocks from
[14678] Fix | Delete
// the original block, so we need to check if removing is possible.
[14679] Fix | Delete
if (!canRemoveBlocks) {
[14680] Fix | Delete
return;
[14681] Fix | Delete
}
[14682] Fix | Delete
const canInsertBlocks = select.canInsertBlocks(clientIds, toRootClientId);
[14683] Fix | Delete
[14684] Fix | Delete
// If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block.
[14685] Fix | Delete
if (!canInsertBlocks) {
[14686] Fix | Delete
return;
[14687] Fix | Delete
}
[14688] Fix | Delete
}
[14689] Fix | Delete
dispatch({
[14690] Fix | Delete
type: 'MOVE_BLOCKS_TO_POSITION',
[14691] Fix | Delete
fromRootClientId,
[14692] Fix | Delete
toRootClientId,
[14693] Fix | Delete
clientIds,
[14694] Fix | Delete
index
[14695] Fix | Delete
});
[14696] Fix | Delete
};
[14697] Fix | Delete
[14698] Fix | Delete
/**
[14699] Fix | Delete
* Action that moves given block to a new position.
[14700] Fix | Delete
*
[14701] Fix | Delete
* @param {?string} clientId The client ID of the block.
[14702] Fix | Delete
* @param {?string} fromRootClientId Root client ID source.
[14703] Fix | Delete
* @param {?string} toRootClientId Root client ID destination.
[14704] Fix | Delete
* @param {number} index The index to move the block to.
[14705] Fix | Delete
*/
[14706] Fix | Delete
function moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId = '', index) {
[14707] Fix | Delete
return moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
[14708] Fix | Delete
}
[14709] Fix | Delete
[14710] Fix | Delete
/**
[14711] Fix | Delete
* Action that inserts a single block, optionally at a specific index respective a root block list.
[14712] Fix | Delete
*
[14713] Fix | Delete
* Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
[14714] Fix | Delete
* a templateLock is active on the block list.
[14715] Fix | Delete
*
[14716] Fix | Delete
* @param {Object} block Block object to insert.
[14717] Fix | Delete
* @param {?number} index Index at which block should be inserted.
[14718] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
[14719] Fix | Delete
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
[14720] Fix | Delete
* @param {?Object} meta Optional Meta values to be passed to the action object.
[14721] Fix | Delete
*
[14722] Fix | Delete
* @return {Object} Action object.
[14723] Fix | Delete
*/
[14724] Fix | Delete
function insertBlock(block, index, rootClientId, updateSelection, meta) {
[14725] Fix | Delete
return insertBlocks([block], index, rootClientId, updateSelection, 0, meta);
[14726] Fix | Delete
}
[14727] Fix | Delete
[14728] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[14729] Fix | Delete
/**
[14730] Fix | Delete
* Action that inserts an array of blocks, optionally at a specific index respective a root block list.
[14731] Fix | Delete
*
[14732] Fix | Delete
* Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
[14733] Fix | Delete
* a templateLock is active on the block list.
[14734] Fix | Delete
*
[14735] Fix | Delete
* @param {Object[]} blocks Block objects to insert.
[14736] Fix | Delete
* @param {?number} index Index at which block should be inserted.
[14737] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
[14738] Fix | Delete
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
[14739] Fix | Delete
* @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
[14740] Fix | Delete
* @param {?Object} meta Optional Meta values to be passed to the action object.
[14741] Fix | Delete
*
[14742] Fix | Delete
* @return {Object} Action object.
[14743] Fix | Delete
*/
[14744] Fix | Delete
const insertBlocks = (blocks, index, rootClientId, updateSelection = true, initialPosition = 0, meta) => ({
[14745] Fix | Delete
select,
[14746] Fix | Delete
dispatch
[14747] Fix | Delete
}) => {
[14748] Fix | Delete
/* eslint-enable jsdoc/valid-types */
[14749] Fix | Delete
if (initialPosition !== null && typeof initialPosition === 'object') {
[14750] Fix | Delete
meta = initialPosition;
[14751] Fix | Delete
initialPosition = 0;
[14752] Fix | Delete
external_wp_deprecated_default()("meta argument in wp.data.dispatch('core/block-editor')", {
[14753] Fix | Delete
since: '5.8',
[14754] Fix | Delete
hint: 'The meta argument is now the 6th argument of the function'
[14755] Fix | Delete
});
[14756] Fix | Delete
}
[14757] Fix | Delete
blocks = actions_castArray(blocks);
[14758] Fix | Delete
const allowedBlocks = [];
[14759] Fix | Delete
for (const block of blocks) {
[14760] Fix | Delete
const isValid = select.canInsertBlockType(block.name, rootClientId);
[14761] Fix | Delete
if (isValid) {
[14762] Fix | Delete
allowedBlocks.push(block);
[14763] Fix | Delete
}
[14764] Fix | Delete
}
[14765] Fix | Delete
if (allowedBlocks.length) {
[14766] Fix | Delete
dispatch({
[14767] Fix | Delete
type: 'INSERT_BLOCKS',
[14768] Fix | Delete
blocks: allowedBlocks,
[14769] Fix | Delete
index,
[14770] Fix | Delete
rootClientId,
[14771] Fix | Delete
time: Date.now(),
[14772] Fix | Delete
updateSelection,
[14773] Fix | Delete
initialPosition: updateSelection ? initialPosition : null,
[14774] Fix | Delete
meta
[14775] Fix | Delete
});
[14776] Fix | Delete
}
[14777] Fix | Delete
};
[14778] Fix | Delete
[14779] Fix | Delete
/**
[14780] Fix | Delete
* Action that shows the insertion point.
[14781] Fix | Delete
*
[14782] Fix | Delete
* @param {?string} rootClientId Optional root client ID of block list on
[14783] Fix | Delete
* which to insert.
[14784] Fix | Delete
* @param {?number} index Index at which block should be inserted.
[14785] Fix | Delete
* @param {?Object} __unstableOptions Additional options.
[14786] Fix | Delete
* @property {boolean} __unstableWithInserter Whether or not to show an inserter button.
[14787] Fix | Delete
* @property {WPDropOperation} operation The operation to perform when applied,
[14788] Fix | Delete
* either 'insert' or 'replace' for now.
[14789] Fix | Delete
*
[14790] Fix | Delete
* @return {Object} Action object.
[14791] Fix | Delete
*/
[14792] Fix | Delete
function showInsertionPoint(rootClientId, index, __unstableOptions = {}) {
[14793] Fix | Delete
const {
[14794] Fix | Delete
__unstableWithInserter,
[14795] Fix | Delete
operation,
[14796] Fix | Delete
nearestSide
[14797] Fix | Delete
} = __unstableOptions;
[14798] Fix | Delete
return {
[14799] Fix | Delete
type: 'SHOW_INSERTION_POINT',
[14800] Fix | Delete
rootClientId,
[14801] Fix | Delete
index,
[14802] Fix | Delete
__unstableWithInserter,
[14803] Fix | Delete
operation,
[14804] Fix | Delete
nearestSide
[14805] Fix | Delete
};
[14806] Fix | Delete
}
[14807] Fix | Delete
/**
[14808] Fix | Delete
* Action that hides the insertion point.
[14809] Fix | Delete
*/
[14810] Fix | Delete
const hideInsertionPoint = () => ({
[14811] Fix | Delete
select,
[14812] Fix | Delete
dispatch
[14813] Fix | Delete
}) => {
[14814] Fix | Delete
if (!select.isBlockInsertionPointVisible()) {
[14815] Fix | Delete
return;
[14816] Fix | Delete
}
[14817] Fix | Delete
dispatch({
[14818] Fix | Delete
type: 'HIDE_INSERTION_POINT'
[14819] Fix | Delete
});
[14820] Fix | Delete
};
[14821] Fix | Delete
[14822] Fix | Delete
/**
[14823] Fix | Delete
* Action that resets the template validity.
[14824] Fix | Delete
*
[14825] Fix | Delete
* @param {boolean} isValid template validity flag.
[14826] Fix | Delete
*
[14827] Fix | Delete
* @return {Object} Action object.
[14828] Fix | Delete
*/
[14829] Fix | Delete
function setTemplateValidity(isValid) {
[14830] Fix | Delete
return {
[14831] Fix | Delete
type: 'SET_TEMPLATE_VALIDITY',
[14832] Fix | Delete
isValid
[14833] Fix | Delete
};
[14834] Fix | Delete
}
[14835] Fix | Delete
[14836] Fix | Delete
/**
[14837] Fix | Delete
* Action that synchronizes the template with the list of blocks.
[14838] Fix | Delete
*
[14839] Fix | Delete
* @return {Object} Action object.
[14840] Fix | Delete
*/
[14841] Fix | Delete
const synchronizeTemplate = () => ({
[14842] Fix | Delete
select,
[14843] Fix | Delete
dispatch
[14844] Fix | Delete
}) => {
[14845] Fix | Delete
dispatch({
[14846] Fix | Delete
type: 'SYNCHRONIZE_TEMPLATE'
[14847] Fix | Delete
});
[14848] Fix | Delete
const blocks = select.getBlocks();
[14849] Fix | Delete
const template = select.getTemplate();
[14850] Fix | Delete
const updatedBlockList = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
[14851] Fix | Delete
dispatch.resetBlocks(updatedBlockList);
[14852] Fix | Delete
};
[14853] Fix | Delete
[14854] Fix | Delete
/**
[14855] Fix | Delete
* Delete the current selection.
[14856] Fix | Delete
*
[14857] Fix | Delete
* @param {boolean} isForward
[14858] Fix | Delete
*/
[14859] Fix | Delete
const __unstableDeleteSelection = isForward => ({
[14860] Fix | Delete
registry,
[14861] Fix | Delete
select,
[14862] Fix | Delete
dispatch
[14863] Fix | Delete
}) => {
[14864] Fix | Delete
const selectionAnchor = select.getSelectionStart();
[14865] Fix | Delete
const selectionFocus = select.getSelectionEnd();
[14866] Fix | Delete
if (selectionAnchor.clientId === selectionFocus.clientId) {
[14867] Fix | Delete
return;
[14868] Fix | Delete
}
[14869] Fix | Delete
[14870] Fix | Delete
// It's not mergeable if there's no rich text selection.
[14871] Fix | Delete
if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
[14872] Fix | Delete
return false;
[14873] Fix | Delete
}
[14874] Fix | Delete
const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId);
[14875] Fix | Delete
const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId);
[14876] Fix | Delete
[14877] Fix | Delete
// It's not mergeable if the selection doesn't start and end in the same
[14878] Fix | Delete
// block list. Maybe in the future it should be allowed.
[14879] Fix | Delete
if (anchorRootClientId !== focusRootClientId) {
[14880] Fix | Delete
return;
[14881] Fix | Delete
}
[14882] Fix | Delete
const blockOrder = select.getBlockOrder(anchorRootClientId);
[14883] Fix | Delete
const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
[14884] Fix | Delete
const focusIndex = blockOrder.indexOf(selectionFocus.clientId);
[14885] Fix | Delete
[14886] Fix | Delete
// Reassign selection start and end based on order.
[14887] Fix | Delete
let selectionStart, selectionEnd;
[14888] Fix | Delete
if (anchorIndex > focusIndex) {
[14889] Fix | Delete
selectionStart = selectionFocus;
[14890] Fix | Delete
selectionEnd = selectionAnchor;
[14891] Fix | Delete
} else {
[14892] Fix | Delete
selectionStart = selectionAnchor;
[14893] Fix | Delete
selectionEnd = selectionFocus;
[14894] Fix | Delete
}
[14895] Fix | Delete
const targetSelection = isForward ? selectionEnd : selectionStart;
[14896] Fix | Delete
const targetBlock = select.getBlock(targetSelection.clientId);
[14897] Fix | Delete
const targetBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(targetBlock.name);
[14898] Fix | Delete
if (!targetBlockType.merge) {
[14899] Fix | Delete
return;
[14900] Fix | Delete
}
[14901] Fix | Delete
const selectionA = selectionStart;
[14902] Fix | Delete
const selectionB = selectionEnd;
[14903] Fix | Delete
const blockA = select.getBlock(selectionA.clientId);
[14904] Fix | Delete
const blockB = select.getBlock(selectionB.clientId);
[14905] Fix | Delete
const htmlA = blockA.attributes[selectionA.attributeKey];
[14906] Fix | Delete
const htmlB = blockB.attributes[selectionB.attributeKey];
[14907] Fix | Delete
let valueA = (0,external_wp_richText_namespaceObject.create)({
[14908] Fix | Delete
html: htmlA
[14909] Fix | Delete
});
[14910] Fix | Delete
let valueB = (0,external_wp_richText_namespaceObject.create)({
[14911] Fix | Delete
html: htmlB
[14912] Fix | Delete
});
[14913] Fix | Delete
valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length);
[14914] Fix | Delete
valueB = (0,external_wp_richText_namespaceObject.insert)(valueB, START_OF_SELECTED_AREA, 0, selectionB.offset);
[14915] Fix | Delete
[14916] Fix | Delete
// Clone the blocks so we don't manipulate the original.
[14917] Fix | Delete
const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA, {
[14918] Fix | Delete
[selectionA.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
[14919] Fix | Delete
value: valueA
[14920] Fix | Delete
})
[14921] Fix | Delete
});
[14922] Fix | Delete
const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB, {
[14923] Fix | Delete
[selectionB.attributeKey]: (0,external_wp_richText_namespaceObject.toHTMLString)({
[14924] Fix | Delete
value: valueB
[14925] Fix | Delete
})
[14926] Fix | Delete
});
[14927] Fix | Delete
const followingBlock = isForward ? cloneA : cloneB;
[14928] Fix | Delete
[14929] Fix | Delete
// We can only merge blocks with similar types
[14930] Fix | Delete
// thus, we transform the block to merge first
[14931] Fix | Delete
const blocksWithTheSameType = blockA.name === blockB.name ? [followingBlock] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(followingBlock, targetBlockType.name);
[14932] Fix | Delete
[14933] Fix | Delete
// If the block types can not match, do nothing
[14934] Fix | Delete
if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
[14935] Fix | Delete
return;
[14936] Fix | Delete
}
[14937] Fix | Delete
let updatedAttributes;
[14938] Fix | Delete
if (isForward) {
[14939] Fix | Delete
const blockToMerge = blocksWithTheSameType.pop();
[14940] Fix | Delete
updatedAttributes = targetBlockType.merge(blockToMerge.attributes, cloneB.attributes);
[14941] Fix | Delete
} else {
[14942] Fix | Delete
const blockToMerge = blocksWithTheSameType.shift();
[14943] Fix | Delete
updatedAttributes = targetBlockType.merge(cloneA.attributes, blockToMerge.attributes);
[14944] Fix | Delete
}
[14945] Fix | Delete
const newAttributeKey = retrieveSelectedAttribute(updatedAttributes);
[14946] Fix | Delete
const convertedHtml = updatedAttributes[newAttributeKey];
[14947] Fix | Delete
const convertedValue = (0,external_wp_richText_namespaceObject.create)({
[14948] Fix | Delete
html: convertedHtml
[14949] Fix | Delete
});
[14950] Fix | Delete
const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
[14951] Fix | Delete
const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1);
[14952] Fix | Delete
const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({
[14953] Fix | Delete
value: newValue
[14954] Fix | Delete
});
[14955] Fix | Delete
updatedAttributes[newAttributeKey] = newHtml;
[14956] Fix | Delete
const selectedBlockClientIds = select.getSelectedBlockClientIds();
[14957] Fix | Delete
const replacement = [...(isForward ? blocksWithTheSameType : []), {
[14958] Fix | Delete
// Preserve the original client ID.
[14959] Fix | Delete
...targetBlock,
[14960] Fix | Delete
attributes: {
[14961] Fix | Delete
...targetBlock.attributes,
[14962] Fix | Delete
...updatedAttributes
[14963] Fix | Delete
}
[14964] Fix | Delete
}, ...(isForward ? [] : blocksWithTheSameType)];
[14965] Fix | Delete
registry.batch(() => {
[14966] Fix | Delete
dispatch.selectionChange(targetBlock.clientId, newAttributeKey, newOffset, newOffset);
[14967] Fix | Delete
dispatch.replaceBlocks(selectedBlockClientIds, replacement, 0,
[14968] Fix | Delete
// If we don't pass the `indexToSelect` it will default to the last block.
[14969] Fix | Delete
select.getSelectedBlocksInitialCaretPosition());
[14970] Fix | Delete
});
[14971] Fix | Delete
};
[14972] Fix | Delete
[14973] Fix | Delete
/**
[14974] Fix | Delete
* Split the current selection.
[14975] Fix | Delete
* @param {?Array} blocks
[14976] Fix | Delete
*/
[14977] Fix | Delete
const __unstableSplitSelection = (blocks = []) => ({
[14978] Fix | Delete
registry,
[14979] Fix | Delete
select,
[14980] Fix | Delete
dispatch
[14981] Fix | Delete
}) => {
[14982] Fix | Delete
const selectionAnchor = select.getSelectionStart();
[14983] Fix | Delete
const selectionFocus = select.getSelectionEnd();
[14984] Fix | Delete
const anchorRootClientId = select.getBlockRootClientId(selectionAnchor.clientId);
[14985] Fix | Delete
const focusRootClientId = select.getBlockRootClientId(selectionFocus.clientId);
[14986] Fix | Delete
[14987] Fix | Delete
// It's not splittable if the selection doesn't start and end in the same
[14988] Fix | Delete
// block list. Maybe in the future it should be allowed.
[14989] Fix | Delete
if (anchorRootClientId !== focusRootClientId) {
[14990] Fix | Delete
return;
[14991] Fix | Delete
}
[14992] Fix | Delete
const blockOrder = select.getBlockOrder(anchorRootClientId);
[14993] Fix | Delete
const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
[14994] Fix | Delete
const focusIndex = blockOrder.indexOf(selectionFocus.clientId);
[14995] Fix | Delete
[14996] Fix | Delete
// Reassign selection start and end based on order.
[14997] Fix | Delete
let selectionStart, selectionEnd;
[14998] Fix | Delete
if (anchorIndex > focusIndex) {
[14999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function