Skip to content

Commit

Permalink
Add page list to Link UI transforms in Nav block (#46426)
Browse files Browse the repository at this point in the history
* Initial work

* Remove debugging

* Allow Page List in Nav Link and Submenu

* Fix introduction of bug

* Remove console log
  • Loading branch information
getdave authored and dmsnell committed Dec 15, 2022
1 parent ef28fbe commit 5b475a6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function LinkControlTransforms( { clientId } ) {
const { replaceBlock } = useDispatch( blockEditorStore );

const featuredBlocks = [
'core/page-list',
'core/site-logo',
'core/social-links',
'core/search',
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ export default function NavigationLinkEdit( {
const ALLOWED_BLOCKS = [
'core/navigation-link',
'core/navigation-submenu',
'core/page-list',
];
const DEFAULT_BLOCK = {
name: 'core/navigation-link',
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/navigation-link/link-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ function LinkControlTransforms( { clientId } ) {
const { replaceBlock } = useDispatch( blockEditorStore );

const featuredBlocks = [
'core/page-list',
'core/site-logo',
'core/social-links',
'core/search',
];

const transforms = blockTransforms.filter( ( item ) => {
return featuredBlocks.includes( item.name );
} );
Expand Down
14 changes: 14 additions & 0 deletions packages/block-library/src/navigation-link/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ const transforms = {
return createBlock( 'core/navigation-link' );
},
},
{
type: 'block',
blocks: [ 'core/page-list' ],
transform: () => {
return createBlock( 'core/navigation-link' );
},
},
],
to: [
{
Expand Down Expand Up @@ -91,6 +98,13 @@ const transforms = {
} );
},
},
{
type: 'block',
blocks: [ 'core/page-list' ],
transform: () => {
return createBlock( 'core/page-list' );
},
},
],
};

Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ import { name } from './block.json';
import { LinkUI } from '../navigation-link/link-ui';
import { updateAttributes } from '../navigation-link/update-attributes';

const ALLOWED_BLOCKS = [ 'core/navigation-link', 'core/navigation-submenu' ];
const ALLOWED_BLOCKS = [
'core/navigation-link',
'core/navigation-submenu',
'core/page-list',
];

const DEFAULT_BLOCK = {
name: 'core/navigation-link',
Expand Down

0 comments on commit 5b475a6

Please sign in to comment.