tinyMCEだと、textareaで文字の装飾はもちろん画像の挿入ができる
### viewの作成
views/includes/tinyeditor.blade.php
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script> <script>tinymce.init({selector:'textarea'});</script>
posts/create.blade.php
@extends('layouts.admin') @section('content') @include('includes.tinyeditor') ...
### filemanager install
https://unisharp.github.io/laravel-filemanager/installation
$ php composer.phar require unisharp/laravel-filemanager
$ php composer.phar require intervention/image
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class, Intervention\Image\ImageServiceProvider::class, 'Image' => Intervention\Image\Facades\Image::class,
$ php artisan vendor:publish –tag=lfm_config
$ php artisan vendor:publish –tag=lfm_public
### tinyeditor.blade.php
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script> <script> var editor_config = { path_absolute : "/", selector: "textarea", plugins: [ "advlist autolink lists link image charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars code fullscreen", "insertdatetime media nonbreaking save table contextmenu directionality", "emoticons template paste textcolor colorpicker textpattern" ], toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media", relative_urls: false, file_browser_callback : function(field_name, url, type, win) { var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth; var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight; var cmsURL = editor_config.path_absolute + 'laravel-filemanager?field_name=' + field_name; if (type == 'image') { cmsURL = cmsURL + "&type=Images"; } else { cmsURL = cmsURL + "&type=Files"; } tinyMCE.activeEditor.windowManager.open({ file : cmsURL, title : 'Filemanager', width : x * 0.8, height : y * 0.8, resizable : "yes", close_previous : "no" }); } }; tinymce.init(editor_config); </script>
### config
lfm.php
'base_directory' => 'public', 'images_folder_name' => 'images',
### view
post.blade.php
<p>{!! $post->body !!}</p>
{{$post->body}}だと画像が表示されないので注意が必要
殆ど公式に書いてあるので、公式との闘いになりそう