Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable filter hooks for convertLegacyBlockNameAndAttributes #40749

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/blocks/src/api/parser/convert-legacy-block.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* WordPress dependencies
*/
import { applyFilters } from '@wordpress/hooks';

/**
* Convert legacy blocks to their canonical form. This function is used
* both in the parser level for previous content and to convert such blocks
Expand Down Expand Up @@ -67,5 +72,8 @@ export function convertLegacyBlockNameAndAttributes( name, attributes ) {
name = 'core/comment-date';
}

return [ name, newAttributes ];
return applyFilters( 'editor.convertLegacyBlockNameAndAttributes', [
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document the filter in the code with JSDoc? For reference, this is how filters get documented in WordPress core:

https://github.com/WordPress/wordpress-develop/blob/e94cd298c6e0208a5feb888099601feadf460eda/src/wp-includes/blocks.php#L262-L269

We should also include a new section in this document:

https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/filters/block-filters.md#block-editor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great. Cc @ryanwelcher.

name,
newAttributes,
] );
}