Configuration

The Config object in Easyblocks is a central object that holds all the essential configuration settings. It's a parameter required by EasyblocksEditor (Editor Page) and buildDocument (Rendering Content).

import type { Config } from "@easyblocks/core";

export const easyblocksConfig: Config = {
  /* config properties */
};

Properties

Config.backend

Sets the backend service responsible for saving, updating and versioning documents and templates. Please read Backend guide to learn more.

import type { Config, EasyblocksBackend } from "@easyblocks/core";

const config: Config = {
  backend: new EasyblocksBackend({ accessToken: MY_ACCESS_TOKEN }),
  // ...
};

Config.components

All the No-Code Component Definitions available in your setup must be provided in components property:

import type { Config } from '@easyblocks/core';

const config: Config = {
  ...,
  components: [
    {
      id: 'MyNoCodeComponent',
      schema: [
        {
          prop: 'title',
          type: 'string',
          label: 'Title'
        }
      ]
    }
  ]
};

Config.devices

Devices object allows you reconfigure default devices provided by Easyblocks. Easyblocks comes with an opinionated list of devices:

  1. Mobile xs - max-width: 568px

  2. Mobile Horizontal sm - max-width: 768px

  3. Tablet md - max-width: 992px

  4. Tablet Horizontal lg - max-width: 1280px

  5. Desktop xl - max-width: 1600px

  6. Large desktop 2xl

You can switch between different devices using the device switch from the top bar of editor.

Device switch in the editor

By default, Mobile Horizontal and Tablet Horizontal are hidden as we find them unnecessary to be visible out of the box. If you would like to have more control over your breakpoints you can make them visible by setting hidden property:

Config.locales

List of available locales.

One of the locales must be alwyas set as default. This locale is going to be used as a fallback in cases where locale is missing or a translation for selected locale (different than default) is missing.

Config.types

Beside using built-in types provided by Eeasyblocks you can also define your own custom types for referencing external data. Learn more about custom types here.

Config.tokens

Each type in Easyblocks can be tokenised which means that a predefined list of variables (tokens) is always available in the field widgets. The tokens are defined via Config.tokens property.

The built-in types like color, font, space, aspectRatio, boxShadow, icon are tokenized. When you use any of those types please remember of defining its tokens (example below).

Your custom types can also be tokenised and you can create your own custom token scales.

config.templates

This property allows for setting templates. Read the Templates section to learn more.

Last updated