Skip to content

Commit efe5aef

Browse files
committed
Enable and improve types for syntaxhighlighter/code transform filter
1 parent 94d541c commit efe5aef

File tree

1 file changed

+7
-4
lines changed
  • projects/packages/jetpack-mu-wpcom/src/features/wpcom-blocks/code/block-definition

1 file changed

+7
-4
lines changed

projects/packages/jetpack-mu-wpcom/src/features/wpcom-blocks/code/block-definition/block-definition.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ const selectLanguageOptions: ReadonlyArray< {
7676
*/
7777
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- No good interface available for this type now.
7878
function filterBlockRegistration( settings: any ) {
79-
// Our transform is better than the transform provided by syntaxhighlighter/code.
80-
// Remove thier transform.
81-
if ( false && settings.name === 'syntaxhighlighter/code' ) {
79+
/*
80+
* The enhanced code block includes a "from" transform that handles things like language
81+
* name, line number settings, etc. Remove the "to" transform provided by syntaxhighlighter/code
82+
* so that simpler trnasform is not applied.
83+
*/
84+
if ( settings.name === 'syntaxhighlighter/code' ) {
8285
if ( settings.transforms?.to ) {
8386
settings.transforms.to = settings.transforms.to.filter(
84-
transform =>
87+
( transform: { type: string; blocks?: unknown } ) =>
8588
! (
8689
transform.type === 'block' &&
8790
Array.isArray( transform.blocks ) &&

0 commit comments

Comments
 (0)