razaqofficial/laravel-inline-editor
Composer 安装命令:
composer require razaqofficial/laravel-inline-editor
包简介
Laravel package, which allows inline editing of model specific content blocks.
README 文档
README
Simple inline editor toolbar, to update the content of any HTML block, or specific DB table.
This package is an updated version of dyusha/laravel-html-editor with some additional functionality and updated dependencies.
Installation
Download this git repo, or install it via composer:
composer require razaqofficial/laravel-inline-editor
Also make sure to get our npm dependencies:
npm install vue vue-resource medium-editor vue-sweetalert2 --save
Configuration
Note, Optional in
Laravel 5.5 or +
Add the following to your config file:
// config/app.php 'providers' => [ ... razaqofficial\LaravelInlineEditor\InlineEditorServiceProvider::class, ],
Initial Setup
Run:
php artisan vendor:publish
- Include the following code snippet into your applications layout file, eg: "view/layouts/app.blade.php". This will render the required controls on your page.
{{-- Start Laravel Inline Editor Components --}} @include('laravel-inline-editor::html-manager') {{-- End Laravel Inline Editor Components --}}`
- Afterwards apply our default table with:
php artisan migrate
-
By default editing is allowed only for users who have
laravel-inline-editorability, so you should add it in yourAuthServiceProvider// app/Providers/AuthServiceProvider.php use Illuminate\Contracts\Auth\Access\Gate as GateContract; public function boot(GateContract $gate) { //... $gate->define('laravel-inline-editor', function ($user) { // Add your logic here return true; }); }
-
Include provided .scss and .js files on the page using your preferred build tools. For laravel mix:
// resources/assets/js/app.js Vue.component('inlineManager', require('./components/laravel-inline-editor/manager')); Vue.component('inlineContentBlock', require('./components/laravel-inline-editor/contentBlock.vue'));
// resources/assets/sass/app.scss // Inline Editor @import "./plugins/_medium-editor.scss";
Customization
You can publish the configuration files of the package, to tweak its behaviour or appearance:
php artisan vendor:publish
To change the default behaviour of the medium editor simply override the options setting in the config file:
// config/laravel-inline-editor.php 'options' => '{ \'anchor\': { \'targetCheckbox\': true }, \'toolbar\': { \'buttons\': [\'bold\', \'italic\', \'underline\'] } }',
By default js and sass assets will be published to /resources/assets/js/components and
/resources/assets/sass/plugins directories respectively.
To change this, just update the following paths in your config file:
// config/laravel-inline-editor.php 'paths' => [ 'js' => base_path('/resources/assets/js/components'), 'sass' => base_path('/resources/assets/sass/plugins'), ],
Usage
This package provides custom Blade directives @inlineEditor and @endInlineEditor which can be used to wrap blocks of HTML that should be editable.
For example if somewhere in your template you will have the following code:
Simple
Saves the containing HTML content in the laravel-inline-editor table under the key item01.
{{-- Simple Content Block --}}
@inlineEditor( 'item01' )
<p>Lorem text for our text block</p>
@endInlineEditor
Custom Table
To save the containing HTML in a custom table, just specify, the table name, source & target keys.
If no source, or target keys are defined the defaults key and content will be used.
{{-- Custom Database Content Block --}}
{{-- $source_value, $table, $source_key, $target_key, $options --}}
@inlineEditor('example_item', 'example_objects', 'title', 'content' )
{{ \Illuminate\Support\Facades\DB::table('example_objects')->where('title', 'example_item')->first() }}
@endInlineEditor
Custom Options
You can override the default options for the medium editor by overriding the default options:
{{-- Shows the usage of the options property --}}
@inlineEditor( 'item01', null, null, null, "{ 'anchor': { 'targetCheckbox': true }, 'toolbar': { 'buttons': ['bold', 'italic', 'underline'] } }" )
<p>Lorem text for our text block</p>
@endInlineEditor
For details check the medium js documentation: https://github.com/yabwe/medium-editor#mediumeditor-options
Note Look at the configuration settings to override the default options
Properties
- Source Value - DB row, where we are looking for our source key.
- Table - will override at which table we are looking for the above defined value.
- Source Key - allow overwriting the DB row at which we are looking for our source value.
- Target Key - allow overwriting the DB row at which will be updated.
- Editor Options - allows you to specify additional options for the medium editor.
- Validation Rules - Allows you to define a set of custom validation rules.
- Strip HTML - Strips all HTML elements from the given input string, before saving it into the DB.
The first time it's being rendered directive will try to find the content of your element by its defined key in the default database, if not specified otherwise. If it is present then its content will be rendered on the page.
Otherwise new HTML block will be created with the given parameters.
You can put any HTML markup between @inlineEditor and @endInlineEditor directives.
Workflow
When you press Accept changes button <html-manager> component will send POST request to /inline-content-block with blocks param that will contain all changed HTML blocks.
License
This library is licensed under the MIT license. Please see LICENSE for more details.
razaqofficial/laravel-inline-editor 适用场景与选型建议
razaqofficial/laravel-inline-editor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 razaqofficial/laravel-inline-editor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 razaqofficial/laravel-inline-editor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-03