-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Move the Classic block to the packages #10397
Move the Classic block to the packages #10397
Conversation
Should the folders be renamed to |
Yes; the "freeform" name is quite confusing! 😅 |
It's called Classic in the UI: I don't like exceptions, but in this case, it is only an internal name. We refer to it as classic every time we chat. I would vote to rename the folder and the variable assigned with import and leave the rest as is. Sidenote: when you search for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. We could discuss whether it should land in edit-post
but this makes all the things easier for the time being and removes a lot of dead code. I would still consider renaming the folder from freeform
to classic
.
packages/block-library/src/index.js
Outdated
@@ -44,6 +45,9 @@ import * as textColumns from './text-columns'; | |||
import * as verse from './verse'; | |||
import * as video from './video'; | |||
|
|||
// The freeform block can't be moved to the "npm" packages folder because it requires the wp.oldEditor global. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer relevant, I guess 😅
registerBlockType( name, settings ); | ||
} ); | ||
|
||
setDefaultBlockName( paragraph.name ); | ||
if ( window.wp && window.wp.oldEditor ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could register Classic block in here to avoid conditional in other parts.
if ( window.wp && window.wp.oldEditor ) {
registerBlockType( freeform.name, freeform.settings );
setUnknownTypeHandlerName( freeform.name );
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about the implication of the order of the block's registration, I know it has some importance in the transforms priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is important in this case, but I'm fine with leaving it as it is.
We probably still need to add a changelog entry because technically speaking, you still can enable Classic block by defining |
I'll wait for a review of #10396 to merge this one as it's targetting that branch. |
@@ -7,6 +7,7 @@ | |||
@import "./cover-image/editor.scss"; | |||
@import "./embed/editor.scss"; | |||
@import "./file/editor.scss"; | |||
@import "./freeform/editor.scss"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be updated, too
Hey @youknowriad - I’m seeing a warning in latest master:
It's still there after I cleaned the repo using |
@talldan, looking into it. |
I can't reproduce: All 3 styles for wp_register_style(
'wp-edit-blocks',
gutenberg_url( 'build/block-library/editor.css' ),
array(
'wp-components',
'wp-editor',
// Always include visual styles so the editor never appears broken.
'wp-block-library-theme',
),
filemtime( gutenberg_dir_path() . 'build/block-library/editor.css' )
); |
Hmm, unusual. Restarted my docker env and it's fine now. Thanks for looking into it. |
In order to merge Gutenberg into Core easily, all the Gutenberg JavaScript Core must be shared a reusable npm package. This PR moves the freeform block to the packages folder.
The idea is to test whether the
wp.oldEditor
global (provided by WP) is available or not before registering the block. An alternative proposed by @gziolo is to move this block toedit-post
module. I think both alternatives are good options. We'll probably have to revisit at some point either way so I just went with the simplest one for noow.This also means the block library is fully available as a package. (so a bunch of files removed etc...)
Testing instructions
Make sure you can use the classic block properly.