Skip to content

Commit

Permalink
Support new block collection functionality in WordPress 5.4 (#1367)
Browse files Browse the repository at this point in the history
* registerBlockCollection

* Set categories

* Rename CoBlocks Galleries category to "Galleries"

* Update block-category.js

* try conditional

* fix highlight test

Co-authored-by: Anthony Ledesma <[email protected]>
Co-authored-by: JR Tashjian <[email protected]>
  • Loading branch information
3 people authored Mar 3, 2020
1 parent eac3d96 commit e3cd3b4
Show file tree
Hide file tree
Showing 46 changed files with 223 additions and 187 deletions.
11 changes: 10 additions & 1 deletion src/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import './extensions/coblocks-settings/';
// Formats
import './formats';

// Categories Helper
import { supportsCollections } from './utils/block-helpers';

// Deprecate Blocks
import './js/deprecations/deprecate-coblocks-buttons.js';

Expand Down Expand Up @@ -88,7 +91,13 @@ const registerBlock = ( block ) => {
return;
}

const { name, category, settings } = block;
let { category } = block;

const { name, settings } = block;

if ( ! supportsCollections() && ! name.includes( 'gallery' ) ) {
category = 'coblocks';
}

registerBlockType( name, {
category,
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/accordion/accordion-item/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/accordion-item",
"category": "coblocks",
"category": "common",
"attributes": {
"title": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/accordion/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/accordion",
"category": "coblocks",
"category": "common",
"attributes": {
"count": {
"type": "number",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/alert/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/alert",
"category": "coblocks",
"category": "formatting",
"attributes": {
"title": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/author/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/author",
"category": "coblocks",
"category": "layout",
"attributes": {
"biography": {
"type": "array",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/buttons/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/buttons",
"category": "coblocks",
"category": "layout",
"attributes": {
"items": {
"type": "number",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/click-to-tweet/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/click-to-tweet",
"category": "coblocks",
"category": "formatting",
"attributes": {
"content": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/dynamic-separator/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/dynamic-separator",
"category": "coblocks",
"category": "layout",
"attributes": {
"height": {
"type": "number",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/events/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/events",
"category": "coblocks",
"category": "layout",
"attributes": {
"align": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/events/event-item/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/event-item",
"category": "coblocks",
"category": "layout",
"attributes": {
"title": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/features/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/features",
"category": "coblocks",
"category": "layout",
"attributes": {
"headingLevel": {
"type": "integer",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/features/feature/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/feature",
"category": "coblocks",
"category": "layout",
"attributes": {
"headingLevel": {
"type": "integer",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/food-and-drinks/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/food-and-drinks",
"category": "coblocks",
"category": "layout",
"attributes": {
"showImages": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/food-and-drinks/food-item/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/food-item",
"category": "coblocks",
"category": "layout",
"attributes": {
"title": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-checkbox',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-date',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-email',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/hidden/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-hidden',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/name/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-name',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/phone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-phone',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/radio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-radio',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-select',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/textarea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-textarea',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/fields/website/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
*/
const metadata = {
name: 'coblocks/field-website',
category: 'coblocks',
category: 'layout',
attributes: {
label: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { InnerBlocks } from '@wordpress/block-editor';
*/
const metadata = {
name: 'coblocks/form',
category: 'coblocks',
category: 'layout',
attributes: {
subject: {
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/gif/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/gif",
"category": "coblocks",
"category": "common",
"attributes": {
"url": {
"attribute": "src",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/gist/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/gist",
"category": "coblocks",
"category": "formatting",
"attributes": {
"url": {
"type": "string"
Expand Down
116 changes: 58 additions & 58 deletions src/blocks/hero/block.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
{
"name": "coblocks/hero",
"category": "coblocks",
"attributes": {
"align": {
"type": "string",
"default": "full"
},
"contentAlign": {
"type": "string"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
},
"maxWidth": {
"type": "number",
"default": 560
},
"saveCoBlocksMeta": {
"type": "boolean",
"default": true
},
"paddingSize": {
"type": "string",
"default": "huge"
},
"paddingUnit": {
"type": "string",
"default": "px"
},
"paddingTop": {
"type": "number",
"default": 60
},
"paddingBottom": {
"type": "number",
"default": 60
},
"paddingLeft": {
"type": "number",
"default": 60
},
"paddingRight": {
"type": "number",
"default": 60
},
"customBackgroundColor": {
"type": "string"
},
"height": {
"type": "number",
"default": 500
}
}
}
{
"name": "coblocks/hero",
"category": "layout",
"attributes": {
"align": {
"type": "string",
"default": "full"
},
"contentAlign": {
"type": "string"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
},
"maxWidth": {
"type": "number",
"default": 560
},
"saveCoBlocksMeta": {
"type": "boolean",
"default": true
},
"paddingSize": {
"type": "string",
"default": "huge"
},
"paddingUnit": {
"type": "string",
"default": "px"
},
"paddingTop": {
"type": "number",
"default": 60
},
"paddingBottom": {
"type": "number",
"default": 60
},
"paddingLeft": {
"type": "number",
"default": 60
},
"paddingRight": {
"type": "number",
"default": 60
},
"customBackgroundColor": {
"type": "string"
},
"height": {
"type": "number",
"default": 500
}
}
}
2 changes: 1 addition & 1 deletion src/blocks/highlight/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/highlight",
"category": "coblocks",
"category": "formatting",
"attributes": {
"content": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/icon/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/icon",
"category": "coblocks",
"category": "common",
"attributes": {
"icon": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/logos/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/logos",
"category": "coblocks",
"category": "layout",
"attributes": {
"align": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/map/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coblocks/map",
"category": "coblocks",
"category": "layout",
"attributes": {
"address": {
"type": "string"
Expand Down
Loading

0 comments on commit e3cd3b4

Please sign in to comment.