-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
- Part of Block API #41236.
- Related to Block Bindings API iteration for 6.5 #54536.
N.B. Previously referred to as partially synced patterns.
What problem does this address?
Currently when adding a synced pattern all parts of that pattern are synced across every instance, so changes in any part of the pattern are reflected across as instances of the pattern.
It has been discussed in a number of places (#48458, #50456 ) that patterns would be much more useful/flexible if parts of them, particularly the layout and styling components, could be locked and synced across instances while allowing parts of the content to be updated independently.
An example workflow for a user could be a partially synced 'Recipe' pattern. A user could insert this pattern into multiple posts and any content (Ingredients, Steps) would be local to the post rather than synced in the pattern itself. The user would also be able to go back and modify the design of the recipe pattern, and this should have no effect on their content.
What is your proposed solution?
A number of potential solutions were discussed here with a few proofs of concepts. The current thinking is to use of the proposed block bindings api to implement partial syncing, since there's some overlap in requirements. The block bindings API mostly describes a way to use external data for a block attribute value (e.g. using a custom field for paragraph content). For patterns, child blocks of a pattern block could get and set their attribute values to the pattern block instance itself. This way, different instances of patterns could inject different data into the same pattern.
See the current prototype in #56235.
Tasks
V1 (Completed)
Pattern override tasks
- Add a new experiment to initially put partial syncing functionality behind separate to block bindings one - this can go in Automatically assign block ids to pattern blocks for use in partial synching of pattern instances #56495Implement a system to set/get attributes in parent pattern block (Implement partially synced patterns behind an experimental flag #56235)Experiment with using ids and/or names to connect attributes to a data source, document trade-offs and choose an approach. (Automatically assign block ids to pattern blocks for use in partial synching of pattern instances #56495)Add a way for the pattern creator to indicate which parts of the synced pattern can be edited (e.g. via the block renaming functionality?). (V1 of this here - [Pattern Overrides] Use a single checkbox to turn on pattern overrides for all allowed attributes #57009)Explore locking synced pattern instances by default, providing a way to edit them through the toolbar. This could open the isolated editing mode for patterns. (see Make Synced Patterns lockable so content cannot be edited inline #32353) - potential solution here Patterns: edit source pattern in focus mode in post and site editors #57036Add UX to indicate to user which parts of the pattern instance can be edited, similar to the
contentOnly
mode - this is also covered by Patterns: edit source pattern in focus mode in post and site editors #57036Consider rewording the description of the pattern block (wp/block
block) based on the changes in functionality (see Pattern Overrides epic (WordPress 6.5) #53705 (comment)) (PR: Update pattern block copy in light of pattern overrides #58231)Remove the experiment flag prior to WordPress 6.5 beta (Stabilize the pattern overrides block context #58102, Remove pattern override experiment completely #58105)Reduce reset button text to justReset
- (PR - Patterns: Change text on pattern reset button #58286)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Block Binding Intergration
- Adopt the block bindings API as it becomes available (see Block Bindings API iteration for 6.5 #54536)
(add subtasks here as required)- Utilize the new block bindings source API (see Block Bindings API: Add block bindings PHP registration mechanisms and "Post meta" source under the experimental flag #57249)
- Expand support to heading and button blocks (PR: Allow heading and button in Pattern Overrides #57789)
- Expand support to image blocks (PR: Add image block support for pattern overrides #57909)
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Bugs
- New paragraph can be added by hitting enter at end of existing paragraph that has editable attributes, but the new paragraph can't be edited. (fix: Pattern Overrides: Add
template-lock: all
to pattern inner blocks to prevent deletion/insertion #57661)A user can multi-select two non-adjacent paragraphs that have overrides and delete any 'locked' blocks between them. (fix: Pattern Overrides: Addtemplate-lock: all
to pattern inner blocks to prevent deletion/insertion #57661)Fix the white background when editing a pattern in the post editor (fixed by Patterns: Add black border back when editing synced pattern in the post editor #57631)If you delete the content from a paragraph with editable attrib, it looks empty, which is what user may want, but saving and reloading brings back content from the original pattern, which in other cases may also be what user wants 🤔. (update: unable to reproduce this in recent testing)ThecontentOnly
UI for editing overriden blocks currently shows the text align tool on the toolbar, but this isn't supported (it can be changed but the changes aren't saved). (PR: Remove text align control for paragraph, heading, and button in contentOnly editing mode #57906)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Follow Ups
- Use the solution in #57036 for template only mode (see this comment) - (PR: Remove
template-only
mode from editor and edit-post packages #57700)Explore highlighting editable blocks - (PR - Outline editable blocks that are within a content-locked container #57901)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Suggested enhancements/explorations
- Consider how future features like shuffling might workReconsider using Ids to bind blocks, the data stored in the pattern block should be more readable/interpretable - draft PR using name instead of idWhen a pattern is redesigned, there's a chance a user will modify blocks/attributes in a way that they become disconnected from the instances of a pattern (e.g. renaming the block to something different). Explore ways to prevent/warn a user about these risks.Change the override attribute name to
content
- (PR - #58596)Look into storing the block name as metadata in the overrides data (PR - #58715)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Block specific issues
Image Block
Supported attributes: url
, id
, title
, alt
- Adding an image that has a caption set in the media library displays the caption, even when the original pattern has been designed to hide captions. (it disappears after a refresh though)Caption is not supported as a block bindings attribute, but can be edited in the UI (when toggled on in the original pattern) (PR: #58916)Alt and title are supported attributes, but are not editable in the UI (they're hidden by content only mode) (PR: #58998)Link is not supported as a block bindings attribute, but can be edited in the UI (PR: Disable overriding links of images inside pattern instances #58660)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Button Block
Supported attributes: text
, url
- Link (
url
) attribute is supported, but related attributeslinkTarget
andrel
are not supported as block bindings attributes, but are still editable in the UI (PR: Support button's link settings for Pattern Overrides #58587)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Heading block
Supported attributes: content
- Heading level isn't supported, could/should it be?To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Paragraph block
Supported attributes: content
No known issues
General Bugs
- Lock icons display in List View for a pattern's inner blocks (even though the blocks are still content editable)To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Code quality
- Explore better ways to show/hide block UI that doesn't involve hard-coding references to 'core/block' in the codebase, AKA address where
blockEditingMode
doesn't quite work for the pattern block (see Patterns: edit source pattern in focus mode in post and site editors #57036 (comment))To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Future
- As part of the block binding API, users can denote connections to different sources (e.g. custom fields, other post values, custom data sources). To declare a pattern override, the user also defines connections. Given they're separate UIs, some thought needs to go into what happens when a user attempts to connect a pattern override on a block that's already connected to a custom field—should it overwrite it, should it be prevented, how is the user made aware of the risk/outcome.At the moment the API will work for one block at a time. A solution will be needed for lists, galleries or anything that requires a series/array of bound blocks. (see Add new mode to
contentOnly
locking to allow insertion of new inner blocks #52018 for similar challenges withcontentOnly
mode). One solution explored here [PoC] Patterns: try partial syncing of inner blocks #56348Some exploration might be need around how block deprecations will work (i.e. if a block attribute name changes)If a user completely deletes a source pattern, they will potentially lose content everywhere the pattern is used. Are there ways to restore this content, maybe offering a flow similar to block recovery?To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.