{{-- format-ignore-start --}} @props([ // name of the input field for use in forms 'name' => defaultBladewindName('textarea-'), 'rows' => config('bladewind.textarea.rows', 3), 'label' => '', 'required' => false, 'addClearing' => config('bladewind.textarea.add_clearing', true), 'placeholder' => '', // placeholder text 'selectedValue' => '', // message to display when validation fails for this field // this is just attached to the input field as a data attribute 'errorMessage' => '', // this is an easy way to pass a translatable heading to the notification component // since it is triggered from Javascript, it is hard to translate any text from within js 'errorHeading' => config('bladewind.textarea.error_heading', __("bladewind::bladewind.error_heading")), // how should error messages be displayed for this input // by default error messages are displayed in the Bladewind notification component // the component should exist on the page 'showErrorInline' => config('bladewind.textarea.show_error_inline', false), 'toolbar' => config('bladewind.textarea.toolbar', false), 'except' => '', 'nonce' => config('bladewind.script.nonce', null), ]) @php $addClearing = parseBladewindVariable($addClearing); $showErrorInline = parseBladewindVariable($showErrorInline); $required = parseBladewindVariable($required); $name = parseBladewindName($name); $required_symbol = ($label == '' && $required) ? ' *' : ''; $is_required = ($required) ? 'required' : ''; $placeholder_color = ($label !== '') ? 'placeholder-transparent dark:placeholder-transparent' : ''; @endphp {{-- format-ignore-end --}}
@if($toolbar)
@else @endif @if($errorMessage !== '') @endif @if($label !== '') @endif
@if($toolbar) @once {{-- --}} const toolbarOptions = ['bold', 'italic', 'underline', {'align': []}, {'indent': '-1'}, {'indent': '+1'}, 'link', {'color': []}, {'background': []}, {'list': 'ordered'}, {'list': 'bullet'}, {'list': 'check'}, 'image', 'blockquote', 'code-block', 'clean' ]; const modifyToolbarOptions = (toolbarOptions, except) => { except = except.replaceAll(' ', ''); const exceptArray = except.split(',').map(item => item.trim()); return toolbarOptions.filter(option => { if (typeof option === 'string') { return !exceptArray.includes(option); } else if (typeof option === 'object') { const key = Object.keys(option)[0]; return !exceptArray.includes(key); } return true; }); } const quillOptions = { theme: 'snow', placeholder: '{{ ($label !== '') ? $label : $placeholder }}', modules: { toolbar: '', }, }; @endonce if (typeof Quill === 'undefined') { console.log('Unable to load assets from https://quilljs.com'); } else { quillOptions.modules.toolbar = modifyToolbarOptions(toolbarOptions, '{{$except}}'); var quill_{{$name}} = new Quill('#{{$name}}', quillOptions); // Update the hidden input field whenever the textarea content changes quill_{{ $name }}.on('text-change', function (delta, oldDelta, source) { var value = quill_{{ $name }}.root.innerHTML; document.getElementById('{{ $name }}-hidden').value = value; }); // set the initial content for quill quill_{{ $name }}.root.innerHTML = @js($selectedValue); } @endif