-
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
Template/site editor: prevent classic block from loading #27059
Conversation
Size Change: +291 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
Some unit tests fail:
It looks like this file needs to include more mocks: gutenberg/test/unit/__mocks__/@wordpress/block-library.js Lines 2 to 3 in 273dee2
|
const isClassicEnabled = | ||
window.wpEditorL10n && 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.
These values might change during runtime so a function would work better here. This would fix the tests too.
const isClassicEnabled = | |
window.wpEditorL10n && window.wp && window.wp.oldEditor; | |
const isClassicEnabled = () => | |
window.wpEditorL10n && window.wp && window.wp.oldEditor; | |
@@ -139,7 +142,7 @@ export const __experimentalGetCoreBlocks = () => [ | |||
embed, | |||
file, | |||
group, | |||
window.wp && window.wp.oldEditor ? classic : null, // Only add the classic block in WP Context | |||
isClassicEnabled ? classic : null, // Only add the classic block in WP Context |
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.
isClassicEnabled ? classic : null, // Only add the classic block in WP Context | |
isClassicEnabled() ? classic : null, // Only add the classic block in WP Context |
@@ -182,7 +185,7 @@ export const registerCoreBlocks = ( | |||
blocks.forEach( registerBlock ); | |||
|
|||
setDefaultBlockName( paragraph.name ); | |||
if ( window.wp && window.wp.oldEditor ) { | |||
if ( isClassicEnabled ) { |
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.
if ( isClassicEnabled ) { | |
if ( isClassicEnabled() ) { |
Description
See #26915.
Currently the classic block is available in the site editor and triggers an error when loading because
window.wpEditorL10n
is not set.In the site editor, ideally any scripts for the classic editor should not load and the block should not be available.
If there is free form content in the post content, the content can be previewed through the missing block mechanism.
How has this been tested?
Screenshots
Types of changes
Checklist: