Skip to content

Commit

Permalink
Merge branch 'trunk' into feat/issue-54399
Browse files Browse the repository at this point in the history
  • Loading branch information
hbhalodia committed Jan 4, 2024
2 parents 55fa121 + 228344b commit 9f45336
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 360 deletions.
2 changes: 1 addition & 1 deletion lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function gutenberg_initialize_experiments_settings() {
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test Connections', 'gutenberg' ),
'label' => __( 'Test connecting block attribute values to a custom field value', 'gutenberg' ),
'id' => 'gutenberg-connections',
)
);
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class PrivateInserter extends Component {
clientId={ clientId }
isAppender={ isAppender }
showInserterHelpPanel={ showInserterHelpPanel }
prioritizePatterns={ prioritizePatterns }
/>
);
}
Expand Down
10 changes: 2 additions & 8 deletions packages/block-editor/src/components/inserter/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ function InserterLibrary(
},
ref
) {
const { destinationRootClientId, prioritizePatterns } = useSelect(
const { destinationRootClientId } = useSelect(
( select ) => {
const { getBlockRootClientId, getSettings } =
select( blockEditorStore );

const { getBlockRootClientId } = select( blockEditorStore );
const _rootClientId =
rootClientId || getBlockRootClientId( clientId ) || undefined;
return {
destinationRootClientId: _rootClientId,
prioritizePatterns:
getSettings().__experimentalPreferPatternsOnRoot &&
! _rootClientId,
};
},
[ clientId, rootClientId ]
Expand All @@ -54,7 +49,6 @@ function InserterLibrary(
__experimentalInsertionIndex={ __experimentalInsertionIndex }
__experimentalFilterValue={ __experimentalFilterValue }
shouldFocusBlock={ shouldFocusBlock }
prioritizePatterns={ prioritizePatterns }
ref={ ref }
/>
);
Expand Down
2 changes: 0 additions & 2 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function InserterMenu(
showMostUsedBlocks,
__experimentalFilterValue = '',
shouldFocusBlock = true,
prioritizePatterns,
},
ref
) {
Expand Down Expand Up @@ -258,7 +257,6 @@ function InserterMenu(
<InserterTabs
showPatterns={ showPatterns }
showMedia={ showMedia }
prioritizePatterns={ prioritizePatterns }
onSelect={ handleSetSelectedTab }
tabsContents={ inserterTabsContents }
/>
Expand Down
4 changes: 1 addition & 3 deletions packages/block-editor/src/components/inserter/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ function InserterTabs( {
showPatterns = false,
showMedia = false,
onSelect,
prioritizePatterns = false,
tabsContents,
} ) {
const tabs = [
prioritizePatterns && showPatterns && patternsTab,
blocksTab,
! prioritizePatterns && showPatterns && patternsTab,
showPatterns && patternsTab,
showMedia && mediaTab,
].filter( Boolean );

Expand Down
17 changes: 2 additions & 15 deletions packages/block-editor/src/components/use-on-block-drop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export function onBlockDrop(
* A function that returns an event handler function for block-related file drop events.
*
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
* @param {Function} getSettings A function that gets the block editor settings.
* @param {Function} updateBlockAttributes A function that updates a block's attributes.
* @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
Expand All @@ -143,7 +142,6 @@ export function onBlockDrop(
*/
export function onFilesDrop(
targetRootClientId,
targetBlockIndex,
getSettings,
updateBlockAttributes,
canInsertBlockType,
Expand Down Expand Up @@ -175,17 +173,11 @@ export function onFilesDrop(
/**
* A function that returns an event handler function for block-related HTML drop events.
*
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
* @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
*
* @return {Function} The event handler for a block-related HTML drop event.
*/
export function onHTMLDrop(
targetRootClientId,
targetBlockIndex,
insertOrReplaceBlocks
) {
export function onHTMLDrop( insertOrReplaceBlocks ) {
return ( HTML ) => {
const blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );

Expand Down Expand Up @@ -309,17 +301,12 @@ export default function useOnBlockDrop(
);
const _onFilesDrop = onFilesDrop(
targetRootClientId,
targetBlockIndex,
getSettings,
updateBlockAttributes,
canInsertBlockType,
insertOrReplaceBlocks
);
const _onHTMLDrop = onHTMLDrop(
targetRootClientId,
targetBlockIndex,
insertOrReplaceBlocks
);
const _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );

return ( event ) => {
const files = getFilesFromDataTransfer( event.dataTransfer );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,10 @@ describe( 'onFilesDrop', () => {
const canInsertBlockType = noop;
const insertOrReplaceBlocks = jest.fn();
const targetRootClientId = '1';
const targetBlockIndex = 0;
const getSettings = jest.fn( () => ( {} ) );

const onFileDropHandler = onFilesDrop(
targetRootClientId,
targetBlockIndex,
getSettings,
updateBlockAttributes,
canInsertBlockType,
Expand All @@ -331,14 +329,12 @@ describe( 'onFilesDrop', () => {
const insertOrReplaceBlocks = jest.fn();
const canInsertBlockType = noop;
const targetRootClientId = '1';
const targetBlockIndex = 0;
const getSettings = jest.fn( () => ( {
mediaUpload: true,
} ) );

const onFileDropHandler = onFilesDrop(
targetRootClientId,
targetBlockIndex,
getSettings,
updateBlockAttributes,
canInsertBlockType,
Expand All @@ -361,14 +357,12 @@ describe( 'onFilesDrop', () => {
const canInsertBlockType = noop;
const insertOrReplaceBlocks = jest.fn();
const targetRootClientId = '1';
const targetBlockIndex = 0;
const getSettings = jest.fn( () => ( {
mediaUpload: true,
} ) );

const onFileDropHandler = onFilesDrop(
targetRootClientId,
targetBlockIndex,
getSettings,
updateBlockAttributes,
canInsertBlockType,
Expand All @@ -389,15 +383,9 @@ describe( 'onFilesDrop', () => {
describe( 'onHTMLDrop', () => {
it( 'does nothing if the HTML cannot be converted into blocks', () => {
pasteHandler.mockImplementation( () => [] );
const targetRootClientId = '1';
const targetBlockIndex = 0;
const insertOrReplaceBlocks = jest.fn();

const eventHandler = onHTMLDrop(
targetRootClientId,
targetBlockIndex,
insertOrReplaceBlocks
);
const eventHandler = onHTMLDrop( insertOrReplaceBlocks );
eventHandler();

expect( insertOrReplaceBlocks ).not.toHaveBeenCalled();
Expand All @@ -406,15 +394,9 @@ describe( 'onHTMLDrop', () => {
it( 'inserts blocks if the HTML can be converted into blocks', () => {
const blocks = [ 'blocks' ];
pasteHandler.mockImplementation( () => blocks );
const targetRootClientId = '1';
const targetBlockIndex = 0;
const insertOrReplaceBlocks = jest.fn();

const eventHandler = onHTMLDrop(
targetRootClientId,
targetBlockIndex,
insertOrReplaceBlocks
);
const eventHandler = onHTMLDrop( insertOrReplaceBlocks );
eventHandler();

expect( insertOrReplaceBlocks ).toHaveBeenCalledWith( blocks );
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
displayPreview,
previewHeight,
} = attributes;
const { media, mediaUpload } = useSelect(
const { getSettings } = useSelect( blockEditorStore );
const { media } = useSelect(
( select ) => ( {
media:
id === undefined
? undefined
: select( coreStore ).getMedia( id ),
mediaUpload: select( blockEditorStore ).getSettings().mediaUpload,
} ),
[ id ]
);
Expand All @@ -93,7 +93,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
if ( isBlobURL( href ) ) {
const file = getBlobByURL( href );

mediaUpload( {
getSettings().mediaUpload( {
filesList: [ file ],
onFileChange: ( [ newMedia ] ) => onSelectFile( newMedia ),
onError: onUploadError,
Expand Down
100 changes: 0 additions & 100 deletions packages/e2e-tests/specs/editor/various/invalid-block.test.js

This file was deleted.

Loading

0 comments on commit 9f45336

Please sign in to comment.