Custom classes do not get added to markup in editor for certain blocks
Issue Overview
Not every block that supports custom classes adds the class name to the block's markup while editing.
Most blocks that support custom classes add the entered classes to the block markup in the editor. This is great. You can add your custom defined styles and they immediately get reflected in Gutenberg while you are editing. However some blocks only add the custom class when viewed on the front-end and not while in the editor. This is a broken experience. I think a fix should be made to any block that supports custom classes to actually render the classes in edit mode.
I've gone through all the core blocks that support custom classes and the following don't add the custom class while editing:
- Heading
- Paragraph
- List
- Audio
- Video
- Embeds
Steps to Reproduce (for bugs)
- Create a new Heading, Paragraph, List, Audio, Video, or Embed block.
- While new block is active, select the block tab from the inspector.
- Add a custom class in the 'Additional CSS Class' input field.
- Check for class to be added to block markup using browser inspector tools.
Expected Behavior
Editing custom class is added to block while editing, allowing to see custom styles applied in editor.
Current Behavior
Editing custom classes for certain blocks does not get added to block while editing, it only show on the front end.
Possible Solution
Make sure the className property is added to the output of the edit function for any block that supports custom classes.
Screenshots / Video
Current:

Fixed:

Related Issues and/or PRs
I've put in a PR #5488 to fix heading, paragraph, list, and embeds. I am not quite sure how to fix the audio and video blocks?
Todos
- [ ] Patch
- [ ] Tests
- [ ] Documentation
#5488 addressed this issue. Related issues with server side rendered blocks (Latest Posts, Categories) are brought up in #5644