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
[57500] Fix | Delete
// Update the selection if the original selection has been removed.
[57501] Fix | Delete
const shouldUpdateSelection = selectedBlockClientIds.length > 0 && getSelectedBlockClientIds().length === 0;
[57502] Fix | Delete
[57503] Fix | Delete
// If there's no previous block nor parent block, focus the first block.
[57504] Fix | Delete
if (!blockToFocus) {
[57505] Fix | Delete
blockToFocus = getBlockOrder()[0];
[57506] Fix | Delete
}
[57507] Fix | Delete
updateFocusAndSelection(blockToFocus, shouldUpdateSelection);
[57508] Fix | Delete
} else if (isMatch('core/block-editor/duplicate', event)) {
[57509] Fix | Delete
event.preventDefault();
[57510] Fix | Delete
const {
[57511] Fix | Delete
blocksToUpdate,
[57512] Fix | Delete
firstBlockRootClientId
[57513] Fix | Delete
} = getBlocksToUpdate();
[57514] Fix | Delete
const canDuplicate = getBlocksByClientId(blocksToUpdate).every(blockToUpdate => {
[57515] Fix | Delete
return !!blockToUpdate && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockToUpdate.name, 'multiple', true) && canInsertBlockType(blockToUpdate.name, firstBlockRootClientId);
[57516] Fix | Delete
});
[57517] Fix | Delete
if (canDuplicate) {
[57518] Fix | Delete
const updatedBlocks = await duplicateBlocks(blocksToUpdate, false);
[57519] Fix | Delete
if (updatedBlocks?.length) {
[57520] Fix | Delete
// If blocks have been duplicated, focus the first duplicated block.
[57521] Fix | Delete
updateFocusAndSelection(updatedBlocks[0], false);
[57522] Fix | Delete
}
[57523] Fix | Delete
}
[57524] Fix | Delete
} else if (isMatch('core/block-editor/insert-before', event)) {
[57525] Fix | Delete
event.preventDefault();
[57526] Fix | Delete
const {
[57527] Fix | Delete
blocksToUpdate
[57528] Fix | Delete
} = getBlocksToUpdate();
[57529] Fix | Delete
await insertBeforeBlock(blocksToUpdate[0]);
[57530] Fix | Delete
const newlySelectedBlocks = getSelectedBlockClientIds();
[57531] Fix | Delete
[57532] Fix | Delete
// Focus the first block of the newly inserted blocks, to keep focus within the list view.
[57533] Fix | Delete
setOpenedBlockSettingsMenu(undefined);
[57534] Fix | Delete
updateFocusAndSelection(newlySelectedBlocks[0], false);
[57535] Fix | Delete
} else if (isMatch('core/block-editor/insert-after', event)) {
[57536] Fix | Delete
event.preventDefault();
[57537] Fix | Delete
const {
[57538] Fix | Delete
blocksToUpdate
[57539] Fix | Delete
} = getBlocksToUpdate();
[57540] Fix | Delete
await insertAfterBlock(blocksToUpdate.at(-1));
[57541] Fix | Delete
const newlySelectedBlocks = getSelectedBlockClientIds();
[57542] Fix | Delete
[57543] Fix | Delete
// Focus the first block of the newly inserted blocks, to keep focus within the list view.
[57544] Fix | Delete
setOpenedBlockSettingsMenu(undefined);
[57545] Fix | Delete
updateFocusAndSelection(newlySelectedBlocks[0], false);
[57546] Fix | Delete
} else if (isMatch('core/block-editor/select-all', event)) {
[57547] Fix | Delete
event.preventDefault();
[57548] Fix | Delete
const {
[57549] Fix | Delete
firstBlockRootClientId,
[57550] Fix | Delete
selectedBlockClientIds
[57551] Fix | Delete
} = getBlocksToUpdate();
[57552] Fix | Delete
const blockClientIds = getBlockOrder(firstBlockRootClientId);
[57553] Fix | Delete
if (!blockClientIds.length) {
[57554] Fix | Delete
return;
[57555] Fix | Delete
}
[57556] Fix | Delete
[57557] Fix | Delete
// If we have selected all sibling nested blocks, try selecting up a level.
[57558] Fix | Delete
// This is a similar implementation to that used by `useSelectAll`.
[57559] Fix | Delete
// `isShallowEqual` is used for the list view instead of a length check,
[57560] Fix | Delete
// as the array of siblings of the currently focused block may be a different
[57561] Fix | Delete
// set of blocks from the current block selection if the user is focused
[57562] Fix | Delete
// on a different part of the list view from the block selection.
[57563] Fix | Delete
if (external_wp_isShallowEqual_default()(selectedBlockClientIds, blockClientIds)) {
[57564] Fix | Delete
// Only select up a level if the first block is not the root block.
[57565] Fix | Delete
// This ensures that the block selection can't break out of the root block
[57566] Fix | Delete
// used by the list view, if the list view is only showing a partial hierarchy.
[57567] Fix | Delete
if (firstBlockRootClientId && firstBlockRootClientId !== rootClientId) {
[57568] Fix | Delete
updateFocusAndSelection(firstBlockRootClientId, true);
[57569] Fix | Delete
return;
[57570] Fix | Delete
}
[57571] Fix | Delete
}
[57572] Fix | Delete
[57573] Fix | Delete
// Select all while passing `null` to skip focusing to the editor canvas,
[57574] Fix | Delete
// and retain focus within the list view.
[57575] Fix | Delete
multiSelect(blockClientIds[0], blockClientIds[blockClientIds.length - 1], null);
[57576] Fix | Delete
} else if (isMatch('core/block-editor/collapse-list-view', event)) {
[57577] Fix | Delete
event.preventDefault();
[57578] Fix | Delete
const {
[57579] Fix | Delete
firstBlockClientId
[57580] Fix | Delete
} = getBlocksToUpdate();
[57581] Fix | Delete
const blockParents = getBlockParents(firstBlockClientId, false);
[57582] Fix | Delete
// Collapse all blocks.
[57583] Fix | Delete
collapseAll();
[57584] Fix | Delete
// Expand all parents of the current block.
[57585] Fix | Delete
expand(blockParents);
[57586] Fix | Delete
} else if (isMatch('core/block-editor/group', event)) {
[57587] Fix | Delete
const {
[57588] Fix | Delete
blocksToUpdate
[57589] Fix | Delete
} = getBlocksToUpdate();
[57590] Fix | Delete
if (blocksToUpdate.length > 1 && isGroupable(blocksToUpdate)) {
[57591] Fix | Delete
event.preventDefault();
[57592] Fix | Delete
const blocks = getBlocksByClientId(blocksToUpdate);
[57593] Fix | Delete
const groupingBlockName = getGroupingBlockName();
[57594] Fix | Delete
const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, groupingBlockName);
[57595] Fix | Delete
replaceBlocks(blocksToUpdate, newBlocks);
[57596] Fix | Delete
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Selected blocks are grouped.'));
[57597] Fix | Delete
const newlySelectedBlocks = getSelectedBlockClientIds();
[57598] Fix | Delete
// Focus the first block of the newly inserted blocks, to keep focus within the list view.
[57599] Fix | Delete
setOpenedBlockSettingsMenu(undefined);
[57600] Fix | Delete
updateFocusAndSelection(newlySelectedBlocks[0], false);
[57601] Fix | Delete
}
[57602] Fix | Delete
}
[57603] Fix | Delete
}
[57604] Fix | Delete
const onMouseEnter = (0,external_wp_element_namespaceObject.useCallback)(() => {
[57605] Fix | Delete
setIsHovered(true);
[57606] Fix | Delete
toggleBlockHighlight(clientId, true);
[57607] Fix | Delete
}, [clientId, setIsHovered, toggleBlockHighlight]);
[57608] Fix | Delete
const onMouseLeave = (0,external_wp_element_namespaceObject.useCallback)(() => {
[57609] Fix | Delete
setIsHovered(false);
[57610] Fix | Delete
toggleBlockHighlight(clientId, false);
[57611] Fix | Delete
}, [clientId, setIsHovered, toggleBlockHighlight]);
[57612] Fix | Delete
const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)(event => {
[57613] Fix | Delete
selectBlock(event, clientId);
[57614] Fix | Delete
event.preventDefault();
[57615] Fix | Delete
}, [clientId, selectBlock]);
[57616] Fix | Delete
const updateFocusAndSelection = (0,external_wp_element_namespaceObject.useCallback)((focusClientId, shouldSelectBlock) => {
[57617] Fix | Delete
if (shouldSelectBlock) {
[57618] Fix | Delete
selectBlock(undefined, focusClientId, null, null);
[57619] Fix | Delete
}
[57620] Fix | Delete
focusListItem(focusClientId, treeGridElementRef?.current);
[57621] Fix | Delete
}, [selectBlock, treeGridElementRef]);
[57622] Fix | Delete
const toggleExpanded = (0,external_wp_element_namespaceObject.useCallback)(event => {
[57623] Fix | Delete
// Prevent shift+click from opening link in a new window when toggling.
[57624] Fix | Delete
event.preventDefault();
[57625] Fix | Delete
event.stopPropagation();
[57626] Fix | Delete
if (isExpanded === true) {
[57627] Fix | Delete
collapse(clientId);
[57628] Fix | Delete
} else if (isExpanded === false) {
[57629] Fix | Delete
expand(clientId);
[57630] Fix | Delete
}
[57631] Fix | Delete
}, [clientId, expand, collapse, isExpanded]);
[57632] Fix | Delete
[57633] Fix | Delete
// Allow right-clicking an item in the List View to open up the block settings dropdown.
[57634] Fix | Delete
const onContextMenu = (0,external_wp_element_namespaceObject.useCallback)(event => {
[57635] Fix | Delete
if (showBlockActions && allowRightClickOverrides) {
[57636] Fix | Delete
settingsRef.current?.click();
[57637] Fix | Delete
// Ensure the position of the settings dropdown is at the cursor.
[57638] Fix | Delete
setSettingsAnchorRect(new window.DOMRect(event.clientX, event.clientY, 0, 0));
[57639] Fix | Delete
event.preventDefault();
[57640] Fix | Delete
}
[57641] Fix | Delete
}, [allowRightClickOverrides, settingsRef, showBlockActions]);
[57642] Fix | Delete
const onMouseDown = (0,external_wp_element_namespaceObject.useCallback)(event => {
[57643] Fix | Delete
// Prevent right-click from focusing the block,
[57644] Fix | Delete
// because focus will be handled when opening the block settings dropdown.
[57645] Fix | Delete
if (allowRightClickOverrides && event.button === 2) {
[57646] Fix | Delete
event.preventDefault();
[57647] Fix | Delete
}
[57648] Fix | Delete
}, [allowRightClickOverrides]);
[57649] Fix | Delete
const settingsPopoverAnchor = (0,external_wp_element_namespaceObject.useMemo)(() => {
[57650] Fix | Delete
const {
[57651] Fix | Delete
ownerDocument
[57652] Fix | Delete
} = rowRef?.current || {};
[57653] Fix | Delete
[57654] Fix | Delete
// If no custom position is set, the settings dropdown will be anchored to the
[57655] Fix | Delete
// DropdownMenu toggle button.
[57656] Fix | Delete
if (!settingsAnchorRect || !ownerDocument) {
[57657] Fix | Delete
return undefined;
[57658] Fix | Delete
}
[57659] Fix | Delete
[57660] Fix | Delete
// Position the settings dropdown at the cursor when right-clicking a block.
[57661] Fix | Delete
return {
[57662] Fix | Delete
ownerDocument,
[57663] Fix | Delete
getBoundingClientRect() {
[57664] Fix | Delete
return settingsAnchorRect;
[57665] Fix | Delete
}
[57666] Fix | Delete
};
[57667] Fix | Delete
}, [settingsAnchorRect]);
[57668] Fix | Delete
const clearSettingsAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => {
[57669] Fix | Delete
// Clear the custom position for the settings dropdown so that it is restored back
[57670] Fix | Delete
// to being anchored to the DropdownMenu toggle button.
[57671] Fix | Delete
setSettingsAnchorRect(undefined);
[57672] Fix | Delete
}, [setSettingsAnchorRect]);
[57673] Fix | Delete
[57674] Fix | Delete
// Pass in a ref to the row, so that it can be scrolled
[57675] Fix | Delete
// into view when selected. For long lists, the placeholder for the
[57676] Fix | Delete
// selected block is also observed, within ListViewLeafPlaceholder.
[57677] Fix | Delete
useListViewScrollIntoView({
[57678] Fix | Delete
isSelected,
[57679] Fix | Delete
rowItemRef: rowRef,
[57680] Fix | Delete
selectedClientIds
[57681] Fix | Delete
});
[57682] Fix | Delete
[57683] Fix | Delete
// When switching between rendering modes (such as template preview and content only),
[57684] Fix | Delete
// it is possible for a block to temporarily be unavailable. In this case, we should not
[57685] Fix | Delete
// render the leaf, to avoid errors further down the tree.
[57686] Fix | Delete
if (!block) {
[57687] Fix | Delete
return null;
[57688] Fix | Delete
}
[57689] Fix | Delete
const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
[57690] Fix | Delete
const blockPropertiesDescription = getBlockPropertiesDescription(isLocked);
[57691] Fix | Delete
const hasSiblings = siblingBlockCount > 0;
[57692] Fix | Delete
const hasRenderedMovers = showBlockMovers && hasSiblings;
[57693] Fix | Delete
const moverCellClassName = dist_clsx('block-editor-list-view-block__mover-cell', {
[57694] Fix | Delete
'is-visible': isHovered || isSelected
[57695] Fix | Delete
});
[57696] Fix | Delete
const listViewBlockSettingsClassName = dist_clsx('block-editor-list-view-block__menu-cell', {
[57697] Fix | Delete
'is-visible': isHovered || isFirstSelectedBlock
[57698] Fix | Delete
});
[57699] Fix | Delete
let colSpan;
[57700] Fix | Delete
if (hasRenderedMovers) {
[57701] Fix | Delete
colSpan = 2;
[57702] Fix | Delete
} else if (!showBlockActions) {
[57703] Fix | Delete
colSpan = 3;
[57704] Fix | Delete
}
[57705] Fix | Delete
const classes = dist_clsx({
[57706] Fix | Delete
'is-selected': isSelected,
[57707] Fix | Delete
'is-first-selected': isFirstSelectedBlock,
[57708] Fix | Delete
'is-last-selected': isLastSelectedBlock,
[57709] Fix | Delete
'is-branch-selected': isBranchSelected,
[57710] Fix | Delete
'is-synced-branch': isSyncedBranch,
[57711] Fix | Delete
'is-dragging': isDragged,
[57712] Fix | Delete
'has-single-cell': !showBlockActions,
[57713] Fix | Delete
'is-synced': blockInformation?.isSynced,
[57714] Fix | Delete
'is-draggable': canMove,
[57715] Fix | Delete
'is-displacement-normal': displacement === 'normal',
[57716] Fix | Delete
'is-displacement-up': displacement === 'up',
[57717] Fix | Delete
'is-displacement-down': displacement === 'down',
[57718] Fix | Delete
'is-after-dragged-blocks': isAfterDraggedBlocks,
[57719] Fix | Delete
'is-nesting': isNesting
[57720] Fix | Delete
});
[57721] Fix | Delete
[57722] Fix | Delete
// Only include all selected blocks if the currently clicked on block
[57723] Fix | Delete
// is one of the selected blocks. This ensures that if a user attempts
[57724] Fix | Delete
// to alter a block that isn't part of the selection, they're still able
[57725] Fix | Delete
// to do so.
[57726] Fix | Delete
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
[57727] Fix | Delete
[57728] Fix | Delete
// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.
[57729] Fix | Delete
const currentlyEditingBlockInCanvas = isSelected && selectedClientIds.length === 1;
[57730] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(leaf, {
[57731] Fix | Delete
className: classes,
[57732] Fix | Delete
isDragged: isDragged,
[57733] Fix | Delete
onKeyDown: onKeyDown,
[57734] Fix | Delete
onMouseEnter: onMouseEnter,
[57735] Fix | Delete
onMouseLeave: onMouseLeave,
[57736] Fix | Delete
onFocus: onMouseEnter,
[57737] Fix | Delete
onBlur: onMouseLeave,
[57738] Fix | Delete
level: level,
[57739] Fix | Delete
position: position,
[57740] Fix | Delete
rowCount: rowCount,
[57741] Fix | Delete
path: path,
[57742] Fix | Delete
id: `list-view-${listViewInstanceId}-block-${clientId}`,
[57743] Fix | Delete
"data-block": clientId,
[57744] Fix | Delete
"data-expanded": canEdit ? isExpanded : undefined,
[57745] Fix | Delete
ref: rowRef,
[57746] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
[57747] Fix | Delete
className: "block-editor-list-view-block__contents-cell",
[57748] Fix | Delete
colSpan: colSpan,
[57749] Fix | Delete
ref: cellRef,
[57750] Fix | Delete
"aria-selected": !!isSelected,
[57751] Fix | Delete
children: ({
[57752] Fix | Delete
ref,
[57753] Fix | Delete
tabIndex,
[57754] Fix | Delete
onFocus
[57755] Fix | Delete
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[57756] Fix | Delete
className: "block-editor-list-view-block__contents-container",
[57757] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_contents, {
[57758] Fix | Delete
block: block,
[57759] Fix | Delete
onClick: selectEditorBlock,
[57760] Fix | Delete
onContextMenu: onContextMenu,
[57761] Fix | Delete
onMouseDown: onMouseDown,
[57762] Fix | Delete
onToggleExpanded: toggleExpanded,
[57763] Fix | Delete
isSelected: isSelected,
[57764] Fix | Delete
position: position,
[57765] Fix | Delete
siblingBlockCount: siblingBlockCount,
[57766] Fix | Delete
level: level,
[57767] Fix | Delete
ref: ref,
[57768] Fix | Delete
tabIndex: currentlyEditingBlockInCanvas ? 0 : tabIndex,
[57769] Fix | Delete
onFocus: onFocus,
[57770] Fix | Delete
isExpanded: canEdit ? isExpanded : undefined,
[57771] Fix | Delete
selectedClientIds: selectedClientIds,
[57772] Fix | Delete
ariaDescribedBy: descriptionId
[57773] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AriaReferencedText, {
[57774] Fix | Delete
id: descriptionId,
[57775] Fix | Delete
children: `${blockPositionDescription} ${blockPropertiesDescription}`
[57776] Fix | Delete
})]
[57777] Fix | Delete
})
[57778] Fix | Delete
}), hasRenderedMovers && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[57779] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
[57780] Fix | Delete
className: moverCellClassName,
[57781] Fix | Delete
withoutGridItem: true,
[57782] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTreeGridItem, {
[57783] Fix | Delete
children: ({
[57784] Fix | Delete
ref,
[57785] Fix | Delete
tabIndex,
[57786] Fix | Delete
onFocus
[57787] Fix | Delete
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockMoverUpButton, {
[57788] Fix | Delete
orientation: "vertical",
[57789] Fix | Delete
clientIds: [clientId],
[57790] Fix | Delete
ref: ref,
[57791] Fix | Delete
tabIndex: tabIndex,
[57792] Fix | Delete
onFocus: onFocus
[57793] Fix | Delete
})
[57794] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTreeGridItem, {
[57795] Fix | Delete
children: ({
[57796] Fix | Delete
ref,
[57797] Fix | Delete
tabIndex,
[57798] Fix | Delete
onFocus
[57799] Fix | Delete
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockMoverDownButton, {
[57800] Fix | Delete
orientation: "vertical",
[57801] Fix | Delete
clientIds: [clientId],
[57802] Fix | Delete
ref: ref,
[57803] Fix | Delete
tabIndex: tabIndex,
[57804] Fix | Delete
onFocus: onFocus
[57805] Fix | Delete
})
[57806] Fix | Delete
})]
[57807] Fix | Delete
})
[57808] Fix | Delete
}), showBlockActions && BlockSettingsMenu && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
[57809] Fix | Delete
className: listViewBlockSettingsClassName,
[57810] Fix | Delete
"aria-selected": !!isSelected,
[57811] Fix | Delete
ref: settingsRef,
[57812] Fix | Delete
children: ({
[57813] Fix | Delete
ref,
[57814] Fix | Delete
tabIndex,
[57815] Fix | Delete
onFocus
[57816] Fix | Delete
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockSettingsMenu, {
[57817] Fix | Delete
clientIds: dropdownClientIds,
[57818] Fix | Delete
block: block,
[57819] Fix | Delete
icon: more_vertical,
[57820] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Options'),
[57821] Fix | Delete
popoverProps: {
[57822] Fix | Delete
anchor: settingsPopoverAnchor // Used to position the settings at the cursor on right-click.
[57823] Fix | Delete
},
[57824] Fix | Delete
toggleProps: {
[57825] Fix | Delete
ref,
[57826] Fix | Delete
className: 'block-editor-list-view-block__menu',
[57827] Fix | Delete
tabIndex,
[57828] Fix | Delete
onClick: clearSettingsAnchorRect,
[57829] Fix | Delete
onFocus
[57830] Fix | Delete
},
[57831] Fix | Delete
disableOpenOnArrowDown: true,
[57832] Fix | Delete
expand: expand,
[57833] Fix | Delete
expandedState: expandedState,
[57834] Fix | Delete
setInsertedBlock: setInsertedBlock,
[57835] Fix | Delete
__experimentalSelectBlock: updateFocusAndSelection
[57836] Fix | Delete
})
[57837] Fix | Delete
})]
[57838] Fix | Delete
});
[57839] Fix | Delete
}
[57840] Fix | Delete
/* harmony default export */ const list_view_block = ((0,external_wp_element_namespaceObject.memo)(ListViewBlock));
[57841] Fix | Delete
[57842] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/branch.js
[57843] Fix | Delete
/**
[57844] Fix | Delete
* WordPress dependencies
[57845] Fix | Delete
*/
[57846] Fix | Delete
[57847] Fix | Delete
[57848] Fix | Delete
[57849] Fix | Delete
[57850] Fix | Delete
/**
[57851] Fix | Delete
* Internal dependencies
[57852] Fix | Delete
*/
[57853] Fix | Delete
[57854] Fix | Delete
[57855] Fix | Delete
[57856] Fix | Delete
[57857] Fix | Delete
[57858] Fix | Delete
[57859] Fix | Delete
[57860] Fix | Delete
/**
[57861] Fix | Delete
* Given a block, returns the total number of blocks in that subtree. This is used to help determine
[57862] Fix | Delete
* the list position of a block.
[57863] Fix | Delete
*
[57864] Fix | Delete
* When a block is collapsed, we do not count their children as part of that total. In the current drag
[57865] Fix | Delete
* implementation dragged blocks and their children are not counted.
[57866] Fix | Delete
*
[57867] Fix | Delete
* @param {Object} block block tree
[57868] Fix | Delete
* @param {Object} expandedState state that notes which branches are collapsed
[57869] Fix | Delete
* @param {Array} draggedClientIds a list of dragged client ids
[57870] Fix | Delete
* @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
[57871] Fix | Delete
* @return {number} block count
[57872] Fix | Delete
*/
[57873] Fix | Delete
[57874] Fix | Delete
[57875] Fix | Delete
[57876] Fix | Delete
function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
[57877] Fix | Delete
var _expandedState$block$;
[57878] Fix | Delete
const isDragged = draggedClientIds?.includes(block.clientId);
[57879] Fix | Delete
if (isDragged) {
[57880] Fix | Delete
return 0;
[57881] Fix | Delete
}
[57882] Fix | Delete
const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
[57883] Fix | Delete
if (isExpanded) {
[57884] Fix | Delete
return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
[57885] Fix | Delete
}
[57886] Fix | Delete
return 1;
[57887] Fix | Delete
}
[57888] Fix | Delete
const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
[57889] Fix | Delete
var _expandedState$block$2;
[57890] Fix | Delete
const isDragged = draggedClientIds?.includes(block.clientId);
[57891] Fix | Delete
if (isDragged) {
[57892] Fix | Delete
return count;
[57893] Fix | Delete
}
[57894] Fix | Delete
const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
[57895] Fix | Delete
if (isExpanded && block.innerBlocks.length > 0) {
[57896] Fix | Delete
return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
[57897] Fix | Delete
}
[57898] Fix | Delete
return count + 1;
[57899] Fix | Delete
};
[57900] Fix | Delete
const branch_noop = () => {};
[57901] Fix | Delete
function ListViewBranch(props) {
[57902] Fix | Delete
const {
[57903] Fix | Delete
blocks,
[57904] Fix | Delete
selectBlock = branch_noop,
[57905] Fix | Delete
showBlockMovers,
[57906] Fix | Delete
selectedClientIds,
[57907] Fix | Delete
level = 1,
[57908] Fix | Delete
path = '',
[57909] Fix | Delete
isBranchSelected = false,
[57910] Fix | Delete
listPosition = 0,
[57911] Fix | Delete
fixedListWindow,
[57912] Fix | Delete
isExpanded,
[57913] Fix | Delete
parentId,
[57914] Fix | Delete
shouldShowInnerBlocks = true,
[57915] Fix | Delete
isSyncedBranch = false,
[57916] Fix | Delete
showAppender: showAppenderProp = true
[57917] Fix | Delete
} = props;
[57918] Fix | Delete
const parentBlockInformation = useBlockDisplayInformation(parentId);
[57919] Fix | Delete
const syncedBranch = isSyncedBranch || !!parentBlockInformation?.isSynced;
[57920] Fix | Delete
const canParentExpand = (0,external_wp_data_namespaceObject.useSelect)(select => {
[57921] Fix | Delete
if (!parentId) {
[57922] Fix | Delete
return true;
[57923] Fix | Delete
}
[57924] Fix | Delete
return select(store).canEditBlock(parentId);
[57925] Fix | Delete
}, [parentId]);
[57926] Fix | Delete
const {
[57927] Fix | Delete
blockDropPosition,
[57928] Fix | Delete
blockDropTargetIndex,
[57929] Fix | Delete
firstDraggedBlockIndex,
[57930] Fix | Delete
blockIndexes,
[57931] Fix | Delete
expandedState,
[57932] Fix | Delete
draggedClientIds
[57933] Fix | Delete
} = useListViewContext();
[57934] Fix | Delete
if (!canParentExpand) {
[57935] Fix | Delete
return null;
[57936] Fix | Delete
}
[57937] Fix | Delete
[57938] Fix | Delete
// Only show the appender at the first level.
[57939] Fix | Delete
const showAppender = showAppenderProp && level === 1;
[57940] Fix | Delete
const filteredBlocks = blocks.filter(Boolean);
[57941] Fix | Delete
const blockCount = filteredBlocks.length;
[57942] Fix | Delete
// The appender means an extra row in List View, so add 1 to the row count.
[57943] Fix | Delete
const rowCount = showAppender ? blockCount + 1 : blockCount;
[57944] Fix | Delete
let nextPosition = listPosition;
[57945] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[57946] Fix | Delete
children: [filteredBlocks.map((block, index) => {
[57947] Fix | Delete
var _expandedState$client;
[57948] Fix | Delete
const {
[57949] Fix | Delete
clientId,
[57950] Fix | Delete
innerBlocks
[57951] Fix | Delete
} = block;
[57952] Fix | Delete
if (index > 0) {
[57953] Fix | Delete
nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
[57954] Fix | Delete
}
[57955] Fix | Delete
const isDragged = !!draggedClientIds?.includes(clientId);
[57956] Fix | Delete
[57957] Fix | Delete
// Determine the displacement of the block while dragging. This
[57958] Fix | Delete
// works out whether the current block should be displaced up or
[57959] Fix | Delete
// down, relative to the dragged blocks and the drop target.
[57960] Fix | Delete
const {
[57961] Fix | Delete
displacement,
[57962] Fix | Delete
isAfterDraggedBlocks,
[57963] Fix | Delete
isNesting
[57964] Fix | Delete
} = getDragDisplacementValues({
[57965] Fix | Delete
blockIndexes,
[57966] Fix | Delete
blockDropTargetIndex,
[57967] Fix | Delete
blockDropPosition,
[57968] Fix | Delete
clientId,
[57969] Fix | Delete
firstDraggedBlockIndex,
[57970] Fix | Delete
isDragged
[57971] Fix | Delete
});
[57972] Fix | Delete
const {
[57973] Fix | Delete
itemInView
[57974] Fix | Delete
} = fixedListWindow;
[57975] Fix | Delete
const blockInView = itemInView(nextPosition);
[57976] Fix | Delete
const position = index + 1;
[57977] Fix | Delete
const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
[57978] Fix | Delete
const hasNestedBlocks = !!innerBlocks?.length;
[57979] Fix | Delete
const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
[57980] Fix | Delete
[57981] Fix | Delete
// Make updates to the selected or dragged blocks synchronous,
[57982] Fix | Delete
// but asynchronous for any other block.
[57983] Fix | Delete
const isSelected = isClientIdSelected(clientId, selectedClientIds);
[57984] Fix | Delete
const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
[57985] Fix | Delete
[57986] Fix | Delete
// To avoid performance issues, we only render blocks that are in view,
[57987] Fix | Delete
// or blocks that are selected or dragged. If a block is selected,
[57988] Fix | Delete
// it is only counted if it is the first of the block selection.
[57989] Fix | Delete
// This prevents the entire tree from being rendered when a branch is
[57990] Fix | Delete
// selected, or a user selects all blocks, while still enabling scroll
[57991] Fix | Delete
// into view behavior when selecting a block or opening the list view.
[57992] Fix | Delete
// The first and last blocks of the list are always rendered, to ensure
[57993] Fix | Delete
// that Home and End keys work as expected.
[57994] Fix | Delete
const showBlock = isDragged || blockInView || isSelected && clientId === selectedClientIds[0] || index === 0 || index === blockCount - 1;
[57995] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_data_namespaceObject.AsyncModeProvider, {
[57996] Fix | Delete
value: !isSelected,
[57997] Fix | Delete
children: [showBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(list_view_block, {
[57998] Fix | Delete
block: block,
[57999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function