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
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[58500] Fix | Delete
const {
[58501] Fix | Delete
getBlockParents: _getBlockParents,
[58502] Fix | Delete
getExpandedBlock
[58503] Fix | Delete
} = unlock(select(store));
[58504] Fix | Delete
return {
[58505] Fix | Delete
expandedBlock: getExpandedBlock(),
[58506] Fix | Delete
getBlockParents: _getBlockParents
[58507] Fix | Delete
};
[58508] Fix | Delete
}, []);
[58509] Fix | Delete
[58510] Fix | Delete
// Collapse all but the specified block when the expanded block client Id changes.
[58511] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[58512] Fix | Delete
if (expandedBlock) {
[58513] Fix | Delete
const blockParents = getBlockParents(expandedBlock, false);
[58514] Fix | Delete
// Collapse all blocks and expand the block's parents.
[58515] Fix | Delete
collapseAll();
[58516] Fix | Delete
expand(blockParents);
[58517] Fix | Delete
}
[58518] Fix | Delete
}, [collapseAll, expand, expandedBlock, getBlockParents]);
[58519] Fix | Delete
}
[58520] Fix | Delete
[58521] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-drop-zone.js
[58522] Fix | Delete
/**
[58523] Fix | Delete
* WordPress dependencies
[58524] Fix | Delete
*/
[58525] Fix | Delete
[58526] Fix | Delete
[58527] Fix | Delete
[58528] Fix | Delete
[58529] Fix | Delete
[58530] Fix | Delete
/**
[58531] Fix | Delete
* Internal dependencies
[58532] Fix | Delete
*/
[58533] Fix | Delete
[58534] Fix | Delete
[58535] Fix | Delete
[58536] Fix | Delete
[58537] Fix | Delete
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
[58538] Fix | Delete
[58539] Fix | Delete
/**
[58540] Fix | Delete
* The type of a drag event.
[58541] Fix | Delete
*
[58542] Fix | Delete
* @typedef {'default'|'file'|'html'} WPDragEventType
[58543] Fix | Delete
*/
[58544] Fix | Delete
[58545] Fix | Delete
/**
[58546] Fix | Delete
* An object representing data for blocks in the DOM used by drag and drop.
[58547] Fix | Delete
*
[58548] Fix | Delete
* @typedef {Object} WPListViewDropZoneBlock
[58549] Fix | Delete
* @property {string} clientId The client id for the block.
[58550] Fix | Delete
* @property {string} rootClientId The root client id for the block.
[58551] Fix | Delete
* @property {number} blockIndex The block's index.
[58552] Fix | Delete
* @property {Element} element The DOM element representing the block.
[58553] Fix | Delete
* @property {number} innerBlockCount The number of inner blocks the block has.
[58554] Fix | Delete
* @property {boolean} isDraggedBlock Whether the block is currently being dragged.
[58555] Fix | Delete
* @property {boolean} isExpanded Whether the block is expanded in the UI.
[58556] Fix | Delete
* @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
[58557] Fix | Delete
* @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
[58558] Fix | Delete
*/
[58559] Fix | Delete
[58560] Fix | Delete
/**
[58561] Fix | Delete
* An array representing data for blocks in the DOM used by drag and drop.
[58562] Fix | Delete
*
[58563] Fix | Delete
* @typedef {WPListViewDropZoneBlock[]} WPListViewDropZoneBlocks
[58564] Fix | Delete
*/
[58565] Fix | Delete
[58566] Fix | Delete
/**
[58567] Fix | Delete
* An object containing details of a drop target.
[58568] Fix | Delete
*
[58569] Fix | Delete
* @typedef {Object} WPListViewDropZoneTarget
[58570] Fix | Delete
* @property {string} blockIndex The insertion index.
[58571] Fix | Delete
* @property {string} rootClientId The root client id for the block.
[58572] Fix | Delete
* @property {string|undefined} clientId The client id for the block.
[58573] Fix | Delete
* @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
[58574] Fix | Delete
* 'inside' refers to nesting as an inner block.
[58575] Fix | Delete
*/
[58576] Fix | Delete
[58577] Fix | Delete
// When the indentation level, the corresponding left margin in `style.scss`
[58578] Fix | Delete
// must be updated as well to ensure the drop zone is aligned with the indentation.
[58579] Fix | Delete
const NESTING_LEVEL_INDENTATION = 24;
[58580] Fix | Delete
[58581] Fix | Delete
/**
[58582] Fix | Delete
* Determines whether the user is positioning the dragged block to be
[58583] Fix | Delete
* moved up to a parent level.
[58584] Fix | Delete
*
[58585] Fix | Delete
* Determined based on nesting level indentation of the current block.
[58586] Fix | Delete
*
[58587] Fix | Delete
* @param {WPPoint} point The point representing the cursor position when dragging.
[58588] Fix | Delete
* @param {DOMRect} rect The rectangle.
[58589] Fix | Delete
* @param {number} nestingLevel The nesting level of the block.
[58590] Fix | Delete
* @param {boolean} rtl Whether the editor is in RTL mode.
[58591] Fix | Delete
* @return {boolean} Whether the gesture is an upward gesture.
[58592] Fix | Delete
*/
[58593] Fix | Delete
function isUpGesture(point, rect, nestingLevel = 1, rtl = false) {
[58594] Fix | Delete
// If the block is nested, and the user is dragging to the bottom
[58595] Fix | Delete
// left of the block (or bottom right in RTL languages), then it is an upward gesture.
[58596] Fix | Delete
const blockIndentPosition = rtl ? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION : rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;
[58597] Fix | Delete
return rtl ? point.x > blockIndentPosition : point.x < blockIndentPosition;
[58598] Fix | Delete
}
[58599] Fix | Delete
[58600] Fix | Delete
/**
[58601] Fix | Delete
* Returns how many nesting levels up the user is attempting to drag to.
[58602] Fix | Delete
*
[58603] Fix | Delete
* The relative parent level is calculated based on how far
[58604] Fix | Delete
* the cursor is from the provided nesting level (e.g. of a candidate block
[58605] Fix | Delete
* that the user is hovering over). The nesting level is considered "desired"
[58606] Fix | Delete
* because it is not guaranteed that the user will be able to drag to the desired level.
[58607] Fix | Delete
*
[58608] Fix | Delete
* The returned integer can be used to access an ascending array
[58609] Fix | Delete
* of parent blocks, where the first item is the block the user
[58610] Fix | Delete
* is hovering over, and the last item is the root block.
[58611] Fix | Delete
*
[58612] Fix | Delete
* @param {WPPoint} point The point representing the cursor position when dragging.
[58613] Fix | Delete
* @param {DOMRect} rect The rectangle.
[58614] Fix | Delete
* @param {number} nestingLevel The nesting level of the block.
[58615] Fix | Delete
* @param {boolean} rtl Whether the editor is in RTL mode.
[58616] Fix | Delete
* @return {number} The desired relative parent level.
[58617] Fix | Delete
*/
[58618] Fix | Delete
function getDesiredRelativeParentLevel(point, rect, nestingLevel = 1, rtl = false) {
[58619] Fix | Delete
// In RTL languages, the block indent position is from the right edge of the block.
[58620] Fix | Delete
// In LTR languages, the block indent position is from the left edge of the block.
[58621] Fix | Delete
const blockIndentPosition = rtl ? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION : rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;
[58622] Fix | Delete
const distanceBetweenPointAndBlockIndentPosition = rtl ? blockIndentPosition - point.x : point.x - blockIndentPosition;
[58623] Fix | Delete
const desiredParentLevel = Math.round(distanceBetweenPointAndBlockIndentPosition / NESTING_LEVEL_INDENTATION);
[58624] Fix | Delete
return Math.abs(desiredParentLevel);
[58625] Fix | Delete
}
[58626] Fix | Delete
[58627] Fix | Delete
/**
[58628] Fix | Delete
* Returns an array of the parent blocks of the block the user is dropping to.
[58629] Fix | Delete
*
[58630] Fix | Delete
* @param {WPListViewDropZoneBlock} candidateBlockData The block the user is dropping to.
[58631] Fix | Delete
* @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
[58632] Fix | Delete
* @return {WPListViewDropZoneBlocks} An array of block parents, including the block the user is dropping to.
[58633] Fix | Delete
*/
[58634] Fix | Delete
function getCandidateBlockParents(candidateBlockData, blocksData) {
[58635] Fix | Delete
const candidateBlockParents = [];
[58636] Fix | Delete
let currentBlockData = candidateBlockData;
[58637] Fix | Delete
while (currentBlockData) {
[58638] Fix | Delete
candidateBlockParents.push({
[58639] Fix | Delete
...currentBlockData
[58640] Fix | Delete
});
[58641] Fix | Delete
currentBlockData = blocksData.find(blockData => blockData.clientId === currentBlockData.rootClientId);
[58642] Fix | Delete
}
[58643] Fix | Delete
return candidateBlockParents;
[58644] Fix | Delete
}
[58645] Fix | Delete
[58646] Fix | Delete
/**
[58647] Fix | Delete
* Given a list of blocks data and a block index, return the next non-dragged
[58648] Fix | Delete
* block. This is used to determine the block that the user is dropping to,
[58649] Fix | Delete
* while ignoring the dragged block.
[58650] Fix | Delete
*
[58651] Fix | Delete
* @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
[58652] Fix | Delete
* @param {number} index The index to begin searching from.
[58653] Fix | Delete
* @return {WPListViewDropZoneBlock | undefined} The next non-dragged block.
[58654] Fix | Delete
*/
[58655] Fix | Delete
function getNextNonDraggedBlock(blocksData, index) {
[58656] Fix | Delete
const nextBlockData = blocksData[index + 1];
[58657] Fix | Delete
if (nextBlockData && nextBlockData.isDraggedBlock) {
[58658] Fix | Delete
return getNextNonDraggedBlock(blocksData, index + 1);
[58659] Fix | Delete
}
[58660] Fix | Delete
return nextBlockData;
[58661] Fix | Delete
}
[58662] Fix | Delete
[58663] Fix | Delete
/**
[58664] Fix | Delete
* Determines whether the user positioning the dragged block to nest as an
[58665] Fix | Delete
* inner block.
[58666] Fix | Delete
*
[58667] Fix | Delete
* Determined based on nesting level indentation of the current block, plus
[58668] Fix | Delete
* the indentation of the next level of nesting. The vertical position of the
[58669] Fix | Delete
* cursor must also be within the block.
[58670] Fix | Delete
*
[58671] Fix | Delete
* @param {WPPoint} point The point representing the cursor position when dragging.
[58672] Fix | Delete
* @param {DOMRect} rect The rectangle.
[58673] Fix | Delete
* @param {number} nestingLevel The nesting level of the block.
[58674] Fix | Delete
* @param {boolean} rtl Whether the editor is in RTL mode.
[58675] Fix | Delete
*/
[58676] Fix | Delete
function isNestingGesture(point, rect, nestingLevel = 1, rtl = false) {
[58677] Fix | Delete
const blockIndentPosition = rtl ? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION : rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;
[58678] Fix | Delete
const isNestingHorizontalGesture = rtl ? point.x < blockIndentPosition - NESTING_LEVEL_INDENTATION : point.x > blockIndentPosition + NESTING_LEVEL_INDENTATION;
[58679] Fix | Delete
return isNestingHorizontalGesture && point.y < rect.bottom;
[58680] Fix | Delete
}
[58681] Fix | Delete
[58682] Fix | Delete
// Block navigation is always a vertical list, so only allow dropping
[58683] Fix | Delete
// to the above or below a block.
[58684] Fix | Delete
const ALLOWED_DROP_EDGES = ['top', 'bottom'];
[58685] Fix | Delete
[58686] Fix | Delete
/**
[58687] Fix | Delete
* Given blocks data and the cursor position, compute the drop target.
[58688] Fix | Delete
*
[58689] Fix | Delete
* @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
[58690] Fix | Delete
* @param {WPPoint} position The point representing the cursor position when dragging.
[58691] Fix | Delete
* @param {boolean} rtl Whether the editor is in RTL mode.
[58692] Fix | Delete
*
[58693] Fix | Delete
* @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.
[58694] Fix | Delete
*/
[58695] Fix | Delete
function getListViewDropTarget(blocksData, position, rtl = false) {
[58696] Fix | Delete
let candidateEdge;
[58697] Fix | Delete
let candidateBlockData;
[58698] Fix | Delete
let candidateDistance;
[58699] Fix | Delete
let candidateRect;
[58700] Fix | Delete
let candidateBlockIndex;
[58701] Fix | Delete
for (let i = 0; i < blocksData.length; i++) {
[58702] Fix | Delete
const blockData = blocksData[i];
[58703] Fix | Delete
if (blockData.isDraggedBlock) {
[58704] Fix | Delete
continue;
[58705] Fix | Delete
}
[58706] Fix | Delete
const rect = blockData.element.getBoundingClientRect();
[58707] Fix | Delete
const [distance, edge] = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES);
[58708] Fix | Delete
const isCursorWithinBlock = isPointContainedByRect(position, rect);
[58709] Fix | Delete
if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
[58710] Fix | Delete
candidateDistance = distance;
[58711] Fix | Delete
const index = blocksData.indexOf(blockData);
[58712] Fix | Delete
const previousBlockData = blocksData[index - 1];
[58713] Fix | Delete
[58714] Fix | Delete
// If dragging near the top of a block and the preceding block
[58715] Fix | Delete
// is at the same level, use the preceding block as the candidate
[58716] Fix | Delete
// instead, as later it makes determining a nesting drop easier.
[58717] Fix | Delete
if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
[58718] Fix | Delete
candidateBlockData = previousBlockData;
[58719] Fix | Delete
candidateEdge = 'bottom';
[58720] Fix | Delete
candidateRect = previousBlockData.element.getBoundingClientRect();
[58721] Fix | Delete
candidateBlockIndex = index - 1;
[58722] Fix | Delete
} else {
[58723] Fix | Delete
candidateBlockData = blockData;
[58724] Fix | Delete
candidateEdge = edge;
[58725] Fix | Delete
candidateRect = rect;
[58726] Fix | Delete
candidateBlockIndex = index;
[58727] Fix | Delete
}
[58728] Fix | Delete
[58729] Fix | Delete
// If the mouse position is within the block, break early
[58730] Fix | Delete
// as the user would intend to drop either before or after
[58731] Fix | Delete
// this block.
[58732] Fix | Delete
//
[58733] Fix | Delete
// This solves an issue where some rows in the list view
[58734] Fix | Delete
// tree overlap slightly due to sub-pixel rendering.
[58735] Fix | Delete
if (isCursorWithinBlock) {
[58736] Fix | Delete
break;
[58737] Fix | Delete
}
[58738] Fix | Delete
}
[58739] Fix | Delete
}
[58740] Fix | Delete
if (!candidateBlockData) {
[58741] Fix | Delete
return;
[58742] Fix | Delete
}
[58743] Fix | Delete
const candidateBlockParents = getCandidateBlockParents(candidateBlockData, blocksData);
[58744] Fix | Delete
const isDraggingBelow = candidateEdge === 'bottom';
[58745] Fix | Delete
[58746] Fix | Delete
// If the user is dragging towards the bottom of the block check whether
[58747] Fix | Delete
// they might be trying to nest the block as a child.
[58748] Fix | Delete
// If the block already has inner blocks, and is expanded, this should be treated
[58749] Fix | Delete
// as nesting since the next block in the tree will be the first child.
[58750] Fix | Delete
// However, if the block is collapsed, dragging beneath the block should
[58751] Fix | Delete
// still be allowed, as the next visible block in the tree will be a sibling.
[58752] Fix | Delete
if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 && candidateBlockData.isExpanded || isNestingGesture(position, candidateRect, candidateBlockParents.length, rtl))) {
[58753] Fix | Delete
// If the block is expanded, insert the block as the first child.
[58754] Fix | Delete
// Otherwise, for collapsed blocks, insert the block as the last child.
[58755] Fix | Delete
const newBlockIndex = candidateBlockData.isExpanded ? 0 : candidateBlockData.innerBlockCount || 0;
[58756] Fix | Delete
return {
[58757] Fix | Delete
rootClientId: candidateBlockData.clientId,
[58758] Fix | Delete
clientId: candidateBlockData.clientId,
[58759] Fix | Delete
blockIndex: newBlockIndex,
[58760] Fix | Delete
dropPosition: 'inside'
[58761] Fix | Delete
};
[58762] Fix | Delete
}
[58763] Fix | Delete
[58764] Fix | Delete
// If the user is dragging towards the bottom of the block check whether
[58765] Fix | Delete
// they might be trying to move the block to be at a parent level.
[58766] Fix | Delete
if (isDraggingBelow && candidateBlockData.rootClientId && isUpGesture(position, candidateRect, candidateBlockParents.length, rtl)) {
[58767] Fix | Delete
const nextBlock = getNextNonDraggedBlock(blocksData, candidateBlockIndex);
[58768] Fix | Delete
const currentLevel = candidateBlockData.nestingLevel;
[58769] Fix | Delete
const nextLevel = nextBlock ? nextBlock.nestingLevel : 1;
[58770] Fix | Delete
if (currentLevel && nextLevel) {
[58771] Fix | Delete
// Determine the desired relative level of the block to be dropped.
[58772] Fix | Delete
const desiredRelativeLevel = getDesiredRelativeParentLevel(position, candidateRect, candidateBlockParents.length, rtl);
[58773] Fix | Delete
const targetParentIndex = Math.max(Math.min(desiredRelativeLevel, currentLevel - nextLevel), 0);
[58774] Fix | Delete
if (candidateBlockParents[targetParentIndex]) {
[58775] Fix | Delete
// Default to the block index of the candidate block.
[58776] Fix | Delete
let newBlockIndex = candidateBlockData.blockIndex;
[58777] Fix | Delete
[58778] Fix | Delete
// If the next block is at the same level, use that as the default
[58779] Fix | Delete
// block index. This ensures that the block is dropped in the correct
[58780] Fix | Delete
// position when dragging to the bottom of a block.
[58781] Fix | Delete
if (candidateBlockParents[targetParentIndex].nestingLevel === nextBlock?.nestingLevel) {
[58782] Fix | Delete
newBlockIndex = nextBlock?.blockIndex;
[58783] Fix | Delete
} else {
[58784] Fix | Delete
// Otherwise, search from the current block index back
[58785] Fix | Delete
// to find the last block index within the same target parent.
[58786] Fix | Delete
for (let i = candidateBlockIndex; i >= 0; i--) {
[58787] Fix | Delete
const blockData = blocksData[i];
[58788] Fix | Delete
if (blockData.rootClientId === candidateBlockParents[targetParentIndex].rootClientId) {
[58789] Fix | Delete
newBlockIndex = blockData.blockIndex + 1;
[58790] Fix | Delete
break;
[58791] Fix | Delete
}
[58792] Fix | Delete
}
[58793] Fix | Delete
}
[58794] Fix | Delete
return {
[58795] Fix | Delete
rootClientId: candidateBlockParents[targetParentIndex].rootClientId,
[58796] Fix | Delete
clientId: candidateBlockData.clientId,
[58797] Fix | Delete
blockIndex: newBlockIndex,
[58798] Fix | Delete
dropPosition: candidateEdge
[58799] Fix | Delete
};
[58800] Fix | Delete
}
[58801] Fix | Delete
}
[58802] Fix | Delete
}
[58803] Fix | Delete
[58804] Fix | Delete
// If dropping as a sibling, but block cannot be inserted in
[58805] Fix | Delete
// this context, return early.
[58806] Fix | Delete
if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
[58807] Fix | Delete
return;
[58808] Fix | Delete
}
[58809] Fix | Delete
const offset = isDraggingBelow ? 1 : 0;
[58810] Fix | Delete
return {
[58811] Fix | Delete
rootClientId: candidateBlockData.rootClientId,
[58812] Fix | Delete
clientId: candidateBlockData.clientId,
[58813] Fix | Delete
blockIndex: candidateBlockData.blockIndex + offset,
[58814] Fix | Delete
dropPosition: candidateEdge
[58815] Fix | Delete
};
[58816] Fix | Delete
}
[58817] Fix | Delete
[58818] Fix | Delete
// Throttle options need to be defined outside of the hook to avoid
[58819] Fix | Delete
// re-creating the object on every render. This is due to a limitation
[58820] Fix | Delete
// of the `useThrottle` hook, where the options object is included
[58821] Fix | Delete
// in the dependency array for memoization.
[58822] Fix | Delete
const EXPAND_THROTTLE_OPTIONS = {
[58823] Fix | Delete
leading: false,
[58824] Fix | Delete
// Don't call the function immediately on the first call.
[58825] Fix | Delete
trailing: true // Do call the function on the last call.
[58826] Fix | Delete
};
[58827] Fix | Delete
[58828] Fix | Delete
/**
[58829] Fix | Delete
* A react hook for implementing a drop zone in list view.
[58830] Fix | Delete
*
[58831] Fix | Delete
* @param {Object} props Named parameters.
[58832] Fix | Delete
* @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone.
[58833] Fix | Delete
* @param {Object} [props.expandedState] The expanded state of the blocks in the list view.
[58834] Fix | Delete
* @param {Function} [props.setExpandedState] Function to set the expanded state of a list of block clientIds.
[58835] Fix | Delete
*
[58836] Fix | Delete
* @return {WPListViewDropZoneTarget} The drop target.
[58837] Fix | Delete
*/
[58838] Fix | Delete
function useListViewDropZone({
[58839] Fix | Delete
dropZoneElement,
[58840] Fix | Delete
expandedState,
[58841] Fix | Delete
setExpandedState
[58842] Fix | Delete
}) {
[58843] Fix | Delete
const {
[58844] Fix | Delete
getBlockRootClientId,
[58845] Fix | Delete
getBlockIndex,
[58846] Fix | Delete
getBlockCount,
[58847] Fix | Delete
getDraggedBlockClientIds,
[58848] Fix | Delete
canInsertBlocks
[58849] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store);
[58850] Fix | Delete
const [target, setTarget] = (0,external_wp_element_namespaceObject.useState)();
[58851] Fix | Delete
const {
[58852] Fix | Delete
rootClientId: targetRootClientId,
[58853] Fix | Delete
blockIndex: targetBlockIndex
[58854] Fix | Delete
} = target || {};
[58855] Fix | Delete
const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
[58856] Fix | Delete
const rtl = (0,external_wp_i18n_namespaceObject.isRTL)();
[58857] Fix | Delete
const previousRootClientId = (0,external_wp_compose_namespaceObject.usePrevious)(targetRootClientId);
[58858] Fix | Delete
const maybeExpandBlock = (0,external_wp_element_namespaceObject.useCallback)((_expandedState, _target) => {
[58859] Fix | Delete
// If the user is attempting to drop a block inside a collapsed block,
[58860] Fix | Delete
// that is, using a nesting gesture flagged by 'inside' dropPosition,
[58861] Fix | Delete
// expand the block within the list view, if it isn't already.
[58862] Fix | Delete
const {
[58863] Fix | Delete
rootClientId
[58864] Fix | Delete
} = _target || {};
[58865] Fix | Delete
if (!rootClientId) {
[58866] Fix | Delete
return;
[58867] Fix | Delete
}
[58868] Fix | Delete
if (_target?.dropPosition === 'inside' && !_expandedState[rootClientId]) {
[58869] Fix | Delete
setExpandedState({
[58870] Fix | Delete
type: 'expand',
[58871] Fix | Delete
clientIds: [rootClientId]
[58872] Fix | Delete
});
[58873] Fix | Delete
}
[58874] Fix | Delete
}, [setExpandedState]);
[58875] Fix | Delete
[58876] Fix | Delete
// Throttle the maybeExpandBlock function to avoid expanding the block
[58877] Fix | Delete
// too quickly when the user is dragging over the block. This is to
[58878] Fix | Delete
// avoid expanding the block when the user is just passing over it.
[58879] Fix | Delete
const throttledMaybeExpandBlock = (0,external_wp_compose_namespaceObject.useThrottle)(maybeExpandBlock, 500, EXPAND_THROTTLE_OPTIONS);
[58880] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[58881] Fix | Delete
if (target?.dropPosition !== 'inside' || previousRootClientId !== target?.rootClientId) {
[58882] Fix | Delete
throttledMaybeExpandBlock.cancel();
[58883] Fix | Delete
return;
[58884] Fix | Delete
}
[58885] Fix | Delete
throttledMaybeExpandBlock(expandedState, target);
[58886] Fix | Delete
}, [expandedState, previousRootClientId, target, throttledMaybeExpandBlock]);
[58887] Fix | Delete
const draggedBlockClientIds = getDraggedBlockClientIds();
[58888] Fix | Delete
const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
[58889] Fix | Delete
const position = {
[58890] Fix | Delete
x: event.clientX,
[58891] Fix | Delete
y: event.clientY
[58892] Fix | Delete
};
[58893] Fix | Delete
const isBlockDrag = !!draggedBlockClientIds?.length;
[58894] Fix | Delete
const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
[58895] Fix | Delete
const blocksData = blockElements.map(blockElement => {
[58896] Fix | Delete
const clientId = blockElement.dataset.block;
[58897] Fix | Delete
const isExpanded = blockElement.dataset.expanded === 'true';
[58898] Fix | Delete
const isDraggedBlock = blockElement.classList.contains('is-dragging');
[58899] Fix | Delete
[58900] Fix | Delete
// Get nesting level from `aria-level` attribute because Firefox does not support `element.ariaLevel`.
[58901] Fix | Delete
const nestingLevel = parseInt(blockElement.getAttribute('aria-level'), 10);
[58902] Fix | Delete
const rootClientId = getBlockRootClientId(clientId);
[58903] Fix | Delete
return {
[58904] Fix | Delete
clientId,
[58905] Fix | Delete
isExpanded,
[58906] Fix | Delete
rootClientId,
[58907] Fix | Delete
blockIndex: getBlockIndex(clientId),
[58908] Fix | Delete
element: blockElement,
[58909] Fix | Delete
nestingLevel: nestingLevel || undefined,
[58910] Fix | Delete
isDraggedBlock: isBlockDrag ? isDraggedBlock : false,
[58911] Fix | Delete
innerBlockCount: getBlockCount(clientId),
[58912] Fix | Delete
canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
[58913] Fix | Delete
canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
[58914] Fix | Delete
};
[58915] Fix | Delete
});
[58916] Fix | Delete
const newTarget = getListViewDropTarget(blocksData, position, rtl);
[58917] Fix | Delete
if (newTarget) {
[58918] Fix | Delete
setTarget(newTarget);
[58919] Fix | Delete
}
[58920] Fix | Delete
}, [canInsertBlocks, draggedBlockClientIds, getBlockCount, getBlockIndex, getBlockRootClientId, rtl]), 50);
[58921] Fix | Delete
const ref = (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
[58922] Fix | Delete
dropZoneElement,
[58923] Fix | Delete
onDrop(event) {
[58924] Fix | Delete
throttled.cancel();
[58925] Fix | Delete
if (target) {
[58926] Fix | Delete
onBlockDrop(event);
[58927] Fix | Delete
}
[58928] Fix | Delete
// Use `undefined` value to indicate that the drag has concluded.
[58929] Fix | Delete
// This allows styling rules that are active only when a user is
[58930] Fix | Delete
// dragging to be removed.
[58931] Fix | Delete
setTarget(undefined);
[58932] Fix | Delete
},
[58933] Fix | Delete
onDragLeave() {
[58934] Fix | Delete
throttled.cancel();
[58935] Fix | Delete
// Use `null` value to indicate that the drop target is not valid,
[58936] Fix | Delete
// but that the drag is still active. This allows for styling rules
[58937] Fix | Delete
// that are active only when a user drags outside of the list view.
[58938] Fix | Delete
setTarget(null);
[58939] Fix | Delete
},
[58940] Fix | Delete
onDragOver(event) {
[58941] Fix | Delete
// `currentTarget` is only available while the event is being
[58942] Fix | Delete
// handled, so get it now and pass it to the thottled function.
[58943] Fix | Delete
// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
[58944] Fix | Delete
throttled(event, event.currentTarget);
[58945] Fix | Delete
},
[58946] Fix | Delete
onDragEnd() {
[58947] Fix | Delete
throttled.cancel();
[58948] Fix | Delete
// Use `undefined` value to indicate that the drag has concluded.
[58949] Fix | Delete
// This allows styling rules that are active only when a user is
[58950] Fix | Delete
// dragging to be removed.
[58951] Fix | Delete
setTarget(undefined);
[58952] Fix | Delete
}
[58953] Fix | Delete
});
[58954] Fix | Delete
return {
[58955] Fix | Delete
ref,
[58956] Fix | Delete
target
[58957] Fix | Delete
};
[58958] Fix | Delete
}
[58959] Fix | Delete
[58960] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/list-view/use-list-view-expand-selected-item.js
[58961] Fix | Delete
/**
[58962] Fix | Delete
* WordPress dependencies
[58963] Fix | Delete
*/
[58964] Fix | Delete
[58965] Fix | Delete
[58966] Fix | Delete
[58967] Fix | Delete
/**
[58968] Fix | Delete
* Internal dependencies
[58969] Fix | Delete
*/
[58970] Fix | Delete
[58971] Fix | Delete
function useListViewExpandSelectedItem({
[58972] Fix | Delete
firstSelectedBlockClientId,
[58973] Fix | Delete
setExpandedState
[58974] Fix | Delete
}) {
[58975] Fix | Delete
const [selectedTreeId, setSelectedTreeId] = (0,external_wp_element_namespaceObject.useState)(null);
[58976] Fix | Delete
const {
[58977] Fix | Delete
selectedBlockParentClientIds
[58978] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[58979] Fix | Delete
const {
[58980] Fix | Delete
getBlockParents
[58981] Fix | Delete
} = select(store);
[58982] Fix | Delete
return {
[58983] Fix | Delete
selectedBlockParentClientIds: getBlockParents(firstSelectedBlockClientId, false)
[58984] Fix | Delete
};
[58985] Fix | Delete
}, [firstSelectedBlockClientId]);
[58986] Fix | Delete
[58987] Fix | Delete
// Expand tree when a block is selected.
[58988] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[58989] Fix | Delete
// If the selectedTreeId is the same as the selected block,
[58990] Fix | Delete
// it means that the block was selected using the block list tree.
[58991] Fix | Delete
if (selectedTreeId === firstSelectedBlockClientId) {
[58992] Fix | Delete
return;
[58993] Fix | Delete
}
[58994] Fix | Delete
[58995] Fix | Delete
// If the selected block has parents, get the top-level parent.
[58996] Fix | Delete
if (selectedBlockParentClientIds?.length) {
[58997] Fix | Delete
// If the selected block has parents,
[58998] Fix | Delete
// expand the tree branch.
[58999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function