Giter VIP home page Giter VIP logo

easy-gutenberg-bundle's Introduction

Adeliom Quality gate

Easy Gutenberg Bundle

Provide Wordpress's Gutenberg Editor into Easyadmin.

Versions

Repository Branch Version Symfony Compatibility PHP Compatibility Status
2.x 2.x 5.4, and 6.x 8.0.2 or higher New features and bug fixes

Installation with Symfony Flex

Add our recipes endpoint

{
  "extra": {
    "symfony": {
      "endpoint": [
        "https://api.github.com/repos/agence-adeliom/symfony-recipes/contents/index.json?ref=flex/main",
        ...
        "flex://defaults"
      ],
      "allow-contrib": true
    }
  }
}

Install with composer

composer require agence-adeliom/easy-gutenberg-bundle

Documentation

Use GutenbergField

Go to your crud controller, example : src/Controller/Admin/PageCrudController.php

<?php

namespace App\Controller\Admin;

...
use App\Entity\EasyFaq\Entry;
use App\Entity\EasyFaq\Category;

abstract class PageCrudController extends AbstractCrudController
{
    ...
    
    public function configureCrud(Crud $crud): Crud
    {
        return parent::configureCrud($crud)
            // Add the form theme
            ->addFormTheme('@EasyGutenberg/form/gutenberg_widget.html.twig')
            ;
    }
    
    public function configureFields(string $pageName): iterable
    {
        ...
        yield GutenbergField::new("content");
        ...

Create a new Block

php bin/console make:gutenberg

Then setup your form field

<?php

namespace App\Blocks;

use Adeliom\EasyGutenbergBundle\Blocks\AbstractBlockType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

class TwoColsType extends AbstractBlockType
{
    public function buildBlock(FormBuilderInterface $builder, array $options): void
    {
        $builder->add("left_col", TextType::class, ["label" => 'Left column content']);
        $builder->add("right_col", TextType::class, ["label" => 'Right column content']);
    }

    public static function getName(): string
    {
        return 'Two columns';
    }

    public static function getDescription(): string
    {
        return 'Make a two columns layout';
    }

    public static function getIcon(): string
    {
        return '';
    }

    public static function getTemplate(): string
    {
        return "blocks/two_cols.html.twig";
    }
}

Frontend usage

In your template you can use these functions :

# This convert and render the content 
{{ easy_gutenberg(page.content) }}

# This render the blocks's assets must be called after 'easy_gutenberg'
{{ easy_gutenberg_assets() }}

Extra features

Add frontend assets

    public static function configureAssets(): array
    {
        return [
            'js' => [],
            'css' => [],
            'webpack' => [],
        ];
    }

Add backend assets

    public static function configureAdminAssets(): array
    {
        return [
            'js' => [],
            'css' => [],
        ];
    }

Add extra form themes

    public static function configureAdminFormTheme(): array
    {
        return [];
    }

Specify a category

The provided categories are:

  • common
  • text
  • media
  • design
  • widgets
  • theme
  • embed
    public static function getCategory(): string
    {
        return 'common';
    }

Specify variations

    public static function getVariations(): array
    {
        return [
            [
                "name": 'variation_with_bg',
                "isDefault": true,
                "title": "Variation With background",
                "icon": '',
                "attributes": [
                    "with-bg": true
                ],
            ]
        ];
    }

Specify extra attributes

    public static function getAttributes(): array
    {
        return [
             "with-bg" => ['type' => 'boolean']
        ];
    }

Specify supports

Allowed supports are :

    public static function getSupports(): array
    {
        return array_merge(parent::getSupports(),[
            'align' => false,
        ]);
    }

License

MIT

Authors

easy-gutenberg-bundle's People

Contributors

arnaud-ritti avatar dependabot[bot] avatar jdadeliom avatar jeandaviddaviet avatar jeromeengeln avatar lucasvigneron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

easy-gutenberg-bundle's Issues

Two columns block

Hi,
How to create a 2 column block so that other blocks can be inserted into this block?

Multiple gutenberg fields on one easyadmin field.

Hi,

I wonder if its possible to get two gutenberg fields working on one admin page. The question is because i want to work with translation fields and have each translation work with one gutenberg field.

However if i try to do so the content of all the gutenberg fields are kept in sync. So i cannot change the content per locale without changing the other ones. Probably its a small thing to change this, but i cannot seem to find the right place to search for.

Regards,
Stefan

Language issue

Gutenberg language is always french, is there way to change to english?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.