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
// If we're supposed to focus the block, we'll focus the first inner block
[49500] Fix | Delete
// otherwise, we won't apply any auto-focus.
[49501] Fix | Delete
// This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
[49502] Fix | Delete
getSelectedBlocksInitialCaretPosition());
[49503] Fix | Delete
}
[49504] Fix | Delete
});
[49505] Fix | Delete
return () => {
[49506] Fix | Delete
isCancelled = true;
[49507] Fix | Delete
};
[49508] Fix | Delete
}, [template, templateLock, clientId]);
[49509] Fix | Delete
}
[49510] Fix | Delete
[49511] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-block-context.js
[49512] Fix | Delete
/**
[49513] Fix | Delete
* WordPress dependencies
[49514] Fix | Delete
*/
[49515] Fix | Delete
[49516] Fix | Delete
[49517] Fix | Delete
[49518] Fix | Delete
/**
[49519] Fix | Delete
* Internal dependencies
[49520] Fix | Delete
*/
[49521] Fix | Delete
[49522] Fix | Delete
[49523] Fix | Delete
/**
[49524] Fix | Delete
* Returns a context object for a given block.
[49525] Fix | Delete
*
[49526] Fix | Delete
* @param {string} clientId The block client ID.
[49527] Fix | Delete
*
[49528] Fix | Delete
* @return {Record<string,*>} Context value.
[49529] Fix | Delete
*/
[49530] Fix | Delete
function useBlockContext(clientId) {
[49531] Fix | Delete
return (0,external_wp_data_namespaceObject.useSelect)(select => {
[49532] Fix | Delete
const block = select(store).getBlock(clientId);
[49533] Fix | Delete
if (!block) {
[49534] Fix | Delete
return undefined;
[49535] Fix | Delete
}
[49536] Fix | Delete
const blockType = select(external_wp_blocks_namespaceObject.store).getBlockType(block.name);
[49537] Fix | Delete
if (!blockType) {
[49538] Fix | Delete
return undefined;
[49539] Fix | Delete
}
[49540] Fix | Delete
if (Object.keys(blockType.providesContext).length === 0) {
[49541] Fix | Delete
return undefined;
[49542] Fix | Delete
}
[49543] Fix | Delete
return Object.fromEntries(Object.entries(blockType.providesContext).map(([contextName, attributeName]) => [contextName, block.attributes[attributeName]]));
[49544] Fix | Delete
}, [clientId]);
[49545] Fix | Delete
}
[49546] Fix | Delete
[49547] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-on-block-drop/index.js
[49548] Fix | Delete
/**
[49549] Fix | Delete
* WordPress dependencies
[49550] Fix | Delete
*/
[49551] Fix | Delete
[49552] Fix | Delete
[49553] Fix | Delete
[49554] Fix | Delete
[49555] Fix | Delete
[49556] Fix | Delete
/**
[49557] Fix | Delete
* Internal dependencies
[49558] Fix | Delete
*/
[49559] Fix | Delete
[49560] Fix | Delete
[49561] Fix | Delete
/** @typedef {import('react').SyntheticEvent} SyntheticEvent */
[49562] Fix | Delete
/** @typedef {import('./types').WPDropOperation} WPDropOperation */
[49563] Fix | Delete
[49564] Fix | Delete
/**
[49565] Fix | Delete
* Retrieve the data for a block drop event.
[49566] Fix | Delete
*
[49567] Fix | Delete
* @param {SyntheticEvent} event The drop event.
[49568] Fix | Delete
*
[49569] Fix | Delete
* @return {Object} An object with block drag and drop data.
[49570] Fix | Delete
*/
[49571] Fix | Delete
function parseDropEvent(event) {
[49572] Fix | Delete
let result = {
[49573] Fix | Delete
srcRootClientId: null,
[49574] Fix | Delete
srcClientIds: null,
[49575] Fix | Delete
srcIndex: null,
[49576] Fix | Delete
type: null,
[49577] Fix | Delete
blocks: null
[49578] Fix | Delete
};
[49579] Fix | Delete
if (!event.dataTransfer) {
[49580] Fix | Delete
return result;
[49581] Fix | Delete
}
[49582] Fix | Delete
try {
[49583] Fix | Delete
result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks')));
[49584] Fix | Delete
} catch (err) {
[49585] Fix | Delete
return result;
[49586] Fix | Delete
}
[49587] Fix | Delete
return result;
[49588] Fix | Delete
}
[49589] Fix | Delete
[49590] Fix | Delete
/**
[49591] Fix | Delete
* A function that returns an event handler function for block drop events.
[49592] Fix | Delete
*
[49593] Fix | Delete
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
[49594] Fix | Delete
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
[49595] Fix | Delete
* @param {Function} getBlockIndex A function that gets the index of a block.
[49596] Fix | Delete
* @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
[49597] Fix | Delete
* @param {Function} moveBlocks A function that moves blocks.
[49598] Fix | Delete
* @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
[49599] Fix | Delete
* @param {Function} clearSelectedBlock A function that clears block selection.
[49600] Fix | Delete
* @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.
[49601] Fix | Delete
* @param {Function} getBlock A function that returns a block given its client id.
[49602] Fix | Delete
* @return {Function} The event handler for a block drop event.
[49603] Fix | Delete
*/
[49604] Fix | Delete
function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocks, insertOrReplaceBlocks, clearSelectedBlock, operation, getBlock) {
[49605] Fix | Delete
return event => {
[49606] Fix | Delete
const {
[49607] Fix | Delete
srcRootClientId: sourceRootClientId,
[49608] Fix | Delete
srcClientIds: sourceClientIds,
[49609] Fix | Delete
type: dropType,
[49610] Fix | Delete
blocks
[49611] Fix | Delete
} = parseDropEvent(event);
[49612] Fix | Delete
[49613] Fix | Delete
// If the user is inserting a block.
[49614] Fix | Delete
if (dropType === 'inserter') {
[49615] Fix | Delete
clearSelectedBlock();
[49616] Fix | Delete
const blocksToInsert = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
[49617] Fix | Delete
insertOrReplaceBlocks(blocksToInsert, true, null);
[49618] Fix | Delete
}
[49619] Fix | Delete
[49620] Fix | Delete
// If the user is moving a block.
[49621] Fix | Delete
if (dropType === 'block') {
[49622] Fix | Delete
const sourceBlockIndex = getBlockIndex(sourceClientIds[0]);
[49623] Fix | Delete
[49624] Fix | Delete
// If the user is dropping to the same position, return early.
[49625] Fix | Delete
if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
[49626] Fix | Delete
return;
[49627] Fix | Delete
}
[49628] Fix | Delete
[49629] Fix | Delete
// If the user is attempting to drop a block within its own
[49630] Fix | Delete
// nested blocks, return early as this would create infinite
[49631] Fix | Delete
// recursion.
[49632] Fix | Delete
if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
[49633] Fix | Delete
return;
[49634] Fix | Delete
}
[49635] Fix | Delete
[49636] Fix | Delete
// If the user is dropping a block over another block, replace both blocks
[49637] Fix | Delete
// with a group block containing them
[49638] Fix | Delete
if (operation === 'group') {
[49639] Fix | Delete
const blocksToInsert = sourceClientIds.map(clientId => getBlock(clientId));
[49640] Fix | Delete
insertOrReplaceBlocks(blocksToInsert, true, null, sourceClientIds);
[49641] Fix | Delete
return;
[49642] Fix | Delete
}
[49643] Fix | Delete
const isAtSameLevel = sourceRootClientId === targetRootClientId;
[49644] Fix | Delete
const draggedBlockCount = sourceClientIds.length;
[49645] Fix | Delete
[49646] Fix | Delete
// If the block is kept at the same level and moved downwards,
[49647] Fix | Delete
// subtract to take into account that the blocks being dragged
[49648] Fix | Delete
// were removed from the block list above the insertion point.
[49649] Fix | Delete
const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
[49650] Fix | Delete
moveBlocks(sourceClientIds, sourceRootClientId, insertIndex);
[49651] Fix | Delete
}
[49652] Fix | Delete
};
[49653] Fix | Delete
}
[49654] Fix | Delete
[49655] Fix | Delete
/**
[49656] Fix | Delete
* A function that returns an event handler function for block-related file drop events.
[49657] Fix | Delete
*
[49658] Fix | Delete
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
[49659] Fix | Delete
* @param {Function} getSettings A function that gets the block editor settings.
[49660] Fix | Delete
* @param {Function} updateBlockAttributes A function that updates a block's attributes.
[49661] Fix | Delete
* @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
[49662] Fix | Delete
* @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
[49663] Fix | Delete
*
[49664] Fix | Delete
* @return {Function} The event handler for a block-related file drop event.
[49665] Fix | Delete
*/
[49666] Fix | Delete
function onFilesDrop(targetRootClientId, getSettings, updateBlockAttributes, canInsertBlockType, insertOrReplaceBlocks) {
[49667] Fix | Delete
return files => {
[49668] Fix | Delete
if (!getSettings().mediaUpload) {
[49669] Fix | Delete
return;
[49670] Fix | Delete
}
[49671] Fix | Delete
const transformation = (0,external_wp_blocks_namespaceObject.findTransform)((0,external_wp_blocks_namespaceObject.getBlockTransforms)('from'), transform => transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files));
[49672] Fix | Delete
if (transformation) {
[49673] Fix | Delete
const blocks = transformation.transform(files, updateBlockAttributes);
[49674] Fix | Delete
insertOrReplaceBlocks(blocks);
[49675] Fix | Delete
}
[49676] Fix | Delete
};
[49677] Fix | Delete
}
[49678] Fix | Delete
[49679] Fix | Delete
/**
[49680] Fix | Delete
* A function that returns an event handler function for block-related HTML drop events.
[49681] Fix | Delete
*
[49682] Fix | Delete
* @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
[49683] Fix | Delete
*
[49684] Fix | Delete
* @return {Function} The event handler for a block-related HTML drop event.
[49685] Fix | Delete
*/
[49686] Fix | Delete
function onHTMLDrop(insertOrReplaceBlocks) {
[49687] Fix | Delete
return HTML => {
[49688] Fix | Delete
const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
[49689] Fix | Delete
HTML,
[49690] Fix | Delete
mode: 'BLOCKS'
[49691] Fix | Delete
});
[49692] Fix | Delete
if (blocks.length) {
[49693] Fix | Delete
insertOrReplaceBlocks(blocks);
[49694] Fix | Delete
}
[49695] Fix | Delete
};
[49696] Fix | Delete
}
[49697] Fix | Delete
[49698] Fix | Delete
/**
[49699] Fix | Delete
* A React hook for handling block drop events.
[49700] Fix | Delete
*
[49701] Fix | Delete
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
[49702] Fix | Delete
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
[49703] Fix | Delete
* @param {Object} options The optional options.
[49704] Fix | Delete
* @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.
[49705] Fix | Delete
*
[49706] Fix | Delete
* @return {Function} A function to be passed to the onDrop handler.
[49707] Fix | Delete
*/
[49708] Fix | Delete
function useOnBlockDrop(targetRootClientId, targetBlockIndex, options = {}) {
[49709] Fix | Delete
const {
[49710] Fix | Delete
operation = 'insert',
[49711] Fix | Delete
nearestSide = 'right'
[49712] Fix | Delete
} = options;
[49713] Fix | Delete
const {
[49714] Fix | Delete
canInsertBlockType,
[49715] Fix | Delete
getBlockIndex,
[49716] Fix | Delete
getClientIdsOfDescendants,
[49717] Fix | Delete
getBlockOrder,
[49718] Fix | Delete
getBlocksByClientId,
[49719] Fix | Delete
getSettings,
[49720] Fix | Delete
getBlock,
[49721] Fix | Delete
isGroupable
[49722] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store);
[49723] Fix | Delete
const {
[49724] Fix | Delete
getGroupingBlockName
[49725] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
[49726] Fix | Delete
const {
[49727] Fix | Delete
insertBlocks,
[49728] Fix | Delete
moveBlocksToPosition,
[49729] Fix | Delete
updateBlockAttributes,
[49730] Fix | Delete
clearSelectedBlock,
[49731] Fix | Delete
replaceBlocks,
[49732] Fix | Delete
removeBlocks
[49733] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
[49734] Fix | Delete
const registry = (0,external_wp_data_namespaceObject.useRegistry)();
[49735] Fix | Delete
const insertOrReplaceBlocks = (0,external_wp_element_namespaceObject.useCallback)((blocks, updateSelection = true, initialPosition = 0, clientIdsToReplace = []) => {
[49736] Fix | Delete
if (!Array.isArray(blocks)) {
[49737] Fix | Delete
blocks = [blocks];
[49738] Fix | Delete
}
[49739] Fix | Delete
const clientIds = getBlockOrder(targetRootClientId);
[49740] Fix | Delete
const clientId = clientIds[targetBlockIndex];
[49741] Fix | Delete
const blocksClientIds = blocks.map(block => block.clientId);
[49742] Fix | Delete
const areGroupableBlocks = isGroupable([...blocksClientIds, clientId]);
[49743] Fix | Delete
if (operation === 'replace') {
[49744] Fix | Delete
replaceBlocks(clientId, blocks, undefined, initialPosition);
[49745] Fix | Delete
} else if (operation === 'group' && areGroupableBlocks) {
[49746] Fix | Delete
const targetBlock = getBlock(clientId);
[49747] Fix | Delete
if (nearestSide === 'left') {
[49748] Fix | Delete
blocks.push(targetBlock);
[49749] Fix | Delete
} else {
[49750] Fix | Delete
blocks.unshift(targetBlock);
[49751] Fix | Delete
}
[49752] Fix | Delete
const groupInnerBlocks = blocks.map(block => {
[49753] Fix | Delete
return (0,external_wp_blocks_namespaceObject.createBlock)(block.name, block.attributes, block.innerBlocks);
[49754] Fix | Delete
});
[49755] Fix | Delete
const areAllImages = blocks.every(block => {
[49756] Fix | Delete
return block.name === 'core/image';
[49757] Fix | Delete
});
[49758] Fix | Delete
const galleryBlock = canInsertBlockType('core/gallery', targetRootClientId);
[49759] Fix | Delete
const wrappedBlocks = (0,external_wp_blocks_namespaceObject.createBlock)(areAllImages && galleryBlock ? 'core/gallery' : getGroupingBlockName(), {
[49760] Fix | Delete
layout: {
[49761] Fix | Delete
type: 'flex',
[49762] Fix | Delete
flexWrap: areAllImages && galleryBlock ? null : 'nowrap'
[49763] Fix | Delete
}
[49764] Fix | Delete
}, groupInnerBlocks);
[49765] Fix | Delete
// Need to make sure both the target block and the block being dragged are replaced
[49766] Fix | Delete
// otherwise the dragged block will be duplicated.
[49767] Fix | Delete
replaceBlocks([clientId, ...clientIdsToReplace], wrappedBlocks, undefined, initialPosition);
[49768] Fix | Delete
} else {
[49769] Fix | Delete
insertBlocks(blocks, targetBlockIndex, targetRootClientId, updateSelection, initialPosition);
[49770] Fix | Delete
}
[49771] Fix | Delete
}, [getBlockOrder, targetRootClientId, targetBlockIndex, isGroupable, operation, replaceBlocks, getBlock, nearestSide, canInsertBlockType, getGroupingBlockName, insertBlocks]);
[49772] Fix | Delete
const moveBlocks = (0,external_wp_element_namespaceObject.useCallback)((sourceClientIds, sourceRootClientId, insertIndex) => {
[49773] Fix | Delete
if (operation === 'replace') {
[49774] Fix | Delete
const sourceBlocks = getBlocksByClientId(sourceClientIds);
[49775] Fix | Delete
const targetBlockClientIds = getBlockOrder(targetRootClientId);
[49776] Fix | Delete
const targetBlockClientId = targetBlockClientIds[targetBlockIndex];
[49777] Fix | Delete
registry.batch(() => {
[49778] Fix | Delete
// Remove the source blocks.
[49779] Fix | Delete
removeBlocks(sourceClientIds, false);
[49780] Fix | Delete
// Replace the target block with the source blocks.
[49781] Fix | Delete
replaceBlocks(targetBlockClientId, sourceBlocks, undefined, 0);
[49782] Fix | Delete
});
[49783] Fix | Delete
} else {
[49784] Fix | Delete
moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
[49785] Fix | Delete
}
[49786] Fix | Delete
}, [operation, getBlockOrder, getBlocksByClientId, moveBlocksToPosition, registry, removeBlocks, replaceBlocks, targetBlockIndex, targetRootClientId]);
[49787] Fix | Delete
const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocks, insertOrReplaceBlocks, clearSelectedBlock, operation, getBlock);
[49788] Fix | Delete
const _onFilesDrop = onFilesDrop(targetRootClientId, getSettings, updateBlockAttributes, canInsertBlockType, insertOrReplaceBlocks);
[49789] Fix | Delete
const _onHTMLDrop = onHTMLDrop(insertOrReplaceBlocks);
[49790] Fix | Delete
return event => {
[49791] Fix | Delete
const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(event.dataTransfer);
[49792] Fix | Delete
const html = event.dataTransfer.getData('text/html');
[49793] Fix | Delete
[49794] Fix | Delete
/**
[49795] Fix | Delete
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
[49796] Fix | Delete
* The order of the checks is important to recognise the HTML drop.
[49797] Fix | Delete
*/
[49798] Fix | Delete
if (html) {
[49799] Fix | Delete
_onHTMLDrop(html);
[49800] Fix | Delete
} else if (files.length) {
[49801] Fix | Delete
_onFilesDrop(files);
[49802] Fix | Delete
} else {
[49803] Fix | Delete
_onDrop(event);
[49804] Fix | Delete
}
[49805] Fix | Delete
};
[49806] Fix | Delete
}
[49807] Fix | Delete
[49808] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/math.js
[49809] Fix | Delete
/**
[49810] Fix | Delete
* A string representing the name of an edge.
[49811] Fix | Delete
*
[49812] Fix | Delete
* @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
[49813] Fix | Delete
*/
[49814] Fix | Delete
[49815] Fix | Delete
/**
[49816] Fix | Delete
* @typedef {Object} WPPoint
[49817] Fix | Delete
* @property {number} x The horizontal position.
[49818] Fix | Delete
* @property {number} y The vertical position.
[49819] Fix | Delete
*/
[49820] Fix | Delete
[49821] Fix | Delete
/**
[49822] Fix | Delete
* Given a point, a DOMRect and the name of an edge, returns the distance to
[49823] Fix | Delete
* that edge of the rect.
[49824] Fix | Delete
*
[49825] Fix | Delete
* This function works for edges that are horizontal or vertical (e.g. not
[49826] Fix | Delete
* rotated), the following terms are used so that the function works in both
[49827] Fix | Delete
* orientations:
[49828] Fix | Delete
*
[49829] Fix | Delete
* - Forward, meaning the axis running horizontally when an edge is vertical
[49830] Fix | Delete
* and vertically when an edge is horizontal.
[49831] Fix | Delete
* - Lateral, meaning the axis running vertically when an edge is vertical
[49832] Fix | Delete
* and horizontally when an edge is horizontal.
[49833] Fix | Delete
*
[49834] Fix | Delete
* @param {WPPoint} point The point to measure distance from.
[49835] Fix | Delete
* @param {DOMRect} rect A DOM Rect containing edge positions.
[49836] Fix | Delete
* @param {WPEdgeName} edge The edge to measure to.
[49837] Fix | Delete
*/
[49838] Fix | Delete
function getDistanceFromPointToEdge(point, rect, edge) {
[49839] Fix | Delete
const isHorizontal = edge === 'top' || edge === 'bottom';
[49840] Fix | Delete
const {
[49841] Fix | Delete
x,
[49842] Fix | Delete
y
[49843] Fix | Delete
} = point;
[49844] Fix | Delete
const pointLateralPosition = isHorizontal ? x : y;
[49845] Fix | Delete
const pointForwardPosition = isHorizontal ? y : x;
[49846] Fix | Delete
const edgeStart = isHorizontal ? rect.left : rect.top;
[49847] Fix | Delete
const edgeEnd = isHorizontal ? rect.right : rect.bottom;
[49848] Fix | Delete
const edgeForwardPosition = rect[edge];
[49849] Fix | Delete
[49850] Fix | Delete
// Measure the straight line distance to the edge of the rect, when the
[49851] Fix | Delete
// point is adjacent to the edge.
[49852] Fix | Delete
// Else, if the point is positioned diagonally to the edge of the rect,
[49853] Fix | Delete
// measure diagonally to the nearest corner that the edge meets.
[49854] Fix | Delete
let edgeLateralPosition;
[49855] Fix | Delete
if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
[49856] Fix | Delete
edgeLateralPosition = pointLateralPosition;
[49857] Fix | Delete
} else if (pointLateralPosition < edgeEnd) {
[49858] Fix | Delete
edgeLateralPosition = edgeStart;
[49859] Fix | Delete
} else {
[49860] Fix | Delete
edgeLateralPosition = edgeEnd;
[49861] Fix | Delete
}
[49862] Fix | Delete
return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2);
[49863] Fix | Delete
}
[49864] Fix | Delete
[49865] Fix | Delete
/**
[49866] Fix | Delete
* Given a point, a DOMRect and a list of allowed edges returns the name of and
[49867] Fix | Delete
* distance to the nearest edge.
[49868] Fix | Delete
*
[49869] Fix | Delete
* @param {WPPoint} point The point to measure distance from.
[49870] Fix | Delete
* @param {DOMRect} rect A DOM Rect containing edge positions.
[49871] Fix | Delete
* @param {WPEdgeName[]} allowedEdges A list of the edges included in the
[49872] Fix | Delete
* calculation. Defaults to all edges.
[49873] Fix | Delete
*
[49874] Fix | Delete
* @return {[number, string]} An array where the first value is the distance
[49875] Fix | Delete
* and a second is the edge name.
[49876] Fix | Delete
*/
[49877] Fix | Delete
function getDistanceToNearestEdge(point, rect, allowedEdges = ['top', 'bottom', 'left', 'right']) {
[49878] Fix | Delete
let candidateDistance;
[49879] Fix | Delete
let candidateEdge;
[49880] Fix | Delete
allowedEdges.forEach(edge => {
[49881] Fix | Delete
const distance = getDistanceFromPointToEdge(point, rect, edge);
[49882] Fix | Delete
if (candidateDistance === undefined || distance < candidateDistance) {
[49883] Fix | Delete
candidateDistance = distance;
[49884] Fix | Delete
candidateEdge = edge;
[49885] Fix | Delete
}
[49886] Fix | Delete
});
[49887] Fix | Delete
return [candidateDistance, candidateEdge];
[49888] Fix | Delete
}
[49889] Fix | Delete
[49890] Fix | Delete
/**
[49891] Fix | Delete
* Is the point contained by the rectangle.
[49892] Fix | Delete
*
[49893] Fix | Delete
* @param {WPPoint} point The point.
[49894] Fix | Delete
* @param {DOMRect} rect The rectangle.
[49895] Fix | Delete
*
[49896] Fix | Delete
* @return {boolean} True if the point is contained by the rectangle, false otherwise.
[49897] Fix | Delete
*/
[49898] Fix | Delete
function isPointContainedByRect(point, rect) {
[49899] Fix | Delete
return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
[49900] Fix | Delete
}
[49901] Fix | Delete
[49902] Fix | Delete
/**
[49903] Fix | Delete
* Is the point within the top and bottom boundaries of the rectangle.
[49904] Fix | Delete
*
[49905] Fix | Delete
* @param {WPPoint} point The point.
[49906] Fix | Delete
* @param {DOMRect} rect The rectangle.
[49907] Fix | Delete
*
[49908] Fix | Delete
* @return {boolean} True if the point is within top and bottom of rectangle, false otherwise.
[49909] Fix | Delete
*/
[49910] Fix | Delete
function isPointWithinTopAndBottomBoundariesOfRect(point, rect) {
[49911] Fix | Delete
return rect.top <= point.y && rect.bottom >= point.y;
[49912] Fix | Delete
}
[49913] Fix | Delete
[49914] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-drop-zone/index.js
[49915] Fix | Delete
/**
[49916] Fix | Delete
* WordPress dependencies
[49917] Fix | Delete
*/
[49918] Fix | Delete
[49919] Fix | Delete
[49920] Fix | Delete
[49921] Fix | Delete
[49922] Fix | Delete
[49923] Fix | Delete
[49924] Fix | Delete
/**
[49925] Fix | Delete
* Internal dependencies
[49926] Fix | Delete
*/
[49927] Fix | Delete
[49928] Fix | Delete
[49929] Fix | Delete
[49930] Fix | Delete
[49931] Fix | Delete
const THRESHOLD_DISTANCE = 30;
[49932] Fix | Delete
const MINIMUM_HEIGHT_FOR_THRESHOLD = 120;
[49933] Fix | Delete
const MINIMUM_WIDTH_FOR_THRESHOLD = 120;
[49934] Fix | Delete
[49935] Fix | Delete
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
[49936] Fix | Delete
/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */
[49937] Fix | Delete
[49938] Fix | Delete
/**
[49939] Fix | Delete
* The orientation of a block list.
[49940] Fix | Delete
*
[49941] Fix | Delete
* @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
[49942] Fix | Delete
*/
[49943] Fix | Delete
[49944] Fix | Delete
/**
[49945] Fix | Delete
* The insert position when dropping a block.
[49946] Fix | Delete
*
[49947] Fix | Delete
* @typedef {'before'|'after'} WPInsertPosition
[49948] Fix | Delete
*/
[49949] Fix | Delete
[49950] Fix | Delete
/**
[49951] Fix | Delete
* @typedef {Object} WPBlockData
[49952] Fix | Delete
* @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.
[49953] Fix | Delete
* @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.
[49954] Fix | Delete
* @property {number} blockIndex The index of the block.
[49955] Fix | Delete
*/
[49956] Fix | Delete
[49957] Fix | Delete
/**
[49958] Fix | Delete
* Get the drop target position from a given drop point and the orientation.
[49959] Fix | Delete
*
[49960] Fix | Delete
* @param {WPBlockData[]} blocksData The block data list.
[49961] Fix | Delete
* @param {WPPoint} position The position of the item being dragged.
[49962] Fix | Delete
* @param {WPBlockListOrientation} orientation The orientation of the block list.
[49963] Fix | Delete
* @param {Object} options Additional options.
[49964] Fix | Delete
* @return {[number, WPDropOperation]} The drop target position.
[49965] Fix | Delete
*/
[49966] Fix | Delete
function getDropTargetPosition(blocksData, position, orientation = 'vertical', options = {}) {
[49967] Fix | Delete
const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
[49968] Fix | Delete
let nearestIndex = 0;
[49969] Fix | Delete
let insertPosition = 'before';
[49970] Fix | Delete
let minDistance = Infinity;
[49971] Fix | Delete
let targetBlockIndex = null;
[49972] Fix | Delete
let nearestSide = 'right';
[49973] Fix | Delete
const {
[49974] Fix | Delete
dropZoneElement,
[49975] Fix | Delete
parentBlockOrientation,
[49976] Fix | Delete
rootBlockIndex = 0
[49977] Fix | Delete
} = options;
[49978] Fix | Delete
[49979] Fix | Delete
// Allow before/after when dragging over the top/bottom edges of the drop zone.
[49980] Fix | Delete
if (dropZoneElement && parentBlockOrientation !== 'horizontal') {
[49981] Fix | Delete
const rect = dropZoneElement.getBoundingClientRect();
[49982] Fix | Delete
const [distance, edge] = getDistanceToNearestEdge(position, rect, ['top', 'bottom']);
[49983] Fix | Delete
[49984] Fix | Delete
// If dragging over the top or bottom of the drop zone, insert the block
[49985] Fix | Delete
// before or after the parent block. This only applies to blocks that use
[49986] Fix | Delete
// a drop zone element, typically container blocks such as Group or Cover.
[49987] Fix | Delete
if (rect.height > MINIMUM_HEIGHT_FOR_THRESHOLD && distance < THRESHOLD_DISTANCE) {
[49988] Fix | Delete
if (edge === 'top') {
[49989] Fix | Delete
return [rootBlockIndex, 'before'];
[49990] Fix | Delete
}
[49991] Fix | Delete
if (edge === 'bottom') {
[49992] Fix | Delete
return [rootBlockIndex + 1, 'after'];
[49993] Fix | Delete
}
[49994] Fix | Delete
}
[49995] Fix | Delete
}
[49996] Fix | Delete
const isRightToLeft = (0,external_wp_i18n_namespaceObject.isRTL)();
[49997] Fix | Delete
[49998] Fix | Delete
// Allow before/after when dragging over the left/right edges of the drop zone.
[49999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function