If you are looking to add alignment options to some core blocks that don't support alignment, this is the way to achieve it. Add the javascript here to a file in the following location in your active theme:
assets/js/editor.js
and enqueue it in your themes functions.php
file like so:
/**
* Enqueue the correct scripts for the Gutenberg block editor.
*/
function hd_gutenberg_scripts() {
// enqueue the editor js for the starter theme/
wp_enqueue_script(
'hd_editor',
get_stylesheet_directory_uri() . '/assets/js/editor.js',
array(
'wp-blocks',
'wp-dom'
),
filemtime( get_stylesheet_directory() . '/assets/js/editor.js' ),
true
);
}
add_action( 'enqueue_block_editor_assets', 'hd_gutenberg_scripts' );
Great! A possible simplification: