asayhome / asay-editor
该包最新版本(v0.0.1)没有提供许可证信息。
将配置的文本编辑器添加到Laravel应用中
v0.0.1
2022-07-17 19:48 UTC
README
将配置的文本编辑器添加到Laravel应用中。
需求
此包要求在项目中已经安装了livewire\livewire
包。
用法
composer require asayhome/asay-editor
- 此包包含了需要推送到你的blade中的样式和脚本,默认情况下,该包使用
after-scripts
标签用于脚本堆栈,after-scripts
用于样式堆栈,你必须在项目布局中添加以下内容
@stack('after-styles')
@stack('after-scripts')
或者你可以通过发布包配置文件来更改这些标签的名称,并在blade文件中更改
pushed-styles-container
pushed-scripts-container
的值
<livewire:asay-editor
id="textEditor"
language="ar"
:placeholder="__('Type your text her')"
content="Editor content her"
height="200px"
/>
在编辑器内部输入时,将自动触发包含输入内容的textChange
事件,你可以通过在包含编辑器的标签中添加firedEvent='EventName'
来更改此事件,如下所示
<livewire:asay-editor
id="textEditor"
language="ar"
:placeholder="__('Type your text her')"
content="Editor content her"
height="200px"
firedEvent="textChange"
/>
这是一个Livewire事件,你可以在blade文件中获取触发的内容,如下所示
<script>
Livewire.on('textChange',(content)=>{
console.log(content);
})
</script>
或者你可以在Livewire组件内部通过将事件添加到组件监听器数组中获取它,如下所示
protected $listeners = ['textChange'];
public function textChange($content)
{
...
}
发布配置
php artisan vendor:publish --tag=asayeditor-config
发布语言
php artisan vendor:publish --tag=asayeditor-lang
发布视图
php artisan vendor:publish --tag=asayeditor-views
发布资产
php artisan vendor:publish --tag=asayeditor-assets