A package to easily integrate GrapesJS into your laravel proejct.
ofyalcin/laravel-grapesjs is a Laravel package for a package to easily integrate grapesjs into your laravel proejct..
It currently has 0 GitHub stars and 5 downloads on Packagist.
Install it with composer require ofyalcin/laravel-grapesjs.
Discover more Laravel packages by ofyalcin
or browse all Laravel packages to compare alternatives.
Last updated
This package provide an esay way to integrate GrapesJS into your laravel proejct.
composer require ofyalcin/laravel-grapesjs
php artisan vendor:publish --tag="laravel-grapesjs"
php artisan migrate
Add 'gjs_data' column to the model's database table (e.g Page), for which you are going to use the editor.
Implement Editable Interface and use the EditableTrait trait for the Model class
use Illuminate\Database\Eloquent\Model;
use Dotlogics\Grapesjs\App\Traits\EditableTrait;
use Dotlogics\Grapesjs\App\Contracts\Editable;
class Page extends Model implements Editable
{
use EditableTrait;
...
}
Route::get('pages/{page}/editor', 'PageController@editor');
<?php
namespace App\Http\Controllers;
use App\Models\Page;
use Illuminate\Http\Request;
use Dotlogics\Grapesjs\App\Traits\EditorTrait;
class PageController extends Controller
{
use EditorTrait;
...
public function editor(Request $request, Page $page)
{
return $this->show_gjs_editor($request, $page);
}
...
}
Placeholders are like short-code in wordpress. The synax of placeholder is
[[This-Is-Placeholder]]
Create a file named "this-is-placeholder.blade.php" in "/resources/views/vendor/laravel-grapesjs/placeholders" directory.
The the placeholder will be replaced by the content of the relative blade file "this-is-placeholder.blade.php"
You can create global templates (or blocks) in the "/resources/views/vendor/laravel-grapesjs/templates" directory. And the templates/blocks will be availabe in the block section of edittor. You can also create model specific templates/blocks by defining getTemplatesPath/getGjsBlocksPath in model
public function getTemplatesPath(){ return 'pages_templates'; }
This will look for templates under "laravel-grapesj::pages_templates" directory.
You can also return null from these methods to hide templates/blocks for any model.
The "Editable" model (e.g. Page) will have two public properties, css and html. In your blade file you can use these properties to display the content.
<style type="text/css">
{!! $page->css !!}
</style>
{!! $page->html !!}
Thank you for using.