Skip to content

Commit

Permalink
prep build 10/02
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Oct 2, 2024
2 parents dde72f3 + bed3a43 commit 8060ecd
Show file tree
Hide file tree
Showing 73 changed files with 1,169 additions and 543 deletions.
4 changes: 4 additions & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ _Returns_

- `?WPBlockBindingsUtils`: Object containing the block bindings utils.

_Changelog_

`6.7.0` Introduced in WordPress core.

### useBlockCommands

Undocumented declaration.
Expand Down
6 changes: 0 additions & 6 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ function BlockListBlockProvider( props ) {
isBlockBeingDragged,
isDragging,
__unstableHasActiveBlockOverlayActive,
__unstableGetEditorMode,
getSelectedBlocksInitialCaretPosition,
} = unlock( select( blockEditorStore ) );
const blockWithoutAttributes =
Expand Down Expand Up @@ -680,8 +679,6 @@ function BlockListBlockProvider( props ) {
blocksWithSameName.length &&
blocksWithSameName[ 0 ] !== clientId;

const editorMode = __unstableGetEditorMode();

return {
...previewContext,
mode: getBlockMode( clientId ),
Expand All @@ -708,7 +705,6 @@ function BlockListBlockProvider( props ) {
) && hasSelectedInnerBlock( clientId ),
blockApiVersion: blockType?.apiVersion || 1,
blockTitle: match?.title || blockType?.title,
editorMode,
isSubtreeDisabled:
blockEditingMode === 'disabled' &&
isBlockSubtreeDisabled( clientId ),
Expand Down Expand Up @@ -755,7 +751,6 @@ function BlockListBlockProvider( props ) {
themeSupportsLayout,
isTemporarilyEditingAsBlocks,
blockEditingMode,
editorMode,
mayDisplayControls,
mayDisplayParentControls,
index,
Expand Down Expand Up @@ -808,7 +803,6 @@ function BlockListBlockProvider( props ) {
hasOverlay,
initialPosition,
blockEditingMode,
editorMode,
isHighlighted,
isMultiSelected,
isPartiallySelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
name,
blockApiVersion,
blockTitle,
editorMode,
isSelected,
isSubtreeDisabled,
hasOverlay,
Expand Down Expand Up @@ -113,7 +112,7 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
useBlockRefProvider( clientId ),
useFocusHandler( clientId ),
useEventHandlers( { clientId, isSelected } ),
useZoomOutModeExit( { editorMode } ),
useZoomOutModeExit(),
useIsHovered( { clientId } ),
useIntersectionObserver(),
useMovingAnimation( { triggerAnimationOnChange: index, clientId } ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ import { unlock } from '../../../lock-unlock';

/**
* Allows Zoom Out mode to be exited by double clicking in the selected block.
*
* @param {string} clientId Block client ID.
*/
export function useZoomOutModeExit( { editorMode } ) {
const { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );
export function useZoomOutModeExit() {
const { getSettings, isZoomOut, __unstableGetEditorMode } = unlock(
useSelect( blockEditorStore )
);

const { __unstableSetEditorMode, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);

return useRefEffect(
( node ) => {
// In "compose" mode.
const composeMode = editorMode === 'zoom-out' && isZoomOut();
function onDoubleClick( event ) {
// In "compose" mode.
const composeMode =
__unstableGetEditorMode() === 'zoom-out' && isZoomOut();

if ( ! composeMode ) {
return;
}
if ( ! composeMode ) {
return;
}

function onDoubleClick( event ) {
if ( ! event.defaultPrevented ) {
event.preventDefault();

Expand All @@ -52,6 +54,12 @@ export function useZoomOutModeExit( { editorMode } ) {
node.removeEventListener( 'dblclick', onDoubleClick );
};
},
[ editorMode, getSettings, __unstableSetEditorMode ]
[
getSettings,
__unstableSetEditorMode,
__unstableGetEditorMode,
isZoomOut,
resetZoomLevel,
]
);
}
13 changes: 7 additions & 6 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function selector( select ) {
getSettings,
__unstableGetEditorMode,
isTyping,
} = select( blockEditorStore );
isDragging,
} = unlock( select( blockEditorStore ) );

const clientId =
getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
Expand All @@ -46,6 +47,7 @@ function selector( select ) {
hasFixedToolbar: getSettings().hasFixedToolbar,
isTyping: isTyping(),
isZoomOutMode: editorMode === 'zoom-out',
isDragging: isDragging(),
};
}

Expand All @@ -63,10 +65,9 @@ export default function BlockTools( {
__unstableContentRef,
...props
} ) {
const { clientId, hasFixedToolbar, isTyping, isZoomOutMode } = useSelect(
selector,
[]
);
const { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =
useSelect( selector, [] );

const isMatch = useShortcutEventMatch();
const {
getBlocksByClientId,
Expand Down Expand Up @@ -241,7 +242,7 @@ export default function BlockTools( {
name="__unstable-block-tools-after"
ref={ blockToolbarAfterRef }
/>
{ isZoomOutMode && (
{ isZoomOutMode && ! isDragging && (
<ZoomOutModeInserters
__unstableContentRef={ __unstableContentRef }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
label={ __( 'Delete' ) }
onClick={ () => {
removeBlock( clientId );
__unstableContentRef.current?.focus();
} }
/>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { store as noticesStore } from '@wordpress/notices';
import { store as blockEditorStore } from '../../../store';
import { unlock } from '../../../lock-unlock';
import { INSERTER_PATTERN_TYPES } from '../block-patterns-tab/utils';
import { getParsedPattern } from '../../../store/utils';
import { isFiltered } from '../../../store/utils';

/**
* Retrieves the block patterns inserter state.
Expand All @@ -31,48 +31,34 @@ const usePatternsState = (
selectedCategory,
isQuick
) => {
const { patternCategories, allPatterns, userPatternCategories } = useSelect(
const options = useMemo(
() => ( { [ isFiltered ]: !! isQuick } ),
[ isQuick ]
);
const { patternCategories, patterns, userPatternCategories } = useSelect(
( select ) => {
const {
getAllPatterns,
getSettings,
__experimentalGetAllowedPatterns,
} = unlock( select( blockEditorStore ) );
const { getSettings, __experimentalGetAllowedPatterns } = unlock(
select( blockEditorStore )
);
const {
__experimentalUserPatternCategories,
__experimentalBlockPatternCategories,
} = getSettings();
return {
allPatterns: isQuick
? __experimentalGetAllowedPatterns()
: getAllPatterns(),
patterns: __experimentalGetAllowedPatterns(
rootClientId,
options
),
userPatternCategories: __experimentalUserPatternCategories,
patternCategories: __experimentalBlockPatternCategories,
};
},
[ isQuick ]
[ rootClientId, options ]
);
const { getClosestAllowedInsertionPointForPattern } = unlock(
useSelect( blockEditorStore )
);

const patterns = useMemo(
() =>
isQuick
? allPatterns
: allPatterns
.filter( ( { inserter = true } ) => !! inserter )
.map( ( pattern ) => {
return {
...pattern,
get blocks() {
return getParsedPattern( pattern ).blocks;
},
};
} ),
[ isQuick, allPatterns ]
);

const allCategories = useMemo( () => {
const categories = [ ...patternCategories ];
userPatternCategories?.forEach( ( userCategory ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
__experimentalSpacer as Spacer,
__experimentalHeading as Heading,
__experimentalView as View,
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalNavigatorButton as NavigatorButton,
__experimentalNavigatorBackButton as NavigatorBackButton,
Navigator,
FlexBlock,
} from '@wordpress/components';
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
Expand All @@ -24,7 +21,7 @@ function ScreenHeader( { title } ) {
<View>
<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>
<HStack spacing={ 2 }>
<NavigatorBackButton
<Navigator.BackButton
style={
// TODO: This style override is also used in ToolsPanelHeader.
// It should be supported out-of-the-box by Button.
Expand All @@ -46,14 +43,14 @@ function ScreenHeader( { title } ) {

export default function MobileTabNavigation( { categories, children } ) {
return (
<NavigatorProvider
<Navigator
initialPath="/"
className="block-editor-inserter__mobile-tab-navigation"
>
<NavigatorScreen path="/">
<Navigator.Screen path="/">
<ItemGroup>
{ categories.map( ( category ) => (
<NavigatorButton
<Navigator.Button
key={ category.name }
path={ `/category/${ category.name }` }
as={ Item }
Expand All @@ -67,19 +64,19 @@ export default function MobileTabNavigation( { categories, children } ) {
}
/>
</HStack>
</NavigatorButton>
</Navigator.Button>
) ) }
</ItemGroup>
</NavigatorScreen>
</Navigator.Screen>
{ categories.map( ( category ) => (
<NavigatorScreen
<Navigator.Screen
key={ category.name }
path={ `/category/${ category.name }` }
>
<ScreenHeader title={ __( 'Back' ) } />
{ children( category ) }
</NavigatorScreen>
</Navigator.Screen>
) ) }
</NavigatorProvider>
</Navigator>
);
}
Loading

0 comments on commit 8060ecd

Please sign in to comment.