Skip to content
Draft
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
34 changes: 32 additions & 2 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,20 @@ const canInsertBlockTypeUnmemoized = (
rootClientId
)
) {
return false;
// Allow inserting a Paragraph block anywhere that another Paragraph block already exists
// when in contentOnly mode.
if ( blockName === 'core/paragraph' ) {
const existingBlocks = getBlockOrder( state, rootClientId );
const hasParagraphBlock = existingBlocks.some(
( clientId ) =>
getBlockName( state, clientId ) === 'core/paragraph'
);
if ( ! hasParagraphBlock ) {
return false;
}
} else {
return false;
}
}

const parentName = getBlockName( state, rootClientId );
Expand Down Expand Up @@ -1901,7 +1914,24 @@ export function canRemoveBlock( state, clientId ) {
rootClientId
)
) {
return false;
// Allow removing a Paragraph block when other Paragraph blocks exist
// in contentOnly mode.
const blockName = getBlockName( state, clientId );
if (
rootBlockEditingMode === 'contentOnly' &&
blockName === 'core/paragraph'
) {
const existingBlocks = getBlockOrder( state, rootClientId );
const paragraphBlocks = existingBlocks.filter(
( id ) => getBlockName( state, id ) === 'core/paragraph'
);
// Allow removal if there are other paragraph blocks besides this one
if ( ! ( paragraphBlocks.length > 0 ) ) {
return false;
}
} else {
return false;
}
}

return rootBlockEditingMode !== 'disabled';
Expand Down
Loading