@wordpress/block-editor 15.6.7 → 15.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +3 -3
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-selectors.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +3 -3
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +3 -3
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-settings-menu-controls/index.js +1 -1
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/block.js +3 -3
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/store/private-selectors.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-block-drop-zone/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tif ( ! rect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.closest( '[data-is-insertion-point]' )\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOut,\n\t\tgetSectionRootClientId,\n\t\tgetBlockParents,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\n\t\t\t\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\t\t\t\tconst targetParents = [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\t...getBlockParents( targetRootClientId, true ),\n\t\t\t\t];\n\n\t\t\t\t// Check if the target is within any of the dragged blocks.\n\t\t\t\tconst isTargetWithinDraggedBlocks = draggedBlockClientIds.some(\n\t\t\t\t\t( clientId ) => targetParents.includes( clientId )\n\t\t\t\t);\n\n\t\t\t\tif ( isTargetWithinDraggedBlocks ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tdraggedBlockClientIds\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId )\n\t\t\t\t\t// Filter out blocks that are hidden\n\t\t\t\t\t.filter( ( block ) => {\n\t\t\t\t\t\treturn ! (\n\t\t\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\t\t'blockVisibility',\n\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\tblock.attributes?.metadata?.blockVisibility ===\n\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () => {\n\t\t\t\t\t\t\tconst blockElement = ownerDocument.getElementById(\n\t\t\t\t\t\t\t\t`block-${ clientId }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn blockElement\n\t\t\t\t\t\t\t\t? blockElement.getBoundingClientRect()\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tconst isTargetIndexEmptyDefaultBlock =\n\t\t\t\t\tblocksData[ targetIndex ]?.isUnmodifiedDefaultBlock;\n\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\t! isTargetIndexEmptyDefaultBlock &&\n\t\t\t\t\toperation !== 'insert'\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\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,UAAW,kBAAmB,EAE3C,OAAQ,CAAE,UAAW;AACrB,iBAAO,EACN
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tif ( ! rect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.closest( '[data-is-insertion-point]' )\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOut,\n\t\tgetSectionRootClientId,\n\t\tgetBlockParents,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\n\t\t\t\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\t\t\t\tconst targetParents = [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\t...getBlockParents( targetRootClientId, true ),\n\t\t\t\t];\n\n\t\t\t\t// Check if the target is within any of the dragged blocks.\n\t\t\t\tconst isTargetWithinDraggedBlocks = draggedBlockClientIds.some(\n\t\t\t\t\t( clientId ) => targetParents.includes( clientId )\n\t\t\t\t);\n\n\t\t\t\tif ( isTargetWithinDraggedBlocks ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tdraggedBlockClientIds\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId )\n\t\t\t\t\t// Filter out blocks that are hidden\n\t\t\t\t\t.filter( ( block ) => {\n\t\t\t\t\t\treturn ! (\n\t\t\t\t\t\t\thasBlockSupport( block.name, 'visibility', true ) &&\n\t\t\t\t\t\t\tblock.attributes?.metadata?.blockVisibility ===\n\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () => {\n\t\t\t\t\t\t\tconst blockElement = ownerDocument.getElementById(\n\t\t\t\t\t\t\t\t`block-${ clientId }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn blockElement\n\t\t\t\t\t\t\t\t? blockElement.getBoundingClientRect()\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tconst isTargetIndexEmptyDefaultBlock =\n\t\t\t\t\tblocksData[ targetIndex ]?.isUnmodifiedDefaultBlock;\n\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\t! isTargetIndexEmptyDefaultBlock &&\n\t\t\t\t\toperation !== 'insert'\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,aAAa,gBAAgB;AACtC;AAAA,EACC;AAAA,EACA,6BAA6B;AAAA,OACvB;AACP,SAAS,aAAa;AACtB;AAAA,EACC;AAAA,EACA,4BAA4B;AAAA,EAC5B,SAAS;AAAA,OACH;AAKP,OAAO,oBAAoB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,MAAM,qBAAqB;AAC3B,MAAM,+BAA+B;AACrC,MAAM,8BAA8B;AAiC7B,SAAS,sBACf,YACA,UACA,cAAc,YACd,UAAU,CAAC,GACV;AACD,QAAM,eACL,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B,wBAAe;AAAA,YACd,OAAO;AAAA,YACP;AAAA,YACA;AAAA,UACD,CAAE;AAEF,gBAAM,yBAAyB;AAAA,YAC9B;AAAA,YACA;AAAA,UACD,EAAE,SAAU,SAAU,IACnB,sBACA;AAEH,6BAAoB,wBAAwB,aAAa;AAAA,YACxD;AAAA,YACA;AAAA,UACD,CAAE;AAAA,QACH,CAAE;AAAA,MACH;AAAA,MACA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,EACD;AAEA,SAAO,YAAa;AAAA,IACnB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAY,OAAQ;AAInB,gBAAW,OAAO,MAAM,cAAc,aAAc;AAAA,IACrD;AAAA,IACA,YAAa,OAAQ;AACpB,YAAM,EAAE,cAAc,IAAI,MAAM;AAIhC,UACC,iBAAkB,MAAM,eAAe,aAAc,KACrD,iBAAkB,MAAM,QAAQ,aAAc,GAC7C;AACD;AAAA,MACD;AAEA,gBAAU,OAAO;AACjB,yBAAmB;AAAA,IACpB;AAAA,IACA,YAAY;AACX,gBAAU,OAAO;AACjB,mBAAa;AACb,yBAAmB;AAAA,IACpB;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,7 @@ function addTransforms(result, source, index, results) {
|
|
|
34
34
|
if (sourceMetadata.name && !result.attributes?.metadata?.name && hasBlockSupport(result.name, "renaming", true)) {
|
|
35
35
|
preservedMetadata.name = sourceMetadata.name;
|
|
36
36
|
}
|
|
37
|
-
if (sourceMetadata.blockVisibility !== void 0 && !result.attributes?.metadata?.blockVisibility && hasBlockSupport(result.name, "
|
|
37
|
+
if (sourceMetadata.blockVisibility !== void 0 && !result.attributes?.metadata?.blockVisibility && hasBlockSupport(result.name, "visibility", true)) {
|
|
38
38
|
preservedMetadata.blockVisibility = sourceMetadata.blockVisibility;
|
|
39
39
|
}
|
|
40
40
|
if (Object.keys(preservedMetadata).length > 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/metadata.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\nconst META_ATTRIBUTE_NAME = 'metadata';\n\n/**\n * Filters registered block settings, extending attributes to include `metadata`.\n *\n * see: https://github.com/WordPress/gutenberg/pull/40393/files#r864632012\n *\n * @param {Object} blockTypeSettings Original block settings.\n * @return {Object} Filtered block settings.\n */\nexport function addMetaAttribute( blockTypeSettings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( blockTypeSettings?.attributes?.[ META_ATTRIBUTE_NAME ]?.type ) {\n\t\treturn blockTypeSettings;\n\t}\n\n\tblockTypeSettings.attributes = {\n\t\t...blockTypeSettings.attributes,\n\t\t[ META_ATTRIBUTE_NAME ]: {\n\t\t\ttype: 'object',\n\t\t},\n\t};\n\n\treturn blockTypeSettings;\n}\n\n/**\n * Add metadata transforms.\n *\n * @param {Object} result The transformed block.\n * @param {Array} source Original blocks transformed.\n * @param {number} index Index of the transformed block.\n * @param {Array} results All blocks that resulted from the transformation.\n * @return {Object} Modified transformed block.\n */\nexport function addTransforms( result, source, index, results ) {\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the metadata should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the metadata during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming multiple blocks to multiple blocks with different counts,\n\t// we ignore the metadata during the transform.\n\tif (\n\t\tresults.length > 1 &&\n\t\tsource.length > 1 &&\n\t\tresults.length !== source.length\n\t) {\n\t\treturn result;\n\t}\n\n\tconst sourceMetadata = source[ index ]?.attributes?.metadata;\n\n\tif ( ! sourceMetadata ) {\n\t\treturn result;\n\t}\n\n\tconst preservedMetadata = {};\n\n\t// Notes\n\tif ( sourceMetadata.noteId && ! result.attributes?.metadata?.noteId ) {\n\t\tpreservedMetadata.noteId = sourceMetadata.noteId;\n\t}\n\n\t// Custom name\n\tif (\n\t\tsourceMetadata.name &&\n\t\t! result.attributes?.metadata?.name &&\n\t\thasBlockSupport( result.name, 'renaming', true )\n\t) {\n\t\tpreservedMetadata.name = sourceMetadata.name;\n\t}\n\n\t// Block visibility\n\tif (\n\t\tsourceMetadata.blockVisibility !== undefined &&\n\t\t! result.attributes?.metadata?.blockVisibility &&\n\t\thasBlockSupport( result.name, '
|
|
5
|
-
"mappings": "AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAEhC,MAAM,sBAAsB;AAUrB,SAAS,iBAAkB,mBAAoB;AAErD,MAAK,mBAAmB,aAAc,mBAAoB,GAAG,MAAO;AACnE,WAAO;AAAA,EACR;AAEA,oBAAkB,aAAa;AAAA,IAC9B,GAAG,kBAAkB;AAAA,IACrB,CAAE,mBAAoB,GAAG;AAAA,MACxB,MAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO;AACR;AAWO,SAAS,cAAe,QAAQ,QAAQ,OAAO,SAAU;AAG/D,MAAK,QAAQ,WAAW,KAAK,OAAO,YAAY,WAAW,OAAO,QAAS;AAC1E,WAAO;AAAA,EACR;AAIA,MACG,QAAQ,WAAW,KAAK,OAAO,SAAS,KACxC,QAAQ,SAAS,KAAK,OAAO,WAAW,GACzC;AACD,WAAO;AAAA,EACR;AAIA,MACC,QAAQ,SAAS,KACjB,OAAO,SAAS,KAChB,QAAQ,WAAW,OAAO,QACzB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,OAAQ,KAAM,GAAG,YAAY;AAEpD,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,oBAAoB,CAAC;AAG3B,MAAK,eAAe,UAAU,CAAE,OAAO,YAAY,UAAU,QAAS;AACrE,sBAAkB,SAAS,eAAe;AAAA,EAC3C;AAGA,MACC,eAAe,QACf,CAAE,OAAO,YAAY,UAAU,QAC/B,gBAAiB,OAAO,MAAM,YAAY,IAAK,GAC9C;AACD,sBAAkB,OAAO,eAAe;AAAA,EACzC;AAGA,MACC,eAAe,oBAAoB,UACnC,CAAE,OAAO,YAAY,UAAU,mBAC/B,gBAAiB,OAAO,MAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\nconst META_ATTRIBUTE_NAME = 'metadata';\n\n/**\n * Filters registered block settings, extending attributes to include `metadata`.\n *\n * see: https://github.com/WordPress/gutenberg/pull/40393/files#r864632012\n *\n * @param {Object} blockTypeSettings Original block settings.\n * @return {Object} Filtered block settings.\n */\nexport function addMetaAttribute( blockTypeSettings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( blockTypeSettings?.attributes?.[ META_ATTRIBUTE_NAME ]?.type ) {\n\t\treturn blockTypeSettings;\n\t}\n\n\tblockTypeSettings.attributes = {\n\t\t...blockTypeSettings.attributes,\n\t\t[ META_ATTRIBUTE_NAME ]: {\n\t\t\ttype: 'object',\n\t\t},\n\t};\n\n\treturn blockTypeSettings;\n}\n\n/**\n * Add metadata transforms.\n *\n * @param {Object} result The transformed block.\n * @param {Array} source Original blocks transformed.\n * @param {number} index Index of the transformed block.\n * @param {Array} results All blocks that resulted from the transformation.\n * @return {Object} Modified transformed block.\n */\nexport function addTransforms( result, source, index, results ) {\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the metadata should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the metadata during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming multiple blocks to multiple blocks with different counts,\n\t// we ignore the metadata during the transform.\n\tif (\n\t\tresults.length > 1 &&\n\t\tsource.length > 1 &&\n\t\tresults.length !== source.length\n\t) {\n\t\treturn result;\n\t}\n\n\tconst sourceMetadata = source[ index ]?.attributes?.metadata;\n\n\tif ( ! sourceMetadata ) {\n\t\treturn result;\n\t}\n\n\tconst preservedMetadata = {};\n\n\t// Notes\n\tif ( sourceMetadata.noteId && ! result.attributes?.metadata?.noteId ) {\n\t\tpreservedMetadata.noteId = sourceMetadata.noteId;\n\t}\n\n\t// Custom name\n\tif (\n\t\tsourceMetadata.name &&\n\t\t! result.attributes?.metadata?.name &&\n\t\thasBlockSupport( result.name, 'renaming', true )\n\t) {\n\t\tpreservedMetadata.name = sourceMetadata.name;\n\t}\n\n\t// Block visibility\n\tif (\n\t\tsourceMetadata.blockVisibility !== undefined &&\n\t\t! result.attributes?.metadata?.blockVisibility &&\n\t\thasBlockSupport( result.name, 'visibility', true )\n\t) {\n\t\tpreservedMetadata.blockVisibility = sourceMetadata.blockVisibility;\n\t}\n\n\tif ( Object.keys( preservedMetadata ).length > 0 ) {\n\t\treturn {\n\t\t\t...result,\n\t\t\tattributes: {\n\t\t\t\t...result.attributes,\n\t\t\t\tmetadata: {\n\t\t\t\t\t...result.attributes.metadata,\n\t\t\t\t\t...preservedMetadata,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addMetaAttribute',\n\taddMetaAttribute\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/metadata/addTransforms',\n\taddTransforms\n);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAEhC,MAAM,sBAAsB;AAUrB,SAAS,iBAAkB,mBAAoB;AAErD,MAAK,mBAAmB,aAAc,mBAAoB,GAAG,MAAO;AACnE,WAAO;AAAA,EACR;AAEA,oBAAkB,aAAa;AAAA,IAC9B,GAAG,kBAAkB;AAAA,IACrB,CAAE,mBAAoB,GAAG;AAAA,MACxB,MAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO;AACR;AAWO,SAAS,cAAe,QAAQ,QAAQ,OAAO,SAAU;AAG/D,MAAK,QAAQ,WAAW,KAAK,OAAO,YAAY,WAAW,OAAO,QAAS;AAC1E,WAAO;AAAA,EACR;AAIA,MACG,QAAQ,WAAW,KAAK,OAAO,SAAS,KACxC,QAAQ,SAAS,KAAK,OAAO,WAAW,GACzC;AACD,WAAO;AAAA,EACR;AAIA,MACC,QAAQ,SAAS,KACjB,OAAO,SAAS,KAChB,QAAQ,WAAW,OAAO,QACzB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,OAAQ,KAAM,GAAG,YAAY;AAEpD,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,oBAAoB,CAAC;AAG3B,MAAK,eAAe,UAAU,CAAE,OAAO,YAAY,UAAU,QAAS;AACrE,sBAAkB,SAAS,eAAe;AAAA,EAC3C;AAGA,MACC,eAAe,QACf,CAAE,OAAO,YAAY,UAAU,QAC/B,gBAAiB,OAAO,MAAM,YAAY,IAAK,GAC9C;AACD,sBAAkB,OAAO,eAAe;AAAA,EACzC;AAGA,MACC,eAAe,oBAAoB,UACnC,CAAE,OAAO,YAAY,UAAU,mBAC/B,gBAAiB,OAAO,MAAM,cAAc,IAAK,GAChD;AACD,sBAAkB,kBAAkB,eAAe;AAAA,EACpD;AAEA,MAAK,OAAO,KAAM,iBAAkB,EAAE,SAAS,GAAI;AAClD,WAAO;AAAA,MACN,GAAG;AAAA,MACH,YAAY;AAAA,QACX,GAAG,OAAO;AAAA,QACV,UAAU;AAAA,UACT,GAAG,OAAO,WAAW;AAAA,UACrB,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -341,7 +341,7 @@ function getInsertionPoint(state) {
|
|
|
341
341
|
}
|
|
342
342
|
const isBlockHidden = (state, clientId) => {
|
|
343
343
|
const blockName = getBlockName(state, clientId);
|
|
344
|
-
if (!hasBlockSupport(state, blockName, "
|
|
344
|
+
if (!hasBlockSupport(state, blockName, "visibility", true)) {
|
|
345
345
|
return false;
|
|
346
346
|
}
|
|
347
347
|
const attributes = state.blocks.attributes.get(clientId);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/private-selectors.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\thasBlockSupport,\n\tprivateApis as blocksPrivateApis,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockOrder,\n\tgetBlockParents,\n\tgetBlockEditingMode,\n\tgetSettings,\n\tcanInsertBlockType,\n\tgetBlockName,\n\tgetTemplateLock,\n\tgetClientIdsWithDescendants,\n\tgetBlockRootClientId,\n\tgetBlockAttributes,\n} from './selectors';\nimport {\n\tcheckAllowListRecursive,\n\tgetAllPatternsDependants,\n\tgetInsertBlockTypeDependants,\n\tgetGrammar,\n\tmapUserPattern,\n} from './utils';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\nimport {\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n} from './private-keys';\n\nconst { isContentBlock } = unlock( blocksPrivateApis );\n\nexport { getBlockSettings } from './get-block-settings';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\nexport function getBlockWithoutAttributes( state, clientId ) {\n\treturn state.blocks.byClientId.get( clientId );\n}\n\n/**\n * Returns true if all of the descendants of a block with the given client ID\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = ( state, clientId ) => {\n\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, childClientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\tisChildSubtreeDisabled\n\t\t\t)\n\t\t);\n\t};\n\treturn getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );\n};\n\n/**\n * Determines if a container (clientId) allows insertion of blocks, considering contentOnly mode restrictions.\n *\n * @param {Object} state Editor state.\n * @param {string} blockName The block name to insert.\n * @param {string} rootClientId The client ID of the root container block.\n * @return {boolean} Whether the container allows insertion.\n */\nexport function isContainerInsertableToInContentOnlyMode(\n\tstate,\n\tblockName,\n\trootClientId\n) {\n\tconst isBlockContentBlock = isContentBlock( blockName );\n\tconst rootBlockName = getBlockName( state, rootClientId );\n\tconst isContainerContentBlock = isContentBlock( rootBlockName );\n\tconst isRootBlockMain = getSectionRootClientId( state ) === rootClientId;\n\n\t// In contentOnly mode, containers shouldn't be inserted into unless:\n\t// 1. they are a section root;\n\t// 2. they are a content block and the block to be inserted is also content.\n\treturn (\n\t\tisRootBlockMain || ( isContainerContentBlock && isBlockContentBlock )\n\t);\n}\n\nfunction getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {\n\tconst blockOrder = getBlockOrder( state, rootClientId );\n\tconst result = [];\n\n\tfor ( const clientId of blockOrder ) {\n\t\tconst innerBlocks = getEnabledClientIdsTreeUnmemoized(\n\t\t\tstate,\n\t\t\tclientId\n\t\t);\n\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\tresult.push( { clientId, innerBlocks } );\n\t\t} else {\n\t\t\tresult.push( ...innerBlocks );\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getEnabledClientIdsTree = createRegistrySelector( () =>\n\tcreateSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.derivedBlockEditingModes,\n\t\tstate.blockEditingModes,\n\t] )\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function getBlockRemovalRules( state ) {\n\treturn state.blockRemovalRules;\n}\n\n/**\n * Returns the client ID of the block settings menu that is currently open.\n *\n * @param {Object} state Global application state.\n * @return {string|null} The client ID of the block menu that is currently open.\n */\nexport function getOpenedBlockSettingsMenu( state ) {\n\treturn state.openedBlockSettingsMenu;\n}\n\n/**\n * Returns all style overrides, intended to be merged with global editor styles.\n *\n * Overrides are sorted to match the order of the blocks they relate to. This\n * is useful to maintain correct CSS cascade order.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} An array of style ID to style override pairs.\n */\nexport const getStyleOverrides = createSelector(\n\t( state ) => {\n\t\tconst clientIds = getClientIdsWithDescendants( state );\n\t\tconst clientIdMap = clientIds.reduce( ( acc, clientId, index ) => {\n\t\t\tacc[ clientId ] = index;\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\treturn [ ...state.styleOverrides ].sort( ( overrideA, overrideB ) => {\n\t\t\t// Once the overrides Map is spread to an array, the first element\n\t\t\t// is the key, while the second is the override itself including\n\t\t\t// the clientId to sort by.\n\t\t\tconst [ , { clientId: clientIdA } ] = overrideA;\n\t\t\tconst [ , { clientId: clientIdB } ] = overrideB;\n\n\t\t\tconst aIndex = clientIdMap[ clientIdA ] ?? -1;\n\t\t\tconst bIndex = clientIdMap[ clientIdB ] ?? -1;\n\n\t\t\treturn aIndex - bIndex;\n\t\t} );\n\t},\n\t( state ) => [ state.blocks.order, state.styleOverrides ]\n);\n\n/** @typedef {import('./actions').InserterMediaCategory} InserterMediaCategory */\n/**\n * Returns the registered inserter media categories through the public API.\n *\n * @param {Object} state Editor state.\n *\n * @return {InserterMediaCategory[]} Inserter media categories.\n */\nexport function getRegisteredInserterMediaCategories( state ) {\n\treturn state.registeredInserterMediaCategories;\n}\n\n/**\n * Returns an array containing the allowed inserter media categories.\n * It merges the registered media categories from extenders with the\n * core ones. It also takes into account the allowed `mime_types`, which\n * can be altered by `upload_mimes` filter and restrict some of them.\n *\n * @param {Object} state Global application state.\n *\n * @return {InserterMediaCategory[]} Client IDs of descendants.\n */\nexport const getInserterMediaCategories = createSelector(\n\t( state ) => {\n\t\tconst {\n\t\t\tsettings: {\n\t\t\t\tinserterMediaCategories,\n\t\t\t\tallowedMimeTypes,\n\t\t\t\tenableOpenverseMediaCategory,\n\t\t\t},\n\t\t\tregisteredInserterMediaCategories,\n\t\t} = state;\n\t\t// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict\n\t\t// some of them. In this case we shouldn't add the category to the available media\n\t\t// categories list in the inserter.\n\t\tif (\n\t\t\t( ! inserterMediaCategories &&\n\t\t\t\t! registeredInserterMediaCategories.length ) ||\n\t\t\t! allowedMimeTypes\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst coreInserterMediaCategoriesNames =\n\t\t\tinserterMediaCategories?.map( ( { name } ) => name ) || [];\n\t\tconst mergedCategories = [\n\t\t\t...( inserterMediaCategories || [] ),\n\t\t\t...( registeredInserterMediaCategories || [] ).filter(\n\t\t\t\t( { name } ) =>\n\t\t\t\t\t! coreInserterMediaCategoriesNames.includes( name )\n\t\t\t),\n\t\t];\n\t\treturn mergedCategories.filter( ( category ) => {\n\t\t\t// Check if Openverse category is enabled.\n\t\t\tif (\n\t\t\t\t! enableOpenverseMediaCategory &&\n\t\t\t\tcategory.name === 'openverse'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn Object.values( allowedMimeTypes ).some( ( mimeType ) =>\n\t\t\t\tmimeType.startsWith( `${ category.mediaType }/` )\n\t\t\t);\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.settings.inserterMediaCategories,\n\t\tstate.settings.allowedMimeTypes,\n\t\tstate.settings.enableOpenverseMediaCategory,\n\t\tstate.registeredInserterMediaCategories,\n\t]\n);\n\n/**\n * Returns whether there is at least one allowed pattern for inner blocks children.\n * This is useful for deferring the parsing of all patterns until needed.\n *\n * @param {Object} state Editor state.\n * @param {string} [rootClientId=null] Target root client ID.\n *\n * @return {boolean} If there is at least one allowed pattern.\n */\nexport const hasAllowedPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, rootClientId = null ) => {\n\t\t\tconst { getAllPatterns } = unlock( select( STORE_NAME ) );\n\t\t\tconst patterns = getAllPatterns();\n\t\t\tconst { allowedBlockTypes } = getSettings( state );\n\t\t\treturn patterns.some( ( pattern ) => {\n\t\t\t\tconst { inserter = true } = pattern;\n\t\t\t\tif ( ! inserter ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst grammar = getGrammar( pattern );\n\t\t\t\treturn (\n\t\t\t\t\tcheckAllowListRecursive( grammar, allowedBlockTypes ) &&\n\t\t\t\t\tgrammar.every( ( { name: blockName } ) =>\n\t\t\t\t\t\tcanInsertBlockType( state, blockName, rootClientId )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t( state, rootClientId ) => [\n\t\t\t...getAllPatternsDependants( select )( state ),\n\t\t\t...getInsertBlockTypeDependants( select )( state, rootClientId ),\n\t\t]\n\t)\n);\n\nexport const getPatternBySlug = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, patternName ) => {\n\t\t\t// Only fetch reusable blocks if we know we need them. To do: maybe\n\t\t\t// use the entity record API to retrieve the block by slug.\n\t\t\tif ( patternName?.startsWith( 'core/block/' ) ) {\n\t\t\t\tconst _id = parseInt(\n\t\t\t\t\tpatternName.slice( 'core/block/'.length ),\n\t\t\t\t\t10\n\t\t\t\t);\n\t\t\t\tconst block = unlock( select( STORE_NAME ) )\n\t\t\t\t\t.getReusableBlocks()\n\t\t\t\t\t.find( ( { id } ) => id === _id );\n\n\t\t\t\tif ( ! block ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn mapUserPattern(\n\t\t\t\t\tblock,\n\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t// This setting is left for back compat.\n\t\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ??\n\t\t\t\t\t[] ),\n\t\t\t].find( ( { name } ) => name === patternName );\n\t\t},\n\t\t( state, patternName ) =>\n\t\t\tpatternName?.startsWith( 'core/block/' )\n\t\t\t\t? [\n\t\t\t\t\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t\t\t\t\t\tstate.settings.__experimentalReusableBlocks,\n\t\t\t\t ]\n\t\t\t\t: [\n\t\t\t\t\t\tstate.settings.__experimentalBlockPatterns,\n\t\t\t\t\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\t\t\t ]\n\t)\n);\n\nexport const getAllPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector( ( state ) => {\n\t\treturn [\n\t\t\t...unlock( select( STORE_NAME ) )\n\t\t\t\t.getReusableBlocks()\n\t\t\t\t.map( ( userPattern ) =>\n\t\t\t\t\tmapUserPattern(\n\t\t\t\t\t\tuserPattern,\n\t\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t// This setting is left for back compat.\n\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),\n\t\t].filter(\n\t\t\t( x, index, arr ) =>\n\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t);\n\t}, getAllPatternsDependants( select ) )\n);\n\nconst EMPTY_ARRAY = [];\n\nexport const getReusableBlocks = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];\n\t\treturn (\n\t\t\t( reusableBlocksSelect\n\t\t\t\t? reusableBlocksSelect( select )\n\t\t\t\t: state.settings.__experimentalReusableBlocks ) ?? EMPTY_ARRAY\n\t\t);\n\t}\n);\n\n/**\n * Returns the element of the last element that had focus when focus left the editor canvas.\n *\n * @param {Object} state Block editor state.\n *\n * @return {Object} Element.\n */\nexport function getLastFocus( state ) {\n\treturn state.lastFocus;\n}\n\n/**\n * Returns true if the user is dragging anything, or false otherwise. It is possible for a\n * user to be dragging data from outside of the editor, so this selector is separate from\n * the `isDraggingBlocks` selector which only returns true if the user is dragging blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether user is dragging.\n */\nexport function isDragging( state ) {\n\treturn state.isDragging;\n}\n\n/**\n * Retrieves the expanded block from the state.\n *\n * @param {Object} state Block editor state.\n *\n * @return {string|null} The client ID of the expanded block, if set.\n */\nexport function getExpandedBlock( state ) {\n\treturn state.expandedBlock;\n}\n\n/**\n * Retrieves the client ID of the ancestor block that is content locking the block\n * with the provided client ID.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getContentLockingParent = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( getTemplateLock( state, current ) === 'contentOnly' ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID of the parent section block.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getParentSectionBlock = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( isSectionBlock( state, current ) ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID is a content locking parent\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {boolean} Whether the block is a content locking parent.\n */\nexport function isSectionBlock( state, clientId ) {\n\tconst blockName = getBlockName( state, clientId );\n\tif (\n\t\tblockName === 'core/block' ||\n\t\tgetTemplateLock( state, clientId ) === 'contentOnly'\n\t) {\n\t\treturn true;\n\t}\n\n\tconst attributes = getBlockAttributes( state, clientId );\n\tconst isTemplatePart = blockName === 'core/template-part';\n\tif (\n\t\t( attributes?.metadata?.patternName || isTemplatePart ) &&\n\t\t!! window?.__experimentalContentOnlyPatternInsertion\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Retrieves the client ID of the block that is content locked but is\n * currently being temporarily edited as a non-locked block.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The client ID of the block being temporarily edited as a non-locked block.\n */\nexport function getTemporarilyEditingAsBlocks( state ) {\n\treturn state.temporarilyEditingAsBlocks;\n}\n\n/**\n * Returns the focus mode that should be reapplied when the user stops editing\n * a content locked blocks as a block without locking.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The focus mode that should be re-set when temporarily editing as blocks stops.\n */\nexport function getTemporarilyEditingFocusModeToRevert( state ) {\n\treturn state.temporarilyEditingFocusModeRevert;\n}\n\n/**\n * Returns the style attributes of multiple blocks.\n *\n * @param {Object} state Global application state.\n * @param {string[]} clientIds An array of block client IDs.\n *\n * @return {Object} An object where keys are client IDs and values are the corresponding block styles or undefined.\n */\nexport const getBlockStyles = createSelector(\n\t( state, clientIds ) =>\n\t\tclientIds.reduce( ( styles, clientId ) => {\n\t\t\tstyles[ clientId ] = state.blocks.attributes.get( clientId )?.style;\n\t\t\treturn styles;\n\t\t}, {} ),\n\t( state, clientIds ) => [\n\t\t...clientIds.map(\n\t\t\t( clientId ) => state.blocks.attributes.get( clientId )?.style\n\t\t),\n\t]\n);\n\n/**\n * Retrieves the client ID of the block which contains the blocks\n * acting as \"sections\" in the editor. This is typically the \"main content\"\n * of the template/post.\n *\n * @param {Object} state Editor state.\n *\n * @return {string|undefined} The section root client ID or undefined if not set.\n */\nexport function getSectionRootClientId( state ) {\n\treturn state.settings?.[ sectionRootClientIdKey ];\n}\n\n/**\n * Returns whether the editor is considered zoomed out.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the editor is zoomed.\n */\nexport function isZoomOut( state ) {\n\treturn state.zoomLevel === 'auto-scaled' || state.zoomLevel < 100;\n}\n\n/**\n * Returns whether the zoom level.\n *\n * @param {Object} state Global application state.\n * @return {number|\"auto-scaled\"} Zoom level.\n */\nexport function getZoomLevel( state ) {\n\treturn state.zoomLevel;\n}\n\n/**\n * Finds the closest block where the block is allowed to be inserted.\n *\n * @param {Object} state Editor state.\n * @param {string[] | string} name Block name or names.\n * @param {string} clientId Default insertion point.\n *\n * @return {string} clientID of the closest container when the block name can be inserted.\n */\nexport function getClosestAllowedInsertionPoint( state, name, clientId = '' ) {\n\tconst blockNames = Array.isArray( name ) ? name : [ name ];\n\tconst areBlockNamesAllowedInClientId = ( id ) =>\n\t\tblockNames.every( ( currentName ) =>\n\t\t\tcanInsertBlockType( state, currentName, id )\n\t\t);\n\n\t// If we're trying to insert at the root level and it's not allowed\n\t// Try the section root instead.\n\tif ( ! clientId ) {\n\t\tif ( areBlockNamesAllowedInClientId( clientId ) ) {\n\t\t\treturn clientId;\n\t\t}\n\n\t\tconst sectionRootClientId = getSectionRootClientId( state );\n\t\tif (\n\t\t\tsectionRootClientId &&\n\t\t\tareBlockNamesAllowedInClientId( sectionRootClientId )\n\t\t) {\n\t\t\treturn sectionRootClientId;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Traverse the block tree up until we find a place where we can insert.\n\tlet current = clientId;\n\twhile ( current !== null && ! areBlockNamesAllowedInClientId( current ) ) {\n\t\tconst parentClientId = getBlockRootClientId( state, current );\n\t\tcurrent = parentClientId;\n\t}\n\n\treturn current;\n}\n\nexport function getClosestAllowedInsertionPointForPattern(\n\tstate,\n\tpattern,\n\tclientId\n) {\n\tconst { allowedBlockTypes } = getSettings( state );\n\tconst isAllowed = checkAllowListRecursive(\n\t\tgetGrammar( pattern ),\n\t\tallowedBlockTypes\n\t);\n\tif ( ! isAllowed ) {\n\t\treturn null;\n\t}\n\tconst names = getGrammar( pattern ).map( ( { blockName: name } ) => name );\n\treturn getClosestAllowedInsertionPoint( state, names, clientId );\n}\n\n/**\n * Where the point where the next block will be inserted into.\n *\n * @param {Object} state\n * @return {Object} where the insertion point in the block editor is or null if none is set.\n */\nexport function getInsertionPoint( state ) {\n\treturn state.insertionPoint;\n}\n\n/**\n * Returns true if the block is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client ID of the block.\n *\n * @return {boolean} Whether the block is hidden.\n */\nexport const isBlockHidden = ( state, clientId ) => {\n\tconst blockName = getBlockName( state, clientId );\n\tif ( ! hasBlockSupport( state, blockName, 'blockVisibility', true ) ) {\n\t\treturn false;\n\t}\n\tconst attributes = state.blocks.attributes.get( clientId );\n\treturn attributes?.metadata?.blockVisibility === false;\n};\n\n/**\n * Returns true if the current spotlighted block matches the block clientId.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block is currently spotlighted.\n */\nexport function hasBlockSpotlight( state ) {\n\treturn !! state.hasBlockSpotlight;\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,gBAAgB,8BAA8B;AACvD;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AAKP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP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YAAY,QAAQ,CAAE,+BAAgC,OAAQ,GAAI;AACzE,UAAM,iBAAiB,qBAAsB,OAAO,OAAQ;AAC5D,cAAU;AAAA,EACX;AAEA,SAAO;AACR;AAEO,SAAS,0CACf,OACA,SACA,UACC;AACD,QAAM,EAAE,kBAAkB,IAAI,YAAa,KAAM;AACjD,QAAM,YAAY;AAAA,IACjB,WAAY,OAAQ;AAAA,IACpB;AAAA,EACD;AACA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AACA,QAAM,QAAQ,WAAY,OAAQ,EAAE,IAAK,CAAE,EAAE,WAAW,KAAK,MAAO,IAAK;AACzE,SAAO,gCAAiC,OAAO,OAAO,QAAS;AAChE;AAQO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,MAAM;AACd;AAUO,MAAM,gBAAgB,CAAE,OAAO,aAAc;AACnD,QAAM,YAAY,aAAc,OAAO,QAAS;AAChD,MAAK,CAAE,gBAAiB,OAAO,WAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\thasBlockSupport,\n\tprivateApis as blocksPrivateApis,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockOrder,\n\tgetBlockParents,\n\tgetBlockEditingMode,\n\tgetSettings,\n\tcanInsertBlockType,\n\tgetBlockName,\n\tgetTemplateLock,\n\tgetClientIdsWithDescendants,\n\tgetBlockRootClientId,\n\tgetBlockAttributes,\n} from './selectors';\nimport {\n\tcheckAllowListRecursive,\n\tgetAllPatternsDependants,\n\tgetInsertBlockTypeDependants,\n\tgetGrammar,\n\tmapUserPattern,\n} from './utils';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\nimport {\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n} from './private-keys';\n\nconst { isContentBlock } = unlock( blocksPrivateApis );\n\nexport { getBlockSettings } from './get-block-settings';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\nexport function getBlockWithoutAttributes( state, clientId ) {\n\treturn state.blocks.byClientId.get( clientId );\n}\n\n/**\n * Returns true if all of the descendants of a block with the given client ID\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = ( state, clientId ) => {\n\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, childClientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\tisChildSubtreeDisabled\n\t\t\t)\n\t\t);\n\t};\n\treturn getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );\n};\n\n/**\n * Determines if a container (clientId) allows insertion of blocks, considering contentOnly mode restrictions.\n *\n * @param {Object} state Editor state.\n * @param {string} blockName The block name to insert.\n * @param {string} rootClientId The client ID of the root container block.\n * @return {boolean} Whether the container allows insertion.\n */\nexport function isContainerInsertableToInContentOnlyMode(\n\tstate,\n\tblockName,\n\trootClientId\n) {\n\tconst isBlockContentBlock = isContentBlock( blockName );\n\tconst rootBlockName = getBlockName( state, rootClientId );\n\tconst isContainerContentBlock = isContentBlock( rootBlockName );\n\tconst isRootBlockMain = getSectionRootClientId( state ) === rootClientId;\n\n\t// In contentOnly mode, containers shouldn't be inserted into unless:\n\t// 1. they are a section root;\n\t// 2. they are a content block and the block to be inserted is also content.\n\treturn (\n\t\tisRootBlockMain || ( isContainerContentBlock && isBlockContentBlock )\n\t);\n}\n\nfunction getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {\n\tconst blockOrder = getBlockOrder( state, rootClientId );\n\tconst result = [];\n\n\tfor ( const clientId of blockOrder ) {\n\t\tconst innerBlocks = getEnabledClientIdsTreeUnmemoized(\n\t\t\tstate,\n\t\t\tclientId\n\t\t);\n\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\tresult.push( { clientId, innerBlocks } );\n\t\t} else {\n\t\t\tresult.push( ...innerBlocks );\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getEnabledClientIdsTree = createRegistrySelector( () =>\n\tcreateSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.derivedBlockEditingModes,\n\t\tstate.blockEditingModes,\n\t] )\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function getBlockRemovalRules( state ) {\n\treturn state.blockRemovalRules;\n}\n\n/**\n * Returns the client ID of the block settings menu that is currently open.\n *\n * @param {Object} state Global application state.\n * @return {string|null} The client ID of the block menu that is currently open.\n */\nexport function getOpenedBlockSettingsMenu( state ) {\n\treturn state.openedBlockSettingsMenu;\n}\n\n/**\n * Returns all style overrides, intended to be merged with global editor styles.\n *\n * Overrides are sorted to match the order of the blocks they relate to. This\n * is useful to maintain correct CSS cascade order.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} An array of style ID to style override pairs.\n */\nexport const getStyleOverrides = createSelector(\n\t( state ) => {\n\t\tconst clientIds = getClientIdsWithDescendants( state );\n\t\tconst clientIdMap = clientIds.reduce( ( acc, clientId, index ) => {\n\t\t\tacc[ clientId ] = index;\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\treturn [ ...state.styleOverrides ].sort( ( overrideA, overrideB ) => {\n\t\t\t// Once the overrides Map is spread to an array, the first element\n\t\t\t// is the key, while the second is the override itself including\n\t\t\t// the clientId to sort by.\n\t\t\tconst [ , { clientId: clientIdA } ] = overrideA;\n\t\t\tconst [ , { clientId: clientIdB } ] = overrideB;\n\n\t\t\tconst aIndex = clientIdMap[ clientIdA ] ?? -1;\n\t\t\tconst bIndex = clientIdMap[ clientIdB ] ?? -1;\n\n\t\t\treturn aIndex - bIndex;\n\t\t} );\n\t},\n\t( state ) => [ state.blocks.order, state.styleOverrides ]\n);\n\n/** @typedef {import('./actions').InserterMediaCategory} InserterMediaCategory */\n/**\n * Returns the registered inserter media categories through the public API.\n *\n * @param {Object} state Editor state.\n *\n * @return {InserterMediaCategory[]} Inserter media categories.\n */\nexport function getRegisteredInserterMediaCategories( state ) {\n\treturn state.registeredInserterMediaCategories;\n}\n\n/**\n * Returns an array containing the allowed inserter media categories.\n * It merges the registered media categories from extenders with the\n * core ones. It also takes into account the allowed `mime_types`, which\n * can be altered by `upload_mimes` filter and restrict some of them.\n *\n * @param {Object} state Global application state.\n *\n * @return {InserterMediaCategory[]} Client IDs of descendants.\n */\nexport const getInserterMediaCategories = createSelector(\n\t( state ) => {\n\t\tconst {\n\t\t\tsettings: {\n\t\t\t\tinserterMediaCategories,\n\t\t\t\tallowedMimeTypes,\n\t\t\t\tenableOpenverseMediaCategory,\n\t\t\t},\n\t\t\tregisteredInserterMediaCategories,\n\t\t} = state;\n\t\t// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict\n\t\t// some of them. In this case we shouldn't add the category to the available media\n\t\t// categories list in the inserter.\n\t\tif (\n\t\t\t( ! inserterMediaCategories &&\n\t\t\t\t! registeredInserterMediaCategories.length ) ||\n\t\t\t! allowedMimeTypes\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst coreInserterMediaCategoriesNames =\n\t\t\tinserterMediaCategories?.map( ( { name } ) => name ) || [];\n\t\tconst mergedCategories = [\n\t\t\t...( inserterMediaCategories || [] ),\n\t\t\t...( registeredInserterMediaCategories || [] ).filter(\n\t\t\t\t( { name } ) =>\n\t\t\t\t\t! coreInserterMediaCategoriesNames.includes( name )\n\t\t\t),\n\t\t];\n\t\treturn mergedCategories.filter( ( category ) => {\n\t\t\t// Check if Openverse category is enabled.\n\t\t\tif (\n\t\t\t\t! enableOpenverseMediaCategory &&\n\t\t\t\tcategory.name === 'openverse'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn Object.values( allowedMimeTypes ).some( ( mimeType ) =>\n\t\t\t\tmimeType.startsWith( `${ category.mediaType }/` )\n\t\t\t);\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.settings.inserterMediaCategories,\n\t\tstate.settings.allowedMimeTypes,\n\t\tstate.settings.enableOpenverseMediaCategory,\n\t\tstate.registeredInserterMediaCategories,\n\t]\n);\n\n/**\n * Returns whether there is at least one allowed pattern for inner blocks children.\n * This is useful for deferring the parsing of all patterns until needed.\n *\n * @param {Object} state Editor state.\n * @param {string} [rootClientId=null] Target root client ID.\n *\n * @return {boolean} If there is at least one allowed pattern.\n */\nexport const hasAllowedPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, rootClientId = null ) => {\n\t\t\tconst { getAllPatterns } = unlock( select( STORE_NAME ) );\n\t\t\tconst patterns = getAllPatterns();\n\t\t\tconst { allowedBlockTypes } = getSettings( state );\n\t\t\treturn patterns.some( ( pattern ) => {\n\t\t\t\tconst { inserter = true } = pattern;\n\t\t\t\tif ( ! inserter ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst grammar = getGrammar( pattern );\n\t\t\t\treturn (\n\t\t\t\t\tcheckAllowListRecursive( grammar, allowedBlockTypes ) &&\n\t\t\t\t\tgrammar.every( ( { name: blockName } ) =>\n\t\t\t\t\t\tcanInsertBlockType( state, blockName, rootClientId )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t( state, rootClientId ) => [\n\t\t\t...getAllPatternsDependants( select )( state ),\n\t\t\t...getInsertBlockTypeDependants( select )( state, rootClientId ),\n\t\t]\n\t)\n);\n\nexport const getPatternBySlug = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, patternName ) => {\n\t\t\t// Only fetch reusable blocks if we know we need them. To do: maybe\n\t\t\t// use the entity record API to retrieve the block by slug.\n\t\t\tif ( patternName?.startsWith( 'core/block/' ) ) {\n\t\t\t\tconst _id = parseInt(\n\t\t\t\t\tpatternName.slice( 'core/block/'.length ),\n\t\t\t\t\t10\n\t\t\t\t);\n\t\t\t\tconst block = unlock( select( STORE_NAME ) )\n\t\t\t\t\t.getReusableBlocks()\n\t\t\t\t\t.find( ( { id } ) => id === _id );\n\n\t\t\t\tif ( ! block ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn mapUserPattern(\n\t\t\t\t\tblock,\n\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t// This setting is left for back compat.\n\t\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ??\n\t\t\t\t\t[] ),\n\t\t\t].find( ( { name } ) => name === patternName );\n\t\t},\n\t\t( state, patternName ) =>\n\t\t\tpatternName?.startsWith( 'core/block/' )\n\t\t\t\t? [\n\t\t\t\t\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t\t\t\t\t\tstate.settings.__experimentalReusableBlocks,\n\t\t\t\t ]\n\t\t\t\t: [\n\t\t\t\t\t\tstate.settings.__experimentalBlockPatterns,\n\t\t\t\t\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\t\t\t ]\n\t)\n);\n\nexport const getAllPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector( ( state ) => {\n\t\treturn [\n\t\t\t...unlock( select( STORE_NAME ) )\n\t\t\t\t.getReusableBlocks()\n\t\t\t\t.map( ( userPattern ) =>\n\t\t\t\t\tmapUserPattern(\n\t\t\t\t\t\tuserPattern,\n\t\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t// This setting is left for back compat.\n\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),\n\t\t].filter(\n\t\t\t( x, index, arr ) =>\n\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t);\n\t}, getAllPatternsDependants( select ) )\n);\n\nconst EMPTY_ARRAY = [];\n\nexport const getReusableBlocks = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];\n\t\treturn (\n\t\t\t( reusableBlocksSelect\n\t\t\t\t? reusableBlocksSelect( select )\n\t\t\t\t: state.settings.__experimentalReusableBlocks ) ?? EMPTY_ARRAY\n\t\t);\n\t}\n);\n\n/**\n * Returns the element of the last element that had focus when focus left the editor canvas.\n *\n * @param {Object} state Block editor state.\n *\n * @return {Object} Element.\n */\nexport function getLastFocus( state ) {\n\treturn state.lastFocus;\n}\n\n/**\n * Returns true if the user is dragging anything, or false otherwise. It is possible for a\n * user to be dragging data from outside of the editor, so this selector is separate from\n * the `isDraggingBlocks` selector which only returns true if the user is dragging blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether user is dragging.\n */\nexport function isDragging( state ) {\n\treturn state.isDragging;\n}\n\n/**\n * Retrieves the expanded block from the state.\n *\n * @param {Object} state Block editor state.\n *\n * @return {string|null} The client ID of the expanded block, if set.\n */\nexport function getExpandedBlock( state ) {\n\treturn state.expandedBlock;\n}\n\n/**\n * Retrieves the client ID of the ancestor block that is content locking the block\n * with the provided client ID.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getContentLockingParent = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( getTemplateLock( state, current ) === 'contentOnly' ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID of the parent section block.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getParentSectionBlock = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( isSectionBlock( state, current ) ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID is a content locking parent\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {boolean} Whether the block is a content locking parent.\n */\nexport function isSectionBlock( state, clientId ) {\n\tconst blockName = getBlockName( state, clientId );\n\tif (\n\t\tblockName === 'core/block' ||\n\t\tgetTemplateLock( state, clientId ) === 'contentOnly'\n\t) {\n\t\treturn true;\n\t}\n\n\tconst attributes = getBlockAttributes( state, clientId );\n\tconst isTemplatePart = blockName === 'core/template-part';\n\tif (\n\t\t( attributes?.metadata?.patternName || isTemplatePart ) &&\n\t\t!! window?.__experimentalContentOnlyPatternInsertion\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Retrieves the client ID of the block that is content locked but is\n * currently being temporarily edited as a non-locked block.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The client ID of the block being temporarily edited as a non-locked block.\n */\nexport function getTemporarilyEditingAsBlocks( state ) {\n\treturn state.temporarilyEditingAsBlocks;\n}\n\n/**\n * Returns the focus mode that should be reapplied when the user stops editing\n * a content locked blocks as a block without locking.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The focus mode that should be re-set when temporarily editing as blocks stops.\n */\nexport function getTemporarilyEditingFocusModeToRevert( state ) {\n\treturn state.temporarilyEditingFocusModeRevert;\n}\n\n/**\n * Returns the style attributes of multiple blocks.\n *\n * @param {Object} state Global application state.\n * @param {string[]} clientIds An array of block client IDs.\n *\n * @return {Object} An object where keys are client IDs and values are the corresponding block styles or undefined.\n */\nexport const getBlockStyles = createSelector(\n\t( state, clientIds ) =>\n\t\tclientIds.reduce( ( styles, clientId ) => {\n\t\t\tstyles[ clientId ] = state.blocks.attributes.get( clientId )?.style;\n\t\t\treturn styles;\n\t\t}, {} ),\n\t( state, clientIds ) => [\n\t\t...clientIds.map(\n\t\t\t( clientId ) => state.blocks.attributes.get( clientId )?.style\n\t\t),\n\t]\n);\n\n/**\n * Retrieves the client ID of the block which contains the blocks\n * acting as \"sections\" in the editor. This is typically the \"main content\"\n * of the template/post.\n *\n * @param {Object} state Editor state.\n *\n * @return {string|undefined} The section root client ID or undefined if not set.\n */\nexport function getSectionRootClientId( state ) {\n\treturn state.settings?.[ sectionRootClientIdKey ];\n}\n\n/**\n * Returns whether the editor is considered zoomed out.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the editor is zoomed.\n */\nexport function isZoomOut( state ) {\n\treturn state.zoomLevel === 'auto-scaled' || state.zoomLevel < 100;\n}\n\n/**\n * Returns whether the zoom level.\n *\n * @param {Object} state Global application state.\n * @return {number|\"auto-scaled\"} Zoom level.\n */\nexport function getZoomLevel( state ) {\n\treturn state.zoomLevel;\n}\n\n/**\n * Finds the closest block where the block is allowed to be inserted.\n *\n * @param {Object} state Editor state.\n * @param {string[] | string} name Block name or names.\n * @param {string} clientId Default insertion point.\n *\n * @return {string} clientID of the closest container when the block name can be inserted.\n */\nexport function getClosestAllowedInsertionPoint( state, name, clientId = '' ) {\n\tconst blockNames = Array.isArray( name ) ? name : [ name ];\n\tconst areBlockNamesAllowedInClientId = ( id ) =>\n\t\tblockNames.every( ( currentName ) =>\n\t\t\tcanInsertBlockType( state, currentName, id )\n\t\t);\n\n\t// If we're trying to insert at the root level and it's not allowed\n\t// Try the section root instead.\n\tif ( ! clientId ) {\n\t\tif ( areBlockNamesAllowedInClientId( clientId ) ) {\n\t\t\treturn clientId;\n\t\t}\n\n\t\tconst sectionRootClientId = getSectionRootClientId( state );\n\t\tif (\n\t\t\tsectionRootClientId &&\n\t\t\tareBlockNamesAllowedInClientId( sectionRootClientId )\n\t\t) {\n\t\t\treturn sectionRootClientId;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Traverse the block tree up until we find a place where we can insert.\n\tlet current = clientId;\n\twhile ( current !== null && ! areBlockNamesAllowedInClientId( current ) ) {\n\t\tconst parentClientId = getBlockRootClientId( state, current );\n\t\tcurrent = parentClientId;\n\t}\n\n\treturn current;\n}\n\nexport function getClosestAllowedInsertionPointForPattern(\n\tstate,\n\tpattern,\n\tclientId\n) {\n\tconst { allowedBlockTypes } = getSettings( state );\n\tconst isAllowed = checkAllowListRecursive(\n\t\tgetGrammar( pattern ),\n\t\tallowedBlockTypes\n\t);\n\tif ( ! isAllowed ) {\n\t\treturn null;\n\t}\n\tconst names = getGrammar( pattern ).map( ( { blockName: name } ) => name );\n\treturn getClosestAllowedInsertionPoint( state, names, clientId );\n}\n\n/**\n * Where the point where the next block will be inserted into.\n *\n * @param {Object} state\n * @return {Object} where the insertion point in the block editor is or null if none is set.\n */\nexport function getInsertionPoint( state ) {\n\treturn state.insertionPoint;\n}\n\n/**\n * Returns true if the block is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client ID of the block.\n *\n * @return {boolean} Whether the block is hidden.\n */\nexport const isBlockHidden = ( state, clientId ) => {\n\tconst blockName = getBlockName( state, clientId );\n\tif ( ! hasBlockSupport( state, blockName, 'visibility', true ) ) {\n\t\treturn false;\n\t}\n\tconst attributes = state.blocks.attributes.get( clientId );\n\treturn attributes?.metadata?.blockVisibility === false;\n};\n\n/**\n * Returns true if the current spotlighted block matches the block clientId.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block is currently spotlighted.\n */\nexport function hasBlockSpotlight( state ) {\n\treturn !! state.hasBlockSpotlight;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,gBAAgB,8BAA8B;AACvD;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AAKP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,MAAM,EAAE,eAAe,IAAI,OAAQ,iBAAkB;AAErD,SAAS,wBAAwB;AAS1B,SAAS,uBAAwB,OAAQ;AAC/C,SAAO,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,KAAM;AACjD,QAAM,YAAY;AAAA,IACjB,WAAY,OAAQ;AAAA,IACpB;AAAA,EACD;AACA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AACA,QAAM,QAAQ,WAAY,OAAQ,EAAE,IAAK,CAAE,EAAE,WAAW,KAAK,MAAO,IAAK;AACzE,SAAO,gCAAiC,OAAO,OAAO,QAAS;AAChE;AAQO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,MAAM;AACd;AAUO,MAAM,gBAAgB,CAAE,OAAO,aAAc;AACnD,QAAM,YAAY,aAAc,OAAO,QAAS;AAChD,MAAK,CAAE,gBAAiB,OAAO,WAAW,cAAc,IAAK,GAAI;AAChE,WAAO;AAAA,EACR;AACA,QAAM,aAAa,MAAM,OAAO,WAAW,IAAK,QAAS;AACzD,SAAO,YAAY,UAAU,oBAAoB;AAClD;AASO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,CAAC,CAAE,MAAM;AACjB;",
|
|
6
6
|
"names": ["getAllPatterns"]
|
|
7
7
|
}
|
|
@@ -279,6 +279,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
|
|
|
279
279
|
.block-editor-block-list__layout .block-editor-block-list__block[draggable=true], .block-editor-block-list__layout .block-editor-block-list__block[data-draggable=true] {
|
|
280
280
|
cursor: grab;
|
|
281
281
|
}
|
|
282
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-multi-selected {
|
|
283
|
+
cursor: default;
|
|
284
|
+
}
|
|
282
285
|
.block-editor-block-list__layout .block-editor-block-list__block[contenteditable],
|
|
283
286
|
.block-editor-block-list__layout .block-editor-block-list__block [contenteditable] {
|
|
284
287
|
cursor: text;
|
package/build-style/content.css
CHANGED
|
@@ -279,6 +279,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
|
|
|
279
279
|
.block-editor-block-list__layout .block-editor-block-list__block[draggable=true], .block-editor-block-list__layout .block-editor-block-list__block[data-draggable=true] {
|
|
280
280
|
cursor: grab;
|
|
281
281
|
}
|
|
282
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-multi-selected {
|
|
283
|
+
cursor: default;
|
|
284
|
+
}
|
|
282
285
|
.block-editor-block-list__layout .block-editor-block-list__block[contenteditable],
|
|
283
286
|
.block-editor-block-list__layout .block-editor-block-list__block [contenteditable] {
|
|
284
287
|
cursor: text;
|
package/build-style/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.6.
|
|
3
|
+
"version": "15.6.8",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@wordpress/html-entities": "^4.33.1",
|
|
76
76
|
"@wordpress/i18n": "^6.6.1",
|
|
77
77
|
"@wordpress/icons": "^11.0.1",
|
|
78
|
-
"@wordpress/interactivity": "^6.33.
|
|
78
|
+
"@wordpress/interactivity": "^6.33.2",
|
|
79
79
|
"@wordpress/is-shallow-equal": "^5.33.1",
|
|
80
80
|
"@wordpress/keyboard-shortcuts": "^5.33.1",
|
|
81
81
|
"@wordpress/keycodes": "^4.33.1",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "52db1c3ee45bd12b1e3dc65490edc6db5b9ab78f"
|
|
116
116
|
}
|
|
@@ -222,6 +222,11 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .b
|
|
|
222
222
|
cursor: grab;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
// Dragging multi selected blocks is not supported yet.
|
|
226
|
+
&.is-multi-selected {
|
|
227
|
+
cursor: default;
|
|
228
|
+
}
|
|
229
|
+
|
|
225
230
|
&[contenteditable],
|
|
226
231
|
[contenteditable] {
|
|
227
232
|
cursor: text;
|
|
@@ -49,7 +49,7 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
49
49
|
canToggleSelectedBlocksVisibility: getBlocksByClientId(
|
|
50
50
|
ids
|
|
51
51
|
).every( ( block ) =>
|
|
52
|
-
hasBlockSupport( block.name, '
|
|
52
|
+
hasBlockSupport( block.name, 'visibility', true )
|
|
53
53
|
),
|
|
54
54
|
};
|
|
55
55
|
},
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -217,7 +222,7 @@ export default function BlockTools( {
|
|
|
217
222
|
const canToggleBlockVisibility = blocks.every( ( block ) =>
|
|
218
223
|
hasBlockSupport(
|
|
219
224
|
getBlockName( block.clientId ),
|
|
220
|
-
'
|
|
225
|
+
'visibility',
|
|
221
226
|
true
|
|
222
227
|
)
|
|
223
228
|
);
|
|
@@ -252,7 +257,15 @@ export default function BlockTools( {
|
|
|
252
257
|
|
|
253
258
|
return (
|
|
254
259
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
255
|
-
<div
|
|
260
|
+
<div
|
|
261
|
+
{ ...props }
|
|
262
|
+
onKeyDown={ onKeyDown }
|
|
263
|
+
// Popover slots cannot be unmounted during dragging because the
|
|
264
|
+
// will just be rendered in a fallback popover slot instead.
|
|
265
|
+
className={ clsx( props.className, {
|
|
266
|
+
'block-editor-block-tools--is-dragging': isDragging,
|
|
267
|
+
} ) }
|
|
268
|
+
>
|
|
256
269
|
<InsertionPointOpenRef.Provider value={ useRef( false ) }>
|
|
257
270
|
{ ! isTyping && ! isZoomOutMode && (
|
|
258
271
|
<InsertionPoint
|
|
@@ -375,10 +375,10 @@ function ListViewBlock( {
|
|
|
375
375
|
event.preventDefault();
|
|
376
376
|
const { blocksToUpdate } = getBlocksToUpdate();
|
|
377
377
|
const blocks = getBlocksByClientId( blocksToUpdate );
|
|
378
|
-
const
|
|
379
|
-
hasBlockSupport( blockToUpdate.name, '
|
|
378
|
+
const canToggleVisibility = blocks.every( ( blockToUpdate ) =>
|
|
379
|
+
hasBlockSupport( blockToUpdate.name, 'visibility', true )
|
|
380
380
|
);
|
|
381
|
-
if ( !
|
|
381
|
+
if ( ! canToggleVisibility ) {
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
384
|
const hasHiddenBlock = blocks.some(
|
|
@@ -224,7 +224,7 @@ const getQuickActionsCommands = () =>
|
|
|
224
224
|
const canRemove = canRemoveBlocks( clientIds );
|
|
225
225
|
|
|
226
226
|
const canToggleBlockVisibility = blocks.every( ( { clientId } ) =>
|
|
227
|
-
hasBlockSupport( getBlockName( clientId ), '
|
|
227
|
+
hasBlockSupport( getBlockName( clientId ), 'visibility', true )
|
|
228
228
|
);
|
|
229
229
|
|
|
230
230
|
const commands = [];
|
|
@@ -415,11 +415,7 @@ export default function useBlockDropZone( {
|
|
|
415
415
|
// Filter out blocks that are hidden
|
|
416
416
|
.filter( ( block ) => {
|
|
417
417
|
return ! (
|
|
418
|
-
hasBlockSupport(
|
|
419
|
-
block.name,
|
|
420
|
-
'blockVisibility',
|
|
421
|
-
true
|
|
422
|
-
) &&
|
|
418
|
+
hasBlockSupport( block.name, 'visibility', true ) &&
|
|
423
419
|
block.attributes?.metadata?.blockVisibility ===
|
|
424
420
|
false
|
|
425
421
|
);
|
package/src/hooks/metadata.js
CHANGED
|
@@ -91,7 +91,7 @@ export function addTransforms( result, source, index, results ) {
|
|
|
91
91
|
if (
|
|
92
92
|
sourceMetadata.blockVisibility !== undefined &&
|
|
93
93
|
! result.attributes?.metadata?.blockVisibility &&
|
|
94
|
-
hasBlockSupport( result.name, '
|
|
94
|
+
hasBlockSupport( result.name, 'visibility', true )
|
|
95
95
|
) {
|
|
96
96
|
preservedMetadata.blockVisibility = sourceMetadata.blockVisibility;
|
|
97
97
|
}
|
|
@@ -687,7 +687,7 @@ export function getInsertionPoint( state ) {
|
|
|
687
687
|
*/
|
|
688
688
|
export const isBlockHidden = ( state, clientId ) => {
|
|
689
689
|
const blockName = getBlockName( state, clientId );
|
|
690
|
-
if ( ! hasBlockSupport( state, blockName, '
|
|
690
|
+
if ( ! hasBlockSupport( state, blockName, 'visibility', true ) ) {
|
|
691
691
|
return false;
|
|
692
692
|
}
|
|
693
693
|
const attributes = state.blocks.attributes.get( clientId );
|