esign / 行内编辑
使用行内编辑来编辑文本和翻译
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- orchestra/testbench: ^6.0|^7.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-17 18:36:44 UTC
README
此包允许您在行内编辑您的网站文本和翻译。
安装
您可以通过composer安装此包
composer require esign/inline-edit
此包将自动注册服务提供者。
接下来,您可以发布配置文件
php artisan vendor:publish --provider="Esign\InlineEdit\InlineEditServiceProvider" --tag=config --tag=public
发布InlineEdit文件以便在您的前端中使用。
php artisan inline-editing:install
该文件将被复制到resources/assets/js/utils/InlineEdit.js
将以下内容添加到您的app.js
import InlineEdit from './utils/inlineEdit'; InlineEdit();
要使用富文本编辑器,在包含您的app.js
文件之前,在您的app.blade.php
文件中添加以下行以包含ckeditor cdn
<script src="https://cdn.ckeditor.com/ckeditor5/34.0.0/balloon/ckeditor.js"></script>
通过在您的app.blade.php
文件中添加以下行来使基本url公开。
<script>var base_url = '{{ config('app.url') }}';</script>
确保您有一个可访问的csrf令牌,请添加
<meta name="csrf-token" content="{{ csrf_token() }}">
通过添加以下内容来包含行内编辑css
<link rel="stylesheet" href="{{ asset('assets/css/inline-edit.css') }}">
用法
此包假设您在数据库中有一个包含以下必需列(term, type, value
)的翻译表。默认表是dictionary
,但可以通过更改配置文件中的指定表更改为任何其他表。
您可以通过在blade文件中调用以下函数来使用行内编辑器
{!! esign_inline('term') !!}
根据术语的类型,将加载富文本编辑器。支持的类型是text, richtext
!! 重要 !!
保护行内编辑路由很重要,以确保只有管理员才能使用此功能。此包不处理认证
您可以在配置文件中添加一个中间件来处理认证。
可用选项默认限于'styles', 'bold', 'italic', 'link', 'blockQuote'
,但可以在inlineEdit.js
文件中扩展。
有关所有可用选项,请检查:https://ckeditor.npmjs.net.cn/docs/ckeditor5/latest/api/module_core_editor_editorconfig-EditorConfig.html
测试
composer test
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。