Laraberg aims to provide an easy way to integrate the Gutenberg editor with your Laravel projects. It takes the Gutenberg editor and adds all the communication and data it needs function in a Laravel environment. A demo can be found at demo.laraberg.io. If you would like to see an example of how to implement Laraberg you can take a look at the code from the demo over here.
Table of Contents
Installation
Install package using composer:
composer require van-ons/laraberg
Add vendor files to your project (CSS, JS & Config):
php artisan vendor:publish --provider="VanOns\Laraberg\LarabergServiceProvider"
In order to store the data for the Gutenberg editor, Laraberg needs to run a database migration:
php artisan migrate
This will create the 'lb_contents' and 'lb_blocks' tables.
JavaScript and CSS files
The package provides a JS and CSS file that should be present on the page you want to use the editor on:
<link rel="stylesheet" href="{{asset('vendor/laraberg/css/laraberg.css')}}">
<script src="{{ asset('vendor/laraberg/js/laraberg.js') }}">script>
Dependencies
The Gutenberg editor expects React, ReactDOM, Moment and JQuery to be in the environment it runs in. An easy way to do this would be to add the following lines to your page:
<script src="https://unpkg.com/[email protected]/umd/react.production.min.js">script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js">script>
Updating
When updating Laraberg you have to publish the vendor files again by running this command:
php artisan vendor:publish --provider="VanOns\Laraberg\LarabergServiceProvider" --tag="public" --force
Usage
Initializing the Editor
The Gutenberg editor should replace an existing textarea in a form. On submit the raw content from the editor will be put in the 'value' attribute of this textarea.