hovornyan/laravel-grapesjs
Composer 安装命令:
composer require hovornyan/laravel-grapesjs
包简介
A package for use Grapes.js in Laravel
README 文档
README
composer require hovornyan/laravel-grapesjs
Publish files
php artisan vendor:publish --provider="Dotlogics\Grapesjs\GrapesjsServiceProvider"
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan migrate
npm i grapesjs
npm i grapesjs-blocks-basic
npm i grapesjs-blocks-bootstrap4
npm i grapesjs-tui-image-editor
npm i toastr
Get Start
-
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; ... }
- Next Create a Route for editor
Route::get('pages/{page}/editor', 'PageController@editor');
- 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 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); } ... }
- 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 synax of placeholder is
[[This-Is-Placeholder]]
Create a file named "this-is-placeholder.blade.php" in "/resources/views/vendor/grapesjs/placeholders" directory.
The the placeholder will be replaced by the content of the relative blade file "this-is-placeholder.blade.php"
Templates
You can create a template (a block) in the "/resources/views/vendor/grapesjs/templates" directory. And the templates will be availabe in the block section of edittor.
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.
hovornyan/laravel-grapesjs 适用场景与选型建议
hovornyan/laravel-grapesjs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hovornyan/laravel-grapesjs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hovornyan/laravel-grapesjs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-12