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
selectionStart = selectionFocus;
[15000] Fix | Delete
selectionEnd = selectionAnchor;
[15001] Fix | Delete
} else {
[15002] Fix | Delete
selectionStart = selectionAnchor;
[15003] Fix | Delete
selectionEnd = selectionFocus;
[15004] Fix | Delete
}
[15005] Fix | Delete
const selectionA = selectionStart;
[15006] Fix | Delete
const selectionB = selectionEnd;
[15007] Fix | Delete
const blockA = select.getBlock(selectionA.clientId);
[15008] Fix | Delete
const blockB = select.getBlock(selectionB.clientId);
[15009] Fix | Delete
const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
[15010] Fix | Delete
const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
[15011] Fix | Delete
const attributeKeyA = typeof selectionA.attributeKey === 'string' ? selectionA.attributeKey : findRichTextAttributeKey(blockAType);
[15012] Fix | Delete
const attributeKeyB = typeof selectionB.attributeKey === 'string' ? selectionB.attributeKey : findRichTextAttributeKey(blockBType);
[15013] Fix | Delete
const blockAttributes = select.getBlockAttributes(selectionA.clientId);
[15014] Fix | Delete
const bindings = blockAttributes?.metadata?.bindings;
[15015] Fix | Delete
[15016] Fix | Delete
// If the attribute is bound, don't split the selection and insert a new block instead.
[15017] Fix | Delete
if (bindings?.[attributeKeyA]) {
[15018] Fix | Delete
// Show warning if user tries to insert a block into another block with bindings.
[15019] Fix | Delete
if (blocks.length) {
[15020] Fix | Delete
const {
[15021] Fix | Delete
createWarningNotice
[15022] Fix | Delete
} = registry.dispatch(external_wp_notices_namespaceObject.store);
[15023] Fix | Delete
createWarningNotice((0,external_wp_i18n_namespaceObject.__)("Blocks can't be inserted into other blocks with bindings"), {
[15024] Fix | Delete
type: 'snackbar'
[15025] Fix | Delete
});
[15026] Fix | Delete
return;
[15027] Fix | Delete
}
[15028] Fix | Delete
dispatch.insertAfterBlock(selectionA.clientId);
[15029] Fix | Delete
return;
[15030] Fix | Delete
}
[15031] Fix | Delete
[15032] Fix | Delete
// Can't split if the selection is not set.
[15033] Fix | Delete
if (!attributeKeyA || !attributeKeyB || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
[15034] Fix | Delete
return;
[15035] Fix | Delete
}
[15036] Fix | Delete
[15037] Fix | Delete
// We can do some short-circuiting if the selection is collapsed.
[15038] Fix | Delete
if (selectionA.clientId === selectionB.clientId && attributeKeyA === attributeKeyB && selectionA.offset === selectionB.offset) {
[15039] Fix | Delete
// If an unmodified default block is selected, replace it. We don't
[15040] Fix | Delete
// want to be converting into a default block.
[15041] Fix | Delete
if (blocks.length) {
[15042] Fix | Delete
if ((0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blockA)) {
[15043] Fix | Delete
dispatch.replaceBlocks([selectionA.clientId], blocks, blocks.length - 1, -1);
[15044] Fix | Delete
return;
[15045] Fix | Delete
}
[15046] Fix | Delete
}
[15047] Fix | Delete
[15048] Fix | Delete
// If selection is at the start or end, we can simply insert an
[15049] Fix | Delete
// empty block, provided this block has no inner blocks.
[15050] Fix | Delete
else if (!select.getBlockOrder(selectionA.clientId).length) {
[15051] Fix | Delete
function createEmpty() {
[15052] Fix | Delete
const defaultBlockName = (0,external_wp_blocks_namespaceObject.getDefaultBlockName)();
[15053] Fix | Delete
return select.canInsertBlockType(defaultBlockName, anchorRootClientId) ? (0,external_wp_blocks_namespaceObject.createBlock)(defaultBlockName) : (0,external_wp_blocks_namespaceObject.createBlock)(select.getBlockName(selectionA.clientId));
[15054] Fix | Delete
}
[15055] Fix | Delete
const length = blockAttributes[attributeKeyA].length;
[15056] Fix | Delete
if (selectionA.offset === 0 && length) {
[15057] Fix | Delete
dispatch.insertBlocks([createEmpty()], select.getBlockIndex(selectionA.clientId), anchorRootClientId, false);
[15058] Fix | Delete
return;
[15059] Fix | Delete
}
[15060] Fix | Delete
if (selectionA.offset === length) {
[15061] Fix | Delete
dispatch.insertBlocks([createEmpty()], select.getBlockIndex(selectionA.clientId) + 1, anchorRootClientId);
[15062] Fix | Delete
return;
[15063] Fix | Delete
}
[15064] Fix | Delete
}
[15065] Fix | Delete
}
[15066] Fix | Delete
const htmlA = blockA.attributes[attributeKeyA];
[15067] Fix | Delete
const htmlB = blockB.attributes[attributeKeyB];
[15068] Fix | Delete
let valueA = (0,external_wp_richText_namespaceObject.create)({
[15069] Fix | Delete
html: htmlA
[15070] Fix | Delete
});
[15071] Fix | Delete
let valueB = (0,external_wp_richText_namespaceObject.create)({
[15072] Fix | Delete
html: htmlB
[15073] Fix | Delete
});
[15074] Fix | Delete
valueA = (0,external_wp_richText_namespaceObject.remove)(valueA, selectionA.offset, valueA.text.length);
[15075] Fix | Delete
valueB = (0,external_wp_richText_namespaceObject.remove)(valueB, 0, selectionB.offset);
[15076] Fix | Delete
let head = {
[15077] Fix | Delete
// Preserve the original client ID.
[15078] Fix | Delete
...blockA,
[15079] Fix | Delete
// If both start and end are the same, should only copy innerBlocks
[15080] Fix | Delete
// once.
[15081] Fix | Delete
innerBlocks: blockA.clientId === blockB.clientId ? [] : blockA.innerBlocks,
[15082] Fix | Delete
attributes: {
[15083] Fix | Delete
...blockA.attributes,
[15084] Fix | Delete
[attributeKeyA]: (0,external_wp_richText_namespaceObject.toHTMLString)({
[15085] Fix | Delete
value: valueA
[15086] Fix | Delete
})
[15087] Fix | Delete
}
[15088] Fix | Delete
};
[15089] Fix | Delete
let tail = {
[15090] Fix | Delete
...blockB,
[15091] Fix | Delete
// Only preserve the original client ID if the end is different.
[15092] Fix | Delete
clientId: blockA.clientId === blockB.clientId ? (0,external_wp_blocks_namespaceObject.createBlock)(blockB.name).clientId : blockB.clientId,
[15093] Fix | Delete
attributes: {
[15094] Fix | Delete
...blockB.attributes,
[15095] Fix | Delete
[attributeKeyB]: (0,external_wp_richText_namespaceObject.toHTMLString)({
[15096] Fix | Delete
value: valueB
[15097] Fix | Delete
})
[15098] Fix | Delete
}
[15099] Fix | Delete
};
[15100] Fix | Delete
[15101] Fix | Delete
// When splitting a block, attempt to convert the tail block to the
[15102] Fix | Delete
// default block type. For example, when splitting a heading block, the
[15103] Fix | Delete
// tail block will be converted to a paragraph block. Note that for
[15104] Fix | Delete
// blocks such as a list item and button, this will be skipped because
[15105] Fix | Delete
// the default block type cannot be inserted.
[15106] Fix | Delete
const defaultBlockName = (0,external_wp_blocks_namespaceObject.getDefaultBlockName)();
[15107] Fix | Delete
if (
[15108] Fix | Delete
// A block is only split when the selection is within the same
[15109] Fix | Delete
// block.
[15110] Fix | Delete
blockA.clientId === blockB.clientId && defaultBlockName && tail.name !== defaultBlockName && select.canInsertBlockType(defaultBlockName, anchorRootClientId)) {
[15111] Fix | Delete
const switched = (0,external_wp_blocks_namespaceObject.switchToBlockType)(tail, defaultBlockName);
[15112] Fix | Delete
if (switched?.length === 1) {
[15113] Fix | Delete
tail = switched[0];
[15114] Fix | Delete
}
[15115] Fix | Delete
}
[15116] Fix | Delete
if (!blocks.length) {
[15117] Fix | Delete
dispatch.replaceBlocks(select.getSelectedBlockClientIds(), [head, tail]);
[15118] Fix | Delete
return;
[15119] Fix | Delete
}
[15120] Fix | Delete
let selection;
[15121] Fix | Delete
const output = [];
[15122] Fix | Delete
const clonedBlocks = [...blocks];
[15123] Fix | Delete
const firstBlock = clonedBlocks.shift();
[15124] Fix | Delete
const headType = (0,external_wp_blocks_namespaceObject.getBlockType)(head.name);
[15125] Fix | Delete
const firstBlocks = headType.merge && firstBlock.name === headType.name ? [firstBlock] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(firstBlock, headType.name);
[15126] Fix | Delete
if (firstBlocks?.length) {
[15127] Fix | Delete
const first = firstBlocks.shift();
[15128] Fix | Delete
head = {
[15129] Fix | Delete
...head,
[15130] Fix | Delete
attributes: {
[15131] Fix | Delete
...head.attributes,
[15132] Fix | Delete
...headType.merge(head.attributes, first.attributes)
[15133] Fix | Delete
}
[15134] Fix | Delete
};
[15135] Fix | Delete
output.push(head);
[15136] Fix | Delete
selection = {
[15137] Fix | Delete
clientId: head.clientId,
[15138] Fix | Delete
attributeKey: attributeKeyA,
[15139] Fix | Delete
offset: (0,external_wp_richText_namespaceObject.create)({
[15140] Fix | Delete
html: head.attributes[attributeKeyA]
[15141] Fix | Delete
}).text.length
[15142] Fix | Delete
};
[15143] Fix | Delete
clonedBlocks.unshift(...firstBlocks);
[15144] Fix | Delete
} else {
[15145] Fix | Delete
if (!(0,external_wp_blocks_namespaceObject.isUnmodifiedBlock)(head)) {
[15146] Fix | Delete
output.push(head);
[15147] Fix | Delete
}
[15148] Fix | Delete
output.push(firstBlock);
[15149] Fix | Delete
}
[15150] Fix | Delete
const lastBlock = clonedBlocks.pop();
[15151] Fix | Delete
const tailType = (0,external_wp_blocks_namespaceObject.getBlockType)(tail.name);
[15152] Fix | Delete
if (clonedBlocks.length) {
[15153] Fix | Delete
output.push(...clonedBlocks);
[15154] Fix | Delete
}
[15155] Fix | Delete
if (lastBlock) {
[15156] Fix | Delete
const lastBlocks = tailType.merge && tailType.name === lastBlock.name ? [lastBlock] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(lastBlock, tailType.name);
[15157] Fix | Delete
if (lastBlocks?.length) {
[15158] Fix | Delete
const last = lastBlocks.pop();
[15159] Fix | Delete
output.push({
[15160] Fix | Delete
...tail,
[15161] Fix | Delete
attributes: {
[15162] Fix | Delete
...tail.attributes,
[15163] Fix | Delete
...tailType.merge(last.attributes, tail.attributes)
[15164] Fix | Delete
}
[15165] Fix | Delete
});
[15166] Fix | Delete
output.push(...lastBlocks);
[15167] Fix | Delete
selection = {
[15168] Fix | Delete
clientId: tail.clientId,
[15169] Fix | Delete
attributeKey: attributeKeyB,
[15170] Fix | Delete
offset: (0,external_wp_richText_namespaceObject.create)({
[15171] Fix | Delete
html: last.attributes[attributeKeyB]
[15172] Fix | Delete
}).text.length
[15173] Fix | Delete
};
[15174] Fix | Delete
} else {
[15175] Fix | Delete
output.push(lastBlock);
[15176] Fix | Delete
if (!(0,external_wp_blocks_namespaceObject.isUnmodifiedBlock)(tail)) {
[15177] Fix | Delete
output.push(tail);
[15178] Fix | Delete
}
[15179] Fix | Delete
}
[15180] Fix | Delete
} else if (!(0,external_wp_blocks_namespaceObject.isUnmodifiedBlock)(tail)) {
[15181] Fix | Delete
output.push(tail);
[15182] Fix | Delete
}
[15183] Fix | Delete
registry.batch(() => {
[15184] Fix | Delete
dispatch.replaceBlocks(select.getSelectedBlockClientIds(), output, output.length - 1, 0);
[15185] Fix | Delete
if (selection) {
[15186] Fix | Delete
dispatch.selectionChange(selection.clientId, selection.attributeKey, selection.offset, selection.offset);
[15187] Fix | Delete
}
[15188] Fix | Delete
});
[15189] Fix | Delete
};
[15190] Fix | Delete
[15191] Fix | Delete
/**
[15192] Fix | Delete
* Expand the selection to cover the entire blocks, removing partial selection.
[15193] Fix | Delete
*/
[15194] Fix | Delete
const __unstableExpandSelection = () => ({
[15195] Fix | Delete
select,
[15196] Fix | Delete
dispatch
[15197] Fix | Delete
}) => {
[15198] Fix | Delete
const selectionAnchor = select.getSelectionStart();
[15199] Fix | Delete
const selectionFocus = select.getSelectionEnd();
[15200] Fix | Delete
dispatch.selectionChange({
[15201] Fix | Delete
start: {
[15202] Fix | Delete
clientId: selectionAnchor.clientId
[15203] Fix | Delete
},
[15204] Fix | Delete
end: {
[15205] Fix | Delete
clientId: selectionFocus.clientId
[15206] Fix | Delete
}
[15207] Fix | Delete
});
[15208] Fix | Delete
};
[15209] Fix | Delete
[15210] Fix | Delete
/**
[15211] Fix | Delete
* Action that merges two blocks.
[15212] Fix | Delete
*
[15213] Fix | Delete
* @param {string} firstBlockClientId Client ID of the first block to merge.
[15214] Fix | Delete
* @param {string} secondBlockClientId Client ID of the second block to merge.
[15215] Fix | Delete
*/
[15216] Fix | Delete
const mergeBlocks = (firstBlockClientId, secondBlockClientId) => ({
[15217] Fix | Delete
registry,
[15218] Fix | Delete
select,
[15219] Fix | Delete
dispatch
[15220] Fix | Delete
}) => {
[15221] Fix | Delete
const clientIdA = firstBlockClientId;
[15222] Fix | Delete
const clientIdB = secondBlockClientId;
[15223] Fix | Delete
const blockA = select.getBlock(clientIdA);
[15224] Fix | Delete
const blockAType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockA.name);
[15225] Fix | Delete
if (!blockAType) {
[15226] Fix | Delete
return;
[15227] Fix | Delete
}
[15228] Fix | Delete
const blockB = select.getBlock(clientIdB);
[15229] Fix | Delete
if (!blockAType.merge && (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockA.name, '__experimentalOnMerge')) {
[15230] Fix | Delete
// If there's no merge function defined, attempt merging inner
[15231] Fix | Delete
// blocks.
[15232] Fix | Delete
const blocksWithTheSameType = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blockB, blockAType.name);
[15233] Fix | Delete
// Only focus the previous block if it's not mergeable.
[15234] Fix | Delete
if (blocksWithTheSameType?.length !== 1) {
[15235] Fix | Delete
dispatch.selectBlock(blockA.clientId);
[15236] Fix | Delete
return;
[15237] Fix | Delete
}
[15238] Fix | Delete
const [blockWithSameType] = blocksWithTheSameType;
[15239] Fix | Delete
if (blockWithSameType.innerBlocks.length < 1) {
[15240] Fix | Delete
dispatch.selectBlock(blockA.clientId);
[15241] Fix | Delete
return;
[15242] Fix | Delete
}
[15243] Fix | Delete
registry.batch(() => {
[15244] Fix | Delete
dispatch.insertBlocks(blockWithSameType.innerBlocks, undefined, clientIdA);
[15245] Fix | Delete
dispatch.removeBlock(clientIdB);
[15246] Fix | Delete
dispatch.selectBlock(blockWithSameType.innerBlocks[0].clientId);
[15247] Fix | Delete
[15248] Fix | Delete
// Attempt to merge the next block if it's the same type and
[15249] Fix | Delete
// same attributes. This is useful when merging a paragraph into
[15250] Fix | Delete
// a list, and the next block is also a list. If we don't merge,
[15251] Fix | Delete
// it looks like one list, but it's actually two lists. The same
[15252] Fix | Delete
// applies to other blocks such as a group with the same
[15253] Fix | Delete
// attributes.
[15254] Fix | Delete
const nextBlockClientId = select.getNextBlockClientId(clientIdA);
[15255] Fix | Delete
if (nextBlockClientId && select.getBlockName(clientIdA) === select.getBlockName(nextBlockClientId)) {
[15256] Fix | Delete
const rootAttributes = select.getBlockAttributes(clientIdA);
[15257] Fix | Delete
const previousRootAttributes = select.getBlockAttributes(nextBlockClientId);
[15258] Fix | Delete
if (Object.keys(rootAttributes).every(key => rootAttributes[key] === previousRootAttributes[key])) {
[15259] Fix | Delete
dispatch.moveBlocksToPosition(select.getBlockOrder(nextBlockClientId), nextBlockClientId, clientIdA);
[15260] Fix | Delete
dispatch.removeBlock(nextBlockClientId, false);
[15261] Fix | Delete
}
[15262] Fix | Delete
}
[15263] Fix | Delete
});
[15264] Fix | Delete
return;
[15265] Fix | Delete
}
[15266] Fix | Delete
if ((0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blockA)) {
[15267] Fix | Delete
dispatch.removeBlock(clientIdA, select.isBlockSelected(clientIdA));
[15268] Fix | Delete
return;
[15269] Fix | Delete
}
[15270] Fix | Delete
if ((0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blockB)) {
[15271] Fix | Delete
dispatch.removeBlock(clientIdB, select.isBlockSelected(clientIdB));
[15272] Fix | Delete
return;
[15273] Fix | Delete
}
[15274] Fix | Delete
if (!blockAType.merge) {
[15275] Fix | Delete
dispatch.selectBlock(blockA.clientId);
[15276] Fix | Delete
return;
[15277] Fix | Delete
}
[15278] Fix | Delete
const blockBType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockB.name);
[15279] Fix | Delete
const {
[15280] Fix | Delete
clientId,
[15281] Fix | Delete
attributeKey,
[15282] Fix | Delete
offset
[15283] Fix | Delete
} = select.getSelectionStart();
[15284] Fix | Delete
const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
[15285] Fix | Delete
const attributeDefinition = selectedBlockType.attributes[attributeKey];
[15286] Fix | Delete
const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined &&
[15287] Fix | Delete
// We cannot restore text selection if the RichText identifier
[15288] Fix | Delete
// is not a defined block attribute key. This can be the case if the
[15289] Fix | Delete
// fallback intance ID is used to store selection (and no RichText
[15290] Fix | Delete
// identifier is set), or when the identifier is wrong.
[15291] Fix | Delete
!!attributeDefinition;
[15292] Fix | Delete
if (!attributeDefinition) {
[15293] Fix | Delete
if (typeof attributeKey === 'number') {
[15294] Fix | Delete
window.console.error(`RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was ${typeof attributeKey}`);
[15295] Fix | Delete
} else {
[15296] Fix | Delete
window.console.error('The RichText identifier prop does not match any attributes defined by the block.');
[15297] Fix | Delete
}
[15298] Fix | Delete
}
[15299] Fix | Delete
[15300] Fix | Delete
// Clone the blocks so we don't insert the character in a "live" block.
[15301] Fix | Delete
const cloneA = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockA);
[15302] Fix | Delete
const cloneB = (0,external_wp_blocks_namespaceObject.cloneBlock)(blockB);
[15303] Fix | Delete
if (canRestoreTextSelection) {
[15304] Fix | Delete
const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
[15305] Fix | Delete
const html = selectedBlock.attributes[attributeKey];
[15306] Fix | Delete
const value = (0,external_wp_richText_namespaceObject.insert)((0,external_wp_richText_namespaceObject.create)({
[15307] Fix | Delete
html
[15308] Fix | Delete
}), START_OF_SELECTED_AREA, offset, offset);
[15309] Fix | Delete
selectedBlock.attributes[attributeKey] = (0,external_wp_richText_namespaceObject.toHTMLString)({
[15310] Fix | Delete
value
[15311] Fix | Delete
});
[15312] Fix | Delete
}
[15313] Fix | Delete
[15314] Fix | Delete
// We can only merge blocks with similar types
[15315] Fix | Delete
// thus, we transform the block to merge first.
[15316] Fix | Delete
const blocksWithTheSameType = blockA.name === blockB.name ? [cloneB] : (0,external_wp_blocks_namespaceObject.switchToBlockType)(cloneB, blockA.name);
[15317] Fix | Delete
[15318] Fix | Delete
// If the block types can not match, do nothing.
[15319] Fix | Delete
if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
[15320] Fix | Delete
return;
[15321] Fix | Delete
}
[15322] Fix | Delete
[15323] Fix | Delete
// Calling the merge to update the attributes and remove the block to be merged.
[15324] Fix | Delete
const updatedAttributes = blockAType.merge(cloneA.attributes, blocksWithTheSameType[0].attributes);
[15325] Fix | Delete
if (canRestoreTextSelection) {
[15326] Fix | Delete
const newAttributeKey = retrieveSelectedAttribute(updatedAttributes);
[15327] Fix | Delete
const convertedHtml = updatedAttributes[newAttributeKey];
[15328] Fix | Delete
const convertedValue = (0,external_wp_richText_namespaceObject.create)({
[15329] Fix | Delete
html: convertedHtml
[15330] Fix | Delete
});
[15331] Fix | Delete
const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
[15332] Fix | Delete
const newValue = (0,external_wp_richText_namespaceObject.remove)(convertedValue, newOffset, newOffset + 1);
[15333] Fix | Delete
const newHtml = (0,external_wp_richText_namespaceObject.toHTMLString)({
[15334] Fix | Delete
value: newValue
[15335] Fix | Delete
});
[15336] Fix | Delete
updatedAttributes[newAttributeKey] = newHtml;
[15337] Fix | Delete
dispatch.selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
[15338] Fix | Delete
}
[15339] Fix | Delete
dispatch.replaceBlocks([blockA.clientId, blockB.clientId], [{
[15340] Fix | Delete
...blockA,
[15341] Fix | Delete
attributes: {
[15342] Fix | Delete
...blockA.attributes,
[15343] Fix | Delete
...updatedAttributes
[15344] Fix | Delete
}
[15345] Fix | Delete
}, ...blocksWithTheSameType.slice(1)], 0 // If we don't pass the `indexToSelect` it will default to the last block.
[15346] Fix | Delete
);
[15347] Fix | Delete
};
[15348] Fix | Delete
[15349] Fix | Delete
/**
[15350] Fix | Delete
* Yields action objects used in signalling that the blocks corresponding to
[15351] Fix | Delete
* the set of specified client IDs are to be removed.
[15352] Fix | Delete
*
[15353] Fix | Delete
* @param {string|string[]} clientIds Client IDs of blocks to remove.
[15354] Fix | Delete
* @param {boolean} selectPrevious True if the previous block
[15355] Fix | Delete
* or the immediate parent
[15356] Fix | Delete
* (if no previous block exists)
[15357] Fix | Delete
* should be selected
[15358] Fix | Delete
* when a block is removed.
[15359] Fix | Delete
*/
[15360] Fix | Delete
const removeBlocks = (clientIds, selectPrevious = true) => privateRemoveBlocks(clientIds, selectPrevious);
[15361] Fix | Delete
[15362] Fix | Delete
/**
[15363] Fix | Delete
* Returns an action object used in signalling that the block with the
[15364] Fix | Delete
* specified client ID is to be removed.
[15365] Fix | Delete
*
[15366] Fix | Delete
* @param {string} clientId Client ID of block to remove.
[15367] Fix | Delete
* @param {boolean} selectPrevious True if the previous block should be
[15368] Fix | Delete
* selected when a block is removed.
[15369] Fix | Delete
*
[15370] Fix | Delete
* @return {Object} Action object.
[15371] Fix | Delete
*/
[15372] Fix | Delete
function removeBlock(clientId, selectPrevious) {
[15373] Fix | Delete
return removeBlocks([clientId], selectPrevious);
[15374] Fix | Delete
}
[15375] Fix | Delete
[15376] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[15377] Fix | Delete
/**
[15378] Fix | Delete
* Returns an action object used in signalling that the inner blocks with the
[15379] Fix | Delete
* specified client ID should be replaced.
[15380] Fix | Delete
*
[15381] Fix | Delete
* @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced.
[15382] Fix | Delete
* @param {Object[]} blocks Block objects to insert as new InnerBlocks
[15383] Fix | Delete
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to false.
[15384] Fix | Delete
* @param {0|-1|null} initialPosition Initial block position.
[15385] Fix | Delete
* @return {Object} Action object.
[15386] Fix | Delete
*/
[15387] Fix | Delete
function replaceInnerBlocks(rootClientId, blocks, updateSelection = false, initialPosition = 0) {
[15388] Fix | Delete
/* eslint-enable jsdoc/valid-types */
[15389] Fix | Delete
return {
[15390] Fix | Delete
type: 'REPLACE_INNER_BLOCKS',
[15391] Fix | Delete
rootClientId,
[15392] Fix | Delete
blocks,
[15393] Fix | Delete
updateSelection,
[15394] Fix | Delete
initialPosition: updateSelection ? initialPosition : null,
[15395] Fix | Delete
time: Date.now()
[15396] Fix | Delete
};
[15397] Fix | Delete
}
[15398] Fix | Delete
[15399] Fix | Delete
/**
[15400] Fix | Delete
* Returns an action object used to toggle the block editing mode between
[15401] Fix | Delete
* visual and HTML modes.
[15402] Fix | Delete
*
[15403] Fix | Delete
* @param {string} clientId Block client ID.
[15404] Fix | Delete
*
[15405] Fix | Delete
* @return {Object} Action object.
[15406] Fix | Delete
*/
[15407] Fix | Delete
function toggleBlockMode(clientId) {
[15408] Fix | Delete
return {
[15409] Fix | Delete
type: 'TOGGLE_BLOCK_MODE',
[15410] Fix | Delete
clientId
[15411] Fix | Delete
};
[15412] Fix | Delete
}
[15413] Fix | Delete
[15414] Fix | Delete
/**
[15415] Fix | Delete
* Returns an action object used in signalling that the user has begun to type.
[15416] Fix | Delete
*
[15417] Fix | Delete
* @return {Object} Action object.
[15418] Fix | Delete
*/
[15419] Fix | Delete
function startTyping() {
[15420] Fix | Delete
return {
[15421] Fix | Delete
type: 'START_TYPING'
[15422] Fix | Delete
};
[15423] Fix | Delete
}
[15424] Fix | Delete
[15425] Fix | Delete
/**
[15426] Fix | Delete
* Returns an action object used in signalling that the user has stopped typing.
[15427] Fix | Delete
*
[15428] Fix | Delete
* @return {Object} Action object.
[15429] Fix | Delete
*/
[15430] Fix | Delete
function stopTyping() {
[15431] Fix | Delete
return {
[15432] Fix | Delete
type: 'STOP_TYPING'
[15433] Fix | Delete
};
[15434] Fix | Delete
}
[15435] Fix | Delete
[15436] Fix | Delete
/**
[15437] Fix | Delete
* Returns an action object used in signalling that the user has begun to drag blocks.
[15438] Fix | Delete
*
[15439] Fix | Delete
* @param {string[]} clientIds An array of client ids being dragged
[15440] Fix | Delete
*
[15441] Fix | Delete
* @return {Object} Action object.
[15442] Fix | Delete
*/
[15443] Fix | Delete
function startDraggingBlocks(clientIds = []) {
[15444] Fix | Delete
return {
[15445] Fix | Delete
type: 'START_DRAGGING_BLOCKS',
[15446] Fix | Delete
clientIds
[15447] Fix | Delete
};
[15448] Fix | Delete
}
[15449] Fix | Delete
[15450] Fix | Delete
/**
[15451] Fix | Delete
* Returns an action object used in signalling that the user has stopped dragging blocks.
[15452] Fix | Delete
*
[15453] Fix | Delete
* @return {Object} Action object.
[15454] Fix | Delete
*/
[15455] Fix | Delete
function stopDraggingBlocks() {
[15456] Fix | Delete
return {
[15457] Fix | Delete
type: 'STOP_DRAGGING_BLOCKS'
[15458] Fix | Delete
};
[15459] Fix | Delete
}
[15460] Fix | Delete
[15461] Fix | Delete
/**
[15462] Fix | Delete
* Returns an action object used in signalling that the caret has entered formatted text.
[15463] Fix | Delete
*
[15464] Fix | Delete
* @deprecated
[15465] Fix | Delete
*
[15466] Fix | Delete
* @return {Object} Action object.
[15467] Fix | Delete
*/
[15468] Fix | Delete
function enterFormattedText() {
[15469] Fix | Delete
external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).enterFormattedText', {
[15470] Fix | Delete
since: '6.1',
[15471] Fix | Delete
version: '6.3'
[15472] Fix | Delete
});
[15473] Fix | Delete
return {
[15474] Fix | Delete
type: 'DO_NOTHING'
[15475] Fix | Delete
};
[15476] Fix | Delete
}
[15477] Fix | Delete
[15478] Fix | Delete
/**
[15479] Fix | Delete
* Returns an action object used in signalling that the user caret has exited formatted text.
[15480] Fix | Delete
*
[15481] Fix | Delete
* @deprecated
[15482] Fix | Delete
*
[15483] Fix | Delete
* @return {Object} Action object.
[15484] Fix | Delete
*/
[15485] Fix | Delete
function exitFormattedText() {
[15486] Fix | Delete
external_wp_deprecated_default()('wp.data.dispatch( "core/block-editor" ).exitFormattedText', {
[15487] Fix | Delete
since: '6.1',
[15488] Fix | Delete
version: '6.3'
[15489] Fix | Delete
});
[15490] Fix | Delete
return {
[15491] Fix | Delete
type: 'DO_NOTHING'
[15492] Fix | Delete
};
[15493] Fix | Delete
}
[15494] Fix | Delete
[15495] Fix | Delete
/**
[15496] Fix | Delete
* Action that changes the position of the user caret.
[15497] Fix | Delete
*
[15498] Fix | Delete
* @param {string|WPSelection} clientId The selected block client ID.
[15499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function