We use JavaScript to unregister some Core blocks from the Page Editor. We'd like to unregister a slightly different list of blocks when using the Site Editor vs when editing a page or post.
Rather than something clunky to make this determination, such as looking at the current page's URL, does WordPress provide any native functions we can rely on? Some JavaScript version of get_current_screen or is_site_editor() or similar?
wp-edit-site
handle withwp_add_inline_script()
to add inline script likewp.domReady( function(){ wp.blocks.unregisterBlockType( 'core/html' );});
or useadmin_enqueue_scripts
for larger scripts. There is also a way to use the PHP filterallowed_block_types_all
and target the block editor's context there with$block_editor_context->name === 'core/edit-site'
... etc but we just keep the above in mind.