Skip to main content

Course Progress

Loading...

Mastering the Gutenberg Block Editor

Duration: 60 minutes
Module 4: Session 7.2

Learning Objectives

  • Master all Gutenberg block categories and types
  • Understand block toolbars and settings panels
  • Navigate efficiently with List View and Outline
  • Learn essential keyboard shortcuts
  • Optimize workflow with productivity tips
  • Troubleshoot common block issues

Understanding the Block Editor Interface

The Gutenberg Block Editor transforms content creation into a modular, visual experience. Each piece of content—from paragraphs to complex layouts—is a discrete block that can be manipulated independently.

🎯
Block Philosophy
Everything is a block. This simple concept powers infinite possibilities. Blocks can be nested, grouped, styled, and reused, making complex layouts achievable without code.

Block Categories and Types

mindmap root((Gutenberg Blocks)) Text Paragraph Heading List Quote Code Preformatted Verse Table Media Image Gallery Audio Video File Cover Media & Text Design Columns Group Row Stack Separator Spacer Page Break Widgets Shortcode Archives Calendar Categories Latest Posts RSS Search Tag Cloud Theme Navigation Site Logo Site Title Query Loop Post Template Comments Embeds YouTube Twitter Facebook Instagram WordPress SoundCloud Spotify TED

Essential Text Blocks

Block Use Case Key Features Shortcut
Paragraph Body text Drop cap, font size, colors /paragraph or /p
Heading Section titles H1-H6 levels, alignment /heading or /h2
List Bullet/numbered items Nested lists, start value /list
Quote Citations Citation field, styles /quote
Code Code snippets Syntax preservation /code

Media Blocks Detailed

// Programmatically insert media blocks
wp.data.dispatch('core/block-editor').insertBlocks([
    wp.blocks.createBlock('core/image', {
        url: 'https://example.com/image.jpg',
        alt: 'Description',
        caption: 'Image caption',
        sizeSlug: 'large',
        linkDestination: 'none'
    }),
    
    wp.blocks.createBlock('core/gallery', {
        images: [
            { url: 'image1.jpg', id: 1 },
            { url: 'image2.jpg', id: 2 }
        ],
        columns: 3,
        imageCrop: true,
        linkTo: 'media'
    }),
    
    wp.blocks.createBlock('core/video', {
        src: 'video.mp4',
        poster: 'poster.jpg',
        autoplay: false,
        loop: false,
        muted: false,
        controls: true
    })
]);

Block Toolbar Mastery

Each block has a contextual toolbar with specific controls:

Universal Toolbar Options

Move Up
Move Down
Change Alignment
🔄 Transform Block
More Options

Block-Specific Toolbars

// Customize block toolbar programmatically
wp.hooks.addFilter(
    'editor.BlockEdit',
    'my-plugin/custom-toolbar',
    wp.compose.createHigherOrderComponent(BlockEdit => {
        return props => {
            const { name } = props;
            
            if (name !== 'core/paragraph') {
                return React.createElement(BlockEdit, props);
            }
            
            return React.createElement(
                React.Fragment,
                null,
                React.createElement(
                    BlockControls,
                    null,
                    React.createElement(
                        ToolbarGroup,
                        null,
                        React.createElement(ToolbarButton, {
                            icon: "admin-customizer",
                            label: "Custom Action",
                            onClick: () => {
                                // Custom action
                            }
                        })
                    )
                ),
                React.createElement(BlockEdit, props)
            );
        };
    })
);

Block Settings Panel

The right sidebar provides detailed block customization:

Common Settings

Typography

  • Font Size
  • Line Height
  • Letter Spacing
  • Text Transform
  • Font Family (theme-dependent)

Color

  • Text Color
  • Background Color
  • Link Color
  • Gradient Background
  • Overlay Color

Dimensions

  • Padding
  • Margin
  • Width Settings
  • Height Control
  • Border Radius

Advanced

  • HTML Anchor
  • CSS Classes
  • Visibility Settings
  • Animation (plugin)
  • Custom Attributes

Accessing Settings via Code

// Get and set block attributes
const block = wp.data.select('core/block-editor').getBlock(blockId);

// Update block attributes
wp.data.dispatch('core/block-editor').updateBlockAttributes(
    blockId,
    {
        fontSize: 'large',
        textColor: 'primary',
        backgroundColor: 'secondary',
        className: 'custom-class featured-content',
        anchor: 'section-1'
    }
);

// Get all blocks with specific attributes
const blocks = wp.data.select('core/block-editor').getBlocks();
const headings = blocks.filter(block => 
    block.name === 'core/heading' && 
    block.attributes.level === 2
);

Navigation and List View

Efficiently navigate complex documents with these tools:

🗺️
List View (Document Outline)
Access withShift + Alt + Oor the List View button. Shows hierarchical structure of all blocks, allows drag-and-drop reorganization, and enables bulk selection.

Navigation Shortcuts

Action Windows/Linux Mac
Open List View Shift + Alt + O ⌃ ⌥ O
Navigate to nearest toolbar Alt + F10 ⌥ F10
Navigate between blocks Arrow Keys Arrow Keys
Select parent block Esc Esc
Select all blocks Ctrl + A(twice) ⌘ A(twice)

Advanced Navigation Techniques

// Navigate blocks programmatically
// Select next block
wp.data.dispatch('core/block-editor').selectNextBlock();

// Select previous block
wp.data.dispatch('core/block-editor').selectPreviousBlock();

// Select specific block
wp.data.dispatch('core/block-editor').selectBlock(blockClientId);

// Multi-select blocks
wp.data.dispatch('core/block-editor').multiSelect(startBlockId, endBlockId);

// Clear selection
wp.data.dispatch('core/block-editor').clearSelectedBlock();

// Focus on a specific block
const blockElement = document.querySelector(`[data-block="${blockClientId}"]`);
blockElement?.focus();

Essential Keyboard Shortcuts

🎯 Block Management

/ Quick insert
Enter New paragraph
Shift + Enter Line break
Ctrl + Alt + T Insert before
Ctrl + Alt + Y Insert after

✏️ Text Formatting

Ctrl + B Bold
Ctrl + I Italic
Ctrl + K Link
Ctrl + U Underline
Shift + Alt + X Strikethrough

🔄 Block Actions

Ctrl + Shift + D Duplicate
Shift + Alt + Z Remove block
Ctrl + Alt + M Move mode
Ctrl + G Group blocks
Ctrl + Shift + G Ungroup

Custom Keyboard Shortcuts

// Register custom keyboard shortcuts
wp.data.dispatch('core/keyboard-shortcuts').registerShortcut({
    name: 'custom/insert-special-block',
    category: 'block',
    description: 'Insert special block',
    keyCombination: {
        modifier: 'primary',
        character: 'j'
    }
});

// Handle custom shortcut
wp.data.subscribe(() => {
    const isPressed = wp.data.select('core/keyboard-shortcuts')
        .isShortcutPressed('custom/insert-special-block');
    
    if (isPressed) {
        wp.data.dispatch('core/block-editor').insertBlocks(
            wp.blocks.createBlock('my-plugin/special-block')
        );
    }
});

Block Transforms and Conversions

Transform blocks between compatible types:

graph LR P[Paragraph] <--> H[Heading] P <--> L[List] P <--> Q[Quote] I[Image] <--> G[Gallery] I <--> C[Cover] I <--> MT[Media & Text] Co[Columns] <--> Gr[Group] Gr <--> R[Row] Gr <--> S[Stack]

Transform Examples

// Transform block programmatically
const transforms = wp.blocks.getBlockTransforms('from', 'core/paragraph');

// Apply transform
const headingBlock = wp.blocks.switchToBlockType(
    paragraphBlock,
    'core/heading'
);

// Batch transform multiple blocks
const blocks = wp.data.select('core/block-editor').getMultiSelectedBlocks();
const transformedBlocks = blocks.map(block => 
    wp.blocks.switchToBlockType(block, 'core/list')[0]
);

wp.data.dispatch('core/block-editor').replaceBlocks(
    blocks.map(b => b.clientId),
    transformedBlocks
);

Productivity Tips and Tricks

🚀 Speed Tips

  • Use/for quick block insertion
  • Type---for separator
  • Start line with#for heading
  • Start with*or-for list
  • Type```for code block
  • Use>for quote block

🎨 Styling Tips

  • Hold Shift while resizing to maintain ratio
  • Use keyboard for precise nudging
  • Copy styles with block settings clipboard
  • Apply styles to multiple blocks at once
  • Save custom styles as reusable blocks

🔧 Workflow Tips

  • Use Spotlight mode for focus
  • Enable Top Toolbar for more space
  • Customize editor preferences
  • Use Code Editor view for bulk edits
  • Create block patterns for common layouts

Troubleshooting Common Issues

Block Validation Errors

// Fix block validation errors
wp.blocks.registerBlockType('core/paragraph', {
    ...wp.blocks.getBlockType('core/paragraph'),
    deprecated: [
        {
            attributes: {
                // Old attributes
            },
            migrate(attributes) {
                return {
                    ...attributes,
                    // Updated attributes
                };
            },
            save(props) {
                // Old save function
            }
        }
    ]
});

// Attempt block recovery
const isValid = wp.blocks.isValidBlockContent(
    blockType,
    blockAttributes,
    innerHTML
);

if (!isValid) {
    const recovered = wp.blocks.getBlockContent(
        wp.blocks.createBlock(blockType, blockAttributes)
    );
}

Common Issues and Solutions

Issue Cause Solution
Block won't delete JS error or frozen state Use List View to remove
Can't select block Overlapping elements Use List View or Tab key
Lost toolbar Focus issue Press Alt + F10
Slow performance Too many blocks Use pagination or lazy loading
Block validation error Modified HTML Attempt recovery or recreate

Gutenberg Best Practices

  • Plan your structure:Outline content hierarchy before building
  • Use semantic blocks:Choose appropriate blocks for content type
  • Group related blocks:Use Group, Columns, or Row for organization
  • Save patterns:Create reusable blocks for repeated layouts
  • Optimize media:Compress images before uploading
  • Test responsiveness:Preview on different screen sizes
  • Regular saves:Let autosave work, but save manually for important changes
  • Use keyboard shortcuts:Learn shortcuts for efficiency

Real World: Building a Landing Page

// Creating a landing page structure programmatically
const landingPageBlocks = [
    // Hero Section
    wp.blocks.createBlock('core/cover', {
        url: 'hero-background.jpg',
        dimRatio: 50,
        minHeight: 500,
        align: 'full'
    }, [
        wp.blocks.createBlock('core/heading', {
            content: 'Welcome to Our Service',
            level: 1,
            textAlign: 'center'
        }),
        wp.blocks.createBlock('core/paragraph', {
            content: 'Your success starts here',
            align: 'center',
            fontSize: 'large'
        }),
        wp.blocks.createBlock('core/buttons', {}, [
            wp.blocks.createBlock('core/button', {
                text: 'Get Started',
                url: '#signup',
                className: 'is-style-fill'
            })
        ])
    ]),
    
    // Features Section
    wp.blocks.createBlock('core/group', {
        align: 'wide',
        backgroundColor: 'tertiary'
    }, [
        wp.blocks.createBlock('core/heading', {
            content: 'Features',
            level: 2,
            textAlign: 'center'
        }),
        wp.blocks.createBlock('core/columns', {}, [
            wp.blocks.createBlock('core/column', {}, [
                wp.blocks.createBlock('core/heading', {
                    content: 'Fast',
                    level: 3
                }),
                wp.blocks.createBlock('core/paragraph', {
                    content: 'Lightning fast performance'
                })
            ]),
            wp.blocks.createBlock('core/column', {}, [
                wp.blocks.createBlock('core/heading', {
                    content: 'Secure',
                    level: 3
                }),
                wp.blocks.createBlock('core/paragraph', {
                    content: 'Enterprise-level security'
                })
            ]),
            wp.blocks.createBlock('core/column', {}, [
                wp.blocks.createBlock('core/heading', {
                    content: 'Scalable',
                    level: 3
                }),
                wp.blocks.createBlock('core/paragraph', {
                    content: 'Grows with your business'
                })
            ])
        ])
    ])
];

// Insert all blocks
wp.data.dispatch('core/block-editor').insertBlocks(landingPageBlocks);

Practice Exercise

Create a blog post layout using only keyboard shortcuts:

  1. Type/headingand add a title
  2. PressEnterthen/imagefor featured image
  3. Add paragraphs withEnter
  4. Create a list with-at line start
  5. Add a quote with/quote
  6. Group sections withCtrl + G
  7. UseShift + Alt + Oto review structure
  8. Apply formatting withCtrl + BandCtrl + I