-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support reusable blocks for multi-selection #9732
Changes from 5 commits
d4d9758
42791c9
10363e2
66a33d8
23a9e98
aae9f43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { InnerBlocks } from '@wordpress/editor'; | ||
|
||
export const name = 'core/template'; | ||
|
||
export const settings = { | ||
title: __( 'Reusable Template' ), | ||
|
||
category: 'reusable', | ||
|
||
description: __( 'Template block used as a container.' ), | ||
|
||
icon: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="0" fill="none" width="24" height="24" /><g><path d="M19 3H5c-1.105 0-2 .895-2 2v14c0 1.105.895 2 2 2h14c1.105 0 2-.895 2-2V5c0-1.105-.895-2-2-2zM6 6h5v5H6V6zm4.5 13C9.12 19 8 17.88 8 16.5S9.12 14 10.5 14s2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5zm3-6l3-5 3 5h-6z" /></g></svg>, | ||
|
||
supports: { | ||
customClassName: false, | ||
html: false, | ||
inserter: false, | ||
}, | ||
|
||
edit() { | ||
return <InnerBlocks />; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the simplicity of this |
||
}, | ||
|
||
save() { | ||
return <InnerBlocks.Content />; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,14 +691,14 @@ export function convertBlockToStatic( clientId ) { | |
/** | ||
* Returns an action object used to convert a static block into a reusable block. | ||
* | ||
* @param {string} clientId The client ID of the block to detach. | ||
* @param {string} clientIds The client IDs of the block to detach. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed running docs update. Local changes on master after running |
||
* | ||
* @return {Object} Action object. | ||
*/ | ||
export function convertBlockToReusable( clientId ) { | ||
export function convertBlockToReusable( clientIds ) { | ||
return { | ||
type: 'CONVERT_BLOCK_TO_REUSABLE', | ||
clientId, | ||
clientIds: castArray( clientIds ), | ||
}; | ||
} | ||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Reusable Blocks multi-selection reusable block can be converted back to regular blocks 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>Hello there!</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>Second paragraph</p> | ||
<!-- /wp:paragraph -->" | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,7 +223,7 @@ describe( 'full post content fixture', () => { | |
.map( ( block ) => block.name ) | ||
// We don't want tests for each oembed provider, which all have the same | ||
// `save` functions and attributes. | ||
.filter( ( name ) => name.indexOf( 'core-embed' ) !== 0 ) | ||
.filter( ( name ) => name.indexOf( 'core-embed' ) !== 0 && name !== 'core/template' ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we update the comment here too? Not clear why we need to exclude it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to add fixtures for this block. I thought this test would bring too much compared to the e2e test |
||
.forEach( ( name ) => { | ||
const nameToFilename = name.replace( /\//g, '__' ); | ||
const foundFixtures = fileBasenames | ||
|
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.
Wonder if we should call this just "template" here?