syntaxhighlighter icon indicating copy to clipboard operation
syntaxhighlighter copied to clipboard

Fix Language is not set when language alias does not exist.

Open t-hamano opened this issue 3 years ago • 0 comments

Reported in the gutenberg repository issue: https://github.com/WordPress/gutenberg/issues/41623

Changes proposed in this Pull Request

This PR adds fallback when a non-existent alias (brush) is entered by ``` + enter.

Screenshot / Video

If a block is created by a non-existent alias, the language is not set correctly in the toolbar. Also, clicking a blank button causes the block to crash.

https://user-images.githubusercontent.com/54422211/173046664-cdc6bf69-7f5d-4caf-a59d-3b0c9cf3f841.mp4

Testing instructions

Plain Text is now set as the language as a fallback when a non-existent alias is specified.

My concern is that when plain key is excluded by the syntaxhighlighter_brushes filter, it will probably cause the same error. Another way to handle this might be to not generate a block when a non-existent alias is specified.

t-hamano avatar Jun 10 '22 10:06 t-hamano