-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import '@wordpress/core-data'; | |
import { | ||
registerBlockType, | ||
setDefaultBlockName, | ||
setUnknownTypeHandlerName, | ||
} from '@wordpress/blocks'; | ||
|
||
/** | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This comment is no longer relevant, I guess 😅 |
||
import * as freeform from './freeform'; | ||
|
||
export const registerCoreBlocks = () => { | ||
[ | ||
// Common blocks are grouped at the top to prioritize their display | ||
|
@@ -69,6 +73,7 @@ export const registerCoreBlocks = () => { | |
...embed.common, | ||
...embed.others, | ||
file, | ||
window.wp && window.wp.oldEditor ? freeform : null, // Only add the freeform block in WP Context | ||
html, | ||
latestComments, | ||
latestPosts, | ||
|
@@ -85,9 +90,16 @@ export const registerCoreBlocks = () => { | |
textColumns, | ||
verse, | ||
video, | ||
].forEach( ( { name, settings } ) => { | ||
].forEach( ( block ) => { | ||
if ( ! block ) { | ||
return; | ||
} | ||
const { name, settings } = block; | ||
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 commentThe 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 commentThe 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 commentThe 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. |
||
setUnknownTypeHandlerName( freeform.name ); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Make sure the freeform block is registered. | ||
window.wp = window.wp || {}; | ||
window.wp.oldEditor = {}; | ||
|
||
export * from '../../../../packages/block-library/src'; |
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