How to change the Gutenberg defalt title block into heading block when pasting
-
After the update of the theme, I have the problem with the Gutenberg editor. When I pasted the the text to the Gutenberg editor, the heading will change into the theme title block. but it was heading block before, how can I transform the heading block. because I want to set different heading formats for each heading.
Attachments:
You must be
logged in to view attached files.
Hello,
Try to add the following PHP code snippet to the child theme functions.php file to do this
add_action('enqueue_block_editor_assets', function() {
$custom_js = "
wp.hooks.addFilter(
'blocks.registerBlockType',
'wd/remove-wd-title-transforms',
function(settings, name) {
if (name === 'wd/title') {
return Object.assign({}, settings, {
transforms: {}
});
}
return settings;
}
);
";
wp_add_inline_script('wp-blocks', $custom_js);
});
Kind Regards
The heading problem was solved, I also want to solve the same problem for paragraph, please give me the solultion, thanks
Attachments:
You must be
logged in to view attached files.
Please try to replace the previous code with the following
add_action('enqueue_block_editor_assets', function() {
$custom_js = "
wp.hooks.addFilter(
'blocks.registerBlockType',
'wd/remove-wd-title-transforms',
function(settings, name) {
if (name === 'wd/title' || name === 'wd/paragraph') {
return Object.assign({}, settings, {
transforms: {}
});
}
return settings;
}
);
";
wp_add_inline_script('wp-blocks', $custom_js);
});