Home › Forums › WoodMart support forum › How to change the Gutenberg defalt title block into heading block when pasting

How to change the Gutenberg defalt title block into heading block when pasting

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #710236

    HARSLE
    Participant

    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.
    #710445

    Artem Temos
    Participant

    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

    #710447

    HARSLE
    Participant

    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.
    #710455

    Artem Temos
    Participant

    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);
    	});
Viewing 4 posts - 1 through 4 (of 4 total)