Slide 1

Slide 1 text

Think Outside The Block @ChrisVanPatten

Slide 2

Slide 2 text

The other ways you can extend Gutenberg

Slide 3

Slide 3 text

Gutenberg is all about Blocks

Slide 4

Slide 4 text

Composable units that allow you to build page content (and soon page layouts) blocks (noun)

Slide 5

Slide 5 text

Blocks are the building blocks, but you don't have to build blocks to customise the block editor

Slide 6

Slide 6 text

Developers are used to the Classic Experience

Slide 7

Slide 7 text

Metaboxes

Slide 8

Slide 8 text

Metaboxes TinyMCE

Slide 9

Slide 9 text

Metaboxes TinyMCE Hooks and filters

Slide 10

Slide 10 text

Metaboxes TinyMCE Hooks and filters

Slide 11

Slide 11 text

Gutenberg offers curated customisation

Slide 12

Slide 12 text

Not everything from the past is possible today, but a lot is… and more!

Slide 13

Slide 13 text

Block Styles Editor Settings Formats Sidebars Slots & Fills Automations

Slide 14

Slide 14 text

CSS-based presets for block visual appearance block styles (noun)

Slide 15

Slide 15 text

One style can be active at a time

Slide 16

Slide 16 text

Users can select a default

Slide 17

Slide 17 text

Can be registered when you create a block, or added by third parties

Slide 18

Slide 18 text

Can also be removed by third parties

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

register_block_style( 'core/quote', [ 'name' => 'cool-design', 'label' => __( 'Cool Design' ), 'inline_style' => '' . '.wp-block-quote.is-style-cool-design {' . 'background: red;' . 'border: 3px solid blue;' . 'padding: 1rem;' . '}', ] );

Slide 21

Slide 21 text

unregister_block_style( 'core/quote', 'fancy-quote' );

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Custom toggles and settings shared across blocks and editors editor settings (noun)

Slide 24

Slide 24 text

add_theme_support( 'disable-custom-colors' );

Slide 25

Slide 25 text

$colors = [ [ 'name' => 'Brand Red', 'slug' => 'brand-red', 'color' => '#B86251', ], ]; add_theme_support( 'editor-color-palette', $colors );

Slide 26

Slide 26 text

add_theme_support( 'disable-custom-font-sizes' );

Slide 27

Slide 27 text

$sizes = [ [ 'name' => 'Super Large', 'slug' => 'super-large', 'size' => 80, ], ]; add_theme_support( 'editor-font-sizes', $sizes );

Slide 28

Slide 28 text

Inline HTML "modifiers" for selections of text formats (noun)

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

import { applyFormat } from '@wordpress/rich-text'; import { RichTextToolbarButton } from '@wordpress/editor'; const MyFormat = ( { isActive, onChange, value } ) => ( onChange( applyFormat( value, { type: 'wcphx/fancy-text' } ) ) } title="Fancy Text" /> );

Slide 31

Slide 31 text

import { registerFormatType } from '@wordpress/rich-text'; import MyFormat from './my-format'; registerFormatType( 'wcphx/fancy-text', { className: 'wcphx-fancy-text', edit: MyFormat, tagName: 'span', title: 'Fancy Text', }, );

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Special link formats (e.g. for affiliate links) Superscript and subscript Footnotes

Slide 34

Slide 34 text

Wide open (narrow) free space sidebars (noun)

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post'; import { registerPlugin } from '@wordpress/plugins'; const name = 'wcphx-sidebar'; const title = 'WordCamp Phoenix'; const icon = 'smiley';

Slide 37

Slide 37 text

const Sidebar = () => ( <> { title }

Slide 38

Slide 38 text

Hello Phoenix! > );

Slide 39

Slide 39 text

registerPlugin( 'wcphx-sidebar', { render: Sidebar, }, );

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Defined extension areas within the editor slots and fills (noun)

Slide 42

Slide 42 text

PluginPostStatusInfo

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

PluginDocumentSettingPanel

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

PluginBlockSettingsMenuItem

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

PluginPrePublishPanel & PluginPostPublishPanel

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

PluginMoreMenuItem

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Actions executed programmatically automations (noun)

Slide 54

Slide 54 text

Inserting blocks Opening sidebars Moving blocks Applying formats Saving and Publishing

Slide 55

Slide 55 text

import { createBlock } from '@wordpress/blocks'; import { Button } from '@wordpress/components'; import { dispatch } from '@wordpress/data'; import { PluginDocumentSettingPanel } from '@wordpress/edit-post'; import { registerPlugin } from '@wordpress/plugins';

Slide 56

Slide 56 text

const DemoPanel = () => ( ... );

Slide 57

Slide 57 text

{ const { editPost, insertBlocks, } = dispatch( 'core/editor' ); const block = createBlock( 'wcphx/demo' ); editPost( { title: 'WordCamp Phoenix!' } ); insertBlocks( block ); } } > Insert New Demo Block

Slide 58

Slide 58 text

registerPlugin( 'wcphx-demo-automation-panel', { render: DemoPanel, }, );

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

Powerful extension options

Slide 61

Slide 61 text

New ideas and new capabilities

Slide 62

Slide 62 text

What can you come up with?

Slide 63

Slide 63 text

thanks!

Slide 64

Slide 64 text

@ChrisVanPatten cvp.me/wcphx2020