我正在使用laravel创建一个新的Blog Web应用程序。在这个应用程序中,需要一个编辑器来创建博客文章,因此我可以使用ckeditor
它。
我已经使用了官方ckeditor
文档来安装和设置ckeditor,但是在我的文本区域中没有显示编辑器。
这是我使用的脚本
<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<script>
CKEDITOR.replace('article-ckeditor');
</script>
这是实现ckeditor
<div class="form-group">
{{Form::label('body', 'Body')}}
{{Form::textarea('body', $post->body, ['id' => 'article-ckeditor', 'class' => 'form-control', 'placeholder' => 'Body Text'])}}
</div>
在这里,我在控制台日志中发现了一些错误
Failed to load resource: the server responded with a status of 404 (Not Found) (ckeditor.js:1)
Uncaught ReferenceError: CKEDITOR is not defined at create:108
运行 php artisan vendor:publish --tag=ckeditor
命令后,我得到了更多新错误。
Uncaught TypeError: Cannot read property 'unselectable' of null (ckeditor.js:326 )
at b (ckeditor.js:326)
at a.<anonymous> (ckeditor.js:322)
at a.h (ckeditor.js:11)
at a.<anonymous> (ckeditor.js:13)
at a.window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:14)
at a.fireOnce (ckeditor.js:13)
at a.window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.editor.CKEDITOR.editor.fireOnce (ckeditor.js:14)
at Object.<anonymous> (ckeditor.js:252)
at g (ckeditor.js:233)
at Object.load (ckeditor.js:233)
我正在创建一个博客应用程序,因此我需要一个编辑器,但它无法正常工作,而且由于没有显示任何错误,因此无法解决。整个应用程序是该编辑器以外的工作属性。
从错误看来ckeditor.js
文件没有被加载。
UniSharp / laravel-ckeditor的官方文档说,您应该通过以下命令发布资源:
php artisan vendor:publish --tag=ckeditor
执行该命令后,您应该拥有以下文件:your_project_path/public/vendor/unisharp/laravel-ckeditor/ckeditor.js
。
更新:最后一个错误(Cannot read property 'unselectable' of null
)似乎是ckeditor的已知问题,默认为laravel app.js
,他们建议defer
从app.js
模板的行加载中删除app.blade.php
:
<script src="{{ asset('js/app.js') }}"></script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句