Lectures List

Use TinyMCE editor on livewire laravel project

Make sure you have created an account at tinymce

and you have Tinymce api key

then use tinymce CDN link at your webpage head section

Create component in laravel

php artisan make:component components/input

Add tinymce.blade.php at input folder

Paste this code on tinymce.blade.php

  x-data="{ value: @entangle($attributes->wire('model')) }"
          target: $refs.tinymce,
          themes: 'modern',
          height: 200,
          menubar: false,
          plugins: [
              'advlist autolink lists link image charmap print preview anchor',
              'searchreplace visualblocks code fullscreen',
              'insertdatetime media table paste code help wordcount'
          toolbar: 'undo redo | formatselect | ' +
              'bold italic backcolor | alignleft aligncenter ' +
              'alignright alignjustify | bullist numlist outdent indent | ' +
              'removeformat | help',
          setup: function(editor) {
              editor.on('blur', function(e) {
                  value = editor.getContent()
              editor.on('init', function (e) {
                  if (value != null) {
              function putCursorToEnd() {
                  editor.selection.select(editor.getBody(), true);
              $watch('value', function (newValue) {
                  if (newValue !== editor.getContent()) {
                      editor.resetContent(newValue || '');
          {{ $attributes->whereDoesntStartWith('wire:model') }}

use this component at the place of textarea input field, it automatically will create input field and enable tinymce on textarea.

<x-input.tinymce wire:model="editor" placeholder="Write post here..." />

Benefit of using this component

This component does not render automatically, we can use it as html editor.