Editor: Register core blocks on the server

Exposes all core blocks (excluding embeds) on the server to be used with the REST API block types endpoint.

Props spacedmonkey, timothyblynjacobs.
Fixes #50263.


Built from https://develop.svn.wordpress.org/trunk@48262


git-svn-id: http://core.svn.wordpress.org/trunk@48031 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo 2020-07-01 12:29:03 +00:00
parent eeb4d75c57
commit eafcf52d18
33 changed files with 1122 additions and 12 deletions

View File

@ -0,0 +1,42 @@
{
"name": "core/audio",
"category": "media",
"attributes": {
"src": {
"type": "string",
"source": "attribute",
"selector": "audio",
"attribute": "src"
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption"
},
"id": {
"type": "number"
},
"autoplay": {
"type": "boolean",
"source": "attribute",
"selector": "audio",
"attribute": "autoplay"
},
"loop": {
"type": "boolean",
"source": "attribute",
"selector": "audio",
"attribute": "loop"
},
"preload": {
"type": "string",
"source": "attribute",
"selector": "audio",
"attribute": "preload"
}
},
"supports": {
"align": true,
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,62 @@
{
"name": "core/button",
"category": "design",
"parent": [
"core/buttons"
],
"attributes": {
"url": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "href"
},
"title": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "title"
},
"text": {
"type": "string",
"source": "html",
"selector": "a"
},
"linkTarget": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "target"
},
"rel": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "rel"
},
"placeholder": {
"type": "string"
},
"borderRadius": {
"type": "number"
},
"style": {
"type": "object"
},
"backgroundColor": {
"type": "string"
},
"textColor": {
"type": "string"
},
"gradient": {
"type": "string"
}
},
"supports": {
"align": true,
"alignWide": false,
"reusable": false,
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,9 @@
{
"name": "core/buttons",
"category": "design",
"supports": {
"align": true,
"alignWide": false,
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,15 @@
{
"name": "core/freeform",
"category": "text",
"attributes": {
"content": {
"type": "string",
"source": "html"
}
},
"supports": {
"className": false,
"customClassName": false,
"reusable": false
}
}

View File

@ -0,0 +1,15 @@
{
"name": "core/code",
"category": "text",
"attributes": {
"content": {
"type": "string",
"source": "text",
"selector": "code"
}
},
"supports": {
"html": false,
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,22 @@
{
"name": "core/column",
"category": "text",
"parent": [
"core/columns"
],
"attributes": {
"verticalAlignment": {
"type": "string"
},
"width": {
"type": "number",
"min": 0,
"max": 100
}
},
"supports": {
"reusable": false,
"html": false,
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,21 @@
{
"name": "core/columns",
"category": "design",
"attributes": {
"verticalAlignment": {
"type": "string"
}
},
"supports": {
"align": [
"wide",
"full"
],
"html": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"gradients": true,
"linkColor": true
}
}
}

View File

@ -0,0 +1,41 @@
{
"name": "core/file",
"category": "media",
"attributes": {
"id": {
"type": "number"
},
"href": {
"type": "string"
},
"fileName": {
"type": "string",
"source": "html",
"selector": "a:not([download])"
},
"textLinkHref": {
"type": "string",
"source": "attribute",
"selector": "a:not([download])",
"attribute": "href"
},
"textLinkTarget": {
"type": "string",
"source": "attribute",
"selector": "a:not([download])",
"attribute": "target"
},
"showDownloadButton": {
"type": "boolean",
"default": true
},
"downloadButtonText": {
"type": "string",
"source": "html",
"selector": "a[download]"
}
},
"supports": {
"align": true
}
}

View File

@ -0,0 +1,82 @@
{
"name": "core/gallery",
"category": "media",
"attributes": {
"images": {
"type": "array",
"default": [],
"source": "query",
"selector": ".blocks-gallery-item",
"query": {
"url": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "src"
},
"fullUrl": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "data-full-url"
},
"link": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "data-link"
},
"alt": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "alt",
"default": ""
},
"id": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "data-id"
},
"caption": {
"type": "string",
"source": "html",
"selector": ".blocks-gallery-item__caption"
}
}
},
"ids": {
"type": "array",
"items": {
"type": "number"
},
"default": []
},
"columns": {
"type": "number",
"minimum": 1,
"maximum": 8
},
"caption": {
"type": "string",
"source": "html",
"selector": ".blocks-gallery-caption"
},
"imageCrop": {
"type": "boolean",
"default": true
},
"linkTo": {
"type": "string",
"default": "none"
},
"sizeSlug": {
"type": "string",
"default": "large"
}
},
"supports": {
"align": true
}
}

View File

@ -0,0 +1,23 @@
{
"name": "core/group",
"category": "design",
"attributes": {
"tagName": {
"type": "string",
"default": "div"
}
},
"supports": {
"align": [
"wide",
"full"
],
"anchor": true,
"html": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"gradients": true,
"linkColor": true
}
}
}

View File

@ -0,0 +1,41 @@
{
"name": "core/heading",
"category": "text",
"attributes": {
"align": {
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"selector": "h1,h2,h3,h4,h5,h6",
"default": ""
},
"level": {
"type": "number",
"default": 2
},
"placeholder": {
"type": "string"
}
},
"supports": {
"anchor": true,
"className": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"linkColor": true
},
"__experimentalFontSize": true,
"__experimentalLineHeight": true,
"__experimentalSelector": {
"core/heading/h1": "h1",
"core/heading/h2": "h2",
"core/heading/h3": "h3",
"core/heading/h4": "h4",
"core/heading/h5": "h5",
"core/heading/h6": "h6"
},
"__unstablePasteTextInline": true
}
}

View File

@ -0,0 +1,15 @@
{
"name": "core/html",
"category": "widgets",
"attributes": {
"content": {
"type": "string",
"source": "html"
}
},
"supports": {
"customClassName": false,
"className": false,
"html": false
}
}

View File

@ -0,0 +1,76 @@
{
"name": "core/image",
"category": "media",
"attributes": {
"align": {
"type": "string"
},
"url": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "src"
},
"alt": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "alt",
"default": ""
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption"
},
"title": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "title"
},
"href": {
"type": "string",
"source": "attribute",
"selector": "figure > a",
"attribute": "href"
},
"rel": {
"type": "string",
"source": "attribute",
"selector": "figure > a",
"attribute": "rel"
},
"linkClass": {
"type": "string",
"source": "attribute",
"selector": "figure > a",
"attribute": "class"
},
"id": {
"type": "number"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
},
"sizeSlug": {
"type": "string"
},
"linkDestination": {
"type": "string",
"default": "none"
},
"linkTarget": {
"type": "string",
"source": "attribute",
"selector": "figure > a",
"attribute": "target"
}
},
"supports": {
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Used to set up all core blocks used with the block editor.
*
* @package WordPress
*/
// Include files required for core blocks registration.
require ABSPATH . WPINC . '/blocks/archives.php';
require ABSPATH . WPINC . '/blocks/block.php';
require ABSPATH . WPINC . '/blocks/calendar.php';
require ABSPATH . WPINC . '/blocks/categories.php';
require ABSPATH . WPINC . '/blocks/latest-comments.php';
require ABSPATH . WPINC . '/blocks/latest-posts.php';
require ABSPATH . WPINC . '/blocks/rss.php';
require ABSPATH . WPINC . '/blocks/search.php';
require ABSPATH . WPINC . '/blocks/shortcode.php';
require ABSPATH . WPINC . '/blocks/social-link.php';
require ABSPATH . WPINC . '/blocks/tag-cloud.php';
$block_folders = array(
'audio',
'button',
'buttons',
'classic',
'code',
'column',
'columns',
'file',
'gallery',
'group',
'heading',
'html',
'image',
'list',
'media-text',
'missing',
'more',
'nextpage',
'paragraph',
'preformatted',
'pullquote',
'quote',
'separator',
'social-links',
'spacer',
'subhead',
'table',
'text-columns',
'verse',
'video',
);
foreach ( $block_folders as $block_folder ) {
register_block_type_from_metadata(
ABSPATH . WPINC . '/blocks/' . $block_folder
);
}

View File

@ -0,0 +1,35 @@
{
"name": "core/list",
"category": "text",
"attributes": {
"ordered": {
"type": "boolean",
"default": false
},
"values": {
"type": "string",
"source": "html",
"selector": "ol,ul",
"multiline": "li",
"__unstableMultilineWrapperTags": [
"ol",
"ul"
],
"default": ""
},
"type": {
"type": "string"
},
"start": {
"type": "number"
},
"reversed": {
"type": "boolean"
}
},
"supports": {
"className": false,
"__unstablePasteTextInline": true,
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,92 @@
{
"name": "core/media-text",
"category": "media",
"attributes": {
"align": {
"type": "string",
"default": "wide"
},
"mediaAlt": {
"type": "string",
"source": "attribute",
"selector": "figure img",
"attribute": "alt",
"default": ""
},
"mediaPosition": {
"type": "string",
"default": "left"
},
"mediaId": {
"type": "number"
},
"mediaUrl": {
"type": "string",
"source": "attribute",
"selector": "figure video,figure img",
"attribute": "src"
},
"mediaLink": {
"type": "string"
},
"linkDestination": {
"type": "string"
},
"linkTarget": {
"type": "string",
"source": "attribute",
"selector": "figure a",
"attribute": "target"
},
"href": {
"type": "string",
"source": "attribute",
"selector": "figure a",
"attribute": "href"
},
"rel": {
"type": "string",
"source": "attribute",
"selector": "figure a",
"attribute": "rel"
},
"linkClass": {
"type": "string",
"source": "attribute",
"selector": "figure a",
"attribute": "class"
},
"mediaType": {
"type": "string"
},
"mediaWidth": {
"type": "number",
"default": 50
},
"isStackedOnMobile": {
"type": "boolean",
"default": true
},
"verticalAlignment": {
"type": "string"
},
"imageFill": {
"type": "boolean"
},
"focalPoint": {
"type": "object"
}
},
"supports": {
"align": [
"wide",
"full"
],
"html": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"gradients": true,
"linkColor": true
}
}
}

View File

@ -0,0 +1,23 @@
{
"name": "core/missing",
"category": "text",
"attributes": {
"originalName": {
"type": "string"
},
"originalUndelimitedContent": {
"type": "string"
},
"originalContent": {
"type": "string",
"source": "html"
}
},
"supports": {
"className": false,
"customClassName": false,
"inserter": false,
"html": false,
"reusable": false
}
}

View File

@ -0,0 +1,19 @@
{
"name": "core/more",
"category": "design",
"attributes": {
"customText": {
"type": "string"
},
"noTeaser": {
"type": "boolean",
"default": false
}
},
"supports": {
"customClassName": false,
"className": false,
"html": false,
"multiple": false
}
}

View File

@ -0,0 +1,10 @@
{
"name": "core/nextpage",
"category": "design",
"parent": [ "core/post-content" ],
"supports": {
"customClassName": false,
"className": false,
"html": false
}
}

View File

@ -0,0 +1,45 @@
{
"name": "core/paragraph",
"category": "text",
"attributes": {
"align": {
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"selector": "p",
"default": ""
},
"dropCap": {
"type": "boolean",
"default": false
},
"placeholder": {
"type": "string"
},
"direction": {
"type": "string",
"enum": [
"ltr",
"rtl"
]
}
},
"supports": {
"className": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"linkColor": true
},
"__experimentalFontSize": true,
"__experimentalLineHeight": true,
"__experimentalFeatures": {
"typography": {
"dropCap": true
}
},
"__experimentalSelector": "p",
"__unstablePasteTextInline": true
}
}

View File

@ -0,0 +1,16 @@
{
"name": "core/preformatted",
"category": "text",
"attributes": {
"content": {
"type": "string",
"source": "html",
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true
}
},
"supports": {
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,38 @@
{
"name": "core/pullquote",
"category": "text",
"attributes": {
"value": {
"type": "string",
"source": "html",
"selector": "blockquote",
"multiline": "p"
},
"citation": {
"type": "string",
"source": "html",
"selector": "cite",
"default": ""
},
"mainColor": {
"type": "string"
},
"customMainColor": {
"type": "string"
},
"textColor": {
"type": "string"
},
"customTextColor": {
"type": "string"
}
},
"supports": {
"align": [
"left",
"right",
"wide",
"full"
]
}
}

View File

@ -0,0 +1,22 @@
{
"name": "core/quote",
"category": "text",
"attributes": {
"value": {
"type": "string",
"source": "html",
"selector": "blockquote",
"multiline": "p",
"default": ""
},
"citation": {
"type": "string",
"source": "html",
"selector": "cite",
"default": ""
},
"align": {
"type": "string"
}
}
}

View File

@ -0,0 +1,12 @@
{
"name": "core/separator",
"category": "design",
"attributes": {
"color": {
"type": "string"
},
"customColor": {
"type": "string"
}
}
}

View File

@ -0,0 +1,12 @@
{
"name": "core/social-links",
"category": "widgets",
"supports": {
"align": [
"left",
"center",
"right"
],
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,10 @@
{
"name": "core/spacer",
"category": "design",
"attributes": {
"height": {
"type": "number",
"default": 100
}
}
}

View File

@ -0,0 +1,18 @@
{
"name": "core/subhead",
"category": "text",
"attributes": {
"align": {
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"selector": "p"
}
},
"supports": {
"inserter": false,
"multiple": false
}
}

View File

@ -0,0 +1,127 @@
{
"name": "core/table",
"category": "text",
"attributes": {
"hasFixedLayout": {
"type": "boolean",
"default": false
},
"backgroundColor": {
"type": "string"
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption",
"default": ""
},
"head": {
"type": "array",
"default": [],
"source": "query",
"selector": "thead tr",
"query": {
"cells": {
"type": "array",
"default": [],
"source": "query",
"selector": "td,th",
"query": {
"content": {
"type": "string",
"source": "html"
},
"tag": {
"type": "string",
"default": "td",
"source": "tag"
},
"scope": {
"type": "string",
"source": "attribute",
"attribute": "scope"
},
"align": {
"type": "string",
"source": "attribute",
"attribute": "data-align"
}
}
}
}
},
"body": {
"type": "array",
"default": [],
"source": "query",
"selector": "tbody tr",
"query": {
"cells": {
"type": "array",
"default": [],
"source": "query",
"selector": "td,th",
"query": {
"content": {
"type": "string",
"source": "html"
},
"tag": {
"type": "string",
"default": "td",
"source": "tag"
},
"scope": {
"type": "string",
"source": "attribute",
"attribute": "scope"
},
"align": {
"type": "string",
"source": "attribute",
"attribute": "data-align"
}
}
}
}
},
"foot": {
"type": "array",
"default": [],
"source": "query",
"selector": "tfoot tr",
"query": {
"cells": {
"type": "array",
"default": [],
"source": "query",
"selector": "td,th",
"query": {
"content": {
"type": "string",
"source": "html"
},
"tag": {
"type": "string",
"default": "td",
"source": "tag"
},
"scope": {
"type": "string",
"source": "attribute",
"attribute": "scope"
},
"align": {
"type": "string",
"source": "attribute",
"attribute": "data-align"
}
}
}
}
}
},
"supports": {
"align": true
}
}

View File

@ -0,0 +1,32 @@
{
"name": "core/text-columns",
"icon": "columns",
"category": "design",
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "p",
"query": {
"children": {
"type": "string",
"source": "html"
}
},
"default": [
{},
{}
]
},
"columns": {
"type": "number",
"default": 2
},
"width": {
"type": "string"
}
},
"supports": {
"inserter": false
}
}

View File

@ -0,0 +1,19 @@
{
"name": "core/verse",
"category": "text",
"attributes": {
"content": {
"type": "string",
"source": "html",
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true
},
"textAlign": {
"type": "string"
}
},
"supports": {
"lightBlockWrapper": true
}
}

View File

@ -0,0 +1,68 @@
{
"name": "core/video",
"category": "media",
"attributes": {
"autoplay": {
"type": "boolean",
"source": "attribute",
"selector": "video",
"attribute": "autoplay"
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption"
},
"controls": {
"type": "boolean",
"source": "attribute",
"selector": "video",
"attribute": "controls",
"default": true
},
"id": {
"type": "number"
},
"loop": {
"type": "boolean",
"source": "attribute",
"selector": "video",
"attribute": "loop"
},
"muted": {
"type": "boolean",
"source": "attribute",
"selector": "video",
"attribute": "muted"
},
"poster": {
"type": "string",
"source": "attribute",
"selector": "video",
"attribute": "poster"
},
"preload": {
"type": "string",
"source": "attribute",
"selector": "video",
"attribute": "preload",
"default": "metadata"
},
"src": {
"type": "string",
"source": "attribute",
"selector": "video",
"attribute": "src"
},
"playsInline": {
"type": "boolean",
"source": "attribute",
"selector": "video",
"attribute": "playsinline"
}
},
"supports": {
"align": true,
"lightBlockWrapper": true
}
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48243';
$wp_version = '5.5-alpha-48262';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -285,17 +285,7 @@ require ABSPATH . WPINC . '/class-wp-block.php';
require ABSPATH . WPINC . '/class-wp-block-list.php';
require ABSPATH . WPINC . '/class-wp-block-parser.php';
require ABSPATH . WPINC . '/blocks.php';
require ABSPATH . WPINC . '/blocks/archives.php';
require ABSPATH . WPINC . '/blocks/block.php';
require ABSPATH . WPINC . '/blocks/calendar.php';
require ABSPATH . WPINC . '/blocks/categories.php';
require ABSPATH . WPINC . '/blocks/latest-comments.php';
require ABSPATH . WPINC . '/blocks/latest-posts.php';
require ABSPATH . WPINC . '/blocks/rss.php';
require ABSPATH . WPINC . '/blocks/search.php';
require ABSPATH . WPINC . '/blocks/shortcode.php';
require ABSPATH . WPINC . '/blocks/social-link.php';
require ABSPATH . WPINC . '/blocks/tag-cloud.php';
require ABSPATH . WPINC . '/blocks/index.php';
$GLOBALS['wp_embed'] = new WP_Embed();