-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template Parts: Add a replace flow to the inspector controls (#55128)
* Template Parts: Add a replace flow to the inspector controls * create a function to share the code that creates block patterns from template parts' * fix the template part selection * show patterns either way
- Loading branch information
Showing
3 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/block-library/src/template-part/edit/utils/map-template-part-to-block-pattern.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { parse } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { createTemplatePartId } from './create-template-part-id'; | ||
|
||
/** | ||
* This maps the properties of a template part to those of a block pattern. | ||
* @param {Object} templatePart | ||
* @return {Object} The template part in the shape of block pattern. | ||
*/ | ||
export function mapTemplatePartToBlockPattern( templatePart ) { | ||
return { | ||
name: createTemplatePartId( templatePart.theme, templatePart.slug ), | ||
title: templatePart.title.rendered, | ||
blocks: parse( templatePart.content.raw ), | ||
templatePart, | ||
}; | ||
} |
3bb8b94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 3bb8b94.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8007467101
📝 Reported issues:
/test/e2e/specs/editor/blocks/navigation.spec.js