Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark FSE blocks as non experimental #35979

Merged
merged 3 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 80 additions & 87 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,74 +12,41 @@ import {
/**
* Internal dependencies
*/
import * as paragraph from './paragraph';
import * as image from './image';
import * as heading from './heading';
import * as quote from './quote';
import * as gallery from './gallery';
import * as archives from './archives';
import * as audio from './audio';
import * as buttons from './buttons';
import * as button from './button';
import * as buttons from './buttons';
import * as calendar from './calendar';
import * as categories from './categories';
import * as classic from './freeform';
import * as code from './code';
import * as columns from './columns';
import * as column from './column';
import * as columns from './columns';
import * as commentTemplate from './comment-template';
import * as commentsQueryLoop from './comments-query-loop';
import * as cover from './cover';
import * as embed from './embed';
import * as file from './file';
import * as html from './html';
import * as mediaText from './media-text';
import * as navigation from './navigation';
import * as navigationLink from './navigation-link';
import * as navigationSubmenu from './navigation-submenu';
import * as gallery from './gallery';
import * as group from './group';
import * as heading from './heading';
import * as homeLink from './home-link';
import * as html from './html';
import * as image from './image';
import * as latestComments from './latest-comments';
import * as latestPosts from './latest-posts';
import * as logInOut from './loginout';
import * as list from './list';
import * as logInOut from './loginout';
import * as mediaText from './media-text';
import * as missing from './missing';
import * as more from './more';
import * as navigation from './navigation';
import * as navigationLink from './navigation-link';
import * as navigationSubmenu from './navigation-submenu';
import * as nextpage from './nextpage';
import * as pattern from './pattern';
import * as pageList from './page-list';
import * as preformatted from './preformatted';
import * as pullquote from './pullquote';
import * as reusableBlock from './block';
import * as rss from './rss';
import * as search from './search';
import * as group from './group';
import * as separator from './separator';
import * as shortcode from './shortcode';
import * as spacer from './spacer';
import * as table from './table';
// import * as tableOfContents from './table-of-contents';
import * as textColumns from './text-columns';
import * as verse from './verse';
import * as video from './video';
import * as tagCloud from './tag-cloud';
import * as classic from './freeform';
import * as socialLinks from './social-links';
import * as socialLink from './social-link';

// Full Site Editing Blocks
import * as commentsQueryLoop from './comments-query-loop';
import * as commentTemplate from './comment-template';
import * as siteLogo from './site-logo';
import * as siteTagline from './site-tagline';
import * as siteTitle from './site-title';
import * as templatePart from './template-part';
import * as query from './query';
import * as postTemplate from './post-template';
import * as queryTitle from './query-title';
import * as queryPagination from './query-pagination';
import * as queryPaginationNext from './query-pagination-next';
import * as queryPaginationNumbers from './query-pagination-numbers';
import * as queryPaginationPrevious from './query-pagination-previous';
import * as postNavigationLink from './post-navigation-link';
import * as postTitle from './post-title';
import * as postContent from './post-content';
import * as paragraph from './paragraph';
import * as postAuthor from './post-author';
import * as postComment from './post-comment';
import * as postCommentAuthor from './post-comment-author';
Expand All @@ -92,11 +59,42 @@ import * as postComments from './post-comments';
import * as postCommentsCount from './post-comments-count';
import * as postCommentsForm from './post-comments-form';
import * as postCommentsLink from './post-comments-link';
import * as postContent from './post-content';
import * as postDate from './post-date';
import * as postExcerpt from './post-excerpt';
import * as postFeaturedImage from './post-featured-image';
import * as postNavigationLink from './post-navigation-link';
import * as postTemplate from './post-template';
import * as postTerms from './post-terms';
import * as postTitle from './post-title';
import * as preformatted from './preformatted';
import * as pullquote from './pullquote';
import * as query from './query';
import * as queryPagination from './query-pagination';
import * as queryPaginationNext from './query-pagination-next';
import * as queryPaginationNumbers from './query-pagination-numbers';
import * as queryPaginationPrevious from './query-pagination-previous';
import * as queryTitle from './query-title';
import * as quote from './quote';
import * as reusableBlock from './block';
import * as rss from './rss';
import * as search from './search';
import * as separator from './separator';
import * as shortcode from './shortcode';
import * as siteLogo from './site-logo';
import * as siteTagline from './site-tagline';
import * as siteTitle from './site-title';
import * as socialLink from './social-link';
import * as socialLinks from './social-links';
import * as spacer from './spacer';
import * as table from './table';
// import * as tableOfContents from './table-of-contents';
import * as tagCloud from './tag-cloud';
import * as templatePart from './template-part';
import * as termDescription from './term-description';
import * as textColumns from './text-columns';
import * as verse from './verse';
import * as video from './video';

/**
* Function to register an individual block.
Expand Down Expand Up @@ -133,70 +131,69 @@ export const __experimentalGetCoreBlocks = () => [
quote,

// Register all remaining core blocks.
shortcode,
archives,
audio,
button,
buttons,
calendar,
categories,
window.wp && window.wp.oldEditor ? classic : null, // Only add the classic block in WP Context
code,
columns,
column,
columns,
commentTemplate,
commentsQueryLoop,
cover,
embed,
file,
group,
window.wp && window.wp.oldEditor ? classic : null, // Only add the classic block in WP Context
html,
mediaText,
latestComments,
latestPosts,
logInOut,
mediaText,
missing,
more,
navigation,
navigationLink,
navigationSubmenu,
nextpage,
pageList,
pattern,
postAuthor,
postContent,
postDate,
postExcerpt,
postFeaturedImage,
postTemplate,
postTerms,
postTitle,
preformatted,
pullquote,
query,
queryPagination,
queryPaginationNext,
queryPaginationNumbers,
queryPaginationPrevious,
queryTitle,
reusableBlock,
rss,
search,
separator,
reusableBlock,
socialLinks,
shortcode,
siteLogo,
siteTagline,
siteTitle,
socialLink,
socialLinks,
spacer,
table,
// tableOfContents,
tagCloud,
templatePart,
textColumns,
verse,
video,

// Theme blocks
commentsQueryLoop,
commentTemplate,

siteLogo,
siteTagline,
siteTitle,

query,
postTemplate,
queryTitle,
queryPagination,
queryPaginationNext,
queryPaginationNumbers,
queryPaginationPrevious,

postTitle,
postContent,
postDate,
postExcerpt,
postFeaturedImage,
postTerms,

logInOut,
pattern,
];

/**
Expand Down Expand Up @@ -239,16 +236,12 @@ export const __experimentalRegisterExperimentalCoreBlocks =
process.env.GUTENBERG_PHASE === 2
? ( { enableFSEBlocks } = {} ) => {
[
navigation,
navigationLink,
// Experimental blocks.
homeLink,
navigationSubmenu,

// Register Full Site Editing Blocks.
// Full Site Editing blocks.
...( enableFSEBlocks
? [
templatePart,
postAuthor,
Copy link
Contributor

@youknowriad youknowriad Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the post author has been removed from the 5.8 release because it was deemed not ready (as not flexible enough for all use cases and user-* blocks were being considered), that said, it seems too late to replace at the moment for 5.9, so maybe it's fine to land this one as (as a simple opinionated one) and add the more flexible ones later. cc @mtias

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also hesitant that we need more granular ones. As long as you can show / hide avatar and show / hide name it seems you can do a lot with it. If you want to show avatar and name in different layouts you can add two author blocks with different settings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting thoughts @mtias. We have more granular blocks for the Comment Template block:

  • Comment Author
  • Comment Author Avatar

Should we consolidate them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure :) There are some tradeoffs to both approaches.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, either way we need a way to display the post author in 5.9. 😄 I think the current one is workable if we want to just continue iterating on it.

postComment,
postCommentAuthor,
postCommentAuthorAvatar,
Expand Down
10 changes: 8 additions & 2 deletions packages/customize-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ import './filters';

const { wp } = window;

const DISABLED_BLOCKS = [ 'core/more', 'core/block', 'core/freeform' ];
const DISABLED_BLOCKS = [
'core/more',
'core/block',
'core/freeform',
'core/template-part',
];
const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;

/**
Expand All @@ -50,7 +55,8 @@ export function initialize( editorName, blockEditorSettings ) {
DISABLED_BLOCKS.includes( block.name ) ||
block.name.startsWith( 'core/post' ) ||
block.name.startsWith( 'core/query' ) ||
block.name.startsWith( 'core/site' )
block.name.startsWith( 'core/site' ) ||
block.name.startsWith( 'core/navigation' )
);
} );
registerCoreBlocks( coreBlocks );
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
const disabledBlocks = [
'core/more',
'core/freeform',
'core/template-part',
...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),
];

Expand Down Expand Up @@ -72,7 +73,8 @@ export function initialize( id, settings ) {
disabledBlocks.includes( block.name ) ||
block.name.startsWith( 'core/post' ) ||
block.name.startsWith( 'core/query' ) ||
block.name.startsWith( 'core/site' )
block.name.startsWith( 'core/site' ) ||
block.name.startsWith( 'core/navigation' )
);
} );

Expand Down
12 changes: 6 additions & 6 deletions tools/webpack/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ module.exports = {
// Within content, search for any function definitions. For
// each, replace every other reference to it in the file.
return (
content
.match( /^function [^\(]+/gm )
.reduce( ( result, functionName ) => {
// Trim leading "function " prefix from match.
functionName = functionName.slice( 9 );

Array.from(
content.matchAll(
/^\s*function ([^\(]+)/gm
)
)
.reduce( ( result, [ , functionName ] ) => {
// Prepend the Gutenberg prefix, substituting any
// other core prefix (e.g. "wp_").
return result.replace(
Expand Down