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
* @param {Object} state Global application state.
[13500] Fix | Delete
* @param {string} clientId The block to check.
[13501] Fix | Delete
*
[13502] Fix | Delete
* @return {boolean} True if the block has controlled inner blocks.
[13503] Fix | Delete
*/
[13504] Fix | Delete
function areInnerBlocksControlled(state, clientId) {
[13505] Fix | Delete
return !!state.blocks.controlledInnerBlocks[clientId];
[13506] Fix | Delete
}
[13507] Fix | Delete
[13508] Fix | Delete
/**
[13509] Fix | Delete
* Returns the clientId for the first 'active' block of a given array of block names.
[13510] Fix | Delete
* A block is 'active' if it (or a child) is the selected block.
[13511] Fix | Delete
* Returns the first match moving up the DOM from the selected block.
[13512] Fix | Delete
*
[13513] Fix | Delete
* @param {Object} state Global application state.
[13514] Fix | Delete
* @param {string[]} validBlocksNames The names of block types to check for.
[13515] Fix | Delete
*
[13516] Fix | Delete
* @return {string} The matching block's clientId.
[13517] Fix | Delete
*/
[13518] Fix | Delete
const __experimentalGetActiveBlockIdByBlockNames = (0,external_wp_data_namespaceObject.createSelector)((state, validBlockNames) => {
[13519] Fix | Delete
if (!validBlockNames.length) {
[13520] Fix | Delete
return null;
[13521] Fix | Delete
}
[13522] Fix | Delete
// Check if selected block is a valid entity area.
[13523] Fix | Delete
const selectedBlockClientId = getSelectedBlockClientId(state);
[13524] Fix | Delete
if (validBlockNames.includes(getBlockName(state, selectedBlockClientId))) {
[13525] Fix | Delete
return selectedBlockClientId;
[13526] Fix | Delete
}
[13527] Fix | Delete
// Check if first selected block is a child of a valid entity area.
[13528] Fix | Delete
const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state);
[13529] Fix | Delete
const entityAreaParents = getBlockParentsByBlockName(state, selectedBlockClientId || multiSelectedBlockClientIds[0], validBlockNames);
[13530] Fix | Delete
if (entityAreaParents) {
[13531] Fix | Delete
// Last parent closest/most interior.
[13532] Fix | Delete
return entityAreaParents[entityAreaParents.length - 1];
[13533] Fix | Delete
}
[13534] Fix | Delete
return null;
[13535] Fix | Delete
}, (state, validBlockNames) => [state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId, validBlockNames]);
[13536] Fix | Delete
[13537] Fix | Delete
/**
[13538] Fix | Delete
* Tells if the block with the passed clientId was just inserted.
[13539] Fix | Delete
*
[13540] Fix | Delete
* @param {Object} state Global application state.
[13541] Fix | Delete
* @param {Object} clientId Client Id of the block.
[13542] Fix | Delete
* @param {?string} source Optional insertion source of the block.
[13543] Fix | Delete
* @return {boolean} True if the block matches the last block inserted from the specified source.
[13544] Fix | Delete
*/
[13545] Fix | Delete
function wasBlockJustInserted(state, clientId, source) {
[13546] Fix | Delete
const {
[13547] Fix | Delete
lastBlockInserted
[13548] Fix | Delete
} = state;
[13549] Fix | Delete
return lastBlockInserted.clientIds?.includes(clientId) && lastBlockInserted.source === source;
[13550] Fix | Delete
}
[13551] Fix | Delete
[13552] Fix | Delete
/**
[13553] Fix | Delete
* Tells if the block is visible on the canvas or not.
[13554] Fix | Delete
*
[13555] Fix | Delete
* @param {Object} state Global application state.
[13556] Fix | Delete
* @param {Object} clientId Client Id of the block.
[13557] Fix | Delete
* @return {boolean} True if the block is visible.
[13558] Fix | Delete
*/
[13559] Fix | Delete
function isBlockVisible(state, clientId) {
[13560] Fix | Delete
var _state$blockVisibilit;
[13561] Fix | Delete
return (_state$blockVisibilit = state.blockVisibility?.[clientId]) !== null && _state$blockVisibilit !== void 0 ? _state$blockVisibilit : true;
[13562] Fix | Delete
}
[13563] Fix | Delete
[13564] Fix | Delete
/**
[13565] Fix | Delete
* Returns the list of all hidden blocks.
[13566] Fix | Delete
*
[13567] Fix | Delete
* @param {Object} state Global application state.
[13568] Fix | Delete
* @return {[string]} List of hidden blocks.
[13569] Fix | Delete
*/
[13570] Fix | Delete
const __unstableGetVisibleBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
[13571] Fix | Delete
const visibleBlocks = new Set(Object.keys(state.blockVisibility).filter(key => state.blockVisibility[key]));
[13572] Fix | Delete
if (visibleBlocks.size === 0) {
[13573] Fix | Delete
return EMPTY_SET;
[13574] Fix | Delete
}
[13575] Fix | Delete
return visibleBlocks;
[13576] Fix | Delete
}, state => [state.blockVisibility]);
[13577] Fix | Delete
function __unstableHasActiveBlockOverlayActive(state, clientId) {
[13578] Fix | Delete
// Prevent overlay on blocks with a non-default editing mode. If the mdoe is
[13579] Fix | Delete
// 'disabled' then the overlay is redundant since the block can't be
[13580] Fix | Delete
// selected. If the mode is 'contentOnly' then the overlay is redundant
[13581] Fix | Delete
// since there will be no controls to interact with once selected.
[13582] Fix | Delete
if (getBlockEditingMode(state, clientId) !== 'default') {
[13583] Fix | Delete
return false;
[13584] Fix | Delete
}
[13585] Fix | Delete
[13586] Fix | Delete
// If the block editing is locked, the block overlay is always active.
[13587] Fix | Delete
if (!canEditBlock(state, clientId)) {
[13588] Fix | Delete
return true;
[13589] Fix | Delete
}
[13590] Fix | Delete
const editorMode = __unstableGetEditorMode(state);
[13591] Fix | Delete
[13592] Fix | Delete
// In zoom-out mode, the block overlay is always active for section level blocks.
[13593] Fix | Delete
if (editorMode === 'zoom-out') {
[13594] Fix | Delete
const {
[13595] Fix | Delete
sectionRootClientId
[13596] Fix | Delete
} = unlock(getSettings(state));
[13597] Fix | Delete
if (sectionRootClientId) {
[13598] Fix | Delete
const sectionClientIds = getBlockOrder(state, sectionRootClientId);
[13599] Fix | Delete
if (sectionClientIds?.includes(clientId)) {
[13600] Fix | Delete
return true;
[13601] Fix | Delete
}
[13602] Fix | Delete
} else if (clientId && !getBlockRootClientId(state, clientId)) {
[13603] Fix | Delete
return true;
[13604] Fix | Delete
}
[13605] Fix | Delete
}
[13606] Fix | Delete
[13607] Fix | Delete
// In navigation mode, the block overlay is active when the block is not
[13608] Fix | Delete
// selected (and doesn't contain a selected child). The same behavior is
[13609] Fix | Delete
// also enabled in all modes for blocks that have controlled children
[13610] Fix | Delete
// (reusable block, template part, navigation), unless explicitly disabled
[13611] Fix | Delete
// with `supports.__experimentalDisableBlockOverlay`.
[13612] Fix | Delete
const blockSupportDisable = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(getBlockName(state, clientId), '__experimentalDisableBlockOverlay', false);
[13613] Fix | Delete
const shouldEnableIfUnselected = editorMode === 'navigation' || (blockSupportDisable ? false : areInnerBlocksControlled(state, clientId));
[13614] Fix | Delete
return shouldEnableIfUnselected && !isBlockSelected(state, clientId) && !hasSelectedInnerBlock(state, clientId, true);
[13615] Fix | Delete
}
[13616] Fix | Delete
function __unstableIsWithinBlockOverlay(state, clientId) {
[13617] Fix | Delete
let parent = state.blocks.parents.get(clientId);
[13618] Fix | Delete
while (!!parent) {
[13619] Fix | Delete
if (__unstableHasActiveBlockOverlayActive(state, parent)) {
[13620] Fix | Delete
return true;
[13621] Fix | Delete
}
[13622] Fix | Delete
parent = state.blocks.parents.get(parent);
[13623] Fix | Delete
}
[13624] Fix | Delete
return false;
[13625] Fix | Delete
}
[13626] Fix | Delete
[13627] Fix | Delete
/**
[13628] Fix | Delete
* @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode
[13629] Fix | Delete
*/
[13630] Fix | Delete
[13631] Fix | Delete
/**
[13632] Fix | Delete
* Returns the block editing mode for a given block.
[13633] Fix | Delete
*
[13634] Fix | Delete
* The mode can be one of three options:
[13635] Fix | Delete
*
[13636] Fix | Delete
* - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be
[13637] Fix | Delete
* selected.
[13638] Fix | Delete
* - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the
[13639] Fix | Delete
* toolbar, the block movers, block settings.
[13640] Fix | Delete
* - `'default'`: Allows editing the block as normal.
[13641] Fix | Delete
*
[13642] Fix | Delete
* Blocks can set a mode using the `useBlockEditingMode` hook.
[13643] Fix | Delete
*
[13644] Fix | Delete
* The mode is inherited by all of the block's inner blocks, unless they have
[13645] Fix | Delete
* their own mode.
[13646] Fix | Delete
*
[13647] Fix | Delete
* A template lock can also set a mode. If the template lock is `'contentOnly'`,
[13648] Fix | Delete
* the block's mode is overridden to `'contentOnly'` if the block has a content
[13649] Fix | Delete
* role attribute, or `'disabled'` otherwise.
[13650] Fix | Delete
*
[13651] Fix | Delete
* @see useBlockEditingMode
[13652] Fix | Delete
*
[13653] Fix | Delete
* @param {Object} state Global application state.
[13654] Fix | Delete
* @param {string} clientId The block client ID, or `''` for the root container.
[13655] Fix | Delete
*
[13656] Fix | Delete
* @return {BlockEditingMode} The block editing mode. One of `'disabled'`,
[13657] Fix | Delete
* `'contentOnly'`, or `'default'`.
[13658] Fix | Delete
*/
[13659] Fix | Delete
const getBlockEditingMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, clientId = '') => {
[13660] Fix | Delete
// Some selectors that call this provide `null` as the default
[13661] Fix | Delete
// rootClientId, but the default rootClientId is actually `''`.
[13662] Fix | Delete
if (clientId === null) {
[13663] Fix | Delete
clientId = '';
[13664] Fix | Delete
}
[13665] Fix | Delete
// In zoom-out mode, override the behavior set by
[13666] Fix | Delete
// __unstableSetBlockEditingMode to only allow editing the top-level
[13667] Fix | Delete
// sections.
[13668] Fix | Delete
const editorMode = __unstableGetEditorMode(state);
[13669] Fix | Delete
if (editorMode === 'zoom-out') {
[13670] Fix | Delete
const {
[13671] Fix | Delete
sectionRootClientId
[13672] Fix | Delete
} = unlock(getSettings(state));
[13673] Fix | Delete
if (clientId === '' /* ROOT_CONTAINER_CLIENT_ID */) {
[13674] Fix | Delete
return sectionRootClientId ? 'disabled' : 'contentOnly';
[13675] Fix | Delete
}
[13676] Fix | Delete
if (clientId === sectionRootClientId) {
[13677] Fix | Delete
return 'contentOnly';
[13678] Fix | Delete
}
[13679] Fix | Delete
const sectionsClientIds = getBlockOrder(state, sectionRootClientId);
[13680] Fix | Delete
if (!sectionsClientIds?.includes(clientId)) {
[13681] Fix | Delete
return 'disabled';
[13682] Fix | Delete
}
[13683] Fix | Delete
}
[13684] Fix | Delete
const blockEditingMode = state.blockEditingModes.get(clientId);
[13685] Fix | Delete
if (blockEditingMode) {
[13686] Fix | Delete
return blockEditingMode;
[13687] Fix | Delete
}
[13688] Fix | Delete
if (!clientId) {
[13689] Fix | Delete
return 'default';
[13690] Fix | Delete
}
[13691] Fix | Delete
const rootClientId = getBlockRootClientId(state, clientId);
[13692] Fix | Delete
const templateLock = getTemplateLock(state, rootClientId);
[13693] Fix | Delete
if (templateLock === 'contentOnly') {
[13694] Fix | Delete
const name = getBlockName(state, clientId);
[13695] Fix | Delete
const isContent = select(external_wp_blocks_namespaceObject.store).__experimentalHasContentRoleAttribute(name);
[13696] Fix | Delete
return isContent ? 'contentOnly' : 'disabled';
[13697] Fix | Delete
}
[13698] Fix | Delete
const parentMode = getBlockEditingMode(state, rootClientId);
[13699] Fix | Delete
return parentMode === 'contentOnly' ? 'default' : parentMode;
[13700] Fix | Delete
});
[13701] Fix | Delete
[13702] Fix | Delete
/**
[13703] Fix | Delete
* Indicates if a block is ungroupable.
[13704] Fix | Delete
* A block is ungroupable if it is a single grouping block with inner blocks.
[13705] Fix | Delete
* If a block has an `ungroup` transform, it is also ungroupable, without the
[13706] Fix | Delete
* requirement of being the default grouping block.
[13707] Fix | Delete
* Additionally a block can only be ungrouped if it has inner blocks and can
[13708] Fix | Delete
* be removed.
[13709] Fix | Delete
*
[13710] Fix | Delete
* @param {Object} state Global application state.
[13711] Fix | Delete
* @param {string} clientId Client Id of the block. If not passed the selected block's client id will be used.
[13712] Fix | Delete
* @return {boolean} True if the block is ungroupable.
[13713] Fix | Delete
*/
[13714] Fix | Delete
const isUngroupable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, clientId = '') => {
[13715] Fix | Delete
const _clientId = clientId || getSelectedBlockClientId(state);
[13716] Fix | Delete
if (!_clientId) {
[13717] Fix | Delete
return false;
[13718] Fix | Delete
}
[13719] Fix | Delete
const {
[13720] Fix | Delete
getGroupingBlockName
[13721] Fix | Delete
} = select(external_wp_blocks_namespaceObject.store);
[13722] Fix | Delete
const block = getBlock(state, _clientId);
[13723] Fix | Delete
const groupingBlockName = getGroupingBlockName();
[13724] Fix | Delete
const _isUngroupable = block && (block.name === groupingBlockName || (0,external_wp_blocks_namespaceObject.getBlockType)(block.name)?.transforms?.ungroup) && !!block.innerBlocks.length;
[13725] Fix | Delete
return _isUngroupable && canRemoveBlock(state, _clientId);
[13726] Fix | Delete
});
[13727] Fix | Delete
[13728] Fix | Delete
/**
[13729] Fix | Delete
* Indicates if the provided blocks(by client ids) are groupable.
[13730] Fix | Delete
* We need to have at least one block, have a grouping block name set and
[13731] Fix | Delete
* be able to remove these blocks.
[13732] Fix | Delete
*
[13733] Fix | Delete
* @param {Object} state Global application state.
[13734] Fix | Delete
* @param {string[]} clientIds Block client ids. If not passed the selected blocks client ids will be used.
[13735] Fix | Delete
* @return {boolean} True if the blocks are groupable.
[13736] Fix | Delete
*/
[13737] Fix | Delete
const isGroupable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, clientIds = selectors_EMPTY_ARRAY) => {
[13738] Fix | Delete
const {
[13739] Fix | Delete
getGroupingBlockName
[13740] Fix | Delete
} = select(external_wp_blocks_namespaceObject.store);
[13741] Fix | Delete
const groupingBlockName = getGroupingBlockName();
[13742] Fix | Delete
const _clientIds = clientIds?.length ? clientIds : getSelectedBlockClientIds(state);
[13743] Fix | Delete
const rootClientId = _clientIds?.length ? getBlockRootClientId(state, _clientIds[0]) : undefined;
[13744] Fix | Delete
const groupingBlockAvailable = canInsertBlockType(state, groupingBlockName, rootClientId);
[13745] Fix | Delete
const _isGroupable = groupingBlockAvailable && _clientIds.length;
[13746] Fix | Delete
return _isGroupable && canRemoveBlocks(state, _clientIds);
[13747] Fix | Delete
});
[13748] Fix | Delete
[13749] Fix | Delete
/**
[13750] Fix | Delete
* DO-NOT-USE in production.
[13751] Fix | Delete
* This selector is created for internal/experimental only usage and may be
[13752] Fix | Delete
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
[13753] Fix | Delete
*
[13754] Fix | Delete
* @deprecated
[13755] Fix | Delete
*
[13756] Fix | Delete
* @param {Object} state Global application state.
[13757] Fix | Delete
* @param {Object} clientId Client Id of the block.
[13758] Fix | Delete
*
[13759] Fix | Delete
* @return {?string} Client ID of the ancestor block that is content locking the block.
[13760] Fix | Delete
*/
[13761] Fix | Delete
const __unstableGetContentLockingParent = (state, clientId) => {
[13762] Fix | Delete
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetContentLockingParent", {
[13763] Fix | Delete
since: '6.1',
[13764] Fix | Delete
version: '6.7'
[13765] Fix | Delete
});
[13766] Fix | Delete
return getContentLockingParent(state, clientId);
[13767] Fix | Delete
};
[13768] Fix | Delete
[13769] Fix | Delete
/**
[13770] Fix | Delete
* DO-NOT-USE in production.
[13771] Fix | Delete
* This selector is created for internal/experimental only usage and may be
[13772] Fix | Delete
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
[13773] Fix | Delete
*
[13774] Fix | Delete
* @deprecated
[13775] Fix | Delete
*
[13776] Fix | Delete
* @param {Object} state Global application state.
[13777] Fix | Delete
*/
[13778] Fix | Delete
function __unstableGetTemporarilyEditingAsBlocks(state) {
[13779] Fix | Delete
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetTemporarilyEditingAsBlocks", {
[13780] Fix | Delete
since: '6.1',
[13781] Fix | Delete
version: '6.7'
[13782] Fix | Delete
});
[13783] Fix | Delete
return getTemporarilyEditingAsBlocks(state);
[13784] Fix | Delete
}
[13785] Fix | Delete
[13786] Fix | Delete
/**
[13787] Fix | Delete
* DO-NOT-USE in production.
[13788] Fix | Delete
* This selector is created for internal/experimental only usage and may be
[13789] Fix | Delete
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
[13790] Fix | Delete
*
[13791] Fix | Delete
* @deprecated
[13792] Fix | Delete
*
[13793] Fix | Delete
* @param {Object} state Global application state.
[13794] Fix | Delete
*/
[13795] Fix | Delete
function __unstableGetTemporarilyEditingFocusModeToRevert(state) {
[13796] Fix | Delete
external_wp_deprecated_default()("wp.data.select( 'core/block-editor' ).__unstableGetTemporarilyEditingFocusModeToRevert", {
[13797] Fix | Delete
since: '6.5',
[13798] Fix | Delete
version: '6.7'
[13799] Fix | Delete
});
[13800] Fix | Delete
return getTemporarilyEditingFocusModeToRevert(state);
[13801] Fix | Delete
}
[13802] Fix | Delete
[13803] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/undo-ignore.js
[13804] Fix | Delete
// Keep track of the blocks that should not be pushing an additional
[13805] Fix | Delete
// undo stack when editing the entity.
[13806] Fix | Delete
// See the implementation of `syncDerivedUpdates` and `useBlockSync`.
[13807] Fix | Delete
const undoIgnoreBlocks = new WeakSet();
[13808] Fix | Delete
[13809] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/private-actions.js
[13810] Fix | Delete
/**
[13811] Fix | Delete
* WordPress dependencies
[13812] Fix | Delete
*/
[13813] Fix | Delete
[13814] Fix | Delete
[13815] Fix | Delete
/**
[13816] Fix | Delete
* Internal dependencies
[13817] Fix | Delete
*/
[13818] Fix | Delete
[13819] Fix | Delete
[13820] Fix | Delete
[13821] Fix | Delete
const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
[13822] Fix | Delete
[13823] Fix | Delete
/**
[13824] Fix | Delete
* A list of private/experimental block editor settings that
[13825] Fix | Delete
* should not become a part of the WordPress public API.
[13826] Fix | Delete
* BlockEditorProvider will remove these settings from the
[13827] Fix | Delete
* settings object it receives.
[13828] Fix | Delete
*
[13829] Fix | Delete
* @see https://github.com/WordPress/gutenberg/pull/46131
[13830] Fix | Delete
*/
[13831] Fix | Delete
const privateSettings = ['inserterMediaCategories', 'blockInspectorAnimation'];
[13832] Fix | Delete
[13833] Fix | Delete
/**
[13834] Fix | Delete
* Action that updates the block editor settings and
[13835] Fix | Delete
* conditionally preserves the experimental ones.
[13836] Fix | Delete
*
[13837] Fix | Delete
* @param {Object} settings Updated settings
[13838] Fix | Delete
* @param {Object} options Options object.
[13839] Fix | Delete
* @param {boolean} options.stripExperimentalSettings Whether to strip experimental settings.
[13840] Fix | Delete
* @param {boolean} options.reset Whether to reset the settings.
[13841] Fix | Delete
* @return {Object} Action object
[13842] Fix | Delete
*/
[13843] Fix | Delete
function __experimentalUpdateSettings(settings, {
[13844] Fix | Delete
stripExperimentalSettings = false,
[13845] Fix | Delete
reset = false
[13846] Fix | Delete
} = {}) {
[13847] Fix | Delete
let cleanSettings = settings;
[13848] Fix | Delete
// There are no plugins in the mobile apps, so there is no
[13849] Fix | Delete
// need to strip the experimental settings:
[13850] Fix | Delete
if (stripExperimentalSettings && external_wp_element_namespaceObject.Platform.OS === 'web') {
[13851] Fix | Delete
cleanSettings = {};
[13852] Fix | Delete
for (const key in settings) {
[13853] Fix | Delete
if (!privateSettings.includes(key)) {
[13854] Fix | Delete
cleanSettings[key] = settings[key];
[13855] Fix | Delete
}
[13856] Fix | Delete
}
[13857] Fix | Delete
}
[13858] Fix | Delete
return {
[13859] Fix | Delete
type: 'UPDATE_SETTINGS',
[13860] Fix | Delete
settings: cleanSettings,
[13861] Fix | Delete
reset
[13862] Fix | Delete
};
[13863] Fix | Delete
}
[13864] Fix | Delete
[13865] Fix | Delete
/**
[13866] Fix | Delete
* Hides the block interface (eg. toolbar, outline, etc.)
[13867] Fix | Delete
*
[13868] Fix | Delete
* @return {Object} Action object.
[13869] Fix | Delete
*/
[13870] Fix | Delete
function hideBlockInterface() {
[13871] Fix | Delete
return {
[13872] Fix | Delete
type: 'HIDE_BLOCK_INTERFACE'
[13873] Fix | Delete
};
[13874] Fix | Delete
}
[13875] Fix | Delete
[13876] Fix | Delete
/**
[13877] Fix | Delete
* Shows the block interface (eg. toolbar, outline, etc.)
[13878] Fix | Delete
*
[13879] Fix | Delete
* @return {Object} Action object.
[13880] Fix | Delete
*/
[13881] Fix | Delete
function showBlockInterface() {
[13882] Fix | Delete
return {
[13883] Fix | Delete
type: 'SHOW_BLOCK_INTERFACE'
[13884] Fix | Delete
};
[13885] Fix | Delete
}
[13886] Fix | Delete
[13887] Fix | Delete
/**
[13888] Fix | Delete
* Yields action objects used in signalling that the blocks corresponding to
[13889] Fix | Delete
* the set of specified client IDs are to be removed.
[13890] Fix | Delete
*
[13891] Fix | Delete
* Compared to `removeBlocks`, this private interface exposes an additional
[13892] Fix | Delete
* parameter; see `forceRemove`.
[13893] Fix | Delete
*
[13894] Fix | Delete
* @param {string|string[]} clientIds Client IDs of blocks to remove.
[13895] Fix | Delete
* @param {boolean} selectPrevious True if the previous block
[13896] Fix | Delete
* or the immediate parent
[13897] Fix | Delete
* (if no previous block exists)
[13898] Fix | Delete
* should be selected
[13899] Fix | Delete
* when a block is removed.
[13900] Fix | Delete
* @param {boolean} forceRemove Whether to force the operation,
[13901] Fix | Delete
* bypassing any checks for certain
[13902] Fix | Delete
* block types.
[13903] Fix | Delete
*/
[13904] Fix | Delete
const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemove = false) => ({
[13905] Fix | Delete
select,
[13906] Fix | Delete
dispatch,
[13907] Fix | Delete
registry
[13908] Fix | Delete
}) => {
[13909] Fix | Delete
if (!clientIds || !clientIds.length) {
[13910] Fix | Delete
return;
[13911] Fix | Delete
}
[13912] Fix | Delete
clientIds = castArray(clientIds);
[13913] Fix | Delete
const canRemoveBlocks = select.canRemoveBlocks(clientIds);
[13914] Fix | Delete
if (!canRemoveBlocks) {
[13915] Fix | Delete
return;
[13916] Fix | Delete
}
[13917] Fix | Delete
[13918] Fix | Delete
// In certain editing contexts, we'd like to prevent accidental removal
[13919] Fix | Delete
// of important blocks. For example, in the site editor, the Query Loop
[13920] Fix | Delete
// block is deemed important. In such cases, we'll ask the user for
[13921] Fix | Delete
// confirmation that they intended to remove such block(s). However,
[13922] Fix | Delete
// the editor instance is responsible for presenting those confirmation
[13923] Fix | Delete
// prompts to the user. Any instance opting into removal prompts must
[13924] Fix | Delete
// register using `setBlockRemovalRules()`.
[13925] Fix | Delete
//
[13926] Fix | Delete
// @see https://github.com/WordPress/gutenberg/pull/51145
[13927] Fix | Delete
const rules = !forceRemove && select.getBlockRemovalRules();
[13928] Fix | Delete
if (rules) {
[13929] Fix | Delete
function flattenBlocks(blocks) {
[13930] Fix | Delete
const result = [];
[13931] Fix | Delete
const stack = [...blocks];
[13932] Fix | Delete
while (stack.length) {
[13933] Fix | Delete
const {
[13934] Fix | Delete
innerBlocks,
[13935] Fix | Delete
...block
[13936] Fix | Delete
} = stack.shift();
[13937] Fix | Delete
stack.push(...innerBlocks);
[13938] Fix | Delete
result.push(block);
[13939] Fix | Delete
}
[13940] Fix | Delete
return result;
[13941] Fix | Delete
}
[13942] Fix | Delete
const blockList = clientIds.map(select.getBlock);
[13943] Fix | Delete
const flattenedBlocks = flattenBlocks(blockList);
[13944] Fix | Delete
[13945] Fix | Delete
// Find the first message and use it.
[13946] Fix | Delete
let message;
[13947] Fix | Delete
for (const rule of rules) {
[13948] Fix | Delete
message = rule.callback(flattenedBlocks);
[13949] Fix | Delete
if (message) {
[13950] Fix | Delete
dispatch(displayBlockRemovalPrompt(clientIds, selectPrevious, message));
[13951] Fix | Delete
return;
[13952] Fix | Delete
}
[13953] Fix | Delete
}
[13954] Fix | Delete
}
[13955] Fix | Delete
if (selectPrevious) {
[13956] Fix | Delete
dispatch.selectPreviousBlock(clientIds[0], selectPrevious);
[13957] Fix | Delete
}
[13958] Fix | Delete
[13959] Fix | Delete
// We're batching these two actions because an extra `undo/redo` step can
[13960] Fix | Delete
// be created, based on whether we insert a default block or not.
[13961] Fix | Delete
registry.batch(() => {
[13962] Fix | Delete
dispatch({
[13963] Fix | Delete
type: 'REMOVE_BLOCKS',
[13964] Fix | Delete
clientIds
[13965] Fix | Delete
});
[13966] Fix | Delete
// To avoid a focus loss when removing the last block, assure there is
[13967] Fix | Delete
// always a default block if the last of the blocks have been removed.
[13968] Fix | Delete
dispatch(ensureDefaultBlock());
[13969] Fix | Delete
});
[13970] Fix | Delete
};
[13971] Fix | Delete
[13972] Fix | Delete
/**
[13973] Fix | Delete
* Action which will insert a default block insert action if there
[13974] Fix | Delete
* are no other blocks at the root of the editor. This action should be used
[13975] Fix | Delete
* in actions which may result in no blocks remaining in the editor (removal,
[13976] Fix | Delete
* replacement, etc).
[13977] Fix | Delete
*/
[13978] Fix | Delete
const ensureDefaultBlock = () => ({
[13979] Fix | Delete
select,
[13980] Fix | Delete
dispatch
[13981] Fix | Delete
}) => {
[13982] Fix | Delete
// To avoid a focus loss when removing the last block, assure there is
[13983] Fix | Delete
// always a default block if the last of the blocks have been removed.
[13984] Fix | Delete
const count = select.getBlockCount();
[13985] Fix | Delete
if (count > 0) {
[13986] Fix | Delete
return;
[13987] Fix | Delete
}
[13988] Fix | Delete
[13989] Fix | Delete
// If there's an custom appender, don't insert default block.
[13990] Fix | Delete
// We have to remember to manually move the focus elsewhere to
[13991] Fix | Delete
// prevent it from being lost though.
[13992] Fix | Delete
const {
[13993] Fix | Delete
__unstableHasCustomAppender
[13994] Fix | Delete
} = select.getSettings();
[13995] Fix | Delete
if (__unstableHasCustomAppender) {
[13996] Fix | Delete
return;
[13997] Fix | Delete
}
[13998] Fix | Delete
dispatch.insertDefaultBlock();
[13999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function