thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.72k stars 2.67k forks source link

Adding Heading Formatter in TinyMCE Editor #5787

Closed joginder89 closed 10 months ago

joginder89 commented 10 months ago

Laravel version

9.19

PHP version

8

Voyager version

1.6

Database

MySQL

Description

I found there in no Heading (H1, H2) formatter in Editor. I found we can do it by adding a new file in config/voyager.php 's additional_js array, but when I try to add code in this file using tinymceOptions or tinymce_init_callback(editor) function then I get following error.

Whenever I try to add js/custom.js in public folder and updating tinymce config, it gives following error: The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information. Plugins: - textcolor

Is there any simple way for adding Heading formatter in TinyMCE editor?

Steps to reproduce

add any code to custom.js and then add this custom.js to config/voyager.php 's additional_js array

Expected behavior

Heading formatter should be visible in admin panel's editor.

Screenshots

No response

Additional context

No response

quangphi4190 commented 10 months ago

I solved this problem by directory vendor/tcg/voyager/resources/views/formfields copy file rich_text_box and create new folder form fields 1 located in folder /resources/views/vendor/voyager/formfields/formfields.blade.php

and then add toolbar: 'h1 h2 h3', Or the additional menu bar, h1 section,.. will be in section format

var additionalConfig = { selector: 'textarea.richTextBox[name="{{ $row->field }}"]', menubar: 'file edit view insert format tools table' toolbar: 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help | h1 h2 h3',

        }

        toolbar: add the necessary things..
joginder89 commented 10 months ago

@quangphi4190 Thank you It works for me. I copied the file vendor/tcg/voyager/resources/views/formfields/rich_text_box.blade.php to resources/views/vendor/voyager/formfields/rich_text_box.blade.php

and then update additionalConfig variable. It looks you wrote /resources/views/vendor/voyager/formfields/formfields.blade.php by mistake.

github-actions[bot] commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.