Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-b
}
}

.is-root-container:not([inert]) .block-editor-block-list__block.is-reusable.is-selected .block-editor-block-list__block.has-editable-outline::after {
.is-root-container:not([inert]) .block-editor-block-list__block.is-selected .block-editor-block-list__block.has-editable-outline::after {
animation-name: block-editor-is-editable__animation;
animation-duration: 0.8s;
animation-timing-function: ease-out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function BlockPattern( {
) {
clonedBlock.attributes.metadata.categories = [ category ];
}
clonedBlock.attributes.templateLock = 'contentOnly';
return clonedBlock;
} );
}, [ blocks, isDraggable, category ] );
Expand Down
24 changes: 16 additions & 8 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { store as blockEditorStore } from '../../store';
import TabbedSidebar from '../tabbed-sidebar';
import { useZoomOut } from '../../hooks/use-zoom-out';
import { unlock } from '../../lock-unlock';
import { cloneBlock } from '@wordpress/blocks';

const NOOP = () => {};
function InserterMenu(
Expand Down Expand Up @@ -122,6 +123,13 @@ function InserterMenu(

const onInsertPattern = useCallback(
( blocks, patternName ) => {
if ( blocks.length === 1 && blocks[ 0 ]?.name === 'core/group' ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaggieCabrera @ndiego I wonder if this is a technique we could use as a proxy for "section pattern"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah perhaps. You might want to include Cover and maybe Media & Text and Columns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a core pattern that is just a cover block, and I think TT4 has one of those too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting that not all blocks support templateLock.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case then we'd need to iterate through the blocks applying the correct blockEditingMode. Template Lock works well for a prototype but possible not for production ready code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've realised that we're actually looking to find the block that is acting as the root of all the blocks we conceptually consider to be "sections" on a template/post.

As a result I think it's important that we review #64544 which might give us a standardised way to compute this.

blocks = [
cloneBlock( blocks[ 0 ], {
templateLock: 'contentOnly',
} ),
];
}
onToggleInsertionPoint( false );
onInsertBlocks( blocks, { patternName } );
onSelect();
Expand Down Expand Up @@ -334,26 +342,26 @@ function InserterMenu(
closeButtonLabel={ __( 'Close block inserter' ) }
tabs={ [
{
name: 'blocks',
title: __( 'Blocks' ),
name: 'patterns',
title: __( 'Patterns' ),
panel: (
<>
{ inserterSearch }
{ selectedTab === 'blocks' &&
{ selectedTab === 'patterns' &&
! delayedFilterValue &&
blocksTab }
patternsTab }
</>
),
},
{
name: 'patterns',
title: __( 'Patterns' ),
name: 'blocks',
title: __( 'Blocks' ),
panel: (
<>
{ inserterSearch }
{ selectedTab === 'patterns' &&
{ selectedTab === 'blocks' &&
! delayedFilterValue &&
patternsTab }
blocksTab }
</>
),
},
Expand Down
24 changes: 9 additions & 15 deletions packages/block-editor/src/hooks/content-lock-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,15 @@ function ContentLockControlsPure( { clientId, isSelected } ) {
</>
) }
{ showStartEditingAsBlocks && (
<BlockSettingsMenuControls>
{ ( { selectedClientIds, onClose } ) =>
selectedClientIds.length === 1 &&
selectedClientIds[ 0 ] === clientId && (
<MenuItem
onClick={ () => {
modifyContentLockBlock( clientId );
onClose();
} }
>
{ __( 'Modify' ) }
</MenuItem>
)
}
</BlockSettingsMenuControls>
<BlockControls group="other">
<ToolbarButton
onClick={ () => {
modifyContentLockBlock( clientId );
} }
>
{ __( 'Edit' ) }
</ToolbarButton>
</BlockControls>
) }
</>
);
Expand Down