定制 webkleur/builder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webkleur/builder

最新稳定版本:5.2.0

Composer 安装命令:

composer require webkleur/builder

包简介

A package to easily integrate GrapesJS into your laravel project.

README 文档

README

This package provide an easy way to integrate GrapesJS into your laravel project.

Installation

composer require go2digital/builder

Publish files & migrate

php artisan vendor:publish --tag="laravel-grapesjs"

php artisan migrate

Getting started

  1. Add 'gjs_data' column to the model's database table (e.g Page), for which you are going to use the editor.

  2. Implement Editable Interface and use the EditableTrait trait for the Model class

use Illuminate\Database\Eloquent\Model;
use Go2Digital\Builder\App\Traits\EditableTrait;
use Go2Digital\Builder\App\Contracts\Editable;

class Page extends Model implements Editable
{
    use EditableTrait;

    ...
}
  1. Next Create a Route for editor
Route::get('pages/{page}/editor', 'PageController@editor');
  1. In your controller, use the EditorTrait and add the editor method
<?php

namespace App\Http\Controllers;

use App\Models\Page;
use Illuminate\Http\Request;
use Go2Digital\Builder\App\Traits\EditorTrait;

class PageController extends Controller
{
    use EditorTrait;

    ...


    public function editor(Request $request, Page $page)
    {
        return $this->show_gjs_editor($request, $page);
    }

    ...
}
  1. Open this route /pages/:page_id/editor (where the :page_id is the id of your model)

Placeholders

Placeholders are like short-code in wordpress. The syntax of placeholder is

[[This-Is-Placeholder]]

Create a file named "this-is-placeholder.blade.php" in "/resources/views/vendor/laravel-grapesjs/placeholders" directory.

The placeholder will be replaced by the content of the relative blade file "this-is-placeholder.blade.php"

Templates

You can create global templates (or blocks) in the "/resources/views/vendor/laravel-grapesjs/templates" directory. And the templates/blocks will be available in the block section of editor. 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.

Display output

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.

统计信息

  • 总下载量: 150
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-02