This is an example snippet for forcing the Gutenberg editor into full screen mode in anticipation of the change coming to WordPress 5.4.
Last active
January 4, 2021 16:24
-
-
Save joemcgill/24d8cc620856ce98805464d87cb40036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import domReady from '@wordpress/dom-ready'; | |
import { | |
dispatch, | |
select, | |
} from '@wordpress/data'; | |
const forceFullScreen = () => { | |
const featurePrefs = select( 'core/edit-post' ).getPreference( 'features' ); | |
// Respect user preferences. | |
if ( typeof featurePrefs.fullscreenMode !== 'undefined' ) { | |
return; | |
} | |
const isFullscreenMode = select( 'core/edit-post' ).isFeatureActive( 'fullscreenMode' ); | |
// Force fullscreen mode if not set already. | |
if ( ! isFullscreenMode ) { | |
dispatch( 'core/edit-post' ).toggleFeature( 'fullscreenMode' ); | |
} | |
} | |
domReady( function() { | |
forceFullScreen(); | |
} ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enqueue the script. | |
add_action( 'enqueue_block_editor_assets', function() { | |
wp_enqueue_script( | |
'gb-fullscreen', | |
plugins_url( '/build/index.js', __FILE__ ), | |
[ 'wp-components', 'wp-editor' ] | |
); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment