ElementorexCms.Registry (ElementorexCms v0.1.0)

Copy Markdown View Source

The set of blocks a document can use.

default/0 is the built-in blocks plus the ones configured by your app:

config :elementorex_cms,
  # your blocks, added to the built-in ones (same type = replaces it)
  blocks: [MyAppWeb.Blocks.Pricing, MyAppWeb.Blocks.Whatsapp],
  # built-in types to leave out
  exclude_blocks: ["video", "mockup"]

A registry can also be built for one editor or page with new/2, e.g. to offer fewer blocks in a modal than in a landing page:

registry = ElementorexCms.Registry.new(only: ~w(heading text button image alert))

Summary

Functions

Whether a node of child_type may go inside a node of parent_type, per the :children option of the parent and the :parents option of the child.

Built-in block modules.

Palette categories of the built-in blocks, in display order.

Whether the type is a container block.

The built-in blocks plus the configured ones (see the module docs).

The module of a block type, or nil.

Block modules in registration order.

Builds a registry.

Blocks shown in the palette grouped by category: [{category, [module]}], built-in categories first, then the custom ones in order of appearance.

Types

t()

@type t() :: %ElementorexCms.Registry{
  blocks: %{required(String.t()) => module()},
  order: [String.t()]
}

Functions

accepts?(registry, parent_type, child_type)

@spec accepts?(t(), String.t(), String.t()) :: boolean()

Whether a node of child_type may go inside a node of parent_type, per the :children option of the parent and the :parents option of the child.

builtin()

@spec builtin() :: [module()]

Built-in block modules.

categories()

@spec categories() :: [atom()]

Palette categories of the built-in blocks, in display order.

container?(registry, type)

@spec container?(t(), String.t()) :: boolean()

Whether the type is a container block.

default()

@spec default() :: t()

The built-in blocks plus the configured ones (see the module docs).

fetch(arg1, type)

@spec fetch(t() | nil, String.t() | nil) :: module() | nil

The module of a block type, or nil.

list(registry)

@spec list(t()) :: [module()]

Block modules in registration order.

new(opts \\ [])

@spec new(keyword()) :: t()

Builds a registry.

  • :blocks - block modules (default: the built-in ones plus the configured)
  • :only - keep only these types (the root is always kept)
  • :exclude - leave out these types

palette(registry)

@spec palette(t()) :: [{atom(), [module()]}]

Blocks shown in the palette grouped by category: [{category, [module]}], built-in categories first, then the custom ones in order of appearance.