TinyMCE and Laravel

感情迁移 提交于 2020-05-13 09:03:35

问题


I'm trying to use tinyMCE with my Laravel project. The problem is when I store the new article the html tags are not working. They're showing up like a plain text on display on my laravel view:

enter image description here

This is the code implemented in create.blade.php:

<script type="text/javascript" src="{{ asset('/js/tinymce/tinymce.min.js') }}"></script>
<script type="text/javascript">
    tinymce.init({
        selector : "textarea",
        plugins : ["advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste jbimages"],
        toolbar : "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",
    });
</script>

回答1:


Markup is escaped by default in Laravel. If you're storing text in your database that contains markup, you will either want to apply a getter to your Eloquent Model that will unescape it for you, or use the following Blade syntax:

{!! $model->text !!}

When dealing with unescaped output, I would highly recommend limiting the tags that can be applied in your TinyMCE editor by using the valid_elements attribute.



来源:https://stackoverflow.com/questions/31224938/tinymce-and-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!