Skip to content

Commit

Permalink
Move pure function
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 5, 2024
1 parent 55fc09e commit bdcb6a4
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions packages/block-editor/src/components/use-block-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ export function isDropTargetValid(
return areBlocksAllowed && targetMatchesDraggedBlockParents;
}

/**
* Checks if the given element is an insertion point.
*
* @param {EventTarget|null} targetToCheck - The element to check.
* @param {Document} ownerDocument - The owner document of the element.
* @return {boolean} True if the element is a insertion point, false otherwise.
*/
function isInsertionPoint( targetToCheck, ownerDocument ) {
const { defaultView } = ownerDocument;

return !! (
defaultView &&
targetToCheck instanceof defaultView.HTMLElement &&
targetToCheck.dataset.isInsertionPoint
);
}

/**
* @typedef {Object} WPBlockDropZoneConfig
* @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.
Expand Down Expand Up @@ -515,23 +532,6 @@ export default function useBlockDropZone( {
200
);

/**
* Checks if the given element is an insertion point.
*
* @param {EventTarget|null} targetToCheck - The element to check.
* @param {Document} ownerDocument - The owner document of the element.
* @return {boolean} True if the element is a insertion point, false otherwise.
*/
function isInsertionPoint( targetToCheck, ownerDocument ) {
const { defaultView } = ownerDocument;

return !! (
defaultView &&
targetToCheck instanceof defaultView.HTMLElement &&
targetToCheck.dataset.isInsertionPoint
);
}

return useDropZone( {
dropZoneElement,
isDisabled,
Expand Down

0 comments on commit bdcb6a4

Please sign in to comment.