Skip to content

Commit

Permalink
Outline editable blocks when in a pattern that has locked children (#…
Browse files Browse the repository at this point in the history
…57991)

Use :has() to outline editable blocks that are within a pattern that has
locked children but are themselves not locked. For example a pattern
that has multiple paragraphs, not in a container, and some of those
paragraphs allows an override.
  • Loading branch information
noisysocks authored Jan 22, 2024
1 parent b2c2a08 commit 6ab0f47
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions packages/block-editor/src/components/block-list/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -303,27 +303,34 @@ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-b
}
}

// Indicate which blocks are editable within a page editor or a content-locked
// pattern. Only show when user hovers over the page editor or pattern.
// Indicate which blocks are editable within a locked context.
// 1. User must be hovering an editor with renderingMode = 'template-lock'; or...
.is-template-locked:hover,
// ...a container block.
.block-editor-block-list__block:hover {
.block-editor-block-list__block.is-editing-disabled > .block-editor-block-list__block:not(.is-editing-disabled):not(.is-selected):not(.has-child-selected) {
&::after {
content: "";
border-style: dotted;
position: absolute;
pointer-events: none;
top: $border-width;
left: $border-width;
right: $border-width;
bottom: $border-width;
border: 1px dotted var(--wp-admin-theme-color);
border-radius: $radius-block-ui - $border-width;
}
// 2. Look for locked blocks; or...
.block-editor-block-list__block.is-editing-disabled,
// ...container blocks that have locked children.
&:has(> .block-editor-block-list__block.is-editing-disabled) {
// 3. Highlight any unlocked children of that locked block.
& > .block-editor-block-list__block:not(.is-editing-disabled):not(.is-selected):not(.has-child-selected) {
&::after {
content: "";
border-style: dotted;
position: absolute;
pointer-events: none;
top: $border-width;
left: $border-width;
right: $border-width;
bottom: $border-width;
border: 1px dotted var(--wp-admin-theme-color);
border-radius: $radius-block-ui - $border-width;
}

&.is-hovered::after {
background: rgba(var(--wp-admin-theme-color--rgb), 0.1);
border: none;
&.is-hovered::after {
background: rgba(var(--wp-admin-theme-color--rgb), 0.1);
border: none;
}
}
}
}
Expand Down

0 comments on commit 6ab0f47

Please sign in to comment.