DEV Community 👩‍💻👨‍💻

Samson Adesanoye
Samson Adesanoye

Posted on

How to use TinyMCE In Your Custom Voyager View

TinyMCE is an online rich-text editor released as open-source software, its website describe it as the most advanced WYSIWYG HTML editor designed to simplify website content creation. It has the ability to convert HTML textarea fields or other HTML elements to editor instances. It is the default textarea fields editor used in Voyager (The Missing Laravel Admin).

Here are the steps in including TinyMCE in your custom voyager view:

  1. Create textarea field add the class richTextBox to the textarea. i.e
<textarea  class="form-control richTextBox" name="body" required>
{!!  old('body') !!}
 </textarea> 
Enter fullscreen mode Exit fullscreen mode

Here is an example commit to voyager source code where TinyMCE was implemented and you can draw some ideas from it.

  1. Customize the minimum height of TinyMCE: The default minimum height of TinyMCE in Voyager is 600 in height, and it is represented with the min_height variable.
var additionalConfig = {
      min_height: 100,
}

$.extend(additionalConfig, {!! json_encode($options->tinymceOptions ?? '{}') !!})

tinymce.init(window.voyagerTinyMCE.getConfig(additionalConfig));
Enter fullscreen mode Exit fullscreen mode

Source:

List of possible key and value

Top comments (0)

DEV

Thank you.

 
Thanks for visiting DEV, we’ve worked really hard to cultivate this great community and would love to have you join us. If you’d like to create an account, you can sign up here.