Skip to content

Audit blocks for writing and contentOnly modes #65778

@talldan

Description

@talldan

Description

contentOnly mode is becoming more prevalent in the editor after 'Select Mode: Use the content-only behavior in select mode' was merged.

Lots of block types still aren't working perfectly in contentOnly mode, so this list intends to capture those issues so that they can be worked on in parallel by multiple devs. Lots of the blocks also share similar issues, so hopefully there are higher-level solutions to the problems that can be found (lets discuss these in the comments).

Feel free to add more to this issue if you discover untracked issues.

Rough snippet that can be run in post editor's console to generate example blocks in contentOnly locked groups, YMMV 🤷
const blockExamples = wp.data.select( 'core/blocks' ).getBlockTypes()
  .filter( ( { example } ) => example )
  .map( ( { name, title, example: { attributes, innerBlocks } } ) => ( { name, title, attributes, innerBlocks } ) );
const createInnerExamples = ( innerBlocks ) => innerBlocks.map( ( { name, attributes, innerBlocks } ) => {
  return wp.blocks.createBlock( name, attributes, createInnerExamples( innerBlocks ?? [] ) );
});
const createExamples = ( examples ) => examples.map( ( { name, title, attributes, innerBlocks } ) => {
  const innerBlockInstances = createInnerExamples( innerBlocks ?? [] );

  return wp.blocks.createBlock( 'core/group', {
    templateLock: 'contentOnly',
    metadata: { name: title }
  }, [ wp.blocks.createBlock( name, attributes, innerBlockInstances ) ]);
});
const innerBlockInstances = createExamples( blockExamples );
const blocks = wp.data.select( 'core/block-editor' ).getBlocks();

wp.data.dispatch( 'core/block-editor' ).insertBlocks( innerBlockInstances, blocks.length );

Blocks

Buttons

Cover

  • Background image cannot be modified (should it be possible to modify this?)
  • Initial block placeholder can't be interacted with in contentOnly mode (possibly the same issue as above).

Details

PR: #70124

  • Details block appears as a single 'Paragraph' in the Inspector Content panel

File

PR: #65787

  • Block is completely non-interactive, including the placeholder

Gallery

List

PR: #65836

Media / Text

  • Additional paragraphs can't be added in the content area of the block (similar to Quote)
  • In the Inspector panel, the paragraph that's inside the Media Text block appears after it (again, similar to Quote)

More

PR: #70100

  • User cannot edit 'Read more' text

Navigation

Post Title / Featured Image / Excerpt

  • Blocks cannot be edited (they have no attributes suitable for the role: content declaration)

Query

Quote

  • The paragraph that's inside the Quote appears after the Quote block in the Inspector Content panel (to repro, add a quote block inside a group, apply contentOnly templateLock to the group, and select the group.)
  • Users cannot add more paragraphs (should they be able to? If so should they also be able to add other types of blocks? How do these appear in the Inspector Content panel?) (see Add new mode to contentOnly locking to allow insertion of new inner blocks #52018)

Site Logo / Site Title / Site Tagline

PR: #67260

  • Blocks cannot be edited (they have no attributes suitable for the role: content declaration)

Social Link(s)

Synced Patterns in Write Mode

PR: #67026

Table

PR: #70114

  • Block is completely non-editable in contentOnly mode, including the initial placeholder

Template Parts

Metadata

Metadata

Assignees

Labels

[Feature] Block LockingThe API allowing for the ability to lock/unlock blocks[Feature] Write mode[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.

Projects

Status

Now

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions