ckeditor - 如何在 Laravel 6 中使用 CKEditor 5?
问题描述
我可以使用 CKEditor 4,但我根本不能使用 CKEditor 5。我尝试通过从 CDN 下载/node_modules
或使用 CDN 来使用。我尝试以与使用 CKEditor 4 相同的方式使用它,但它不起作用。
<script src="https://cdn.ckeditor.com/ckeditor5/12.4.0/classic/ckeditor.js"></script>
<script>
CKEDITOR.replace('classic-ckeditor5')
</script>
我尝试将其加载到我的create.blade.php.
@extends('layouts.app')
@section('content')
<h1>Create Post</h1>
{!! Form::open(['action' => 'PostsController@store', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('title', 'Title') }}
{{ Form::text('title', '', ['class' => 'form-control', 'placeholder' => 'Title']) }}
</div>
<div class="form-group">
{{ Form::label('body', 'Body')}}
{{ Form::textarea('body', '', ['id' => 'classic-ckeditor5',
'class' => 'form-control', 'placeholder' => 'Body Text']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
<!-- when submit button clicked the data will get send to store in PostsController -->
{!! Form::close() !!}
@endsection
但这也没有用。
解决方案
CKEditor 5 改变了他们实例化插件的方式。
早些时候(CKEditor <= 4.*),它是:
CKEditor.replace('<name of the textarea box>')
现在在 CKeditor >= 5.* 中,它是:
ClassicEditor
.create(document.querySelector(<id of the textarea field>))
.catch(error => {
console.error(error);
});
您可以将 ClassicEditor 替换为您正在使用的任何类型的编辑器。
有关更多信息,请查看此 CKEditor 页面
推荐阅读
- typescript - 如何对存储在 user.uid 下的 Firebase 值进行排序?
- hyperledger - Hyperledger explorer 启动问题-orderer 端口通信问题
- angularjs - Ajax 请求失败 500 内部服务器错误
- html - 我想使用 Bootstrap 将“div”居中在另一个有背景和“span”的地方?
- laravel-5.7 - 使用来自 /sender 地址 laravel 5.7 的 Mailer
- firebase - FirebaseUI 取消按钮点击回调
- ios - 如何从原生 ios 视图弹回颤振视图?
- android - 如何修复 android media CursorLoader 无法检测数据文件夹中的媒体文件
- amazon-web-services - AWS DynamoDB。我是否过度使用了我的写入容量?
- angular - 授权不记名令牌Angular 6不起作用