From eafcf52d1884b9096e674fb3015cff017fad4d54 Mon Sep 17 00:00:00 2001 From: gziolo Date: Wed, 1 Jul 2020 12:29:03 +0000 Subject: [PATCH] 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 --- wp-includes/blocks/audio/block.json | 42 +++++++ wp-includes/blocks/button/block.json | 62 ++++++++++ wp-includes/blocks/buttons/block.json | 9 ++ wp-includes/blocks/classic/block.json | 15 +++ wp-includes/blocks/code/block.json | 15 +++ wp-includes/blocks/column/block.json | 22 ++++ wp-includes/blocks/columns/block.json | 21 ++++ wp-includes/blocks/file/block.json | 41 +++++++ wp-includes/blocks/gallery/block.json | 82 +++++++++++++ wp-includes/blocks/group/block.json | 23 ++++ wp-includes/blocks/heading/block.json | 41 +++++++ wp-includes/blocks/html/block.json | 15 +++ wp-includes/blocks/image/block.json | 76 ++++++++++++ wp-includes/blocks/index.php | 58 ++++++++++ wp-includes/blocks/list/block.json | 35 ++++++ wp-includes/blocks/media-text/block.json | 92 +++++++++++++++ wp-includes/blocks/missing/block.json | 23 ++++ wp-includes/blocks/more/block.json | 19 +++ wp-includes/blocks/nextpage/block.json | 10 ++ wp-includes/blocks/paragraph/block.json | 45 ++++++++ wp-includes/blocks/preformatted/block.json | 16 +++ wp-includes/blocks/pullquote/block.json | 38 ++++++ wp-includes/blocks/quote/block.json | 22 ++++ wp-includes/blocks/separator/block.json | 12 ++ wp-includes/blocks/social-links/block.json | 12 ++ wp-includes/blocks/spacer/block.json | 10 ++ wp-includes/blocks/subhead/block.json | 18 +++ wp-includes/blocks/table/block.json | 127 +++++++++++++++++++++ wp-includes/blocks/text-columns/block.json | 32 ++++++ wp-includes/blocks/verse/block.json | 19 +++ wp-includes/blocks/video/block.json | 68 +++++++++++ wp-includes/version.php | 2 +- wp-settings.php | 12 +- 33 files changed, 1122 insertions(+), 12 deletions(-) create mode 100644 wp-includes/blocks/audio/block.json create mode 100644 wp-includes/blocks/button/block.json create mode 100644 wp-includes/blocks/buttons/block.json create mode 100644 wp-includes/blocks/classic/block.json create mode 100644 wp-includes/blocks/code/block.json create mode 100644 wp-includes/blocks/column/block.json create mode 100644 wp-includes/blocks/columns/block.json create mode 100644 wp-includes/blocks/file/block.json create mode 100644 wp-includes/blocks/gallery/block.json create mode 100644 wp-includes/blocks/group/block.json create mode 100644 wp-includes/blocks/heading/block.json create mode 100644 wp-includes/blocks/html/block.json create mode 100644 wp-includes/blocks/image/block.json create mode 100644 wp-includes/blocks/index.php create mode 100644 wp-includes/blocks/list/block.json create mode 100644 wp-includes/blocks/media-text/block.json create mode 100644 wp-includes/blocks/missing/block.json create mode 100644 wp-includes/blocks/more/block.json create mode 100644 wp-includes/blocks/nextpage/block.json create mode 100644 wp-includes/blocks/paragraph/block.json create mode 100644 wp-includes/blocks/preformatted/block.json create mode 100644 wp-includes/blocks/pullquote/block.json create mode 100644 wp-includes/blocks/quote/block.json create mode 100644 wp-includes/blocks/separator/block.json create mode 100644 wp-includes/blocks/social-links/block.json create mode 100644 wp-includes/blocks/spacer/block.json create mode 100644 wp-includes/blocks/subhead/block.json create mode 100644 wp-includes/blocks/table/block.json create mode 100644 wp-includes/blocks/text-columns/block.json create mode 100644 wp-includes/blocks/verse/block.json create mode 100644 wp-includes/blocks/video/block.json diff --git a/wp-includes/blocks/audio/block.json b/wp-includes/blocks/audio/block.json new file mode 100644 index 0000000000..31c6c8f9ef --- /dev/null +++ b/wp-includes/blocks/audio/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/button/block.json b/wp-includes/blocks/button/block.json new file mode 100644 index 0000000000..b2af0f5a4c --- /dev/null +++ b/wp-includes/blocks/button/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/buttons/block.json b/wp-includes/blocks/buttons/block.json new file mode 100644 index 0000000000..4004a9591a --- /dev/null +++ b/wp-includes/blocks/buttons/block.json @@ -0,0 +1,9 @@ +{ + "name": "core/buttons", + "category": "design", + "supports": { + "align": true, + "alignWide": false, + "lightBlockWrapper": true + } +} diff --git a/wp-includes/blocks/classic/block.json b/wp-includes/blocks/classic/block.json new file mode 100644 index 0000000000..63d2c9f37e --- /dev/null +++ b/wp-includes/blocks/classic/block.json @@ -0,0 +1,15 @@ +{ + "name": "core/freeform", + "category": "text", + "attributes": { + "content": { + "type": "string", + "source": "html" + } + }, + "supports": { + "className": false, + "customClassName": false, + "reusable": false + } +} diff --git a/wp-includes/blocks/code/block.json b/wp-includes/blocks/code/block.json new file mode 100644 index 0000000000..d7cab6cf34 --- /dev/null +++ b/wp-includes/blocks/code/block.json @@ -0,0 +1,15 @@ +{ + "name": "core/code", + "category": "text", + "attributes": { + "content": { + "type": "string", + "source": "text", + "selector": "code" + } + }, + "supports": { + "html": false, + "lightBlockWrapper": true + } +} diff --git a/wp-includes/blocks/column/block.json b/wp-includes/blocks/column/block.json new file mode 100644 index 0000000000..328dbb6201 --- /dev/null +++ b/wp-includes/blocks/column/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/columns/block.json b/wp-includes/blocks/columns/block.json new file mode 100644 index 0000000000..352b1e5caa --- /dev/null +++ b/wp-includes/blocks/columns/block.json @@ -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 + } + } +} diff --git a/wp-includes/blocks/file/block.json b/wp-includes/blocks/file/block.json new file mode 100644 index 0000000000..664ec1154a --- /dev/null +++ b/wp-includes/blocks/file/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/gallery/block.json b/wp-includes/blocks/gallery/block.json new file mode 100644 index 0000000000..c16a21e734 --- /dev/null +++ b/wp-includes/blocks/gallery/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/group/block.json b/wp-includes/blocks/group/block.json new file mode 100644 index 0000000000..1e32b1443c --- /dev/null +++ b/wp-includes/blocks/group/block.json @@ -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 + } + } +} diff --git a/wp-includes/blocks/heading/block.json b/wp-includes/blocks/heading/block.json new file mode 100644 index 0000000000..fd03a4487e --- /dev/null +++ b/wp-includes/blocks/heading/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/html/block.json b/wp-includes/blocks/html/block.json new file mode 100644 index 0000000000..b9624b4b3e --- /dev/null +++ b/wp-includes/blocks/html/block.json @@ -0,0 +1,15 @@ +{ + "name": "core/html", + "category": "widgets", + "attributes": { + "content": { + "type": "string", + "source": "html" + } + }, + "supports": { + "customClassName": false, + "className": false, + "html": false + } +} diff --git a/wp-includes/blocks/image/block.json b/wp-includes/blocks/image/block.json new file mode 100644 index 0000000000..d403ec3827 --- /dev/null +++ b/wp-includes/blocks/image/block.json @@ -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 + } +} diff --git a/wp-includes/blocks/index.php b/wp-includes/blocks/index.php new file mode 100644 index 0000000000..53aaf2756a --- /dev/null +++ b/wp-includes/blocks/index.php @@ -0,0 +1,58 @@ +