From f28a371c5c427fac041f897e5f3fb7b2b6aff132 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Thu, 31 Aug 2023 11:37:48 +0200 Subject: [PATCH 1/3] Add editorScript/editorStyle references to all core block.json files --- .../block-library/src/archives/block.json | 3 ++- packages/block-library/src/audio/block.json | 5 +++-- packages/block-library/src/avatar/block.json | 5 +++-- packages/block-library/src/block/block.json | 8 ++++--- packages/block-library/src/button/block.json | 5 +++-- packages/block-library/src/buttons/block.json | 5 +++-- .../block-library/src/calendar/block.json | 4 +++- .../block-library/src/categories/block.json | 5 +++-- packages/block-library/src/code/block.json | 4 +++- packages/block-library/src/column/block.json | 3 ++- packages/block-library/src/columns/block.json | 5 +++-- .../src/comment-author-avatar/block.json | 4 +++- .../src/comment-author-name/block.json | 3 ++- .../src/comment-content/block.json | 5 ++++- .../block-library/src/comment-date/block.json | 3 ++- .../src/comment-edit-link/block.json | 3 ++- .../src/comment-reply-link/block.json | 3 ++- .../src/comment-template/block.json | 4 +++- .../src/comments-pagination-next/block.json | 3 ++- .../comments-pagination-numbers/block.json | 4 +++- .../comments-pagination-previous/block.json | 3 ++- .../src/comments-pagination/block.json | 5 +++-- .../src/comments-title/block.json | 4 +++- .../block-library/src/comments/block.json | 5 +++-- packages/block-library/src/cover/block.json | 5 +++-- packages/block-library/src/details/block.json | 5 +++-- packages/block-library/src/embed/block.json | 5 +++-- packages/block-library/src/file/block.json | 5 +++-- .../block-library/src/footnotes/block.json | 4 +++- .../block-library/src/freeform/block.json | 3 ++- packages/block-library/src/gallery/block.json | 5 +++-- packages/block-library/src/group/block.json | 5 +++-- packages/block-library/src/heading/block.json | 5 +++-- .../block-library/src/home-link/block.json | 3 +-- packages/block-library/src/html/block.json | 3 ++- packages/block-library/src/image/block.json | 5 +++-- .../src/latest-comments/block.json | 5 +++-- .../block-library/src/latest-posts/block.json | 5 +++-- .../block-library/src/list-item/block.json | 3 ++- packages/block-library/src/list/block.json | 5 +++-- .../block-library/src/loginout/block.json | 3 ++- .../block-library/src/media-text/block.json | 5 +++-- packages/block-library/src/missing/block.json | 3 ++- packages/block-library/src/more/block.json | 3 ++- .../src/navigation-link/block.json | 5 +++-- .../src/navigation-submenu/block.json | 4 ++-- .../block-library/src/navigation/block.json | 5 +++-- .../block-library/src/nextpage/block.json | 3 ++- .../src/page-list-item/block.json | 3 +-- .../block-library/src/page-list/block.json | 5 +++-- .../block-library/src/paragraph/block.json | 5 +++-- packages/block-library/src/pattern/block.json | 3 ++- .../src/post-author-biography/block.json | 3 ++- .../src/post-author-name/block.json | 3 ++- .../block-library/src/post-author/block.json | 3 ++- .../block-library/src/post-comment/block.json | 3 ++- .../src/post-comments-count/block.json | 3 ++- .../src/post-comments-form/block.json | 9 +++----- .../src/post-comments-link/block.json | 3 ++- .../block-library/src/post-content/block.json | 2 +- .../block-library/src/post-date/block.json | 4 +++- .../block-library/src/post-excerpt/block.json | 5 +++-- .../src/post-featured-image/block.json | 5 +++-- .../src/post-navigation-link/block.json | 3 ++- .../src/post-template/block.json | 5 +++-- .../block-library/src/post-terms/block.json | 3 ++- .../src/post-time-to-read/block.json | 4 +++- .../block-library/src/post-title/block.json | 3 ++- .../block-library/src/preformatted/block.json | 3 ++- .../block-library/src/pullquote/block.json | 5 +++-- .../src/query-no-results/block.json | 3 ++- .../src/query-pagination-next/block.json | 3 ++- .../src/query-pagination-numbers/block.json | 3 ++- .../src/query-pagination-previous/block.json | 3 ++- .../src/query-pagination/block.json | 5 +++-- .../block-library/src/query-title/block.json | 3 ++- packages/block-library/src/query/block.json | 4 ++-- packages/block-library/src/quote/block.json | 9 +++++--- .../block-library/src/read-more/block.json | 3 ++- packages/block-library/src/rss/block.json | 5 +++-- packages/block-library/src/search/block.json | 5 +++-- .../block-library/src/separator/block.json | 21 ++++++++++++++----- .../block-library/src/shortcode/block.json | 3 ++- .../block-library/src/site-logo/block.json | 10 ++++++--- .../block-library/src/site-tagline/block.json | 3 ++- .../block-library/src/site-title/block.json | 4 ++-- .../block-library/src/social-link/block.json | 3 ++- .../block-library/src/social-links/block.json | 21 ++++++++++++++----- packages/block-library/src/spacer/block.json | 5 +++-- .../src/table-of-contents/block.json | 3 ++- packages/block-library/src/table/block.json | 5 +++-- .../block-library/src/tag-cloud/block.json | 3 ++- .../src/template-part/block.json | 3 ++- .../src/term-description/block.json | 4 +++- .../block-library/src/text-columns/block.json | 5 +++-- packages/block-library/src/verse/block.json | 4 ++-- packages/block-library/src/video/block.json | 5 +++-- .../src/blocks/legacy-widget/block.json | 3 +-- .../src/blocks/widget-group/block.json | 1 - 99 files changed, 280 insertions(+), 160 deletions(-) diff --git a/packages/block-library/src/archives/block.json b/packages/block-library/src/archives/block.json index 7e0f5181d2c3dd..5e8d4c4ce992fe 100644 --- a/packages/block-library/src/archives/block.json +++ b/packages/block-library/src/archives/block.json @@ -49,5 +49,6 @@ } } }, - "editorStyle": "wp-block-archives-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/audio/block.json b/packages/block-library/src/audio/block.json index 04df268a74a630..901edf1fe03d5d 100644 --- a/packages/block-library/src/audio/block.json +++ b/packages/block-library/src/audio/block.json @@ -56,6 +56,7 @@ } } }, - "editorStyle": "wp-block-audio-editor", - "style": "wp-block-audio" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/avatar/block.json b/packages/block-library/src/avatar/block.json index fa86541b2963f2..1cf3b2deb5fc4d 100644 --- a/packages/block-library/src/avatar/block.json +++ b/packages/block-library/src/avatar/block.json @@ -55,6 +55,7 @@ "selectors": { "border": ".wp-block-avatar img" }, - "editorStyle": "wp-block-avatar-editor", - "style": "wp-block-avatar" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/block/block.json b/packages/block-library/src/block/block.json index aeccdbfc1051db..f6f5aee72a5026 100644 --- a/packages/block-library/src/block/block.json +++ b/packages/block-library/src/block/block.json @@ -15,7 +15,9 @@ "supports": { "customClassName": false, "html": false, - "inserter": false, - "renaming": false - } + "inserter": false, + "renaming": false +}, + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/button/block.json b/packages/block-library/src/button/block.json index 3c232700a876e6..c758617d474255 100644 --- a/packages/block-library/src/button/block.json +++ b/packages/block-library/src/button/block.json @@ -124,6 +124,7 @@ { "name": "fill", "label": "Fill", "isDefault": true }, { "name": "outline", "label": "Outline" } ], - "editorStyle": "wp-block-button-editor", - "style": "wp-block-button" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/buttons/block.json b/packages/block-library/src/buttons/block.json index 4dc420bd418855..8f47da58f2196c 100644 --- a/packages/block-library/src/buttons/block.json +++ b/packages/block-library/src/buttons/block.json @@ -40,6 +40,7 @@ } } }, - "editorStyle": "wp-block-buttons-editor", - "style": "wp-block-buttons" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/calendar/block.json b/packages/block-library/src/calendar/block.json index 974d47ff8ec2ca..4b7b1eb56aff46 100644 --- a/packages/block-library/src/calendar/block.json +++ b/packages/block-library/src/calendar/block.json @@ -39,5 +39,7 @@ } } }, - "style": "wp-block-calendar" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/categories/block.json b/packages/block-library/src/categories/block.json index 5014da82980493..4a93be19f82dc2 100644 --- a/packages/block-library/src/categories/block.json +++ b/packages/block-library/src/categories/block.json @@ -53,6 +53,7 @@ } } }, - "editorStyle": "wp-block-categories-editor", - "style": "wp-block-categories" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/code/block.json b/packages/block-library/src/code/block.json index bd5db3c918b963..5c9fda719d2410 100644 --- a/packages/block-library/src/code/block.json +++ b/packages/block-library/src/code/block.json @@ -58,5 +58,7 @@ } } }, - "style": "wp-block-code" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/column/block.json b/packages/block-library/src/column/block.json index 7f61f307fab159..ce1d1e3a55190f 100644 --- a/packages/block-library/src/column/block.json +++ b/packages/block-library/src/column/block.json @@ -69,5 +69,6 @@ } }, "layout": true - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/columns/block.json b/packages/block-library/src/columns/block.json index dff9c45ae2ddeb..7386411001a992 100644 --- a/packages/block-library/src/columns/block.json +++ b/packages/block-library/src/columns/block.json @@ -80,6 +80,7 @@ } } }, - "editorStyle": "wp-block-columns-editor", - "style": "wp-block-columns" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/comment-author-avatar/block.json b/packages/block-library/src/comment-author-avatar/block.json index 050d87c3b4634a..cb288b97d72a43 100644 --- a/packages/block-library/src/comment-author-avatar/block.json +++ b/packages/block-library/src/comment-author-avatar/block.json @@ -40,5 +40,7 @@ "margin": true, "padding": true } - } + }, + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/comment-author-name/block.json b/packages/block-library/src/comment-author-name/block.json index 93350779fc8bd2..e6e2b7379b43d8 100644 --- a/packages/block-library/src/comment-author-name/block.json +++ b/packages/block-library/src/comment-author-name/block.json @@ -49,5 +49,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/comment-content/block.json b/packages/block-library/src/comment-content/block.json index 9ac4b5453365bb..a42ac9f6468132 100644 --- a/packages/block-library/src/comment-content/block.json +++ b/packages/block-library/src/comment-content/block.json @@ -42,5 +42,8 @@ } }, "html": false - } + }, + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/comment-date/block.json b/packages/block-library/src/comment-date/block.json index 7e4776c68ff2fa..a16c74e0afeb02 100644 --- a/packages/block-library/src/comment-date/block.json +++ b/packages/block-library/src/comment-date/block.json @@ -45,5 +45,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/comment-edit-link/block.json b/packages/block-library/src/comment-edit-link/block.json index 505305f60987ac..844bc43b538116 100644 --- a/packages/block-library/src/comment-edit-link/block.json +++ b/packages/block-library/src/comment-edit-link/block.json @@ -45,5 +45,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/comment-reply-link/block.json b/packages/block-library/src/comment-reply-link/block.json index c10129412145c8..6accfffa4b70ae 100644 --- a/packages/block-library/src/comment-reply-link/block.json +++ b/packages/block-library/src/comment-reply-link/block.json @@ -41,5 +41,6 @@ } }, "html": false - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/comment-template/block.json b/packages/block-library/src/comment-template/block.json index 7b9bfc5e0340fd..59129c0efda74a 100644 --- a/packages/block-library/src/comment-template/block.json +++ b/packages/block-library/src/comment-template/block.json @@ -30,5 +30,7 @@ } } }, - "style": "wp-block-comment-template" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/comments-pagination-next/block.json b/packages/block-library/src/comments-pagination-next/block.json index d619865ebd6f5e..3328a2f55fc662 100644 --- a/packages/block-library/src/comments-pagination-next/block.json +++ b/packages/block-library/src/comments-pagination-next/block.json @@ -36,5 +36,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/comments-pagination-numbers/block.json b/packages/block-library/src/comments-pagination-numbers/block.json index fcebb52763870e..fe4d86e83e99dc 100644 --- a/packages/block-library/src/comments-pagination-numbers/block.json +++ b/packages/block-library/src/comments-pagination-numbers/block.json @@ -31,5 +31,7 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/comments-pagination-previous/block.json b/packages/block-library/src/comments-pagination-previous/block.json index 2dab1e9dd73674..da9e127b4cbb70 100644 --- a/packages/block-library/src/comments-pagination-previous/block.json +++ b/packages/block-library/src/comments-pagination-previous/block.json @@ -36,5 +36,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/comments-pagination/block.json b/packages/block-library/src/comments-pagination/block.json index a11decd201e94f..5f9043a7eb4503 100644 --- a/packages/block-library/src/comments-pagination/block.json +++ b/packages/block-library/src/comments-pagination/block.json @@ -50,6 +50,7 @@ } } }, - "editorStyle": "wp-block-comments-pagination-editor", - "style": "wp-block-comments-pagination" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/comments-title/block.json b/packages/block-library/src/comments-title/block.json index 4107f5d590cdee..796f9f96c4e07c 100644 --- a/packages/block-library/src/comments-title/block.json +++ b/packages/block-library/src/comments-title/block.json @@ -62,5 +62,7 @@ "__experimentalFontWeight": true } } - } + }, + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/comments/block.json b/packages/block-library/src/comments/block.json index b35ea3505c816f..3f6af4aef1156d 100644 --- a/packages/block-library/src/comments/block.json +++ b/packages/block-library/src/comments/block.json @@ -47,6 +47,7 @@ } } }, - "editorStyle": "wp-block-comments-editor", - "usesContext": [ "postId", "postType" ] + "usesContext": [ "postId", "postType" ], + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/cover/block.json b/packages/block-library/src/cover/block.json index d2c55dd26b4d74..78a1914f528ada 100644 --- a/packages/block-library/src/cover/block.json +++ b/packages/block-library/src/cover/block.json @@ -131,6 +131,7 @@ "allowJustification": false } }, - "editorStyle": "wp-block-cover-editor", - "style": "wp-block-cover" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/details/block.json b/packages/block-library/src/details/block.json index a71d3af2a5ed39..4d74f629a2da03 100644 --- a/packages/block-library/src/details/block.json +++ b/packages/block-library/src/details/block.json @@ -60,6 +60,7 @@ "allowEditing": false } }, - "editorStyle": "wp-block-details-editor", - "style": "wp-block-details" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/embed/block.json b/packages/block-library/src/embed/block.json index 5aac8bbd6b8cab..eb0c6b6e499bea 100644 --- a/packages/block-library/src/embed/block.json +++ b/packages/block-library/src/embed/block.json @@ -46,6 +46,7 @@ "margin": true } }, - "editorStyle": "wp-block-embed-editor", - "style": "wp-block-embed" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/file/block.json b/packages/block-library/src/file/block.json index 9dc6677e4adce3..f18c47f875c705 100644 --- a/packages/block-library/src/file/block.json +++ b/packages/block-library/src/file/block.json @@ -73,6 +73,7 @@ "interactivity": true }, "viewScript": "file:./view.min.js", - "editorStyle": "wp-block-file-editor", - "style": "wp-block-file" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:/style.css" } diff --git a/packages/block-library/src/footnotes/block.json b/packages/block-library/src/footnotes/block.json index 3192df77969781..018933d991313e 100644 --- a/packages/block-library/src/footnotes/block.json +++ b/packages/block-library/src/footnotes/block.json @@ -57,5 +57,7 @@ } } }, - "style": "wp-block-footnotes" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/freeform/block.json b/packages/block-library/src/freeform/block.json index d40e8ea13dc117..42257f88be075e 100644 --- a/packages/block-library/src/freeform/block.json +++ b/packages/block-library/src/freeform/block.json @@ -17,5 +17,6 @@ "customClassName": false, "reusable": false }, - "editorStyle": "wp-block-freeform-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/gallery/block.json b/packages/block-library/src/gallery/block.json index fad92aed59bf77..f2e14a116058f7 100644 --- a/packages/block-library/src/gallery/block.json +++ b/packages/block-library/src/gallery/block.json @@ -134,6 +134,7 @@ } } }, - "editorStyle": "wp-block-gallery-editor", - "style": "wp-block-gallery" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/group/block.json b/packages/block-library/src/group/block.json index 92bbc1b0d11352..9c4e73acce23d1 100644 --- a/packages/block-library/src/group/block.json +++ b/packages/block-library/src/group/block.json @@ -85,6 +85,7 @@ "allowSizingOnChildren": true } }, - "editorStyle": "wp-block-group-editor", - "style": "wp-block-group" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index 72cc67caddd9ea..bac67ab9489c8f 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -62,6 +62,7 @@ "__unstablePasteTextInline": true, "__experimentalSlashInserter": true }, - "editorStyle": "wp-block-heading-editor", - "style": "wp-block-heading" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/home-link/block.json b/packages/block-library/src/home-link/block.json index a9827b7718b9be..8eaa42c989fbb4 100644 --- a/packages/block-library/src/home-link/block.json +++ b/packages/block-library/src/home-link/block.json @@ -38,6 +38,5 @@ } } }, - "editorStyle": "wp-block-home-link-editor", - "style": "wp-block-home-link" + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/html/block.json b/packages/block-library/src/html/block.json index b1a2ad60625d12..4c4b010624ae0d 100644 --- a/packages/block-library/src/html/block.json +++ b/packages/block-library/src/html/block.json @@ -18,5 +18,6 @@ "className": false, "html": false }, - "editorStyle": "wp-block-html-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/image/block.json b/packages/block-library/src/image/block.json index c5191e3dd86543..806f1fb5341a84 100644 --- a/packages/block-library/src/image/block.json +++ b/packages/block-library/src/image/block.json @@ -128,7 +128,8 @@ }, { "name": "rounded", "label": "Rounded" } ], - "editorStyle": "wp-block-image-editor", - "style": "wp-block-image", + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css", "viewScript": "file:./view.min.js" } diff --git a/packages/block-library/src/latest-comments/block.json b/packages/block-library/src/latest-comments/block.json index 0b213e9b7903a4..23dc1038abd7e0 100644 --- a/packages/block-library/src/latest-comments/block.json +++ b/packages/block-library/src/latest-comments/block.json @@ -48,6 +48,7 @@ } } }, - "editorStyle": "wp-block-latest-comments-editor", - "style": "wp-block-latest-comments" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/latest-posts/block.json b/packages/block-library/src/latest-posts/block.json index f36164614dd506..83cae6049bb482 100644 --- a/packages/block-library/src/latest-posts/block.json +++ b/packages/block-library/src/latest-posts/block.json @@ -112,6 +112,7 @@ } } }, - "editorStyle": "wp-block-latest-posts-editor", - "style": "wp-block-latest-posts" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/list-item/block.json b/packages/block-library/src/list-item/block.json index 06997c2ac23f8e..ba7dbb5595f4b4 100644 --- a/packages/block-library/src/list-item/block.json +++ b/packages/block-library/src/list-item/block.json @@ -42,5 +42,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/list/block.json b/packages/block-library/src/list/block.json index e2fb9e4c9e3b0d..e3b2f055fe7193 100644 --- a/packages/block-library/src/list/block.json +++ b/packages/block-library/src/list/block.json @@ -72,6 +72,7 @@ "__experimentalOnMerge": true, "__experimentalSlashInserter": true }, - "editorStyle": "wp-block-list-editor", - "style": "wp-block-list" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/loginout/block.json b/packages/block-library/src/loginout/block.json index 59fceec596e37c..178ab12544ee3b 100644 --- a/packages/block-library/src/loginout/block.json +++ b/packages/block-library/src/loginout/block.json @@ -40,5 +40,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/media-text/block.json b/packages/block-library/src/media-text/block.json index cdeb4ce13e8f51..227417cd5723bc 100644 --- a/packages/block-library/src/media-text/block.json +++ b/packages/block-library/src/media-text/block.json @@ -125,6 +125,7 @@ } } }, - "editorStyle": "wp-block-media-text-editor", - "style": "wp-block-media-text" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/missing/block.json b/packages/block-library/src/missing/block.json index 242a1d2c6b21a8..0aef889ad0f336 100644 --- a/packages/block-library/src/missing/block.json +++ b/packages/block-library/src/missing/block.json @@ -24,5 +24,6 @@ "inserter": false, "html": false, "reusable": false - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/more/block.json b/packages/block-library/src/more/block.json index bfd95652ea1767..5e4c115da9bd90 100644 --- a/packages/block-library/src/more/block.json +++ b/packages/block-library/src/more/block.json @@ -22,5 +22,6 @@ "html": false, "multiple": false }, - "editorStyle": "wp-block-more-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/navigation-link/block.json b/packages/block-library/src/navigation-link/block.json index d8f2fe31aef9dd..352c4f8a21c973 100644 --- a/packages/block-library/src/navigation-link/block.json +++ b/packages/block-library/src/navigation-link/block.json @@ -74,6 +74,7 @@ }, "renaming": false }, - "editorStyle": "wp-block-navigation-link-editor", - "style": "wp-block-navigation-link" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/navigation-submenu/block.json b/packages/block-library/src/navigation-submenu/block.json index 91364109ea7400..17deaccf7220fe 100644 --- a/packages/block-library/src/navigation-submenu/block.json +++ b/packages/block-library/src/navigation-submenu/block.json @@ -60,6 +60,6 @@ "reusable": false, "html": false }, - "editorStyle": "wp-block-navigation-submenu-editor", - "style": "wp-block-navigation-submenu" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/navigation/block.json b/packages/block-library/src/navigation/block.json index 9ec919ae38d1fa..bfc9bbd3513987 100644 --- a/packages/block-library/src/navigation/block.json +++ b/packages/block-library/src/navigation/block.json @@ -137,6 +137,7 @@ "renaming": false }, "viewScript": "file:./view.min.js", - "editorStyle": "wp-block-navigation-editor", - "style": "wp-block-navigation" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/nextpage/block.json b/packages/block-library/src/nextpage/block.json index ab88d4a7be4f0b..bfd9a4ca516b08 100644 --- a/packages/block-library/src/nextpage/block.json +++ b/packages/block-library/src/nextpage/block.json @@ -13,5 +13,6 @@ "className": false, "html": false }, - "editorStyle": "wp-block-nextpage-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/page-list-item/block.json b/packages/block-library/src/page-list-item/block.json index abd86924949ab6..40ceb51e3bfb86 100644 --- a/packages/block-library/src/page-list-item/block.json +++ b/packages/block-library/src/page-list-item/block.json @@ -47,6 +47,5 @@ "inserter": false, "__experimentalToolbar": false }, - "editorStyle": "wp-block-page-list-editor", - "style": "wp-block-page-list" + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/page-list/block.json b/packages/block-library/src/page-list/block.json index 7f4f2ce86c425f..d58b2bf8a070a4 100644 --- a/packages/block-library/src/page-list/block.json +++ b/packages/block-library/src/page-list/block.json @@ -49,6 +49,7 @@ } } }, - "editorStyle": "wp-block-page-list-editor", - "style": "wp-block-page-list" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json index 3fe4fbb34e1029..7aeb77fe8e9cda 100644 --- a/packages/block-library/src/paragraph/block.json +++ b/packages/block-library/src/paragraph/block.json @@ -67,6 +67,7 @@ "__experimentalSelector": "p", "__unstablePasteTextInline": true }, - "editorStyle": "wp-block-paragraph-editor", - "style": "wp-block-paragraph" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/pattern/block.json b/packages/block-library/src/pattern/block.json index da02f7b72747e4..2770f99de1dfbf 100644 --- a/packages/block-library/src/pattern/block.json +++ b/packages/block-library/src/pattern/block.json @@ -15,5 +15,6 @@ "slug": { "type": "string" } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-author-biography/block.json b/packages/block-library/src/post-author-biography/block.json index 5d7a4d4585747d..6612f278f42a4b 100644 --- a/packages/block-library/src/post-author-biography/block.json +++ b/packages/block-library/src/post-author-biography/block.json @@ -38,5 +38,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-author-name/block.json b/packages/block-library/src/post-author-name/block.json index 89e4b38de2c281..a70ac2047bb09c 100644 --- a/packages/block-library/src/post-author-name/block.json +++ b/packages/block-library/src/post-author-name/block.json @@ -48,5 +48,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-author/block.json b/packages/block-library/src/post-author/block.json index 47dceef55604f6..6d75ca1f08371d 100644 --- a/packages/block-library/src/post-author/block.json +++ b/packages/block-library/src/post-author/block.json @@ -63,5 +63,6 @@ } } }, - "style": "wp-block-post-author" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-comment/block.json b/packages/block-library/src/post-comment/block.json index 85bdb7dd6cf327..9cae6b88750c83 100644 --- a/packages/block-library/src/post-comment/block.json +++ b/packages/block-library/src/post-comment/block.json @@ -18,5 +18,6 @@ "supports": { "html": false, "inserter": false - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-comments-count/block.json b/packages/block-library/src/post-comments-count/block.json index 43c1aaf713776f..ab78b460448488 100644 --- a/packages/block-library/src/post-comments-count/block.json +++ b/packages/block-library/src/post-comments-count/block.json @@ -39,5 +39,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-comments-form/block.json b/packages/block-library/src/post-comments-form/block.json index ff157beb5ced9c..ed04ce0cf4a41b 100644 --- a/packages/block-library/src/post-comments-form/block.json +++ b/packages/block-library/src/post-comments-form/block.json @@ -39,10 +39,7 @@ } } }, - "editorStyle": "wp-block-post-comments-form-editor", - "style": [ - "wp-block-post-comments-form", - "wp-block-buttons", - "wp-block-button" - ] + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": [ "file:./style.css", "wp-block-buttons", "wp-block-button" ] } diff --git a/packages/block-library/src/post-comments-link/block.json b/packages/block-library/src/post-comments-link/block.json index 74e268c3c20b19..7cbe667d1e64fe 100644 --- a/packages/block-library/src/post-comments-link/block.json +++ b/packages/block-library/src/post-comments-link/block.json @@ -40,5 +40,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-content/block.json b/packages/block-library/src/post-content/block.json index b0e0487a0b8249..c4b4fc5b896d85 100644 --- a/packages/block-library/src/post-content/block.json +++ b/packages/block-library/src/post-content/block.json @@ -39,5 +39,5 @@ } } }, - "editorStyle": "wp-block-post-content-editor" + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/post-date/block.json b/packages/block-library/src/post-date/block.json index 11ebc32d9cabec..1efddccc0baa64 100644 --- a/packages/block-library/src/post-date/block.json +++ b/packages/block-library/src/post-date/block.json @@ -51,5 +51,7 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-excerpt/block.json b/packages/block-library/src/post-excerpt/block.json index 33b7818ebed9f2..a38491c618d0a1 100644 --- a/packages/block-library/src/post-excerpt/block.json +++ b/packages/block-library/src/post-excerpt/block.json @@ -52,6 +52,7 @@ } } }, - "editorStyle": "wp-block-post-excerpt-editor", - "style": "wp-block-post-excerpt" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-featured-image/block.json b/packages/block-library/src/post-featured-image/block.json index 34e3bd6b2325fa..2b62692bd2c10d 100644 --- a/packages/block-library/src/post-featured-image/block.json +++ b/packages/block-library/src/post-featured-image/block.json @@ -79,6 +79,7 @@ "padding": true } }, - "editorStyle": "wp-block-post-featured-image-editor", - "style": "wp-block-post-featured-image" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-navigation-link/block.json b/packages/block-library/src/post-navigation-link/block.json index e1b6d4fa90a40c..fa7467108d0c1c 100644 --- a/packages/block-library/src/post-navigation-link/block.json +++ b/packages/block-library/src/post-navigation-link/block.json @@ -51,5 +51,6 @@ } } }, - "style": "wp-block-post-navigation-link" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-template/block.json b/packages/block-library/src/post-template/block.json index d2f7c09693121c..d08d6aebaaf294 100644 --- a/packages/block-library/src/post-template/block.json +++ b/packages/block-library/src/post-template/block.json @@ -50,6 +50,7 @@ } } }, - "style": "wp-block-post-template", - "editorStyle": "wp-block-post-template-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-terms/block.json b/packages/block-library/src/post-terms/block.json index 0da7fb02f8134f..f8a5108ae4857b 100644 --- a/packages/block-library/src/post-terms/block.json +++ b/packages/block-library/src/post-terms/block.json @@ -56,5 +56,6 @@ } } }, - "style": "wp-block-post-terms" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-time-to-read/block.json b/packages/block-library/src/post-time-to-read/block.json index 281e9bb1f1b210..396748e5a28fae 100644 --- a/packages/block-library/src/post-time-to-read/block.json +++ b/packages/block-library/src/post-time-to-read/block.json @@ -43,5 +43,7 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/post-title/block.json b/packages/block-library/src/post-title/block.json index 75a4fa3c3a60fa..37e8cd9a52568c 100644 --- a/packages/block-library/src/post-title/block.json +++ b/packages/block-library/src/post-title/block.json @@ -59,5 +59,6 @@ } } }, - "style": "wp-block-post-title" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/preformatted/block.json b/packages/block-library/src/preformatted/block.json index def870e7ad2fb7..b8ab601764f816 100644 --- a/packages/block-library/src/preformatted/block.json +++ b/packages/block-library/src/preformatted/block.json @@ -42,5 +42,6 @@ } } }, - "style": "wp-block-preformatted" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/pullquote/block.json b/packages/block-library/src/pullquote/block.json index 7fc81d5683bd19..92f0b8645a6e39 100644 --- a/packages/block-library/src/pullquote/block.json +++ b/packages/block-library/src/pullquote/block.json @@ -67,6 +67,7 @@ } } }, - "editorStyle": "wp-block-pullquote-editor", - "style": "wp-block-pullquote" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/query-no-results/block.json b/packages/block-library/src/query-no-results/block.json index 32088752bb0606..8656db22b4a909 100644 --- a/packages/block-library/src/query-no-results/block.json +++ b/packages/block-library/src/query-no-results/block.json @@ -29,5 +29,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/query-pagination-next/block.json b/packages/block-library/src/query-pagination-next/block.json index 95b1169dc992fd..de5c921abb6052 100644 --- a/packages/block-library/src/query-pagination-next/block.json +++ b/packages/block-library/src/query-pagination-next/block.json @@ -42,5 +42,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/query-pagination-numbers/block.json b/packages/block-library/src/query-pagination-numbers/block.json index f22d88115d68cd..caba49d73800c8 100644 --- a/packages/block-library/src/query-pagination-numbers/block.json +++ b/packages/block-library/src/query-pagination-numbers/block.json @@ -38,5 +38,6 @@ } } }, - "editorStyle": "wp-block-query-pagination-numbers-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/query-pagination-previous/block.json b/packages/block-library/src/query-pagination-previous/block.json index fbaac543c1da35..68a0912c2e49b5 100644 --- a/packages/block-library/src/query-pagination-previous/block.json +++ b/packages/block-library/src/query-pagination-previous/block.json @@ -42,5 +42,6 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/query-pagination/block.json b/packages/block-library/src/query-pagination/block.json index e32a9ba9b495ff..db55e141ab4d31 100644 --- a/packages/block-library/src/query-pagination/block.json +++ b/packages/block-library/src/query-pagination/block.json @@ -56,6 +56,7 @@ } } }, - "editorStyle": "wp-block-query-pagination-editor", - "style": "wp-block-query-pagination" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/query-title/block.json b/packages/block-library/src/query-title/block.json index 65eb03d310c12d..0f30f8b8342cea 100644 --- a/packages/block-library/src/query-title/block.json +++ b/packages/block-library/src/query-title/block.json @@ -54,5 +54,6 @@ } } }, - "style": "wp-block-query-title" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/query/block.json b/packages/block-library/src/query/block.json index d30eccf3765792..a81b6361b784f5 100644 --- a/packages/block-library/src/query/block.json +++ b/packages/block-library/src/query/block.json @@ -51,7 +51,7 @@ "html": false, "layout": true }, - "editorStyle": "wp-block-query-editor", - "style": "wp-block-query", + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", "viewScript": "file:./view.min.js" } diff --git a/packages/block-library/src/quote/block.json b/packages/block-library/src/quote/block.json index 9deca000efe06b..83abf63892df85 100644 --- a/packages/block-library/src/quote/block.json +++ b/packages/block-library/src/quote/block.json @@ -66,8 +66,11 @@ "label": "Default", "isDefault": true }, - { "name": "plain", "label": "Plain" } + { + "name": "plain", + "label": "Plain" + } ], - "editorStyle": "wp-block-quote-editor", - "style": "wp-block-quote" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/read-more/block.json b/packages/block-library/src/read-more/block.json index d3386a49d66b82..bf762a264be3de 100644 --- a/packages/block-library/src/read-more/block.json +++ b/packages/block-library/src/read-more/block.json @@ -52,5 +52,6 @@ } } }, - "style": "wp-block-read-more" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/rss/block.json b/packages/block-library/src/rss/block.json index 2535eda5946fbd..7aa549f54a2758 100644 --- a/packages/block-library/src/rss/block.json +++ b/packages/block-library/src/rss/block.json @@ -45,6 +45,7 @@ "align": true, "html": false }, - "editorStyle": "wp-block-rss-editor", - "style": "wp-block-rss" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/search/block.json b/packages/block-library/src/search/block.json index 5669a9089d0e03..a56ced7ca98185 100644 --- a/packages/block-library/src/search/block.json +++ b/packages/block-library/src/search/block.json @@ -92,6 +92,7 @@ "html": false }, "viewScript": "file:./view.min.js", - "editorStyle": "wp-block-search-editor", - "style": "wp-block-search" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/separator/block.json b/packages/block-library/src/separator/block.json index 970f6b5cbb5821..0e301c50ccc08e 100644 --- a/packages/block-library/src/separator/block.json +++ b/packages/block-library/src/separator/block.json @@ -31,10 +31,21 @@ } }, "styles": [ - { "name": "default", "label": "Default", "isDefault": true }, - { "name": "wide", "label": "Wide Line" }, - { "name": "dots", "label": "Dots" } + { + "name": "default", + "label": "Default", + "isDefault": true + }, + { + "name": "wide", + "label": "Wide Line" + }, + { + "name": "dots", + "label": "Dots" + } ], - "editorStyle": "wp-block-separator-editor", - "style": "wp-block-separator" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/shortcode/block.json b/packages/block-library/src/shortcode/block.json index 22d838a7198e1e..186e15ec0d6a19 100644 --- a/packages/block-library/src/shortcode/block.json +++ b/packages/block-library/src/shortcode/block.json @@ -17,5 +17,6 @@ "customClassName": false, "html": false }, - "editorStyle": "wp-block-shortcode-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/site-logo/block.json b/packages/block-library/src/site-logo/block.json index d1e3d1b20c3dad..68ef12956bce89 100644 --- a/packages/block-library/src/site-logo/block.json +++ b/packages/block-library/src/site-logo/block.json @@ -53,8 +53,12 @@ "label": "Default", "isDefault": true }, - { "name": "rounded", "label": "Rounded" } + { + "name": "rounded", + "label": "Rounded" + } ], - "editorStyle": "wp-block-site-logo-editor", - "style": "wp-block-site-logo" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/site-tagline/block.json b/packages/block-library/src/site-tagline/block.json index 22fb59aab5ead7..46cc79876b1b66 100644 --- a/packages/block-library/src/site-tagline/block.json +++ b/packages/block-library/src/site-tagline/block.json @@ -45,5 +45,6 @@ } } }, - "editorStyle": "wp-block-site-tagline-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/site-title/block.json b/packages/block-library/src/site-title/block.json index 4a2685e6941fc6..f8e07a92bd6b4d 100644 --- a/packages/block-library/src/site-title/block.json +++ b/packages/block-library/src/site-title/block.json @@ -60,6 +60,6 @@ } } }, - "editorStyle": "wp-block-site-title-editor", - "style": "wp-block-site-title" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/social-link/block.json b/packages/block-library/src/social-link/block.json index 50e95efedb630c..e1c76c2c311db8 100644 --- a/packages/block-library/src/social-link/block.json +++ b/packages/block-library/src/social-link/block.json @@ -33,5 +33,6 @@ "reusable": false, "html": false }, - "editorStyle": "wp-block-social-link-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/social-links/block.json b/packages/block-library/src/social-links/block.json index 20206511a4c96c..3dc3e8444e4c9c 100644 --- a/packages/block-library/src/social-links/block.json +++ b/packages/block-library/src/social-links/block.json @@ -80,10 +80,21 @@ } }, "styles": [ - { "name": "default", "label": "Default", "isDefault": true }, - { "name": "logos-only", "label": "Logos Only" }, - { "name": "pill-shape", "label": "Pill Shape" } + { + "name": "default", + "label": "Default", + "isDefault": true + }, + { + "name": "logos-only", + "label": "Logos Only" + }, + { + "name": "pill-shape", + "label": "Pill Shape" + } ], - "editorStyle": "wp-block-social-links-editor", - "style": "wp-block-social-links" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/spacer/block.json b/packages/block-library/src/spacer/block.json index a9da8d537f1b61..3fa552b181b202 100644 --- a/packages/block-library/src/spacer/block.json +++ b/packages/block-library/src/spacer/block.json @@ -25,6 +25,7 @@ } } }, - "editorStyle": "wp-block-spacer-editor", - "style": "wp-block-spacer" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/table-of-contents/block.json b/packages/block-library/src/table-of-contents/block.json index 5fa7e37e6acbdf..db1db3a47bdcbe 100644 --- a/packages/block-library/src/table-of-contents/block.json +++ b/packages/block-library/src/table-of-contents/block.json @@ -47,5 +47,6 @@ } } }, - "example": {} + "example": {}, + "editorScript": "file:./editor.min.js" } diff --git a/packages/block-library/src/table/block.json b/packages/block-library/src/table/block.json index 470886a1247fe1..eb16dc9afd99ce 100644 --- a/packages/block-library/src/table/block.json +++ b/packages/block-library/src/table/block.json @@ -205,6 +205,7 @@ }, { "name": "stripes", "label": "Stripes" } ], - "editorStyle": "wp-block-table-editor", - "style": "wp-block-table" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/tag-cloud/block.json b/packages/block-library/src/tag-cloud/block.json index 9481dc945666ad..1f62518635ebac 100644 --- a/packages/block-library/src/tag-cloud/block.json +++ b/packages/block-library/src/tag-cloud/block.json @@ -50,5 +50,6 @@ "__experimentalLetterSpacing": true } }, - "editorStyle": "wp-block-tag-cloud-editor" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/template-part/block.json b/packages/block-library/src/template-part/block.json index 3b0946718bcb9c..2cd4c04a7a88f0 100644 --- a/packages/block-library/src/template-part/block.json +++ b/packages/block-library/src/template-part/block.json @@ -26,5 +26,6 @@ "reusable": false, "renaming": false }, - "editorStyle": "wp-block-template-part-editor" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css" } diff --git a/packages/block-library/src/term-description/block.json b/packages/block-library/src/term-description/block.json index fc91a4aff4c484..47399627742174 100644 --- a/packages/block-library/src/term-description/block.json +++ b/packages/block-library/src/term-description/block.json @@ -38,5 +38,7 @@ "fontSize": true } } - } + }, + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/text-columns/block.json b/packages/block-library/src/text-columns/block.json index 3af169fadbb3bd..0cd8a1963bfc21 100644 --- a/packages/block-library/src/text-columns/block.json +++ b/packages/block-library/src/text-columns/block.json @@ -31,6 +31,7 @@ "supports": { "inserter": false }, - "editorStyle": "wp-block-text-columns-editor", - "style": "wp-block-text-columns" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/block-library/src/verse/block.json b/packages/block-library/src/verse/block.json index 846a1dc99caafc..f9cff98235e285 100644 --- a/packages/block-library/src/verse/block.json +++ b/packages/block-library/src/verse/block.json @@ -57,6 +57,6 @@ "style": true } }, - "style": "wp-block-verse", - "editorStyle": "wp-block-verse-editor" + "editorScript": "file:./editor.min.js", + "style": "file:./style.css" } diff --git a/packages/block-library/src/video/block.json b/packages/block-library/src/video/block.json index 5d4680f39e79a8..adfd1321bdd9a2 100644 --- a/packages/block-library/src/video/block.json +++ b/packages/block-library/src/video/block.json @@ -90,6 +90,7 @@ } } }, - "editorStyle": "wp-block-video-editor", - "style": "wp-block-video" + "editorScript": "file:./editor.min.js", + "editorStyle": "file:./editor.css", + "style": "file:./style.css" } diff --git a/packages/widgets/src/blocks/legacy-widget/block.json b/packages/widgets/src/blocks/legacy-widget/block.json index 6b0c1e2a916fdd..2bd2751703c5c9 100644 --- a/packages/widgets/src/blocks/legacy-widget/block.json +++ b/packages/widgets/src/blocks/legacy-widget/block.json @@ -23,6 +23,5 @@ "html": false, "customClassName": false, "reusable": false - }, - "editorStyle": "wp-block-legacy-widget-editor" + } } diff --git a/packages/widgets/src/blocks/widget-group/block.json b/packages/widgets/src/blocks/widget-group/block.json index c29e811554ac11..73fbcded608d26 100644 --- a/packages/widgets/src/blocks/widget-group/block.json +++ b/packages/widgets/src/blocks/widget-group/block.json @@ -13,6 +13,5 @@ "customClassName": true, "reusable": false }, - "editorStyle": "wp-block-widget-group-editor", "style": "wp-block-widget-group" } From 78c32cfa83c56ddb866774a441fd5b33e46def26 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Fri, 15 Dec 2023 12:19:02 +0100 Subject: [PATCH 2/3] Build blocks as separate entrypoints --- tools/webpack/blocks.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/webpack/blocks.js b/tools/webpack/blocks.js index d599980b951a93..d72acbc4e78e36 100644 --- a/tools/webpack/blocks.js +++ b/tools/webpack/blocks.js @@ -75,6 +75,25 @@ const createEntrypoints = () => { }, {} ); }; +const createEditorEntrypoints = () => { + const blockInitScriptPaths = fastGlob.sync( + './packages/block-library/build-module/**/init.js' + ); + + const entrypoints = {}; + for ( const scriptPath of blockInitScriptPaths ) { + const result = scriptPath.match( + /build-module\/(?.*)\/init\.js$/ + ); + if ( ! result ) { + continue; + } + entrypoints[ result.groups.filename + '/editor' ] = scriptPath; + } + + return entrypoints; +}; + module.exports = [ { ...baseConfig, @@ -220,4 +239,17 @@ module.exports = [ } ), ].filter( Boolean ), }, + { + ...baseConfig, + name: 'editor', + entry: createEditorEntrypoints(), + output: { + devtoolNamespace: 'wp', + filename: './build/block-library/blocks/[name].min.js', + path: join( __dirname, '..', '..' ), + }, + plugins: [ ...plugins, new DependencyExtractionWebpackPlugin() ].filter( + Boolean + ), + }, ]; From e1d88a5e24a6de5a792b3f35e46236d389083dc4 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Fri, 15 Dec 2023 12:29:51 +0100 Subject: [PATCH 3/3] Async block loading --- .../data/data-core-block-editor.md | 4 + .../reference-guides/data/data-core-blocks.md | 8 ++ lib/blocks.php | 7 + lib/init.php | 52 +++++++ .../block-editor/src/autocompleters/block.js | 5 +- .../src/components/block-actions/index.js | 7 +- .../src/components/block-list/block.js | 4 +- .../src/components/block-list/block.native.js | 4 +- .../block-styles/use-styles-for-block.js | 13 +- .../block-transformations-menu.js | 26 +++- .../block-transformations-menu.native.js | 4 +- .../src/components/block-switcher/index.js | 110 +++++++------- .../convert-to-group-buttons/index.js | 4 +- .../convert-to-group-buttons/toolbar.js | 14 +- .../components/inserter-list-item/index.js | 33 +++-- .../inserter/hooks/use-block-types-state.js | 17 ++- .../src/components/inserter/menu.js | 8 +- .../src/components/inserter/quick-inserter.js | 2 +- .../src/components/media-placeholder/index.js | 2 +- .../src/components/rich-text/index.native.js | 31 ++-- .../src/components/rich-text/use-enter.js | 8 +- .../components/rich-text/use-input-rules.js | 18 ++- .../components/rich-text/use-paste-handler.js | 6 +- .../src/components/use-on-block-drop/index.js | 8 +- .../writing-flow/use-clipboard-handler.js | 6 +- packages/block-editor/src/store/actions.js | 13 +- packages/block-editor/src/store/index.js | 2 + packages/block-editor/src/store/reducer.js | 12 ++ packages/block-editor/src/store/resolvers.js | 69 +++++++++ packages/block-editor/src/store/selectors.js | 109 ++++++-------- packages/block-library/src/image/image.js | 4 +- packages/block-library/src/list-item/edit.js | 4 +- .../src/list-item/edit.native.js | 6 +- packages/block-library/src/list-item/utils.js | 12 +- .../src/navigation-link/link-ui.js | 4 +- packages/block-library/src/page-list/edit.js | 60 ++++---- .../template-part/edit/utils/transformers.js | 36 ++--- packages/blocks/README.md | 12 ++ packages/blocks/src/api/factory.js | 136 ++++++++++-------- packages/blocks/src/api/index.js | 3 + packages/blocks/src/api/parser/index.js | 30 ++-- .../api/raw-handling/get-raw-transforms.js | 5 +- packages/blocks/src/api/raw-handling/index.js | 4 +- .../src/api/raw-handling/paste-handler.js | 6 +- .../api/raw-handling/shortcode-converter.js | 14 +- packages/blocks/src/api/registration.js | 34 +++-- packages/blocks/src/api/utils.js | 44 +++--- packages/blocks/src/store/index.js | 2 + .../blocks/src/store/private-selectors.js | 12 -- packages/blocks/src/store/resolvers.js | 46 ++++++ packages/blocks/src/store/selectors.js | 17 ++- .../components/src/autocomplete/index.tsx | 7 +- packages/core-data/src/entity-provider.js | 32 +++-- .../src/editor/transform-block-to.ts | 7 +- .../editor/various/inserting-blocks.test.js | 3 + .../components/start-page-options/index.js | 37 +++-- packages/edit-post/src/editor.js | 4 +- packages/edit-post/src/index.js | 26 ++-- .../src/components/style-book/index.js | 4 +- packages/edit-site/src/store/actions.js | 2 +- .../local-autosave-monitor/index.js | 4 +- test/performance/fixtures/perf-utils.ts | 4 +- 62 files changed, 744 insertions(+), 483 deletions(-) create mode 100644 packages/block-editor/src/store/resolvers.js create mode 100644 packages/blocks/src/store/resolvers.js diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md index 38a93552bcbef2..a0acea3ced6831 100644 --- a/docs/reference-guides/data/data-core-block-editor.md +++ b/docs/reference-guides/data/data-core-block-editor.md @@ -846,6 +846,10 @@ _Returns_ - `string|false`: Block Template Lock +### getUnsyncedPatterns + +Undocumented declaration. + ### hasBlockMovingClientId Returns whether block moving mode is enabled. diff --git a/docs/reference-guides/data/data-core-blocks.md b/docs/reference-guides/data/data-core-blocks.md index 084c9c1d7a5fbc..0c3c95beb1f1ba 100644 --- a/docs/reference-guides/data/data-core-blocks.md +++ b/docs/reference-guides/data/data-core-blocks.md @@ -246,6 +246,14 @@ _Returns_ - `(WPBlockVariation[]|void)`: Block variations. +### getBootstrappedBlockType + +Undocumented declaration. + +### getBootstrappedBlockTypes + +Undocumented declaration. + ### getCategories Returns all the available block categories. diff --git a/lib/blocks.php b/lib/blocks.php index 698b5d6873748f..fc20c98d37f6e0 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -227,6 +227,13 @@ function gutenberg_deregister_core_block_and_assets( $block_name ) { } } } + if ( ! empty( $block_type->editor_script_handles ) ) { + foreach ( $block_type->editor_script_handles as $editor_script_handle ) { + if ( str_starts_with( $editor_script_handle, 'wp-block-' ) ) { + wp_deregister_script( $editor_script_handle ); + } + } + } $registry->unregister( $block_name ); } } diff --git a/lib/init.php b/lib/init.php index 71b6a276c60f33..3fa7fdbaece97c 100644 --- a/lib/init.php +++ b/lib/init.php @@ -57,3 +57,55 @@ function gutenberg_menu() { ); } add_action( 'admin_menu', 'gutenberg_menu', 9 ); + +// disable loading and enqueuing block editor scripts and styles +add_filter( 'should_load_block_editor_scripts_and_styles', '__return_false', 11 ); + +function get_block_importmap() { + $block_registry = WP_Block_Type_Registry::get_instance(); + $scripts = wp_scripts(); + $styles = wp_styles(); + $blocks = array(); + + foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { + $imports = array(); + if ( isset( $block_type->editor_script_handles ) ) { + foreach ( $block_type->editor_script_handles as $handle ) { + $spec = $scripts->registered[ $handle ]; + $imports[] = array( + 'type' => 'script', + 'handle' => $spec->handle, + 'src' => $spec->src, + 'ver' => $spec->ver + ); + } + } + if ( isset( $block_type->editor_style_handles ) ) { + foreach ( $block_type->editor_style_handles as $handle ) { + if ( ! isset( $styles->registered[ $handle ] ) ) { + continue; + } + $spec = $styles->registered[ $handle ]; + $imports[] = array( + 'type' => 'style', + 'handle' => $spec->handle, + 'src' => $spec->src, + 'ver' => $spec->ver + ); + } + } + if ( ! empty( $imports ) ) { + $blocks[ $block_name ] = $imports; + } + } + + return $blocks; +} + +function emit_importmap() { + wp_register_script( 'wp-importmap', ''); + wp_add_inline_script( 'wp-importmap', 'wp.importmap = ' . wp_json_encode( get_block_importmap() ) . ';' ); + wp_enqueue_script('wp-importmap'); +} + +add_action( 'enqueue_block_editor_assets', 'emit_importmap' ); \ No newline at end of file diff --git a/packages/block-editor/src/autocompleters/block.js b/packages/block-editor/src/autocompleters/block.js index bc06c9de5aaaff..e3539d7ba2e763 100644 --- a/packages/block-editor/src/autocompleters/block.js +++ b/packages/block-editor/src/autocompleters/block.js @@ -116,7 +116,7 @@ function createBlockCompleter() { allowContext( before, after ) { return ! ( /\S/.test( before ) || /\S/.test( after ) ); }, - getOptionCompletion( inserterItem ) { + async getOptionCompletion( inserterItem ) { const { name, initialAttributes, @@ -124,12 +124,11 @@ function createBlockCompleter() { syncStatus, content, } = inserterItem; - return { action: 'replace', value: syncStatus === 'unsynced' - ? parse( content, { + ? await parse( content, { __unstableSkipMigrationLogs: true, } ) : createBlock( diff --git a/packages/block-editor/src/components/block-actions/index.js b/packages/block-editor/src/components/block-actions/index.js index 5d942d2b25c708..2f82cda2086198 100644 --- a/packages/block-editor/src/components/block-actions/index.js +++ b/packages/block-editor/src/components/block-actions/index.js @@ -103,7 +103,7 @@ export default function BlockActions( { selectBlock( clientIds[ 0 ] ); setBlockMovingClientId( clientIds[ 0 ] ); }, - onGroup() { + async onGroup() { if ( ! blocks.length ) { return; } @@ -111,7 +111,10 @@ export default function BlockActions( { const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion. - const newBlocks = switchToBlockType( blocks, groupingBlockName ); + const newBlocks = await switchToBlockType( + blocks, + groupingBlockName + ); if ( ! newBlocks ) { return; diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js index c053235c2d0d36..de89fd6cd8cf5b 100644 --- a/packages/block-editor/src/components/block-list/block.js +++ b/packages/block-editor/src/components/block-list/block.js @@ -307,7 +307,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => { ) { removeBlock( _clientId ); } else { - registry.batch( () => { + registry.batch( async () => { if ( canInsertBlockType( getBlockName( firstClientId ), @@ -321,7 +321,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => { getBlockIndex( _clientId ) ); } else { - const replacement = switchToBlockType( + const replacement = await switchToBlockType( getBlock( firstClientId ), getDefaultBlockName() ); diff --git a/packages/block-editor/src/components/block-list/block.native.js b/packages/block-editor/src/components/block-list/block.native.js index 027ed12a7483ae..5adb68d7c17647 100644 --- a/packages/block-editor/src/components/block-list/block.native.js +++ b/packages/block-editor/src/components/block-list/block.native.js @@ -500,7 +500,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => { ) { removeBlock( _clientId ); } else { - registry.batch( () => { + registry.batch( async () => { if ( canInsertBlockType( getBlockName( firstClientId ), @@ -514,7 +514,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => { getBlockIndex( _clientId ) ); } else { - const replacement = switchToBlockType( + const replacement = await switchToBlockType( getBlock( firstClientId ), getDefaultBlockName() ); diff --git a/packages/block-editor/src/components/block-styles/use-styles-for-block.js b/packages/block-editor/src/components/block-styles/use-styles-for-block.js index 6d73dca557b058..d89557be058643 100644 --- a/packages/block-editor/src/components/block-styles/use-styles-for-block.js +++ b/packages/block-editor/src/components/block-styles/use-styles-for-block.js @@ -24,20 +24,13 @@ import { store as blockEditorStore } from '../../store'; */ function useGenericPreviewBlock( block, type ) { return useMemo( () => { - const example = type?.example; - const blockName = type?.name; - - if ( example && blockName ) { - return getBlockFromExample( blockName, { - attributes: example.attributes, - innerBlocks: example.innerBlocks, - } ); + if ( type && type.blockName && type.example ) { + return getBlockFromExample( type.blockName, type.example ); } - if ( block ) { return cloneBlock( block ); } - }, [ type?.example ? block?.name : block, type ] ); + }, [ type, type?.example ? block?.name : block ] ); } /** diff --git a/packages/block-editor/src/components/block-switcher/block-transformations-menu.js b/packages/block-editor/src/components/block-switcher/block-transformations-menu.js index 033201d7facadb..f89b1605391bc7 100644 --- a/packages/block-editor/src/components/block-switcher/block-transformations-menu.js +++ b/packages/block-editor/src/components/block-switcher/block-transformations-menu.js @@ -7,7 +7,7 @@ import { getBlockMenuDefaultClassName, switchToBlockType, } from '@wordpress/blocks'; -import { useState, useMemo } from '@wordpress/element'; +import { useEffect, useState, useMemo } from '@wordpress/element'; /** * Internal dependencies @@ -63,6 +63,21 @@ function useGroupedTransforms( possibleBlockTransformations ) { return transformations; } +function Preview( { blocks, transformName } ) { + const [ switched, setSwitched ] = useState( null ); + useEffect( () => { + switchToBlockType( blocks, transformName ).then( ( result ) => + setSwitched( result ) + ); + }, [ blocks, transformName ] ); + + if ( ! switched ) { + return null; + } + + return ; +} + const BlockTransformationsMenu = ( { className, possibleBlockTransformations, @@ -91,11 +106,10 @@ const BlockTransformationsMenu = ( { <> { hoveredTransformItemName && ( - ) } { !! possibleBlockVariationTransformations?.length && ( diff --git a/packages/block-editor/src/components/block-switcher/block-transformations-menu.native.js b/packages/block-editor/src/components/block-switcher/block-transformations-menu.native.js index 33952378f601f5..a9ae04bcf90b34 100644 --- a/packages/block-editor/src/components/block-switcher/block-transformations-menu.native.js +++ b/packages/block-editor/src/components/block-switcher/block-transformations-menu.native.js @@ -55,10 +55,10 @@ const BlockTransformationsMenu = ( { const getAnchor = () => anchorNodeRef ? findNodeHandle( anchorNodeRef ) : undefined; - function onPickerSelect( value ) { + async function onPickerSelect( value ) { replaceBlocks( selectedBlockClientId, - switchToBlockType( selectedBlock, value ) + await switchToBlockType( selectedBlock, value ) ); const selectedItem = pickerOptions().find( diff --git a/packages/block-editor/src/components/block-switcher/index.js b/packages/block-editor/src/components/block-switcher/index.js index 8117c6f539b4f3..eb58a1dc1e1d92 100644 --- a/packages/block-editor/src/components/block-switcher/index.js +++ b/packages/block-editor/src/components/block-switcher/index.js @@ -13,9 +13,11 @@ import { store as blocksStore, isReusableBlock, isTemplatePart, + getTransformItemsForBlocks, } from '@wordpress/blocks'; import { useSelect, useDispatch } from '@wordpress/data'; import { copy } from '@wordpress/icons'; +import { useState, useEffect } from '@wordpress/element'; /** * Internal dependencies @@ -33,56 +35,58 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => { const { replaceBlocks, multiSelect, updateBlockAttributes } = useDispatch( blockEditorStore ); const blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId ); - const { - possibleBlockTransformations, - canRemove, - hasBlockStyles, - icon, - patterns, - } = useSelect( - ( select ) => { - const { - getBlockRootClientId, - getBlockTransformItems, - __experimentalGetPatternTransformItems, - canRemoveBlocks, - } = select( blockEditorStore ); - const { getBlockStyles, getBlockType } = select( blocksStore ); - const rootClientId = getBlockRootClientId( - Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds - ); - const [ { name: firstBlockName } ] = blocks; - const _isSingleBlockSelected = blocks.length === 1; - const styles = - _isSingleBlockSelected && getBlockStyles( firstBlockName ); - let _icon; - if ( _isSingleBlockSelected ) { - _icon = blockInformation?.icon; // Take into account active block variations. - } else { - const isSelectionOfSameType = - new Set( blocks.map( ( { name } ) => name ) ).size === 1; - // When selection consists of blocks of multiple types, display an - // appropriate icon to communicate the non-uniformity. - _icon = isSelectionOfSameType - ? getBlockType( firstBlockName )?.icon - : copy; - } - return { - possibleBlockTransformations: getBlockTransformItems( - blocks, - rootClientId - ), - canRemove: canRemoveBlocks( clientIds, rootClientId ), - hasBlockStyles: !! styles?.length, - icon: _icon, - patterns: __experimentalGetPatternTransformItems( - blocks, - rootClientId - ), - }; - }, - [ clientIds, blocks, blockInformation?.icon ] - ); + const { blockTransformations, canRemove, hasBlockStyles, icon, patterns } = + useSelect( + ( select ) => { + const { + getBlockRootClientId, + getBlockTransformItems, + __experimentalGetPatternTransformItems, + canRemoveBlocks, + } = select( blockEditorStore ); + const { getBlockStyles, getBlockType } = select( blocksStore ); + const rootClientId = getBlockRootClientId( + Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds + ); + const [ { name: firstBlockName } ] = blocks; + const _isSingleBlockSelected = blocks.length === 1; + const styles = + _isSingleBlockSelected && getBlockStyles( firstBlockName ); + let _icon; + if ( _isSingleBlockSelected ) { + _icon = blockInformation?.icon; // Take into account active block variations. + } else { + const isSelectionOfSameType = + new Set( blocks.map( ( { name } ) => name ) ).size === + 1; + // When selection consists of blocks of multiple types, display an + // appropriate icon to communicate the non-uniformity. + _icon = isSelectionOfSameType + ? getBlockType( firstBlockName )?.icon + : copy; + } + return { + blockTransformations: + getBlockTransformItems( rootClientId ), + canRemove: canRemoveBlocks( clientIds, rootClientId ), + hasBlockStyles: !! styles?.length, + icon: _icon, + patterns: __experimentalGetPatternTransformItems( + blocks, + rootClientId + ), + }; + }, + [ clientIds, blocks, blockInformation?.icon ] + ); + + const [ possibleBlockTransformations, setPossibleBlockTransformations ] = + useState( null ); + useEffect( () => { + getTransformItemsForBlocks( blockTransformations, blocks ).then( + ( result ) => setPossibleBlockTransformations( result ) + ); + }, [ blockTransformations, blocks ] ); const blockVariationTransformations = useBlockVariationTransforms( { clientIds, @@ -108,8 +112,8 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => { } // Simple block tranformation based on the `Block Transforms` API. - function onBlockTransform( name ) { - const newBlocks = switchToBlockType( blocks, name ); + async function onBlockTransform( name ) { + const newBlocks = await switchToBlockType( blocks, name ); replaceBlocks( clientIds, newBlocks ); selectForMultipleBlocks( newBlocks ); } @@ -134,7 +138,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => { * by allowing to exclude blocks from wildcard transformations. */ const hasPossibleBlockTransformations = - !! possibleBlockTransformations.length && canRemove && ! isTemplate; + possibleBlockTransformations?.length && canRemove && ! isTemplate; const hasPossibleBlockVariationTransformations = !! blockVariationTransformations?.length; const hasPatternTransformation = !! patterns?.length && canRemove; diff --git a/packages/block-editor/src/components/convert-to-group-buttons/index.js b/packages/block-editor/src/components/convert-to-group-buttons/index.js index c2bb3fb25b8452..1053f76ba7efe5 100644 --- a/packages/block-editor/src/components/convert-to-group-buttons/index.js +++ b/packages/block-editor/src/components/convert-to-group-buttons/index.js @@ -23,9 +23,9 @@ function ConvertToGroupButton( { onClose = () => {}, } ) { const { replaceBlocks } = useDispatch( blockEditorStore ); - const onConvertToGroup = () => { + const onConvertToGroup = async () => { // Activate the `transform` on the Grouping Block which does the conversion. - const newBlocks = switchToBlockType( + const newBlocks = await switchToBlockType( blocksSelection, groupingBlockName ); diff --git a/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js b/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js index 38405fe3ee6abb..cde6fe11daec9d 100644 --- a/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js +++ b/packages/block-editor/src/components/convert-to-group-buttons/toolbar.js @@ -40,16 +40,12 @@ function BlockGroupToolbar() { [ clientIds, groupingBlockName ] ); - const onConvertToGroup = ( layout ) => { - const newBlocks = switchToBlockType( + const onConvertToGroup = async ( layout ) => { + const newBlocks = await switchToBlockType( blocksSelection, groupingBlockName ); - if ( typeof layout !== 'string' ) { - layout = 'group'; - } - if ( newBlocks && newBlocks.length > 0 ) { // Because the block is not in the store yet we can't use // updateBlockAttributes so need to manually update attributes. @@ -69,10 +65,10 @@ function BlockGroupToolbar() { return null; } - const canInsertRow = !! variations.find( + const canInsertRow = variations?.some( ( { name } ) => name === 'group-row' ); - const canInsertStack = !! variations.find( + const canInsertStack = variations?.some( ( { name } ) => name === 'group-stack' ); @@ -81,7 +77,7 @@ function BlockGroupToolbar() { onConvertToGroup( 'group' ) } /> { canInsertRow && ( ( { + item: select( blocksStore ).getBlockType( name ), + } ), + [ name ] + ); + + const itemIconStyle = item?.icon ? { backgroundColor: item.icon.background, color: item.icon.foreground, } : {}; - const blocks = useMemo( - () => [ + + const blocks = useMemo( () => { + if ( ! item ) { + return []; + } + return [ createBlock( item.name, item.initialAttributes, createBlocksFromInnerBlocksTemplate( item.innerBlocks ) ), - ], - [ item.name, item.initialAttributes, item.innerBlocks ] - ); + ]; + }, [ item ] ); + + if ( ! item ) { + return null; + } const isSynced = ( isReusableBlock( item ) && item.syncStatus !== 'unsynced' ) || @@ -89,7 +106,7 @@ function InserterListItem( { 'block-editor-block-types-list__item', className ) } - disabled={ item.isDisabled } + disabled={ isDisabled } onClick={ ( event ) => { event.preventDefault(); onSelect( diff --git a/packages/block-editor/src/components/inserter/hooks/use-block-types-state.js b/packages/block-editor/src/components/inserter/hooks/use-block-types-state.js index 566d0476fbd0f5..914a76276725da 100644 --- a/packages/block-editor/src/components/inserter/hooks/use-block-types-state.js +++ b/packages/block-editor/src/components/inserter/hooks/use-block-types-state.js @@ -36,19 +36,18 @@ const useBlockTypesState = ( rootClientId, onInsert ) => { }, [] ); const onSelectItem = useCallback( - ( - { name, initialAttributes, innerBlocks, syncStatus, content }, - shouldFocusBlock - ) => { + async ( item, shouldFocusBlock ) => { const insertedBlock = - syncStatus === 'unsynced' - ? parse( content, { + item.syncStatus === 'unsynced' + ? await parse( item.content, { __unstableSkipMigrationLogs: true, } ) : createBlock( - name, - initialAttributes, - createBlocksFromInnerBlocksTemplate( innerBlocks ) + item.name, + item.initialAttributes, + createBlocksFromInnerBlocksTemplate( + item.innerBlocks + ) ); onInsert( insertedBlock, undefined, shouldFocusBlock ); diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index 24c099869ae0d6..6123fdc8866fcb 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -199,6 +199,8 @@ function InserterMenu( }, } ) ); + const readyToShow = showPatterns !== null; + const showPatternPanel = selectedTab === 'patterns' && ! delayedFilterValue && @@ -236,7 +238,7 @@ function InserterMenu( placeholder={ __( 'Search' ) } ref={ searchRef } /> - { !! delayedFilterValue && ( + { readyToShow && delayedFilterValue && (
) } - { showAsTabs && ( + { readyToShow && showAsTabs && ( ) } - { ! delayedFilterValue && ! showAsTabs && ( + { readyToShow && ! delayedFilterValue && ! showAsTabs && (
{ blocksTab }
diff --git a/packages/block-editor/src/components/inserter/quick-inserter.js b/packages/block-editor/src/components/inserter/quick-inserter.js index 540b51a4757e0d..9edc1d7001f83c 100644 --- a/packages/block-editor/src/components/inserter/quick-inserter.js +++ b/packages/block-editor/src/components/inserter/quick-inserter.js @@ -68,7 +68,7 @@ export default function QuickInserter( { ); const showPatterns = - patterns.length && ( !! filterValue || prioritizePatterns ); + patterns?.length && ( !! filterValue || prioritizePatterns ); const showSearch = ( showPatterns && patterns.length > SEARCH_THRESHOLD ) || blockTypes.length > SEARCH_THRESHOLD; diff --git a/packages/block-editor/src/components/media-placeholder/index.js b/packages/block-editor/src/components/media-placeholder/index.js index 41b1d3fe37c56a..a1f588b25cdcb3 100644 --- a/packages/block-editor/src/components/media-placeholder/index.js +++ b/packages/block-editor/src/components/media-placeholder/index.js @@ -290,7 +290,7 @@ export function MediaPlaceholder( { } async function onHTMLDrop( HTML ) { - const blocks = pasteHandler( { HTML } ); + const blocks = await pasteHandler( { HTML } ); return await handleBlocksDrop( blocks ); } diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index acadfb24a72217..911c5809d3268e 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -300,16 +300,17 @@ export function RichTextWrapper( ); const onEnter = useCallback( - ( { value, onChange, shiftKey } ) => { + async ( { value, onChange, shiftKey } ) => { const canSplit = onReplace && onSplit; if ( onReplace ) { - const transforms = getBlockTransforms( 'from' ).filter( - ( { type } ) => type === 'enter' + const transforms = await getBlockTransforms( 'from' ); + const enterTransforms = transforms.filter( + ( t ) => t.type === 'enter' + ); + const transformation = findTransform( enterTransforms, ( t ) => + t.regExp.test( value.text ) ); - const transformation = findTransform( transforms, ( item ) => { - return item.regExp.test( value.text ); - } ); if ( transformation ) { onReplace( [ @@ -364,7 +365,7 @@ export function RichTextWrapper( ); const onPaste = useCallback( - ( { + async ( { value, onChange, html, @@ -394,7 +395,7 @@ export function RichTextWrapper( // Only process file if no HTML is present. // Note: a pasted file may have the URL as plain text. if ( files && files.length && ! html ) { - const content = pasteHandler( { + const content = await pasteHandler( { HTML: filePasteHandler( files ), mode: 'BLOCKS', tagName, @@ -433,7 +434,7 @@ export function RichTextWrapper( mode = 'BLOCKS'; } - const content = pasteHandler( { + const content = await pasteHandler( { HTML: html, plainText, mode, @@ -486,7 +487,7 @@ export function RichTextWrapper( ); const inputRule = useCallback( - ( value, valueToFormat ) => { + async ( value, valueToFormat ) => { if ( ! onReplace ) { return; } @@ -503,14 +504,12 @@ export function RichTextWrapper( } const trimmedTextBefore = text.slice( 0, startPosition ).trim(); - const prefixTransforms = getBlockTransforms( 'from' ).filter( - ( { type } ) => type === 'prefix' - ); + const prefixTransforms = ( + await getBlockTransforms( 'from' ) + ).filter( ( { type } ) => type === 'prefix' ); const transformation = findTransform( prefixTransforms, - ( { prefix } ) => { - return trimmedTextBefore === prefix; - } + ( { prefix } ) => trimmedTextBefore === prefix ); if ( ! transformation ) { diff --git a/packages/block-editor/src/components/rich-text/use-enter.js b/packages/block-editor/src/components/rich-text/use-enter.js index 40d4f9be4759fa..6bb6db1d3c8705 100644 --- a/packages/block-editor/src/components/rich-text/use-enter.js +++ b/packages/block-editor/src/components/rich-text/use-enter.js @@ -20,7 +20,7 @@ export function useEnter( props ) { const propsRef = useRef( props ); propsRef.current = props; return useRefEffect( ( element ) => { - function onKeyDown( event ) { + async function onKeyDown( event ) { if ( event.defaultPrevented ) { return; } @@ -47,9 +47,9 @@ export function useEnter( props ) { const canSplit = onReplace && onSplit; if ( onReplace ) { - const transforms = getBlockTransforms( 'from' ).filter( - ( { type } ) => type === 'enter' - ); + const transforms = ( + await getBlockTransforms( 'from' ) + ).filter( ( { type } ) => type === 'enter' ); const transformation = findTransform( transforms, ( item ) => { return item.regExp.test( _value.text ); } ); diff --git a/packages/block-editor/src/components/rich-text/use-input-rules.js b/packages/block-editor/src/components/rich-text/use-input-rules.js index 5640a85f5f2695..1e7b3986c51988 100644 --- a/packages/block-editor/src/components/rich-text/use-input-rules.js +++ b/packages/block-editor/src/components/rich-text/use-input-rules.js @@ -83,7 +83,7 @@ export function useInputRules( props ) { const propsRef = useRef( props ); propsRef.current = props; return useRefEffect( ( element ) => { - function inputRule() { + async function inputRule() { const { getValue, onReplace, selectionChange } = propsRef.current; if ( ! onReplace ) { @@ -102,14 +102,12 @@ export function useInputRules( props ) { } const trimmedTextBefore = text.slice( 0, start ).trim(); - const prefixTransforms = getBlockTransforms( 'from' ).filter( - ( { type } ) => type === 'prefix' - ); + const prefixTransforms = ( + await getBlockTransforms( 'from' ) + ).filter( ( { type } ) => type === 'prefix' ); const transformation = findTransform( prefixTransforms, - ( { prefix } ) => { - return trimmedTextBefore === prefix; - } + ( { prefix } ) => trimmedTextBefore === prefix ); if ( ! transformation ) { @@ -128,7 +126,7 @@ export function useInputRules( props ) { return true; } - function onInput( event ) { + async function onInput( event ) { const { inputType, type } = event; const { getValue, @@ -142,8 +140,8 @@ export function useInputRules( props ) { return; } - if ( __unstableAllowPrefixTransformations && inputRule ) { - if ( inputRule() ) return; + if ( __unstableAllowPrefixTransformations ) { + if ( await inputRule() ) return; } const value = getValue(); diff --git a/packages/block-editor/src/components/rich-text/use-paste-handler.js b/packages/block-editor/src/components/rich-text/use-paste-handler.js index 1302e2d0dce469..78382eb8d12b12 100644 --- a/packages/block-editor/src/components/rich-text/use-paste-handler.js +++ b/packages/block-editor/src/components/rich-text/use-paste-handler.js @@ -24,7 +24,7 @@ export function usePasteHandler( props ) { const propsRef = useRef( props ); propsRef.current = props; return useRefEffect( ( element ) => { - function _onPaste( event ) { + async function _onPaste( event ) { const { isSelected, disableFormats, @@ -78,7 +78,7 @@ export function usePasteHandler( props ) { // eslint-disable-next-line no-console window.console.log( 'Received items:\n\n', files ); - const fromTransforms = getBlockTransforms( 'from' ); + const fromTransforms = await getBlockTransforms( 'from' ); const blocks = files .reduce( ( accumulator, file ) => { const transformation = findTransform( @@ -127,7 +127,7 @@ export function usePasteHandler( props ) { mode = 'BLOCKS'; } - const content = pasteHandler( { + const content = await pasteHandler( { HTML: html, plainText, mode, diff --git a/packages/block-editor/src/components/use-on-block-drop/index.js b/packages/block-editor/src/components/use-on-block-drop/index.js index c49af2f80fca22..3d5a608f5a07bf 100644 --- a/packages/block-editor/src/components/use-on-block-drop/index.js +++ b/packages/block-editor/src/components/use-on-block-drop/index.js @@ -149,13 +149,13 @@ export function onFilesDrop( canInsertBlockType, insertOrReplaceBlocks ) { - return ( files ) => { + return async ( files ) => { if ( ! getSettings().mediaUpload ) { return; } const transformation = findTransform( - getBlockTransforms( 'from' ), + await getBlockTransforms( 'from' ), ( transform ) => transform.type === 'files' && canInsertBlockType( transform.blockName, targetRootClientId ) && @@ -186,8 +186,8 @@ export function onHTMLDrop( targetBlockIndex, insertOrReplaceBlocks ) { - return ( HTML ) => { - const blocks = pasteHandler( { HTML, mode: 'BLOCKS' } ); + return async ( HTML ) => { + const blocks = await pasteHandler( { HTML, mode: 'BLOCKS' } ); if ( blocks.length ) { insertOrReplaceBlocks( blocks ); diff --git a/packages/block-editor/src/components/writing-flow/use-clipboard-handler.js b/packages/block-editor/src/components/writing-flow/use-clipboard-handler.js index 5b78d2f8656b61..f8a2652b694b46 100644 --- a/packages/block-editor/src/components/writing-flow/use-clipboard-handler.js +++ b/packages/block-editor/src/components/writing-flow/use-clipboard-handler.js @@ -46,7 +46,7 @@ export default function useClipboardHandler() { const notifyCopy = useNotifyCopy(); return useRefEffect( ( node ) => { - function handler( event ) { + async function handler( event ) { if ( event.defaultPrevented ) { // This was likely already handled in rich-text/use-paste-handler.js. return; @@ -157,7 +157,7 @@ export default function useClipboardHandler() { let blocks = []; if ( files.length ) { - const fromTransforms = getBlockTransforms( 'from' ); + const fromTransforms = await getBlockTransforms( 'from' ); blocks = files .reduce( ( accumulator, file ) => { const transformation = findTransform( @@ -175,7 +175,7 @@ export default function useClipboardHandler() { }, [] ) .flat(); } else { - blocks = pasteHandler( { + blocks = await pasteHandler( { HTML: html, plainText, mode: 'BLOCKS', diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index b21436161cb8c3..3df8eddaf5b078 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -703,7 +703,7 @@ export const synchronizeTemplate = */ export const __unstableDeleteSelection = ( isForward ) => - ( { registry, select, dispatch } ) => { + async ( { registry, select, dispatch } ) => { const selectionAnchor = select.getSelectionStart(); const selectionFocus = select.getSelectionEnd(); @@ -784,7 +784,10 @@ export const __unstableDeleteSelection = const blocksWithTheSameType = blockA.name === blockB.name ? [ followingBlock ] - : switchToBlockType( followingBlock, targetBlockType.name ); + : await switchToBlockType( + followingBlock, + targetBlockType.name + ); // If the block types can not match, do nothing if ( ! blocksWithTheSameType || ! blocksWithTheSameType.length ) { @@ -957,7 +960,7 @@ export const __unstableExpandSelection = */ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => - ( { registry, select, dispatch } ) => { + async ( { registry, select, dispatch } ) => { const blocks = [ firstBlockClientId, secondBlockClientId ]; dispatch( { type: 'MERGE_BLOCKS', blocks } ); @@ -975,7 +978,7 @@ export const mergeBlocks = ) { // If there's no merge function defined, attempt merging inner // blocks. - const blocksWithTheSameType = switchToBlockType( + const blocksWithTheSameType = await switchToBlockType( blockB, blockAType.name ); @@ -1112,7 +1115,7 @@ export const mergeBlocks = const blocksWithTheSameType = blockA.name === blockB.name ? [ cloneB ] - : switchToBlockType( cloneB, blockA.name ); + : await switchToBlockType( cloneB, blockA.name ); // If the block types can not match, do nothing. if ( ! blocksWithTheSameType || ! blocksWithTheSameType.length ) { diff --git a/packages/block-editor/src/store/index.js b/packages/block-editor/src/store/index.js index 0bcc00cb5f6ae8..fc999278ed68c4 100644 --- a/packages/block-editor/src/store/index.js +++ b/packages/block-editor/src/store/index.js @@ -11,6 +11,7 @@ import * as selectors from './selectors'; import * as privateActions from './private-actions'; import * as privateSelectors from './private-selectors'; import * as actions from './actions'; +import * as resolvers from './resolvers'; import { STORE_NAME } from './constants'; import { unlock } from '../lock-unlock'; @@ -23,6 +24,7 @@ export const storeConfig = { reducer, selectors, actions, + resolvers, }; /** diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index 5319a3b2553654..6572277217eb0b 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -1991,6 +1991,17 @@ export function lastFocus( state = false, action ) { return state; } +export function parsedPatterns( state = {}, action ) { + switch ( action.type ) { + case 'SET_PARSED_PATTERN': + return { + ...state, + [ action.patternName ]: action.parsedPattern, + }; + } + return state; +} + const combinedReducers = combineReducers( { blocks, isTyping, @@ -2020,6 +2031,7 @@ const combinedReducers = combineReducers( { blockRemovalRules, openedBlockSettingsMenu, registeredInserterMediaCategories, + parsedPatterns, } ); function withAutomaticChangeReset( reducer ) { diff --git a/packages/block-editor/src/store/resolvers.js b/packages/block-editor/src/store/resolvers.js new file mode 100644 index 00000000000000..f072b6689706ae --- /dev/null +++ b/packages/block-editor/src/store/resolvers.js @@ -0,0 +1,69 @@ +/** + * WordPress dependencies + */ +import { parse } from '@wordpress/blocks'; + +export const __experimentalGetParsedPattern = + ( patternName ) => + async ( { select, dispatch } ) => { + const patterns = select( + ( state ) => state.root.settings.__experimentalBlockPatterns + ); + const unsyncedPatterns = select.getUnsyncedPatterns(); + + const pattern = [ ...patterns, ...unsyncedPatterns ].find( + ( { name } ) => name === patternName + ); + + if ( ! pattern ) { + return; + } + + const blocks = await parse( pattern.content, { + __unstableSkipMigrationLogs: true, + } ); + + const parsedPattern = { ...pattern, blocks }; + + dispatch( { + type: 'SET_PARSED_PATTERN', + patternName: pattern.name, + parsedPattern, + } ); + }; + +export const __experimentalGetAllowedPatterns = + () => + async ( { select, dispatch } ) => { + const patterns = select( + ( state ) => state.root.settings.__experimentalBlockPatterns + ); + const unsyncedPatterns = select.getUnsyncedPatterns(); + + const inserterPatterns = [ ...patterns, ...unsyncedPatterns ].filter( + ( { inserter = true } ) => inserter + ); + + for ( const pattern of inserterPatterns ) { + const blocks = await parse( pattern.content, { + __unstableSkipMigrationLogs: true, + } ); + + const parsedPattern = { ...pattern, blocks }; + + dispatch( { + type: 'SET_PARSED_PATTERN', + patternName: pattern.name, + parsedPattern, + } ); + } + }; + +__experimentalGetAllowedPatterns.shouldInvalidate = ( action ) => { + return ( + action.type === 'UPDATE_SETTINGS' && + action.settings.__experimentalBlockPatterns + ); +}; + +export const getPatternsByBlockTypes = __experimentalGetAllowedPatterns; diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index b6d455333c7a52..3eb7ccd25866a6 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -8,10 +8,10 @@ import createSelector from 'rememo'; */ import { getBlockType, - getBlockTypes, + getBootstrappedBlockType, + getBootstrappedBlockTypes, getBlockVariations, hasBlockSupport, - getPossibleBlockTransformations, parse, switchToBlockType, store as blocksStore, @@ -1508,7 +1508,7 @@ const canInsertBlockTypeUnmemoized = ( blockType = blockName; blockName = blockType.name; } else { - blockType = getBlockType( blockName ); + blockType = getBootstrappedBlockType( blockName ); } if ( ! blockType ) { return false; @@ -1975,7 +1975,7 @@ export const getInserterItems = createSelector( buildScope: 'inserter', } ); - const blockTypeInserterItems = getBlockTypes() + const blockTypeInserterItems = getBootstrappedBlockTypes() .filter( ( blockType ) => canIncludeBlockTypeInInserter( state, blockType, rootClientId ) ) @@ -1987,10 +1987,9 @@ export const getInserterItems = createSelector( if ( ! variations.some( ( { isDefault } ) => isDefault ) ) { accumulator.push( item ); } - if ( variations.length ) { - const variationMapper = getItemFromVariation( state, item ); - accumulator.push( ...variations.map( variationMapper ) ); - } + accumulator.push( + ...variations.map( getItemFromVariation( state, item ) ) + ); return accumulator; }, [] ); @@ -1999,18 +1998,10 @@ export const getInserterItems = createSelector( // the core blocks (usually by using the `init` action), // thus affecting the display order. // We don't sort reusable blocks as they are handled differently. - const groupByType = ( blocks, block ) => { - const { core, noncore } = blocks; - const type = block.name.startsWith( 'core/' ) ? core : noncore; - - type.push( block ); - return blocks; - }; - const { core: coreItems, noncore: nonCoreItems } = items.reduce( - groupByType, - { core: [], noncore: [] } + const sortedBlockTypes = orderBy( + items, + ( block ) => ! block.name.startsWith( 'core/' ) // false < true ); - const sortedBlockTypes = [ ...coreItems, ...nonCoreItems ]; return [ ...sortedBlockTypes, ...syncedPatternInserterItems ]; }, ( state, rootClientId ) => [ @@ -2021,7 +2012,7 @@ export const getInserterItems = createSelector( state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks( state ), - getBlockTypes(), + getBootstrappedBlockTypes(), ] ); @@ -2052,37 +2043,18 @@ export const getInserterItems = createSelector( * @property {number} frecency Heuristic that combines frequency and recency. */ export const getBlockTransformItems = createSelector( - ( state, blocks, rootClientId = null ) => { - const normalizedBlocks = Array.isArray( blocks ) ? blocks : [ blocks ]; + ( state, rootClientId = null ) => { const buildBlockTypeTransformItem = buildBlockTypeItem( state, { buildScope: 'transform', } ); - const blockTypeTransformItems = getBlockTypes() + const blockTypeTransformItems = getBootstrappedBlockTypes() .filter( ( blockType ) => canIncludeBlockTypeInInserter( state, blockType, rootClientId ) ) - .map( buildBlockTypeTransformItem ); - - const itemsByName = Object.fromEntries( - Object.entries( blockTypeTransformItems ).map( ( [ , value ] ) => [ - value.name, - value, - ] ) - ); + .map( buildBlockTypeTransformItem ) + .map( ( value ) => [ value.name, value ] ); - const possibleTransforms = getPossibleBlockTransformations( - normalizedBlocks - ).reduce( ( accumulator, block ) => { - if ( itemsByName[ block?.name ] ) { - accumulator.push( itemsByName[ block.name ] ); - } - return accumulator; - }, [] ); - return orderBy( - possibleTransforms, - ( block ) => itemsByName[ block.name ].frecency, - 'desc' - ); + return Object.fromEntries( blockTypeTransformItems ); }, ( state, blocks, rootClientId ) => [ state.blockListSettings[ rootClientId ], @@ -2090,7 +2062,7 @@ export const getBlockTransformItems = createSelector( state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, - getBlockTypes(), + getBootstrappedBlockTypes(), ] ); @@ -2102,29 +2074,21 @@ export const getBlockTransformItems = createSelector( * * @return {boolean} Items that appear in inserter. */ -export const hasInserterItems = createSelector( - ( state, rootClientId = null ) => { - const hasBlockType = getBlockTypes().some( ( blockType ) => - canIncludeBlockTypeInInserter( state, blockType, rootClientId ) - ); - if ( hasBlockType ) { - return true; - } - const hasReusableBlock = - canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) && - getReusableBlocks( state ).length > 0; +export const hasInserterItems = ( state, rootClientId = null ) => { + const hasBlockType = getBootstrappedBlockTypes().some( ( blockType ) => + canIncludeBlockTypeInInserter( state, blockType, rootClientId ) + ); - return hasReusableBlock; - }, - ( state, rootClientId ) => [ - state.blockListSettings[ rootClientId ], - state.blocks.byClientId, - state.settings.allowedBlockTypes, - state.settings.templateLock, - getReusableBlocks( state ), - getBlockTypes(), - ] -); + if ( hasBlockType ) { + return true; + } + + const hasReusableBlock = + canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) && + getReusableBlocks( state ).length > 0; + + return hasReusableBlock; +}; /** * Returns the list of allowed inserter blocks for inner blocks children. @@ -2140,9 +2104,10 @@ export const getAllowedBlocks = createSelector( return; } - const blockTypes = getBlockTypes().filter( ( blockType ) => + const blockTypes = getBootstrappedBlockTypes().filter( ( blockType ) => canIncludeBlockTypeInInserter( state, blockType, rootClientId ) ); + const hasReusableBlock = canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) && getReusableBlocks( state ).length > 0; @@ -2158,7 +2123,7 @@ export const getAllowedBlocks = createSelector( state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks( state ), - getBlockTypes(), + getBootstrappedBlockTypes(), ] ); @@ -2321,6 +2286,7 @@ export const __experimentalGetAllowedPatterns = createSelector( state.settings.templateLock, state.blockListSettings[ rootClientId ], state.blocks.byClientId.get( rootClientId ), + state.parsedPatterns, ] ); @@ -2344,6 +2310,11 @@ export const getPatternsByBlockTypes = createSelector( state, rootClientId ); + + if ( ! patterns ) { + return null; + } + const normalizedBlockNames = Array.isArray( blockNames ) ? blockNames : [ blockNames ]; diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index b74079b2b8b79d..bcbe08538a26cb 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -324,10 +324,10 @@ export default function Image( { const canEditImage = id && naturalWidth && naturalHeight && imageEditing; const allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage; - function switchToCover() { + async function switchToCover() { replaceBlocks( clientId, - switchToBlockType( getBlock( clientId ), 'core/cover' ) + await switchToBlockType( getBlock( clientId ), 'core/cover' ) ); } diff --git a/packages/block-library/src/list-item/edit.js b/packages/block-library/src/list-item/edit.js index 7733a762807528..d31f26555eefc3 100644 --- a/packages/block-library/src/list-item/edit.js +++ b/packages/block-library/src/list-item/edit.js @@ -106,9 +106,9 @@ export default function ListItemEdit( { onMerge={ onMerge } onReplace={ onReplace - ? ( blocks, ...args ) => { + ? async ( blocks, ...args ) => { onReplace( - convertToListItems( blocks ), + await convertToListItems( blocks ), ...args ); } diff --git a/packages/block-library/src/list-item/edit.native.js b/packages/block-library/src/list-item/edit.native.js index cf2e77c08d2e83..b8b3690a41fa81 100644 --- a/packages/block-library/src/list-item/edit.native.js +++ b/packages/block-library/src/list-item/edit.native.js @@ -130,12 +130,12 @@ export default function ListItemEdit( { [ clientId, onSplit ] ); const onReplaceList = useCallback( - ( blocks, ...args ) => { + async ( blocks, ...args ) => { if ( ! preventDefault.current ) { - onReplace( convertToListItems( blocks ), ...args ); + onReplace( await convertToListItems( blocks ), ...args ); } }, - [ clientId, onReplace, convertToListItems ] + [ onReplace ] ); const onLayout = useCallback( ( { nativeEvent } ) => { setContentWidth( ( prevState ) => { diff --git a/packages/block-library/src/list-item/utils.js b/packages/block-library/src/list-item/utils.js index 5e5b51a8af680c..29252fb4f2a12a 100644 --- a/packages/block-library/src/list-item/utils.js +++ b/packages/block-library/src/list-item/utils.js @@ -3,19 +3,19 @@ */ import { switchToBlockType } from '@wordpress/blocks'; -function convertBlockToList( block ) { - const list = switchToBlockType( block, 'core/list' ); +async function convertBlockToList( block ) { + const list = await switchToBlockType( block, 'core/list' ); if ( list ) { return list; } - const paragraph = switchToBlockType( block, 'core/paragraph' ); + const paragraph = await switchToBlockType( block, 'core/paragraph' ); if ( ! paragraph ) { return null; } - return switchToBlockType( paragraph, 'core/list' ); + return await switchToBlockType( paragraph, 'core/list' ); } -export function convertToListItems( blocks ) { +export async function convertToListItems( blocks ) { const listItems = []; for ( let block of blocks ) { @@ -23,7 +23,7 @@ export function convertToListItems( blocks ) { listItems.push( block ); } else if ( block.name === 'core/list' ) { listItems.push( ...block.innerBlocks ); - } else if ( ( block = convertBlockToList( block ) ) ) { + } else if ( ( block = await convertBlockToList( block ) ) ) { for ( const { innerBlocks } of block ) { listItems.push( ...innerBlocks ); } diff --git a/packages/block-library/src/navigation-link/link-ui.js b/packages/block-library/src/navigation-link/link-ui.js index 3c3d91e7b0a052..3b8259e1fb7c15 100644 --- a/packages/block-library/src/navigation-link/link-ui.js +++ b/packages/block-library/src/navigation-link/link-ui.js @@ -113,10 +113,10 @@ function LinkControlTransforms( { clientId } ) { return (